display.c (58314) | display.c (75409) |
---|---|
1/* $FreeBSD: head/contrib/libreadline/display.c 58314 2000-03-19 22:00:57Z ache $ */ | 1/* $FreeBSD: head/contrib/libreadline/display.c 75409 2001-04-11 03:15:56Z ache $ */ |
2/* display.c -- readline redisplay facility. */ 3 4/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. 5 6 This file is part of the GNU Readline Library, a library for 7 reading lines of text with interactive input and history editing. 8 9 The GNU Readline Library is free software; you can redistribute it --- 45 unchanged lines hidden (view full) --- 55#include "rlprivate.h" 56#include "xmalloc.h" 57 58#if !defined (strchr) && !defined (__STDC__) 59extern char *strchr (), *strrchr (); 60#endif /* !strchr && !__STDC__ */ 61 62#if defined (HACK_TERMCAP_MOTION) | 2/* display.c -- readline redisplay facility. */ 3 4/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. 5 6 This file is part of the GNU Readline Library, a library for 7 reading lines of text with interactive input and history editing. 8 9 The GNU Readline Library is free software; you can redistribute it --- 45 unchanged lines hidden (view full) --- 55#include "rlprivate.h" 56#include "xmalloc.h" 57 58#if !defined (strchr) && !defined (__STDC__) 59extern char *strchr (), *strrchr (); 60#endif /* !strchr && !__STDC__ */ 61 62#if defined (HACK_TERMCAP_MOTION) |
63extern char *term_forward_char; | 63extern char *_rl_term_forward_char; |
64#endif 65 66static void update_line __P((char *, char *, int, int, int, int)); 67static void space_to_eol __P((int)); 68static void delete_chars __P((int)); 69static void insert_some_chars __P((char *, int)); 70static void cr __P((void)); 71 --- 27 unchanged lines hidden (view full) --- 99 just drew into be the one which reflects the current contents of the 100 screen, and place the cursor where it belongs. 101 102 Commands that want to can fix the display themselves, and then let 103 this function know that the display has been fixed by setting the 104 RL_DISPLAY_FIXED variable. This is good for efficiency. */ 105 106/* Application-specific redisplay function. */ | 64#endif 65 66static void update_line __P((char *, char *, int, int, int, int)); 67static void space_to_eol __P((int)); 68static void delete_chars __P((int)); 69static void insert_some_chars __P((char *, int)); 70static void cr __P((void)); 71 --- 27 unchanged lines hidden (view full) --- 99 just drew into be the one which reflects the current contents of the 100 screen, and place the cursor where it belongs. 101 102 Commands that want to can fix the display themselves, and then let 103 this function know that the display has been fixed by setting the 104 RL_DISPLAY_FIXED variable. This is good for efficiency. */ 105 106/* Application-specific redisplay function. */ |
107VFunction *rl_redisplay_function = rl_redisplay; | 107rl_voidfunc_t *rl_redisplay_function = rl_redisplay; |
108 109/* Global variables declared here. */ 110/* What YOU turn on when you have handled all redisplay yourself. */ 111int rl_display_fixed = 0; 112 113int _rl_suppress_redisplay = 0; 114 115/* The stuff that gets printed out before the actual text of the line. --- 22 unchanged lines hidden (view full) --- 138static char msg_buf[128]; 139 140/* Non-zero forces the redisplay even if we thought it was unnecessary. */ 141static int forced_display; 142 143/* Default and initial buffer size. Can grow. */ 144static int line_size = 1024; 145 | 108 109/* Global variables declared here. */ 110/* What YOU turn on when you have handled all redisplay yourself. */ 111int rl_display_fixed = 0; 112 113int _rl_suppress_redisplay = 0; 114 115/* The stuff that gets printed out before the actual text of the line. --- 22 unchanged lines hidden (view full) --- 138static char msg_buf[128]; 139 140/* Non-zero forces the redisplay even if we thought it was unnecessary. */ 141static int forced_display; 142 143/* Default and initial buffer size. Can grow. */ 144static int line_size = 1024; 145 |
146/* Variables to keep track of the expanded prompt string, which may 147 include invisible characters. */ 148 |
|
146static char *local_prompt, *local_prompt_prefix; | 149static char *local_prompt, *local_prompt_prefix; |
147static int visible_length, prefix_length; | 150static int prompt_visible_length, prompt_prefix_length; |
148 149/* The number of invisible characters in the line currently being 150 displayed on the screen. */ 151static int visible_wrap_offset; 152 | 151 152/* The number of invisible characters in the line currently being 153 displayed on the screen. */ 154static int visible_wrap_offset; 155 |
153/* static so it can be shared between rl_redisplay and update_line */ | 156/* The number of invisible characters in the prompt string. Static so it 157 can be shared between rl_redisplay and update_line */ |
154static int wrap_offset; 155 | 158static int wrap_offset; 159 |
156/* The index of the last invisible_character in the prompt string. */ 157static int last_invisible; | 160/* The index of the last invisible character in the prompt string. */ 161static int prompt_last_invisible; |
158 159/* The length (buffer offset) of the first line of the last (possibly 160 multi-line) buffer displayed on the screen. */ 161static int visible_first_line_len; 162 | 162 163/* The length (buffer offset) of the first line of the last (possibly 164 multi-line) buffer displayed on the screen. */ 165static int visible_first_line_len; 166 |
167/* Number of invisible characters on the first physical line of the prompt. 168 Only valid when the number of physical characters in the prompt exceeds 169 (or is equal to) _rl_screenwidth. */ 170static int prompt_invis_chars_first_line; 171 172static int prompt_last_screen_line; 173 |
|
163/* Expand the prompt string S and return the number of visible 164 characters in *LP, if LP is not null. This is currently more-or-less 165 a placeholder for expansion. LIP, if non-null is a place to store the | 174/* Expand the prompt string S and return the number of visible 175 characters in *LP, if LP is not null. This is currently more-or-less 176 a placeholder for expansion. LIP, if non-null is a place to store the |
166 index of the last invisible character in the returned string. */ | 177 index of the last invisible character in the returned string. NIFLP, 178 if non-zero, is a place to store the number of invisible characters in 179 the first prompt line. */ |
167 168/* Current implementation: 169 \001 (^A) start non-visible characters 170 \002 (^B) end non-visible characters 171 all characters except \001 and \002 (following a \001) are copied to 172 the returned string; all characters except those between \001 and 173 \002 are assumed to be `visible'. */ 174 175static char * | 180 181/* Current implementation: 182 \001 (^A) start non-visible characters 183 \002 (^B) end non-visible characters 184 all characters except \001 and \002 (following a \001) are copied to 185 the returned string; all characters except those between \001 and 186 \002 are assumed to be `visible'. */ 187 188static char * |
176expand_prompt (pmt, lp, lip) | 189expand_prompt (pmt, lp, lip, niflp) |
177 char *pmt; | 190 char *pmt; |
178 int *lp, *lip; | 191 int *lp, *lip, *niflp; |
179{ 180 char *r, *ret, *p; | 192{ 193 char *r, *ret, *p; |
181 int l, rl, last, ignoring; | 194 int l, rl, last, ignoring, ninvis, invfl; |
182 183 /* Short-circuit if we can. */ 184 if (strchr (pmt, RL_PROMPT_START_IGNORE) == 0) 185 { 186 r = savestring (pmt); 187 if (lp) 188 *lp = strlen (r); 189 return r; 190 } 191 192 l = strlen (pmt); 193 r = ret = xmalloc (l + 1); | 195 196 /* Short-circuit if we can. */ 197 if (strchr (pmt, RL_PROMPT_START_IGNORE) == 0) 198 { 199 r = savestring (pmt); 200 if (lp) 201 *lp = strlen (r); 202 return r; 203 } 204 205 l = strlen (pmt); 206 r = ret = xmalloc (l + 1); |
194 195 for (rl = ignoring = last = 0, p = pmt; p && *p; p++) | 207 208 invfl = 0; /* invisible chars in first line of prompt */ 209 210 for (rl = ignoring = last = ninvis = 0, p = pmt; p && *p; p++) |
196 { 197 /* This code strips the invisible character string markers 198 RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE */ 199 if (*p == RL_PROMPT_START_IGNORE) 200 { 201 ignoring++; 202 continue; 203 } 204 else if (ignoring && *p == RL_PROMPT_END_IGNORE) 205 { 206 ignoring = 0; 207 last = r - ret - 1; 208 continue; 209 } 210 else 211 { 212 *r++ = *p; 213 if (!ignoring) 214 rl++; | 211 { 212 /* This code strips the invisible character string markers 213 RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE */ 214 if (*p == RL_PROMPT_START_IGNORE) 215 { 216 ignoring++; 217 continue; 218 } 219 else if (ignoring && *p == RL_PROMPT_END_IGNORE) 220 { 221 ignoring = 0; 222 last = r - ret - 1; 223 continue; 224 } 225 else 226 { 227 *r++ = *p; 228 if (!ignoring) 229 rl++; |
230 else 231 ninvis++; 232 if (rl == _rl_screenwidth) 233 invfl = ninvis; |
|
215 } 216 } 217 | 234 } 235 } 236 |
237 if (rl < _rl_screenwidth) 238 invfl = ninvis; 239 |
|
218 *r = '\0'; 219 if (lp) 220 *lp = rl; 221 if (lip) 222 *lip = last; | 240 *r = '\0'; 241 if (lp) 242 *lp = rl; 243 if (lip) 244 *lip = last; |
245 if (niflp) 246 *niflp = invfl; |
|
223 return ret; 224} 225 226/* Just strip out RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE from 227 PMT and return the rest of PMT. */ 228char * 229_rl_strip_prompt (pmt) 230 char *pmt; 231{ 232 char *ret; 233 | 247 return ret; 248} 249 250/* Just strip out RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE from 251 PMT and return the rest of PMT. */ 252char * 253_rl_strip_prompt (pmt) 254 char *pmt; 255{ 256 char *ret; 257 |
234 ret = expand_prompt (pmt, (int *)NULL, (int *)NULL); | 258 ret = expand_prompt (pmt, (int *)NULL, (int *)NULL, (int *)NULL); |
235 return ret; 236} 237 238/* 239 * Expand the prompt string into the various display components, if 240 * necessary. 241 * 242 * local_prompt = expanded last line of string in rl_display_prompt 243 * (portion after the final newline) 244 * local_prompt_prefix = portion before last newline of rl_display_prompt, 245 * expanded via expand_prompt | 259 return ret; 260} 261 262/* 263 * Expand the prompt string into the various display components, if 264 * necessary. 265 * 266 * local_prompt = expanded last line of string in rl_display_prompt 267 * (portion after the final newline) 268 * local_prompt_prefix = portion before last newline of rl_display_prompt, 269 * expanded via expand_prompt |
246 * visible_length = number of visible characters in local_prompt 247 * prefix_length = number of visible characters in local_prompt_prefix | 270 * prompt_visible_length = number of visible characters in local_prompt 271 * prompt_prefix_length = number of visible characters in local_prompt_prefix |
248 * 249 * This function is called once per call to readline(). It may also be 250 * called arbitrarily to expand the primary prompt. 251 * 252 * The return value is the number of visible characters on the last line 253 * of the (possibly multi-line) prompt. 254 */ 255int 256rl_expand_prompt (prompt) 257 char *prompt; 258{ 259 char *p, *t; 260 int c; 261 262 /* Clear out any saved values. */ | 272 * 273 * This function is called once per call to readline(). It may also be 274 * called arbitrarily to expand the primary prompt. 275 * 276 * The return value is the number of visible characters on the last line 277 * of the (possibly multi-line) prompt. 278 */ 279int 280rl_expand_prompt (prompt) 281 char *prompt; 282{ 283 char *p, *t; 284 int c; 285 286 /* Clear out any saved values. */ |
263 if (local_prompt) 264 free (local_prompt); 265 if (local_prompt_prefix) 266 free (local_prompt_prefix); | 287 FREE (local_prompt); 288 FREE (local_prompt_prefix); 289 |
267 local_prompt = local_prompt_prefix = (char *)0; | 290 local_prompt = local_prompt_prefix = (char *)0; |
268 last_invisible = visible_length = 0; | 291 prompt_last_invisible = prompt_visible_length = 0; |
269 270 if (prompt == 0 || *prompt == 0) 271 return (0); 272 273 p = strrchr (prompt, '\n'); 274 if (!p) 275 { | 292 293 if (prompt == 0 || *prompt == 0) 294 return (0); 295 296 p = strrchr (prompt, '\n'); 297 if (!p) 298 { |
276 /* The prompt is only one line. */ 277 local_prompt = expand_prompt (prompt, &visible_length, &last_invisible); | 299 /* The prompt is only one logical line, though it might wrap. */ 300 local_prompt = expand_prompt (prompt, &prompt_visible_length, 301 &prompt_last_invisible, 302 &prompt_invis_chars_first_line); |
278 local_prompt_prefix = (char *)0; | 303 local_prompt_prefix = (char *)0; |
279 return (visible_length); | 304 return (prompt_visible_length); |
280 } 281 else 282 { 283 /* The prompt spans multiple lines. */ 284 t = ++p; | 305 } 306 else 307 { 308 /* The prompt spans multiple lines. */ 309 t = ++p; |
285 local_prompt = expand_prompt (p, &visible_length, &last_invisible); | 310 local_prompt = expand_prompt (p, &prompt_visible_length, 311 &prompt_last_invisible, 312 &prompt_invis_chars_first_line); |
286 c = *t; *t = '\0'; 287 /* The portion of the prompt string up to and including the 288 final newline is now null-terminated. */ | 313 c = *t; *t = '\0'; 314 /* The portion of the prompt string up to and including the 315 final newline is now null-terminated. */ |
289 local_prompt_prefix = expand_prompt (prompt, &prefix_length, (int *)NULL); | 316 local_prompt_prefix = expand_prompt (prompt, &prompt_prefix_length, 317 (int *)NULL, 318 &prompt_invis_chars_first_line); |
290 *t = c; | 319 *t = c; |
291 return (prefix_length); | 320 return (prompt_prefix_length); |
292 } 293} 294 295/* Initialize the VISIBLE_LINE and INVISIBLE_LINE arrays, and their associated 296 arrays of line break markers. MINSIZE is the minimum size of VISIBLE_LINE 297 and INVISIBLE_LINE; if it is greater than LINE_SIZE, LINE_SIZE is 298 increased. If the lines have already been allocated, this ensures that 299 they can hold at least MINSIZE characters. */ --- 95 unchanged lines hidden (view full) --- 395 line_size = (temp + 1024) - (temp % 1024); 396 visible_line = xrealloc (visible_line, line_size); 397 line = invisible_line = xrealloc (invisible_line, line_size); 398 } 399 strncpy (line + out, local_prompt, local_len); 400 out += local_len; 401 } 402 line[out] = '\0'; | 321 } 322} 323 324/* Initialize the VISIBLE_LINE and INVISIBLE_LINE arrays, and their associated 325 arrays of line break markers. MINSIZE is the minimum size of VISIBLE_LINE 326 and INVISIBLE_LINE; if it is greater than LINE_SIZE, LINE_SIZE is 327 increased. If the lines have already been allocated, this ensures that 328 they can hold at least MINSIZE characters. */ --- 95 unchanged lines hidden (view full) --- 424 line_size = (temp + 1024) - (temp % 1024); 425 visible_line = xrealloc (visible_line, line_size); 426 line = invisible_line = xrealloc (invisible_line, line_size); 427 } 428 strncpy (line + out, local_prompt, local_len); 429 out += local_len; 430 } 431 line[out] = '\0'; |
403 wrap_offset = local_len - visible_length; | 432 wrap_offset = local_len - prompt_visible_length; |
404 } 405 else 406 { 407 int pmtlen; 408 prompt_this_line = strrchr (rl_display_prompt, '\n'); 409 if (!prompt_this_line) 410 prompt_this_line = rl_display_prompt; 411 else --- 16 unchanged lines hidden (view full) --- 428 { 429 line_size = (temp + 1024) - (temp % 1024); 430 visible_line = xrealloc (visible_line, line_size); 431 line = invisible_line = xrealloc (invisible_line, line_size); 432 } 433 strncpy (line + out, prompt_this_line, pmtlen); 434 out += pmtlen; 435 line[out] = '\0'; | 433 } 434 else 435 { 436 int pmtlen; 437 prompt_this_line = strrchr (rl_display_prompt, '\n'); 438 if (!prompt_this_line) 439 prompt_this_line = rl_display_prompt; 440 else --- 16 unchanged lines hidden (view full) --- 457 { 458 line_size = (temp + 1024) - (temp % 1024); 459 visible_line = xrealloc (visible_line, line_size); 460 line = invisible_line = xrealloc (invisible_line, line_size); 461 } 462 strncpy (line + out, prompt_this_line, pmtlen); 463 out += pmtlen; 464 line[out] = '\0'; |
436 wrap_offset = 0; | 465 wrap_offset = prompt_invis_chars_first_line = 0; |
437 } 438 439#define CHECK_INV_LBREAKS() \ 440 do { \ 441 if (newlines >= (inv_lbsize - 2)) \ 442 { \ 443 inv_lbsize *= 2; \ 444 inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \ 445 } \ 446 } while (0) 447 448#define CHECK_LPOS() \ 449 do { \ 450 lpos++; \ | 466 } 467 468#define CHECK_INV_LBREAKS() \ 469 do { \ 470 if (newlines >= (inv_lbsize - 2)) \ 471 { \ 472 inv_lbsize *= 2; \ 473 inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \ 474 } \ 475 } while (0) 476 477#define CHECK_LPOS() \ 478 do { \ 479 lpos++; \ |
451 if (lpos >= screenwidth) \ | 480 if (lpos >= _rl_screenwidth) \ |
452 { \ 453 if (newlines >= (inv_lbsize - 2)) \ 454 { \ 455 inv_lbsize *= 2; \ 456 inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \ 457 } \ 458 inv_lbreaks[++newlines] = out; \ 459 lpos = 0; \ 460 } \ 461 } while (0) 462 463 /* inv_lbreaks[i] is where line i starts in the buffer. */ 464 inv_lbreaks[newlines = 0] = 0; 465 lpos = out - wrap_offset; 466 | 481 { \ 482 if (newlines >= (inv_lbsize - 2)) \ 483 { \ 484 inv_lbsize *= 2; \ 485 inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \ 486 } \ 487 inv_lbreaks[++newlines] = out; \ 488 lpos = 0; \ 489 } \ 490 } while (0) 491 492 /* inv_lbreaks[i] is where line i starts in the buffer. */ 493 inv_lbreaks[newlines = 0] = 0; 494 lpos = out - wrap_offset; 495 |
467 /* XXX - what if lpos is already >= screenwidth before we start drawing the | 496 /* prompt_invis_chars_first_line is the number of invisible characters in 497 the first physical line of the prompt. 498 wrap_offset - prompt_invis_chars_first_line is the number of invis 499 chars on the second line. */ 500 501 /* what if lpos is already >= _rl_screenwidth before we start drawing the |
468 contents of the command line? */ | 502 contents of the command line? */ |
469 while (lpos >= screenwidth) | 503 while (lpos >= _rl_screenwidth) |
470 { | 504 { |
471 /* XXX - possible fix from Darin Johnson <darin@acuson.com> for prompt 472 string with invisible characters that is longer than the screen 473 width. XXX - this doesn't work right if invisible characters have 474 to be put on the second screen line -- it adds too much (the number 475 of invisible chars after the screenwidth). */ 476 temp = ((newlines + 1) * screenwidth) + ((newlines == 0) ? wrap_offset : 0); | 505 /* fix from Darin Johnson <darin@acuson.com> for prompt string with 506 invisible characters that is longer than the screen width. The 507 prompt_invis_chars_first_line variable could be made into an array 508 saying how many invisible characters there are per line, but that's 509 probably too much work for the benefit gained. How many people have 510 prompts that exceed two physical lines? */ 511 temp = ((newlines + 1) * _rl_screenwidth) + 512 ((newlines == 0) ? prompt_invis_chars_first_line : 0) + 513 ((newlines == 1) ? wrap_offset : 0); |
477 478 inv_lbreaks[++newlines] = temp; | 514 515 inv_lbreaks[++newlines] = temp; |
479 lpos -= screenwidth; | 516 lpos -= _rl_screenwidth; |
480 } 481 | 517 } 518 |
519 prompt_last_screen_line = newlines; 520 521 /* Draw the rest of the line (after the prompt) into invisible_line, keeping 522 track of where the cursor is (c_pos), the number of the line containing 523 the cursor (lb_linenum), the last line number (lb_botlin and inv_botlin). 524 It maintains an array of line breaks for display (inv_lbreaks). 525 This handles expanding tabs for display and displaying meta characters. */ |
|
482 lb_linenum = 0; 483 for (in = 0; in < rl_end; in++) 484 { 485 c = (unsigned char)rl_line_buffer[in]; 486 487 if (out + 8 >= line_size) /* XXX - 8 for \t */ 488 { 489 line_size *= 2; --- 9 unchanged lines hidden (view full) --- 499 } 500 501 if (META_CHAR (c)) 502 { 503 if (_rl_output_meta_chars == 0) 504 { 505 sprintf (line + out, "\\%o", c); 506 | 526 lb_linenum = 0; 527 for (in = 0; in < rl_end; in++) 528 { 529 c = (unsigned char)rl_line_buffer[in]; 530 531 if (out + 8 >= line_size) /* XXX - 8 for \t */ 532 { 533 line_size *= 2; --- 9 unchanged lines hidden (view full) --- 543 } 544 545 if (META_CHAR (c)) 546 { 547 if (_rl_output_meta_chars == 0) 548 { 549 sprintf (line + out, "\\%o", c); 550 |
507 if (lpos + 4 >= screenwidth) | 551 if (lpos + 4 >= _rl_screenwidth) |
508 { | 552 { |
509 temp = screenwidth - lpos; | 553 temp = _rl_screenwidth - lpos; |
510 CHECK_INV_LBREAKS (); 511 inv_lbreaks[++newlines] = out + temp; 512 lpos = 4 - temp; 513 } 514 else 515 lpos += 4; 516 517 out += 4; 518 } 519 else 520 { 521 line[out++] = c; 522 CHECK_LPOS(); 523 } 524 } 525#if defined (DISPLAY_TABS) 526 else if (c == '\t') 527 { | 554 CHECK_INV_LBREAKS (); 555 inv_lbreaks[++newlines] = out + temp; 556 lpos = 4 - temp; 557 } 558 else 559 lpos += 4; 560 561 out += 4; 562 } 563 else 564 { 565 line[out++] = c; 566 CHECK_LPOS(); 567 } 568 } 569#if defined (DISPLAY_TABS) 570 else if (c == '\t') 571 { |
528 register int temp, newout; | 572 register int newout; |
529 530#if 0 531 newout = (out | (int)7) + 1; 532#else 533 newout = out + 8 - lpos % 8; 534#endif 535 temp = newout - out; | 573 574#if 0 575 newout = (out | (int)7) + 1; 576#else 577 newout = out + 8 - lpos % 8; 578#endif 579 temp = newout - out; |
536 if (lpos + temp >= screenwidth) | 580 if (lpos + temp >= _rl_screenwidth) |
537 { 538 register int temp2; | 581 { 582 register int temp2; |
539 temp2 = screenwidth - lpos; | 583 temp2 = _rl_screenwidth - lpos; |
540 CHECK_INV_LBREAKS (); 541 inv_lbreaks[++newlines] = out + temp2; 542 lpos = temp - temp2; 543 while (out < newout) 544 line[out++] = ' '; 545 } 546 else 547 { 548 while (out < newout) 549 line[out++] = ' '; 550 lpos += temp; 551 } 552 } 553#endif | 584 CHECK_INV_LBREAKS (); 585 inv_lbreaks[++newlines] = out + temp2; 586 lpos = temp - temp2; 587 while (out < newout) 588 line[out++] = ' '; 589 } 590 else 591 { 592 while (out < newout) 593 line[out++] = ' '; 594 lpos += temp; 595 } 596 } 597#endif |
554 else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && term_up && *term_up) | 598 else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up) |
555 { 556 line[out++] = '\0'; /* XXX - sentinel */ 557 CHECK_INV_LBREAKS (); 558 inv_lbreaks[++newlines] = out; 559 lpos = 0; 560 } 561 else if (CTRL_CHAR (c) || c == RUBOUT) 562 { --- 15 unchanged lines hidden (view full) --- 578 lb_linenum = newlines; 579 } 580 581 inv_botlin = lb_botlin = newlines; 582 CHECK_INV_LBREAKS (); 583 inv_lbreaks[newlines+1] = out; 584 cursor_linenum = lb_linenum; 585 | 599 { 600 line[out++] = '\0'; /* XXX - sentinel */ 601 CHECK_INV_LBREAKS (); 602 inv_lbreaks[++newlines] = out; 603 lpos = 0; 604 } 605 else if (CTRL_CHAR (c) || c == RUBOUT) 606 { --- 15 unchanged lines hidden (view full) --- 622 lb_linenum = newlines; 623 } 624 625 inv_botlin = lb_botlin = newlines; 626 CHECK_INV_LBREAKS (); 627 inv_lbreaks[newlines+1] = out; 628 cursor_linenum = lb_linenum; 629 |
586 /* C_POS == position in buffer where cursor should be placed. */ | 630 /* C_POS == position in buffer where cursor should be placed. 631 CURSOR_LINENUM == line number where the cursor should be placed. */ |
587 588 /* PWP: now is when things get a bit hairy. The visible and invisible 589 line buffers are really multiple lines, which would wrap every 590 (screenwidth - 1) characters. Go through each in turn, finding 591 the changed region and updating it. The line order is top to bottom. */ 592 593 /* If we can move the cursor up and down, then use multiple lines, 594 otherwise, let long lines display in a single terminal line, and 595 horizontally scroll it. */ 596 | 632 633 /* PWP: now is when things get a bit hairy. The visible and invisible 634 line buffers are really multiple lines, which would wrap every 635 (screenwidth - 1) characters. Go through each in turn, finding 636 the changed region and updating it. The line order is top to bottom. */ 637 638 /* If we can move the cursor up and down, then use multiple lines, 639 otherwise, let long lines display in a single terminal line, and 640 horizontally scroll it. */ 641 |
597 if (_rl_horizontal_scroll_mode == 0 && term_up && *term_up) | 642 if (_rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up) |
598 { 599 int nleft, pos, changed_screen_line; 600 601 if (!rl_display_fixed || forced_display) 602 { 603 forced_display = 0; 604 605 /* If we have more than a screenful of material to display, then 606 only display a screenful. We should display the last screen, 607 not the first. */ | 643 { 644 int nleft, pos, changed_screen_line; 645 646 if (!rl_display_fixed || forced_display) 647 { 648 forced_display = 0; 649 650 /* If we have more than a screenful of material to display, then 651 only display a screenful. We should display the last screen, 652 not the first. */ |
608 if (out >= screenchars) 609 out = screenchars - 1; | 653 if (out >= _rl_screenchars) 654 out = _rl_screenchars - 1; |
610 611 /* The first line is at character position 0 in the buffer. The 612 second and subsequent lines start at inv_lbreaks[N], offset by 613 OFFSET (which has already been calculated above). */ 614 615#define W_OFFSET(line, offset) ((line) == 0 ? offset : 0) 616#define VIS_LLEN(l) ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l])) 617#define INV_LLEN(l) (inv_lbreaks[l+1] - inv_lbreaks[l]) --- 13 unchanged lines hidden (view full) --- 631 implies that we completely overwrite the old visible line) 632 and the new line is shorter than the old. Make sure we are 633 at the end of the new line before clearing. */ 634 if (linenum == 0 && 635 inv_botlin == 0 && _rl_last_c_pos == out && 636 (wrap_offset > visible_wrap_offset) && 637 (_rl_last_c_pos < visible_first_line_len)) 638 { | 655 656 /* The first line is at character position 0 in the buffer. The 657 second and subsequent lines start at inv_lbreaks[N], offset by 658 OFFSET (which has already been calculated above). */ 659 660#define W_OFFSET(line, offset) ((line) == 0 ? offset : 0) 661#define VIS_LLEN(l) ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l])) 662#define INV_LLEN(l) (inv_lbreaks[l+1] - inv_lbreaks[l]) --- 13 unchanged lines hidden (view full) --- 676 implies that we completely overwrite the old visible line) 677 and the new line is shorter than the old. Make sure we are 678 at the end of the new line before clearing. */ 679 if (linenum == 0 && 680 inv_botlin == 0 && _rl_last_c_pos == out && 681 (wrap_offset > visible_wrap_offset) && 682 (_rl_last_c_pos < visible_first_line_len)) 683 { |
639 nleft = screenwidth + wrap_offset - _rl_last_c_pos; | 684 nleft = _rl_screenwidth + wrap_offset - _rl_last_c_pos; |
640 if (nleft) 641 _rl_clear_to_eol (nleft); 642 } 643 644 /* Since the new first line is now visible, save its length. */ 645 if (linenum == 0) 646 visible_first_line_len = (inv_botlin > 0) ? inv_lbreaks[1] : out - wrap_offset; 647 } --- 4 unchanged lines hidden (view full) --- 652 { 653 char *tt; 654 for (; linenum <= _rl_vis_botlin; linenum++) 655 { 656 tt = VIS_CHARS (linenum); 657 _rl_move_vert (linenum); 658 _rl_move_cursor_relative (0, tt); 659 _rl_clear_to_eol | 685 if (nleft) 686 _rl_clear_to_eol (nleft); 687 } 688 689 /* Since the new first line is now visible, save its length. */ 690 if (linenum == 0) 691 visible_first_line_len = (inv_botlin > 0) ? inv_lbreaks[1] : out - wrap_offset; 692 } --- 4 unchanged lines hidden (view full) --- 697 { 698 char *tt; 699 for (; linenum <= _rl_vis_botlin; linenum++) 700 { 701 tt = VIS_CHARS (linenum); 702 _rl_move_vert (linenum); 703 _rl_move_cursor_relative (0, tt); 704 _rl_clear_to_eol |
660 ((linenum == _rl_vis_botlin) ? strlen (tt) : screenwidth); | 705 ((linenum == _rl_vis_botlin) ? strlen (tt) : _rl_screenwidth); |
661 } 662 } 663 _rl_vis_botlin = inv_botlin; 664 665 /* CHANGED_SCREEN_LINE is set to 1 if we have moved to a 666 different screen line during this redisplay. */ 667 changed_screen_line = _rl_last_v_pos != cursor_linenum; 668 if (changed_screen_line) 669 { 670 _rl_move_vert (cursor_linenum); | 706 } 707 } 708 _rl_vis_botlin = inv_botlin; 709 710 /* CHANGED_SCREEN_LINE is set to 1 if we have moved to a 711 different screen line during this redisplay. */ 712 changed_screen_line = _rl_last_v_pos != cursor_linenum; 713 if (changed_screen_line) 714 { 715 _rl_move_vert (cursor_linenum); |
671 /* If we moved up to the line with the prompt using term_up, | 716 /* If we moved up to the line with the prompt using _rl_term_up, |
672 the physical cursor position on the screen stays the same, 673 but the buffer position needs to be adjusted to account 674 for invisible characters. */ 675 if (cursor_linenum == 0 && wrap_offset) 676 _rl_last_c_pos += wrap_offset; 677 } 678 679 /* We have to reprint the prompt if it contains invisible 680 characters, since it's not generally OK to just reprint 681 the characters from the current cursor position. But we 682 only need to reprint it if the cursor is before the last 683 invisible character in the prompt string. */ | 717 the physical cursor position on the screen stays the same, 718 but the buffer position needs to be adjusted to account 719 for invisible characters. */ 720 if (cursor_linenum == 0 && wrap_offset) 721 _rl_last_c_pos += wrap_offset; 722 } 723 724 /* We have to reprint the prompt if it contains invisible 725 characters, since it's not generally OK to just reprint 726 the characters from the current cursor position. But we 727 only need to reprint it if the cursor is before the last 728 invisible character in the prompt string. */ |
684 nleft = visible_length + wrap_offset; | 729 nleft = prompt_visible_length + wrap_offset; |
685 if (cursor_linenum == 0 && wrap_offset > 0 && _rl_last_c_pos > 0 && | 730 if (cursor_linenum == 0 && wrap_offset > 0 && _rl_last_c_pos > 0 && |
686 _rl_last_c_pos <= last_invisible && local_prompt) | 731 _rl_last_c_pos <= prompt_last_invisible && local_prompt) |
687 { 688#if defined (__MSDOS__) 689 putc ('\r', rl_outstream); 690#else | 732 { 733#if defined (__MSDOS__) 734 putc ('\r', rl_outstream); 735#else |
691 if (term_cr) 692 tputs (term_cr, 1, _rl_output_character_function); | 736 if (_rl_term_cr) 737 tputs (_rl_term_cr, 1, _rl_output_character_function); |
693#endif 694 _rl_output_some_chars (local_prompt, nleft); 695 _rl_last_c_pos = nleft; 696 } 697 698 /* Where on that line? And where does that line start 699 in the buffer? */ 700 pos = inv_lbreaks[cursor_linenum]; --- 22 unchanged lines hidden (view full) --- 723 /* Always at top line. */ 724 _rl_last_v_pos = 0; 725 726 /* Compute where in the buffer the displayed line should start. This 727 will be LMARGIN. */ 728 729 /* The number of characters that will be displayed before the cursor. */ 730 ndisp = c_pos - wrap_offset; | 738#endif 739 _rl_output_some_chars (local_prompt, nleft); 740 _rl_last_c_pos = nleft; 741 } 742 743 /* Where on that line? And where does that line start 744 in the buffer? */ 745 pos = inv_lbreaks[cursor_linenum]; --- 22 unchanged lines hidden (view full) --- 768 /* Always at top line. */ 769 _rl_last_v_pos = 0; 770 771 /* Compute where in the buffer the displayed line should start. This 772 will be LMARGIN. */ 773 774 /* The number of characters that will be displayed before the cursor. */ 775 ndisp = c_pos - wrap_offset; |
731 nleft = visible_length + wrap_offset; | 776 nleft = prompt_visible_length + wrap_offset; |
732 /* Where the new cursor position will be on the screen. This can be 733 longer than SCREENWIDTH; if it is, lmargin will be adjusted. */ 734 phys_c_pos = c_pos - (last_lmargin ? last_lmargin : wrap_offset); | 777 /* Where the new cursor position will be on the screen. This can be 778 longer than SCREENWIDTH; if it is, lmargin will be adjusted. */ 779 phys_c_pos = c_pos - (last_lmargin ? last_lmargin : wrap_offset); |
735 t = screenwidth / 3; | 780 t = _rl_screenwidth / 3; |
736 737 /* If the number of characters had already exceeded the screenwidth, 738 last_lmargin will be > 0. */ 739 740 /* If the number of characters to be displayed is more than the screen 741 width, compute the starting offset so that the cursor is about 742 two-thirds of the way across the screen. */ | 781 782 /* If the number of characters had already exceeded the screenwidth, 783 last_lmargin will be > 0. */ 784 785 /* If the number of characters to be displayed is more than the screen 786 width, compute the starting offset so that the cursor is about 787 two-thirds of the way across the screen. */ |
743 if (phys_c_pos > screenwidth - 2) | 788 if (phys_c_pos > _rl_screenwidth - 2) |
744 { 745 lmargin = c_pos - (2 * t); 746 if (lmargin < 0) 747 lmargin = 0; 748 /* If the left margin would be in the middle of a prompt with 749 invisible characters, don't display the prompt at all. */ 750 if (wrap_offset && lmargin > 0 && lmargin < nleft) 751 lmargin = nleft; 752 } | 789 { 790 lmargin = c_pos - (2 * t); 791 if (lmargin < 0) 792 lmargin = 0; 793 /* If the left margin would be in the middle of a prompt with 794 invisible characters, don't display the prompt at all. */ 795 if (wrap_offset && lmargin > 0 && lmargin < nleft) 796 lmargin = nleft; 797 } |
753 else if (ndisp < screenwidth - 2) /* XXX - was -1 */ | 798 else if (ndisp < _rl_screenwidth - 2) /* XXX - was -1 */ |
754 lmargin = 0; 755 else if (phys_c_pos < 1) 756 { 757 /* If we are moving back towards the beginning of the line and 758 the last margin is no longer correct, compute a new one. */ 759 lmargin = ((c_pos - 1) / t) * t; /* XXX */ 760 if (wrap_offset && lmargin > 0 && lmargin < nleft) 761 lmargin = nleft; --- 5 unchanged lines hidden (view full) --- 767 in the display line, indicate this with a special character. */ 768 if (lmargin > 0) 769 line[lmargin] = '<'; 770 771 /* If SCREENWIDTH characters starting at LMARGIN do not encompass 772 the whole line, indicate that with a special character at the 773 right edge of the screen. If LMARGIN is 0, we need to take the 774 wrap offset into account. */ | 799 lmargin = 0; 800 else if (phys_c_pos < 1) 801 { 802 /* If we are moving back towards the beginning of the line and 803 the last margin is no longer correct, compute a new one. */ 804 lmargin = ((c_pos - 1) / t) * t; /* XXX */ 805 if (wrap_offset && lmargin > 0 && lmargin < nleft) 806 lmargin = nleft; --- 5 unchanged lines hidden (view full) --- 812 in the display line, indicate this with a special character. */ 813 if (lmargin > 0) 814 line[lmargin] = '<'; 815 816 /* If SCREENWIDTH characters starting at LMARGIN do not encompass 817 the whole line, indicate that with a special character at the 818 right edge of the screen. If LMARGIN is 0, we need to take the 819 wrap offset into account. */ |
775 t = lmargin + M_OFFSET (lmargin, wrap_offset) + screenwidth; | 820 t = lmargin + M_OFFSET (lmargin, wrap_offset) + _rl_screenwidth; |
776 if (t < out) 777 line[t - 1] = '>'; 778 779 if (!rl_display_fixed || forced_display || lmargin != last_lmargin) 780 { 781 forced_display = 0; 782 update_line (&visible_line[last_lmargin], 783 &invisible_line[lmargin], 784 0, | 821 if (t < out) 822 line[t - 1] = '>'; 823 824 if (!rl_display_fixed || forced_display || lmargin != last_lmargin) 825 { 826 forced_display = 0; 827 update_line (&visible_line[last_lmargin], 828 &invisible_line[lmargin], 829 0, |
785 screenwidth + visible_wrap_offset, 786 screenwidth + (lmargin ? 0 : wrap_offset), | 830 _rl_screenwidth + visible_wrap_offset, 831 _rl_screenwidth + (lmargin ? 0 : wrap_offset), |
787 0); 788 789 /* If the visible new line is shorter than the old, but the number 790 of invisible characters is greater, and we are at the end of 791 the new line, we need to clear to eol. */ 792 t = _rl_last_c_pos - M_OFFSET (lmargin, wrap_offset); 793 if ((M_OFFSET (lmargin, wrap_offset) > visible_wrap_offset) && 794 (_rl_last_c_pos == out) && 795 t < visible_first_line_len) 796 { | 832 0); 833 834 /* If the visible new line is shorter than the old, but the number 835 of invisible characters is greater, and we are at the end of 836 the new line, we need to clear to eol. */ 837 t = _rl_last_c_pos - M_OFFSET (lmargin, wrap_offset); 838 if ((M_OFFSET (lmargin, wrap_offset) > visible_wrap_offset) && 839 (_rl_last_c_pos == out) && 840 t < visible_first_line_len) 841 { |
797 nleft = screenwidth - t; | 842 nleft = _rl_screenwidth - t; |
798 _rl_clear_to_eol (nleft); 799 } 800 visible_first_line_len = out - lmargin - M_OFFSET (lmargin, wrap_offset); | 843 _rl_clear_to_eol (nleft); 844 } 845 visible_first_line_len = out - lmargin - M_OFFSET (lmargin, wrap_offset); |
801 if (visible_first_line_len > screenwidth) 802 visible_first_line_len = screenwidth; | 846 if (visible_first_line_len > _rl_screenwidth) 847 visible_first_line_len = _rl_screenwidth; |
803 804 _rl_move_cursor_relative (c_pos - lmargin, &invisible_line[lmargin]); 805 last_lmargin = lmargin; 806 } 807 } 808 fflush (rl_outstream); 809 810 /* Swap visible and non-visible lines. */ 811 { | 848 849 _rl_move_cursor_relative (c_pos - lmargin, &invisible_line[lmargin]); 850 last_lmargin = lmargin; 851 } 852 } 853 fflush (rl_outstream); 854 855 /* Swap visible and non-visible lines. */ 856 { |
812 char *temp = visible_line; | 857 char *vtemp = visible_line; |
813 int *itemp = vis_lbreaks, ntemp = vis_lbsize; 814 815 visible_line = invisible_line; | 858 int *itemp = vis_lbreaks, ntemp = vis_lbsize; 859 860 visible_line = invisible_line; |
816 invisible_line = temp; | 861 invisible_line = vtemp; |
817 818 vis_lbreaks = inv_lbreaks; 819 inv_lbreaks = itemp; 820 821 vis_lbsize = inv_lbsize; 822 inv_lbsize = ntemp; 823 824 rl_display_fixed = 0; --- 33 unchanged lines hidden (view full) --- 858 int current_invis_chars; 859 860 /* If we're at the right edge of a terminal that supports xn, we're 861 ready to wrap around, so do so. This fixes problems with knowing 862 the exact cursor position and cut-and-paste with certain terminal 863 emulators. In this calculation, TEMP is the physical screen 864 position of the cursor. */ 865 temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset); | 862 863 vis_lbreaks = inv_lbreaks; 864 inv_lbreaks = itemp; 865 866 vis_lbsize = inv_lbsize; 867 inv_lbsize = ntemp; 868 869 rl_display_fixed = 0; --- 33 unchanged lines hidden (view full) --- 903 int current_invis_chars; 904 905 /* If we're at the right edge of a terminal that supports xn, we're 906 ready to wrap around, so do so. This fixes problems with knowing 907 the exact cursor position and cut-and-paste with certain terminal 908 emulators. In this calculation, TEMP is the physical screen 909 position of the cursor. */ 910 temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset); |
866 if (temp == screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode | 911 if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode |
867 && _rl_last_v_pos == current_line - 1) 868 { 869 if (new[0]) 870 putc (new[0], rl_outstream); 871 else 872 putc (' ', rl_outstream); 873 _rl_last_c_pos = 1; /* XXX */ 874 _rl_last_v_pos++; --- 60 unchanged lines hidden (view full) --- 935 This is not an efficiency hack -- there is a problem with redrawing 936 portions of the prompt string if they contain terminal escape 937 sequences (like drawing the `unbold' sequence without a corresponding 938 `bold') that manifests itself on certain terminals. */ 939 940 lendiff = local_prompt ? strlen (local_prompt) : 0; 941 od = ofd - old; /* index of first difference in visible line */ 942 if (current_line == 0 && !_rl_horizontal_scroll_mode && | 912 && _rl_last_v_pos == current_line - 1) 913 { 914 if (new[0]) 915 putc (new[0], rl_outstream); 916 else 917 putc (' ', rl_outstream); 918 _rl_last_c_pos = 1; /* XXX */ 919 _rl_last_v_pos++; --- 60 unchanged lines hidden (view full) --- 980 This is not an efficiency hack -- there is a problem with redrawing 981 portions of the prompt string if they contain terminal escape 982 sequences (like drawing the `unbold' sequence without a corresponding 983 `bold') that manifests itself on certain terminals. */ 984 985 lendiff = local_prompt ? strlen (local_prompt) : 0; 986 od = ofd - old; /* index of first difference in visible line */ 987 if (current_line == 0 && !_rl_horizontal_scroll_mode && |
943 term_cr && lendiff > visible_length && _rl_last_c_pos > 0 && 944 od > lendiff && _rl_last_c_pos < last_invisible) | 988 _rl_term_cr && lendiff > prompt_visible_length && _rl_last_c_pos > 0 && 989 od >= lendiff && _rl_last_c_pos <= prompt_last_invisible) |
945 { 946#if defined (__MSDOS__) 947 putc ('\r', rl_outstream); 948#else | 990 { 991#if defined (__MSDOS__) 992 putc ('\r', rl_outstream); 993#else |
949 tputs (term_cr, 1, _rl_output_character_function); | 994 tputs (_rl_term_cr, 1, _rl_output_character_function); |
950#endif 951 _rl_output_some_chars (local_prompt, lendiff); 952 _rl_last_c_pos = lendiff; 953 } 954 955 _rl_move_cursor_relative (od, old); 956 957 /* if (len (new) > len (old)) */ --- 11 unchanged lines hidden (view full) --- 969 if (lendiff > 0) 970 { 971 /* Non-zero if we're increasing the number of lines. */ 972 int gl = current_line >= _rl_vis_botlin && inv_botlin > _rl_vis_botlin; 973 /* Sometimes it is cheaper to print the characters rather than 974 use the terminal's capabilities. If we're growing the number 975 of lines, make sure we actually cause the new line to wrap 976 around on auto-wrapping terminals. */ | 995#endif 996 _rl_output_some_chars (local_prompt, lendiff); 997 _rl_last_c_pos = lendiff; 998 } 999 1000 _rl_move_cursor_relative (od, old); 1001 1002 /* if (len (new) > len (old)) */ --- 11 unchanged lines hidden (view full) --- 1014 if (lendiff > 0) 1015 { 1016 /* Non-zero if we're increasing the number of lines. */ 1017 int gl = current_line >= _rl_vis_botlin && inv_botlin > _rl_vis_botlin; 1018 /* Sometimes it is cheaper to print the characters rather than 1019 use the terminal's capabilities. If we're growing the number 1020 of lines, make sure we actually cause the new line to wrap 1021 around on auto-wrapping terminals. */ |
977 if (terminal_can_insert && ((2 * temp) >= lendiff || term_IC) && (!_rl_term_autowrap || !gl)) | 1022 if (_rl_terminal_can_insert && ((2 * temp) >= lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl)) |
978 { | 1023 { |
979 /* If lendiff > visible_length and _rl_last_c_pos == 0 and | 1024 /* If lendiff > prompt_visible_length and _rl_last_c_pos == 0 and |
980 _rl_horizontal_scroll_mode == 1, inserting the characters with | 1025 _rl_horizontal_scroll_mode == 1, inserting the characters with |
981 term_IC or term_ic will screw up the screen because of the | 1026 _rl_term_IC or _rl_term_ic will screw up the screen because of the |
982 invisible characters. We need to just draw them. */ 983 if (*ols && (!_rl_horizontal_scroll_mode || _rl_last_c_pos > 0 || | 1027 invisible characters. We need to just draw them. */ 1028 if (*ols && (!_rl_horizontal_scroll_mode || _rl_last_c_pos > 0 || |
984 lendiff <= visible_length || !current_invis_chars)) | 1029 lendiff <= prompt_visible_length || !current_invis_chars)) |
985 { 986 insert_some_chars (nfd, lendiff); 987 _rl_last_c_pos += lendiff; 988 } 989 else if (*ols == 0) 990 { 991 /* At the end of a line the characters do not have to 992 be "inserted". They can just be placed on the screen. */ --- 24 unchanged lines hidden (view full) --- 1017 /* cannot insert chars, write to EOL */ 1018 _rl_output_some_chars (nfd, temp); 1019 _rl_last_c_pos += temp; 1020 } 1021 } 1022 else /* Delete characters from line. */ 1023 { 1024 /* If possible and inexpensive to use terminal deletion, then do so. */ | 1030 { 1031 insert_some_chars (nfd, lendiff); 1032 _rl_last_c_pos += lendiff; 1033 } 1034 else if (*ols == 0) 1035 { 1036 /* At the end of a line the characters do not have to 1037 be "inserted". They can just be placed on the screen. */ --- 24 unchanged lines hidden (view full) --- 1062 /* cannot insert chars, write to EOL */ 1063 _rl_output_some_chars (nfd, temp); 1064 _rl_last_c_pos += temp; 1065 } 1066 } 1067 else /* Delete characters from line. */ 1068 { 1069 /* If possible and inexpensive to use terminal deletion, then do so. */ |
1025 if (term_dc && (2 * temp) >= -lendiff) | 1070 if (_rl_term_dc && (2 * temp) >= -lendiff) |
1026 { 1027 /* If all we're doing is erasing the invisible characters in the 1028 prompt string, don't bother. It screws up the assumptions 1029 about what's on the screen. */ 1030 if (_rl_horizontal_scroll_mode && _rl_last_c_pos == 0 && 1031 -lendiff == visible_wrap_offset) 1032 lendiff = 0; 1033 --- 68 unchanged lines hidden (view full) --- 1102 prompt_last_line = rl_prompt; 1103 1104 l = strlen (prompt_last_line); 1105 _rl_last_c_pos = l; 1106 1107 /* Dissect prompt_last_line into screen lines. Note that here we have 1108 to use the real screenwidth. Readline's notion of screenwidth might be 1109 one less, see terminal.c. */ | 1071 { 1072 /* If all we're doing is erasing the invisible characters in the 1073 prompt string, don't bother. It screws up the assumptions 1074 about what's on the screen. */ 1075 if (_rl_horizontal_scroll_mode && _rl_last_c_pos == 0 && 1076 -lendiff == visible_wrap_offset) 1077 lendiff = 0; 1078 --- 68 unchanged lines hidden (view full) --- 1147 prompt_last_line = rl_prompt; 1148 1149 l = strlen (prompt_last_line); 1150 _rl_last_c_pos = l; 1151 1152 /* Dissect prompt_last_line into screen lines. Note that here we have 1153 to use the real screenwidth. Readline's notion of screenwidth might be 1154 one less, see terminal.c. */ |
1110 real_screenwidth = screenwidth + (_rl_term_autowrap ? 0 : 1); | 1155 real_screenwidth = _rl_screenwidth + (_rl_term_autowrap ? 0 : 1); |
1111 _rl_last_v_pos = l / real_screenwidth; 1112 /* If the prompt length is a multiple of real_screenwidth, we don't know 1113 whether the cursor is at the end of the last line, or already at the 1114 beginning of the next line. Output a newline just to be safe. */ 1115 if (l > 0 && (l % real_screenwidth) == 0) 1116 _rl_output_some_chars ("\n", 1); 1117 last_lmargin = 0; 1118 --- 28 unchanged lines hidden (view full) --- 1147} 1148 1149/* Move the cursor from _rl_last_c_pos to NEW, which are buffer indices. 1150 DATA is the contents of the screen line of interest; i.e., where 1151 the movement is being done. */ 1152void 1153_rl_move_cursor_relative (new, data) 1154 int new; | 1156 _rl_last_v_pos = l / real_screenwidth; 1157 /* If the prompt length is a multiple of real_screenwidth, we don't know 1158 whether the cursor is at the end of the last line, or already at the 1159 beginning of the next line. Output a newline just to be safe. */ 1160 if (l > 0 && (l % real_screenwidth) == 0) 1161 _rl_output_some_chars ("\n", 1); 1162 last_lmargin = 0; 1163 --- 28 unchanged lines hidden (view full) --- 1192} 1193 1194/* Move the cursor from _rl_last_c_pos to NEW, which are buffer indices. 1195 DATA is the contents of the screen line of interest; i.e., where 1196 the movement is being done. */ 1197void 1198_rl_move_cursor_relative (new, data) 1199 int new; |
1155 char *data; | 1200 const char *data; |
1156{ 1157 register int i; 1158 1159 /* If we don't have to do anything, then return. */ 1160 if (_rl_last_c_pos == new) return; 1161 1162 /* It may be faster to output a CR, and then move forwards instead 1163 of moving backwards. */ 1164 /* i == current physical cursor position. */ 1165 i = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset); 1166 if (new == 0 || CR_FASTER (new, _rl_last_c_pos) || | 1201{ 1202 register int i; 1203 1204 /* If we don't have to do anything, then return. */ 1205 if (_rl_last_c_pos == new) return; 1206 1207 /* It may be faster to output a CR, and then move forwards instead 1208 of moving backwards. */ 1209 /* i == current physical cursor position. */ 1210 i = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset); 1211 if (new == 0 || CR_FASTER (new, _rl_last_c_pos) || |
1167 (_rl_term_autowrap && i == screenwidth)) | 1212 (_rl_term_autowrap && i == _rl_screenwidth)) |
1168 { 1169#if defined (__MSDOS__) 1170 putc ('\r', rl_outstream); 1171#else | 1213 { 1214#if defined (__MSDOS__) 1215 putc ('\r', rl_outstream); 1216#else |
1172 tputs (term_cr, 1, _rl_output_character_function); | 1217 tputs (_rl_term_cr, 1, _rl_output_character_function); |
1173#endif /* !__MSDOS__ */ 1174 _rl_last_c_pos = 0; 1175 } 1176 1177 if (_rl_last_c_pos < new) 1178 { 1179 /* Move the cursor forward. We do it by printing the command 1180 to move the cursor forward if there is one, else print that 1181 portion of the output buffer again. Which is cheaper? */ 1182 1183 /* The above comment is left here for posterity. It is faster 1184 to print one character (non-control) than to print a control 1185 sequence telling the terminal to move forward one character. 1186 That kind of control is for people who don't know what the 1187 data is underneath the cursor. */ 1188#if defined (HACK_TERMCAP_MOTION) | 1218#endif /* !__MSDOS__ */ 1219 _rl_last_c_pos = 0; 1220 } 1221 1222 if (_rl_last_c_pos < new) 1223 { 1224 /* Move the cursor forward. We do it by printing the command 1225 to move the cursor forward if there is one, else print that 1226 portion of the output buffer again. Which is cheaper? */ 1227 1228 /* The above comment is left here for posterity. It is faster 1229 to print one character (non-control) than to print a control 1230 sequence telling the terminal to move forward one character. 1231 That kind of control is for people who don't know what the 1232 data is underneath the cursor. */ 1233#if defined (HACK_TERMCAP_MOTION) |
1189 if (term_forward_char) | 1234 if (_rl_term_forward_char) |
1190 for (i = _rl_last_c_pos; i < new; i++) | 1235 for (i = _rl_last_c_pos; i < new; i++) |
1191 tputs (term_forward_char, 1, _rl_output_character_function); | 1236 tputs (_rl_term_forward_char, 1, _rl_output_character_function); |
1192 else 1193 for (i = _rl_last_c_pos; i < new; i++) 1194 putc (data[i], rl_outstream); 1195#else 1196 for (i = _rl_last_c_pos; i < new; i++) 1197 putc (data[i], rl_outstream); 1198#endif /* HACK_TERMCAP_MOTION */ 1199 } --- 4 unchanged lines hidden (view full) --- 1204 1205/* PWP: move the cursor up or down. */ 1206void 1207_rl_move_vert (to) 1208 int to; 1209{ 1210 register int delta, i; 1211 | 1237 else 1238 for (i = _rl_last_c_pos; i < new; i++) 1239 putc (data[i], rl_outstream); 1240#else 1241 for (i = _rl_last_c_pos; i < new; i++) 1242 putc (data[i], rl_outstream); 1243#endif /* HACK_TERMCAP_MOTION */ 1244 } --- 4 unchanged lines hidden (view full) --- 1249 1250/* PWP: move the cursor up or down. */ 1251void 1252_rl_move_vert (to) 1253 int to; 1254{ 1255 register int delta, i; 1256 |
1212 if (_rl_last_v_pos == to || to > screenheight) | 1257 if (_rl_last_v_pos == to || to > _rl_screenheight) |
1213 return; 1214 1215 if ((delta = to - _rl_last_v_pos) > 0) 1216 { 1217 for (i = 0; i < delta; i++) 1218 putc ('\n', rl_outstream); 1219#if defined (__MSDOS__) 1220 putc ('\r', rl_outstream); 1221#else | 1258 return; 1259 1260 if ((delta = to - _rl_last_v_pos) > 0) 1261 { 1262 for (i = 0; i < delta; i++) 1263 putc ('\n', rl_outstream); 1264#if defined (__MSDOS__) 1265 putc ('\r', rl_outstream); 1266#else |
1222 tputs (term_cr, 1, _rl_output_character_function); | 1267 tputs (_rl_term_cr, 1, _rl_output_character_function); |
1223#endif 1224 _rl_last_c_pos = 0; 1225 } 1226 else 1227 { /* delta < 0 */ | 1268#endif 1269 _rl_last_c_pos = 0; 1270 } 1271 else 1272 { /* delta < 0 */ |
1228 if (term_up && *term_up) | 1273 if (_rl_term_up && *_rl_term_up) |
1229 for (i = 0; i < -delta; i++) | 1274 for (i = 0; i < -delta; i++) |
1230 tputs (term_up, 1, _rl_output_character_function); | 1275 tputs (_rl_term_up, 1, _rl_output_character_function); |
1231 } 1232 1233 _rl_last_v_pos = to; /* Now TO is here */ 1234} 1235 1236/* Physically print C on rl_outstream. This is for functions which know 1237 how to optimize the display. Return the number of characters output. */ 1238int --- 117 unchanged lines hidden (view full) --- 1356static int saved_last_invisible; 1357static int saved_visible_length; 1358 1359void 1360rl_save_prompt () 1361{ 1362 saved_local_prompt = local_prompt; 1363 saved_local_prefix = local_prompt_prefix; | 1276 } 1277 1278 _rl_last_v_pos = to; /* Now TO is here */ 1279} 1280 1281/* Physically print C on rl_outstream. This is for functions which know 1282 how to optimize the display. Return the number of characters output. */ 1283int --- 117 unchanged lines hidden (view full) --- 1401static int saved_last_invisible; 1402static int saved_visible_length; 1403 1404void 1405rl_save_prompt () 1406{ 1407 saved_local_prompt = local_prompt; 1408 saved_local_prefix = local_prompt_prefix; |
1364 saved_last_invisible = last_invisible; 1365 saved_visible_length = visible_length; | 1409 saved_last_invisible = prompt_last_invisible; 1410 saved_visible_length = prompt_visible_length; |
1366 1367 local_prompt = local_prompt_prefix = (char *)0; | 1411 1412 local_prompt = local_prompt_prefix = (char *)0; |
1368 last_invisible = visible_length = 0; | 1413 prompt_last_invisible = prompt_visible_length = 0; |
1369} 1370 1371void 1372rl_restore_prompt () 1373{ | 1414} 1415 1416void 1417rl_restore_prompt () 1418{ |
1374 if (local_prompt) 1375 free (local_prompt); 1376 if (local_prompt_prefix) 1377 free (local_prompt_prefix); | 1419 FREE (local_prompt); 1420 FREE (local_prompt_prefix); |
1378 1379 local_prompt = saved_local_prompt; 1380 local_prompt_prefix = saved_local_prefix; | 1421 1422 local_prompt = saved_local_prompt; 1423 local_prompt_prefix = saved_local_prefix; |
1381 last_invisible = saved_last_invisible; 1382 visible_length = saved_visible_length; | 1424 prompt_last_invisible = saved_last_invisible; 1425 prompt_visible_length = saved_visible_length; |
1383} 1384 1385char * 1386_rl_make_prompt_for_search (pchar) 1387 int pchar; 1388{ 1389 int len; 1390 char *pmt; --- 13 unchanged lines hidden (view full) --- 1404 { 1405 len = *saved_local_prompt ? strlen (saved_local_prompt) : 0; 1406 pmt = xmalloc (len + 2); 1407 if (len) 1408 strcpy (pmt, saved_local_prompt); 1409 pmt[len] = pchar; 1410 pmt[len+1] = '\0'; 1411 local_prompt = savestring (pmt); | 1426} 1427 1428char * 1429_rl_make_prompt_for_search (pchar) 1430 int pchar; 1431{ 1432 int len; 1433 char *pmt; --- 13 unchanged lines hidden (view full) --- 1447 { 1448 len = *saved_local_prompt ? strlen (saved_local_prompt) : 0; 1449 pmt = xmalloc (len + 2); 1450 if (len) 1451 strcpy (pmt, saved_local_prompt); 1452 pmt[len] = pchar; 1453 pmt[len+1] = '\0'; 1454 local_prompt = savestring (pmt); |
1412 last_invisible = saved_last_invisible; 1413 visible_length = saved_visible_length + 1; | 1455 prompt_last_invisible = saved_last_invisible; 1456 prompt_visible_length = saved_visible_length + 1; |
1414 } 1415 return pmt; 1416} 1417 1418/* Quick redisplay hack when erasing characters at the end of the line. */ 1419void 1420_rl_erase_at_end_of_line (l) 1421 int l; --- 10 unchanged lines hidden (view full) --- 1432} 1433 1434/* Clear to the end of the line. COUNT is the minimum 1435 number of character spaces to clear, */ 1436void 1437_rl_clear_to_eol (count) 1438 int count; 1439{ | 1457 } 1458 return pmt; 1459} 1460 1461/* Quick redisplay hack when erasing characters at the end of the line. */ 1462void 1463_rl_erase_at_end_of_line (l) 1464 int l; --- 10 unchanged lines hidden (view full) --- 1475} 1476 1477/* Clear to the end of the line. COUNT is the minimum 1478 number of character spaces to clear, */ 1479void 1480_rl_clear_to_eol (count) 1481 int count; 1482{ |
1440 if (term_clreol) 1441 tputs (term_clreol, 1, _rl_output_character_function); | 1483 if (_rl_term_clreol) 1484 tputs (_rl_term_clreol, 1, _rl_output_character_function); |
1442 else if (count) 1443 space_to_eol (count); 1444} 1445 1446/* Clear to the end of the line using spaces. COUNT is the minimum 1447 number of character spaces to clear, */ 1448static void 1449space_to_eol (count) --- 5 unchanged lines hidden (view full) --- 1455 putc (' ', rl_outstream); 1456 1457 _rl_last_c_pos += count; 1458} 1459 1460void 1461_rl_clear_screen () 1462{ | 1485 else if (count) 1486 space_to_eol (count); 1487} 1488 1489/* Clear to the end of the line using spaces. COUNT is the minimum 1490 number of character spaces to clear, */ 1491static void 1492space_to_eol (count) --- 5 unchanged lines hidden (view full) --- 1498 putc (' ', rl_outstream); 1499 1500 _rl_last_c_pos += count; 1501} 1502 1503void 1504_rl_clear_screen () 1505{ |
1463 if (term_clrpag) 1464 tputs (term_clrpag, 1, _rl_output_character_function); | 1506 if (_rl_term_clrpag) 1507 tputs (_rl_term_clrpag, 1, _rl_output_character_function); |
1465 else | 1508 else |
1466 crlf (); | 1509 rl_crlf (); |
1467} 1468 1469/* Insert COUNT characters from STRING to the output stream. */ 1470static void 1471insert_some_chars (string, count) 1472 char *string; 1473 int count; 1474{ 1475 /* If IC is defined, then we do not have to "enter" insert mode. */ | 1510} 1511 1512/* Insert COUNT characters from STRING to the output stream. */ 1513static void 1514insert_some_chars (string, count) 1515 char *string; 1516 int count; 1517{ 1518 /* If IC is defined, then we do not have to "enter" insert mode. */ |
1476 if (term_IC) | 1519 if (_rl_term_IC) |
1477 { 1478 char *buffer; | 1520 { 1521 char *buffer; |
1479 buffer = tgoto (term_IC, 0, count); | 1522 buffer = tgoto (_rl_term_IC, 0, count); |
1480 tputs (buffer, 1, _rl_output_character_function); 1481 _rl_output_some_chars (string, count); 1482 } 1483 else 1484 { 1485 register int i; 1486 1487 /* If we have to turn on insert-mode, then do so. */ | 1523 tputs (buffer, 1, _rl_output_character_function); 1524 _rl_output_some_chars (string, count); 1525 } 1526 else 1527 { 1528 register int i; 1529 1530 /* If we have to turn on insert-mode, then do so. */ |
1488 if (term_im && *term_im) 1489 tputs (term_im, 1, _rl_output_character_function); | 1531 if (_rl_term_im && *_rl_term_im) 1532 tputs (_rl_term_im, 1, _rl_output_character_function); |
1490 1491 /* If there is a special command for inserting characters, then 1492 use that first to open up the space. */ | 1533 1534 /* If there is a special command for inserting characters, then 1535 use that first to open up the space. */ |
1493 if (term_ic && *term_ic) | 1536 if (_rl_term_ic && *_rl_term_ic) |
1494 { 1495 for (i = count; i--; ) | 1537 { 1538 for (i = count; i--; ) |
1496 tputs (term_ic, 1, _rl_output_character_function); | 1539 tputs (_rl_term_ic, 1, _rl_output_character_function); |
1497 } 1498 1499 /* Print the text. */ 1500 _rl_output_some_chars (string, count); 1501 1502 /* If there is a string to turn off insert mode, we had best use 1503 it now. */ | 1540 } 1541 1542 /* Print the text. */ 1543 _rl_output_some_chars (string, count); 1544 1545 /* If there is a string to turn off insert mode, we had best use 1546 it now. */ |
1504 if (term_ei && *term_ei) 1505 tputs (term_ei, 1, _rl_output_character_function); | 1547 if (_rl_term_ei && *_rl_term_ei) 1548 tputs (_rl_term_ei, 1, _rl_output_character_function); |
1506 } 1507} 1508 1509/* Delete COUNT characters from the display line. */ 1510static void 1511delete_chars (count) 1512 int count; 1513{ | 1549 } 1550} 1551 1552/* Delete COUNT characters from the display line. */ 1553static void 1554delete_chars (count) 1555 int count; 1556{ |
1514 if (count > screenwidth) /* XXX */ | 1557 if (count > _rl_screenwidth) /* XXX */ |
1515 return; 1516 | 1558 return; 1559 |
1517 if (term_DC && *term_DC) | 1560 if (_rl_term_DC && *_rl_term_DC) |
1518 { 1519 char *buffer; | 1561 { 1562 char *buffer; |
1520 buffer = tgoto (term_DC, count, count); | 1563 buffer = tgoto (_rl_term_DC, count, count); |
1521 tputs (buffer, count, _rl_output_character_function); 1522 } 1523 else 1524 { | 1564 tputs (buffer, count, _rl_output_character_function); 1565 } 1566 else 1567 { |
1525 if (term_dc && *term_dc) | 1568 if (_rl_term_dc && *_rl_term_dc) |
1526 while (count--) | 1569 while (count--) |
1527 tputs (term_dc, 1, _rl_output_character_function); | 1570 tputs (_rl_term_dc, 1, _rl_output_character_function); |
1528 } 1529} 1530 1531void 1532_rl_update_final () 1533{ 1534 int full_lines; 1535 1536 full_lines = 0; 1537 /* If the cursor is the only thing on an otherwise-blank last line, 1538 compensate so we don't print an extra CRLF. */ 1539 if (_rl_vis_botlin && _rl_last_c_pos == 0 && 1540 visible_line[vis_lbreaks[_rl_vis_botlin]] == 0) 1541 { 1542 _rl_vis_botlin--; 1543 full_lines = 1; 1544 } 1545 _rl_move_vert (_rl_vis_botlin); 1546 /* If we've wrapped lines, remove the final xterm line-wrap flag. */ | 1571 } 1572} 1573 1574void 1575_rl_update_final () 1576{ 1577 int full_lines; 1578 1579 full_lines = 0; 1580 /* If the cursor is the only thing on an otherwise-blank last line, 1581 compensate so we don't print an extra CRLF. */ 1582 if (_rl_vis_botlin && _rl_last_c_pos == 0 && 1583 visible_line[vis_lbreaks[_rl_vis_botlin]] == 0) 1584 { 1585 _rl_vis_botlin--; 1586 full_lines = 1; 1587 } 1588 _rl_move_vert (_rl_vis_botlin); 1589 /* If we've wrapped lines, remove the final xterm line-wrap flag. */ |
1547 if (full_lines && _rl_term_autowrap && (VIS_LLEN(_rl_vis_botlin) == screenwidth)) | 1590 if (full_lines && _rl_term_autowrap && (VIS_LLEN(_rl_vis_botlin) == _rl_screenwidth)) |
1548 { 1549 char *last_line; 1550#if 0 1551 last_line = &visible_line[inv_lbreaks[_rl_vis_botlin]]; 1552#else 1553 last_line = &visible_line[vis_lbreaks[_rl_vis_botlin]]; 1554#endif | 1591 { 1592 char *last_line; 1593#if 0 1594 last_line = &visible_line[inv_lbreaks[_rl_vis_botlin]]; 1595#else 1596 last_line = &visible_line[vis_lbreaks[_rl_vis_botlin]]; 1597#endif |
1555 _rl_move_cursor_relative (screenwidth - 1, last_line); | 1598 _rl_move_cursor_relative (_rl_screenwidth - 1, last_line); |
1556 _rl_clear_to_eol (0); | 1599 _rl_clear_to_eol (0); |
1557 putc (last_line[screenwidth - 1], rl_outstream); | 1600 putc (last_line[_rl_screenwidth - 1], rl_outstream); |
1558 } 1559 _rl_vis_botlin = 0; | 1601 } 1602 _rl_vis_botlin = 0; |
1560 crlf (); | 1603 rl_crlf (); |
1561 fflush (rl_outstream); 1562 rl_display_fixed++; 1563} 1564 1565/* Move to the start of the current line. */ 1566static void 1567cr () 1568{ | 1604 fflush (rl_outstream); 1605 rl_display_fixed++; 1606} 1607 1608/* Move to the start of the current line. */ 1609static void 1610cr () 1611{ |
1569 if (term_cr) | 1612 if (_rl_term_cr) |
1570 { 1571#if defined (__MSDOS__) 1572 putc ('\r', rl_outstream); 1573#else | 1613 { 1614#if defined (__MSDOS__) 1615 putc ('\r', rl_outstream); 1616#else |
1574 tputs (term_cr, 1, _rl_output_character_function); | 1617 tputs (_rl_term_cr, 1, _rl_output_character_function); |
1575#endif 1576 _rl_last_c_pos = 0; 1577 } 1578} 1579 1580/* Redraw the last line of a multi-line prompt that may possibly contain 1581 terminal escape sequences. Called with the cursor at column 0 of the 1582 line to draw the prompt on. */ 1583static void 1584redraw_prompt (t) 1585 char *t; 1586{ 1587 char *oldp, *oldl, *oldlprefix; | 1618#endif 1619 _rl_last_c_pos = 0; 1620 } 1621} 1622 1623/* Redraw the last line of a multi-line prompt that may possibly contain 1624 terminal escape sequences. Called with the cursor at column 0 of the 1625 line to draw the prompt on. */ 1626static void 1627redraw_prompt (t) 1628 char *t; 1629{ 1630 char *oldp, *oldl, *oldlprefix; |
1588 int oldlen, oldlast, oldplen; | 1631 int oldlen, oldlast, oldplen, oldninvis; |
1589 1590 /* Geez, I should make this a struct. */ 1591 oldp = rl_display_prompt; 1592 oldl = local_prompt; 1593 oldlprefix = local_prompt_prefix; | 1632 1633 /* Geez, I should make this a struct. */ 1634 oldp = rl_display_prompt; 1635 oldl = local_prompt; 1636 oldlprefix = local_prompt_prefix; |
1594 oldlen = visible_length; 1595 oldplen = prefix_length; 1596 oldlast = last_invisible; | 1637 oldlen = prompt_visible_length; 1638 oldplen = prompt_prefix_length; 1639 oldlast = prompt_last_invisible; 1640 oldninvis = prompt_invis_chars_first_line; |
1597 1598 rl_display_prompt = t; | 1641 1642 rl_display_prompt = t; |
1599 local_prompt = expand_prompt (t, &visible_length, &last_invisible); | 1643 local_prompt = expand_prompt (t, &prompt_visible_length, 1644 &prompt_last_invisible, 1645 &prompt_invis_chars_first_line); |
1600 local_prompt_prefix = (char *)NULL; 1601 rl_forced_update_display (); 1602 1603 rl_display_prompt = oldp; 1604 local_prompt = oldl; 1605 local_prompt_prefix = oldlprefix; | 1646 local_prompt_prefix = (char *)NULL; 1647 rl_forced_update_display (); 1648 1649 rl_display_prompt = oldp; 1650 local_prompt = oldl; 1651 local_prompt_prefix = oldlprefix; |
1606 visible_length = oldlen; 1607 prefix_length = oldplen; 1608 last_invisible = oldlast; | 1652 prompt_visible_length = oldlen; 1653 prompt_prefix_length = oldplen; 1654 prompt_last_invisible = oldlast; 1655 prompt_invis_chars_first_line = oldninvis; |
1609} 1610 1611/* Redisplay the current line after a SIGWINCH is received. */ 1612void 1613_rl_redisplay_after_sigwinch () 1614{ 1615 char *t; 1616 1617 /* Clear the current line and put the cursor at column 0. Make sure 1618 the right thing happens if we have wrapped to a new screen line. */ | 1656} 1657 1658/* Redisplay the current line after a SIGWINCH is received. */ 1659void 1660_rl_redisplay_after_sigwinch () 1661{ 1662 char *t; 1663 1664 /* Clear the current line and put the cursor at column 0. Make sure 1665 the right thing happens if we have wrapped to a new screen line. */ |
1619 if (term_cr) | 1666 if (_rl_term_cr) |
1620 { 1621#if defined (__MSDOS__) 1622 putc ('\r', rl_outstream); 1623#else | 1667 { 1668#if defined (__MSDOS__) 1669 putc ('\r', rl_outstream); 1670#else |
1624 tputs (term_cr, 1, _rl_output_character_function); | 1671 tputs (_rl_term_cr, 1, _rl_output_character_function); |
1625#endif 1626 _rl_last_c_pos = 0; 1627#if defined (__MSDOS__) | 1672#endif 1673 _rl_last_c_pos = 0; 1674#if defined (__MSDOS__) |
1628 space_to_eol (screenwidth); | 1675 space_to_eol (_rl_screenwidth); |
1629 putc ('\r', rl_outstream); 1630#else | 1676 putc ('\r', rl_outstream); 1677#else |
1631 if (term_clreol) 1632 tputs (term_clreol, 1, _rl_output_character_function); | 1678 if (_rl_term_clreol) 1679 tputs (_rl_term_clreol, 1, _rl_output_character_function); |
1633 else 1634 { | 1680 else 1681 { |
1635 space_to_eol (screenwidth); 1636 tputs (term_cr, 1, _rl_output_character_function); | 1682 space_to_eol (_rl_screenwidth); 1683 tputs (_rl_term_cr, 1, _rl_output_character_function); |
1637 } 1638#endif 1639 if (_rl_last_v_pos > 0) 1640 _rl_move_vert (0); 1641 } 1642 else | 1684 } 1685#endif 1686 if (_rl_last_v_pos > 0) 1687 _rl_move_vert (0); 1688 } 1689 else |
1643 crlf (); | 1690 rl_crlf (); |
1644 1645 /* Redraw only the last line of a multi-line prompt. */ 1646 t = strrchr (rl_display_prompt, '\n'); 1647 if (t) 1648 redraw_prompt (++t); 1649 else 1650 rl_forced_update_display (); 1651} --- 24 unchanged lines hidden (view full) --- 1676int 1677_rl_current_display_line () 1678{ 1679 int ret, nleft; 1680 1681 /* Find out whether or not there might be invisible characters in the 1682 editing buffer. */ 1683 if (rl_display_prompt == rl_prompt) | 1691 1692 /* Redraw only the last line of a multi-line prompt. */ 1693 t = strrchr (rl_display_prompt, '\n'); 1694 if (t) 1695 redraw_prompt (++t); 1696 else 1697 rl_forced_update_display (); 1698} --- 24 unchanged lines hidden (view full) --- 1723int 1724_rl_current_display_line () 1725{ 1726 int ret, nleft; 1727 1728 /* Find out whether or not there might be invisible characters in the 1729 editing buffer. */ 1730 if (rl_display_prompt == rl_prompt) |
1684 nleft = _rl_last_c_pos - screenwidth - rl_visible_prompt_length; | 1731 nleft = _rl_last_c_pos - _rl_screenwidth - rl_visible_prompt_length; |
1685 else | 1732 else |
1686 nleft = _rl_last_c_pos - screenwidth; | 1733 nleft = _rl_last_c_pos - _rl_screenwidth; |
1687 1688 if (nleft > 0) | 1734 1735 if (nleft > 0) |
1689 ret = 1 + nleft / screenwidth; | 1736 ret = 1 + nleft / _rl_screenwidth; |
1690 else 1691 ret = 0; 1692 1693 return ret; 1694} | 1737 else 1738 ret = 0; 1739 1740 return ret; 1741} |