Resolve conflicts.

This commit is contained in:
delphij 2006-08-20 15:50:51 +00:00
parent a77e94924d
commit 5d60487351
9 changed files with 915 additions and 537 deletions

View File

@ -1,6 +1,6 @@
/* $FreeBSD$ */
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2005 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.
@ -22,7 +22,7 @@
#include "option.h"
#include "cmd.h"
extern int erase_char, kill_char;
extern int erase_char, erase2_char, kill_char;
extern int sigs;
extern int quit_at_eof;
extern int quit_if_one_screen;
@ -69,6 +69,7 @@ static char optchar;
static int optflag;
static int optgetname;
static POSITION bottompos;
static int save_hshift;
#if PIPEC
static char pipec;
#endif
@ -394,7 +395,9 @@ mca_char(c)
* Already have a match for the name.
* Don't accept anything but erase/kill.
*/
if (c == erase_char || c == kill_char)
if (c == erase_char ||
c == erase2_char ||
c == kill_char)
return (MCA_DONE);
return (MCA_MORE);
}
@ -405,7 +408,7 @@ mca_char(c)
if (cmd_char(c) == CC_QUIT)
return (MCA_DONE);
p = get_cmdbuf();
lc = islower(p[0]);
lc = ASCII_IS_LOWER(p[0]);
o = findopt_name(&p, &oname, NULL);
if (o != NULL)
{
@ -415,15 +418,15 @@ mca_char(c)
* display the full option name.
*/
optchar = o->oletter;
if (!lc && islower(optchar))
optchar = toupper(optchar);
if (!lc && ASCII_IS_LOWER(optchar))
optchar = ASCII_TO_UPPER(optchar);
cmd_reset();
mca_opt_toggle();
for (p = oname; *p != '\0'; p++)
{
c = *p;
if (!lc && islower(c))
c = toupper(c);
if (!lc && ASCII_IS_LOWER(c))
c = ASCII_TO_UPPER(c);
if (cmd_char(c) != CC_OK)
return (MCA_DONE);
}
@ -432,7 +435,7 @@ mca_char(c)
}
} else
{
if (c == erase_char || c == kill_char)
if (c == erase_char || c == erase2_char || c == kill_char)
break;
if (optchar != '\0')
/* We already have the option letter. */
@ -604,7 +607,10 @@ prompt()
bottompos = position(BOTTOM_PLUS_ONE);
/*
* If the -E flag is set and we've hit EOF on the last file, quit.
* If we've hit EOF on the last file, and the -E flag is set
* (or -F is set and this is the first prompt), then quit.
* {{ 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) &&
hit_eof && !(ch_getflags() & CH_HELPFILE) &&
@ -633,13 +639,13 @@ prompt()
*/
clear_cmd();
p = pr_string();
if (p == NULL)
if (p == NULL || *p == '\0')
putchr(':');
else
{
so_enter();
at_enter(AT_STANDOUT);
putstr(p);
so_exit();
at_exit();
}
}
@ -832,6 +838,9 @@ multi_search(pattern, n)
* Restore the file we were originally viewing.
*/
reedit_ifile(save_ifile);
} else
{
unsave_ifile(save_ifile);
}
}
@ -1217,6 +1226,7 @@ commands()
* just means return to viewing the
* previous file.
*/
hshift = save_hshift;
if (edit_prev(1) == 0)
break;
}
@ -1306,6 +1316,8 @@ commands()
if (ch_getflags() & CH_HELPFILE)
break;
cmd_exec();
save_hshift = hshift;
hshift = 0;
(void) edit(FAKE_HELPFILE);
break;
@ -1346,9 +1358,8 @@ commands()
}
if (curr_altfilename != NULL)
{
error("Cannot edit file processed with LESSOPEN",
error("WARNING: This file was viewed via LESSOPEN",
NULL_PARG);
break;
}
start_mca(A_SHELL, "!", ml_shell, 0);
/*
@ -1530,8 +1541,8 @@ commands()
break;
start_mca(A_SETMARK, "mark: ", (void*)NULL, 0);
c = getcc();
if (c == erase_char || c == kill_char ||
c == '\n' || c == '\r')
if (c == erase_char || c == erase2_char ||
c == kill_char || c == '\n' || c == '\r')
break;
setmark(c);
break;
@ -1542,8 +1553,8 @@ commands()
*/
start_mca(A_GOMARK, "goto mark: ", (void*)NULL, 0);
c = getcc();
if (c == erase_char || c == kill_char ||
c == '\n' || c == '\r')
if (c == erase_char || c == erase2_char ||
c == kill_char || c == '\n' || c == '\r')
break;
gomark(c);
break;
@ -1557,7 +1568,7 @@ commands()
}
start_mca(A_PIPE, "|mark: ", (void*)NULL, 0);
c = getcc();
if (c == erase_char || c == kill_char)
if (c == erase_char || c == erase2_char || c == kill_char)
break;
if (c == '\n' || c == '\r')
c = '.';

