📄 display.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 vsprintf (msg_buf, format, args); 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); 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 (); rl_display_prompt = rl_prompt ? rl_prompt : ""; forced_display = 1; return 0;}static char *saved_local_prompt;static char *saved_local_prefix;static int saved_last_invisible;static int saved_visible_length;voidrl_save_prompt (){ saved_local_prompt = local_prompt; saved_local_prefix = local_prompt_prefix; saved_last_invisible = last_invisible; saved_visible_length = visible_length; local_prompt = local_prompt_prefix = (char *)0; last_invisible = visible_length = 0;}voidrl_restore_prompt (){ if (local_prompt) free (local_prompt); if (local_prompt_prefix) free (local_prompt_prefix); local_prompt = saved_local_prompt; local_prompt_prefix = saved_local_prefix; last_invisible = saved_last_invisible; visible_length = saved_visible_length;}char *_rl_make_prompt_for_search (pchar) int pchar;{ int len; char *pmt; rl_save_prompt (); if (saved_local_prompt == 0) { len = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0; pmt = xmalloc (len + 2); if (len) strcpy (pmt, rl_prompt); pmt[len] = pchar; pmt[len+1] = '\0'; } else { len = *saved_local_prompt ? strlen (saved_local_prompt) : 0; pmt = xmalloc (len + 2); if (len) strcpy (pmt, saved_local_prompt); pmt[len] = pchar; pmt[len+1] = '\0'; local_prompt = savestring (pmt); last_invisible = saved_last_invisible; visible_length = saved_visible_length + 1; } return pmt;}/* Quick redisplay hack when erasing characters at the end of the line. */void_rl_erase_at_end_of_line (l) int l;{ register int i; _rl_backspace (l); for (i = 0; i < l; i++) putc (' ', rl_outstream); _rl_backspace (l); for (i = 0; i < l; i++) visible_line[--_rl_last_c_pos] = '\0'; rl_display_fixed++;}/* Clear to the end of the line. COUNT is the minimum number of character spaces to clear, */void_rl_clear_to_eol (count) int count;{ if (term_clreol) tputs (term_clreol, 1, _rl_output_character_function); else if (count) space_to_eol (count);}/* Clear to the end of the line using spaces. COUNT is the minimum number of character spaces to clear, */static voidspace_to_eol (count) int count;{ register int i; for (i = 0; i < count; i++) putc (' ', rl_outstream); _rl_last_c_pos += count;}void_rl_clear_screen (){#ifdef __MSDOS__ ScreenClear (); /* FIXME: only works in text modes */ ScreenSetCursor (0, 0); /* term_clrpag is "cl" which homes the cursor */#else if (term_clrpag) tputs (term_clrpag, 1, _rl_output_character_function); else crlf ();#endif}/* Insert COUNT characters from STRING to the output stream. */static voidinsert_some_chars (string, count) char *string; int count;{ /* If IC is defined, then we do not have to "enter" insert mode. */ if (term_IC) { char *buffer; buffer = tgoto (term_IC, 0, count); tputs (buffer, 1, _rl_output_character_function); _rl_output_some_chars (string, count); } else { register int i; /* If we have to turn on insert-mode, then do so. */ if (term_im && *term_im) tputs (term_im, 1, _rl_output_character_function); /* If there is a special command for inserting characters, then use that first to open up the space. */ if (term_ic && *term_ic) { for (i = count; i--; ) tputs (term_ic, 1, _rl_output_character_function); } /* Print the text. */ _rl_output_some_chars (string, count); /* If there is a string to turn off insert mode, we had best use it now. */ if (term_ei && *term_ei) tputs (term_ei, 1, _rl_output_character_function); }}/* Delete COUNT characters from the display line. */static voiddelete_chars (count) int count;{ if (count > screenwidth) /* XXX */ return; if (term_DC && *term_DC) { char *buffer; buffer = tgoto (term_DC, count, count); tputs (buffer, count, _rl_output_character_function); } else { if (term_dc && *term_dc) while (count--) tputs (term_dc, 1, _rl_output_character_function); }}void_rl_update_final (){ int full_lines; full_lines = 0; /* If the cursor is the only thing on an otherwise-blank last line, compensate so we don't print an extra CRLF. */ if (_rl_vis_botlin && _rl_last_c_pos == 0 && visible_line[vis_lbreaks[_rl_vis_botlin]] == 0) { _rl_vis_botlin--; full_lines = 1; } _rl_move_vert (_rl_vis_botlin); /* If we've wrapped lines, remove the final xterm line-wrap flag. */ if (full_lines && _rl_term_autowrap && (VIS_LLEN(_rl_vis_botlin) == screenwidth)) { char *last_line;#if 0 last_line = &visible_line[inv_lbreaks[_rl_vis_botlin]];#else last_line = &visible_line[vis_lbreaks[_rl_vis_botlin]];#endif _rl_move_cursor_relative (screenwidth - 1, last_line); _rl_clear_to_eol (0); putc (last_line[screenwidth - 1], rl_outstream); } _rl_vis_botlin = 0; crlf (); fflush (rl_outstream); rl_display_fixed++;}/* Move to the start of the current line. */static voidcr (){ if (term_cr) {#if defined (__MSDOS__) putc ('\r', rl_outstream);#else tputs (term_cr, 1, _rl_output_character_function);#endif _rl_last_c_pos = 0; }}/* Redraw the last line of a multi-line prompt that may possibly contain terminal escape sequences. Called with the cursor at column 0 of the line to draw the prompt on. */static voidredraw_prompt (t) char *t;{ char *oldp, *oldl, *oldlprefix; int oldlen, oldlast, oldplen; /* Geez, I should make this a struct. */ oldp = rl_display_prompt; oldl = local_prompt; oldlprefix = local_prompt_prefix; oldlen = visible_length; oldplen = prefix_length; oldlast = last_invisible; rl_display_prompt = t; local_prompt = expand_prompt (t, &visible_length, &last_invisible); local_prompt_prefix = (char *)NULL; rl_forced_update_display (); rl_display_prompt = oldp; local_prompt = oldl; local_prompt_prefix = oldlprefix; visible_length = oldlen; prefix_length = oldplen; last_invisible = oldlast;} /* Redisplay the current line after a SIGWINCH is received. */void_rl_redisplay_after_sigwinch (){ char *t; /* Clear the current line and put the cursor at column 0. Make sure the right thing happens if we have wrapped to a new screen line. */ if (term_cr) {#if defined (__MSDOS__) putc ('\r', rl_outstream);#else tputs (term_cr, 1, _rl_output_character_function);#endif _rl_last_c_pos = 0;#if defined (__MSDOS__) space_to_eol (screenwidth); putc ('\r', rl_outstream);#else if (term_clreol) tputs (term_clreol, 1, _rl_output_character_function); else { space_to_eol (screenwidth); tputs (term_cr, 1, _rl_output_character_function); }#endif if (_rl_last_v_pos > 0) _rl_move_vert (0); } else crlf (); /* Redraw only the last line of a multi-line prompt. */ t = strrchr (rl_display_prompt, '\n'); if (t) redraw_prompt (++t); else rl_forced_update_display ();}void_rl_clean_up_for_exit (){ if (readline_echoing_p) { _rl_move_vert (_rl_vis_botlin); _rl_vis_botlin = 0; fflush (rl_outstream); rl_restart_output (1, 0); }}void_rl_erase_entire_line (){ cr (); _rl_clear_to_eol (0); cr (); fflush (rl_outstream);}/* return the `current display line' of the cursor -- the number of lines to move up to get to the first screen line of the current readline line. */int_rl_current_display_line (){ int ret, nleft; /* Find out whether or not there might be invisible characters in the editing buffer. */ if (rl_display_prompt == rl_prompt) nleft = _rl_last_c_pos - screenwidth - rl_visible_prompt_length; else nleft = _rl_last_c_pos - screenwidth; if (nleft > 0) ret = 1 + nleft / screenwidth; else ret = 0; return ret;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -