OpenCoverage

display.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/lib/readline/display.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* display.c -- readline redisplay facility. */-
2-
3/* Copyright (C) 1987-2017 Free Software Foundation, Inc.-
4-
5 This file is part of the GNU Readline Library (Readline), a library -
6 for reading lines of text with interactive input and history editing.-
7-
8 Readline is free software: you can redistribute it and/or modify-
9 it under the terms of the GNU General Public License as published by-
10 the Free Software Foundation, either version 3 of the License, or-
11 (at your option) any later version.-
12-
13 Readline is distributed in the hope that it will be useful,-
14 but WITHOUT ANY WARRANTY; without even the implied warranty of-
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-
16 GNU General Public License for more details.-
17-
18 You should have received a copy of the GNU General Public License-
19 along with Readline. If not, see <http://www.gnu.org/licenses/>.-
20*/-
21-
22#define READLINE_LIBRARY-
23-
24#if defined (HAVE_CONFIG_H)-
25# include <config.h>-
26#endif-
27-
28#include <sys/types.h>-
29-
30#if defined (HAVE_UNISTD_H)-
31# include <unistd.h>-
32#endif /* HAVE_UNISTD_H */-
33-
34#include "posixstat.h"-
35-
36#if defined (HAVE_STDLIB_H)-
37# include <stdlib.h>-
38#else-
39# include "ansi_stdlib.h"-
40#endif /* HAVE_STDLIB_H */-
41-
42#include <stdio.h>-
43-
44#ifdef __MSDOS__-
45# include <pc.h>-
46#endif-
47-
48/* System-specific feature definitions and include files. */-
49#include "rldefs.h"-
50#include "rlmbutil.h"-
51-
52/* Termcap library stuff. */-
53#include "tcap.h"-
54-
55/* Some standard library routines. */-
56#include "readline.h"-
57#include "history.h"-
58-
59#include "rlprivate.h"-
60#include "xmalloc.h"-
61-
62#if !defined (strchr) && !defined (__STDC__)-
63extern char *strchr (), *strrchr ();-
64#endif /* !strchr && !__STDC__ */-
65-
66static void update_line PARAMS((char *, char *, int, int, int, int));-
67static void space_to_eol PARAMS((int));-
68static void delete_chars PARAMS((int));-
69static void insert_some_chars PARAMS((char *, int, int));-
70static void open_some_spaces PARAMS((int));-
71static void cr PARAMS((void));-
72static void redraw_prompt PARAMS((char *));-
73-
74/* Values for FLAGS */-
75#define PMT_MULTILINE 0x01-
76-
77static char *expand_prompt PARAMS((char *, int, int *, int *, int *, int *));-
78-
79/* State of visible and invisible lines. */-
80struct line_state-
81 {-
82 char *line;-
83 int *lbreaks;-
84 int lbsize;-
85#if defined (HANDLE_MULTIBYTE)-
86 int wbsize;-
87 int *wrapped_line;-
88#endif-
89 };-
90-
91/* The line display buffers. One is the line currently displayed on-
92 the screen. The other is the line about to be displayed. */-
93static struct line_state line_state_array[2];-
94static struct line_state *line_state_visible = &line_state_array[0];-
95static struct line_state *line_state_invisible = &line_state_array[1];-
96static int line_structures_initialized = 0;-
97-
98/* Backwards-compatible names. */-
99#define inv_lbreaks (line_state_invisible->lbreaks)-
100#define inv_lbsize (line_state_invisible->lbsize)-
101#define vis_lbreaks (line_state_visible->lbreaks)-
102#define vis_lbsize (line_state_visible->lbsize)-
103-
104#define visible_line (line_state_visible->line)-
105#define invisible_line (line_state_invisible->line)-
106-
107#if defined (HANDLE_MULTIBYTE)-
108static int _rl_col_width PARAMS((const char *, int, int, int));-
109#else-
110# define _rl_col_width(l, s, e, f) (((e) <= (s)) ? 0 : (e) - (s))-
111#endif-
112-
113/* Heuristic used to decide whether it is faster to move from CUR to NEW-
114 by backing up or outputting a carriage return and moving forward. CUR-
115 and NEW are either both buffer positions or absolute screen positions. */-
116#define CR_FASTER(new, cur) (((new) + 1) < ((cur) - (new)))-
117-
118/* _rl_last_c_pos is an absolute cursor position in multibyte locales and a-
119 buffer index in others. This macro is used when deciding whether the-
120 current cursor position is in the middle of a prompt string containing-
121 invisible characters. XXX - might need to take `modmark' into account. */-
122/* XXX - only valid when tested against _rl_last_c_pos; buffer indices need-
123 to use prompt_last_invisible directly. */-
124#define PROMPT_ENDING_INDEX \-
125 ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) ? prompt_physical_chars : prompt_last_invisible+1)-
126 -
127/* **************************************************************** */-
128/* */-
129/* Display stuff */-
130/* */-
131/* **************************************************************** */-
132-
133/* This is the stuff that is hard for me. I never seem to write good-
134 display routines in C. Let's see how I do this time. */-
135-
136/* (PWP) Well... Good for a simple line updater, but totally ignores-
137 the problems of input lines longer than the screen width.-
138-
139 update_line and the code that calls it makes a multiple line,-
140 automatically wrapping line update. Careful attention needs-
141 to be paid to the vertical position variables. */-
142-
143/* Keep two buffers; one which reflects the current contents of the-
144 screen, and the other to draw what we think the new contents should-
145 be. Then compare the buffers, and make whatever changes to the-
146 screen itself that we should. Finally, make the buffer that we-
147 just drew into be the one which reflects the current contents of the-
148 screen, and place the cursor where it belongs.-
149-
150 Commands that want to can fix the display themselves, and then let-
151 this function know that the display has been fixed by setting the-
152 RL_DISPLAY_FIXED variable. This is good for efficiency. */-
153-
154/* Application-specific redisplay function. */-
155rl_voidfunc_t *rl_redisplay_function = rl_redisplay;-
156-
157/* Global variables declared here. */-
158/* What YOU turn on when you have handled all redisplay yourself. */-
159int rl_display_fixed = 0;-
160-
161/* The stuff that gets printed out before the actual text of the line.-
162 This is usually pointing to rl_prompt. */-
163char *rl_display_prompt = (char *)NULL;-
164-
165/* Variables used to include the editing mode in the prompt. */-
166char *_rl_emacs_mode_str;-
167int _rl_emacs_modestr_len;-
168-
169char *_rl_vi_ins_mode_str;-
170int _rl_vi_ins_modestr_len;-
171-
172char *_rl_vi_cmd_mode_str;-
173int _rl_vi_cmd_modestr_len;-
174-
175/* Pseudo-global variables declared here. */-
176-
177/* Hints for other parts of readline to give to the display engine. */-
178int _rl_suppress_redisplay = 0;-
179int _rl_want_redisplay = 0;-
180-
181/* The visible cursor position. If you print some text, adjust this. */-
182/* NOTE: _rl_last_c_pos is used as a buffer index when not in a locale-
183 supporting multibyte characters, and an absolute cursor position when-
184 in such a locale. This is an artifact of the donated multibyte support.-
185 Care must be taken when modifying its value. */-
186int _rl_last_c_pos = 0;-
187int _rl_last_v_pos = 0;-
188-
189/* Number of physical lines consumed by the current line buffer currently-
190 on screen minus 1. */-
191int _rl_vis_botlin = 0;-
192-
193/* This is a hint update_line gives to rl_redisplay that it has adjusted the-
194 value of _rl_last_c_pos *and* taken the presence of any invisible chars in-
195 the prompt into account. rl_redisplay notes this and does not do the-
196 adjustment itself. */-
197static int cpos_adjusted;-
198-
199/* The index into the line buffer corresponding to the cursor position */-
200static int cpos_buffer_position;-
201-
202/* A flag to note when we're displaying the first line of the prompt */-
203static int displaying_prompt_first_line;-
204/* The number of multibyte characters in the prompt, if any */-
205static int prompt_multibyte_chars;-
206-
207static int _rl_inv_botlin = 0;-
208-
209/* Variables used only in this file. */-
210/* The last left edge of text that was displayed. This is used when-
211 doing horizontal scrolling. It shifts in thirds of a screenwidth. */-
212static int last_lmargin;-
213-
214/* A buffer for `modeline' messages. */-
215static char *msg_buf = 0;-
216static int msg_bufsiz = 0;-
217-
218/* Non-zero forces the redisplay even if we thought it was unnecessary. */-
219static int forced_display;-
220-
221/* Default and initial buffer size. Can grow. */-
222static int line_size = 1024;-
223-
224/* Variables to keep track of the expanded prompt string, which may-
225 include invisible characters. */-
226-
227static char *local_prompt, *local_prompt_prefix;-
228static int local_prompt_len;-
229static int prompt_prefix_length;-
230/* Number of chars in the buffer that contribute to visible chars on the screen.-
231 This might be different from the number of physical chars in the presence-
232 of multibyte characters */-
233static int prompt_visible_length;-
234-
235/* The number of invisible characters in the line currently being-
236 displayed on the screen. */-
237static int visible_wrap_offset;-
238-
239/* The number of invisible characters in the prompt string. Static so it-
240 can be shared between rl_redisplay and update_line */-
241static int wrap_offset;-
242-
243/* The index of the last invisible character in the prompt string. */-
244static int prompt_last_invisible;-
245-
246/* The length (buffer offset) of the first line of the last (possibly-
247 multi-line) buffer displayed on the screen. */-
248static int visible_first_line_len;-
249-
250/* Number of invisible characters on the first physical line of the prompt.-
251 Only valid when the number of physical characters in the prompt exceeds-
252 (or is equal to) _rl_screenwidth. */-
253static int prompt_invis_chars_first_line;-
254-
255static int prompt_last_screen_line;-
256-
257static int prompt_physical_chars;-
258-
259/* An array of indexes into the prompt string where we will break physical-
260 screen lines. It's easier to compute in expand_prompt and use later in-
261 rl_redisplay instead of having rl_redisplay try to guess about invisible-
262 characters in the prompt or use heuristics about where they are. */-
263static int *local_prompt_newlines;-
264-
265/* set to a non-zero value by rl_redisplay if we are marking modified history-
266 lines and the current line is so marked. */-
267static int modmark;-
268-
269static int line_totbytes;-
270-
271/* Variables to save and restore prompt and display information. */-
272-
273/* These are getting numerous enough that it's time to create a struct. */-
274-
275static char *saved_local_prompt;-
276static char *saved_local_prefix;-
277static int *saved_local_prompt_newlines;-
278-
279static int saved_last_invisible;-
280static int saved_visible_length;-
281static int saved_prefix_length;-
282static int saved_local_length;-
283static int saved_invis_chars_first_line;-
284static int saved_physical_chars;-
285-
286/* Return a string indicating the editing mode, for use in the prompt. */-
287-
288static char *-
289prompt_modestr (int *lenp)-
290{-
291 if (rl_editing_mode == emacs_mode)
rl_editing_mode == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
292 {-
293 if (lenp)
lenpDescription
TRUEnever evaluated
FALSEnever evaluated
0
294 *lenp = _rl_emacs_mode_str ? _rl_emacs_modestr_len : RL_EMACS_MODESTR_DEFLEN;
never executed: *lenp = _rl_emacs_mode_str ? _rl_emacs_modestr_len : 1;
_rl_emacs_mode_strDescription
TRUEnever evaluated
FALSEnever evaluated
0
295 return _rl_emacs_mode_str ? _rl_emacs_mode_str : RL_EMACS_MODESTR_DEFAULT;
never executed: return _rl_emacs_mode_str ? _rl_emacs_mode_str : "@";
0
296 }-
297 else if (_rl_keymap == vi_insertion_keymap)
_rl_keymap == ...sertion_keymapDescription
TRUEnever evaluated
FALSEnever evaluated
0
298 {-
299 if (lenp)
lenpDescription
TRUEnever evaluated
FALSEnever evaluated
0
300 *lenp = _rl_vi_ins_mode_str ? _rl_vi_ins_modestr_len : RL_VI_INS_MODESTR_DEFLEN;
never executed: *lenp = _rl_vi_ins_mode_str ? _rl_vi_ins_modestr_len : 5;
_rl_vi_ins_mode_strDescription
TRUEnever evaluated
FALSEnever evaluated
0
301 return _rl_vi_ins_mode_str ? _rl_vi_ins_mode_str : RL_VI_INS_MODESTR_DEFAULT; /* vi insert mode */
never executed: return _rl_vi_ins_mode_str ? _rl_vi_ins_mode_str : "(ins)";
0
302 }-
303 else-
304 {-
305 if (lenp)
lenpDescription
TRUEnever evaluated
FALSEnever evaluated
0
306 *lenp = _rl_vi_cmd_mode_str ? _rl_vi_cmd_modestr_len : RL_VI_CMD_MODESTR_DEFLEN;
never executed: *lenp = _rl_vi_cmd_mode_str ? _rl_vi_cmd_modestr_len : 5;
_rl_vi_cmd_mode_strDescription
TRUEnever evaluated
FALSEnever evaluated
0
307 return _rl_vi_cmd_mode_str ? _rl_vi_cmd_mode_str : RL_VI_CMD_MODESTR_DEFAULT; /* vi command mode */
never executed: return _rl_vi_cmd_mode_str ? _rl_vi_cmd_mode_str : "(cmd)";
0
308 }-
309}-
310-
311/* Expand the prompt string S and return the number of visible-
312 characters in *LP, if LP is not null. This is currently more-or-less-
313 a placeholder for expansion. LIP, if non-null is a place to store the-
314 index of the last invisible character in the returned string. NIFLP,-
315 if non-zero, is a place to store the number of invisible characters in-
316 the first prompt line. The previous are used as byte counts -- indexes-
317 into a character buffer. *VLP gets the number of physical characters in-
318 the expanded prompt (visible length) */-
319-
320/* Current implementation:-
321 \001 (^A) start non-visible characters-
322 \002 (^B) end non-visible characters-
323 all characters except \001 and \002 (following a \001) are copied to-
324 the returned string; all characters except those between \001 and-
325 \002 are assumed to be `visible'. */ -
326-
327/* Possible values for FLAGS:-
328 PMT_MULTILINE caller indicates that this is part of a multiline prompt-
329*/-
330-
331/* This approximates the number of lines the prompt will take when displayed */-
332#define APPROX_DIV(n, d) (((n) < (d)) ? 1 : ((n) / (d)) + 1)-
333-
334static char *-
335expand_prompt (char *pmt, int flags, int *lp, int *lip, int *niflp, int *vlp)-
336{-
337 char *r, *ret, *p, *igstart, *nprompt, *ms;-
338 int l, rl, last, ignoring, ninvis, invfl, invflset, ind, pind, physchars;-
339 int mlen, newlines, newlines_guess, bound;-
340 int mb_cur_max;-
341-
342 /* We only expand the mode string for the last line of a multiline prompt-
343 (a prompt with embedded newlines). */-
344 ms = (((pmt == rl_prompt) ^ (flags & PMT_MULTILINE)) && _rl_show_mode_in_prompt) ? prompt_modestr (&mlen) : 0;
((pmt == rl_pr...flags & 0x01))Description
TRUEnever evaluated
FALSEnever evaluated
_rl_show_mode_in_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
345 if (ms)
msDescription
TRUEnever evaluated
FALSEnever evaluated
0
346 {-
347 l = strlen (pmt);-
348 nprompt = (char *)xmalloc (l + mlen + 1);-
349 memcpy (nprompt, ms, mlen);-
350 strcpy (nprompt + mlen, pmt);-
351 }
never executed: end of block
0
352 else-
353 nprompt = pmt;
never executed: nprompt = pmt;
0
354-
355 mb_cur_max = MB_CUR_MAX;-
356-
357 if (_rl_screenwidth == 0)
_rl_screenwidth == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
358 _rl_get_screen_size (0, 0); /* avoid division by zero */
never executed: _rl_get_screen_size (0, 0);
0
359-
360 /* Short-circuit if we can. We can do this if we are treating the prompt as-
361 a sequence of bytes and there are no invisible characters in the prompt-
362 to deal with. Since we populate local_prompt_newlines, we have to run-
363 through the rest of the function if this prompt looks like it's going to-
364 be longer than one screen line. */-
365 if ((mb_cur_max <= 1 || rl_byte_oriented) && strchr (nprompt, RL_PROMPT_START_IGNORE) == 0)
mb_cur_max <= 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_orientedDescription
TRUEnever evaluated
FALSEnever evaluated
(__extension__...\001' ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...t_p ( '\001' )Description
TRUEnever evaluated
FALSEnever evaluated
!__builtin_con..._p ( nprompt )Description
TRUEnever evaluated
FALSEnever evaluated
( '\001' ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
366 {-
367 l = strlen (nprompt);-
368 if (l < (_rl_screenwidth > 0 ? _rl_screenwidth : 80))
l < (_rl_scree...eenwidth : 80)Description
TRUEnever evaluated
FALSEnever evaluated
0
369 {-
370 r = (nprompt == pmt) ? savestring (pmt) : nprompt;
(nprompt == pmt)Description
TRUEnever evaluated
FALSEnever evaluated
0
371 if (lp)
lpDescription
TRUEnever evaluated
FALSEnever evaluated
0
372 *lp = l;
never executed: *lp = l;
0
373 if (lip)
lipDescription
TRUEnever evaluated
FALSEnever evaluated
0
374 *lip = 0;
never executed: *lip = 0;
0
375 if (niflp)
niflpDescription
TRUEnever evaluated
FALSEnever evaluated
0
376 *niflp = 0;
never executed: *niflp = 0;
0
377 if (vlp)
vlpDescription
TRUEnever evaluated
FALSEnever evaluated
0
378 *vlp = l;
never executed: *vlp = l;
0
379-
380 local_prompt_newlines = (int *) xrealloc (local_prompt_newlines, sizeof (int) * 2);-
381 local_prompt_newlines[0] = 0;-
382 local_prompt_newlines[1] = -1;-
383-
384 return r;
never executed: return r;
0
385 }-
386 }
never executed: end of block
0
387-
388 l = strlen (nprompt); /* XXX */-
389 r = ret = (char *)xmalloc (l + 1);-
390-
391 /* Guess at how many screen lines the prompt will take to size the array that-
392 keeps track of where the line wraps happen */-
393 newlines_guess = (_rl_screenwidth > 0) ? APPROX_DIV(l, _rl_screenwidth) : APPROX_DIV(l, 80);
(_rl_screenwidth > 0)Description
TRUEnever evaluated
FALSEnever evaluated
((l) < (_rl_screenwidth))Description
TRUEnever evaluated
FALSEnever evaluated
((l) < (80))Description
TRUEnever evaluated
FALSEnever evaluated
0
394 local_prompt_newlines = (int *) xrealloc (local_prompt_newlines, sizeof (int) * (newlines_guess + 1));-
395 local_prompt_newlines[newlines = 0] = 0;-
396 for (rl = 1; rl <= newlines_guess; rl++)
rl <= newlines_guessDescription
TRUEnever evaluated
FALSEnever evaluated
0
397 local_prompt_newlines[rl] = -1;
never executed: local_prompt_newlines[rl] = -1;
0
398-
399 rl = physchars = 0; /* mode string now part of nprompt */-
400 invfl = 0; /* invisible chars in first line of prompt */-
401 invflset = 0; /* we only want to set invfl once */-
402 igstart = 0; /* we're not ignoring any characters yet */-
403-
404 for (ignoring = last = ninvis = 0, p = nprompt; p && *p; p++)
pDescription
TRUEnever evaluated
FALSEnever evaluated
*pDescription
TRUEnever evaluated
FALSEnever evaluated
0
405 {-
406 /* This code strips the invisible character string markers-
407 RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE */-
408 if (ignoring == 0 && *p == RL_PROMPT_START_IGNORE) /* XXX - check ignoring? */
ignoring == 0Description
TRUEnever evaluated
FALSEnever evaluated
*p == '\001'Description
TRUEnever evaluated
FALSEnever evaluated
0
409 {-
410 ignoring = 1;-
411 igstart = p;-
412 continue;
never executed: continue;
0
413 }-
414 else if (ignoring && *p == RL_PROMPT_END_IGNORE)
ignoringDescription
TRUEnever evaluated
FALSEnever evaluated
*p == '\002'Description
TRUEnever evaluated
FALSEnever evaluated
0
415 {-
416 ignoring = 0;-
417 if (p != (igstart + 1))
p != (igstart + 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
418 last = r - ret - 1;
never executed: last = r - ret - 1;
0
419 continue;
never executed: continue;
0
420 }-
421 else-
422 {-
423#if defined (HANDLE_MULTIBYTE)-
424 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
425 {-
426 pind = p - nprompt;-
427 ind = _rl_find_next_mbchar (nprompt, pind, 1, MB_FIND_NONZERO);-
428 l = ind - pind;-
429 while (l--)
l--Description
TRUEnever evaluated
FALSEnever evaluated
0
430 *r++ = *p++;
never executed: *r++ = *p++;
0
431 if (!ignoring)
!ignoringDescription
TRUEnever evaluated
FALSEnever evaluated
0
432 {-
433 /* rl ends up being assigned to prompt_visible_length,-
434 which is the number of characters in the buffer that-
435 contribute to characters on the screen, which might-
436 not be the same as the number of physical characters-
437 on the screen in the presence of multibyte characters */-
438 rl += ind - pind;-
439 physchars += _rl_col_width (nprompt, pind, ind, 0);-
440 }
never executed: end of block
0
441 else-
442 ninvis += ind - pind;
never executed: ninvis += ind - pind;
0
443 p--; /* compensate for later increment */-
444 }
never executed: end of block
0
445 else-
446#endif-
447 {-
448 *r++ = *p;-
449 if (!ignoring)
!ignoringDescription
TRUEnever evaluated
FALSEnever evaluated
0
450 {-
451 rl++; /* visible length byte counter */-
452 physchars++;-
453 }
never executed: end of block
0
454 else-
455 ninvis++; /* invisible chars byte counter */
never executed: ninvis++;
0
456 }-
457-
458 if (invflset == 0 && physchars >= _rl_screenwidth)
invflset == 0Description
TRUEnever evaluated
FALSEnever evaluated
physchars >= _rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
459 {-
460 invfl = ninvis;-
461 invflset = 1;-
462 }
never executed: end of block
0
463-
464 if (physchars >= (bound = (newlines + 1) * _rl_screenwidth) && local_prompt_newlines[newlines+1] == -1)
physchars >= (...l_screenwidth)Description
TRUEnever evaluated
FALSEnever evaluated
local_prompt_n...lines+1] == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
465 {-
466 int new;-
467 if (physchars > bound) /* should rarely happen */
physchars > boundDescription
TRUEnever evaluated
FALSEnever evaluated
0
468 {-
469#if defined (HANDLE_MULTIBYTE)-
470 *r = '\0'; /* need null-termination for strlen */-
471 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
472 new = _rl_find_prev_mbchar (ret, r - ret, MB_FIND_ANY);
never executed: new = _rl_find_prev_mbchar (ret, r - ret, 0x00);
0
473 else-
474#endif-
475 new = r - ret - (physchars - bound); /* XXX */
never executed: new = r - ret - (physchars - bound);
0
476 }-
477 else-
478 new = r - ret;
never executed: new = r - ret;
0
479 local_prompt_newlines[++newlines] = new;-
480 }
never executed: end of block
0
481 }
never executed: end of block
0
482 }-
483-
484 if (rl < _rl_screenwidth)
rl < _rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
485 invfl = ninvis;
never executed: invfl = ninvis;
0
486-
487 *r = '\0';-
488 if (lp)
lpDescription
TRUEnever evaluated
FALSEnever evaluated
0
489 *lp = rl;
never executed: *lp = rl;
0
490 if (lip)
lipDescription
TRUEnever evaluated
FALSEnever evaluated
0
491 *lip = last;
never executed: *lip = last;
0
492 if (niflp)
niflpDescription
TRUEnever evaluated
FALSEnever evaluated
0
493 *niflp = invfl;
never executed: *niflp = invfl;
0
494 if (vlp)
vlpDescription
TRUEnever evaluated
FALSEnever evaluated
0
495 *vlp = physchars;
never executed: *vlp = physchars;
0
496-
497 if (nprompt != pmt)
nprompt != pmtDescription
TRUEnever evaluated
FALSEnever evaluated
0
498 free (nprompt);
never executed: free (nprompt);
0
499-
500 return ret;
never executed: return ret;
0
501}-
502-
503/* Just strip out RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE from-
504 PMT and return the rest of PMT. */-
505char *-
506_rl_strip_prompt (char *pmt)-
507{-
508 char *ret;-
509-
510 ret = expand_prompt (pmt, 0, (int *)NULL, (int *)NULL, (int *)NULL, (int *)NULL);-
511 return ret;
never executed: return ret;
0
512}-
513-
514void-
515_rl_reset_prompt (void)-
516{-
517 rl_visible_prompt_length = rl_expand_prompt (rl_prompt);-
518}
never executed: end of block
0
519-
520/*-
521 * Expand the prompt string into the various display components, if-
522 * necessary.-
523 *-
524 * local_prompt = expanded last line of string in rl_display_prompt-
525 * (portion after the final newline)-
526 * local_prompt_prefix = portion before last newline of rl_display_prompt,-
527 * expanded via expand_prompt-
528 * prompt_visible_length = number of visible characters in local_prompt-
529 * prompt_prefix_length = number of visible characters in local_prompt_prefix-
530 *-
531 * It also tries to keep track of the number of invisible characters in the-
532 * prompt string, and where they are.-
533 *-
534 * This function is called once per call to readline(). It may also be-
535 * called arbitrarily to expand the primary prompt.-
536 *-
537 * The return value is the number of visible characters on the last line-
538 * of the (possibly multi-line) prompt. In this case, multi-line means-
539 * there are embedded newlines in the prompt string itself, not that the-
540 * number of physical characters exceeds the screen width and the prompt-
541 * wraps.-
542 */-
543int-
544rl_expand_prompt (char *prompt)-
545{-
546 char *p, *t;-
547 int c;-
548-
549 /* Clear out any saved values. */-
550 FREE (local_prompt);
never executed: free (local_prompt);
local_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
551 FREE (local_prompt_prefix);
never executed: free (local_prompt_prefix);
local_prompt_prefixDescription
TRUEnever evaluated
FALSEnever evaluated
0
552-
553 local_prompt = local_prompt_prefix = (char *)0;-
554 local_prompt_len = 0;-
555 prompt_last_invisible = prompt_invis_chars_first_line = 0;-
556 prompt_visible_length = prompt_physical_chars = 0;-
557-
558 if (prompt == 0 || *prompt == 0)
prompt == 0Description
TRUEnever evaluated
FALSEnever evaluated
*prompt == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
559 return (0);
never executed: return (0);
0
560-
561 p = strrchr (prompt, '\n');-
562 if (p == 0)
p == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
563 {-
564 /* The prompt is only one logical line, though it might wrap. */-
565 local_prompt = expand_prompt (prompt, 0, &prompt_visible_length,-
566 &prompt_last_invisible,-
567 &prompt_invis_chars_first_line,-
568 &prompt_physical_chars);-
569 local_prompt_prefix = (char *)0;-
570 local_prompt_len = local_prompt ? strlen (local_prompt) : 0;
local_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
571 return (prompt_visible_length);
never executed: return (prompt_visible_length);
0
572 }-
573 else-
574 {-
575 /* The prompt spans multiple lines. */-
576 t = ++p;-
577 local_prompt = expand_prompt (p, PMT_MULTILINE,-
578 &prompt_visible_length,-
579 &prompt_last_invisible,-
580 &prompt_invis_chars_first_line,-
581 &prompt_physical_chars);-
582 c = *t; *t = '\0';-
583 /* The portion of the prompt string up to and including the-
584 final newline is now null-terminated. */-
585 local_prompt_prefix = expand_prompt (prompt, PMT_MULTILINE,-
586 &prompt_prefix_length,-
587 (int *)NULL,-
588 (int *)NULL,-
589 (int *)NULL);-
590 *t = c;-
591 local_prompt_len = local_prompt ? strlen (local_prompt) : 0;
local_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
592 return (prompt_prefix_length);
never executed: return (prompt_prefix_length);
0
593 }-
594}-
595-
596/* Initialize the VISIBLE_LINE and INVISIBLE_LINE arrays, and their associated-
597 arrays of line break markers. MINSIZE is the minimum size of VISIBLE_LINE-
598 and INVISIBLE_LINE; if it is greater than LINE_SIZE, LINE_SIZE is-
599 increased. If the lines have already been allocated, this ensures that-
600 they can hold at least MINSIZE characters. */-
601static void-
602init_line_structures (int minsize)-
603{-
604 register int n;-
605-
606 if (invisible_line == 0) /* initialize it */
(line_state_in...le->line) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
607 {-
608 if (line_size < minsize)
line_size < minsizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
609 line_size = minsize;
never executed: line_size = minsize;
0
610 visible_line = (char *)xmalloc (line_size);-
611 invisible_line = (char *)xmalloc (line_size);-
612 }
never executed: end of block
0
613 else if (line_size < minsize) /* ensure it can hold MINSIZE chars */
line_size < minsizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
614 {-
615 line_size *= 2;-
616 if (line_size < minsize)
line_size < minsizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
617 line_size = minsize;
never executed: line_size = minsize;
0
618 visible_line = (char *)xrealloc (visible_line, line_size);-
619 invisible_line = (char *)xrealloc (invisible_line, line_size);-
620 }
never executed: end of block
0
621-
622 for (n = minsize; n < line_size; n++)
n < line_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
623 {-
624 visible_line[n] = 0;-
625 invisible_line[n] = 1;-
626 }
never executed: end of block
0
627-
628 if (vis_lbreaks == 0)
(line_state_vi...>lbreaks) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
629 {-
630 /* should be enough. */-
631 inv_lbsize = vis_lbsize = 256;-
632-
633#if defined (HANDLE_MULTIBYTE)-
634 line_state_visible->wbsize = vis_lbsize;-
635 line_state_visible->wrapped_line = (int *)xmalloc (line_state_visible->wbsize * sizeof (int));-
636-
637 line_state_invisible->wbsize = inv_lbsize;-
638 line_state_invisible->wrapped_line = (int *)xmalloc (line_state_invisible->wbsize * sizeof (int));-
639#endif-
640-
641 inv_lbreaks = (int *)xmalloc (inv_lbsize * sizeof (int));-
642 vis_lbreaks = (int *)xmalloc (vis_lbsize * sizeof (int));-
643 inv_lbreaks[0] = vis_lbreaks[0] = 0;-
644 }
never executed: end of block
0
645-
646 line_structures_initialized = 1;-
647}
never executed: end of block
0
648 -
649/* Basic redisplay algorithm. See comments inline. */-
650void-
651rl_redisplay (void)-
652{-
653 register int in, out, c, linenum, cursor_linenum;-
654 register char *line;-
655 int inv_botlin, lb_botlin, lb_linenum, o_cpos;-
656 int newlines, lpos, temp, n0, num, prompt_lines_estimate;-
657 char *prompt_this_line;-
658 int mb_cur_max = MB_CUR_MAX;-
659#if defined (HANDLE_MULTIBYTE)-
660 wchar_t wc;-
661 size_t wc_bytes;-
662 int wc_width;-
663 mbstate_t ps;-
664 int _rl_wrapped_multicolumn = 0;-
665#endif-
666-
667 if (_rl_echoing_p == 0)
_rl_echoing_p == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
668 return;
never executed: return;
0
669-
670 /* Block keyboard interrupts because this function manipulates global-
671 data structures. */-
672 _rl_block_sigint (); -
673 RL_SETSTATE (RL_STATE_REDISPLAYING);-
674-
675 if (!rl_display_prompt)
!rl_display_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
676 rl_display_prompt = "";
never executed: rl_display_prompt = "";
0
677-
678 if (line_structures_initialized == 0)
line_structure...itialized == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
679 {-
680 init_line_structures (0);-
681 rl_on_new_line ();-
682 }
never executed: end of block
0
683-
684 /* Draw the line into the buffer. */-
685 cpos_buffer_position = -1;-
686-
687 prompt_multibyte_chars = prompt_visible_length - prompt_physical_chars;-
688-
689 line = invisible_line;-
690 out = inv_botlin = 0;-
691-
692 /* Mark the line as modified or not. We only do this for history-
693 lines. */-
694 modmark = 0;-
695 if (_rl_mark_modified_lines && current_history () && rl_undo_list)
_rl_mark_modified_linesDescription
TRUEnever evaluated
FALSEnever evaluated
current_history ()Description
TRUEnever evaluated
FALSEnever evaluated
rl_undo_listDescription
TRUEnever evaluated
FALSEnever evaluated
0
696 {-
697 line[out++] = '*';-
698 line[out] = '\0';-
699 modmark = 1;-
700 }
never executed: end of block
0
701-
702 /* If someone thought that the redisplay was handled, but the currently-
703 visible line has a different modification state than the one about-
704 to become visible, then correct the caller's misconception. */-
705 if (visible_line[0] != invisible_line[0])
(line_state_vi...ible->line)[0]Description
TRUEnever evaluated
FALSEnever evaluated
0
706 rl_display_fixed = 0;
never executed: rl_display_fixed = 0;
0
707-
708 /* If the prompt to be displayed is the `primary' readline prompt (the-
709 one passed to readline()), use the values we have already expanded.-
710 If not, use what's already in rl_display_prompt. WRAP_OFFSET is the-
711 number of non-visible characters in the prompt string. */-
712 /* This is where we output the characters in the prompt before the last-
713 newline, if any. If there aren't any embedded newlines, we don't-
714 write anything. Copy the last line of the prompt string into the line in-
715 any case */-
716 if (rl_display_prompt == rl_prompt || local_prompt)
rl_display_prompt == rl_promptDescription
TRUEnever evaluated
FALSEnever evaluated
local_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
717 {-
718 if (local_prompt_prefix && forced_display)
local_prompt_prefixDescription
TRUEnever evaluated
FALSEnever evaluated
forced_displayDescription
TRUEnever evaluated
FALSEnever evaluated
0
719 _rl_output_some_chars (local_prompt_prefix, strlen (local_prompt_prefix));
never executed: _rl_output_some_chars (local_prompt_prefix, strlen (local_prompt_prefix));
0
720-
721 if (local_prompt_len > 0)
local_prompt_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
722 {-
723 temp = local_prompt_len + out + 2;-
724 if (temp >= line_size)
temp >= line_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
725 {-
726 line_size = (temp + 1024) - (temp % 1024);-
727 visible_line = (char *)xrealloc (visible_line, line_size);-
728 line = invisible_line = (char *)xrealloc (invisible_line, line_size);-
729 }
never executed: end of block
0
730 strncpy (line + out, local_prompt, local_prompt_len);-
731 out += local_prompt_len;-
732 }
never executed: end of block
0
733 line[out] = '\0';-
734 wrap_offset = local_prompt_len - prompt_visible_length;-
735 }
never executed: end of block
0
736 else-
737 {-
738 int pmtlen;-
739 prompt_this_line = strrchr (rl_display_prompt, '\n');-
740 if (!prompt_this_line)
!prompt_this_lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
741 prompt_this_line = rl_display_prompt;
never executed: prompt_this_line = rl_display_prompt;
0
742 else-
743 {-
744 prompt_this_line++;-
745 pmtlen = prompt_this_line - rl_display_prompt; /* temp var */-
746 if (forced_display)
forced_displayDescription
TRUEnever evaluated
FALSEnever evaluated
0
747 {-
748 _rl_output_some_chars (rl_display_prompt, pmtlen);-
749 /* Make sure we are at column zero even after a newline,-
750 regardless of the state of terminal output processing. */-
751 if (pmtlen < 2 || prompt_this_line[-2] != '\r')
pmtlen < 2Description
TRUEnever evaluated
FALSEnever evaluated
prompt_this_line[-2] != '\r'Description
TRUEnever evaluated
FALSEnever evaluated
0
752 cr ();
never executed: cr ();
0
753 }
never executed: end of block
0
754 }
never executed: end of block
0
755-
756 prompt_physical_chars = pmtlen = strlen (prompt_this_line);-
757 temp = pmtlen + out + 2;-
758 if (temp >= line_size)
temp >= line_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
759 {-
760 line_size = (temp + 1024) - (temp % 1024);-
761 visible_line = (char *)xrealloc (visible_line, line_size);-
762 line = invisible_line = (char *)xrealloc (invisible_line, line_size);-
763 }
never executed: end of block
0
764 strncpy (line + out, prompt_this_line, pmtlen);-
765 out += pmtlen;-
766 line[out] = '\0';-
767 wrap_offset = prompt_invis_chars_first_line = 0;-
768 }
never executed: end of block
0
769-
770#if defined (HANDLE_MULTIBYTE)-
771#define CHECK_INV_LBREAKS() \-
772 do { \-
773 if (newlines >= (inv_lbsize - 2)) \-
774 { \-
775 inv_lbsize *= 2; \-
776 inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \-
777 } \-
778 if (newlines >= (line_state_invisible->wbsize - 2)) \-
779 { \-
780 line_state_invisible->wbsize *= 2; \-
781 line_state_invisible->wrapped_line = (int *)xrealloc (line_state_invisible->wrapped_line, line_state_invisible->wbsize * sizeof(int)); \-
782 } \-
783 } while (0)-
784#else-
785#define CHECK_INV_LBREAKS() \-
786 do { \-
787 if (newlines >= (inv_lbsize - 2)) \-
788 { \-
789 inv_lbsize *= 2; \-
790 inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \-
791 } \-
792 } while (0)-
793#endif /* !HANDLE_MULTIBYTE */-
794-
795#if defined (HANDLE_MULTIBYTE) -
796#define CHECK_LPOS() \-
797 do { \-
798 lpos++; \-
799 if (lpos >= _rl_screenwidth) \-
800 { \-
801 if (newlines >= (inv_lbsize - 2)) \-
802 { \-
803 inv_lbsize *= 2; \-
804 inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \-
805 } \-
806 inv_lbreaks[++newlines] = out; \-
807 if (newlines >= (line_state_invisible->wbsize - 2)) \-
808 { \-
809 line_state_invisible->wbsize *= 2; \-
810 line_state_invisible->wrapped_line = (int *)xrealloc (line_state_invisible->wrapped_line, line_state_invisible->wbsize * sizeof(int)); \-
811 } \-
812 line_state_invisible->wrapped_line[newlines] = _rl_wrapped_multicolumn; \-
813 lpos = 0; \-
814 } \-
815 } while (0)-
816#else-
817#define CHECK_LPOS() \-
818 do { \-
819 lpos++; \-
820 if (lpos >= _rl_screenwidth) \-
821 { \-
822 if (newlines >= (inv_lbsize - 2)) \-
823 { \-
824 inv_lbsize *= 2; \-
825 inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \-
826 } \-
827 inv_lbreaks[++newlines] = out; \-
828 lpos = 0; \-
829 } \-
830 } while (0)-
831#endif-
832-
833 /* inv_lbreaks[i] is where line i starts in the buffer. */-
834 inv_lbreaks[newlines = 0] = 0;-
835 /* lpos is a physical cursor position, so it needs to be adjusted by the-
836 number of invisible characters in the prompt, per line. We compute-
837 the line breaks in the prompt string in expand_prompt, taking invisible-
838 characters into account, and if lpos exceeds the screen width, we copy-
839 the data in the loop below. */-
840 lpos = prompt_physical_chars + modmark;-
841-
842#if defined (HANDLE_MULTIBYTE)-
843 memset (line_state_invisible->wrapped_line, 0, line_state_invisible->wbsize * sizeof (int));-
844 num = 0;-
845#endif-
846-
847 /* prompt_invis_chars_first_line is the number of invisible characters in-
848 the first physical line of the prompt.-
849 wrap_offset - prompt_invis_chars_first_line is usually the number of-
850 invis chars on the second (or, more generally, last) line. */-
851-
852 /* This is zero-based, used to set the newlines */-
853 prompt_lines_estimate = lpos / _rl_screenwidth;-
854-
855 /* what if lpos is already >= _rl_screenwidth before we start drawing the-
856 contents of the command line? */-
857 if (lpos >= _rl_screenwidth)
lpos >= _rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
858 {-
859 temp = 0;-
860-
861 /* first copy the linebreaks array we computed in expand_prompt */-
862 while (local_prompt_newlines[newlines+1] != -1)
local_prompt_n...lines+1] != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
863 {-
864 temp = local_prompt_newlines[newlines+1];-
865 inv_lbreaks[++newlines] = temp;-
866 }
never executed: end of block
0
867-
868 /* Now set lpos from the last newline */-
869 if (mb_cur_max > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
prompt_multibyte_chars > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
870 lpos = _rl_col_width (local_prompt, temp, local_prompt_len, 1) - (wrap_offset - prompt_invis_chars_first_line);
never executed: lpos = _rl_col_width (local_prompt, temp, local_prompt_len, 1) - (wrap_offset - prompt_invis_chars_first_line);
0
871 else-
872 lpos -= (_rl_screenwidth * newlines);
never executed: lpos -= (_rl_screenwidth * newlines);
0
873 }-
874-
875 prompt_last_screen_line = newlines;-
876-
877 /* Draw the rest of the line (after the prompt) into invisible_line, keeping-
878 track of where the cursor is (cpos_buffer_position), the number of the-
879 line containing the cursor (lb_linenum), the last line number (lb_botlin-
880 and inv_botlin).-
881 It maintains an array of line breaks for display (inv_lbreaks).-
882 This handles expanding tabs for display and displaying meta characters. */-
883 lb_linenum = 0;-
884#if defined (HANDLE_MULTIBYTE)-
885 in = 0;-
886 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
887 {-
888 memset (&ps, 0, sizeof (mbstate_t));-
889 if (_rl_utf8locale && UTF8_SINGLEBYTE(rl_line_buffer[0]))
_rl_utf8localeDescription
TRUEnever evaluated
FALSEnever evaluated
(((rl_line_buf... & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
890 {-
891 wc = (wchar_t)rl_line_buffer[0];-
892 wc_bytes = 1;-
893 }
never executed: end of block
0
894 else-
895 wc_bytes = mbrtowc (&wc, rl_line_buffer, rl_end, &ps);
never executed: wc_bytes = mbrtowc (&wc, rl_line_buffer, rl_end, &ps);
0
896 }-
897 else-
898 wc_bytes = 1;
never executed: wc_bytes = 1;
0
899 while (in < rl_end)
in < rl_endDescription
TRUEnever evaluated
FALSEnever evaluated
0
900#else-
901 for (in = 0; in < rl_end; in++)-
902#endif-
903 {-
904 c = (unsigned char)rl_line_buffer[in];-
905-
906#if defined (HANDLE_MULTIBYTE)-
907 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
908 {-
909 if (MB_INVALIDCH (wc_bytes))
(wc_bytes) == (size_t)-1Description
TRUEnever evaluated
FALSEnever evaluated
(wc_bytes) == (size_t)-2Description
TRUEnever evaluated
FALSEnever evaluated
0
910 {-
911 /* Byte sequence is invalid or shortened. Assume that the-
912 first byte represents a character. */-
913 wc_bytes = 1;-
914 /* Assume that a character occupies a single column. */-
915 wc_width = 1;-
916 memset (&ps, 0, sizeof (mbstate_t));-
917 }
never executed: end of block
0
918 else if (MB_NULLWCH (wc_bytes))
((wc_bytes) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
919 break; /* Found '\0' */
never executed: break;
0
920 else-
921 {-
922 temp = WCWIDTH (wc);-
923 wc_width = (temp >= 0) ? temp : 1;
(temp >= 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
924 }
never executed: end of block
0
925 }-
926#endif-
927-
928 if (out + 8 >= line_size) /* XXX - 8 for \t */
out + 8 >= line_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
929 {-
930 line_size *= 2;-
931 visible_line = (char *)xrealloc (visible_line, line_size);-
932 invisible_line = (char *)xrealloc (invisible_line, line_size);-
933 line = invisible_line;-
934 }
never executed: end of block
0
935-
936 if (in == rl_point)
in == rl_pointDescription
TRUEnever evaluated
FALSEnever evaluated
0
937 {-
938 cpos_buffer_position = out;-
939 lb_linenum = newlines;-
940 }
never executed: end of block
0
941-
942#if defined (HANDLE_MULTIBYTE)-
943 if (META_CHAR (c) && _rl_output_meta_chars == 0) /* XXX - clean up */
(c) > 0x07fDescription
TRUEnever evaluated
FALSEnever evaluated
(c) <= 255Description
TRUEnever evaluated
FALSEnever evaluated
_rl_output_meta_chars == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
944#else-
945 if (META_CHAR (c))-
946#endif-
947 {-
948 if (_rl_output_meta_chars == 0)
_rl_output_meta_chars == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
949 {-
950 sprintf (line + out, "\\%o", c);-
951-
952 if (lpos + 4 >= _rl_screenwidth)
lpos + 4 >= _rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
953 {-
954 temp = _rl_screenwidth - lpos;-
955 CHECK_INV_LBREAKS ();
never executed: end of block
never executed: end of block
newlines >= ((...->lbsize) - 2)Description
TRUEnever evaluated
FALSEnever evaluated
newlines >= (l...e->wbsize - 2)Description
TRUEnever evaluated
FALSEnever evaluated
0
956 inv_lbreaks[++newlines] = out + temp;-
957#if defined (HANDLE_MULTIBYTE)-
958 line_state_invisible->wrapped_line[newlines] = _rl_wrapped_multicolumn;-
959#endif-
960 lpos = 4 - temp;-
961 }
never executed: end of block
0
962 else-
963 lpos += 4;
never executed: lpos += 4;
0
964-
965 out += 4;-
966 }
never executed: end of block
0
967 else-
968 {-
969 line[out++] = c;-
970 CHECK_LPOS();
never executed: end of block
never executed: end of block
never executed: end of block
lpos >= _rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
newlines >= ((...->lbsize) - 2)Description
TRUEnever evaluated
FALSEnever evaluated
newlines >= (l...e->wbsize - 2)Description
TRUEnever evaluated
FALSEnever evaluated
0
971 }
never executed: end of block
0
972 }-
973#if defined (DISPLAY_TABS)-
974 else if (c == '\t')
c == '\t'Description
TRUEnever evaluated
FALSEnever evaluated
0
975 {-
976 register int newout;-
977-
978#if 0-
979 newout = (out | (int)7) + 1;-
980#else-
981 newout = out + 8 - lpos % 8;-
982#endif-
983 temp = newout - out;-
984 if (lpos + temp >= _rl_screenwidth)
lpos + temp >= _rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
985 {-
986 register int temp2;-
987 temp2 = _rl_screenwidth - lpos;-
988 CHECK_INV_LBREAKS ();
never executed: end of block
never executed: end of block
newlines >= ((...->lbsize) - 2)Description
TRUEnever evaluated
FALSEnever evaluated
newlines >= (l...e->wbsize - 2)Description
TRUEnever evaluated
FALSEnever evaluated
0
989 inv_lbreaks[++newlines] = out + temp2;-
990#if defined (HANDLE_MULTIBYTE)-
991 line_state_invisible->wrapped_line[newlines] = _rl_wrapped_multicolumn;-
992#endif-
993 lpos = temp - temp2;-
994 while (out < newout)
out < newoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
995 line[out++] = ' ';
never executed: line[out++] = ' ';
0
996 }
never executed: end of block
0
997 else-
998 {-
999 while (out < newout)
out < newoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
1000 line[out++] = ' ';
never executed: line[out++] = ' ';
0
1001 lpos += temp;-
1002 }
never executed: end of block
0
1003 }-
1004#endif-
1005 else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up)
c == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
_rl_horizontal...roll_mode == 0Description
TRUEnever evaluated
FALSEnever evaluated
_rl_term_upDescription
TRUEnever evaluated
FALSEnever evaluated
*_rl_term_upDescription
TRUEnever evaluated
FALSEnever evaluated
0
1006 {-
1007 line[out++] = '\0'; /* XXX - sentinel */-
1008 CHECK_INV_LBREAKS ();
never executed: end of block
never executed: end of block
newlines >= ((...->lbsize) - 2)Description
TRUEnever evaluated
FALSEnever evaluated
newlines >= (l...e->wbsize - 2)Description
TRUEnever evaluated
FALSEnever evaluated
0
1009 inv_lbreaks[++newlines] = out;-
1010#if defined (HANDLE_MULTIBYTE)-
1011 line_state_invisible->wrapped_line[newlines] = _rl_wrapped_multicolumn;-
1012#endif-
1013 lpos = 0;-
1014 }
never executed: end of block
0
1015 else if (CTRL_CHAR (c) || c == RUBOUT)
(c) < 0x020Description
TRUEnever evaluated
FALSEnever evaluated
(((c) & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
c == 0x7fDescription
TRUEnever evaluated
FALSEnever evaluated
0
1016 {-
1017 line[out++] = '^';-
1018 CHECK_LPOS();
never executed: end of block
never executed: end of block
never executed: end of block
lpos >= _rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
newlines >= ((...->lbsize) - 2)Description
TRUEnever evaluated
FALSEnever evaluated
newlines >= (l...e->wbsize - 2)Description
TRUEnever evaluated
FALSEnever evaluated
0
1019 line[out++] = CTRL_CHAR (c) ? UNCTRL (c) : '?';
never executed: end of block
never executed: __res = toupper ( (unsigned char)((c)|0x40) );
never executed: __res = (*__ctype_toupper_loc ())[(int) ( (unsigned char)((c)|0x40) )];
sizeof ( (unsi...c)|0x40) ) > 1Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...r)((c)|0x40) )Description
TRUEnever evaluated
FALSEnever evaluated
(c) < 0x020Description
TRUEnever evaluated
FALSEnever evaluated
(((c) & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
((unsigned cha... (((c)|0x40)))Description
TRUEnever evaluated
FALSEnever evaluated
((*__ctype_b_l...int) _ISlower)Description
TRUEnever evaluated
FALSEnever evaluated
__c < -128Description
TRUEnever evaluated
FALSEnever evaluated
__c > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
1020 CHECK_LPOS();
never executed: end of block
never executed: end of block
never executed: end of block
lpos >= _rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
newlines >= ((...->lbsize) - 2)Description
TRUEnever evaluated
FALSEnever evaluated
newlines >= (l...e->wbsize - 2)Description
TRUEnever evaluated
FALSEnever evaluated
0
1021 }
never executed: end of block
0
1022 else-
1023 {-
1024#if defined (HANDLE_MULTIBYTE)-
1025 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1026 {-
1027 register int i;-
1028-
1029 _rl_wrapped_multicolumn = 0;-
1030-
1031 if (_rl_screenwidth < lpos + wc_width)
_rl_screenwidt...pos + wc_widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1032 for (i = lpos; i < _rl_screenwidth; i++)
i < _rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1033 {-
1034 /* The space will be removed in update_line() */-
1035 line[out++] = ' ';-
1036 _rl_wrapped_multicolumn++;-
1037 CHECK_LPOS();
never executed: end of block
never executed: end of block
never executed: end of block
lpos >= _rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
newlines >= ((...->lbsize) - 2)Description
TRUEnever evaluated
FALSEnever evaluated
newlines >= (l...e->wbsize - 2)Description
TRUEnever evaluated
FALSEnever evaluated
0
1038 }
never executed: end of block
0
1039 if (in == rl_point)
in == rl_pointDescription
TRUEnever evaluated
FALSEnever evaluated
0
1040 {-
1041 cpos_buffer_position = out;-
1042 lb_linenum = newlines;-
1043 }
never executed: end of block
0
1044 for (i = in; i < in+wc_bytes; i++)
i < in+wc_bytesDescription
TRUEnever evaluated
FALSEnever evaluated
0
1045 line[out++] = rl_line_buffer[i];
never executed: line[out++] = rl_line_buffer[i];
0
1046 for (i = 0; i < wc_width; i++)
i < wc_widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1047 CHECK_LPOS();
never executed: end of block
never executed: end of block
never executed: end of block
never executed: end of block
lpos >= _rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
newlines >= ((...->lbsize) - 2)Description
TRUEnever evaluated
FALSEnever evaluated
newlines >= (l...e->wbsize - 2)Description
TRUEnever evaluated
FALSEnever evaluated
0
1048 }
never executed: end of block
0
1049 else-
1050 {-
1051 line[out++] = c;-
1052 CHECK_LPOS();
never executed: end of block
never executed: end of block
never executed: end of block
lpos >= _rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
newlines >= ((...->lbsize) - 2)Description
TRUEnever evaluated
FALSEnever evaluated
newlines >= (l...e->wbsize - 2)Description
TRUEnever evaluated
FALSEnever evaluated
0
1053 }
never executed: end of block
0
1054#else-
1055 line[out++] = c;-
1056 CHECK_LPOS();-
1057#endif-
1058 }-
1059-
1060#if defined (HANDLE_MULTIBYTE)-
1061 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1062 {-
1063 in += wc_bytes;-
1064 if (_rl_utf8locale && UTF8_SINGLEBYTE(rl_line_buffer[in]))
_rl_utf8localeDescription
TRUEnever evaluated
FALSEnever evaluated
(((rl_line_buf... & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1065 {-
1066 wc = (wchar_t)rl_line_buffer[in];-
1067 wc_bytes = 1;-
1068 memset (&ps, 0, sizeof (mbstate_t)); /* re-init state */-
1069 }
never executed: end of block
0
1070 else-
1071 wc_bytes = mbrtowc (&wc, rl_line_buffer + in, rl_end - in, &ps);
never executed: wc_bytes = mbrtowc (&wc, rl_line_buffer + in, rl_end - in, &ps);
0
1072 }-
1073 else-
1074 in++;
never executed: in++;
0
1075#endif-
1076 }-
1077 line[out] = '\0';-
1078 line_totbytes = out;-
1079 if (cpos_buffer_position < 0)
cpos_buffer_position < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1080 {-
1081 cpos_buffer_position = out;-
1082 lb_linenum = newlines;-
1083 }
never executed: end of block
0
1084-
1085 inv_botlin = lb_botlin = _rl_inv_botlin = newlines;-
1086 CHECK_INV_LBREAKS ();
never executed: end of block
never executed: end of block
newlines >= ((...->lbsize) - 2)Description
TRUEnever evaluated
FALSEnever evaluated
newlines >= (l...e->wbsize - 2)Description
TRUEnever evaluated
FALSEnever evaluated
0
1087 inv_lbreaks[newlines+1] = out;-
1088#if defined (HANDLE_MULTIBYTE)-
1089 /* This should be 0 anyway */-
1090 line_state_invisible->wrapped_line[newlines+1] = _rl_wrapped_multicolumn;-
1091#endif-
1092 cursor_linenum = lb_linenum;-
1093-
1094 /* CPOS_BUFFER_POSITION == position in buffer where cursor should be placed.-
1095 CURSOR_LINENUM == line number where the cursor should be placed. */-
1096-
1097 /* PWP: now is when things get a bit hairy. The visible and invisible-
1098 line buffers are really multiple lines, which would wrap every-
1099 (screenwidth - 1) characters. Go through each in turn, finding-
1100 the changed region and updating it. The line order is top to bottom. */-
1101-
1102 /* If we can move the cursor up and down, then use multiple lines,-
1103 otherwise, let long lines display in a single terminal line, and-
1104 horizontally scroll it. */-
1105 displaying_prompt_first_line = 1;-
1106 if (_rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up)
_rl_horizontal...roll_mode == 0Description
TRUEnever evaluated
FALSEnever evaluated
_rl_term_upDescription
TRUEnever evaluated
FALSEnever evaluated
*_rl_term_upDescription
TRUEnever evaluated
FALSEnever evaluated
0
1107 {-
1108 int nleft, pos, changed_screen_line, tx;-
1109-
1110 if (!rl_display_fixed || forced_display)
!rl_display_fixedDescription
TRUEnever evaluated
FALSEnever evaluated
forced_displayDescription
TRUEnever evaluated
FALSEnever evaluated
0
1111 {-
1112 forced_display = 0;-
1113-
1114 /* If we have more than a screenful of material to display, then-
1115 only display a screenful. We should display the last screen,-
1116 not the first. */-
1117 if (out >= _rl_screenchars)
out >= _rl_screencharsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1118 {-
1119#if defined (HANDLE_MULTIBYTE)-
1120 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1121 out = _rl_find_prev_mbchar (line, _rl_screenchars, MB_FIND_ANY);
never executed: out = _rl_find_prev_mbchar (line, _rl_screenchars, 0x00);
0
1122 else-
1123#endif-
1124 out = _rl_screenchars - 1;
never executed: out = _rl_screenchars - 1;
0
1125 }-
1126-
1127 /* The first line is at character position 0 in the buffer. The-
1128 second and subsequent lines start at inv_lbreaks[N], offset by-
1129 OFFSET (which has already been calculated above). */-
1130-
1131#define INVIS_FIRST() (prompt_physical_chars > _rl_screenwidth ? prompt_invis_chars_first_line : wrap_offset)-
1132#define WRAP_OFFSET(line, offset) ((line == 0) \-
1133 ? (offset ? INVIS_FIRST() : 0) \-
1134 : ((line == prompt_last_screen_line) ? wrap_offset-prompt_invis_chars_first_line : 0))-
1135#define W_OFFSET(line, offset) ((line) == 0 ? offset : 0)-
1136#define VIS_LLEN(l) ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))-
1137#define INV_LLEN(l) (inv_lbreaks[l+1] - inv_lbreaks[l])-
1138#define VIS_CHARS(line) (visible_line + vis_lbreaks[line])-
1139#define VIS_LINE(line) ((line) > _rl_vis_botlin) ? "" : VIS_CHARS(line)-
1140#define INV_LINE(line) (invisible_line + inv_lbreaks[line])-
1141-
1142#define OLD_CPOS_IN_PROMPT() (cpos_adjusted == 0 && \-
1143 _rl_last_c_pos != o_cpos && \-
1144 _rl_last_c_pos > wrap_offset && \-
1145 o_cpos < prompt_last_invisible)-
1146-
1147 /* For each line in the buffer, do the updating display. */-
1148 for (linenum = 0; linenum <= inv_botlin; linenum++)
linenum <= inv_botlinDescription
TRUEnever evaluated
FALSEnever evaluated
0
1149 {-
1150 /* This can lead us astray if we execute a program that changes-
1151 the locale from a non-multibyte to a multibyte one. */-
1152 o_cpos = _rl_last_c_pos;-
1153 cpos_adjusted = 0;-
1154 update_line (VIS_LINE(linenum), INV_LINE(linenum), linenum,-
1155 VIS_LLEN(linenum), INV_LLEN(linenum), inv_botlin);-
1156-
1157 /* update_line potentially changes _rl_last_c_pos, but doesn't-
1158 take invisible characters into account, since _rl_last_c_pos-
1159 is an absolute cursor position in a multibyte locale. We-
1160 choose to (mostly) compensate for that here, rather than-
1161 change update_line itself. There are several cases in which-
1162 update_line adjusts _rl_last_c_pos itself (so it can pass-
1163 _rl_move_cursor_relative accurate values); it communicates-
1164 this back by setting cpos_adjusted. If we assume that-
1165 _rl_last_c_pos is correct (an absolute cursor position) each-
1166 time update_line is called, then we can assume in our-
1167 calculations that o_cpos does not need to be adjusted by-
1168 wrap_offset. */-
1169 if (linenum == 0 && (mb_cur_max > 1 && rl_byte_oriented == 0) && OLD_CPOS_IN_PROMPT())
linenum == 0Description
TRUEnever evaluated
FALSEnever evaluated
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
cpos_adjusted == 0Description
TRUEnever evaluated
FALSEnever evaluated
_rl_last_c_pos != o_cposDescription
TRUEnever evaluated
FALSEnever evaluated
_rl_last_c_pos > wrap_offsetDescription
TRUEnever evaluated
FALSEnever evaluated
o_cpos < prompt_last_invisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1170 _rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */
never executed: _rl_last_c_pos -= prompt_invis_chars_first_line;
0
1171 else if (cpos_adjusted == 0 &&
cpos_adjusted == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1172 linenum == prompt_last_screen_line &&
linenum == pro...st_screen_lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1173 prompt_physical_chars > _rl_screenwidth &&
prompt_physica...rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1174 (mb_cur_max > 1 && rl_byte_oriented == 0) &&
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1175 _rl_last_c_pos != o_cpos &&
_rl_last_c_pos != o_cposDescription
TRUEnever evaluated
FALSEnever evaluated
0
1176 _rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - prompt_invis_chars_first_line)) /* XXX - rethink this last one */
_rl_last_c_pos...rs_first_line)Description
TRUEnever evaluated
FALSEnever evaluated
0
1177 /* This assumes that all the invisible characters are split-
1178 between the first and last lines of the prompt, if the -
1179 prompt consumes more than two lines. It's usually right */-
1180 /* XXX - not sure this is ever executed */-
1181 _rl_last_c_pos -= (wrap_offset-prompt_invis_chars_first_line);
never executed: _rl_last_c_pos -= (wrap_offset-prompt_invis_chars_first_line);
0
1182-
1183 /* If this is the line with the prompt, we might need to-
1184 compensate for invisible characters in the new line. Do-
1185 this only if there is not more than one new line (which-
1186 implies that we completely overwrite the old visible line)-
1187 and the new line is shorter than the old. Make sure we are-
1188 at the end of the new line before clearing. */-
1189 if (linenum == 0 &&
linenum == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1190 inv_botlin == 0 && _rl_last_c_pos == out &&
inv_botlin == 0Description
TRUEnever evaluated
FALSEnever evaluated
_rl_last_c_pos == outDescription
TRUEnever evaluated
FALSEnever evaluated
0
1191 (wrap_offset > visible_wrap_offset) &&
(wrap_offset >...e_wrap_offset)Description
TRUEnever evaluated
FALSEnever evaluated
0
1192 (_rl_last_c_pos < visible_first_line_len))
(_rl_last_c_po...irst_line_len)Description
TRUEnever evaluated
FALSEnever evaluated
0
1193 {-
1194 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1195 nleft = _rl_screenwidth - _rl_last_c_pos;
never executed: nleft = _rl_screenwidth - _rl_last_c_pos;
0
1196 else-
1197 nleft = _rl_screenwidth + wrap_offset - _rl_last_c_pos;
never executed: nleft = _rl_screenwidth + wrap_offset - _rl_last_c_pos;
0
1198 if (nleft)
nleftDescription
TRUEnever evaluated
FALSEnever evaluated
0
1199 _rl_clear_to_eol (nleft);
never executed: _rl_clear_to_eol (nleft);
0
1200 }
never executed: end of block
0
1201#if 0-
1202 /* This segment is intended to handle the case where the prompt-
1203 has invisible characters on the second line and the new line-
1204 to be displayed needs to clear the rest of the old characters-
1205 out (e.g., when printing the i-search prompt). In general,-
1206 the case of the new line being shorter than the old.-
1207 Incomplete */-
1208 else if (linenum == prompt_last_screen_line &&-
1209 prompt_physical_chars > _rl_screenwidth &&-
1210 wrap_offset != prompt_invis_chars_first_line &&-
1211 _rl_last_c_pos == out &&-
1212#endif-
1213-
1214-
1215 /* Since the new first line is now visible, save its length. */-
1216 if (linenum == 0)
linenum == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1217 visible_first_line_len = (inv_botlin > 0) ? inv_lbreaks[1] : out - wrap_offset;
never executed: visible_first_line_len = (inv_botlin > 0) ? (line_state_invisible->lbreaks)[1] : out - wrap_offset;
(inv_botlin > 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1218 }
never executed: end of block
0
1219-
1220 /* We may have deleted some lines. If so, clear the left over-
1221 blank ones at the bottom out. */-
1222 if (_rl_vis_botlin > inv_botlin)
_rl_vis_botlin > inv_botlinDescription
TRUEnever evaluated
FALSEnever evaluated
0
1223 {-
1224 char *tt;-
1225 for (; linenum <= _rl_vis_botlin; linenum++)
linenum <= _rl_vis_botlinDescription
TRUEnever evaluated
FALSEnever evaluated
0
1226 {-
1227 tt = VIS_CHARS (linenum);-
1228 _rl_move_vert (linenum);-
1229 _rl_move_cursor_relative (0, tt);-
1230 _rl_clear_to_eol-
1231 ((linenum == _rl_vis_botlin) ? strlen (tt) : _rl_screenwidth);-
1232 }
never executed: end of block
0
1233 }
never executed: end of block
0
1234 _rl_vis_botlin = inv_botlin;-
1235-
1236 /* CHANGED_SCREEN_LINE is set to 1 if we have moved to a-
1237 different screen line during this redisplay. */-
1238 changed_screen_line = _rl_last_v_pos != cursor_linenum;-
1239 if (changed_screen_line)
changed_screen_lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1240 {-
1241 _rl_move_vert (cursor_linenum);-
1242 /* If we moved up to the line with the prompt using _rl_term_up,-
1243 the physical cursor position on the screen stays the same,-
1244 but the buffer position needs to be adjusted to account-
1245 for invisible characters. */-
1246 if ((mb_cur_max == 1 || rl_byte_oriented) && cursor_linenum == 0 && wrap_offset)
mb_cur_max == 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_orientedDescription
TRUEnever evaluated
FALSEnever evaluated
cursor_linenum == 0Description
TRUEnever evaluated
FALSEnever evaluated
wrap_offsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1247 _rl_last_c_pos += wrap_offset;
never executed: _rl_last_c_pos += wrap_offset;
0
1248 }
never executed: end of block
0
1249-
1250 /* Now we move the cursor to where it needs to be. First, make-
1251 sure we are on the correct line (cursor_linenum). */-
1252-
1253 /* We have to reprint the prompt if it contains invisible-
1254 characters, since it's not generally OK to just reprint-
1255 the characters from the current cursor position. But we-
1256 only need to reprint it if the cursor is before the last-
1257 invisible character in the prompt string. */-
1258 nleft = prompt_visible_length + wrap_offset;-
1259 if (cursor_linenum == 0 && wrap_offset > 0 && _rl_last_c_pos > 0 &&
cursor_linenum == 0Description
TRUEnever evaluated
FALSEnever evaluated
wrap_offset > 0Description
TRUEnever evaluated
FALSEnever evaluated
_rl_last_c_pos > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1260#if 0-
1261 _rl_last_c_pos <= PROMPT_ENDING_INDEX && local_prompt)-
1262#else-
1263 _rl_last_c_pos < PROMPT_ENDING_INDEX && local_prompt)
_rl_last_c_pos...t_invisible+1)Description
TRUEnever evaluated
FALSEnever evaluated
local_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
1264#endif-
1265 {-
1266#if defined (__MSDOS__)-
1267 putc ('\r', rl_outstream);-
1268#else-
1269 if (_rl_term_cr)
_rl_term_crDescription
TRUEnever evaluated
FALSEnever evaluated
0
1270 tputs (_rl_term_cr, 1, _rl_output_character_function);
never executed: tputs (_rl_term_cr, 1, _rl_output_character_function);
0
1271#endif-
1272 if (modmark)
modmarkDescription
TRUEnever evaluated
FALSEnever evaluated
0
1273 _rl_output_some_chars ("*", 1);
never executed: _rl_output_some_chars ("*", 1);
0
1274-
1275 _rl_output_some_chars (local_prompt, nleft);-
1276 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1277 _rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft, 1) - wrap_offset + modmark;
never executed: _rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft, 1) - wrap_offset + modmark;
0
1278 else-
1279 _rl_last_c_pos = nleft + modmark;
never executed: _rl_last_c_pos = nleft + modmark;
0
1280 }-
1281-
1282 /* Where on that line? And where does that line start-
1283 in the buffer? */-
1284 pos = inv_lbreaks[cursor_linenum];-
1285 /* nleft == number of characters in the line buffer between the-
1286 start of the line and the desired cursor position. */-
1287 nleft = cpos_buffer_position - pos;-
1288-
1289 /* NLEFT is now a number of characters in a buffer. When in a-
1290 multibyte locale, however, _rl_last_c_pos is an absolute cursor-
1291 position that doesn't take invisible characters in the prompt-
1292 into account. We use a fudge factor to compensate. */-
1293-
1294 /* Since _rl_backspace() doesn't know about invisible characters in-
1295 the prompt, and there's no good way to tell it, we compensate for-
1296 those characters here and call _rl_backspace() directly if-
1297 necessary */-
1298 if (wrap_offset && cursor_linenum == 0 && nleft < _rl_last_c_pos)
wrap_offsetDescription
TRUEnever evaluated
FALSEnever evaluated
cursor_linenum == 0Description
TRUEnever evaluated
FALSEnever evaluated
nleft < _rl_last_c_posDescription
TRUEnever evaluated
FALSEnever evaluated
0
1299 {-
1300 /* TX == new physical cursor position in multibyte locale. */-
1301 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1302 tx = _rl_col_width (&visible_line[pos], 0, nleft, 1) - visible_wrap_offset;
never executed: tx = _rl_col_width (&(line_state_visible->line)[pos], 0, nleft, 1) - visible_wrap_offset;
0
1303 else-
1304 tx = nleft;
never executed: tx = nleft;
0
1305 if (tx >= 0 && _rl_last_c_pos > tx)
tx >= 0Description
TRUEnever evaluated
FALSEnever evaluated
_rl_last_c_pos > txDescription
TRUEnever evaluated
FALSEnever evaluated
0
1306 {-
1307 _rl_backspace (_rl_last_c_pos - tx); /* XXX */-
1308 _rl_last_c_pos = tx;-
1309 }
never executed: end of block
0
1310 }
never executed: end of block
0
1311-
1312 /* We need to note that in a multibyte locale we are dealing with-
1313 _rl_last_c_pos as an absolute cursor position, but moving to a-
1314 point specified by a buffer position (NLEFT) that doesn't take-
1315 invisible characters into account. */-
1316 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1317 _rl_move_cursor_relative (nleft, &invisible_line[pos]);
never executed: _rl_move_cursor_relative (nleft, &(line_state_invisible->line)[pos]);
0
1318 else if (nleft != _rl_last_c_pos)
nleft != _rl_last_c_posDescription
TRUEnever evaluated
FALSEnever evaluated
0
1319 _rl_move_cursor_relative (nleft, &invisible_line[pos]);
never executed: _rl_move_cursor_relative (nleft, &(line_state_invisible->line)[pos]);
0
1320 }
never executed: end of block
0
1321 }
never executed: end of block
0
1322 else /* Do horizontal scrolling. Much simpler */-
1323 {-
1324#define M_OFFSET(margin, offset) ((margin) == 0 ? offset : 0)-
1325 int lmargin, ndisp, nleft, phys_c_pos, t;-
1326-
1327 /* Always at top line. */-
1328 _rl_last_v_pos = 0;-
1329-
1330 /* Compute where in the buffer the displayed line should start. This-
1331 will be LMARGIN. */-
1332-
1333 /* The number of characters that will be displayed before the cursor. */-
1334 ndisp = cpos_buffer_position - wrap_offset;-
1335 nleft = prompt_visible_length + wrap_offset;-
1336 /* Where the new cursor position will be on the screen. This can be-
1337 longer than SCREENWIDTH; if it is, lmargin will be adjusted. */-
1338 phys_c_pos = cpos_buffer_position - (last_lmargin ? last_lmargin : wrap_offset);
last_lmarginDescription
TRUEnever evaluated
FALSEnever evaluated
0
1339 t = _rl_screenwidth / 3;-
1340-
1341 /* If the number of characters had already exceeded the screenwidth,-
1342 last_lmargin will be > 0. */-
1343-
1344 /* If the number of characters to be displayed is more than the screen-
1345 width, compute the starting offset so that the cursor is about-
1346 two-thirds of the way across the screen. */-
1347 if (phys_c_pos > _rl_screenwidth - 2)
phys_c_pos > _...creenwidth - 2Description
TRUEnever evaluated
FALSEnever evaluated
0
1348 {-
1349 lmargin = cpos_buffer_position - (2 * t);-
1350 if (lmargin < 0)
lmargin < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1351 lmargin = 0;
never executed: lmargin = 0;
0
1352 /* If the left margin would be in the middle of a prompt with-
1353 invisible characters, don't display the prompt at all. */-
1354 if (wrap_offset && lmargin > 0 && lmargin < nleft)
wrap_offsetDescription
TRUEnever evaluated
FALSEnever evaluated
lmargin > 0Description
TRUEnever evaluated
FALSEnever evaluated
lmargin < nleftDescription
TRUEnever evaluated
FALSEnever evaluated
0
1355 lmargin = nleft;
never executed: lmargin = nleft;
0
1356 }
never executed: end of block
0
1357 else if (ndisp < _rl_screenwidth - 2) /* XXX - was -1 */
ndisp < _rl_screenwidth - 2Description
TRUEnever evaluated
FALSEnever evaluated
0
1358 lmargin = 0;
never executed: lmargin = 0;
0
1359 else if (phys_c_pos < 1)
phys_c_pos < 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1360 {-
1361 /* If we are moving back towards the beginning of the line and-
1362 the last margin is no longer correct, compute a new one. */-
1363 lmargin = ((cpos_buffer_position - 1) / t) * t; /* XXX */-
1364 if (wrap_offset && lmargin > 0 && lmargin < nleft)
wrap_offsetDescription
TRUEnever evaluated
FALSEnever evaluated
lmargin > 0Description
TRUEnever evaluated
FALSEnever evaluated
lmargin < nleftDescription
TRUEnever evaluated
FALSEnever evaluated
0
1365 lmargin = nleft;
never executed: lmargin = nleft;
0
1366 }
never executed: end of block
0
1367 else-
1368 lmargin = last_lmargin;
never executed: lmargin = last_lmargin;
0
1369-
1370 displaying_prompt_first_line = lmargin < nleft;-
1371-
1372 /* If the first character on the screen isn't the first character-
1373 in the display line, indicate this with a special character. */-
1374 if (lmargin > 0)
lmargin > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1375 line[lmargin] = '<';
never executed: line[lmargin] = '<';
0
1376-
1377 /* If SCREENWIDTH characters starting at LMARGIN do not encompass-
1378 the whole line, indicate that with a special character at the-
1379 right edge of the screen. If LMARGIN is 0, we need to take the-
1380 wrap offset into account. */-
1381 t = lmargin + M_OFFSET (lmargin, wrap_offset) + _rl_screenwidth;
(lmargin) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1382 if (t > 0 && t < out)
t > 0Description
TRUEnever evaluated
FALSEnever evaluated
t < outDescription
TRUEnever evaluated
FALSEnever evaluated
0
1383 line[t - 1] = '>';
never executed: line[t - 1] = '>';
0
1384-
1385 if (rl_display_fixed == 0 || forced_display || lmargin != last_lmargin)
rl_display_fixed == 0Description
TRUEnever evaluated
FALSEnever evaluated
forced_displayDescription
TRUEnever evaluated
FALSEnever evaluated
lmargin != last_lmarginDescription
TRUEnever evaluated
FALSEnever evaluated
0
1386 {-
1387 forced_display = 0;-
1388 o_cpos = _rl_last_c_pos;-
1389 cpos_adjusted = 0;-
1390 update_line (&visible_line[last_lmargin],-
1391 &invisible_line[lmargin],-
1392 0,-
1393 _rl_screenwidth + visible_wrap_offset,-
1394 _rl_screenwidth + (lmargin ? 0 : wrap_offset),-
1395 0);-
1396-
1397 if ((mb_cur_max > 1 && rl_byte_oriented == 0) &&
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1398 displaying_prompt_first_line && OLD_CPOS_IN_PROMPT())
displaying_prompt_first_lineDescription
TRUEnever evaluated
FALSEnever evaluated
cpos_adjusted == 0Description
TRUEnever evaluated
FALSEnever evaluated
_rl_last_c_pos != o_cposDescription
TRUEnever evaluated
FALSEnever evaluated
_rl_last_c_pos > wrap_offsetDescription
TRUEnever evaluated
FALSEnever evaluated
o_cpos < prompt_last_invisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1399 _rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */
never executed: _rl_last_c_pos -= prompt_invis_chars_first_line;
0
1400-
1401 /* If the visible new line is shorter than the old, but the number-
1402 of invisible characters is greater, and we are at the end of-
1403 the new line, we need to clear to eol. */-
1404 t = _rl_last_c_pos - M_OFFSET (lmargin, wrap_offset);
(lmargin) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1405 if ((M_OFFSET (lmargin, wrap_offset) > visible_wrap_offset) &&
(lmargin) == 0Description
TRUEnever evaluated
FALSEnever evaluated
(((lmargin) ==...e_wrap_offset)Description
TRUEnever evaluated
FALSEnever evaluated
0
1406 (_rl_last_c_pos == out) && displaying_prompt_first_line &&
(_rl_last_c_pos == out)Description
TRUEnever evaluated
FALSEnever evaluated
displaying_prompt_first_lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1407 t < visible_first_line_len)
t < visible_first_line_lenDescription
TRUEnever evaluated
FALSEnever evaluated
0
1408 {-
1409 nleft = _rl_screenwidth - t;-
1410 _rl_clear_to_eol (nleft);-
1411 }
never executed: end of block
0
1412 visible_first_line_len = out - lmargin - M_OFFSET (lmargin, wrap_offset);
(lmargin) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1413 if (visible_first_line_len > _rl_screenwidth)
visible_first_...rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1414 visible_first_line_len = _rl_screenwidth;
never executed: visible_first_line_len = _rl_screenwidth;
0
1415-
1416 _rl_move_cursor_relative (cpos_buffer_position - lmargin, &invisible_line[lmargin]);-
1417 last_lmargin = lmargin;-
1418 }
never executed: end of block
0
1419 }
never executed: end of block
0
1420 fflush (rl_outstream);-
1421-
1422 /* Swap visible and non-visible lines. */-
1423 {-
1424 struct line_state *vtemp = line_state_visible;-
1425-
1426 line_state_visible = line_state_invisible;-
1427 line_state_invisible = vtemp;-
1428-
1429 rl_display_fixed = 0;-
1430 /* If we are displaying on a single line, and last_lmargin is > 0, we-
1431 are not displaying any invisible characters, so set visible_wrap_offset-
1432 to 0. */-
1433 if (_rl_horizontal_scroll_mode && last_lmargin)
_rl_horizontal_scroll_modeDescription
TRUEnever evaluated
FALSEnever evaluated
last_lmarginDescription
TRUEnever evaluated
FALSEnever evaluated
0
1434 visible_wrap_offset = 0;
never executed: visible_wrap_offset = 0;
0
1435 else-
1436 visible_wrap_offset = wrap_offset;
never executed: visible_wrap_offset = wrap_offset;
0
1437 }-
1438-
1439 RL_UNSETSTATE (RL_STATE_REDISPLAYING);-
1440 _rl_release_sigint ();-
1441}
never executed: end of block
0
1442-
1443/* PWP: update_line() is based on finding the middle difference of each-
1444 line on the screen; vis:-
1445-
1446 /old first difference-
1447 /beginning of line | /old last same /old EOL-
1448 v v v v-
1449old: eddie> Oh, my little gruntle-buggy is to me, as lurgid as-
1450new: eddie> Oh, my little buggy says to me, as lurgid as-
1451 ^ ^ ^ ^-
1452 \beginning of line | \new last same \new end of line-
1453 \new first difference-
1454-
1455 All are character pointers for the sake of speed. Special cases for-
1456 no differences, as well as for end of line additions must be handled.-
1457-
1458 Could be made even smarter, but this works well enough */-
1459static void-
1460update_line (char *old, char *new, int current_line, int omax, int nmax, int inv_botlin)-
1461{-
1462 register char *ofd, *ols, *oe, *nfd, *nls, *ne;-
1463 int temp, lendiff, wsatend, od, nd, twidth, o_cpos;-
1464 int current_invis_chars;-
1465 int col_lendiff, col_temp;-
1466 int bytes_to_insert;-
1467 int mb_cur_max = MB_CUR_MAX;-
1468#if defined (HANDLE_MULTIBYTE)-
1469 mbstate_t ps_new, ps_old;-
1470 int new_offset, old_offset;-
1471#endif-
1472-
1473 /* If we're at the right edge of a terminal that supports xn, we're-
1474 ready to wrap around, so do so. This fixes problems with knowing-
1475 the exact cursor position and cut-and-paste with certain terminal-
1476 emulators. In this calculation, TEMP is the physical screen-
1477 position of the cursor. */-
1478 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1479 temp = _rl_last_c_pos;
never executed: temp = _rl_last_c_pos;
0
1480 else-
1481 temp = _rl_last_c_pos - WRAP_OFFSET (_rl_last_v_pos, visible_wrap_offset);
never executed: temp = _rl_last_c_pos - ((_rl_last_v_pos == 0) ? (visible_wrap_offset ? (prompt_physical_chars > _rl_screenwidth ? prompt_invis_chars_first_line : wrap_offset) : 0) : ((_rl_last_v_pos == prompt_last_screen_line) ? wrap_offset-prompt_invis_chars_first_line : 0));
(_rl_last_v_pos == 0)Description
TRUEnever evaluated
FALSEnever evaluated
visible_wrap_offsetDescription
TRUEnever evaluated
FALSEnever evaluated
prompt_physica...rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
(_rl_last_v_po...t_screen_line)Description
TRUEnever evaluated
FALSEnever evaluated
0
1482 if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
temp == _rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
_rl_term_autowrapDescription
TRUEnever evaluated
FALSEnever evaluated
!_rl_horizontal_scroll_modeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1483 && _rl_last_v_pos == current_line - 1)
_rl_last_v_pos...rrent_line - 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1484 {-
1485 /* We're going to wrap around by writing the first character of NEW to-
1486 the screen and dealing with changes to what's visible by modifying-
1487 OLD to match it. Complicated by the presence of multi-width-
1488 characters at the end of the line or beginning of the new one. */-
1489 /* old is always somewhere in visible_line; new is always somewhere in-
1490 invisible_line. These should always be null-terminated. */-
1491#if defined (HANDLE_MULTIBYTE)-
1492 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1493 {-
1494 wchar_t wc;-
1495 mbstate_t ps;-
1496 int oldwidth, newwidth;-
1497 int oldbytes, newbytes;-
1498 size_t ret;-
1499-
1500 /* This fixes only double-column characters, but if the wrapped-
1501 character consumes more than three columns, spaces will be-
1502 inserted in the string buffer. */-
1503 /* XXX remember that we are working on the invisible line right now;-
1504 we don't swap visible and invisible until just before rl_redisplay-
1505 returns */-
1506 /* This will remove the extra placeholder space we added with-
1507 _rl_wrapped_multicolumn */-
1508 if (current_line < line_state_invisible->wbsize && line_state_invisible->wrapped_line[current_line] > 0)
current_line <...isible->wbsizeDescription
TRUEnever evaluated
FALSEnever evaluated
line_state_inv...rent_line] > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1509 _rl_clear_to_eol (line_state_invisible->wrapped_line[current_line]);
never executed: _rl_clear_to_eol (line_state_invisible->wrapped_line[current_line]);
0
1510-
1511 /* 1. how many screen positions does first char in old consume? */-
1512 memset (&ps, 0, sizeof (mbstate_t));-
1513 ret = mbrtowc (&wc, old, mb_cur_max, &ps);-
1514 oldbytes = ret;-
1515 if (MB_INVALIDCH (ret))
(ret) == (size_t)-1Description
TRUEnever evaluated
FALSEnever evaluated
(ret) == (size_t)-2Description
TRUEnever evaluated
FALSEnever evaluated
0
1516 {-
1517 oldwidth = 1;-
1518 oldbytes = 1;-
1519 }
never executed: end of block
0
1520 else if (MB_NULLWCH (ret))
((ret) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1521 oldwidth = 0;
never executed: oldwidth = 0;
0
1522 else-
1523 oldwidth = WCWIDTH (wc);
never executed: oldwidth = _rl_wcwidth(wc);
0
1524 if (oldwidth < 0)
oldwidth < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1525 oldwidth = 1;
never executed: oldwidth = 1;
0
1526-
1527 /* 2. how many screen positions does the first char in new consume? */-
1528 memset (&ps, 0, sizeof (mbstate_t));-
1529 ret = mbrtowc (&wc, new, mb_cur_max, &ps);-
1530 newbytes = ret;-
1531 if (MB_INVALIDCH (ret))
(ret) == (size_t)-1Description
TRUEnever evaluated
FALSEnever evaluated
(ret) == (size_t)-2Description
TRUEnever evaluated
FALSEnever evaluated
0
1532 {-
1533 newwidth = 1;-
1534 newbytes = 1;-
1535 }
never executed: end of block
0
1536 else if (MB_NULLWCH (ret))
((ret) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1537 newwidth = 0;
never executed: newwidth = 0;
0
1538 else-
1539 newwidth = WCWIDTH (wc);
never executed: newwidth = _rl_wcwidth(wc);
0
1540 if (newwidth < 0)
newwidth < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1541 newwidth = 1;
never executed: newwidth = 1;
0
1542-
1543 /* 3. if the new width is less than the old width, we need to keep-
1544 going in new until we have consumed at least that many screen-
1545 positions, and figure out how many bytes that will take */-
1546 while (newbytes < nmax && newwidth < oldwidth)
newbytes < nmaxDescription
TRUEnever evaluated
FALSEnever evaluated
newwidth < oldwidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1547 {-
1548 int t;-
1549-
1550 ret = mbrtowc (&wc, new+newbytes, mb_cur_max, &ps);-
1551 if (MB_INVALIDCH (ret))
(ret) == (size_t)-1Description
TRUEnever evaluated
FALSEnever evaluated
(ret) == (size_t)-2Description
TRUEnever evaluated
FALSEnever evaluated
0
1552 {-
1553 newwidth += 1;-
1554 newbytes += 1;-
1555 }
never executed: end of block
0
1556 else if (MB_NULLWCH (ret))
((ret) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1557 break;
never executed: break;
0
1558 else-
1559 {-
1560 t = WCWIDTH (wc);-
1561 newwidth += (t >= 0) ? t : 1;
(t >= 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1562 newbytes += ret;-
1563 }
never executed: end of block
0
1564 }-
1565 /* 4. If the new width is more than the old width, keep going in old-
1566 until we have consumed exactly that many screen positions, and-
1567 figure out how many bytes that will take. This is an optimization */-
1568 while (oldbytes < omax && oldwidth < newwidth)
oldbytes < omaxDescription
TRUEnever evaluated
FALSEnever evaluated
oldwidth < newwidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1569 {-
1570 int t;-
1571-
1572 ret = mbrtowc (&wc, old+oldbytes, mb_cur_max, &ps);-
1573 if (MB_INVALIDCH (ret))
(ret) == (size_t)-1Description
TRUEnever evaluated
FALSEnever evaluated
(ret) == (size_t)-2Description
TRUEnever evaluated
FALSEnever evaluated
0
1574 {-
1575 oldwidth += 1;-
1576 oldbytes += 1;-
1577 }
never executed: end of block
0
1578 else if (MB_NULLWCH (ret))
((ret) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1579 break;
never executed: break;
0
1580 else-
1581 {-
1582 t = WCWIDTH (wc);-
1583 oldwidth += (t >= 0) ? t : 1;
(t >= 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1584 oldbytes += ret;-
1585 }
never executed: end of block
0
1586 }-
1587 /* 5. write the first newbytes of new, which takes newwidth. This is-
1588 where the screen wrapping takes place, and we are now writing-
1589 characters onto the new line. We need to fix up old so it-
1590 accurately reflects what is on the screen after the-
1591 _rl_output_some_chars below. */-
1592 if (newwidth > 0)
newwidth > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1593 {-
1594 int count, i, j;-
1595 char *optr;-
1596-
1597 _rl_output_some_chars (new, newbytes);-
1598 _rl_last_c_pos = newwidth;-
1599 _rl_last_v_pos++;-
1600-
1601 /* 5a. If the number of screen positions doesn't match, punt-
1602 and do a dumb update. */-
1603 if (newwidth != oldwidth)
newwidth != oldwidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1604 {-
1605 ne = new + nmax;-
1606 nd = newbytes;-
1607 nfd = new + nd;-
1608 goto dumb_update;
never executed: goto dumb_update;
0
1609 }-
1610 if (oldbytes != 0 && newbytes != 0)
oldbytes != 0Description
TRUEnever evaluated
FALSEnever evaluated
newbytes != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1611 {-
1612 /* We have written as many bytes from new as we need to-
1613 consume the first character of old. Fix up `old' so it-
1614 reflects the new screen contents. We use +1 in the-
1615 memmove call to copy the trailing NUL. */-
1616 memmove (old+newbytes, old+oldbytes, strlen (old+oldbytes) + 1);-
1617 memcpy (old, new, newbytes);-
1618 j = newbytes - oldbytes;-
1619 -
1620 omax += j;-
1621 /* Fix up indices if we copy data from one line to another */-
1622 for (i = current_line+1; i <= inv_botlin+1; i++)
i <= inv_botlin+1Description
TRUEnever evaluated
FALSEnever evaluated
0
1623 vis_lbreaks[i] += j;
never executed: (line_state_visible->lbreaks)[i] += j;
0
1624 }
never executed: end of block
0
1625 }
never executed: end of block
0
1626 else-
1627 {-
1628 putc (' ', rl_outstream);-
1629 _rl_last_c_pos = 1;-
1630 _rl_last_v_pos++;-
1631 if (old[0] && new[0])
old[0]Description
TRUEnever evaluated
FALSEnever evaluated
new[0]Description
TRUEnever evaluated
FALSEnever evaluated
0
1632 old[0] = new[0];
never executed: old[0] = new[0];
0
1633 }
never executed: end of block
0
1634 }-
1635 else-
1636#endif-
1637 {-
1638 if (new[0])
new[0]Description
TRUEnever evaluated
FALSEnever evaluated
0
1639 putc (new[0], rl_outstream);
never executed: _IO_putc ( new[0] , rl_outstream ) ;
0
1640 else-
1641 putc (' ', rl_outstream);
never executed: _IO_putc ( ' ' , rl_outstream ) ;
0
1642 _rl_last_c_pos = 1;-
1643 _rl_last_v_pos++;-
1644 if (old[0] && new[0])
old[0]Description
TRUEnever evaluated
FALSEnever evaluated
new[0]Description
TRUEnever evaluated
FALSEnever evaluated
0
1645 old[0] = new[0];
never executed: old[0] = new[0];
0
1646 }
never executed: end of block
0
1647 }-
1648-
1649 /* Find first difference. */-
1650#if defined (HANDLE_MULTIBYTE)-
1651 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1652 {-
1653 /* See if the old line is a subset of the new line, so that the-
1654 only change is adding characters. */-
1655 temp = (omax < nmax) ? omax : nmax;
(omax < nmax)Description
TRUEnever evaluated
FALSEnever evaluated
0
1656 if (memcmp (old, new, temp) == 0) /* adding at the end */
memcmp (old, new, temp) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1657 {-
1658 new_offset = old_offset = temp;-
1659 ofd = old + temp;-
1660 nfd = new + temp;-
1661 }
never executed: end of block
0
1662 else-
1663 { -
1664 memset (&ps_new, 0, sizeof(mbstate_t));-
1665 memset (&ps_old, 0, sizeof(mbstate_t));-
1666-
1667 /* Are the old and new lines the same? */-
1668 if (omax == nmax && STREQN (new, old, omax))
never executed: __result = (((const unsigned char *) (const char *) ( (new) ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( (old) ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
((omax) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
omax == nmaxDescription
TRUEnever evaluated
FALSEnever evaluated
(((omax) == 0)...ax) ))) == 0))Description
TRUEnever evaluated
FALSEnever evaluated
((new)[0] == (old)[0])Description
TRUEnever evaluated
FALSEnever evaluated
( (__extension...max) ))) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...t_p ( (omax) )Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( (new) )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( (new)...t) ( (omax) ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( (old) )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( (old)...t) ( (omax) ))Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1669 {-
1670 old_offset = omax;-
1671 new_offset = nmax;-
1672 ofd = old + omax;-
1673 nfd = new + nmax;-
1674 }
never executed: end of block
0
1675 else-
1676 {-
1677 /* Go through the line from the beginning and find the first-
1678 difference. */-
1679 new_offset = old_offset = 0;-
1680 for (ofd = old, nfd = new;-
1681 (ofd - old < omax) && *ofd &&
(ofd - old < omax)Description
TRUEnever evaluated
FALSEnever evaluated
*ofdDescription
TRUEnever evaluated
FALSEnever evaluated
0
1682 _rl_compare_chars(old, old_offset, &ps_old, new, new_offset, &ps_new); )
_rl_compare_ch...fset, &ps_new)Description
TRUEnever evaluated
FALSEnever evaluated
0
1683 {-
1684 old_offset = _rl_find_next_mbchar (old, old_offset, 1, MB_FIND_ANY);-
1685 new_offset = _rl_find_next_mbchar (new, new_offset, 1, MB_FIND_ANY);-
1686-
1687 ofd = old + old_offset;-
1688 nfd = new + new_offset;-
1689 }
never executed: end of block
0
1690 }
never executed: end of block
0
1691 }-
1692 }-
1693 else-
1694#endif-
1695 for (ofd = old, nfd = new;-
1696 (ofd - old < omax) && *ofd && (*ofd == *nfd);
(ofd - old < omax)Description
TRUEnever evaluated
FALSEnever evaluated
*ofdDescription
TRUEnever evaluated
FALSEnever evaluated
(*ofd == *nfd)Description
TRUEnever evaluated
FALSEnever evaluated
0
1697 ofd++, nfd++)-
1698 ;
never executed: ;
0
1699-
1700 /* Move to the end of the screen line. ND and OD are used to keep track-
1701 of the distance between ne and new and oe and old, respectively, to-
1702 move a subtraction out of each loop. */-
1703 for (od = ofd - old, oe = ofd; od < omax && *oe; oe++, od++);
never executed: ;
od < omaxDescription
TRUEnever evaluated
FALSEnever evaluated
*oeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1704 for (nd = nfd - new, ne = nfd; nd < nmax && *ne; ne++, nd++);
never executed: ;
nd < nmaxDescription
TRUEnever evaluated
FALSEnever evaluated
*neDescription
TRUEnever evaluated
FALSEnever evaluated
0
1705-
1706 /* If no difference, continue to next line. */-
1707 if (ofd == oe && nfd == ne)
ofd == oeDescription
TRUEnever evaluated
FALSEnever evaluated
nfd == neDescription
TRUEnever evaluated
FALSEnever evaluated
0
1708 return;
never executed: return;
0
1709-
1710#if defined (HANDLE_MULTIBYTE)-
1711 if (mb_cur_max > 1 && rl_byte_oriented == 0 && _rl_utf8locale)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
_rl_utf8localeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1712 {-
1713 wchar_t wc;-
1714 mbstate_t ps = { 0 };-
1715 int t;-
1716-
1717 /* If the first character in the difference is a zero-width character,-
1718 assume it's a combining character and back one up so the two base-
1719 characters no longer compare equivalently. */-
1720 t = mbrtowc (&wc, ofd, mb_cur_max, &ps);-
1721 if (t > 0 && UNICODE_COMBINING_CHAR (wc) && WCWIDTH (wc) == 0)
t > 0Description
TRUEnever evaluated
FALSEnever evaluated
(wc) >= 768Description
TRUEnever evaluated
FALSEnever evaluated
(wc) <= 879Description
TRUEnever evaluated
FALSEnever evaluated
_rl_wcwidth(wc) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1722 {-
1723 old_offset = _rl_find_prev_mbchar (old, ofd - old, MB_FIND_ANY);-
1724 new_offset = _rl_find_prev_mbchar (new, nfd - new, MB_FIND_ANY);-
1725 ofd = old + old_offset; /* equal by definition */-
1726 nfd = new + new_offset;-
1727 }
never executed: end of block
0
1728 }
never executed: end of block
0
1729#endif-
1730-
1731 wsatend = 1; /* flag for trailing whitespace */-
1732-
1733#if defined (HANDLE_MULTIBYTE)-
1734 /* Find the last character that is the same between the two lines. This-
1735 bounds the region that needs to change. */-
1736 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1737 {-
1738 ols = old + _rl_find_prev_mbchar (old, oe - old, MB_FIND_ANY);-
1739 nls = new + _rl_find_prev_mbchar (new, ne - new, MB_FIND_ANY);-
1740-
1741 while ((ols > ofd) && (nls > nfd))
(ols > ofd)Description
TRUEnever evaluated
FALSEnever evaluated
(nls > nfd)Description
TRUEnever evaluated
FALSEnever evaluated
0
1742 {-
1743 memset (&ps_old, 0, sizeof (mbstate_t));-
1744 memset (&ps_new, 0, sizeof (mbstate_t));-
1745-
1746#if 0-
1747 /* On advice from jir@yamato.ibm.com */-
1748 _rl_adjust_point (old, ols - old, &ps_old);-
1749 _rl_adjust_point (new, nls - new, &ps_new);-
1750#endif-
1751-
1752 if (_rl_compare_chars (old, ols - old, &ps_old, new, nls - new, &ps_new) == 0)
_rl_compare_ch... &ps_new) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1753 break;
never executed: break;
0
1754-
1755 if (*ols == ' ')
*ols == ' 'Description
TRUEnever evaluated
FALSEnever evaluated
0
1756 wsatend = 0;
never executed: wsatend = 0;
0
1757-
1758 ols = old + _rl_find_prev_mbchar (old, ols - old, MB_FIND_ANY);-
1759 nls = new + _rl_find_prev_mbchar (new, nls - new, MB_FIND_ANY);-
1760 }
never executed: end of block
0
1761 }
never executed: end of block
0
1762 else-
1763 {-
1764#endif /* HANDLE_MULTIBYTE */-
1765 ols = oe - 1; /* find last same */-
1766 nls = ne - 1;-
1767 while ((ols > ofd) && (nls > nfd) && (*ols == *nls))
(ols > ofd)Description
TRUEnever evaluated
FALSEnever evaluated
(nls > nfd)Description
TRUEnever evaluated
FALSEnever evaluated
(*ols == *nls)Description
TRUEnever evaluated
FALSEnever evaluated
0
1768 {-
1769 if (*ols != ' ')
*ols != ' 'Description
TRUEnever evaluated
FALSEnever evaluated
0
1770 wsatend = 0;
never executed: wsatend = 0;
0
1771 ols--;-
1772 nls--;-
1773 }
never executed: end of block
0
1774#if defined (HANDLE_MULTIBYTE)-
1775 }
never executed: end of block
0
1776#endif-
1777-
1778 if (wsatend)
wsatendDescription
TRUEnever evaluated
FALSEnever evaluated
0
1779 {-
1780 ols = oe;-
1781 nls = ne;-
1782 }
never executed: end of block
0
1783#if defined (HANDLE_MULTIBYTE)-
1784 /* This may not work for stateful encoding, but who cares? To handle-
1785 stateful encoding properly, we have to scan each string from the-
1786 beginning and compare. */-
1787 else if (_rl_compare_chars (ols, 0, NULL, nls, 0, NULL) == 0)
_rl_compare_ch...id *)0) ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1788#else-
1789 else if (*ols != *nls)-
1790#endif-
1791 {-
1792 if (*ols) /* don't step past the NUL */
*olsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1793 {-
1794 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1795 ols = old + _rl_find_next_mbchar (old, ols - old, 1, MB_FIND_ANY);
never executed: ols = old + _rl_find_next_mbchar (old, ols - old, 1, 0x00);
0
1796 else-
1797 ols++;
never executed: ols++;
0
1798 }-
1799 if (*nls)
*nlsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1800 {-
1801 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1802 nls = new + _rl_find_next_mbchar (new, nls - new, 1, MB_FIND_ANY);
never executed: nls = new + _rl_find_next_mbchar (new, nls - new, 1, 0x00);
0
1803 else-
1804 nls++;
never executed: nls++;
0
1805 }-
1806 }
never executed: end of block
0
1807-
1808 /* count of invisible characters in the current invisible line. */-
1809 current_invis_chars = W_OFFSET (current_line, wrap_offset);
(current_line) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1810 if (_rl_last_v_pos != current_line)
_rl_last_v_pos != current_lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1811 {-
1812 _rl_move_vert (current_line);-
1813 /* We have moved up to a new screen line. This line may or may not have-
1814 invisible characters on it, but we do our best to recalculate-
1815 visible_wrap_offset based on what we know. */-
1816 if (current_line == 0)
current_line == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1817 visible_wrap_offset = prompt_invis_chars_first_line; /* XXX */
never executed: visible_wrap_offset = prompt_invis_chars_first_line;
0
1818 if ((mb_cur_max == 1 || rl_byte_oriented) && current_line == 0 && visible_wrap_offset)
mb_cur_max == 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_orientedDescription
TRUEnever evaluated
FALSEnever evaluated
current_line == 0Description
TRUEnever evaluated
FALSEnever evaluated
visible_wrap_offsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1819 _rl_last_c_pos += visible_wrap_offset;
never executed: _rl_last_c_pos += visible_wrap_offset;
0
1820 }
never executed: end of block
0
1821-
1822 /* If this is the first line and there are invisible characters in the-
1823 prompt string, and the prompt string has not changed, and the current-
1824 cursor position is before the last invisible character in the prompt,-
1825 and the index of the character to move to is past the end of the prompt-
1826 string, then redraw the entire prompt string. We can only do this-
1827 reliably if the terminal supports a `cr' capability.-
1828-
1829 This can also happen if the prompt string has changed, and the first-
1830 difference in the line is in the middle of the prompt string, after a-
1831 sequence of invisible characters (worst case) and before the end of-
1832 the prompt. In this case, we have to redraw the entire prompt string-
1833 so that the entire sequence of invisible characters is drawn. We need-
1834 to handle the worst case, when the difference is after (or in the middle-
1835 of) a sequence of invisible characters that changes the text color and-
1836 before the sequence that restores the text color to normal. Then we have-
1837 to make sure that the lines still differ -- if they don't, we can-
1838 return immediately.-
1839-
1840 This is not an efficiency hack -- there is a problem with redrawing-
1841 portions of the prompt string if they contain terminal escape-
1842 sequences (like drawing the `unbold' sequence without a corresponding-
1843 `bold') that manifests itself on certain terminals. */-
1844-
1845 lendiff = local_prompt_len;-
1846 if (lendiff > nmax)
lendiff > nmaxDescription
TRUEnever evaluated
FALSEnever evaluated
0
1847 lendiff = nmax;
never executed: lendiff = nmax;
0
1848 od = ofd - old; /* index of first difference in visible line */-
1849 nd = nfd - new; /* nd, od are buffer indexes */-
1850 if (current_line == 0 && !_rl_horizontal_scroll_mode &&
current_line == 0Description
TRUEnever evaluated
FALSEnever evaluated
!_rl_horizontal_scroll_modeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1851 _rl_term_cr && lendiff > prompt_visible_length && _rl_last_c_pos > 0 &&
_rl_term_crDescription
TRUEnever evaluated
FALSEnever evaluated
lendiff > prom...visible_lengthDescription
TRUEnever evaluated
FALSEnever evaluated
_rl_last_c_pos > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1852 (((od > 0 || nd > 0) && (od <= prompt_last_invisible || nd <= prompt_last_invisible)) ||
od > 0Description
TRUEnever evaluated
FALSEnever evaluated
nd > 0Description
TRUEnever evaluated
FALSEnever evaluated
od <= prompt_last_invisibleDescription
TRUEnever evaluated
FALSEnever evaluated
nd <= prompt_last_invisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1853 ((od >= lendiff) && _rl_last_c_pos < PROMPT_ENDING_INDEX)))
(od >= lendiff)Description
TRUEnever evaluated
FALSEnever evaluated
_rl_last_c_pos...t_invisible+1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1854 {-
1855#if defined (__MSDOS__)-
1856 putc ('\r', rl_outstream);-
1857#else-
1858 tputs (_rl_term_cr, 1, _rl_output_character_function);-
1859#endif-
1860 if (modmark)
modmarkDescription
TRUEnever evaluated
FALSEnever evaluated
0
1861 _rl_output_some_chars ("*", 1);
never executed: _rl_output_some_chars ("*", 1);
0
1862 _rl_output_some_chars (local_prompt, lendiff);-
1863 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1864 {-
1865 /* We take wrap_offset into account here so we can pass correct-
1866 information to _rl_move_cursor_relative. */-
1867 _rl_last_c_pos = _rl_col_width (local_prompt, 0, lendiff, 1) - wrap_offset + modmark;-
1868 cpos_adjusted = 1;-
1869 }
never executed: end of block
0
1870 else-
1871 _rl_last_c_pos = lendiff + modmark;
never executed: _rl_last_c_pos = lendiff + modmark;
0
1872-
1873 /* Now if we have printed the prompt string because the first difference-
1874 was within the prompt, see if we need to recompute where the lines-
1875 differ. Check whether where we are now is past the last place where-
1876 the old and new lines are the same and short-circuit now if we are. */-
1877 if ((od <= prompt_last_invisible || nd <= prompt_last_invisible) &&
od <= prompt_last_invisibleDescription
TRUEnever evaluated
FALSEnever evaluated
nd <= prompt_last_invisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1878 omax == nmax &&
omax == nmaxDescription
TRUEnever evaluated
FALSEnever evaluated
0
1879 lendiff > (ols-old) && lendiff > (nls-new))
lendiff > (ols-old)Description
TRUEnever evaluated
FALSEnever evaluated
lendiff > (nls-new)Description
TRUEnever evaluated
FALSEnever evaluated
0
1880 return;
never executed: return;
0
1881-
1882 /* XXX - we need to fix up our calculations if we are now past the-
1883 old ofd/nfd and the prompt length (or line length) has changed.-
1884 We punt on the problem and do a dumb update. We'd like to be able-
1885 to just output the prompt from the beginning of the line up to the-
1886 first difference, but you don't know the number of invisible-
1887 characters in that case.-
1888 This needs a lot of work to be efficient. */-
1889 if ((od <= prompt_last_invisible || nd <= prompt_last_invisible))
od <= prompt_last_invisibleDescription
TRUEnever evaluated
FALSEnever evaluated
nd <= prompt_last_invisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1890 {-
1891 nfd = new + lendiff; /* number of characters we output above */-
1892 nd = lendiff;-
1893-
1894 /* Do a dumb update and return */-
1895dumb_update:
code before this statement never executed: dumb_update:
0
1896 temp = ne - nfd;-
1897 if (temp > 0)
temp > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1898 {-
1899 _rl_output_some_chars (nfd, temp);-
1900 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1901 {-
1902 _rl_last_c_pos += _rl_col_width (new, nd, ne - new, 1);-
1903 /* Need to adjust here based on wrap_offset. Guess that if-
1904 this is the line containing the last line of the prompt-
1905 we need to adjust by-
1906 wrap_offset-prompt_invis_chars_first_line-
1907 on the assumption that this is the number of invisible-
1908 characters in the last line of the prompt. */-
1909 if (wrap_offset > prompt_invis_chars_first_line &&
wrap_offset > ...ars_first_lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1910 current_line == prompt_last_screen_line &&
current_line =...st_screen_lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1911 prompt_physical_chars > _rl_screenwidth &&
prompt_physica...rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1912 _rl_horizontal_scroll_mode == 0)
_rl_horizontal...roll_mode == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1913 {-
1914 _rl_last_c_pos -= wrap_offset - prompt_invis_chars_first_line;-
1915 cpos_adjusted = 1;-
1916 }
never executed: end of block
0
1917 }
never executed: end of block
0
1918 else-
1919 _rl_last_c_pos += temp;
never executed: _rl_last_c_pos += temp;
0
1920 }-
1921 if (nmax < omax)
nmax < omaxDescription
TRUEnever evaluated
FALSEnever evaluated
0
1922 goto clear_rest_of_line; /* XXX */
never executed: goto clear_rest_of_line;
0
1923 else-
1924 return;
never executed: return;
0
1925 }-
1926 }
never executed: end of block
0
1927-
1928 o_cpos = _rl_last_c_pos;-
1929-
1930 /* When this function returns, _rl_last_c_pos is correct, and an absolute-
1931 cursor position in multibyte mode, but a buffer index when not in a-
1932 multibyte locale. */-
1933 _rl_move_cursor_relative (od, old);-
1934-
1935#if defined (HANDLE_MULTIBYTE)-
1936 /* We need to indicate that the cursor position is correct in the presence of-
1937 invisible characters in the prompt string. Let's see if setting this when-
1938 we make sure we're at the end of the drawn prompt string works. */-
1939 if (current_line == 0 && mb_cur_max > 1 && rl_byte_oriented == 0 &&
current_line == 0Description
TRUEnever evaluated
FALSEnever evaluated
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1940 (_rl_last_c_pos > 0 || o_cpos > 0) &&
_rl_last_c_pos > 0Description
TRUEnever evaluated
FALSEnever evaluated
o_cpos > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1941 _rl_last_c_pos == prompt_physical_chars)
_rl_last_c_pos...physical_charsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1942 cpos_adjusted = 1;
never executed: cpos_adjusted = 1;
0
1943#endif-
1944-
1945 /* if (len (new) > len (old))-
1946 lendiff == difference in buffer (bytes)-
1947 col_lendiff == difference on screen (columns)-
1948 When not using multibyte characters, these are equal */-
1949 lendiff = (nls - nfd) - (ols - ofd);-
1950 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1951 col_lendiff = _rl_col_width (new, nfd - new, nls - new, 1) - _rl_col_width (old, ofd - old, ols - old, 1);
never executed: col_lendiff = _rl_col_width (new, nfd - new, nls - new, 1) - _rl_col_width (old, ofd - old, ols - old, 1);
0
1952 else-
1953 col_lendiff = lendiff;
never executed: col_lendiff = lendiff;
0
1954-
1955 /* If we are changing the number of invisible characters in a line, and-
1956 the spot of first difference is before the end of the invisible chars,-
1957 lendiff needs to be adjusted. */-
1958 if (current_line == 0 && /* !_rl_horizontal_scroll_mode && */
current_line == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1959 current_invis_chars != visible_wrap_offset)
current_invis_...le_wrap_offsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1960 {-
1961 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1962 {-
1963 lendiff += visible_wrap_offset - current_invis_chars;-
1964 col_lendiff += visible_wrap_offset - current_invis_chars;-
1965 }
never executed: end of block
0
1966 else-
1967 {-
1968 lendiff += visible_wrap_offset - current_invis_chars;-
1969 col_lendiff = lendiff;-
1970 }
never executed: end of block
0
1971 }-
1972-
1973 /* We use temp as a count of the number of bytes from the first difference-
1974 to the end of the new line. col_temp is the corresponding number of-
1975 screen columns. A `dumb' update moves to the spot of first difference-
1976 and writes TEMP bytes. */-
1977 /* Insert (diff (len (old), len (new)) ch. */-
1978 temp = ne - nfd;-
1979 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1980 col_temp = _rl_col_width (new, nfd - new, ne - new, 1);
never executed: col_temp = _rl_col_width (new, nfd - new, ne - new, 1);
0
1981 else-
1982 col_temp = temp;
never executed: col_temp = temp;
0
1983-
1984 /* how many bytes from the new line buffer to write to the display */-
1985 bytes_to_insert = nls - nfd;-
1986-
1987 /* col_lendiff > 0 if we are adding characters to the line */-
1988 if (col_lendiff > 0) /* XXX - was lendiff */
col_lendiff > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1989 {-
1990 /* Non-zero if we're increasing the number of lines. */-
1991 int gl = current_line >= _rl_vis_botlin && inv_botlin > _rl_vis_botlin;
current_line >= _rl_vis_botlinDescription
TRUEnever evaluated
FALSEnever evaluated
inv_botlin > _rl_vis_botlinDescription
TRUEnever evaluated
FALSEnever evaluated
0
1992-
1993 /* If col_lendiff is > 0, implying that the new string takes up more-
1994 screen real estate than the old, but lendiff is < 0, meaning that it-
1995 takes fewer bytes, we need to just output the characters starting-
1996 from the first difference. These will overwrite what is on the-
1997 display, so there's no reason to do a smart update. This can really-
1998 only happen in a multibyte environment. */-
1999 if (lendiff < 0)
lendiff < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2000 {-
2001 _rl_output_some_chars (nfd, temp);-
2002 _rl_last_c_pos += col_temp; /* XXX - was _rl_col_width (nfd, 0, temp, 1); */-
2003 /* If nfd begins before any invisible characters in the prompt,-
2004 adjust _rl_last_c_pos to account for wrap_offset and set-
2005 cpos_adjusted to let the caller know. */-
2006 if (current_line == 0 && displaying_prompt_first_line && wrap_offset && ((nfd - new) <= prompt_last_invisible))
current_line == 0Description
TRUEnever evaluated
FALSEnever evaluated
displaying_prompt_first_lineDescription
TRUEnever evaluated
FALSEnever evaluated
wrap_offsetDescription
TRUEnever evaluated
FALSEnever evaluated
((nfd - new) <...ast_invisible)Description
TRUEnever evaluated
FALSEnever evaluated
0
2007 {-
2008 _rl_last_c_pos -= wrap_offset; /* XXX - prompt_invis_chars_first_line? */-
2009 cpos_adjusted = 1;-
2010 }
never executed: end of block
0
2011 return;
never executed: return;
0
2012 }-
2013 /* Sometimes it is cheaper to print the characters rather than-
2014 use the terminal's capabilities. If we're growing the number-
2015 of lines, make sure we actually cause the new line to wrap-
2016 around on auto-wrapping terminals. */-
2017 else if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl))
_rl_terminal_can_insertDescription
TRUEnever evaluated
FALSEnever evaluated
(2 * col_temp) >= col_lendiffDescription
TRUEnever evaluated
FALSEnever evaluated
_rl_term_ICDescription
TRUEnever evaluated
FALSEnever evaluated
!_rl_term_autowrapDescription
TRUEnever evaluated
FALSEnever evaluated
!glDescription
TRUEnever evaluated
FALSEnever evaluated
0
2018 {-
2019 /* If lendiff > prompt_visible_length and _rl_last_c_pos == 0 and-
2020 _rl_horizontal_scroll_mode == 1, inserting the characters with-
2021 _rl_term_IC or _rl_term_ic will screw up the screen because of the-
2022 invisible characters. We need to just draw them. */-
2023 /* The same thing happens if we're trying to draw before the last-
2024 invisible character in the prompt string or we're increasing the-
2025 number of invisible characters in the line and we're not drawing-
2026 the entire prompt string. */-
2027 if (*ols && ((_rl_horizontal_scroll_mode &&
*olsDescription
TRUEnever evaluated
FALSEnever evaluated
((_rl_horizont...ars > 0) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
_rl_horizontal_scroll_modeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2028 _rl_last_c_pos == 0 &&
((_rl_horizont...ars > 0) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
_rl_last_c_pos == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2029 lendiff > prompt_visible_length &&
((_rl_horizont...ars > 0) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
lendiff > prom...visible_lengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
2030 current_invis_chars > 0) == 0) &&
((_rl_horizont...ars > 0) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
current_invis_chars > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2031 (((mb_cur_max > 1 && rl_byte_oriented == 0) &&
(((mb_cur_max ...length)) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2032 current_line == 0 && wrap_offset &&
(((mb_cur_max ...length)) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
current_line == 0Description
TRUEnever evaluated
FALSEnever evaluated
wrap_offsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2033 ((nfd - new) <= prompt_last_invisible) &&
(((mb_cur_max ...length)) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
((nfd - new) <...ast_invisible)Description
TRUEnever evaluated
FALSEnever evaluated
0
2034 (col_lendiff < prompt_visible_length)) == 0) &&
(((mb_cur_max ...length)) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
(col_lendiff <...isible_length)Description
TRUEnever evaluated
FALSEnever evaluated
0
2035 (visible_wrap_offset >= current_invis_chars))
(visible_wrap_...t_invis_chars)Description
TRUEnever evaluated
FALSEnever evaluated
0
2036 {-
2037 open_some_spaces (col_lendiff);-
2038 _rl_output_some_chars (nfd, bytes_to_insert);-
2039 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2040 _rl_last_c_pos += _rl_col_width (nfd, 0, bytes_to_insert, 1);
never executed: _rl_last_c_pos += _rl_col_width (nfd, 0, bytes_to_insert, 1);
0
2041 else-
2042 _rl_last_c_pos += bytes_to_insert;
never executed: _rl_last_c_pos += bytes_to_insert;
0
2043 }-
2044 else if ((mb_cur_max == 1 || rl_byte_oriented != 0) && *ols == 0 && lendiff > 0)
mb_cur_max == 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented != 0Description
TRUEnever evaluated
FALSEnever evaluated
*ols == 0Description
TRUEnever evaluated
FALSEnever evaluated
lendiff > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2045 {-
2046 /* At the end of a line the characters do not have to-
2047 be "inserted". They can just be placed on the screen. */-
2048 _rl_output_some_chars (nfd, temp);-
2049 _rl_last_c_pos += col_temp;-
2050 return;
never executed: return;
0
2051 }-
2052 else /* just write from first difference to end of new line */-
2053 {-
2054 _rl_output_some_chars (nfd, temp);-
2055 _rl_last_c_pos += col_temp;-
2056 /* If nfd begins before the last invisible character in the-
2057 prompt, adjust _rl_last_c_pos to account for wrap_offset-
2058 and set cpos_adjusted to let the caller know. */-
2059 if ((mb_cur_max > 1 && rl_byte_oriented == 0) && current_line == 0 && displaying_prompt_first_line && wrap_offset && ((nfd - new) <= prompt_last_invisible))
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
current_line == 0Description
TRUEnever evaluated
FALSEnever evaluated
displaying_prompt_first_lineDescription
TRUEnever evaluated
FALSEnever evaluated
wrap_offsetDescription
TRUEnever evaluated
FALSEnever evaluated
((nfd - new) <...ast_invisible)Description
TRUEnever evaluated
FALSEnever evaluated
0
2060 {-
2061 _rl_last_c_pos -= wrap_offset; /* XXX - prompt_invis_chars_first_line? */-
2062 cpos_adjusted = 1;-
2063 }
never executed: end of block
0
2064 return;
never executed: return;
0
2065 }-
2066-
2067 if (bytes_to_insert > lendiff)
bytes_to_insert > lendiffDescription
TRUEnever evaluated
FALSEnever evaluated
0
2068 {-
2069 /* If nfd begins before the last invisible character in the-
2070 prompt, adjust _rl_last_c_pos to account for wrap_offset-
2071 and set cpos_adjusted to let the caller know. */-
2072 if ((mb_cur_max > 1 && rl_byte_oriented == 0) && current_line == 0 && displaying_prompt_first_line && wrap_offset && ((nfd - new) <= prompt_last_invisible))
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
current_line == 0Description
TRUEnever evaluated
FALSEnever evaluated
displaying_prompt_first_lineDescription
TRUEnever evaluated
FALSEnever evaluated
wrap_offsetDescription
TRUEnever evaluated
FALSEnever evaluated
((nfd - new) <...ast_invisible)Description
TRUEnever evaluated
FALSEnever evaluated
0
2073 {-
2074 _rl_last_c_pos -= wrap_offset; /* XXX - prompt_invis_chars_first_line? */-
2075 cpos_adjusted = 1;-
2076 }
never executed: end of block
0
2077 }
never executed: end of block
0
2078 }
never executed: end of block
0
2079 else-
2080 {-
2081 /* cannot insert chars, write to EOL */-
2082 _rl_output_some_chars (nfd, temp);-
2083 _rl_last_c_pos += col_temp;-
2084 /* If we're in a multibyte locale and were before the last invisible-
2085 char in the current line (which implies we just output some invisible-
2086 characters) we need to adjust _rl_last_c_pos, since it represents-
2087 a physical character position. */-
2088 /* The current_line*rl_screenwidth+prompt_invis_chars_first_line is a-
2089 crude attempt to compute how far into the new line buffer we are.-
2090 It doesn't work well in the face of multibyte characters and needs-
2091 to be rethought. XXX */-
2092 if ((mb_cur_max > 1 && rl_byte_oriented == 0) &&
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2093 current_line == prompt_last_screen_line && wrap_offset &&
current_line =...st_screen_lineDescription
TRUEnever evaluated
FALSEnever evaluated
wrap_offsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2094 displaying_prompt_first_line &&
displaying_prompt_first_lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2095 wrap_offset != prompt_invis_chars_first_line &&
wrap_offset !=...ars_first_lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2096 ((nfd-new) < (prompt_last_invisible-(current_line*_rl_screenwidth+prompt_invis_chars_first_line))))
((nfd-new) < (..._first_line)))Description
TRUEnever evaluated
FALSEnever evaluated
0
2097 {-
2098 _rl_last_c_pos -= wrap_offset - prompt_invis_chars_first_line;-
2099 cpos_adjusted = 1;-
2100 }
never executed: end of block
0
2101 }
never executed: end of block
0
2102 }-
2103 else /* Delete characters from line. */-
2104 {-
2105 /* If possible and inexpensive to use terminal deletion, then do so. */-
2106 if (_rl_term_dc && (2 * col_temp) >= -col_lendiff)
_rl_term_dcDescription
TRUEnever evaluated
FALSEnever evaluated
(2 * col_temp) >= -col_lendiffDescription
TRUEnever evaluated
FALSEnever evaluated
0
2107 {-
2108 /* If all we're doing is erasing the invisible characters in the-
2109 prompt string, don't bother. It screws up the assumptions-
2110 about what's on the screen. */-
2111 if (_rl_horizontal_scroll_mode && _rl_last_c_pos == 0 &&
_rl_horizontal_scroll_modeDescription
TRUEnever evaluated
FALSEnever evaluated
_rl_last_c_pos == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2112 displaying_prompt_first_line &&
displaying_prompt_first_lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2113 -lendiff == visible_wrap_offset)
-lendiff == vi...le_wrap_offsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2114 col_lendiff = 0;
never executed: col_lendiff = 0;
0
2115-
2116 /* If we have moved lmargin and we're shrinking the line, we've-
2117 already moved the cursor to the first character of the new line,-
2118 so deleting -col_lendiff characters will mess up the cursor-
2119 position calculation */-
2120 if (_rl_horizontal_scroll_mode && displaying_prompt_first_line == 0 &&
_rl_horizontal_scroll_modeDescription
TRUEnever evaluated
FALSEnever evaluated
displaying_pro...irst_line == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2121 col_lendiff && _rl_last_c_pos < -col_lendiff)
col_lendiffDescription
TRUEnever evaluated
FALSEnever evaluated
_rl_last_c_pos < -col_lendiffDescription
TRUEnever evaluated
FALSEnever evaluated
0
2122 col_lendiff = 0;
never executed: col_lendiff = 0;
0
2123-
2124 if (col_lendiff)
col_lendiffDescription
TRUEnever evaluated
FALSEnever evaluated
0
2125 delete_chars (-col_lendiff); /* delete (diff) characters */
never executed: delete_chars (-col_lendiff);
0
2126-
2127 /* Copy (new) chars to screen from first diff to last match,-
2128 overwriting what is there. */-
2129 if (bytes_to_insert > 0)
bytes_to_insert > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2130 {-
2131 /* If nfd begins at the prompt, or before the invisible-
2132 characters in the prompt, we need to adjust _rl_last_c_pos-
2133 in a multibyte locale to account for the wrap offset and-
2134 set cpos_adjusted accordingly. */-
2135 _rl_output_some_chars (nfd, bytes_to_insert);-
2136 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2137 {-
2138 _rl_last_c_pos += _rl_col_width (nfd, 0, bytes_to_insert, 1);-
2139 if (current_line == 0 && wrap_offset &&
current_line == 0Description
TRUEnever evaluated
FALSEnever evaluated
wrap_offsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2140 displaying_prompt_first_line &&
displaying_prompt_first_lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2141 _rl_last_c_pos >= wrap_offset && /* XXX was > */
_rl_last_c_pos >= wrap_offsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2142 ((nfd - new) <= prompt_last_invisible))
((nfd - new) <...ast_invisible)Description
TRUEnever evaluated
FALSEnever evaluated
0
2143 {-
2144 _rl_last_c_pos -= wrap_offset; /* XXX - prompt_invis_chars_first_line? */-
2145 cpos_adjusted = 1;-
2146 }
never executed: end of block
0
2147-
2148#if 1-
2149#ifdef HANDLE_MULTIBYTE-
2150 /* If we write a non-space into the last screen column,-
2151 remove the note that we added a space to compensate for-
2152 a multibyte double-width character that didn't fit, since-
2153 it's only valid for what was previously there. */-
2154 /* XXX - watch this */-
2155 if (_rl_last_c_pos == _rl_screenwidth &&
_rl_last_c_pos...rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
2156 line_state_invisible->wrapped_line[current_line+1] &&
line_state_inv...urrent_line+1]Description
TRUEnever evaluated
FALSEnever evaluated
0
2157 nfd[bytes_to_insert-1] != ' ')
nfd[bytes_to_insert-1] != ' 'Description
TRUEnever evaluated
FALSEnever evaluated
0
2158 line_state_invisible->wrapped_line[current_line+1] = 0;
never executed: line_state_invisible->wrapped_line[current_line+1] = 0;
0
2159#endif-
2160#endif-
2161 }
never executed: end of block
0
2162 else-
2163 _rl_last_c_pos += bytes_to_insert;
never executed: _rl_last_c_pos += bytes_to_insert;
0
2164-
2165 /* XXX - we only want to do this if we are at the end of the line-
2166 so we move there with _rl_move_cursor_relative */-
2167 if (_rl_horizontal_scroll_mode && ((oe-old) > (ne-new)))
_rl_horizontal_scroll_modeDescription
TRUEnever evaluated
FALSEnever evaluated
((oe-old) > (ne-new))Description
TRUEnever evaluated
FALSEnever evaluated
0
2168 {-
2169 _rl_move_cursor_relative (ne-new, new);-
2170 goto clear_rest_of_line;
never executed: goto clear_rest_of_line;
0
2171 }-
2172 }
never executed: end of block
0
2173 }
never executed: end of block
0
2174 /* Otherwise, print over the existing material. */-
2175 else-
2176 {-
2177 if (temp > 0)
temp > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2178 {-
2179 /* If nfd begins at the prompt, or before the invisible-
2180 characters in the prompt, we need to adjust _rl_last_c_pos-
2181 in a multibyte locale to account for the wrap offset and-
2182 set cpos_adjusted accordingly. */-
2183 _rl_output_some_chars (nfd, temp);-
2184 _rl_last_c_pos += col_temp; /* XXX */-
2185 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2186 {-
2187 if (current_line == 0 && wrap_offset &&
current_line == 0Description
TRUEnever evaluated
FALSEnever evaluated
wrap_offsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2188 displaying_prompt_first_line &&
displaying_prompt_first_lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2189 _rl_last_c_pos > wrap_offset &&
_rl_last_c_pos > wrap_offsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2190 ((nfd - new) <= prompt_last_invisible))
((nfd - new) <...ast_invisible)Description
TRUEnever evaluated
FALSEnever evaluated
0
2191 {-
2192 _rl_last_c_pos -= wrap_offset; /* XXX - prompt_invis_chars_first_line? */-
2193 cpos_adjusted = 1;-
2194 }
never executed: end of block
0
2195 }
never executed: end of block
0
2196 }
never executed: end of block
0
2197clear_rest_of_line:
code before this statement never executed: clear_rest_of_line:
0
2198 lendiff = (oe - old) - (ne - new);-
2199 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2200 col_lendiff = _rl_col_width (old, 0, oe - old, 1) - _rl_col_width (new, 0, ne - new, 1);
never executed: col_lendiff = _rl_col_width (old, 0, oe - old, 1) - _rl_col_width (new, 0, ne - new, 1);
0
2201 else-
2202 col_lendiff = lendiff;
never executed: col_lendiff = lendiff;
0
2203-
2204 /* If we've already printed over the entire width of the screen,-
2205 including the old material, then col_lendiff doesn't matter and-
2206 space_to_eol will insert too many spaces. XXX - maybe we should-
2207 adjust col_lendiff based on the difference between _rl_last_c_pos-
2208 and _rl_screenwidth */-
2209 if (col_lendiff && ((mb_cur_max == 1 || rl_byte_oriented) || (_rl_last_c_pos < _rl_screenwidth)))
col_lendiffDescription
TRUEnever evaluated
FALSEnever evaluated
mb_cur_max == 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_orientedDescription
TRUEnever evaluated
FALSEnever evaluated
(_rl_last_c_po...l_screenwidth)Description
TRUEnever evaluated
FALSEnever evaluated
0
2210 { -
2211 if (_rl_term_autowrap && current_line < inv_botlin)
_rl_term_autowrapDescription
TRUEnever evaluated
FALSEnever evaluated
current_line < inv_botlinDescription
TRUEnever evaluated
FALSEnever evaluated
0
2212 space_to_eol (col_lendiff);
never executed: space_to_eol (col_lendiff);
0
2213 else-
2214 _rl_clear_to_eol (col_lendiff);
never executed: _rl_clear_to_eol (col_lendiff);
0
2215 }-
2216 }
never executed: end of block
0
2217 }-
2218}-
2219-
2220/* Tell the update routines that we have moved onto a new (empty) line. */-
2221int-
2222rl_on_new_line (void)-
2223{-
2224 if (visible_line)
(line_state_visible->line)Description
TRUEnever evaluated
FALSEnever evaluated
0
2225 visible_line[0] = '\0';
never executed: (line_state_visible->line)[0] = '\0';
0
2226-
2227 _rl_last_c_pos = _rl_last_v_pos = 0;-
2228 _rl_vis_botlin = last_lmargin = 0;-
2229 if (vis_lbreaks)
(line_state_visible->lbreaks)Description
TRUEnever evaluated
FALSEnever evaluated
0
2230 vis_lbreaks[0] = vis_lbreaks[1] = 0;
never executed: (line_state_visible->lbreaks)[0] = (line_state_visible->lbreaks)[1] = 0;
0
2231 visible_wrap_offset = 0;-
2232 return 0;
never executed: return 0;
0
2233}-
2234-
2235/* Clear all screen lines occupied by the current readline line buffer-
2236 (visible line) */-
2237int-
2238rl_clear_visible_line (void)-
2239{-
2240 int curr_line;-
2241-
2242 /* Make sure we move to column 0 so we clear the entire line */-
2243#if defined (__MSDOS__)-
2244 putc ('\r', rl_outstream);-
2245#else-
2246 tputs (_rl_term_cr, 1, _rl_output_character_function);-
2247#endif-
2248 _rl_last_c_pos = 0;-
2249-
2250 /* Move to the last screen line of the current visible line */-
2251 _rl_move_vert (_rl_vis_botlin);-
2252-
2253 /* And erase screen lines going up to line 0 (first visible line) */-
2254 for (curr_line = _rl_last_v_pos; curr_line >= 0; curr_line--)
curr_line >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2255 {-
2256 _rl_move_vert (curr_line);-
2257 _rl_clear_to_eol (0);-
2258 }
never executed: end of block
0
2259-
2260 return 0;
never executed: return 0;
0
2261}-
2262-
2263/* Tell the update routines that we have moved onto a new line with the-
2264 prompt already displayed. Code originally from the version of readline-
2265 distributed with CLISP. rl_expand_prompt must have already been called-
2266 (explicitly or implicitly). This still doesn't work exactly right; it-
2267 should use expand_prompt() */-
2268int-
2269rl_on_new_line_with_prompt (void)-
2270{-
2271 int prompt_size, i, l, real_screenwidth, newlines;-
2272 char *prompt_last_line, *lprompt;-
2273-
2274 /* Initialize visible_line and invisible_line to ensure that they can hold-
2275 the already-displayed prompt. */-
2276 prompt_size = strlen (rl_prompt) + 1;-
2277 init_line_structures (prompt_size);-
2278-
2279 /* Make sure the line structures hold the already-displayed prompt for-
2280 redisplay. */-
2281 lprompt = local_prompt ? local_prompt : rl_prompt;
local_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
2282 strcpy (visible_line, lprompt);-
2283 strcpy (invisible_line, lprompt);-
2284-
2285 /* If the prompt contains newlines, take the last tail. */-
2286 prompt_last_line = strrchr (rl_prompt, '\n');-
2287 if (!prompt_last_line)
!prompt_last_lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2288 prompt_last_line = rl_prompt;
never executed: prompt_last_line = rl_prompt;
0
2289-
2290 l = strlen (prompt_last_line);-
2291 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
(__ctype_get_m...ur_max ()) > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2292 _rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l, 1); /* XXX */
never executed: _rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l, 1);
0
2293 else-
2294 _rl_last_c_pos = l;
never executed: _rl_last_c_pos = l;
0
2295-
2296 /* Dissect prompt_last_line into screen lines. Note that here we have-
2297 to use the real screenwidth. Readline's notion of screenwidth might be-
2298 one less, see terminal.c. */-
2299 real_screenwidth = _rl_screenwidth + (_rl_term_autowrap ? 0 : 1);
_rl_term_autowrapDescription
TRUEnever evaluated
FALSEnever evaluated
0
2300 _rl_last_v_pos = l / real_screenwidth;-
2301 /* If the prompt length is a multiple of real_screenwidth, we don't know-
2302 whether the cursor is at the end of the last line, or already at the-
2303 beginning of the next line. Output a newline just to be safe. */-
2304 if (l > 0 && (l % real_screenwidth) == 0)
l > 0Description
TRUEnever evaluated
FALSEnever evaluated
(l % real_screenwidth) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2305 _rl_output_some_chars ("\n", 1);
never executed: _rl_output_some_chars ("\n", 1);
0
2306 last_lmargin = 0;-
2307-
2308 newlines = 0; i = 0;-
2309 while (i <= l)
i <= lDescription
TRUEnever evaluated
FALSEnever evaluated
0
2310 {-
2311 _rl_vis_botlin = newlines;-
2312 vis_lbreaks[newlines++] = i;-
2313 i += real_screenwidth;-
2314 }
never executed: end of block
0
2315 vis_lbreaks[newlines] = l;-
2316 visible_wrap_offset = 0;-
2317-
2318 rl_display_prompt = rl_prompt; /* XXX - make sure it's set */-
2319-
2320 return 0;
never executed: return 0;
0
2321}-
2322-
2323/* Actually update the display, period. */-
2324int-
2325rl_forced_update_display (void)-
2326{-
2327 register char *temp;-
2328-
2329 if (visible_line)
(line_state_visible->line)Description
TRUEnever evaluated
FALSEnever evaluated
0
2330 {-
2331 temp = visible_line;-
2332 while (*temp)
*tempDescription
TRUEnever evaluated
FALSEnever evaluated
0
2333 *temp++ = '\0';
never executed: *temp++ = '\0';
0
2334 }
never executed: end of block
0
2335 rl_on_new_line ();-
2336 forced_display++;-
2337 (*rl_redisplay_function) ();-
2338 return 0;
never executed: return 0;
0
2339}-
2340-
2341/* Redraw only the last line of a multi-line prompt. */-
2342void-
2343rl_redraw_prompt_last_line (void)-
2344{-
2345 char *t;-
2346-
2347 t = strrchr (rl_display_prompt, '\n');-
2348 if (t)
tDescription
TRUEnever evaluated
FALSEnever evaluated
0
2349 redraw_prompt (++t);
never executed: redraw_prompt (++t);
0
2350 else-
2351 rl_forced_update_display ();
never executed: rl_forced_update_display ();
0
2352}-
2353-
2354/* Move the cursor from _rl_last_c_pos to NEW, which are buffer indices.-
2355 (Well, when we don't have multibyte characters, _rl_last_c_pos is a-
2356 buffer index.)-
2357 DATA is the contents of the screen line of interest; i.e., where-
2358 the movement is being done.-
2359 DATA is always the visible line or the invisible line */-
2360void-
2361_rl_move_cursor_relative (int new, const char *data)-
2362{-
2363 register int i;-
2364 int woff; /* number of invisible chars on current line */-
2365 int cpos, dpos; /* current and desired cursor positions */-
2366 int adjust;-
2367 int in_invisline;-
2368 int mb_cur_max = MB_CUR_MAX;-
2369-
2370 woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset);
(_rl_last_v_pos == 0)Description
TRUEnever evaluated
FALSEnever evaluated
wrap_offsetDescription
TRUEnever evaluated
FALSEnever evaluated
prompt_physica...rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
(_rl_last_v_po...t_screen_line)Description
TRUEnever evaluated
FALSEnever evaluated
0
2371 cpos = _rl_last_c_pos;-
2372-
2373 if (cpos == 0 && cpos == new)
cpos == 0Description
TRUEnever evaluated
FALSEnever evaluated
cpos == newDescription
TRUEnever evaluated
FALSEnever evaluated
0
2374 return;
never executed: return;
0
2375-
2376#if defined (HANDLE_MULTIBYTE)-
2377 /* If we have multibyte characters, NEW is indexed by the buffer point in-
2378 a multibyte string, but _rl_last_c_pos is the display position. In-
2379 this case, NEW's display position is not obvious and must be-
2380 calculated. We need to account for invisible characters in this line,-
2381 as long as we are past them and they are counted by _rl_col_width. */-
2382 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2383 {-
2384 adjust = 1;-
2385 /* Try to short-circuit common cases and eliminate a bunch of multibyte-
2386 character function calls. */-
2387 /* 1. prompt string */-
2388 if (new == local_prompt_len && memcmp (data, local_prompt, new) == 0)
new == local_prompt_lenDescription
TRUEnever evaluated
FALSEnever evaluated
memcmp (data, ...mpt, new) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2389 {-
2390 dpos = prompt_physical_chars;-
2391 cpos_adjusted = 1;-
2392 adjust = 0;-
2393 }
never executed: end of block
0
2394 /* 2. prompt_string + line contents */-
2395 else if (new > local_prompt_len && local_prompt && memcmp (data, local_prompt, local_prompt_len) == 0)
new > local_prompt_lenDescription
TRUEnever evaluated
FALSEnever evaluated
local_promptDescription
TRUEnever evaluated
FALSEnever evaluated
memcmp (data, ...ompt_len) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2396 {-
2397 dpos = prompt_physical_chars + _rl_col_width (data, local_prompt_len, new, 1);-
2398 cpos_adjusted = 1;-
2399 adjust = 0;-
2400 }
never executed: end of block
0
2401 else-
2402 dpos = _rl_col_width (data, 0, new, 1);
never executed: dpos = _rl_col_width (data, 0, new, 1);
0
2403-
2404 if (displaying_prompt_first_line == 0)
displaying_pro...irst_line == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2405 adjust = 0;
never executed: adjust = 0;
0
2406-
2407 /* yet another special case: printing the last line of a prompt with-
2408 multibyte characters and invisible characters whose printable length-
2409 exceeds the screen width with the last invisible character-
2410 (prompt_last_invisible) in the last line. IN_INVISLINE is the-
2411 offset of DATA in invisible_line */-
2412 in_invisline = 0;-
2413 if (data > invisible_line && data < invisible_line+inv_lbreaks[_rl_inv_botlin+1])
data > (line_s...visible->line)Description
TRUEnever evaluated
FALSEnever evaluated
data < (line_s..._inv_botlin+1]Description
TRUEnever evaluated
FALSEnever evaluated
0
2414 in_invisline = data - invisible_line;
never executed: in_invisline = data - (line_state_invisible->line);
0
2415-
2416 /* Use NEW when comparing against the last invisible character in the-
2417 prompt string, since they're both buffer indices and DPOS is a-
2418 desired display position. */-
2419 /* NEW is relative to the current displayed line, while-
2420 PROMPT_LAST_INVISIBLE is relative to the entire (wrapped) line.-
2421 Need a way to reconcile these two variables by turning NEW into a-
2422 buffer position relative to the start of the line */-
2423 if (adjust && ((new > prompt_last_invisible) || /* XXX - don't use woff here */
adjustDescription
TRUEnever evaluated
FALSEnever evaluated
(new > prompt_last_invisible)Description
TRUEnever evaluated
FALSEnever evaluated
0
2424 (new+in_invisline > prompt_last_invisible) || /* invisible line */
(new+in_invisl...ast_invisible)Description
TRUEnever evaluated
FALSEnever evaluated
0
2425 (prompt_physical_chars >= _rl_screenwidth && /* visible line */
prompt_physica...rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
2426 _rl_last_v_pos == prompt_last_screen_line &&
_rl_last_v_pos...st_screen_lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2427 wrap_offset >= woff && dpos >= woff &&
wrap_offset >= woffDescription
TRUEnever evaluated
FALSEnever evaluated
dpos >= woffDescription
TRUEnever evaluated
FALSEnever evaluated
0
2428 new > (prompt_last_invisible-(vis_lbreaks[_rl_last_v_pos])-wrap_offset))))
new > (prompt_...)-wrap_offset)Description
TRUEnever evaluated
FALSEnever evaluated
0
2429 /* XXX last comparison might need to be >= */-
2430 {-
2431 dpos -= woff;-
2432 /* Since this will be assigned to _rl_last_c_pos at the end (more-
2433 precisely, _rl_last_c_pos == dpos when this function returns),-
2434 let the caller know. */-
2435 cpos_adjusted = 1;-
2436 }
never executed: end of block
0
2437 }
never executed: end of block
0
2438 else-
2439#endif-
2440 dpos = new;
never executed: dpos = new;
0
2441-
2442 /* If we don't have to do anything, then return. */-
2443 if (cpos == dpos)
cpos == dposDescription
TRUEnever evaluated
FALSEnever evaluated
0
2444 return;
never executed: return;
0
2445-
2446 /* It may be faster to output a CR, and then move forwards instead-
2447 of moving backwards. */-
2448 /* i == current physical cursor position. */-
2449#if defined (HANDLE_MULTIBYTE)-
2450 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2451 i = _rl_last_c_pos;
never executed: i = _rl_last_c_pos;
0
2452 else-
2453#endif-
2454 i = _rl_last_c_pos - woff;
never executed: i = _rl_last_c_pos - woff;
0
2455 if (dpos == 0 || CR_FASTER (dpos, _rl_last_c_pos) ||
dpos == 0Description
TRUEnever evaluated
FALSEnever evaluated
(((dpos) + 1) ...os) - (dpos)))Description
TRUEnever evaluated
FALSEnever evaluated
0
2456 (_rl_term_autowrap && i == _rl_screenwidth))
_rl_term_autowrapDescription
TRUEnever evaluated
FALSEnever evaluated
i == _rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
2457 {-
2458#if defined (__MSDOS__)-
2459 putc ('\r', rl_outstream);-
2460#else-
2461 tputs (_rl_term_cr, 1, _rl_output_character_function);-
2462#endif /* !__MSDOS__ */-
2463 cpos = _rl_last_c_pos = 0;-
2464 }
never executed: end of block
0
2465-
2466 if (cpos < dpos)
cpos < dposDescription
TRUEnever evaluated
FALSEnever evaluated
0
2467 {-
2468 /* Move the cursor forward. We do it by printing the command-
2469 to move the cursor forward if there is one, else print that-
2470 portion of the output buffer again. Which is cheaper? */-
2471-
2472 /* The above comment is left here for posterity. It is faster-
2473 to print one character (non-control) than to print a control-
2474 sequence telling the terminal to move forward one character.-
2475 That kind of control is for people who don't know what the-
2476 data is underneath the cursor. */-
2477-
2478 /* However, we need a handle on where the current display position is-
2479 in the buffer for the immediately preceding comment to be true.-
2480 In multibyte locales, we don't currently have that info available.-
2481 Without it, we don't know where the data we have to display begins-
2482 in the buffer and we have to go back to the beginning of the screen-
2483 line. In this case, we can use the terminal sequence to move forward-
2484 if it's available. */-
2485 if (mb_cur_max > 1 && rl_byte_oriented == 0)
mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2486 {-
2487 if (_rl_term_forward_char)
_rl_term_forward_charDescription
TRUEnever evaluated
FALSEnever evaluated
0
2488 {-
2489 for (i = cpos; i < dpos; i++)
i < dposDescription
TRUEnever evaluated
FALSEnever evaluated
0
2490 tputs (_rl_term_forward_char, 1, _rl_output_character_function);
never executed: tputs (_rl_term_forward_char, 1, _rl_output_character_function);
0
2491 }
never executed: end of block
0
2492 else-
2493 {-
2494 tputs (_rl_term_cr, 1, _rl_output_character_function);-
2495 for (i = 0; i < new; i++)
i < newDescription
TRUEnever evaluated
FALSEnever evaluated
0
2496 putc (data[i], rl_outstream);
never executed: _IO_putc ( data[i] , rl_outstream ) ;
0
2497 }
never executed: end of block
0
2498 }-
2499 else-
2500 for (i = cpos; i < new; i++)
i < newDescription
TRUEnever evaluated
FALSEnever evaluated
0
2501 putc (data[i], rl_outstream);
never executed: _IO_putc ( data[i] , rl_outstream ) ;
0
2502 }
never executed: end of block
0
2503-
2504#if defined (HANDLE_MULTIBYTE)-
2505 /* NEW points to the buffer point, but _rl_last_c_pos is the display point.-
2506 The byte length of the string is probably bigger than the column width-
2507 of the string, which means that if NEW == _rl_last_c_pos, then NEW's-
2508 display point is less than _rl_last_c_pos. */-
2509#endif-
2510 else if (cpos > dpos)
cpos > dposDescription
TRUEnever evaluated
FALSEnever evaluated
0
2511 _rl_backspace (cpos - dpos);
never executed: _rl_backspace (cpos - dpos);
0
2512-
2513 _rl_last_c_pos = dpos;-
2514}
never executed: end of block
0
2515-
2516/* PWP: move the cursor up or down. */-
2517void-
2518_rl_move_vert (int to)-
2519{-
2520 register int delta, i;-
2521-
2522 if (_rl_last_v_pos == to || to > _rl_screenheight)
_rl_last_v_pos == toDescription
TRUEnever evaluated
FALSEnever evaluated
to > _rl_screenheightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2523 return;
never executed: return;
0
2524-
2525 if ((delta = to - _rl_last_v_pos) > 0)
(delta = to - ...ast_v_pos) > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2526 {-
2527 for (i = 0; i < delta; i++)
i < deltaDescription
TRUEnever evaluated
FALSEnever evaluated
0
2528 putc ('\n', rl_outstream);
never executed: _IO_putc ( '\n' , rl_outstream ) ;
0
2529#if defined (__MSDOS__)-
2530 putc ('\r', rl_outstream);-
2531#else-
2532 tputs (_rl_term_cr, 1, _rl_output_character_function);-
2533#endif-
2534 _rl_last_c_pos = 0;-
2535 }
never executed: end of block
0
2536 else-
2537 { /* delta < 0 */-
2538#ifdef __DJGPP__-
2539 int row, col;-
2540-
2541 fflush (rl_outstream);-
2542 ScreenGetCursor (&row, &col);-
2543 ScreenSetCursor (row + delta, col);-
2544 i = -delta;-
2545#else-
2546 if (_rl_term_up && *_rl_term_up)
_rl_term_upDescription
TRUEnever evaluated
FALSEnever evaluated
*_rl_term_upDescription
TRUEnever evaluated
FALSEnever evaluated
0
2547 for (i = 0; i < -delta; i++)
i < -deltaDescription
TRUEnever evaluated
FALSEnever evaluated
0
2548 tputs (_rl_term_up, 1, _rl_output_character_function);
never executed: tputs (_rl_term_up, 1, _rl_output_character_function);
0
2549#endif /* !__DJGPP__ */-
2550 }
never executed: end of block
0
2551-
2552 _rl_last_v_pos = to; /* Now TO is here */-
2553}
never executed: end of block
0
2554-
2555/* Physically print C on rl_outstream. This is for functions which know-
2556 how to optimize the display. Return the number of characters output. */-
2557int-
2558rl_show_char (int c)-
2559{-
2560 int n = 1;-
2561 if (META_CHAR (c) && (_rl_output_meta_chars == 0))
(c) > 0x07fDescription
TRUEnever evaluated
FALSEnever evaluated
(c) <= 255Description
TRUEnever evaluated
FALSEnever evaluated
(_rl_output_meta_chars == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2562 {-
2563 fprintf (rl_outstream, "M-");-
2564 n += 2;-
2565 c = UNMETA (c);-
2566 }
never executed: end of block
0
2567-
2568#if defined (DISPLAY_TABS)-
2569 if ((CTRL_CHAR (c) && c != '\t') || c == RUBOUT)
(c) < 0x020Description
TRUEnever evaluated
FALSEnever evaluated
(((c) & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
c != '\t'Description
TRUEnever evaluated
FALSEnever evaluated
c == 0x7fDescription
TRUEnever evaluated
FALSEnever evaluated
0
2570#else-
2571 if (CTRL_CHAR (c) || c == RUBOUT)-
2572#endif /* !DISPLAY_TABS */-
2573 {-
2574 fprintf (rl_outstream, "C-");-
2575 n += 2;-
2576 c = CTRL_CHAR (c) ? UNCTRL (c) : '?';
never executed: end of block
never executed: __res = toupper ( (unsigned char)((c)|0x40) );
never executed: __res = (*__ctype_toupper_loc ())[(int) ( (unsigned char)((c)|0x40) )];
sizeof ( (unsi...c)|0x40) ) > 1Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...r)((c)|0x40) )Description
TRUEnever evaluated
FALSEnever evaluated
(c) < 0x020Description
TRUEnever evaluated
FALSEnever evaluated
(((c) & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
((unsigned cha... (((c)|0x40)))Description
TRUEnever evaluated
FALSEnever evaluated
((*__ctype_b_l...int) _ISlower)Description
TRUEnever evaluated
FALSEnever evaluated
__c < -128Description
TRUEnever evaluated
FALSEnever evaluated
__c > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
2577 }
never executed: end of block
0
2578-
2579 putc (c, rl_outstream);-
2580 fflush (rl_outstream);-
2581 return n;
never executed: return n;
0
2582}-
2583-
2584int-
2585rl_character_len (int c, int pos)-
2586{-
2587 unsigned char uc;-
2588-
2589 uc = (unsigned char)c;-
2590-
2591 if (META_CHAR (uc))
(uc) > 0x07fDescription
TRUEnever evaluated
FALSEnever evaluated
(uc) <= 255Description
TRUEnever evaluated
FALSEnever evaluated
0
2592 return ((_rl_output_meta_chars == 0) ? 4 : 1);
never executed: return ((_rl_output_meta_chars == 0) ? 4 : 1);
0
2593-
2594 if (uc == '\t')
uc == '\t'Description
TRUEnever evaluated
FALSEnever evaluated
0
2595 {-
2596#if defined (DISPLAY_TABS)-
2597 return (((pos | 7) + 1) - pos);
never executed: return (((pos | 7) + 1) - pos);
0
2598#else-
2599 return (2);-
2600#endif /* !DISPLAY_TABS */-
2601 }-
2602-
2603 if (CTRL_CHAR (c) || c == RUBOUT)
(c) < 0x020Description
TRUEnever evaluated
FALSEnever evaluated
(((c) & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
c == 0x7fDescription
TRUEnever evaluated
FALSEnever evaluated
0
2604 return (2);
never executed: return (2);
0
2605-
2606 return ((ISPRINT (uc)) ? 1 : 2);
never executed: return (((1 && ((*__ctype_b_loc ())[(int) (( (unsigned char)uc ))] & (unsigned short int) _ISprint) )) ? 1 : 2);
0
2607}-
2608/* How to print things in the "echo-area". The prompt is treated as a-
2609 mini-modeline. */-
2610static int msg_saved_prompt = 0;-
2611-
2612#if defined (USE_VARARGS)-
2613int-
2614#if defined (PREFER_STDARG)-
2615rl_message (const char *format, ...)-
2616#else-
2617rl_message (va_alist)-
2618 va_dcl-
2619#endif-
2620{-
2621 va_list args;-
2622#if defined (PREFER_VARARGS)-
2623 char *format;-
2624#endif-
2625#if defined (HAVE_VSNPRINTF)-
2626 int bneed;-
2627#endif-
2628-
2629#if defined (PREFER_STDARG)-
2630 va_start (args, format);-
2631#else-
2632 va_start (args);-
2633 format = va_arg (args, char *);-
2634#endif-
2635-
2636 if (msg_buf == 0)
msg_buf == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2637 msg_buf = xmalloc (msg_bufsiz = 128);
never executed: msg_buf = xmalloc (msg_bufsiz = 128);
0
2638-
2639#if defined (HAVE_VSNPRINTF)-
2640 bneed = vsnprintf (msg_buf, msg_bufsiz, format, args);-
2641 if (bneed >= msg_bufsiz - 1)
bneed >= msg_bufsiz - 1Description
TRUEnever evaluated
FALSEnever evaluated
0
2642 {-
2643 msg_bufsiz = bneed + 1;-
2644 msg_buf = xrealloc (msg_buf, msg_bufsiz);-
2645 va_end (args);-
2646-
2647#if defined (PREFER_STDARG)-
2648 va_start (args, format);-
2649#else-
2650 va_start (args);-
2651 format = va_arg (args, char *);-
2652#endif-
2653 vsnprintf (msg_buf, msg_bufsiz - 1, format, args);-
2654 }
never executed: end of block
0
2655#else-
2656 vsprintf (msg_buf, format, args);-
2657 msg_buf[msg_bufsiz - 1] = '\0'; /* overflow? */-
2658#endif-
2659 va_end (args);-
2660-
2661 if (saved_local_prompt == 0)
saved_local_prompt == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2662 {-
2663 rl_save_prompt ();-
2664 msg_saved_prompt = 1;-
2665 }
never executed: end of block
0
2666 else if (local_prompt != saved_local_prompt)
local_prompt !...d_local_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
2667 {-
2668 FREE (local_prompt);
never executed: free (local_prompt);
local_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
2669 FREE (local_prompt_prefix);
never executed: free (local_prompt_prefix);
local_prompt_prefixDescription
TRUEnever evaluated
FALSEnever evaluated
0
2670 local_prompt = (char *)NULL;-
2671 }
never executed: end of block
0
2672 rl_display_prompt = msg_buf;-
2673 local_prompt = expand_prompt (msg_buf, 0, &prompt_visible_length,-
2674 &prompt_last_invisible,-
2675 &prompt_invis_chars_first_line,-
2676 &prompt_physical_chars);-
2677 local_prompt_prefix = (char *)NULL;-
2678 local_prompt_len = local_prompt ? strlen (local_prompt) : 0;
local_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
2679 (*rl_redisplay_function) ();-
2680-
2681 return 0;
never executed: return 0;
0
2682}-
2683#else /* !USE_VARARGS */-
2684int-
2685rl_message (format, arg1, arg2)-
2686 char *format;-
2687{-
2688 if (msg_buf == 0)-
2689 msg_buf = xmalloc (msg_bufsiz = 128);-
2690-
2691 sprintf (msg_buf, format, arg1, arg2);-
2692 msg_buf[msg_bufsiz - 1] = '\0'; /* overflow? */-
2693-
2694 rl_display_prompt = msg_buf;-
2695 if (saved_local_prompt == 0)-
2696 {-
2697 rl_save_prompt ();-
2698 msg_saved_prompt = 1;-
2699 }-
2700 else if (local_prompt != saved_local_prompt)-
2701 {-
2702 FREE (local_prompt);-
2703 FREE (local_prompt_prefix);-
2704 local_prompt = (char *)NULL;-
2705 }-
2706 local_prompt = expand_prompt (msg_buf, 0, &prompt_visible_length,-
2707 &prompt_last_invisible,-
2708 &prompt_invis_chars_first_line,-
2709 &prompt_physical_chars);-
2710 local_prompt_prefix = (char *)NULL;-
2711 local_prompt_len = local_prompt ? strlen (local_prompt) : 0;-
2712 (*rl_redisplay_function) ();-
2713 -
2714 return 0;-
2715}-
2716#endif /* !USE_VARARGS */-
2717-
2718/* How to clear things from the "echo-area". */-
2719int-
2720rl_clear_message (void)-
2721{-
2722 rl_display_prompt = rl_prompt;-
2723 if (msg_saved_prompt)
msg_saved_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
2724 {-
2725 rl_restore_prompt ();-
2726 msg_saved_prompt = 0;-
2727 }
never executed: end of block
0
2728 (*rl_redisplay_function) ();-
2729 return 0;
never executed: return 0;
0
2730}-
2731-
2732int-
2733rl_reset_line_state (void)-
2734{-
2735 rl_on_new_line ();-
2736-
2737 rl_display_prompt = rl_prompt ? rl_prompt : "";
rl_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
2738 forced_display = 1;-
2739 return 0;
never executed: return 0;
0
2740}-
2741-
2742/* Save all of the variables associated with the prompt and its display. Most-
2743 of the complexity is dealing with the invisible characters in the prompt-
2744 string and where they are. There are enough of these that I should consider-
2745 a struct. */-
2746void-
2747rl_save_prompt (void)-
2748{-
2749 saved_local_prompt = local_prompt;-
2750 saved_local_prefix = local_prompt_prefix;-
2751 saved_prefix_length = prompt_prefix_length;-
2752 saved_local_length = local_prompt_len;-
2753 saved_last_invisible = prompt_last_invisible;-
2754 saved_visible_length = prompt_visible_length;-
2755 saved_invis_chars_first_line = prompt_invis_chars_first_line;-
2756 saved_physical_chars = prompt_physical_chars;-
2757 saved_local_prompt_newlines = local_prompt_newlines;-
2758-
2759 local_prompt = local_prompt_prefix = (char *)0;-
2760 local_prompt_len = 0;-
2761 local_prompt_newlines = (int *)0;-
2762-
2763 prompt_last_invisible = prompt_visible_length = prompt_prefix_length = 0;-
2764 prompt_invis_chars_first_line = prompt_physical_chars = 0;-
2765}
never executed: end of block
0
2766-
2767void-
2768rl_restore_prompt (void)-
2769{-
2770 FREE (local_prompt);
never executed: free (local_prompt);
local_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
2771 FREE (local_prompt_prefix);
never executed: free (local_prompt_prefix);
local_prompt_prefixDescription
TRUEnever evaluated
FALSEnever evaluated
0
2772 FREE (local_prompt_newlines);
never executed: free (local_prompt_newlines);
local_prompt_newlinesDescription
TRUEnever evaluated
FALSEnever evaluated
0
2773-
2774 local_prompt = saved_local_prompt;-
2775 local_prompt_prefix = saved_local_prefix;-
2776 local_prompt_len = saved_local_length;-
2777 local_prompt_newlines = saved_local_prompt_newlines;-
2778-
2779 prompt_prefix_length = saved_prefix_length;-
2780 prompt_last_invisible = saved_last_invisible;-
2781 prompt_visible_length = saved_visible_length;-
2782 prompt_invis_chars_first_line = saved_invis_chars_first_line;-
2783 prompt_physical_chars = saved_physical_chars;-
2784-
2785 /* can test saved_local_prompt to see if prompt info has been saved. */-
2786 saved_local_prompt = saved_local_prefix = (char *)0;-
2787 saved_local_length = 0;-
2788 saved_last_invisible = saved_visible_length = saved_prefix_length = 0;-
2789 saved_invis_chars_first_line = saved_physical_chars = 0;-
2790 saved_local_prompt_newlines = 0;-
2791}
never executed: end of block
0
2792-
2793char *-
2794_rl_make_prompt_for_search (int pchar)-
2795{-
2796 int len;-
2797 char *pmt, *p;-
2798-
2799 rl_save_prompt ();-
2800-
2801 /* We've saved the prompt, and can do anything with the various prompt-
2802 strings we need before they're restored. We want the unexpanded-
2803 portion of the prompt string after any final newline. */-
2804 p = rl_prompt ? strrchr (rl_prompt, '\n') : 0;
rl_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
2805 if (p == 0)
p == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2806 {-
2807 len = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0;
rl_promptDescription
TRUEnever evaluated
FALSEnever evaluated
*rl_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
2808 pmt = (char *)xmalloc (len + 2);-
2809 if (len)
lenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2810 strcpy (pmt, rl_prompt);
never executed: strcpy (pmt, rl_prompt);
0
2811 pmt[len] = pchar;-
2812 pmt[len+1] = '\0';-
2813 }
never executed: end of block
0
2814 else-
2815 {-
2816 p++;-
2817 len = strlen (p);-
2818 pmt = (char *)xmalloc (len + 2);-
2819 if (len)
lenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2820 strcpy (pmt, p);
never executed: strcpy (pmt, p);
0
2821 pmt[len] = pchar;-
2822 pmt[len+1] = '\0';-
2823 }
never executed: end of block
0
2824-
2825 /* will be overwritten by expand_prompt, called from rl_message */-
2826 prompt_physical_chars = saved_physical_chars + 1;-
2827 return pmt;
never executed: return pmt;
0
2828}-
2829-
2830/* Quick redisplay hack when erasing characters at the end of the line. */-
2831void-
2832_rl_erase_at_end_of_line (int l)-
2833{-
2834 register int i;-
2835-
2836 _rl_backspace (l);-
2837 for (i = 0; i < l; i++)
i < lDescription
TRUEnever evaluated
FALSEnever evaluated
0
2838 putc (' ', rl_outstream);
never executed: _IO_putc ( ' ' , rl_outstream ) ;
0
2839 _rl_backspace (l);-
2840 for (i = 0; i < l; i++)
i < lDescription
TRUEnever evaluated
FALSEnever evaluated
0
2841 visible_line[--_rl_last_c_pos] = '\0';
never executed: (line_state_visible->line)[--_rl_last_c_pos] = '\0';
0
2842 rl_display_fixed++;-
2843}
never executed: end of block
0
2844-
2845/* Clear to the end of the line. COUNT is the minimum-
2846 number of character spaces to clear, but we use a terminal escape-
2847 sequence if available. */-
2848void-
2849_rl_clear_to_eol (int count)-
2850{-
2851#ifndef __MSDOS__-
2852 if (_rl_term_clreol)
_rl_term_clreolDescription
TRUEnever evaluated
FALSEnever evaluated
0
2853 tputs (_rl_term_clreol, 1, _rl_output_character_function);
never executed: tputs (_rl_term_clreol, 1, _rl_output_character_function);
0
2854 else-
2855#endif-
2856 if (count)
countDescription
TRUEnever evaluated
FALSEnever evaluated
0
2857 space_to_eol (count);
never executed: space_to_eol (count);
0
2858}
never executed: end of block
0
2859-
2860/* Clear to the end of the line using spaces. COUNT is the minimum-
2861 number of character spaces to clear, */-
2862static void-
2863space_to_eol (int count)-
2864{-
2865 register int i;-
2866-
2867 for (i = 0; i < count; i++)
i < countDescription
TRUEnever evaluated
FALSEnever evaluated
0
2868 putc (' ', rl_outstream);
never executed: _IO_putc ( ' ' , rl_outstream ) ;
0
2869-
2870 _rl_last_c_pos += count;-
2871}
never executed: end of block
0
2872-
2873void-
2874_rl_clear_screen (void)-
2875{-
2876#ifndef __DJGPP__-
2877 if (_rl_term_clrpag)
_rl_term_clrpagDescription
TRUEnever evaluated
FALSEnever evaluated
0
2878 tputs (_rl_term_clrpag, 1, _rl_output_character_function);
never executed: tputs (_rl_term_clrpag, 1, _rl_output_character_function);
0
2879 else-
2880 rl_crlf ();
never executed: rl_crlf ();
0
2881#else-
2882 ScreenClear ();-
2883 ScreenSetCursor (0, 0);-
2884#endif /* __DJGPP__ */-
2885}-
2886-
2887/* Insert COUNT characters from STRING to the output stream at column COL. */-
2888static void-
2889insert_some_chars (char *string, int count, int col)-
2890{-
2891 open_some_spaces (col);-
2892 _rl_output_some_chars (string, count);-
2893}
never executed: end of block
0
2894-
2895/* Insert COL spaces, keeping the cursor at the same position. We follow the-
2896 ncurses documentation and use either im/ei with explicit spaces, or IC/ic-
2897 by itself. We assume there will either be ei or we don't need to use it. */-
2898static void-
2899open_some_spaces (int col)-
2900{-
2901#if !defined (__MSDOS__) && (!defined (__MINGW32__) || defined (NCURSES_VERSION))-
2902 char *buffer;-
2903 register int i;-
2904-
2905 /* If IC is defined, then we do not have to "enter" insert mode. */-
2906 if (_rl_term_IC)
_rl_term_ICDescription
TRUEnever evaluated
FALSEnever evaluated
0
2907 {-
2908 buffer = tgoto (_rl_term_IC, 0, col);-
2909 tputs (buffer, 1, _rl_output_character_function);-
2910 }
never executed: end of block
0
2911 else if (_rl_term_im && *_rl_term_im)
_rl_term_imDescription
TRUEnever evaluated
FALSEnever evaluated
*_rl_term_imDescription
TRUEnever evaluated
FALSEnever evaluated
0
2912 {-
2913 tputs (_rl_term_im, 1, _rl_output_character_function);-
2914 /* just output the desired number of spaces */-
2915 for (i = col; i--; )
i--Description
TRUEnever evaluated
FALSEnever evaluated
0
2916 _rl_output_character_function (' ');
never executed: _rl_output_character_function (' ');
0
2917 /* If there is a string to turn off insert mode, use it now. */-
2918 if (_rl_term_ei && *_rl_term_ei)
_rl_term_eiDescription
TRUEnever evaluated
FALSEnever evaluated
*_rl_term_eiDescription
TRUEnever evaluated
FALSEnever evaluated
0
2919 tputs (_rl_term_ei, 1, _rl_output_character_function);
never executed: tputs (_rl_term_ei, 1, _rl_output_character_function);
0
2920 /* and move back the right number of spaces */-
2921 _rl_backspace (col);-
2922 }
never executed: end of block
0
2923 else if (_rl_term_ic && *_rl_term_ic)
_rl_term_icDescription
TRUEnever evaluated
FALSEnever evaluated
*_rl_term_icDescription
TRUEnever evaluated
FALSEnever evaluated
0
2924 {-
2925 /* If there is a special command for inserting characters, then-
2926 use that first to open up the space. */-
2927 for (i = col; i--; )
i--Description
TRUEnever evaluated
FALSEnever evaluated
0
2928 tputs (_rl_term_ic, 1, _rl_output_character_function);
never executed: tputs (_rl_term_ic, 1, _rl_output_character_function);
0
2929 }
never executed: end of block
0
2930#endif /* !__MSDOS__ && (!__MINGW32__ || NCURSES_VERSION)*/-
2931}
never executed: end of block
0
2932-
2933/* Delete COUNT characters from the display line. */-
2934static void-
2935delete_chars (int count)-
2936{-
2937 if (count > _rl_screenwidth) /* XXX */
count > _rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
2938 return;
never executed: return;
0
2939-
2940#if !defined (__MSDOS__) && (!defined (__MINGW32__) || defined (NCURSES_VERSION))-
2941 if (_rl_term_DC && *_rl_term_DC)
_rl_term_DCDescription
TRUEnever evaluated
FALSEnever evaluated
*_rl_term_DCDescription
TRUEnever evaluated
FALSEnever evaluated
0
2942 {-
2943 char *buffer;-
2944 buffer = tgoto (_rl_term_DC, count, count);-
2945 tputs (buffer, count, _rl_output_character_function);-
2946 }
never executed: end of block
0
2947 else-
2948 {-
2949 if (_rl_term_dc && *_rl_term_dc)
_rl_term_dcDescription
TRUEnever evaluated
FALSEnever evaluated
*_rl_term_dcDescription
TRUEnever evaluated
FALSEnever evaluated
0
2950 while (count--)
count--Description
TRUEnever evaluated
FALSEnever evaluated
0
2951 tputs (_rl_term_dc, 1, _rl_output_character_function);
never executed: tputs (_rl_term_dc, 1, _rl_output_character_function);
0
2952 }
never executed: end of block
0
2953#endif /* !__MSDOS__ && (!__MINGW32__ || NCURSES_VERSION)*/-
2954}-
2955-
2956void-
2957_rl_update_final (void)-
2958{-
2959 int full_lines, woff, botline_length;-
2960-
2961 full_lines = 0;-
2962 /* If the cursor is the only thing on an otherwise-blank last line,-
2963 compensate so we don't print an extra CRLF. */-
2964 if (_rl_vis_botlin && _rl_last_c_pos == 0 &&
_rl_vis_botlinDescription
TRUEnever evaluated
FALSEnever evaluated
_rl_last_c_pos == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2965 visible_line[vis_lbreaks[_rl_vis_botlin]] == 0)
(line_state_vi..._botlin]] == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2966 {-
2967 _rl_vis_botlin--;-
2968 full_lines = 1;-
2969 }
never executed: end of block
0
2970 _rl_move_vert (_rl_vis_botlin);-
2971 woff = W_OFFSET(_rl_vis_botlin, wrap_offset);
(_rl_vis_botlin) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2972 botline_length = VIS_LLEN(_rl_vis_botlin) - woff;
(_rl_vis_botli..._rl_vis_botlinDescription
TRUEnever evaluated
FALSEnever evaluated
0
2973 /* If we've wrapped lines, remove the final xterm line-wrap flag. */-
2974 if (full_lines && _rl_term_autowrap && botline_length == _rl_screenwidth)
full_linesDescription
TRUEnever evaluated
FALSEnever evaluated
_rl_term_autowrapDescription
TRUEnever evaluated
FALSEnever evaluated
botline_length...rl_screenwidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
2975 {-
2976 char *last_line;-
2977-
2978 /* LAST_LINE includes invisible characters, so if you want to get the-
2979 last character of the first line, you have to take WOFF into account.-
2980 This needs to be done for both calls to _rl_move_cursor_relative,-
2981 which takes a buffer position as the first argument, and any direct-
2982 subscripts of LAST_LINE. */-
2983 last_line = &visible_line[vis_lbreaks[_rl_vis_botlin]]; /* = VIS_CHARS(_rl_vis_botlin); */-
2984 cpos_buffer_position = -1; /* don't know where we are in buffer */-
2985 _rl_move_cursor_relative (_rl_screenwidth - 1 + woff, last_line); /* XXX */-
2986 _rl_clear_to_eol (0);-
2987 putc (last_line[_rl_screenwidth - 1 + woff], rl_outstream);-
2988 }
never executed: end of block
0
2989 _rl_vis_botlin = 0;-
2990 rl_crlf ();-
2991 fflush (rl_outstream);-
2992 rl_display_fixed++;-
2993}
never executed: end of block
0
2994-
2995/* Move to the start of the current line. */-
2996static void-
2997cr (void)-
2998{-
2999 if (_rl_term_cr)
_rl_term_crDescription
TRUEnever evaluated
FALSEnever evaluated
0
3000 {-
3001#if defined (__MSDOS__)-
3002 putc ('\r', rl_outstream);-
3003#else-
3004 tputs (_rl_term_cr, 1, _rl_output_character_function);-
3005#endif-
3006 _rl_last_c_pos = 0;-
3007 }
never executed: end of block
0
3008}
never executed: end of block
0
3009-
3010/* Redraw the last line of a multi-line prompt that may possibly contain-
3011 terminal escape sequences. Called with the cursor at column 0 of the-
3012 line to draw the prompt on. */-
3013static void-
3014redraw_prompt (char *t)-
3015{-
3016 char *oldp;-
3017-
3018 oldp = rl_display_prompt;-
3019 rl_save_prompt ();-
3020-
3021 rl_display_prompt = t;-
3022 local_prompt = expand_prompt (t, PMT_MULTILINE,-
3023 &prompt_visible_length,-
3024 &prompt_last_invisible,-
3025 &prompt_invis_chars_first_line,-
3026 &prompt_physical_chars);-
3027 local_prompt_prefix = (char *)NULL;-
3028 local_prompt_len = local_prompt ? strlen (local_prompt) : 0;
local_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
3029-
3030 rl_forced_update_display ();-
3031-
3032 rl_display_prompt = oldp;-
3033 rl_restore_prompt();-
3034}
never executed: end of block
0
3035 -
3036/* Redisplay the current line after a SIGWINCH is received. */-
3037void-
3038_rl_redisplay_after_sigwinch (void)-
3039{-
3040 char *t;-
3041-
3042 /* Clear the last line (assuming that the screen size change will result in-
3043 either more or fewer characters on that line only) and put the cursor at-
3044 column 0. Make sure the right thing happens if we have wrapped to a new-
3045 screen line. */-
3046 if (_rl_term_cr)
_rl_term_crDescription
TRUEnever evaluated
FALSEnever evaluated
0
3047 {-
3048 _rl_move_vert (_rl_vis_botlin);-
3049-
3050#if defined (__MSDOS__)-
3051 putc ('\r', rl_outstream);-
3052#else-
3053 tputs (_rl_term_cr, 1, _rl_output_character_function);-
3054#endif-
3055 _rl_last_c_pos = 0;-
3056#if defined (__MSDOS__)-
3057 space_to_eol (_rl_screenwidth);-
3058 putc ('\r', rl_outstream);-
3059#else-
3060 if (_rl_term_clreol)
_rl_term_clreolDescription
TRUEnever evaluated
FALSEnever evaluated
0
3061 tputs (_rl_term_clreol, 1, _rl_output_character_function);
never executed: tputs (_rl_term_clreol, 1, _rl_output_character_function);
0
3062 else-
3063 {-
3064 space_to_eol (_rl_screenwidth);-
3065 tputs (_rl_term_cr, 1, _rl_output_character_function);-
3066 }
never executed: end of block
0
3067#endif-
3068 if (_rl_last_v_pos > 0)
_rl_last_v_pos > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3069 _rl_move_vert (0);
never executed: _rl_move_vert (0);
0
3070 }
never executed: end of block
0
3071 else-
3072 rl_crlf ();
never executed: rl_crlf ();
0
3073-
3074 /* Redraw only the last line of a multi-line prompt. */-
3075 t = strrchr (rl_display_prompt, '\n');-
3076 if (t)
tDescription
TRUEnever evaluated
FALSEnever evaluated
0
3077 redraw_prompt (++t);
never executed: redraw_prompt (++t);
0
3078 else-
3079 rl_forced_update_display ();
never executed: rl_forced_update_display ();
0
3080}-
3081-
3082void-
3083_rl_clean_up_for_exit (void)-
3084{-
3085 if (_rl_echoing_p)
_rl_echoing_pDescription
TRUEnever evaluated
FALSEnever evaluated
0
3086 {-
3087 if (_rl_vis_botlin > 0) /* minor optimization plus bug fix */
_rl_vis_botlin > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3088 _rl_move_vert (_rl_vis_botlin);
never executed: _rl_move_vert (_rl_vis_botlin);
0
3089 _rl_vis_botlin = 0;-
3090 fflush (rl_outstream);-
3091 rl_restart_output (1, 0);-
3092 }
never executed: end of block
0
3093}
never executed: end of block
0
3094-
3095void-
3096_rl_erase_entire_line (void)-
3097{-
3098 cr ();-
3099 _rl_clear_to_eol (0);-
3100 cr ();-
3101 fflush (rl_outstream);-
3102}
never executed: end of block
0
3103-
3104void-
3105_rl_ttyflush (void)-
3106{-
3107 fflush (rl_outstream);-
3108}
never executed: end of block
0
3109-
3110/* return the `current display line' of the cursor -- the number of lines to-
3111 move up to get to the first screen line of the current readline line. */-
3112int-
3113_rl_current_display_line (void)-
3114{-
3115 int ret, nleft;-
3116-
3117 /* Find out whether or not there might be invisible characters in the-
3118 editing buffer. */-
3119 if (rl_display_prompt == rl_prompt)
rl_display_prompt == rl_promptDescription
TRUEnever evaluated
FALSEnever evaluated
0
3120 nleft = _rl_last_c_pos - _rl_screenwidth - rl_visible_prompt_length;
never executed: nleft = _rl_last_c_pos - _rl_screenwidth - rl_visible_prompt_length;
0
3121 else-
3122 nleft = _rl_last_c_pos - _rl_screenwidth;
never executed: nleft = _rl_last_c_pos - _rl_screenwidth;
0
3123-
3124 if (nleft > 0)
nleft > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3125 ret = 1 + nleft / _rl_screenwidth;
never executed: ret = 1 + nleft / _rl_screenwidth;
0
3126 else-
3127 ret = 0;
never executed: ret = 0;
0
3128-
3129 return ret;
never executed: return ret;
0
3130}-
3131-
3132#if defined (HANDLE_MULTIBYTE)-
3133/* Calculate the number of screen columns occupied by STR from START to END.-
3134 In the case of multibyte characters with stateful encoding, we have to-
3135 scan from the beginning of the string to take the state into account. */-
3136static int-
3137_rl_col_width (const char *str, int start, int end, int flags)-
3138{-
3139 wchar_t wc;-
3140 mbstate_t ps;-
3141 int tmp, point, width, max;-
3142-
3143 if (end <= start)
end <= startDescription
TRUEnever evaluated
FALSEnever evaluated
0
3144 return 0;
never executed: return 0;
0
3145 if (MB_CUR_MAX == 1 || rl_byte_oriented)
(__ctype_get_m...r_max ()) == 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_orientedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3146 /* this can happen in some cases where it's inconvenient to check */-
3147 return (end - start);
never executed: return (end - start);
0
3148-
3149 memset (&ps, 0, sizeof (mbstate_t));-
3150-
3151 point = 0;-
3152 max = end;-
3153-
3154 /* Try to short-circuit common cases. The adjustment to remove wrap_offset-
3155 is done by the caller. */-
3156 /* 1. prompt string */-
3157 if (flags && start == 0 && end == local_prompt_len && memcmp (str, local_prompt, local_prompt_len) == 0)
flagsDescription
TRUEnever evaluated
FALSEnever evaluated
start == 0Description
TRUEnever evaluated
FALSEnever evaluated
end == local_prompt_lenDescription
TRUEnever evaluated
FALSEnever evaluated
memcmp (str, l...ompt_len) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3158 return (prompt_physical_chars + wrap_offset);
never executed: return (prompt_physical_chars + wrap_offset);
0
3159 /* 2. prompt string + line contents */-
3160 else if (flags && start == 0 && local_prompt_len > 0 && end > local_prompt_len && local_prompt && memcmp (str, local_prompt, local_prompt_len) == 0)
flagsDescription
TRUEnever evaluated
FALSEnever evaluated
start == 0Description
TRUEnever evaluated
FALSEnever evaluated
local_prompt_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
end > local_prompt_lenDescription
TRUEnever evaluated
FALSEnever evaluated
local_promptDescription
TRUEnever evaluated
FALSEnever evaluated
memcmp (str, l...ompt_len) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3161 {-
3162 tmp = prompt_physical_chars + wrap_offset;-
3163 /* XXX - try to call ourselves recursively with non-prompt portion */-
3164 tmp += _rl_col_width (str, local_prompt_len, end, flags);-
3165 return (tmp);
never executed: return (tmp);
0
3166 }-
3167-
3168 while (point < start)
point < startDescription
TRUEnever evaluated
FALSEnever evaluated
0
3169 {-
3170 if (_rl_utf8locale && UTF8_SINGLEBYTE(str[point]))
_rl_utf8localeDescription
TRUEnever evaluated
FALSEnever evaluated
(((str[point]) & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
3171 {-
3172 memset (&ps, 0, sizeof (mbstate_t));-
3173 tmp = 1;-
3174 }
never executed: end of block
0
3175 else-
3176 tmp = mbrlen (str + point, max, &ps);
never executed: tmp = mbrlen (str + point, max, &ps);
0
3177 if (MB_INVALIDCH ((size_t)tmp))
((size_t)tmp) == (size_t)-1Description
TRUEnever evaluated
FALSEnever evaluated
((size_t)tmp) == (size_t)-2Description
TRUEnever evaluated
FALSEnever evaluated
0
3178 {-
3179 /* In this case, the bytes are invalid or too short to compose a-
3180 multibyte character, so we assume that the first byte represents-
3181 a single character. */-
3182 point++;-
3183 max--;-
3184-
3185 /* Clear the state of the byte sequence, because in this case the-
3186 effect of mbstate is undefined. */-
3187 memset (&ps, 0, sizeof (mbstate_t));-
3188 }
never executed: end of block
0
3189 else if (MB_NULLWCH (tmp))
((tmp) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
3190 break; /* Found '\0' */
never executed: break;
0
3191 else-
3192 {-
3193 point += tmp;-
3194 max -= tmp;-
3195 }
never executed: end of block
0
3196 }-
3197-
3198 /* If START is not a byte that starts a character, then POINT will be-
3199 greater than START. In this case, assume that (POINT - START) gives-
3200 a byte count that is the number of columns of difference. */-
3201 width = point - start;-
3202-
3203 while (point < end)
point < endDescription
TRUEnever evaluated
FALSEnever evaluated
0
3204 {-
3205 if (_rl_utf8locale && UTF8_SINGLEBYTE(str[point]))
_rl_utf8localeDescription
TRUEnever evaluated
FALSEnever evaluated
(((str[point]) & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
3206 {-
3207 tmp = 1;-
3208 wc = (wchar_t) str[point];-
3209 }
never executed: end of block
0
3210 else-
3211 tmp = mbrtowc (&wc, str + point, max, &ps);
never executed: tmp = mbrtowc (&wc, str + point, max, &ps);
0
3212 if (MB_INVALIDCH ((size_t)tmp))
((size_t)tmp) == (size_t)-1Description
TRUEnever evaluated
FALSEnever evaluated
((size_t)tmp) == (size_t)-2Description
TRUEnever evaluated
FALSEnever evaluated
0
3213 {-
3214 /* In this case, the bytes are invalid or too short to compose a-
3215 multibyte character, so we assume that the first byte represents-
3216 a single character. */-
3217 point++;-
3218 max--;-
3219-
3220 /* and assume that the byte occupies a single column. */-
3221 width++;-
3222-
3223 /* Clear the state of the byte sequence, because in this case the-
3224 effect of mbstate is undefined. */-
3225 memset (&ps, 0, sizeof (mbstate_t));-
3226 }
never executed: end of block
0
3227 else if (MB_NULLWCH (tmp))
((tmp) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
3228 break; /* Found '\0' */
never executed: break;
0
3229 else-
3230 {-
3231 point += tmp;-
3232 max -= tmp;-
3233 tmp = WCWIDTH(wc);-
3234 width += (tmp >= 0) ? tmp : 1;
(tmp >= 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
3235 }
never executed: end of block
0
3236 }-
3237-
3238 width += point - end;-
3239-
3240 return width;
never executed: return width;
0
3241}-
3242#endif /* HANDLE_MULTIBYTE */-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2