aboutsummaryrefslogtreecommitdiff
path: root/contrib/less/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/less/command.c')
-rw-r--r--contrib/less/command.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/contrib/less/command.c b/contrib/less/command.c
index 7c0d60b119cf..da0f3ead6747 100644
--- a/contrib/less/command.c
+++ b/contrib/less/command.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2005 Mark Nudelman
+ * Copyright (C) 1984-2007 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
@@ -23,7 +23,6 @@
extern int erase_char, erase2_char, kill_char;
extern int sigs;
-extern int quit_at_eof;
extern int quit_if_one_screen;
extern int squished;
extern int hit_eof;
@@ -54,6 +53,8 @@ extern char *editproto;
#endif
extern int screen_trashed; /* The screen has been overwritten */
extern int shift_count;
+extern int oldbot;
+extern int forw_prompt;
static char ungot[UNGOT_SIZE];
static char *ungotp = NULL;
@@ -63,6 +64,7 @@ static char *shellcmd = NULL; /* For holding last shell command for "!!" */
static int mca; /* The multicharacter command (action) */
static int search_type; /* The previous type of search */
static LINENUM number; /* The number typed by the user */
+static long fraction; /* The fractional part of the number */
static char optchar;
static int optflag;
static int optgetname;
@@ -75,7 +77,7 @@ static char pipec;
static void multi_search();
/*
- * Move the cursor to lower left before executing a command.
+ * Move the cursor to start of prompt line before executing a command.
* This looks nicer if the command takes a long time before
* updating the screen.
*/
@@ -83,7 +85,7 @@ static void multi_search();
cmd_exec()
{
clear_attn();
- lower_left();
+ line_left();
flush();
}
@@ -98,6 +100,7 @@ start_mca(action, prompt, mlist, cmdflags)
int cmdflags;
{
mca = action;
+ clear_bot();
clear_cmd();
cmd_putstr(prompt);
set_mlist(mlist, cmdflags);
@@ -120,6 +123,7 @@ mca_search()
else
mca = A_B_SEARCH;
+ clear_bot();
clear_cmd();
if (search_type & SRCH_NO_MATCH)
@@ -155,6 +159,7 @@ mca_opt_toggle()
dash = (flag == OPT_NO_TOGGLE) ? "_" : "-";
mca = A_OPT_TOGGLE;
+ clear_bot();
clear_cmd();
cmd_putstr(dash);
if (optgetname)
@@ -291,14 +296,14 @@ mca_char(c)
* Entering digits of a number.
* Terminated by a non-digit.
*/
- if ((c < '0' || c > '9') &&
+ if (!((c >= '0' && c <= '9') || c == '.') &&
editchar(c, EC_PEEK|EC_NOHISTORY|EC_NOCOMPLETE|EC_NORIGHTLEFT) == A_INVALID)
{
/*
* Not part of the number.
* Treat as a normal command character.
*/
- number = cmd_int();
+ number = cmd_int(&fraction);
mca = 0;
cmd_accept();
return (NO_MCA);
@@ -606,7 +611,7 @@ prompt()
* {{ Relying on "first prompt" to detect a single-screen file
* fails if +G is used, for example. }}
*/
- if ((quit_at_eof == OPT_ONPLUS || quit_if_one_screen) &&
+ if ((get_quit_at_eof() == OPT_ONPLUS || quit_if_one_screen) &&
hit_eof && !(ch_getflags() & CH_HELPFILE) &&
next_ifile(curr_ifile) == NULL_IFILE)
quit(QUIT_OK);
@@ -616,7 +621,7 @@ prompt()
* If the -e flag is set and we've hit EOF on the last file,
* and the file is squished (shorter than the screen), quit.
*/
- if (quit_at_eof && squished &&
+ if (get_quit_at_eof() && squished &&
next_ifile(curr_ifile) == NULL_IFILE)
quit(QUIT_OK);
#endif
@@ -631,7 +636,20 @@ prompt()
/*
* Select the proper prompt and display it.
*/
+ /*
+ * If the previous action was a forward movement,
+ * don't clear the bottom line of the display;
+ * just print the prompt since the forward movement guarantees
+ * that we're in the right position to display the prompt.
+ * Clearing the line could cause a problem: for example, if the last
+ * line displayed ended at the right screen edge without a newline,
+ * then clearing would clear the last displayed line rather than
+ * the prompt line.
+ */
+ if (!forw_prompt)
+ clear_bot();
clear_cmd();
+ forw_prompt = 0;
p = pr_string();
if (p == NULL || *p == '\0')
putchr(':');
@@ -641,6 +659,7 @@ prompt()
putstr(p);
at_exit();
}
+ clear_eol();
}
/*
@@ -1161,11 +1180,17 @@ commands()
* Go to a specified percentage into the file.
*/
if (number < 0)
+ {
number = 0;
+ fraction = 0;
+ }
if (number > 100)
+ {
number = 100;
+ fraction = 0;
+ }
cmd_exec();
- jump_percent((int) number);
+ jump_percent((int) number, fraction);
break;
case A_GOEND:
@@ -1386,7 +1411,7 @@ commands()
number = 1;
if (edit_next((int) number))
{
- if (quit_at_eof && hit_eof &&
+ if (get_quit_at_eof() && hit_eof &&
!(ch_getflags() & CH_HELPFILE))
quit(QUIT_OK);
parg.p_string = (number > 1) ? "(N-th) " : "";