?? display.c
字號:
if (*ols && (!_rl_horizontal_scroll_mode || _rl_last_c_pos > 0 || lendiff <= prompt_visible_length || !current_invis_chars)) { insert_some_chars (nfd, lendiff, col_lendiff); _rl_last_c_pos += col_lendiff; } else if (*ols == 0) { /* At the end of a line the characters do not have to be "inserted". They can just be placed on the screen. */ /* However, this screws up the rest of this block, which assumes you've done the insert because you can. */ _rl_output_some_chars (nfd, lendiff); _rl_last_c_pos += col_lendiff; } else { /* We have horizontal scrolling and we are not inserting at the end. We have invisible characters in this line. This is a dumb update. */ _rl_output_some_chars (nfd, temp); _rl_last_c_pos += col_temp; return; } /* Copy (new) chars to screen from first diff to last match. */ temp = nls - nfd; if ((temp - lendiff) > 0) { _rl_output_some_chars (nfd + lendiff, temp - lendiff);#if 0 _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-lendiff) - col_lendiff;#else _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);#endif } } else { /* cannot insert chars, write to EOL */ _rl_output_some_chars (nfd, temp); _rl_last_c_pos += col_temp; } } else /* Delete characters from line. */ { /* If possible and inexpensive to use terminal deletion, then do so. */ if (_rl_term_dc && (2 * col_temp) >= -col_lendiff) { /* If all we're doing is erasing the invisible characters in the prompt string, don't bother. It screws up the assumptions about what's on the screen. */ if (_rl_horizontal_scroll_mode && _rl_last_c_pos == 0 && -lendiff == visible_wrap_offset) col_lendiff = 0; if (col_lendiff) delete_chars (-col_lendiff); /* delete (diff) characters */ /* Copy (new) chars to screen from first diff to last match */ temp = nls - nfd; if (temp > 0) { _rl_output_some_chars (nfd, temp); _rl_last_c_pos += _rl_col_width (nfd, 0, temp);; } } /* Otherwise, print over the existing material. */ else { if (temp > 0) { _rl_output_some_chars (nfd, temp); _rl_last_c_pos += col_temp; } lendiff = (oe - old) - (ne - new); if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) col_lendiff = _rl_col_width (old, 0, oe - old) - _rl_col_width (new, 0, ne - new); else col_lendiff = lendiff; if (col_lendiff) { if (_rl_term_autowrap && current_line < inv_botlin) space_to_eol (col_lendiff); else _rl_clear_to_eol (col_lendiff); } } }}/* Tell the update routines that we have moved onto a new (empty) line. */intrl_on_new_line (){ if (visible_line) visible_line[0] = '\0'; _rl_last_c_pos = _rl_last_v_pos = 0; _rl_vis_botlin = last_lmargin = 0; if (vis_lbreaks) vis_lbreaks[0] = vis_lbreaks[1] = 0; visible_wrap_offset = 0; return 0;}/* Tell the update routines that we have moved onto a new line with the prompt already displayed. Code originally from the version of readline distributed with CLISP. */intrl_on_new_line_with_prompt (){ int prompt_size, i, l, real_screenwidth, newlines; char *prompt_last_line; /* Initialize visible_line and invisible_line to ensure that they can hold the already-displayed prompt. */ prompt_size = strlen (rl_prompt) + 1; init_line_structures (prompt_size); /* Make sure the line structures hold the already-displayed prompt for redisplay. */ strcpy (visible_line, rl_prompt); strcpy (invisible_line, rl_prompt); /* If the prompt contains newlines, take the last tail. */ prompt_last_line = strrchr (rl_prompt, '\n'); if (!prompt_last_line) prompt_last_line = rl_prompt; l = strlen (prompt_last_line); if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) _rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l); else _rl_last_c_pos = l; /* Dissect prompt_last_line into screen lines. Note that here we have to use the real screenwidth. Readline's notion of screenwidth might be one less, see terminal.c. */ real_screenwidth = _rl_screenwidth + (_rl_term_autowrap ? 0 : 1); _rl_last_v_pos = l / real_screenwidth; /* If the prompt length is a multiple of real_screenwidth, we don't know whether the cursor is at the end of the last line, or already at the beginning of the next line. Output a newline just to be safe. */ if (l > 0 && (l % real_screenwidth) == 0) _rl_output_some_chars ("\n", 1); last_lmargin = 0; newlines = 0; i = 0; while (i <= l) { _rl_vis_botlin = newlines; vis_lbreaks[newlines++] = i; i += real_screenwidth; } vis_lbreaks[newlines] = l; visible_wrap_offset = 0; return 0;}/* Actually update the display, period. */intrl_forced_update_display (){ if (visible_line) { register char *temp = visible_line; while (*temp) *temp++ = '\0'; } rl_on_new_line (); forced_display++; (*rl_redisplay_function) (); return 0;}/* Move the cursor from _rl_last_c_pos to NEW, which are buffer indices. DATA is the contents of the screen line of interest; i.e., where the movement is being done. */void_rl_move_cursor_relative (new, data) int new; const char *data;{ register int i; /* If we don't have to do anything, then return. */#if defined (HANDLE_MULTIBYTE) /* If we have multibyte characters, NEW is indexed by the buffer point in a multibyte string, but _rl_last_c_pos is the display position. In this case, NEW's display position is not obvious. */ if ((MB_CUR_MAX == 1 || rl_byte_oriented ) && _rl_last_c_pos == new) return;#else if (_rl_last_c_pos == new) return;#endif /* It may be faster to output a CR, and then move forwards instead of moving backwards. */ /* i == current physical cursor position. */ i = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset); if (new == 0 || CR_FASTER (new, _rl_last_c_pos) || (_rl_term_autowrap && i == _rl_screenwidth)) {#if defined (__MSDOS__) putc ('\r', rl_outstream);#else tputs (_rl_term_cr, 1, _rl_output_character_function);#endif /* !__MSDOS__ */ _rl_last_c_pos = 0; } if (_rl_last_c_pos < new) { /* Move the cursor forward. We do it by printing the command to move the cursor forward if there is one, else print that portion of the output buffer again. Which is cheaper? */ /* The above comment is left here for posterity. It is faster to print one character (non-control) than to print a control sequence telling the terminal to move forward one character. That kind of control is for people who don't know what the data is underneath the cursor. */#if defined (HACK_TERMCAP_MOTION) if (_rl_term_forward_char) { if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) { int width; width = _rl_col_width (data, _rl_last_c_pos, new); for (i = 0; i < width; i++) tputs (_rl_term_forward_char, 1, _rl_output_character_function); } else { for (i = _rl_last_c_pos; i < new; i++) tputs (_rl_term_forward_char, 1, _rl_output_character_function); } } else if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) { tputs (_rl_term_cr, 1, _rl_output_character_function); for (i = 0; i < new; i++) putc (data[i], rl_outstream); } else for (i = _rl_last_c_pos; i < new; i++) putc (data[i], rl_outstream);#else /* !HACK_TERMCAP_MOTION */ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) { tputs (_rl_term_cr, 1, _rl_output_character_function); for (i = 0; i < new; i++) putc (data[i], rl_outstream); } else for (i = _rl_last_c_pos; i < new; i++) putc (data[i], rl_outstream);#endif /* !HACK_TERMCAP_MOTION */ }#if defined (HANDLE_MULTIBYTE) /* NEW points to the buffer point, but _rl_last_c_pos is the display point. The byte length of the string is probably bigger than the column width of the string, which means that if NEW == _rl_last_c_pos, then NEW's display point is less than _rl_last_c_pos. */ else if (_rl_last_c_pos >= new)#else else if (_rl_last_c_pos > new)#endif { if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) { tputs (_rl_term_cr, 1, _rl_output_character_function); for (i = 0; i < new; i++) putc (data[i], rl_outstream); } else _rl_backspace (_rl_last_c_pos - new); } if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) _rl_last_c_pos = _rl_col_width (data, 0, new); else _rl_last_c_pos = new;}/* PWP: move the cursor up or down. */void_rl_move_vert (to) int to;{ register int delta, i; if (_rl_last_v_pos == to || to > _rl_screenheight) return; if ((delta = to - _rl_last_v_pos) > 0) { for (i = 0; i < delta; i++) putc ('\n', rl_outstream);#if defined (__MSDOS__) putc ('\r', rl_outstream);#else tputs (_rl_term_cr, 1, _rl_output_character_function);#endif _rl_last_c_pos = 0; } else { /* delta < 0 */ if (_rl_term_up && *_rl_term_up) for (i = 0; i < -delta; i++) tputs (_rl_term_up, 1, _rl_output_character_function); } _rl_last_v_pos = to; /* Now TO is here */}/* Physically print C on rl_outstream. This is for functions which know how to optimize the display. Return the number of characters output. */intrl_show_char (c) int c;{ int n = 1; if (META_CHAR (c) && (_rl_output_meta_chars == 0)) { fprintf (rl_outstream, "M-"); n += 2; c = UNMETA (c); }#if defined (DISPLAY_TABS) if ((CTRL_CHAR (c) && c != '\t') || c == RUBOUT)#else if (CTRL_CHAR (c) || c == RUBOUT)#endif /* !DISPLAY_TABS */ { fprintf (rl_outstream, "C-"); n += 2; c = CTRL_CHAR (c) ? UNCTRL (c) : '?'; } putc (c, rl_outstream); fflush (rl_outstream); return n;}intrl_character_len (c, pos) register int c, pos;{ unsigned char uc; uc = (unsigned char)c; if (META_CHAR (uc)) return ((_rl_output_meta_chars == 0) ? 4 : 1); if (uc == '\t') {#if defined (DISPLAY_TABS) return (((pos | 7) + 1) - pos);#else return (2);#endif /* !DISPLAY_TABS */ } if (CTRL_CHAR (c) || c == RUBOUT) return (2); return ((ISPRINT (uc)) ? 1 : 2);}/* How to print things in the "echo-area". The prompt is treated as a mini-modeline. */#if defined (USE_VARARGS)int#if defined (PREFER_STDARG)rl_message (const char *format, ...)#elserl_message (va_alist) va_dcl#endif{ va_list args;#if defined (PREFER_VARARGS) char *format;#endif#if defined (PREFER_STDARG) va_start (args, format);#else va_start (args); format = va_arg (args, char *);#endif#if defined (HAVE_VSNPRINTF) vsnprintf (msg_buf, sizeof (msg_buf) - 1, format, args);#else vsprintf (msg_buf, format, args); msg_buf[sizeof(msg_buf) - 1] = '\0'; /* overflow? */#endif va_end (args); rl_display_prompt = msg_buf; (*rl_redisplay_function) (); return 0;}#else /* !USE_VARARGS */intrl_message (format, arg1, arg2) char *format;{ sprintf (msg_buf, format, arg1, arg2); msg_buf[sizeof(msg_buf) - 1] = '\0'; /* overflow? */ rl_display_prompt = msg_buf; (*rl_redisplay_function) (); return 0;}#endif /* !USE_VARARGS *//* How to clear things from the "echo-area". */intrl_clear_message (){ rl_display_prompt = rl_prompt; (*rl_redisplay_function) (); return 0;}intrl_reset_line_state (){ rl_on_new_line ();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -