Skip to content

Commit

Permalink
Allow --rscroll to accept a non-ASCII character.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Mar 4, 2024
1 parent 840c9d2 commit d4b3821
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 24 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@

* Improve colors of bold, underline and standout text on Windows.

* Allow --rscroll to accept non-ASCII characters.

* Fix bug where # substitution failed after viewing help (github #420).

* Fix crash if files are deleted while less is viewing them (github #404).
Expand Down
17 changes: 1 addition & 16 deletions charset.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,21 +365,6 @@ static void ilocale(void)
*/
public void setfmt(constant char *s, constant char **fmtvarptr, int *attrptr, constant char *default_fmt, lbool for_printf)
{
if (s && utf_mode)
{
/* It would be too hard to account for width otherwise. */
char constant *t = s;
while (*t)
{
if (*t < ' ' || *t > '~')
{
s = default_fmt;
goto attr;
}
t++;
}
}

if (s == NULL || *s == '\0')
s = default_fmt;
else if (for_printf &&
Expand Down Expand Up @@ -534,7 +519,7 @@ public lbool control_char(LWCHAR c)
*/
public constant char * prchar(LWCHAR c)
{
/* {{ This buffer can be overrun if LESSBINFMT is a long string. }} */
/* {{ Fixed buffer size means LESSBINFMT etc can be truncated. }} */
static char buf[MAX_PRCHAR_LEN+1];

c &= 0377; /*{{type-issue}}*/
Expand Down
2 changes: 1 addition & 1 deletion less.nro.VER
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ Some options like \-k or \-D require a string to follow the option letter.
The string for that option is considered to end when a dollar sign ($) is found.
For example, you can set two \-D options like this:
.sp
LESS="Dn9.1$Ds4.1"
LESS="Dnwb$Dsbw"
.sp
If the \-\-use-backslash option appears earlier in the options, then
a dollar sign or backslash may be included literally in an option string
Expand Down
12 changes: 9 additions & 3 deletions line.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ extern int sc_width, sc_height;
extern int utf_mode;
extern POSITION start_attnpos;
extern POSITION end_attnpos;
extern char rscroll_char;
extern LWCHAR rscroll_char;
extern int rscroll_attr;
extern int use_color;
extern int status_line;
Expand Down Expand Up @@ -1223,6 +1223,9 @@ public void pdone(int endline, int chopped, int forw)

if (chopped && rscroll_char)
{
char rscroll_utf8[MAX_UTF_CHAR_LEN+1];
char *up = rscroll_utf8;

/*
* Display the right scrolling char.
* If we've already filled the rightmost screen char
Expand All @@ -1244,8 +1247,11 @@ public void pdone(int endline, int chopped, int forw)
*/
add_linebuf(' ', 0, 1);
}
/* Print rscroll char. It must be single-width. */
add_linebuf(rscroll_char, rscroll_attr, 1);
/* Print rscroll char. */
put_wchar(&up, rscroll_char);
*up = '\0';
addstr_linebuf(rscroll_utf8, rscroll_attr, 0);
inc_end_column(1); /* assume rscroll_char is single-width */
} else
{
add_attr_normal();
Expand Down
13 changes: 11 additions & 2 deletions optfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extern int shift_count;
extern long shift_count_fraction;
extern int match_shift;
extern long match_shift_fraction;
extern char rscroll_char;
extern LWCHAR rscroll_char;
extern int rscroll_attr;
extern int mousecap;
extern int wheel_lines;
Expand Down Expand Up @@ -805,8 +805,17 @@ public void opt_rscroll(int type, constant char *s)
rscroll_char = 0;
} else
{
rscroll_char = *fmt ? *fmt : '>';
rscroll_attr = attr|AT_COLOR_RSCROLL;
if (*fmt == '\0')
rscroll_char = '>';
else
{
LWCHAR ch = step_charc(&fmt, +1, fmt+strlen(fmt));
if (pwidth(ch, rscroll_attr, 0, 0) > 1)
error("cannot set rscroll to a wide character", NULL_PARG);
else
rscroll_char = ch;
}
}
break; }
case QUERY: {
Expand Down
2 changes: 1 addition & 1 deletion opttbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public int quit_on_intr; /* Quit on interrupt */
public int follow_mode; /* F cmd Follows file desc or file name? */
public int oldbot; /* Old bottom of screen behavior {{REMOVE}} */
public int opt_use_backslash; /* Use backslash escaping in option parsing */
public char rscroll_char; /* Char which marks chopped lines with -S */
public LWCHAR rscroll_char; /* Char which marks chopped lines with -S */
public int rscroll_attr; /* Attribute of rscroll_char */
public int no_hist_dups; /* Remove dups from history list */
public int mousecap; /* Allow mouse for scrolling */
Expand Down
2 changes: 1 addition & 1 deletion search.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extern int nosearch_header_lines;
extern int nosearch_header_cols;
extern int header_lines;
extern int header_cols;
extern char rscroll_char;
extern LWCHAR rscroll_char;
#if HILITE_SEARCH
extern int hilite_search;
extern size_t size_linebuf;
Expand Down

0 comments on commit d4b3821

Please sign in to comment.