diff options
-rw-r--r-- | usr.bin/less/command.c | 29 | ||||
-rw-r--r-- | usr.bin/less/forwback.c | 4 | ||||
-rw-r--r-- | usr.bin/less/less.nro | 53 | ||||
-rw-r--r-- | usr.bin/less/main.c | 16 | ||||
-rw-r--r-- | usr.bin/less/opttbl.c | 9 | ||||
-rw-r--r-- | usr.bin/less/output.c | 2 | ||||
-rw-r--r-- | usr.bin/less/prompt.c | 2 | ||||
-rw-r--r-- | usr.bin/less/screen.c | 21 |
8 files changed, 105 insertions, 31 deletions
diff --git a/usr.bin/less/command.c b/usr.bin/less/command.c index d1ff9946237..f91f71c712d 100644 --- a/usr.bin/less/command.c +++ b/usr.bin/less/command.c @@ -69,6 +69,9 @@ extern char *editor; extern char *editproto; #endif extern int screen_trashed; /* The screen has been overwritten */ +extern int be_helpful; + +public int helpprompt; static char ungot[100]; static char *ungotp = NULL; @@ -453,14 +456,23 @@ prompt() * Select the proper prompt and display it. */ clear_bot(); - p = pr_string(); - if (p == NULL) - putchr(':'); - else - { + if (helpprompt) { so_enter(); - putstr(p); + putstr("[Press 'h' for instructions.]"); so_exit(); + helpprompt = 0; + } else { + p = pr_string(); + if (p == NULL) + putchr(':'); + else + { + so_enter(); + putstr(p); + if (be_helpful) + putstr(" [Press space to continue, 'q' to quit.]"); + so_exit(); + } } } @@ -1246,7 +1258,10 @@ commands() break; default: - bell(); + if (be_helpful) + helpprompt = 1; + else + bell(); break; } } diff --git a/usr.bin/less/forwback.c b/usr.bin/less/forwback.c index 49664522f4c..bbafefcd0d9 100644 --- a/usr.bin/less/forwback.c +++ b/usr.bin/less/forwback.c @@ -42,6 +42,7 @@ extern int top_scroll; extern int quiet; extern int sc_width, sc_height; extern int quit_at_eof; +extern int less_mode; extern int plusoption; extern int forw_scroll; extern int back_scroll; @@ -350,8 +351,7 @@ forward(n, force, only_last) pos = position(BOTTOM_PLUS_ONE); } while (pos == NULL_POSITION); } - } else - { + } else { eof_bell(); hit_eof++; return; diff --git a/usr.bin/less/less.nro b/usr.bin/less/less.nro index e6be297fed7..b077de115c1 100644 --- a/usr.bin/less/less.nro +++ b/usr.bin/less/less.nro @@ -1,12 +1,12 @@ .TH LESS 1 .SH NAME -less \- opposite of more +less, more \- view files on a crt .SH SYNOPSIS -.B "less -?" +.B "less|more -?" .br -.B "less -V" +.B "less|more -V" .br -.B "less [-[+]aBcCdeEfgGiImMnNqQrsSuUVwX]" +.B "less|more [-[+]aBcCdeEfgGiImMnNqQrsSuUVwX]" .br .B " [-b \fIbufs\fP] [-h \fIlines\fP] [-j \fIline\fP] [-k \fIkeyfile\fP]" .br @@ -18,7 +18,7 @@ less \- opposite of more .SH DESCRIPTION .I Less -is a program similar to +is a program similar to the traditional .I more (1), but which allows backward movement in the file as well as forward movement. @@ -35,7 +35,16 @@ There is even limited support for hardcopy terminals. (On a hardcopy terminal, lines which should be printed at the top of the screen are prefixed with a caret.) .PP -Commands are based on both +This version of +.I less +also acts as +.I more +(1) if it is called as +.I more. +In this mode, the differences are in the prompt and that +.I more +exits by default when it gets to the end of the file. +Commands are based on both traditional .I more and .I vi. @@ -282,6 +291,9 @@ If a number N is specified, the N-th next file is examined. Examine the previous file in the command line list. If a number N is specified, the N-th previous file is examined. .PP +.IP ":t" +Go to supplied tag. +.PP .IP ":x" Examine the first file in the command line list. If a number N is specified, the N-th file in the list is examined. @@ -377,7 +389,11 @@ Most options may be changed while .I less is running, via the "\-" command. .PP -Options are also taken from the environment variable "LESS". +Options are also taken from the environment variable "LESS" if the +command is +.I less +, or from the environment variable "MORE" if the command is +.I more. For example, to avoid typing "less -options ..." each time .I less @@ -439,13 +455,12 @@ full screen repaints are done by scrolling from the bottom of the screen. .IP -C The -C option is like -c, but the screen is cleared before it is repainted. .IP -d -The -d option suppresses the error message -normally displayed if the terminal is dumb; -that is, lacks some important capability, -such as the ability to clear the screen or scroll backward. -The -d option does not otherwise change the behavior of -.I less -on a dumb terminal). +The -d option causes the default prompt to include the basic directions +``[Press space to continue, 'q' to quit.]''. The -d +option also causes the message ``[Press 'h' for instructions.]'' to be +displayed when an invalid command is entered (normally, the bell is +rung). This option is useful in environments where users may not be +experienced with pagers. .IP -D\fBx\fP\fIcolor\fP [MS-DOS only] Sets the color of the text displayed. @@ -462,7 +477,11 @@ to automatically exit the second time it reaches end-of-file. By default, the only way to exit .I less -is via the "q" command. +is via the "q" command, except in +.I more +mode, where +.I less +will exit at the end of a file. .IP -E Causes .I less @@ -1182,6 +1201,10 @@ Language for determining the character set. Flags which are passed to .I less automatically. +.IP MORE +Flags which are passed to +.I more +automatically. .IP LESSBINFMT Format for displaying non-printable, non-control characters. .IP LESSCHARDEF diff --git a/usr.bin/less/main.c b/usr.bin/less/main.c index ae4271056c6..b247fe2e9cb 100644 --- a/usr.bin/less/main.c +++ b/usr.bin/less/main.c @@ -42,6 +42,7 @@ public int any_display = FALSE; public int wscroll; public char * progname; public int quitting; +public int more_mode = 0; extern int quit_at_eof; extern int cbufs; @@ -77,6 +78,7 @@ main(argc, argv) char *argv[]; { IFILE ifile; + extern char *__progname; #ifdef __EMX__ _response(&argc, &argv); @@ -89,12 +91,22 @@ main(argc, argv) * Process command line arguments and LESS environment arguments. * Command line arguments override environment arguments. */ + if (strcmp(__progname, "more") == 0) + more_mode = 1; + get_term(); init_cmds(); init_prompt(); init_charset(); init_option(); - scan_option(getenv("LESS")); + + if (more_mode) { + scan_option("-E"); + scan_option("-m"); + scan_option("-G"); + scan_option(getenv("MORE")); + } else + scan_option(getenv("LESS")); #if GNU_OPTIONS /* @@ -319,7 +331,7 @@ quit(status) save_status = status; quitting = 1; edit((char*)NULL); - if (any_display) + if (is_tty && any_display) clear_bot(); deinit(); flush(); diff --git a/usr.bin/less/opttbl.c b/usr.bin/less/opttbl.c index 69e9faf2b0a..2e9ad23cddc 100644 --- a/usr.bin/less/opttbl.c +++ b/usr.bin/less/opttbl.c @@ -43,6 +43,7 @@ public int pr_type; /* Type of prompt (short, medium, long) */ public int bs_mode; /* How to process backspaces */ public int know_dumb; /* Don't complain about dumb terminals */ public int quit_at_eof; /* Quit after hitting end of file twice */ +public int be_helpful; /* more(1) style -d */ public int squeeze; /* Squeeze multiple blank lines into one */ public int tabstop; /* Tab settings */ public int back_scroll; /* Repaint screen on backwards movement */ @@ -88,11 +89,19 @@ static struct option option[] = "Repaint by clearing each line", "Repaint by painting from top of screen" }, +#if 0 { 'd', BOOL|NO_TOGGLE, OPT_OFF, &know_dumb, NULL, "Assume intelligent terminal", "Assume dumb terminal", NULL }, +#else + { 'd', BOOL, OPT_OFF, &be_helpful, NULL, + "Be helpful in prompts", + "Be less helpful in prompts", + NULL, + }, +#endif #if MSOFTC { 'D', STRING|REPAINT, 0, NULL, opt_D, "color desc: ", NULL, NULL diff --git a/usr.bin/less/output.c b/usr.bin/less/output.c index dbe180073a5..95b2131580a 100644 --- a/usr.bin/less/output.c +++ b/usr.bin/less/output.c @@ -292,6 +292,8 @@ error(fmt, parg) bell(); #else c = getchr(); + if (c == 'q') + quit(QUIT_OK); if (c != '\n' && c != '\r' && c != ' ' && c != READ_INTR) ungetcc(c); #endif diff --git a/usr.bin/less/prompt.c b/usr.bin/less/prompt.c index 59468f0c58b..2e0b62cc6bf 100644 --- a/usr.bin/less/prompt.c +++ b/usr.bin/less/prompt.c @@ -57,7 +57,7 @@ extern char *editor; static char s_proto[] = "?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\\: %x..%t"; static char m_proto[] = - "?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\\: %x.:?pB%pB\\%:byte %bB?s/%s...%t"; + "?f%f .?m(file %i of %m) .?e(END) ?x- Next\\: %x.:(?pB%pB\\%:byte %bB?s/%s..).%t"; static char M_proto[] = "?f%f .?n?m(file %i of %m) ..?ltline %lt?L/%L. :byte %bB?s/%s. .?e(END) ?x- Next\\: %x.:?pB%pB\\%..%t"; static char e_proto[] = diff --git a/usr.bin/less/screen.c b/usr.bin/less/screen.c index 95082ac6432..8340dd408a9 100644 --- a/usr.bin/less/screen.c +++ b/usr.bin/less/screen.c @@ -136,6 +136,8 @@ extern int know_dumb; /* Don't complain about a dumb terminal */ extern int back_scroll; extern int swindow; extern int no_init; +extern int quit_at_eof; +extern int more_mode; #if HILITE_SEARCH extern int hilite_search; #endif @@ -412,9 +414,10 @@ cannot(s) { PARG parg; - if (know_dumb) + if (know_dumb || more_mode) /* * User knows this is a dumb terminal, so don't tell him. + * more doesn't complain about these, either. */ return; @@ -755,11 +758,17 @@ get_term() if (sc_e_keypad == NULL) sc_e_keypad = ""; - sc_init = tgetstr("ti", &sp); + /* + * This loses for terminals with termcap entries with ti/te strings + * that switch to/from an alternate screen, and we're in quit_at_eof + * (eg, more(1)). + */ + if (!quit_at_eof && !more_mode) { + sc_init = tgetstr("ti", &sp); + sc_deinit = tgetstr("te", &sp); + } if (sc_init == NULL) sc_init = ""; - - sc_deinit= tgetstr("te", &sp); if (sc_deinit == NULL) sc_deinit = ""; @@ -982,7 +991,9 @@ init() if (no_init) return; tputs(sc_init, sc_height, putchr); +#if 0 tputs(sc_s_keypad, sc_height, putchr); +#endif init_done = 1; } @@ -996,7 +1007,9 @@ deinit() return; if (!init_done) return; +#if 0 tputs(sc_e_keypad, sc_height, putchr); +#endif tputs(sc_deinit, sc_height, putchr); init_done = 0; } |