View File

@ -1,6 +1,6 @@
/* $FreeBSD$ */
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2005 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.
@ -126,13 +126,6 @@ forw(n, pos, force, only_last, nblank)
if (!do_repaint)
{
/*
* Forget any current line shift we might have
* (from the last line of the previous screenful).
*/
extern int cshift;
cshift = 0;
if (top_scroll && n >= sc_height - 1 && pos != ch_length())
{
/*
@ -146,7 +139,7 @@ forw(n, pos, force, only_last, nblank)
force = 1;
if (more_mode == 0)
{
if (top_scroll == OPT_ONPLUS || first_time)
if (top_scroll == OPT_ONPLUS || (first_time && top_scroll != OPT_ON))
clear();
home();
}
@ -246,7 +239,7 @@ forw(n, pos, force, only_last, nblank)
if (top_scroll == OPT_ON)
clear_eol();
put_line();
if (clear_bg && final_attr != AT_NORMAL)
if (clear_bg && apply_at_specials(final_attr) != AT_NORMAL)
{
/*
* Writing the last character on the last line

View File

@ -1,6 +1,6 @@
/* $FreeBSD$ */
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2005 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.
@ -80,13 +80,21 @@
#if HAVE_STRING_H
#include <string.h>
#endif
/* OS-specific includes */
#ifdef _OSK
#include <modes.h>
#include <strings.h>
#endif
#ifdef __TANDEM
#include <floss.h>
#endif
#if MSDOS_COMPILER==WIN32C || OS2
#include <io.h>
#endif
#if MSDOS_COMPILER==DJGPPC
#include <io.h>
#include <sys/exceptn.h>
@ -105,16 +113,40 @@ void free();
* Simple lowercase test which can be used during option processing
* (before options are parsed which might tell us what charset to use).
*/
#define SIMPLE_IS_UPPER(c) ((c) >= 'A' && (c) <= 'Z')
#define SIMPLE_IS_LOWER(c) ((c) >= 'a' && (c) <= 'z')
#define SIMPLE_TO_UPPER(c) ((c) - 'a' + 'A')
#define SIMPLE_TO_LOWER(c) ((c) - 'A' + 'a')
#define ASCII_IS_UPPER(c) ((c) >= 'A' && (c) <= 'Z')
#define ASCII_IS_LOWER(c) ((c) >= 'a' && (c) <= 'z')
#define ASCII_TO_UPPER(c) ((c) - 'a' + 'A')
#define ASCII_TO_LOWER(c) ((c) - 'A' + 'a')
#undef IS_UPPER
#undef IS_LOWER
#undef TO_UPPER
#undef TO_LOWER
#undef IS_SPACE
#undef IS_DIGIT
#if !HAVE_UPPER_LOWER
#define isupper(c) SIMPLE_IS_UPPER(c)
#define islower(c) SIMPLE_IS_LOWER(c)
#define toupper(c) SIMPLE_TO_UPPER(c)
#define tolower(c) SIMPLE_TO_LOWER(c)
#define IS_UPPER(c) ASCII_IS_UPPER(c)
#define IS_LOWER(c) ASCII_IS_LOWER(c)
#define TO_UPPER(c) ASCII_TO_UPPER(c)
#define TO_LOWER(c) ASCII_TO_LOWER(c)
#else
#define IS_UPPER(c) isupper((unsigned char) (c))
#define IS_LOWER(c) islower((unsigned char) (c))
#define TO_UPPER(c) toupper((unsigned char) (c))
#define TO_LOWER(c) tolower((unsigned char) (c))
#endif
#ifdef isspace
#define IS_SPACE(c) isspace((unsigned char)(c))
#else
#define IS_SPACE(c) ((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r' || (c) == '\f')
#endif
#ifdef isdigit
#define IS_DIGIT(c) isdigit((unsigned char)(c))
#else
#define IS_DIGIT(c) ((c) >= '0' && (c) <= '9')
#endif
#ifndef NULL
@ -138,6 +170,19 @@ void free();
#endif
#endif
#if HAVE_SNPRINTF
#define SNPRINTF1(str, size, fmt, v1) snprintf((str), (size), (fmt), (v1))
#define SNPRINTF2(str, size, fmt, v1, v2) snprintf((str), (size), (fmt), (v1), (v2))
#define SNPRINTF3(str, size, fmt, v1, v2, v3) snprintf((str), (size), (fmt), (v1), (v2), (v3))
#define SNPRINTF4(str, size, fmt, v1, v2, v3, v4) snprintf((str), (size), (fmt), (v1), (v2), (v3), (v4))
#else
/* Use unsafe sprintf if we don't have snprintf. */
#define SNPRINTF1(str, size, fmt, v1) sprintf((str), (fmt), (v1))
#define SNPRINTF2(str, size, fmt, v1, v2) sprintf((str), (fmt), (v1), (v2))
#define SNPRINTF3(str, size, fmt, v1, v2, v3) sprintf((str), (fmt), (v1), (v2), (v3))
#define SNPRINTF4(str, size, fmt, v1, v2, v3, v4) sprintf((str), (fmt), (v1), (v2), (v3), (v4))
#endif
#define BAD_LSEEK ((off_t)-1)
#ifndef CHAR_BIT
@ -154,9 +199,11 @@ void free();
/*
* Special types and constants.
*/
typedef unsigned long LWCHAR;
typedef off_t POSITION;
typedef off_t LINENUM;
#define MIN_LINENUM_WIDTH 7 /* Min printing width of a line number */
#define MAX_UTF_CHAR_LEN 6 /* Max bytes in one UTF-8 char */
#define NULL_POSITION ((POSITION)(-1))
@ -265,14 +312,14 @@ struct textlist
#define BS_CONTROL 2 /* \b treated as control char; prints as ^H */
/* How should we search? */
#define SRCH_FORW 000001 /* Search forward from current position */
#define SRCH_BACK 000002 /* Search backward from current position */
#define SRCH_NO_MOVE 000004 /* Highlight, but don't move */
#define SRCH_FIND_ALL 000010 /* Find and highlight all matches */
#define SRCH_NO_MATCH 000100 /* Search for non-matching lines */
#define SRCH_PAST_EOF 000200 /* Search past end-of-file, into next file */
#define SRCH_FIRST_FILE 000400 /* Search starting at the first file */
#define SRCH_NO_REGEX 001000 /* Don't use regular expressions */
#define SRCH_FORW (1 << 0) /* Search forward from current position */
#define SRCH_BACK (1 << 1) /* Search backward from current position */
#define SRCH_NO_MOVE (1 << 2) /* Highlight, but don't move */
#define SRCH_FIND_ALL (1 << 4) /* Find and highlight all matches */
#define SRCH_NO_MATCH (1 << 8) /* Search for non-matching lines */
#define SRCH_PAST_EOF (1 << 9) /* Search past end-of-file, into next file */
#define SRCH_FIRST_FILE (1 << 10) /* Search starting at the first file */
#define SRCH_NO_REGEX (1 << 12) /* Don't use regular expressions */
#define SRCH_REVERSE(t) (((t) & SRCH_FORW) ? \
(((t) & ~SRCH_FORW) | SRCH_BACK) : \
@ -290,13 +337,15 @@ struct textlist
#define CF_QUIT_ON_ERASE 0001 /* Abort cmd if its entirely erased */
/* Special chars used to tell put_line() to do something special */
/* Special char bit-flags used to tell put_line() to do something special */
#define AT_NORMAL (0)
#define AT_UNDERLINE (1)
#define AT_BOLD (2)
#define AT_BLINK (3)
#define AT_INVIS (4)
#define AT_STANDOUT (5)
#define AT_UNDERLINE (1 << 0)
#define AT_BOLD (1 << 1)
#define AT_BLINK (1 << 2)
#define AT_STANDOUT (1 << 3)
#define AT_ANSI (1 << 4) /* Content-supplied "ANSI" escape sequence */
#define AT_BINARY (1 << 5) /* LESS*BINFMT representation */
#define AT_HILITE (1 << 6) /* Internal highlights (e.g., for search) */
#if '0' == 240
#define IS_EBCDIC_HOST 1

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/* $FreeBSD$ */
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2004 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.
@ -120,6 +120,7 @@ main(argc, argv)
init_prompt();
init_charset();
init_line();
init_cmdhist();
init_option();
if (more_mode) {
@ -350,14 +351,14 @@ sprefix(ps, s, uppercase)
c = *ps;
if (uppercase)
{
if (len == 0 && SIMPLE_IS_LOWER(c))
if (len == 0 && ASCII_IS_LOWER(c))
return (-1);
if (SIMPLE_IS_UPPER(c))
c = SIMPLE_TO_LOWER(c);
if (ASCII_IS_UPPER(c))
c = ASCII_TO_LOWER(c);
}
sc = *s;
if (len > 0 && SIMPLE_IS_UPPER(sc))
sc = SIMPLE_TO_LOWER(sc);
if (len > 0 && ASCII_IS_UPPER(sc))
sc = ASCII_TO_LOWER(sc);
if (c != sc)
break;
len++;
@ -384,6 +385,7 @@ quit(status)
save_status = status;
quitting = 1;
edit((char*)NULL);
save_cmdhist();
if (any_display && is_tty)
clear_bot();
deinit();

View File

@ -1,6 +1,6 @@
/* $FreeBSD$ */
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2004 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.
@ -165,7 +165,7 @@ curr_byte(where)
POSITION pos;
pos = position(where);
while (pos == NULL_POSITION && where >= 0 && where < sc_height)
while (pos == NULL_POSITION && where >= 0 && where < sc_height-1)
pos = position(++where);
if (pos == NULL_POSITION)
pos = ch_length();
@ -201,7 +201,7 @@ cond(c, where)
case 'd': /* Same as l */
return (linenums);
case 'L': /* Final line number known? */
case 'D': /* Same as L */
case 'D': /* Final page number known? */
return (linenums && ch_length() != NULL_POSITION);
case 'm': /* More than one file? */
#if TAGS
@ -255,6 +255,9 @@ protochar(c, where, iseditproto)
LINENUM last_linenum;
IFILE h;
#undef PAGE_NUM
#define PAGE_NUM(linenum) ((((linenum) - 1) / (sc_height - 1)) + 1)
switch (c)
{
case 'b': /* Current byte offset */
@ -270,17 +273,26 @@ protochar(c, where, iseditproto)
case 'd': /* Current page number */
linenum = currline(where);
if (linenum > 0 && sc_height > 1)
ap_linenum(((linenum - 1) / (sc_height - 1)) + 1);
ap_linenum(PAGE_NUM(linenum));
else
ap_quest();
break;
case 'D': /* Last page number */
case 'D': /* Final page number */
/* Find the page number of the last byte in the file (len-1). */
len = ch_length();
if (len == NULL_POSITION || len == ch_zero() ||
(linenum = find_linenum(len)) <= 0)
if (len == NULL_POSITION)
ap_quest();
else if (len == 0)
/* An empty file has no pages. */
ap_linenum(0);
else
{
linenum = find_linenum(len - 1);
if (linenum <= 0)
ap_quest();
else
ap_linenum(((linenum - 1) / (sc_height - 1)) + 1);
ap_linenum(PAGE_NUM(linenum));
}
break;
#if EDITOR
case 'E': /* Editor name */
@ -519,7 +531,7 @@ pr_expand(proto, maxwidth)
}
if (mp == message)
return (NULL);
return ("");
if (maxwidth > 0 && mp >= message + maxwidth)
{
/*

View File

@ -1,6 +1,6 @@
/* $FreeBSD$ */
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2005 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.
@ -39,11 +39,12 @@ extern int fd0;
#else
#if HAVE_TERMIOS_H && HAVE_TERMIOS_FUNCS
#include <termios.h>
#if HAVE_SYS_IOCTL_H && !defined(TIOCGWINSZ)
#if HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#if HAVE_TERMIOS_H && HAVE_TERMIOS_FUNCS
#include <termios.h>
#else
#if HAVE_TERMIO_H
#include <termio.h>
@ -53,9 +54,6 @@ extern int fd0;
#else
#include <sgtty.h>
#endif
#if HAVE_SYS_IOCTL_H && (defined(TIOCGWINSZ) || defined(TCGETA) || defined(TIOCGETP) || defined(WIOCGETD))
#include <sys/ioctl.h>
#endif
#endif
#endif
@ -190,7 +188,9 @@ static int init_done = 0;
public int auto_wrap; /* Terminal does \r\n when write past margin */
public int ignaw; /* Terminal ignores \n immediately after wrap */
public int erase_char, kill_char; /* The user's erase and line-kill chars */
public int erase_char; /* The user's erase char */
public int erase2_char; /* The user's other erase char */
public int kill_char; /* The user's line-kill char */
public int werase_char; /* The user's word-erase char */
public int sc_width, sc_height; /* Height & width of screen */
public int bo_s_width, bo_e_width; /* Printing width of boldface seq */
@ -203,6 +203,7 @@ public int clear_bg; /* Clear fills with background color */
public int missing_cap = 0; /* Some capability is missing */
static int attrmode = AT_NORMAL;
extern int binattr;
#if !MSDOS_COMPILER
static char *cheaper();
@ -233,6 +234,7 @@ extern int sigs;
extern int wscroll;
extern int screen_trashed;
extern int tty;
extern int top_scroll;
#if HILITE_SEARCH
extern int hilite_search;
#endif
@ -260,6 +262,7 @@ raw_mode(on)
if (on == curr_on)
return;
erase2_char = '\b'; /* in case OS doesn't know about erase2 */
#if HAVE_TERMIOS_H && HAVE_TERMIOS_FUNCS
{
struct termios s;
@ -342,6 +345,9 @@ raw_mode(on)
}
#endif
erase_char = s.c_cc[VERASE];
#ifdef VERASE2
erase2_char = s.c_cc[VERASE2];
#endif
kill_char = s.c_cc[VKILL];
#ifdef VWERASE
werase_char = s.c_cc[VWERASE];
@ -1212,7 +1218,7 @@ get_term()
if (below_mem && (sc_eos_clear == NULL || *sc_eos_clear == '\0'))
{
missing_cap = 1;
sc_eol_clear = "";
sc_eos_clear = "";
}
sc_clear = ltgetstr("cl", &sp);
@ -1516,6 +1522,19 @@ init()
tputs(sc_init, sc_height, putchr);
if (!no_keypad)
tputs(sc_s_keypad, sc_height, putchr);
if (top_scroll)
{
int i;
/*
* This is nice to terminals with no alternate screen,
* but with saved scrolled-off-the-top lines. This way,
* no previous line is lost, but we start with a whole
* screen to ourself.
*/
for (i = 1; i < sc_height; i++)
putchr('\n');
}
#else
#if MSDOS_COMPILER==WIN32C
if (!no_init)
@ -1857,12 +1876,12 @@ create_flash()
videopages = w.numvideopages;
if (videopages < 2)
{
so_enter();
so_exit();
at_enter(AT_STANDOUT);
at_exit();
} else
{
_setactivepage(1);
so_enter();
at_enter(AT_STANDOUT);
blanks = (char *) ecalloc(w.numtextcols, sizeof(char));
for (col = 0; col < w.numtextcols; col++)
blanks[col] = ' ';
@ -1871,7 +1890,7 @@ create_flash()
_setactivepage(0);
_setvisualpage(0);
free(blanks);
so_exit();
at_exit();
}
#else
#if MSDOS_COMPILER==BORLANDC
@ -2101,153 +2120,111 @@ clear_bot()
* cleared area with the current attribute.
*/
lower_left();
switch (attrmode)
if (attrmode == AT_NORMAL)
clear_eol_bot();
else
{
case AT_STANDOUT:
so_exit();
int saved_attrmode = attrmode;
at_exit();
clear_eol_bot();
so_enter();
break;
case AT_UNDERLINE:
ul_exit();
clear_eol_bot();
ul_enter();
break;
case AT_BOLD:
bo_exit();
clear_eol_bot();
bo_enter();
break;
case AT_BLINK:
bl_exit();
clear_eol_bot();
bl_enter();
break;
default:
clear_eol_bot();
break;
at_enter(saved_attrmode);
}
}
/*
* Begin "standout" (bold, underline, or whatever).
*/
public void
so_enter()
at_enter(attr)
int attr;
{
attr = apply_at_specials(attr);
#if !MSDOS_COMPILER
/* The one with the most priority is last. */
if (attr & AT_UNDERLINE)
tputs(sc_u_in, 1, putchr);
if (attr & AT_BOLD)
tputs(sc_b_in, 1, putchr);
if (attr & AT_BLINK)
tputs(sc_bl_in, 1, putchr);
if (attr & AT_STANDOUT)
tputs(sc_s_in, 1, putchr);
#else
flush();
/* The one with the most priority is first. */
if (attr & AT_STANDOUT)
{
SETCOLORS(so_fg_color, so_bg_color);
#endif
attrmode = AT_STANDOUT;
}
/*
* End "standout".
*/
public void
so_exit()
{
#if !MSDOS_COMPILER
tputs(sc_s_out, 1, putchr);
#else
flush();
SETCOLORS(nm_fg_color, nm_bg_color);
#endif
attrmode = AT_NORMAL;
}
/*
* Begin "underline" (hopefully real underlining,
* otherwise whatever the terminal provides).
*/
public void
ul_enter()
{
#if !MSDOS_COMPILER
tputs(sc_u_in, 1, putchr);
#else
flush();
} else if (attr & AT_BLINK)
{
SETCOLORS(bl_fg_color, bl_bg_color);
}
else if (attr & AT_BOLD)
{
SETCOLORS(bo_fg_color, bo_bg_color);
}
else if (attr & AT_UNDERLINE)
{
SETCOLORS(ul_fg_color, ul_bg_color);
}
#endif
attrmode = AT_UNDERLINE;
attrmode = attr;
}
/*
* End "underline".
*/
public void
ul_exit()
at_exit()
{
#if !MSDOS_COMPILER
/* Undo things in the reverse order we did them. */
if (attrmode & AT_STANDOUT)
tputs(sc_s_out, 1, putchr);
if (attrmode & AT_BLINK)
tputs(sc_bl_out, 1, putchr);
if (attrmode & AT_BOLD)
tputs(sc_b_out, 1, putchr);
if (attrmode & AT_UNDERLINE)
tputs(sc_u_out, 1, putchr);
#else
flush();
SETCOLORS(nm_fg_color, nm_bg_color);
#endif
attrmode = AT_NORMAL;
}
/*
* Begin "bold"
*/
public void
bo_enter()
at_switch(attr)
int attr;
{
#if !MSDOS_COMPILER
tputs(sc_b_in, 1, putchr);
#else
flush();
SETCOLORS(bo_fg_color, bo_bg_color);
#endif
attrmode = AT_BOLD;
if (apply_at_specials(attr) != attrmode)
{
at_exit();
at_enter(attr);
}
}
/*
* End "bold".
*/
public void
bo_exit()
public int
is_at_equiv(attr1, attr2)
int attr1;
int attr2;
{
#if !MSDOS_COMPILER
tputs(sc_b_out, 1, putchr);
#else
flush();
SETCOLORS(nm_fg_color, nm_bg_color);
#endif
attrmode = AT_NORMAL;
attr1 = apply_at_specials(attr1);
attr2 = apply_at_specials(attr2);
return (attr1 == attr2);
}
/*
* Begin "blink"
*/
public void
bl_enter()
public int
apply_at_specials(attr)
int attr;
{
#if !MSDOS_COMPILER
tputs(sc_bl_in, 1, putchr);
#else
flush();
SETCOLORS(bl_fg_color, bl_bg_color);
#endif
attrmode = AT_BLINK;
}
if (attr & AT_BINARY)
attr |= binattr;
if (attr & AT_HILITE)
attr |= AT_STANDOUT;
attr &= ~(AT_BINARY|AT_HILITE);
/*
* End "blink".
*/
public void
bl_exit()
{
#if !MSDOS_COMPILER
tputs(sc_bl_out, 1, putchr);
#else
flush();
SETCOLORS(nm_fg_color, nm_bg_color);
#endif
attrmode = AT_NORMAL;
return attr;
}
#if 0 /* No longer used */

View File

@ -1,6 +1,6 @@
/* $FreeBSD$ */
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2005 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.
@ -122,9 +122,9 @@ cvt_text(odst, osrc, ops)
for (src = osrc, dst = odst; *src != '\0'; src++)
{
if ((ops & CVT_TO_LC) && isupper((unsigned char) *src))
if ((ops & CVT_TO_LC) && IS_UPPER(*src))
/* Convert uppercase to lowercase. */
*dst++ = tolower((unsigned char) *src);
*dst++ = TO_LOWER(*src);
else if ((ops & CVT_BS) && *src == '\b' && dst > odst)
/* Delete BS and preceding char. */
dst--;
@ -132,7 +132,7 @@ cvt_text(odst, osrc, ops)
{
/* Skip to end of ANSI escape sequence. */
while (src[1] != '\0')
if (is_ansi_end(*++src))
if (!is_ansi_middle(*++src))
break;
} else
/* Just copy. */
@ -177,7 +177,7 @@ is_ucase(s)
register char *p;
for (p = s; *p != '\0'; p++)
if (isupper((unsigned char) *p))
if (IS_UPPER(*p))
return (1);
return (0);
}
@ -249,11 +249,18 @@ repaint_hilite(on)
if (pos == NULL_POSITION)
continue;
epos = position(slinenum+1);
#if 0
/*
* If any character in the line is highlighted,
* repaint the line.
*
* {{ This doesn't work -- if line is drawn with highlights
* which should be erased (e.g. toggle -i with status column),
* we must redraw the line even if it has no highlights.
* For now, just repaint every line. }}
*/
if (is_hilited(pos, epos, 1))
if (is_hilited(pos, epos, 1, NULL))
#endif
{
(void) forw_line(pos);
goto_line(slinenum);
@ -532,17 +539,43 @@ clr_hilite()
prep_startpos = prep_endpos = NULL_POSITION;
}
/*
* Should any characters in a specified range be highlighted?
*/
static int
is_hilited_range(pos, epos)
POSITION pos;
POSITION epos;
{
struct hilite *hl;
/*
* Look at each highlight and see if any part of it falls in the range.
*/
for (hl = hilite_anchor.hl_first; hl != NULL; hl = hl->hl_next)
{
if (hl->hl_endpos > pos &&
(epos == NULL_POSITION || epos > hl->hl_startpos))
return (1);
}
return (0);
}
/*
* Should any characters in a specified range be highlighted?
* If nohide is nonzero, don't consider hide_hilite.
*/
public int
is_hilited(pos, epos, nohide)
is_hilited(pos, epos, nohide, p_matches)
POSITION pos;
POSITION epos;
int nohide;
int *p_matches;
{
struct hilite *hl;
int match;
if (p_matches != NULL)
*p_matches = 0;
if (!status_col &&
start_attnpos != NULL_POSITION &&
@ -553,6 +586,16 @@ is_hilited(pos, epos, nohide)
*/
return (1);
match = is_hilited_range(pos, epos);
if (!match)
return (0);
if (p_matches != NULL)
/*
* Report matches, even if we're hiding highlights.
*/
*p_matches = 1;
if (hilite_search == 0)
/*
* Not doing highlighting.
@ -565,16 +608,7 @@ is_hilited(pos, epos, nohide)
*/
return (0);
/*
* Look at each highlight and see if any part of it falls in the range.
*/
for (hl = hilite_anchor.hl_first; hl != NULL; hl = hl->hl_next)
{
if (hl->hl_endpos > pos &&
(epos == NULL_POSITION || epos > hl->hl_startpos))
return (1);
}
return (0);
}
/*
@ -617,6 +651,30 @@ add_hilite(anchor, hl)
ihl->hl_next = hl;
}
static void
adj_hilite_ansi(cvt_ops, line, npos)
int cvt_ops;
char **line;
POSITION *npos;
{
if (cvt_ops & CVT_ANSI)
while (**line == ESC)
{
/*
* Found an ESC. The file position moves
* forward past the entire ANSI escape sequence.
*/
(*line)++;
(*npos)++;
while (**line != '\0')
{
(*npos)++;
if (!is_ansi_middle(*(*line)++))
break;
}
}
}
/*
* Adjust hl_startpos & hl_endpos to account for backspace processing.
*/
@ -666,38 +724,30 @@ adj_hilite(anchor, linepos, cvt_ops)
}
if (*line == '\0')
break;
if (cvt_ops & CVT_ANSI)
{
while (line[0] == ESC)
{
/*
* Found an ESC. The file position moves
* forward past the entire ANSI escape sequence.
*/
line++;
npos++;
while (*line != '\0')
{
npos++;
if (is_ansi_end(*line++))
break;
}
}
}
adj_hilite_ansi(cvt_ops, &line, &npos);
opos++;
npos++;
line++;
if (cvt_ops & CVT_BS)
{
while (line[0] == '\b' && line[1] != '\0')
while (*line == '\b')
{
npos++;
line++;
adj_hilite_ansi(cvt_ops, &line, &npos);
if (*line == '\0')
{
--npos;
--line;
break;
}
/*
* Found a backspace. The file position moves
* forward by 2 relative to the processed line
* which was searched in hilite_line.
*/
npos += 2;
line += 2;
npos++;
line++;
}
}
}
@ -1043,7 +1093,7 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
* Return it.
*/
#if HILITE_SEARCH
if (hilite_search == 1)
if (hilite_search == OPT_ON)
{
/*
* Clear the hilite list and add only

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2004 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.
@ -34,6 +34,7 @@ extern int lnloop;
extern int linenums;
extern int wscroll;
extern int reading;
extern int quit_on_intr;
extern int more_mode;
/*
@ -251,6 +252,8 @@ psignals()
#endif
if (tsignals & S_INTERRUPT)
{
if (quit_on_intr)
quit(QUIT_OK);
bell();
/*
* {{ You may wish to replace the bell() with