summaryrefslogtreecommitdiffstats
path: root/contrib/less/command.c
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2007-06-04 01:43:11 +0000
committerdelphij <delphij@FreeBSD.org>2007-06-04 01:43:11 +0000
commit2908bdb1f10f819d2713971e094aa9719b317184 (patch)
tree81e259b4b8551856ddf7763cc779172378fe60dc /contrib/less/command.c
parent9b5d103b5b51a6fea5caf2c8b1fc678d65a357c9 (diff)
downloadFreeBSD-src-2908bdb1f10f819d2713971e094aa9719b317184.zip
FreeBSD-src-2908bdb1f10f819d2713971e094aa9719b317184.tar.gz
Resolve conflicts.
Diffstat (limited to 'contrib/less/command.c')
-rw-r--r--contrib/less/command.c51
1 files changed, 38 insertions, 13 deletions
diff --git a/contrib/less/command.c b/contrib/less/command.c
index 18ea4d4..bac2431 100644
--- a/contrib/less/command.c
+++ b/contrib/less/command.c
@@ -1,6 +1,6 @@
/* $FreeBSD$ */
/*
- * 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.
@@ -24,7 +24,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;
@@ -39,7 +38,7 @@ extern int ignore_eoi;
extern int secure;
extern int hshift;
extern int show_attn;
-extern int more_mode;
+extern int less_is_more;
extern char *every_first_cmd;
extern char *curr_altfilename;
extern char version[];
@@ -56,6 +55,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;
@@ -65,6 +66,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;
@@ -77,7 +79,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.
*/
@@ -85,7 +87,7 @@ static void multi_search();
cmd_exec()
{
clear_attn();
- lower_left();
+ line_left();
flush();
}
@@ -100,6 +102,7 @@ start_mca(action, prompt, mlist, cmdflags)
int cmdflags;
{
mca = action;
+ clear_bot();
clear_cmd();
cmd_putstr(prompt);
set_mlist(mlist, cmdflags);
@@ -122,6 +125,7 @@ mca_search()
else
mca = A_B_SEARCH;
+ clear_bot();
clear_cmd();
if (search_type & SRCH_NO_MATCH)
@@ -157,6 +161,7 @@ mca_opt_toggle()
dash = (flag == OPT_NO_TOGGLE) ? "_" : "-";
mca = A_OPT_TOGGLE;
+ clear_bot();
clear_cmd();
cmd_putstr(dash);
if (optgetname)
@@ -293,14 +298,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);
@@ -482,13 +487,13 @@ mca_char(c)
switch (c)
{
case '*':
- if (more_mode)
+ if (less_is_more)
break;
case CONTROL('E'): /* ignore END of file */
flag = SRCH_PAST_EOF;
break;
case '@':
- if (more_mode)
+ if (less_is_more)
break;
case CONTROL('F'): /* FIRST file */
flag = SRCH_FIRST_FILE;
@@ -612,7 +617,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);
@@ -622,7 +627,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
@@ -637,7 +642,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(':');
@@ -647,6 +665,7 @@ prompt()
putstr(p);
at_exit();
}
+ clear_eol();
}
/*
@@ -1167,11 +1186,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:
@@ -1392,7 +1417,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) " : "";
OpenPOWER on IntegriCloud