⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 display.c

📁 在非GUI环境下
💻 C
📖 第 1 页 / 共 5 页
字号:
/* 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;}/* These are getting numerous enough that it's time to create a struct. */static char *saved_local_prompt;static char *saved_local_prefix;static int saved_last_invisible;static int saved_visible_length;static int saved_invis_chars_first_line;static int saved_physical_chars;voidrl_save_prompt (){  saved_local_prompt = local_prompt;  saved_local_prefix = local_prompt_prefix;  saved_last_invisible = prompt_last_invisible;  saved_visible_length = prompt_visible_length;  saved_invis_chars_first_line = prompt_invis_chars_first_line;  saved_physical_chars = prompt_physical_chars;  local_prompt = local_prompt_prefix = (char *)0;  prompt_last_invisible = prompt_visible_length = 0;  prompt_invis_chars_first_line = prompt_physical_chars = 0;}voidrl_restore_prompt (){  FREE (local_prompt);  FREE (local_prompt_prefix);  local_prompt = saved_local_prompt;  local_prompt_prefix = saved_local_prefix;  prompt_last_invisible = saved_last_invisible;  prompt_visible_length = saved_visible_length;  prompt_invis_chars_first_line = saved_invis_chars_first_line;  prompt_physical_chars = saved_physical_chars;}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 = (char *)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 = (char *)xmalloc (len + 2);      if (len)	strcpy (pmt, saved_local_prompt);      pmt[len] = pchar;      pmt[len+1] = '\0';      local_prompt = savestring (pmt);      prompt_last_invisible = saved_last_invisible;      prompt_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 (_rl_term_clreol)    tputs (_rl_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 (){  if (_rl_term_clrpag)    tputs (_rl_term_clrpag, 1, _rl_output_character_function);  else    rl_crlf ();}/* Insert COUNT characters from STRING to the output stream at column COL. */static voidinsert_some_chars (string, count, col)     char *string;     int count, col;{  /* DEBUGGING */  if (MB_CUR_MAX == 1 || rl_byte_oriented)    if (count != col)      fprintf(stderr, "readline: debug: insert_some_chars: count (%d) != col (%d)\n", count, col);  /* If IC is defined, then we do not have to "enter" insert mode. */  if (_rl_term_IC)    {      char *buffer;      buffer = tgoto (_rl_term_IC, 0, col);      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 (_rl_term_im && *_rl_term_im)	tputs (_rl_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 (_rl_term_ic && *_rl_term_ic)	{	  for (i = col; i--; )	    tputs (_rl_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 (_rl_term_ei && *_rl_term_ei)	tputs (_rl_term_ei, 1, _rl_output_character_function);    }}/* Delete COUNT characters from the display line. */static voiddelete_chars (count)     int count;{  if (count > _rl_screenwidth)	/* XXX */    return;  if (_rl_term_DC && *_rl_term_DC)    {      char *buffer;      buffer = tgoto (_rl_term_DC, count, count);      tputs (buffer, count, _rl_output_character_function);    }  else    {      if (_rl_term_dc && *_rl_term_dc)	while (count--)	  tputs (_rl_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) == _rl_screenwidth))    {      char *last_line;      last_line = &visible_line[vis_lbreaks[_rl_vis_botlin]];      _rl_move_cursor_relative (_rl_screenwidth - 1, last_line);      _rl_clear_to_eol (0);      putc (last_line[_rl_screenwidth - 1], rl_outstream);    }  _rl_vis_botlin = 0;  rl_crlf ();  fflush (rl_outstream);  rl_display_fixed++;}/* Move to the start of the current line. */static voidcr (){  if (_rl_term_cr)    {#if defined (__MSDOS__)      putc ('\r', rl_outstream);#else      tputs (_rl_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, oldninvis, oldphyschars;  /* Geez, I should make this a struct. */  oldp = rl_display_prompt;  oldl = local_prompt;  oldlprefix = local_prompt_prefix;  oldlen = prompt_visible_length;  oldplen = prompt_prefix_length;  oldlast = prompt_last_invisible;  oldninvis = prompt_invis_chars_first_line;  oldphyschars = prompt_physical_chars;  rl_display_prompt = t;  local_prompt = expand_prompt (t, &prompt_visible_length,				   &prompt_last_invisible,				   &prompt_invis_chars_first_line,				   &prompt_physical_chars);  local_prompt_prefix = (char *)NULL;  rl_forced_update_display ();  rl_display_prompt = oldp;  local_prompt = oldl;  local_prompt_prefix = oldlprefix;  prompt_visible_length = oldlen;  prompt_prefix_length = oldplen;  prompt_last_invisible = oldlast;  prompt_invis_chars_first_line = oldninvis;  prompt_physical_chars = oldphyschars;}      /* 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 (_rl_term_cr)    {#if defined (__MSDOS__)      putc ('\r', rl_outstream);#else      tputs (_rl_term_cr, 1, _rl_output_character_function);#endif      _rl_last_c_pos = 0;#if defined (__MSDOS__)      space_to_eol (_rl_screenwidth);      putc ('\r', rl_outstream);#else      if (_rl_term_clreol)	tputs (_rl_term_clreol, 1, _rl_output_character_function);      else	{	  space_to_eol (_rl_screenwidth);	  tputs (_rl_term_cr, 1, _rl_output_character_function);	}#endif      if (_rl_last_v_pos > 0)	_rl_move_vert (0);    }  else    rl_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 - _rl_screenwidth - rl_visible_prompt_length;  else    nleft = _rl_last_c_pos - _rl_screenwidth;  if (nleft > 0)    ret = 1 + nleft / _rl_screenwidth;  else    ret = 0;  return ret;}#if defined (HANDLE_MULTIBYTE)/* Calculate the number of screen columns occupied by STR from START to END.   In the case of multibyte characters with stateful encoding, we have to   scan from the beginning of the string to take the state into account. */static int_rl_col_width (str, start, end)     const char *str;     int start, end;{  wchar_t wc;  mbstate_t ps = {0};  int tmp, point, width, max;  if (end <= start)    return 0;  point = 0;  max = end;  while (point < start)    {      tmp = mbrlen (str + point, max, &ps);      if (MB_INVALIDCH ((size_t)tmp))	{	  /* In this case, the bytes are invalid or too short to compose a	     multibyte character, so we assume that the first byte represents	     a single character. */	  point++;	  max--;	  /* Clear the state of the byte sequence, because in this case the	     effect of mbstate is undefined. */	  memset (&ps, 0, sizeof (mbstate_t));	}      else if (MB_NULLWCH (tmp))	break;		/* Found '\0' */      else	{	  point += tmp;	  max -= tmp;	}    }  /* If START is not a byte that starts a character, then POINT will be     greater than START.  In this case, assume that (POINT - START) gives     a byte count that is the number of columns of difference. */  width = point - start;  while (point < end)    {      tmp = mbrtowc (&wc, str + point, max, &ps);      if (MB_INVALIDCH ((size_t)tmp))	{	  /* In this case, the bytes are invalid or too short to compose a	     multibyte character, so we assume that the first byte represents	     a single character. */	  point++;	  max--;	  /* and assume that the byte occupies a single column. */	  width++;	  /* Clear the state of the byte sequence, because in this case the	     effect of mbstate is undefined. */	  memset (&ps, 0, sizeof (mbstate_t));	}      else if (MB_NULLWCH (tmp))	break;			/* Found '\0' */      else	{	  point += tmp;	  max -= tmp;	  tmp = 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -