Deleted Added
full compact
1/* $FreeBSD: head/contrib/libreadline/display.c 58314 2000-03-19 22:00:57Z ache $ */
2/* display.c -- readline redisplay facility. */
3
4/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
5
6 This file is part of the GNU Readline Library, a library for
7 reading lines of text with interactive input and history editing.
8
9 The GNU Readline Library is free software; you can redistribute it
10 and/or modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 1, or
11 as published by the Free Software Foundation; either version 2, or
12 (at your option) any later version.
13
14 The GNU Readline Library is distributed in the hope that it will be
15 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
16 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 The GNU General Public License is often shipped with GNU software, and
20 is generally kept in a file called COPYING or LICENSE. If you do not
21 have a copy of the license, write to the Free Software Foundation,
21 675 Mass Ave, Cambridge, MA 02139, USA. */
22 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
23#define READLINE_LIBRARY
24
25#if defined (HAVE_CONFIG_H)
26# include <config.h>
27#endif
28
29#include <sys/types.h>
30

--- 6 unchanged lines hidden (view full) ---

37#if defined (HAVE_STDLIB_H)
38# include <stdlib.h>
39#else
40# include "ansi_stdlib.h"
41#endif /* HAVE_STDLIB_H */
42
43#include <stdio.h>
44
44#if defined (__GO32__)
45# include <go32.h>
46# include <pc.h>
47#endif /* __GO32__ */
48
45/* System-specific feature definitions and include files. */
46#include "rldefs.h"
47
48/* Termcap library stuff. */
49#include "tcap.h"
50
51/* Some standard library routines. */
52#include "readline.h"
53#include "history.h"
54
55#include "rlprivate.h"
56#include "xmalloc.h"
57
58#if !defined (strchr) && !defined (__STDC__)
59extern char *strchr (), *strrchr ();
60#endif /* !strchr && !__STDC__ */
61
63/* Global and pseudo-global variables and functions
64 imported from readline.c. */
65extern char *rl_prompt;
66extern int readline_echoing_p;
67
68extern int _rl_output_meta_chars;
69extern int _rl_horizontal_scroll_mode;
70extern int _rl_mark_modified_lines;
71extern int _rl_prefer_visible_bell;
72
73/* Variables and functions imported from terminal.c */
74extern void _rl_output_some_chars ();
75#ifdef _MINIX
76extern void _rl_output_character_function ();
77#else
78extern int _rl_output_character_function ();
62#if defined (HACK_TERMCAP_MOTION)
63extern char *term_forward_char;
64#endif
80extern int _rl_backspace ();
65
82extern char *term_clreol, *term_clrpag;
83extern char *term_im, *term_ic, *term_ei, *term_DC;
84extern char *term_up, *term_dc, *term_cr, *term_IC;
85extern int screenheight, screenwidth, screenchars;
86extern int terminal_can_insert, _rl_term_autowrap;
66static void update_line __P((char *, char *, int, int, int, int));
67static void space_to_eol __P((int));
68static void delete_chars __P((int));
69static void insert_some_chars __P((char *, int));
70static void cr __P((void));
71
88/* Pseudo-global functions (local to the readline library) exported
89 by this file. */
90void _rl_move_cursor_relative (), _rl_output_some_chars ();
91void _rl_move_vert ();
92void _rl_clear_to_eol (), _rl_clear_screen ();
93
94static void update_line (), space_to_eol ();
95static void delete_chars (), insert_some_chars ();
96static void cr ();
97
72static int *inv_lbreaks, *vis_lbreaks;
73static int inv_lbsize, vis_lbsize;
74
100extern char *xmalloc (), *xrealloc ();
101
75/* Heuristic used to decide whether it is faster to move from CUR to NEW
76 by backing up or outputting a carriage return and moving forward. */
77#define CR_FASTER(new, cur) (((new) + 1) < ((cur) - (new)))
78
79/* **************************************************************** */
80/* */
81/* Display stuff */
82/* */

