mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-11 04:30:44 +02:00
commit bash-20060720 snapshot
This commit is contained in:
+41
-38
@@ -1,6 +1,6 @@
|
||||
/* display.c -- readline redisplay facility. */
|
||||
|
||||
/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
@@ -59,10 +59,6 @@
|
||||
extern char *strchr (), *strrchr ();
|
||||
#endif /* !strchr && !__STDC__ */
|
||||
|
||||
#if defined (HACK_TERMCAP_MOTION)
|
||||
extern char *_rl_term_forward_char;
|
||||
#endif
|
||||
|
||||
static void update_line PARAMS((char *, char *, int, int, int, int));
|
||||
static void space_to_eol PARAMS((int));
|
||||
static void delete_chars PARAMS((int));
|
||||
@@ -80,7 +76,8 @@ static int *inv_lbreaks, *vis_lbreaks;
|
||||
static int inv_lbsize, vis_lbsize;
|
||||
|
||||
/* Heuristic used to decide whether it is faster to move from CUR to NEW
|
||||
by backing up or outputting a carriage return and moving forward. */
|
||||
by backing up or outputting a carriage return and moving forward. CUR
|
||||
and NEW are either both buffer positions or absolute screen positions. */
|
||||
#define CR_FASTER(new, cur) (((new) + 1) < ((cur) - (new)))
|
||||
|
||||
/* _rl_last_c_pos is an absolute cursor position in multibyte locales and a
|
||||
@@ -143,6 +140,7 @@ int _rl_last_c_pos = 0;
|
||||
int _rl_last_v_pos = 0;
|
||||
|
||||
static int cpos_adjusted;
|
||||
static int cpos_buffer_position;
|
||||
|
||||
/* Number of lines currently on screen minus 1. */
|
||||
int _rl_vis_botlin = 0;
|
||||
@@ -460,7 +458,7 @@ rl_redisplay ()
|
||||
{
|
||||
register int in, out, c, linenum, cursor_linenum;
|
||||
register char *line;
|
||||
int c_pos, inv_botlin, lb_botlin, lb_linenum, o_cpos;
|
||||
int inv_botlin, lb_botlin, lb_linenum, o_cpos;
|
||||
int newlines, lpos, temp, modmark, n0, num;
|
||||
char *prompt_this_line;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
@@ -484,7 +482,7 @@ rl_redisplay ()
|
||||
}
|
||||
|
||||
/* Draw the line into the buffer. */
|
||||
c_pos = -1;
|
||||
cpos_buffer_position = -1;
|
||||
|
||||
line = invisible_line;
|
||||
out = inv_botlin = 0;
|
||||
@@ -666,7 +664,7 @@ rl_redisplay ()
|
||||
prompt_last_screen_line = newlines;
|
||||
|
||||
/* Draw the rest of the line (after the prompt) into invisible_line, keeping
|
||||
track of where the cursor is (c_pos), the number of the line containing
|
||||
track of where the cursor is (cpos_buffer_position), the number of the line containing
|
||||
the cursor (lb_linenum), the last line number (lb_botlin and inv_botlin).
|
||||
It maintains an array of line breaks for display (inv_lbreaks).
|
||||
This handles expanding tabs for display and displaying meta characters. */
|
||||
@@ -719,7 +717,7 @@ rl_redisplay ()
|
||||
|
||||
if (in == rl_point)
|
||||
{
|
||||
c_pos = out;
|
||||
cpos_buffer_position = out;
|
||||
lb_linenum = newlines;
|
||||
}
|
||||
|
||||
@@ -813,7 +811,7 @@ rl_redisplay ()
|
||||
}
|
||||
if (in == rl_point)
|
||||
{
|
||||
c_pos = out;
|
||||
cpos_buffer_position = out;
|
||||
lb_linenum = newlines;
|
||||
}
|
||||
for (i = in; i < in+wc_bytes; i++)
|
||||
@@ -844,9 +842,9 @@ rl_redisplay ()
|
||||
|
||||
}
|
||||
line[out] = '\0';
|
||||
if (c_pos < 0)
|
||||
if (cpos_buffer_position < 0)
|
||||
{
|
||||
c_pos = out;
|
||||
cpos_buffer_position = out;
|
||||
lb_linenum = newlines;
|
||||
}
|
||||
|
||||
@@ -855,7 +853,7 @@ rl_redisplay ()
|
||||
inv_lbreaks[newlines+1] = out;
|
||||
cursor_linenum = lb_linenum;
|
||||
|
||||
/* C_POS == position in buffer where cursor should be placed.
|
||||
/* CPOS_BUFFER_POSITION == position in buffer where cursor should be placed.
|
||||
CURSOR_LINENUM == line number where the cursor should be placed. */
|
||||
|
||||
/* PWP: now is when things get a bit hairy. The visible and invisible
|
||||
@@ -1011,7 +1009,7 @@ rl_redisplay ()
|
||||
pos = inv_lbreaks[cursor_linenum];
|
||||
/* nleft == number of characters in the line buffer between the
|
||||
start of the line and the desired cursor position. */
|
||||
nleft = c_pos - pos;
|
||||
nleft = cpos_buffer_position - pos;
|
||||
|
||||
/* NLEFT is now a number of characters in a buffer. When in a
|
||||
multibyte locale, however, _rl_last_c_pos is an absolute cursor
|
||||
@@ -1057,11 +1055,11 @@ rl_redisplay ()
|
||||
will be LMARGIN. */
|
||||
|
||||
/* The number of characters that will be displayed before the cursor. */
|
||||
ndisp = c_pos - wrap_offset;
|
||||
ndisp = cpos_buffer_position - wrap_offset;
|
||||
nleft = prompt_visible_length + wrap_offset;
|
||||
/* Where the new cursor position will be on the screen. This can be
|
||||
longer than SCREENWIDTH; if it is, lmargin will be adjusted. */
|
||||
phys_c_pos = c_pos - (last_lmargin ? last_lmargin : wrap_offset);
|
||||
phys_c_pos = cpos_buffer_position - (last_lmargin ? last_lmargin : wrap_offset);
|
||||
t = _rl_screenwidth / 3;
|
||||
|
||||
/* If the number of characters had already exceeded the screenwidth,
|
||||
@@ -1072,7 +1070,7 @@ rl_redisplay ()
|
||||
two-thirds of the way across the screen. */
|
||||
if (phys_c_pos > _rl_screenwidth - 2)
|
||||
{
|
||||
lmargin = c_pos - (2 * t);
|
||||
lmargin = cpos_buffer_position - (2 * t);
|
||||
if (lmargin < 0)
|
||||
lmargin = 0;
|
||||
/* If the left margin would be in the middle of a prompt with
|
||||
@@ -1086,7 +1084,7 @@ rl_redisplay ()
|
||||
{
|
||||
/* If we are moving back towards the beginning of the line and
|
||||
the last margin is no longer correct, compute a new one. */
|
||||
lmargin = ((c_pos - 1) / t) * t; /* XXX */
|
||||
lmargin = ((cpos_buffer_position - 1) / t) * t; /* XXX */
|
||||
if (wrap_offset && lmargin > 0 && lmargin < nleft)
|
||||
lmargin = nleft;
|
||||
}
|
||||
@@ -1131,7 +1129,7 @@ rl_redisplay ()
|
||||
if (visible_first_line_len > _rl_screenwidth)
|
||||
visible_first_line_len = _rl_screenwidth;
|
||||
|
||||
_rl_move_cursor_relative (c_pos - lmargin, &invisible_line[lmargin]);
|
||||
_rl_move_cursor_relative (cpos_buffer_position - lmargin, &invisible_line[lmargin]);
|
||||
last_lmargin = lmargin;
|
||||
}
|
||||
}
|
||||
@@ -1724,11 +1722,7 @@ _rl_move_cursor_relative (new, data)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
dpos = _rl_col_width (data, 0, new);
|
||||
#if 0
|
||||
if (dpos > woff)
|
||||
#else
|
||||
if (dpos > prompt_last_invisible)
|
||||
#endif
|
||||
if (dpos > prompt_last_invisible) /* XXX - don't use woff here */
|
||||
{
|
||||
dpos -= woff;
|
||||
/* Since this will be assigned to _rl_last_c_pos at the end (more
|
||||
@@ -1754,7 +1748,7 @@ _rl_move_cursor_relative (new, data)
|
||||
else
|
||||
#endif
|
||||
i = _rl_last_c_pos - woff;
|
||||
if (new == 0 || CR_FASTER (new, _rl_last_c_pos) ||
|
||||
if (dpos == 0 || CR_FASTER (dpos, _rl_last_c_pos) ||
|
||||
(_rl_term_autowrap && i == _rl_screenwidth))
|
||||
{
|
||||
#if defined (__MSDOS__)
|
||||
@@ -1776,19 +1770,27 @@ _rl_move_cursor_relative (new, data)
|
||||
sequence telling the terminal to move forward one character.
|
||||
That kind of control is for people who don't know what the
|
||||
data is underneath the cursor. */
|
||||
#if defined (HACK_TERMCAP_MOTION)
|
||||
if (_rl_term_forward_char)
|
||||
{
|
||||
for (i = cpos; i < dpos; i++)
|
||||
tputs (_rl_term_forward_char, 1, _rl_output_character_function);
|
||||
}
|
||||
else
|
||||
#endif /* HACK_TERMCAP_MOTION */
|
||||
|
||||
/* However, we need a handle on where the current display position is
|
||||
in the buffer for the immediately preceding comment to be true.
|
||||
In multibyte locales, we don't currently have that info available.
|
||||
Without it, we don't know where the data we have to display begins
|
||||
in the buffer and we have to go back to the beginning of the screen
|
||||
line. In this case, we can use the terminal sequence to move forward
|
||||
if it's available. */
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
for (i = 0; i < new; i++)
|
||||
putc (data[i], rl_outstream);
|
||||
if (_rl_term_forward_char)
|
||||
{
|
||||
for (i = cpos; i < dpos; i++)
|
||||
tputs (_rl_term_forward_char, 1, _rl_output_character_function);
|
||||
}
|
||||
else
|
||||
{
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
for (i = 0; i < new; i++)
|
||||
putc (data[i], rl_outstream);
|
||||
}
|
||||
}
|
||||
else
|
||||
for (i = cpos; i < new; i++)
|
||||
@@ -2216,7 +2218,8 @@ _rl_update_final ()
|
||||
char *last_line;
|
||||
|
||||
last_line = &visible_line[vis_lbreaks[_rl_vis_botlin]];
|
||||
_rl_move_cursor_relative (_rl_screenwidth - 1, last_line);
|
||||
cpos_buffer_position = -1; /* don't know where we are in buffer */
|
||||
_rl_move_cursor_relative (_rl_screenwidth - 1, last_line); /* XXX */
|
||||
_rl_clear_to_eol (0);
|
||||
putc (last_line[_rl_screenwidth - 1], rl_outstream);
|
||||
}
|
||||
|
||||
@@ -408,6 +408,7 @@ extern char *_rl_term_up;
|
||||
extern char *_rl_term_dc;
|
||||
extern char *_rl_term_cr;
|
||||
extern char *_rl_term_IC;
|
||||
extern char *_rl_term_forward_char;
|
||||
extern int _rl_screenheight;
|
||||
extern int _rl_screenwidth;
|
||||
extern int _rl_screenchars;
|
||||
|
||||
@@ -125,9 +125,7 @@ char *_rl_term_IC;
|
||||
char *_rl_term_dc;
|
||||
char *_rl_term_DC;
|
||||
|
||||
#if defined (HACK_TERMCAP_MOTION)
|
||||
char *_rl_term_forward_char;
|
||||
#endif /* HACK_TERMCAP_MOTION */
|
||||
|
||||
/* How to go up a line. */
|
||||
char *_rl_term_up;
|
||||
@@ -391,9 +389,7 @@ static struct _tc_string tc_strings[] =
|
||||
{ "le", &_rl_term_backspace },
|
||||
{ "mm", &_rl_term_mm },
|
||||
{ "mo", &_rl_term_mo },
|
||||
#if defined (HACK_TERMCAP_MOTION)
|
||||
{ "nd", &_rl_term_forward_char },
|
||||
#endif
|
||||
{ "pc", &_rl_term_pc },
|
||||
{ "up", &_rl_term_up },
|
||||
{ "vb", &_rl_visible_bell },
|
||||
@@ -490,9 +486,7 @@ _rl_init_terminal_io (terminal_name)
|
||||
_rl_term_ks = _rl_term_ke = _rl_term_at7 = (char *)NULL;
|
||||
_rl_term_mm = _rl_term_mo = (char *)NULL;
|
||||
_rl_term_ve = _rl_term_vs = (char *)NULL;
|
||||
#if defined (HACK_TERMCAP_MOTION)
|
||||
term_forward_char = (char *)NULL;
|
||||
#endif
|
||||
_rl_term_forward_char = (char *)NULL;
|
||||
_rl_terminal_can_insert = term_has_meta = 0;
|
||||
|
||||
/* Reasonable defaults for tgoto(). Readline currently only uses
|
||||
|
||||
Reference in New Issue
Block a user