Deleted Added
full compact
1c1
< /* $FreeBSD: head/contrib/libreadline/display.c 58314 2000-03-19 22:00:57Z ache $ */
---
> /* $FreeBSD: head/contrib/libreadline/display.c 75409 2001-04-11 03:15:56Z ache $ */
63c63
< extern char *term_forward_char;
---
> extern char *_rl_term_forward_char;
107c107
< VFunction *rl_redisplay_function = rl_redisplay;
---
> rl_voidfunc_t *rl_redisplay_function = rl_redisplay;
145a146,148
> /* Variables to keep track of the expanded prompt string, which may
> include invisible characters. */
>
147c150
< static int visible_length, prefix_length;
---
> static int prompt_visible_length, prompt_prefix_length;
153c156,157
< /* static so it can be shared between rl_redisplay and update_line */
---
> /* The number of invisible characters in the prompt string. Static so it
> can be shared between rl_redisplay and update_line */
156,157c160,161
< /* The index of the last invisible_character in the prompt string. */
< static int last_invisible;
---
> /* The index of the last invisible character in the prompt string. */
> static int prompt_last_invisible;
162a167,173
> /* Number of invisible characters on the first physical line of the prompt.
> Only valid when the number of physical characters in the prompt exceeds
> (or is equal to) _rl_screenwidth. */
> static int prompt_invis_chars_first_line;
>
> static int prompt_last_screen_line;
>
166c177,179
< index of the last invisible character in the returned string. */
---
> index of the last invisible character in the returned string. NIFLP,
> if non-zero, is a place to store the number of invisible characters in
> the first prompt line. */
176c189
< expand_prompt (pmt, lp, lip)
---
> expand_prompt (pmt, lp, lip, niflp)
178c191
< int *lp, *lip;
---
> int *lp, *lip, *niflp;
181c194
< int l, rl, last, ignoring;
---
> int l, rl, last, ignoring, ninvis, invfl;
194,195c207,210
<
< for (rl = ignoring = last = 0, p = pmt; p && *p; p++)
---
>
> invfl = 0; /* invisible chars in first line of prompt */
>
> for (rl = ignoring = last = ninvis = 0, p = pmt; p && *p; p++)
214a230,233
> else
> ninvis++;
> if (rl == _rl_screenwidth)
> invfl = ninvis;
217a237,239
> if (rl < _rl_screenwidth)
> invfl = ninvis;
>
222a245,246
> if (niflp)
> *niflp = invfl;
234c258
< ret = expand_prompt (pmt, (int *)NULL, (int *)NULL);
---
> ret = expand_prompt (pmt, (int *)NULL, (int *)NULL, (int *)NULL);
246,247c270,271
< * visible_length = number of visible characters in local_prompt
< * prefix_length = number of visible characters in local_prompt_prefix
---
> * prompt_visible_length = number of visible characters in local_prompt
> * prompt_prefix_length = number of visible characters in local_prompt_prefix
263,266c287,289
< if (local_prompt)
< free (local_prompt);
< if (local_prompt_prefix)
< free (local_prompt_prefix);
---
> FREE (local_prompt);
> FREE (local_prompt_prefix);
>
268c291
< last_invisible = visible_length = 0;
---
> prompt_last_invisible = prompt_visible_length = 0;
276,277c299,302
< /* The prompt is only one line. */
< local_prompt = expand_prompt (prompt, &visible_length, &last_invisible);
---
> /* The prompt is only one logical line, though it might wrap. */
> local_prompt = expand_prompt (prompt, &prompt_visible_length,
> &prompt_last_invisible,
> &prompt_invis_chars_first_line);
279c304
< return (visible_length);
---
> return (prompt_visible_length);
285c310,312
< local_prompt = expand_prompt (p, &visible_length, &last_invisible);
---
> local_prompt = expand_prompt (p, &prompt_visible_length,
> &prompt_last_invisible,
> &prompt_invis_chars_first_line);
289c316,318
< local_prompt_prefix = expand_prompt (prompt, &prefix_length, (int *)NULL);
---
> local_prompt_prefix = expand_prompt (prompt, &prompt_prefix_length,
> (int *)NULL,
> &prompt_invis_chars_first_line);
291c320
< return (prefix_length);
---
> return (prompt_prefix_length);
403c432
< wrap_offset = local_len - visible_length;
---
> wrap_offset = local_len - prompt_visible_length;
436c465
< wrap_offset = 0;
---
> wrap_offset = prompt_invis_chars_first_line = 0;
451c480
< if (lpos >= screenwidth) \
---
> if (lpos >= _rl_screenwidth) \
467c496,501
< /* XXX - what if lpos is already >= screenwidth before we start drawing the
---
> /* prompt_invis_chars_first_line is the number of invisible characters in
> the first physical line of the prompt.
> wrap_offset - prompt_invis_chars_first_line is the number of invis
> chars on the second line. */
>
> /* what if lpos is already >= _rl_screenwidth before we start drawing the
469c503
< while (lpos >= screenwidth)
---
> while (lpos >= _rl_screenwidth)
471,476c505,513
< /* XXX - possible fix from Darin Johnson <darin@acuson.com> for prompt
< string with invisible characters that is longer than the screen
< width. XXX - this doesn't work right if invisible characters have
< to be put on the second screen line -- it adds too much (the number
< of invisible chars after the screenwidth). */
< temp = ((newlines + 1) * screenwidth) + ((newlines == 0) ? wrap_offset : 0);
---
> /* fix from Darin Johnson <darin@acuson.com> for prompt string with
> invisible characters that is longer than the screen width. The
> prompt_invis_chars_first_line variable could be made into an array
> saying how many invisible characters there are per line, but that's
> probably too much work for the benefit gained. How many people have
> prompts that exceed two physical lines? */
> temp = ((newlines + 1) * _rl_screenwidth) +
> ((newlines == 0) ? prompt_invis_chars_first_line : 0) +
> ((newlines == 1) ? wrap_offset : 0);
479c516
< lpos -= screenwidth;
---
> lpos -= _rl_screenwidth;
481a519,525
> 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
> 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. */
507c551
< if (lpos + 4 >= screenwidth)
---
> if (lpos + 4 >= _rl_screenwidth)
509c553
< temp = screenwidth - lpos;
---
> temp = _rl_screenwidth - lpos;
528c572
< register int temp, newout;
---
> register int newout;
536c580
< if (lpos + temp >= screenwidth)
---
> if (lpos + temp >= _rl_screenwidth)
539c583
< temp2 = screenwidth - lpos;
---
> temp2 = _rl_screenwidth - lpos;
554c598
< else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && term_up && *term_up)
---
> else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up)
586c630,631
< /* C_POS == position in buffer where cursor should be placed. */
---
> /* C_POS == position in buffer where cursor should be placed.
> CURSOR_LINENUM == line number where the cursor should be placed. */
597c642
< if (_rl_horizontal_scroll_mode == 0 && term_up && *term_up)
---
> if (_rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up)
608,609c653,654
< if (out >= screenchars)
< out = screenchars - 1;
---
> if (out >= _rl_screenchars)
> out = _rl_screenchars - 1;
639c684
< nleft = screenwidth + wrap_offset - _rl_last_c_pos;
---
> nleft = _rl_screenwidth + wrap_offset - _rl_last_c_pos;
660c705
< ((linenum == _rl_vis_botlin) ? strlen (tt) : screenwidth);
---
> ((linenum == _rl_vis_botlin) ? strlen (tt) : _rl_screenwidth);
671c716
< /* If we moved up to the line with the prompt using term_up,
---
> /* If we moved up to the line with the prompt using _rl_term_up,
684c729
< nleft = visible_length + wrap_offset;
---
> nleft = prompt_visible_length + wrap_offset;
686c731
< _rl_last_c_pos <= last_invisible && local_prompt)
---
> _rl_last_c_pos <= prompt_last_invisible && local_prompt)
691,692c736,737
< if (term_cr)
< tputs (term_cr, 1, _rl_output_character_function);
---
> if (_rl_term_cr)
> tputs (_rl_term_cr, 1, _rl_output_character_function);
731c776
< nleft = visible_length + wrap_offset;
---
> nleft = prompt_visible_length + wrap_offset;
735c780
< t = screenwidth / 3;
---
> t = _rl_screenwidth / 3;
743c788
< if (phys_c_pos > screenwidth - 2)
---
> if (phys_c_pos > _rl_screenwidth - 2)
753c798
< else if (ndisp < screenwidth - 2) /* XXX - was -1 */
---
> else if (ndisp < _rl_screenwidth - 2) /* XXX - was -1 */
775c820
< t = lmargin + M_OFFSET (lmargin, wrap_offset) + screenwidth;
---
> t = lmargin + M_OFFSET (lmargin, wrap_offset) + _rl_screenwidth;
785,786c830,831
< screenwidth + visible_wrap_offset,
< screenwidth + (lmargin ? 0 : wrap_offset),
---
> _rl_screenwidth + visible_wrap_offset,
> _rl_screenwidth + (lmargin ? 0 : wrap_offset),
797c842
< nleft = screenwidth - t;
---
> nleft = _rl_screenwidth - t;
801,802c846,847
< if (visible_first_line_len > screenwidth)
< visible_first_line_len = screenwidth;
---
> if (visible_first_line_len > _rl_screenwidth)
> visible_first_line_len = _rl_screenwidth;
812c857
< char *temp = visible_line;
---
> char *vtemp = visible_line;
816c861
< invisible_line = temp;
---
> invisible_line = vtemp;
866c911
< if (temp == screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
---
> if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
943,944c988,989
< term_cr && lendiff > visible_length && _rl_last_c_pos > 0 &&
< od > lendiff && _rl_last_c_pos < last_invisible)
---
> _rl_term_cr && lendiff > prompt_visible_length && _rl_last_c_pos > 0 &&
> od >= lendiff && _rl_last_c_pos <= prompt_last_invisible)
949c994
< tputs (term_cr, 1, _rl_output_character_function);
---
> tputs (_rl_term_cr, 1, _rl_output_character_function);
977c1022
< if (terminal_can_insert && ((2 * temp) >= lendiff || term_IC) && (!_rl_term_autowrap || !gl))
---
> if (_rl_terminal_can_insert && ((2 * temp) >= lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl))
979c1024
< /* If lendiff > visible_length and _rl_last_c_pos == 0 and
---
> /* If lendiff > prompt_visible_length and _rl_last_c_pos == 0 and
981c1026
< term_IC or term_ic will screw up the screen because of the
---
> _rl_term_IC or _rl_term_ic will screw up the screen because of the
984c1029
< lendiff <= visible_length || !current_invis_chars))
---
> lendiff <= prompt_visible_length || !current_invis_chars))
1025c1070
< if (term_dc && (2 * temp) >= -lendiff)
---
> if (_rl_term_dc && (2 * temp) >= -lendiff)
1110c1155
< real_screenwidth = screenwidth + (_rl_term_autowrap ? 0 : 1);
---
> real_screenwidth = _rl_screenwidth + (_rl_term_autowrap ? 0 : 1);
1155c1200
< char *data;
---
> const char *data;
1167c1212
< (_rl_term_autowrap && i == screenwidth))
---
> (_rl_term_autowrap && i == _rl_screenwidth))
1172c1217
< tputs (term_cr, 1, _rl_output_character_function);
---
> tputs (_rl_term_cr, 1, _rl_output_character_function);
1189c1234
< if (term_forward_char)
---
> if (_rl_term_forward_char)
1191c1236
< tputs (term_forward_char, 1, _rl_output_character_function);
---
> tputs (_rl_term_forward_char, 1, _rl_output_character_function);
1212c1257
< if (_rl_last_v_pos == to || to > screenheight)
---
> if (_rl_last_v_pos == to || to > _rl_screenheight)
1222c1267
< tputs (term_cr, 1, _rl_output_character_function);
---
> tputs (_rl_term_cr, 1, _rl_output_character_function);
1228c1273
< if (term_up && *term_up)
---
> if (_rl_term_up && *_rl_term_up)
1230c1275
< tputs (term_up, 1, _rl_output_character_function);
---
> tputs (_rl_term_up, 1, _rl_output_character_function);
1364,1365c1409,1410
< saved_last_invisible = last_invisible;
< saved_visible_length = visible_length;
---
> saved_last_invisible = prompt_last_invisible;
> saved_visible_length = prompt_visible_length;
1368c1413
< last_invisible = visible_length = 0;
---
> prompt_last_invisible = prompt_visible_length = 0;
1374,1377c1419,1420
< if (local_prompt)
< free (local_prompt);
< if (local_prompt_prefix)
< free (local_prompt_prefix);
---
> FREE (local_prompt);
> FREE (local_prompt_prefix);
1381,1382c1424,1425
< last_invisible = saved_last_invisible;
< visible_length = saved_visible_length;
---
> prompt_last_invisible = saved_last_invisible;
> prompt_visible_length = saved_visible_length;
1412,1413c1455,1456
< last_invisible = saved_last_invisible;
< visible_length = saved_visible_length + 1;
---
> prompt_last_invisible = saved_last_invisible;
> prompt_visible_length = saved_visible_length + 1;
1440,1441c1483,1484
< if (term_clreol)
< tputs (term_clreol, 1, _rl_output_character_function);
---
> if (_rl_term_clreol)
> tputs (_rl_term_clreol, 1, _rl_output_character_function);
1463,1464c1506,1507
< if (term_clrpag)
< tputs (term_clrpag, 1, _rl_output_character_function);
---
> if (_rl_term_clrpag)
> tputs (_rl_term_clrpag, 1, _rl_output_character_function);
1466c1509
< crlf ();
---
> rl_crlf ();
1476c1519
< if (term_IC)
---
> if (_rl_term_IC)
1479c1522
< buffer = tgoto (term_IC, 0, count);
---
> buffer = tgoto (_rl_term_IC, 0, count);
1488,1489c1531,1532
< if (term_im && *term_im)
< tputs (term_im, 1, _rl_output_character_function);
---
> if (_rl_term_im && *_rl_term_im)
> tputs (_rl_term_im, 1, _rl_output_character_function);
1493c1536
< if (term_ic && *term_ic)
---
> if (_rl_term_ic && *_rl_term_ic)
1496c1539
< tputs (term_ic, 1, _rl_output_character_function);
---
> tputs (_rl_term_ic, 1, _rl_output_character_function);
1504,1505c1547,1548
< if (term_ei && *term_ei)
< tputs (term_ei, 1, _rl_output_character_function);
---
> if (_rl_term_ei && *_rl_term_ei)
> tputs (_rl_term_ei, 1, _rl_output_character_function);
1514c1557
< if (count > screenwidth) /* XXX */
---
> if (count > _rl_screenwidth) /* XXX */
1517c1560
< if (term_DC && *term_DC)
---
> if (_rl_term_DC && *_rl_term_DC)
1520c1563
< buffer = tgoto (term_DC, count, count);
---
> buffer = tgoto (_rl_term_DC, count, count);
1525c1568
< if (term_dc && *term_dc)
---
> if (_rl_term_dc && *_rl_term_dc)
1527c1570
< tputs (term_dc, 1, _rl_output_character_function);
---
> tputs (_rl_term_dc, 1, _rl_output_character_function);
1547c1590
< if (full_lines && _rl_term_autowrap && (VIS_LLEN(_rl_vis_botlin) == screenwidth))
---
> if (full_lines && _rl_term_autowrap && (VIS_LLEN(_rl_vis_botlin) == _rl_screenwidth))
1555c1598
< _rl_move_cursor_relative (screenwidth - 1, last_line);
---
> _rl_move_cursor_relative (_rl_screenwidth - 1, last_line);
1557c1600
< putc (last_line[screenwidth - 1], rl_outstream);
---
> putc (last_line[_rl_screenwidth - 1], rl_outstream);
1560c1603
< crlf ();
---
> rl_crlf ();
1569c1612
< if (term_cr)
---
> if (_rl_term_cr)
1574c1617
< tputs (term_cr, 1, _rl_output_character_function);
---
> tputs (_rl_term_cr, 1, _rl_output_character_function);
1588c1631
< int oldlen, oldlast, oldplen;
---
> int oldlen, oldlast, oldplen, oldninvis;
1594,1596c1637,1640
< oldlen = visible_length;
< oldplen = prefix_length;
< oldlast = last_invisible;
---
> oldlen = prompt_visible_length;
> oldplen = prompt_prefix_length;
> oldlast = prompt_last_invisible;
> oldninvis = prompt_invis_chars_first_line;
1599c1643,1645
< local_prompt = expand_prompt (t, &visible_length, &last_invisible);
---
> local_prompt = expand_prompt (t, &prompt_visible_length,
> &prompt_last_invisible,
> &prompt_invis_chars_first_line);
1606,1608c1652,1655
< visible_length = oldlen;
< prefix_length = oldplen;
< last_invisible = oldlast;
---
> prompt_visible_length = oldlen;
> prompt_prefix_length = oldplen;
> prompt_last_invisible = oldlast;
> prompt_invis_chars_first_line = oldninvis;
1619c1666
< if (term_cr)
---
> if (_rl_term_cr)
1624c1671
< tputs (term_cr, 1, _rl_output_character_function);
---
> tputs (_rl_term_cr, 1, _rl_output_character_function);
1628c1675
< space_to_eol (screenwidth);
---
> space_to_eol (_rl_screenwidth);
1631,1632c1678,1679
< if (term_clreol)
< tputs (term_clreol, 1, _rl_output_character_function);
---
> if (_rl_term_clreol)
> tputs (_rl_term_clreol, 1, _rl_output_character_function);
1635,1636c1682,1683
< space_to_eol (screenwidth);
< tputs (term_cr, 1, _rl_output_character_function);
---
> space_to_eol (_rl_screenwidth);
> tputs (_rl_term_cr, 1, _rl_output_character_function);
1643c1690
< crlf ();
---
> rl_crlf ();
1684c1731
< nleft = _rl_last_c_pos - screenwidth - rl_visible_prompt_length;
---
> nleft = _rl_last_c_pos - _rl_screenwidth - rl_visible_prompt_length;
1686c1733
< nleft = _rl_last_c_pos - screenwidth;
---
> nleft = _rl_last_c_pos - _rl_screenwidth;
1689c1736
< ret = 1 + nleft / screenwidth;
---
> ret = 1 + nleft / _rl_screenwidth;