--- 75 unchanged lines hidden (view full) ---

158
159/* The length (buffer offset) of the first line of the last (possibly
160 multi-line) buffer displayed on the screen. */
161static int visible_first_line_len;
162
163/* Expand the prompt string S and return the number of visible
164 characters in *LP, if LP is not null. This is currently more-or-less
165 a placeholder for expansion. LIP, if non-null is a place to store the
193 index of the last invisible character in ther eturned string. */
166 index of the last invisible character in the returned string. */
167
168/* Current implementation:
169 \001 (^A) start non-visible characters
170 \002 (^B) end non-visible characters
171 all characters except \001 and \002 (following a \001) are copied to
172 the returned string; all characters except those between \001 and
173 \002 are assumed to be `visible'. */
174

--- 43 unchanged lines hidden (view full) ---

218 *r = '\0';
219 if (lp)
220 *lp = rl;
221 if (lip)
222 *lip = last;
223 return ret;
224}
225
226/* Just strip out RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE from
227 PMT and return the rest of PMT. */
228char *
229_rl_strip_prompt (pmt)
230 char *pmt;
231{
232 char *ret;
233
234 ret = expand_prompt (pmt, (int *)NULL, (int *)NULL);
235 return ret;
236}
237
238/*
239 * Expand the prompt string into the various display components, if
240 * necessary.
241 *
242 * local_prompt = expanded last line of string in rl_display_prompt
243 * (portion after the final newline)
244 * local_prompt_prefix = portion before last newline of rl_display_prompt,
245 * expanded via expand_prompt

--- 41 unchanged lines hidden (view full) ---

287 /* The portion of the prompt string up to and including the
288 final newline is now null-terminated. */
289 local_prompt_prefix = expand_prompt (prompt, &prefix_length, (int *)NULL);
290 *t = c;
291 return (prefix_length);
292 }
293}
294
295/* Initialize the VISIBLE_LINE and INVISIBLE_LINE arrays, and their associated
296 arrays of line break markers. MINSIZE is the minimum size of VISIBLE_LINE
297 and INVISIBLE_LINE; if it is greater than LINE_SIZE, LINE_SIZE is
298 increased. If the lines have already been allocated, this ensures that
299 they can hold at least MINSIZE characters. */
300static void
301init_line_structures (minsize)
302 int minsize;
303{
304 register int n;
305
306 if (invisible_line == 0) /* initialize it */
307 {
308 if (line_size < minsize)
309 line_size = minsize;
310 visible_line = xmalloc (line_size);
311 invisible_line = xmalloc (line_size);
312 }
313 else if (line_size < minsize) /* ensure it can hold MINSIZE chars */
314 {
315 line_size *= 2;
316 if (line_size < minsize)
317 line_size = minsize;
318 visible_line = xrealloc (visible_line, line_size);
319 invisible_line = xrealloc (invisible_line, line_size);
320 }
321
322 for (n = minsize; n < line_size; n++)
323 {
324 visible_line[n] = 0;
325 invisible_line[n] = 1;
326 }
327
328 if (vis_lbreaks == 0)
329 {
330 /* should be enough. */
331 inv_lbsize = vis_lbsize = 256;
332 inv_lbreaks = (int *)xmalloc (inv_lbsize * sizeof (int));
333 vis_lbreaks = (int *)xmalloc (vis_lbsize * sizeof (int));
334 inv_lbreaks[0] = vis_lbreaks[0] = 0;
335 }
336}
337
338/* Basic redisplay algorithm. */
339void
340rl_redisplay ()
341{
342 register int in, out, c, linenum, cursor_linenum;
343 register char *line;
344 int c_pos, inv_botlin, lb_botlin, lb_linenum;
345 int newlines, lpos, temp;
346 char *prompt_this_line;
347
348 if (!readline_echoing_p)
349 return;
350
351 if (!rl_display_prompt)
352 rl_display_prompt = "";
353
354 if (invisible_line == 0)
355 {
328 visible_line = xmalloc (line_size);
329 invisible_line = xmalloc (line_size);
330 for (in = 0; in < line_size; in++)
331 {
332 visible_line[in] = 0;
333 invisible_line[in] = 1;
334 }
335
336 /* should be enough, but then again, this is just for testing. */
337 inv_lbreaks = (int *)malloc (256 * sizeof (int));
338 vis_lbreaks = (int *)malloc (256 * sizeof (int));
339 inv_lbreaks[0] = vis_lbreaks[0] = 0;
340
356 init_line_structures (0);
357 rl_on_new_line ();
358 }
359
360 /* Draw the line into the buffer. */
361 c_pos = -1;
362
363 line = invisible_line;
364 out = inv_botlin = 0;

--- 41 unchanged lines hidden (view full) ---

406 {
407 int pmtlen;
408 prompt_this_line = strrchr (rl_display_prompt, '\n');
409 if (!prompt_this_line)
410 prompt_this_line = rl_display_prompt;
411 else
412 {
413 prompt_this_line++;
414 pmtlen = prompt_this_line - rl_display_prompt; /* temp var */
415 if (forced_display)
416 {
400 _rl_output_some_chars (rl_display_prompt, prompt_this_line - rl_display_prompt);
417 _rl_output_some_chars (rl_display_prompt, pmtlen);
418 /* Make sure we are at column zero even after a newline,
419 regardless of the state of terminal output processing. */
403 if (prompt_this_line[-2] != '\r')
420 if (pmtlen < 2 || prompt_this_line[-2] != '\r')
421 cr ();
422 }
423 }
424
425 pmtlen = strlen (prompt_this_line);
426 temp = pmtlen + out + 2;
427 if (temp >= line_size)
428 {
429 line_size = (temp + 1024) - (temp % 1024);
430 visible_line = xrealloc (visible_line, line_size);
431 line = invisible_line = xrealloc (invisible_line, line_size);
432 }
433 strncpy (line + out, prompt_this_line, pmtlen);
434 out += pmtlen;
435 line[out] = '\0';
436 wrap_offset = 0;
437 }
438
439#define CHECK_INV_LBREAKS() \
440 do { \
441 if (newlines >= (inv_lbsize - 2)) \
442 { \
443 inv_lbsize *= 2; \
444 inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
445 } \
446 } while (0)
447
448#define CHECK_LPOS() \
449 do { \
450 lpos++; \
451 if (lpos >= screenwidth) \
452 { \
453 if (newlines >= (inv_lbsize - 2)) \
454 { \
455 inv_lbsize *= 2; \
456 inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
457 } \
458 inv_lbreaks[++newlines] = out; \
459 lpos = 0; \
460 } \
461 } while (0)
462
463 /* inv_lbreaks[i] is where line i starts in the buffer. */
464 inv_lbreaks[newlines = 0] = 0;
465 lpos = out - wrap_offset;
466
467 /* XXX - what if lpos is already >= screenwidth before we start drawing the
468 contents of the command line? */
469 while (lpos >= screenwidth)
470 {
440#if 0
441 temp = ((newlines + 1) * screenwidth) - ((newlines == 0) ? wrap_offset : 0);
442#else
471 /* XXX - possible fix from Darin Johnson <darin@acuson.com> for prompt
472 string with invisible characters that is longer than the screen
445 width. */
473 width. XXX - this doesn't work right if invisible characters have
474 to be put on the second screen line -- it adds too much (the number
475 of invisible chars after the screenwidth). */
476 temp = ((newlines + 1) * screenwidth) + ((newlines == 0) ? wrap_offset : 0);
447#endif
477
478 inv_lbreaks[++newlines] = temp;
479 lpos -= screenwidth;
480 }
481
482 lb_linenum = 0;
483 for (in = 0; in < rl_end; in++)
484 {
485 c = (unsigned char)rl_line_buffer[in];

--- 16 unchanged lines hidden (view full) ---

502 {
503 if (_rl_output_meta_chars == 0)
504 {
505 sprintf (line + out, "\\%o", c);
506
507 if (lpos + 4 >= screenwidth)
508 {
509 temp = screenwidth - lpos;
510 CHECK_INV_LBREAKS ();
511 inv_lbreaks[++newlines] = out + temp;
512 lpos = 4 - temp;
513 }
514 else
515 lpos += 4;
516
517 out += 4;
518 }

--- 13 unchanged lines hidden (view full) ---

532#else
533 newout = out + 8 - lpos % 8;
534#endif
535 temp = newout - out;
536 if (lpos + temp >= screenwidth)
537 {
538 register int temp2;
539 temp2 = screenwidth - lpos;
540 CHECK_INV_LBREAKS ();
541 inv_lbreaks[++newlines] = out + temp2;
542 lpos = temp - temp2;
543 while (out < newout)
544 line[out++] = ' ';
545 }
546 else
547 {
548 while (out < newout)
549 line[out++] = ' ';
550 lpos += temp;
551 }
552 }
553#endif
554 else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && term_up && *term_up)
555 {
556 line[out++] = '\0'; /* XXX - sentinel */
557 CHECK_INV_LBREAKS ();
558 inv_lbreaks[++newlines] = out;
559 lpos = 0;
560 }
561 else if (CTRL_CHAR (c) || c == RUBOUT)
562 {
563 line[out++] = '^';
564 CHECK_LPOS();
565 line[out++] = CTRL_CHAR (c) ? UNCTRL (c) : '?';

--- 8 unchanged lines hidden (view full) ---

574 line[out] = '\0';
575 if (c_pos < 0)
576 {
577 c_pos = out;
578 lb_linenum = newlines;
579 }
580
581 inv_botlin = lb_botlin = newlines;
582 CHECK_INV_LBREAKS ();
583 inv_lbreaks[newlines+1] = out;
584 cursor_linenum = lb_linenum;
585
586 /* C_POS == position in buffer where cursor should be placed. */
587
588 /* PWP: now is when things get a bit hairy. The visible and invisible
589 line buffers are really multiple lines, which would wrap every
590 (screenwidth - 1) characters. Go through each in turn, finding

--- 89 unchanged lines hidden (view full) ---

680 characters, since it's not generally OK to just reprint
681 the characters from the current cursor position. But we
682 only need to reprint it if the cursor is before the last
683 invisible character in the prompt string. */
684 nleft = visible_length + wrap_offset;
685 if (cursor_linenum == 0 && wrap_offset > 0 && _rl_last_c_pos > 0 &&
686 _rl_last_c_pos <= last_invisible && local_prompt)
687 {
688#if defined (__MSDOS__)
689 putc ('\r', rl_outstream);
690#else
691 if (term_cr)
692 tputs (term_cr, 1, _rl_output_character_function);
693#endif
694 _rl_output_some_chars (local_prompt, nleft);
695 _rl_last_c_pos = nleft;
696 }
697
698 /* Where on that line? And where does that line start
699 in the buffer? */
700 pos = inv_lbreaks[cursor_linenum];
701 /* nleft == number of characters in the line buffer between the

--- 103 unchanged lines hidden (view full) ---

805 last_lmargin = lmargin;
806 }
807 }
808 fflush (rl_outstream);
809
810 /* Swap visible and non-visible lines. */
811 {
812 char *temp = visible_line;
775 int *itemp = vis_lbreaks;
813 int *itemp = vis_lbreaks, ntemp = vis_lbsize;
814
815 visible_line = invisible_line;
816 invisible_line = temp;
817
818 vis_lbreaks = inv_lbreaks;
819 inv_lbreaks = itemp;
820
821 vis_lbsize = inv_lbsize;
822 inv_lbsize = ntemp;
823
824 rl_display_fixed = 0;
825 /* If we are displaying on a single line, and last_lmargin is > 0, we
826 are not displaying any invisible characters, so set visible_wrap_offset
827 to 0. */
828 if (_rl_horizontal_scroll_mode && last_lmargin)
829 visible_wrap_offset = 0;
830 else
831 visible_wrap_offset = wrap_offset;

--- 106 unchanged lines hidden (view full) ---

938 `bold') that manifests itself on certain terminals. */
939
940 lendiff = local_prompt ? strlen (local_prompt) : 0;
941 od = ofd - old; /* index of first difference in visible line */
942 if (current_line == 0 && !_rl_horizontal_scroll_mode &&
943 term_cr && lendiff > visible_length && _rl_last_c_pos > 0 &&
944 od > lendiff && _rl_last_c_pos < last_invisible)
945 {
946#if defined (__MSDOS__)
947 putc ('\r', rl_outstream);
948#else
949 tputs (term_cr, 1, _rl_output_character_function);
950#endif
951 _rl_output_some_chars (local_prompt, lendiff);
952 _rl_last_c_pos = lendiff;
953 }
954
955 _rl_move_cursor_relative (od, old);
956
957 /* if (len (new) > len (old)) */
958 lendiff = (nls - nfd) - (ols - ofd);

--- 113 unchanged lines hidden (view full) ---

1072 _rl_last_c_pos = _rl_last_v_pos = 0;
1073 _rl_vis_botlin = last_lmargin = 0;
1074 if (vis_lbreaks)
1075 vis_lbreaks[0] = vis_lbreaks[1] = 0;
1076 visible_wrap_offset = 0;
1077 return 0;
1078}
1079
1080/* Tell the update routines that we have moved onto a new line with the
1081 prompt already displayed. Code originally from the version of readline
1082 distributed with CLISP. */
1083int
1084rl_on_new_line_with_prompt ()
1085{
1086 int prompt_size, i, l, real_screenwidth, newlines;
1087 char *prompt_last_line;
1088
1089 /* Initialize visible_line and invisible_line to ensure that they can hold
1090 the already-displayed prompt. */
1091 prompt_size = strlen (rl_prompt) + 1;
1092 init_line_structures (prompt_size);
1093
1094 /* Make sure the line structures hold the already-displayed prompt for
1095 redisplay. */
1096 strcpy (visible_line, rl_prompt);
1097 strcpy (invisible_line, rl_prompt);
1098
1099 /* If the prompt contains newlines, take the last tail. */
1100 prompt_last_line = strrchr (rl_prompt, '\n');
1101 if (!prompt_last_line)
1102 prompt_last_line = rl_prompt;
1103
1104 l = strlen (prompt_last_line);
1105 _rl_last_c_pos = l;
1106
1107 /* Dissect prompt_last_line into screen lines. Note that here we have
1108 to use the real screenwidth. Readline's notion of screenwidth might be
1109 one less, see terminal.c. */
1110 real_screenwidth = screenwidth + (_rl_term_autowrap ? 0 : 1);
1111 _rl_last_v_pos = l / real_screenwidth;
1112 /* If the prompt length is a multiple of real_screenwidth, we don't know
1113 whether the cursor is at the end of the last line, or already at the
1114 beginning of the next line. Output a newline just to be safe. */
1115 if (l > 0 && (l % real_screenwidth) == 0)
1116 _rl_output_some_chars ("\n", 1);
1117 last_lmargin = 0;
1118
1119 newlines = 0; i = 0;
1120 while (i <= l)
1121 {
1122 _rl_vis_botlin = newlines;
1123 vis_lbreaks[newlines++] = i;
1124 i += real_screenwidth;
1125 }
1126 vis_lbreaks[newlines] = l;
1127 visible_wrap_offset = 0;
1128
1129 return 0;
1130}
1131
1132/* Actually update the display, period. */
1133int
1134rl_forced_update_display ()
1135{
1136 if (visible_line)
1137 {
1138 register char *temp = visible_line;
1139

--- 41 unchanged lines hidden (view full) ---

1181 portion of the output buffer again. Which is cheaper? */
1182
1183 /* The above comment is left here for posterity. It is faster
1184 to print one character (non-control) than to print a control
1185 sequence telling the terminal to move forward one character.
1186 That kind of control is for people who don't know what the
1187 data is underneath the cursor. */
1188#if defined (HACK_TERMCAP_MOTION)
1089 extern char *term_forward_char;
1090
1189 if (term_forward_char)
1190 for (i = _rl_last_c_pos; i < new; i++)
1191 tputs (term_forward_char, 1, _rl_output_character_function);
1192 else
1193 for (i = _rl_last_c_pos; i < new; i++)
1194 putc (data[i], rl_outstream);
1195#else
1196 for (i = _rl_last_c_pos; i < new; i++)

--- 10 unchanged lines hidden (view full) ---

1207_rl_move_vert (to)
1208 int to;
1209{
1210 register int delta, i;
1211
1212 if (_rl_last_v_pos == to || to > screenheight)
1213 return;
1214
1117#if defined (__GO32__)
1118 {
1119 int row, col;
1120
1121 ScreenGetCursor (&row, &col);
1122 ScreenSetCursor ((row + to - _rl_last_v_pos), col);
1123 }
1124#else /* !__GO32__ */
1125
1215 if ((delta = to - _rl_last_v_pos) > 0)
1216 {
1217 for (i = 0; i < delta; i++)
1218 putc ('\n', rl_outstream);
1219#if defined (__MSDOS__)
1220 putc ('\r', rl_outstream);
1221#else
1222 tputs (term_cr, 1, _rl_output_character_function);
1223#endif
1224 _rl_last_c_pos = 0;
1225 }
1226 else
1227 { /* delta < 0 */
1228 if (term_up && *term_up)
1229 for (i = 0; i < -delta; i++)
1230 tputs (term_up, 1, _rl_output_character_function);
1231 }
1139#endif /* !__GO32__ */
1232
1233 _rl_last_v_pos = to; /* Now TO is here */
1234}
1235
1236/* Physically print C on rl_outstream. This is for functions which know
1237 how to optimize the display. Return the number of characters output. */
1238int
1239rl_show_char (c)
1240 int c;

--- 191 unchanged lines hidden (view full) ---

1432}
1433
1434/* Clear to the end of the line. COUNT is the minimum
1435 number of character spaces to clear, */
1436void
1437_rl_clear_to_eol (count)
1438 int count;
1439{
1347#if !defined (__GO32__)
1440 if (term_clreol)
1441 tputs (term_clreol, 1, _rl_output_character_function);
1442 else if (count)
1351#endif /* !__GO32__ */
1443 space_to_eol (count);
1444}
1445
1446/* Clear to the end of the line using spaces. COUNT is the minimum
1447 number of character spaces to clear, */
1448static void
1449space_to_eol (count)
1450 int count;

--- 4 unchanged lines hidden (view full) ---

1455 putc (' ', rl_outstream);
1456
1457 _rl_last_c_pos += count;
1458}
1459
1460void
1461_rl_clear_screen ()
1462{
1372#if !defined (__GO32__)
1463 if (term_clrpag)
1464 tputs (term_clrpag, 1, _rl_output_character_function);
1465 else
1376#endif /* !__GO32__ */
1466 crlf ();
1467}
1468
1469/* Insert COUNT characters from STRING to the output stream. */
1470static void
1471insert_some_chars (string, count)
1472 char *string;
1473 int count;
1474{
1386#if defined (__GO32__)
1387 int row, col, width;
1388 char *row_start;
1389
1390 ScreenGetCursor (&row, &col);
1391 width = ScreenCols ();
1392 row_start = ScreenPrimary + (row * width);
1393
1394 memcpy (row_start + col + count, row_start + col, width - col - count);
1395
1396 /* Place the text on the screen. */
1397 _rl_output_some_chars (string, count);
1398#else /* !_GO32 */
1399
1475 /* If IC is defined, then we do not have to "enter" insert mode. */
1476 if (term_IC)
1477 {
1478 char *buffer;
1479 buffer = tgoto (term_IC, 0, count);
1480 tputs (buffer, 1, _rl_output_character_function);
1481 _rl_output_some_chars (string, count);
1482 }

--- 16 unchanged lines hidden (view full) ---

1499 /* Print the text. */
1500 _rl_output_some_chars (string, count);
1501
1502 /* If there is a string to turn off insert mode, we had best use
1503 it now. */
1504 if (term_ei && *term_ei)
1505 tputs (term_ei, 1, _rl_output_character_function);
1506 }
1432#endif /* !__GO32__ */
1507}
1508
1509/* Delete COUNT characters from the display line. */
1510static void
1511delete_chars (count)
1512 int count;
1513{
1440#if defined (__GO32__)
1441 int row, col, width;
1442 char *row_start;
1443
1444 ScreenGetCursor (&row, &col);
1445 width = ScreenCols ();
1446 row_start = ScreenPrimary + (row * width);
1447
1448 memcpy (row_start + col, row_start + col + count, width - col - count);
1449 memset (row_start + width - count, 0, count * 2);
1450#else /* !_GO32 */
1451
1514 if (count > screenwidth) /* XXX */
1515 return;
1516
1517 if (term_DC && *term_DC)
1518 {
1519 char *buffer;
1520 buffer = tgoto (term_DC, count, count);
1521 tputs (buffer, count, _rl_output_character_function);
1522 }
1523 else
1524 {
1525 if (term_dc && *term_dc)
1526 while (count--)
1527 tputs (term_dc, 1, _rl_output_character_function);
1528 }
1467#endif /* !__GO32__ */
1529}
1530
1531void
1532_rl_update_final ()
1533{
1534 int full_lines;
1535
1536 full_lines = 0;

--- 5 unchanged lines hidden (view full) ---

1542 _rl_vis_botlin--;
1543 full_lines = 1;
1544 }
1545 _rl_move_vert (_rl_vis_botlin);
1546 /* If we've wrapped lines, remove the final xterm line-wrap flag. */
1547 if (full_lines && _rl_term_autowrap && (VIS_LLEN(_rl_vis_botlin) == screenwidth))
1548 {
1549 char *last_line;
1550#if 0
1551 last_line = &visible_line[inv_lbreaks[_rl_vis_botlin]];
1552#else
1553 last_line = &visible_line[vis_lbreaks[_rl_vis_botlin]];
1554#endif
1555 _rl_move_cursor_relative (screenwidth - 1, last_line);
1556 _rl_clear_to_eol (0);
1557 putc (last_line[screenwidth - 1], rl_outstream);
1558 }
1559 _rl_vis_botlin = 0;
1560 crlf ();
1561 fflush (rl_outstream);
1562 rl_display_fixed++;
1563}
1564
1565/* Move to the start of the current line. */
1566static void
1567cr ()
1568{
1569 if (term_cr)
1570 {
1571#if defined (__MSDOS__)
1572 putc ('\r', rl_outstream);
1573#else
1574 tputs (term_cr, 1, _rl_output_character_function);
1575#endif
1576 _rl_last_c_pos = 0;
1577 }
1578}
1579
1580/* Redraw the last line of a multi-line prompt that may possibly contain
1581 terminal escape sequences. Called with the cursor at column 0 of the
1582 line to draw the prompt on. */
1583static void
1584redraw_prompt (t)
1585 char *t;
1586{
1587 char *oldp, *oldl, *oldlprefix;
1588 int oldlen, oldlast, oldplen;
1589
1590 /* Geez, I should make this a struct. */
1591 oldp = rl_display_prompt;
1592 oldl = local_prompt;
1593 oldlprefix = local_prompt_prefix;
1594 oldlen = visible_length;
1595 oldplen = prefix_length;
1596 oldlast = last_invisible;
1597
1598 rl_display_prompt = t;
1599 local_prompt = expand_prompt (t, &visible_length, &last_invisible);
1600 local_prompt_prefix = (char *)NULL;
1601 rl_forced_update_display ();
1602
1603 rl_display_prompt = oldp;
1604 local_prompt = oldl;
1605 local_prompt_prefix = oldlprefix;
1606 visible_length = oldlen;
1607 prefix_length = oldplen;
1608 last_invisible = oldlast;
1609}
1610
1611/* Redisplay the current line after a SIGWINCH is received. */
1612void
1613_rl_redisplay_after_sigwinch ()
1614{
1515 char *t, *oldp, *oldl, *oldlprefix;
1615 char *t;
1616
1617 /* Clear the current line and put the cursor at column 0. Make sure
1618 the right thing happens if we have wrapped to a new screen line. */
1619 if (term_cr)
1620 {
1621#if defined (__MSDOS__)
1622 putc ('\r', rl_outstream);
1623#else
1624 tputs (term_cr, 1, _rl_output_character_function);
1625#endif
1626 _rl_last_c_pos = 0;
1627#if defined (__MSDOS__)
1628 space_to_eol (screenwidth);
1629 putc ('\r', rl_outstream);
1630#else
1631 if (term_clreol)
1632 tputs (term_clreol, 1, _rl_output_character_function);
1633 else
1634 {
1635 space_to_eol (screenwidth);
1636 tputs (term_cr, 1, _rl_output_character_function);
1637 }
1638#endif
1639 if (_rl_last_v_pos > 0)
1640 _rl_move_vert (0);
1641 }
1642 else
1643 crlf ();
1644
1645 /* Redraw only the last line of a multi-line prompt. */
1646 t = strrchr (rl_display_prompt, '\n');
1647 if (t)
1539 {
1540 oldp = rl_display_prompt;
1541 oldl = local_prompt;
1542 oldlprefix = local_prompt_prefix;
1543 rl_display_prompt = ++t;
1544 local_prompt = local_prompt_prefix = (char *)NULL;
1545 rl_forced_update_display ();
1546 rl_display_prompt = oldp;
1547 local_prompt = oldl;
1548 local_prompt_prefix = oldlprefix;
1549 }
1648 redraw_prompt (++t);
1649 else
1650 rl_forced_update_display ();
1651}
1652
1653void
1654_rl_clean_up_for_exit ()
1655{
1656 if (readline_echoing_p)

--- 8 unchanged lines hidden (view full) ---

1665void
1666_rl_erase_entire_line ()
1667{
1668 cr ();
1669 _rl_clear_to_eol (0);
1670 cr ();
1671 fflush (rl_outstream);
1672}
1673
1674/* return the `current display line' of the cursor -- the number of lines to
1675 move up to get to the first screen line of the current readline line. */
1676int
1677_rl_current_display_line ()
1678{
1679 int ret, nleft;
1680
1681 /* Find out whether or not there might be invisible characters in the
1682 editing buffer. */
1683 if (rl_display_prompt == rl_prompt)
1684 nleft = _rl_last_c_pos - screenwidth - rl_visible_prompt_length;
1685 else
1686 nleft = _rl_last_c_pos - screenwidth;
1687
1688 if (nleft > 0)
1689 ret = 1 + nleft / screenwidth;
1690 else
1691 ret = 0;
1692
1693 return ret;
1694}