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

📄 text.c

📁 在非GUI环境下
💻 C
📖 第 1 页 / 共 3 页
字号:
	}    }  return 0;}/* Delete the character under the cursor.  Given a numeric argument,   kill that many characters instead. */intrl_delete (count, key)     int count, key;{  int r;  if (count < 0)    return (_rl_rubout_char (-count, key));  if (rl_point == rl_end)    {      rl_ding ();      return -1;    }  if (count > 1 || rl_explicit_arg)    {      int orig_point = rl_point;#if defined (HANDLE_MULTIBYTE)      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)	rl_forward_char (count, key);      else#endif	rl_forward_byte (count, key);      r = rl_kill_text (orig_point, rl_point);      rl_point = orig_point;      return r;    }  else    {      int new_point;      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)	new_point = _rl_find_next_mbchar (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO);      else	new_point = rl_point + 1;	      return (rl_delete_text (rl_point, new_point));    }}/* Delete the character under the cursor, unless the insertion   point is at the end of the line, in which case the character   behind the cursor is deleted.  COUNT is obeyed and may be used   to delete forward or backward that many characters. */      intrl_rubout_or_delete (count, key)     int count, key;{  if (rl_end != 0 && rl_point == rl_end)    return (_rl_rubout_char (count, key));  else    return (rl_delete (count, key));}  /* Delete all spaces and tabs around point. */intrl_delete_horizontal_space (count, ignore)     int count, ignore;{  int start = rl_point;  while (rl_point && whitespace (rl_line_buffer[rl_point - 1]))    rl_point--;  start = rl_point;  while (rl_point < rl_end && whitespace (rl_line_buffer[rl_point]))    rl_point++;  if (start != rl_point)    {      rl_delete_text (start, rl_point);      rl_point = start;    }  return 0;}/* Like the tcsh editing function delete-char-or-list.  The eof character   is caught before this is invoked, so this really does the same thing as   delete-char-or-list-or-eof, as long as it's bound to the eof character. */intrl_delete_or_show_completions (count, key)     int count, key;{  if (rl_end != 0 && rl_point == rl_end)    return (rl_possible_completions (count, key));  else    return (rl_delete (count, key));}#ifndef RL_COMMENT_BEGIN_DEFAULT#define RL_COMMENT_BEGIN_DEFAULT "#"#endif/* Turn the current line into a comment in shell history.   A K*rn shell style function. */intrl_insert_comment (count, key)     int count, key;{  char *rl_comment_text;  int rl_comment_len;  rl_beg_of_line (1, key);  rl_comment_text = _rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT;  if (rl_explicit_arg == 0)    rl_insert_text (rl_comment_text);  else    {      rl_comment_len = strlen (rl_comment_text);      if (STREQN (rl_comment_text, rl_line_buffer, rl_comment_len))	rl_delete_text (rl_point, rl_point + rl_comment_len);      else	rl_insert_text (rl_comment_text);    }  (*rl_redisplay_function) ();  rl_newline (1, '\n');  return (0);}/* **************************************************************** *//*								    *//*			Changing Case				    *//*								    *//* **************************************************************** *//* The three kinds of things that we know how to do. */#define UpCase 1#define DownCase 2#define CapCase 3/* Uppercase the word at point. */intrl_upcase_word (count, key)     int count, key;{  return (rl_change_case (count, UpCase));}/* Lowercase the word at point. */intrl_downcase_word (count, key)     int count, key;{  return (rl_change_case (count, DownCase));}/* Upcase the first letter, downcase the rest. */intrl_capitalize_word (count, key)     int count, key;{ return (rl_change_case (count, CapCase));}/* The meaty function.   Change the case of COUNT words, performing OP on them.   OP is one of UpCase, DownCase, or CapCase.   If a negative argument is given, leave point where it started,   otherwise, leave it where it moves to. */static intrl_change_case (count, op)     int count, op;{  register int start, end;  int inword, c;  start = rl_point;  rl_forward_word (count, 0);  end = rl_point;  if (count < 0)    SWAP (start, end);  /* We are going to modify some text, so let's prepare to undo it. */  rl_modifying (start, end);  for (inword = 0; start < end; start++)    {      c = rl_line_buffer[start];      switch (op)	{	case UpCase:	  rl_line_buffer[start] = _rl_to_upper (c);	  break;	case DownCase:	  rl_line_buffer[start] = _rl_to_lower (c);	  break;	case CapCase:	  rl_line_buffer[start] = (inword == 0) ? _rl_to_upper (c) : _rl_to_lower (c);	  inword = rl_alphabetic (rl_line_buffer[start]);	  break;	default:	  rl_ding ();	  return -1;	}    }  rl_point = end;  return 0;}/* **************************************************************** *//*								    *//*			Transposition				    *//*								    *//* **************************************************************** *//* Transpose the words at point.  If point is at the end of the line,   transpose the two words before point. */intrl_transpose_words (count, key)     int count, key;{  char *word1, *word2;  int w1_beg, w1_end, w2_beg, w2_end;  int orig_point = rl_point;  if (!count)    return 0;  /* Find the two words. */  rl_forward_word (count, key);  w2_end = rl_point;  rl_backward_word (1, key);  w2_beg = rl_point;  rl_backward_word (count, key);  w1_beg = rl_point;  rl_forward_word (1, key);  w1_end = rl_point;  /* Do some check to make sure that there really are two words. */  if ((w1_beg == w2_beg) || (w2_beg < w1_end))    {      rl_ding ();      rl_point = orig_point;      return -1;    }  /* Get the text of the words. */  word1 = rl_copy_text (w1_beg, w1_end);  word2 = rl_copy_text (w2_beg, w2_end);  /* We are about to do many insertions and deletions.  Remember them     as one operation. */  rl_begin_undo_group ();  /* Do the stuff at word2 first, so that we don't have to worry     about word1 moving. */  rl_point = w2_beg;  rl_delete_text (w2_beg, w2_end);  rl_insert_text (word1);  rl_point = w1_beg;  rl_delete_text (w1_beg, w1_end);  rl_insert_text (word2);  /* This is exactly correct since the text before this point has not     changed in length. */  rl_point = w2_end;  /* I think that does it. */  rl_end_undo_group ();  free (word1);  free (word2);  return 0;}/* Transpose the characters at point.  If point is at the end of the line,   then transpose the characters before point. */intrl_transpose_chars (count, key)     int count, key;{#if defined (HANDLE_MULTIBYTE)  char *dummy;  int i, prev_point;#else  char dummy[2];#endif  int char_length;  if (count == 0)    return 0;  if (!rl_point || rl_end < 2)    {      rl_ding ();      return -1;    }  rl_begin_undo_group ();  if (rl_point == rl_end)    {      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)	rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO);      else	--rl_point;      count = 1;    }#if defined (HANDLE_MULTIBYTE)  prev_point = rl_point;  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)    rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO);  else#endif    rl_point--;#if defined (HANDLE_MULTIBYTE)  char_length = prev_point - rl_point;  dummy = (char *)xmalloc (char_length + 1);  for (i = 0; i < char_length; i++)    dummy[i] = rl_line_buffer[rl_point + i];  dummy[i] = '\0';#else  dummy[0] = rl_line_buffer[rl_point];  dummy[char_length = 1] = '\0';#endif  rl_delete_text (rl_point, rl_point + char_length);  rl_point = _rl_find_next_mbchar (rl_line_buffer, rl_point, count, MB_FIND_NONZERO);  _rl_fix_point (0);  rl_insert_text (dummy);  rl_end_undo_group ();#if defined (HANDLE_MULTIBYTE)  free (dummy);#endif  return 0;}/* **************************************************************** *//*								    *//*			Character Searching			    *//*								    *//* **************************************************************** */int#if defined (HANDLE_MULTIBYTE)_rl_char_search_internal (count, dir, smbchar, len)     int count, dir;     char *smbchar;     int len;#else_rl_char_search_internal (count, dir, schar)     int count, dir, schar;#endif{  int pos, inc;#if defined (HANDLE_MULTIBYTE)  int prepos;#endif  pos = rl_point;  inc = (dir < 0) ? -1 : 1;  while (count)    {      if ((dir < 0 && pos <= 0) || (dir > 0 && pos >= rl_end))	{	  rl_ding ();	  return -1;	}#if defined (HANDLE_MULTIBYTE)      pos = (inc > 0) ? _rl_find_next_mbchar (rl_line_buffer, pos, 1, MB_FIND_ANY)		      : _rl_find_prev_mbchar (rl_line_buffer, pos, MB_FIND_ANY);#else      pos += inc;#endif      do	{#if defined (HANDLE_MULTIBYTE)	  if (_rl_is_mbchar_matched (rl_line_buffer, pos, rl_end, smbchar, len))#else	  if (rl_line_buffer[pos] == schar)#endif	    {	      count--;	      if (dir < 0)	        rl_point = (dir == BTO) ? _rl_find_next_mbchar (rl_line_buffer, pos, 1, MB_FIND_ANY)					: pos;	      else		rl_point = (dir == FTO) ? _rl_find_prev_mbchar (rl_line_buffer, pos, MB_FIND_ANY)					: pos;	      break;	    }#if defined (HANDLE_MULTIBYTE)	  prepos = pos;#endif	}#if defined (HANDLE_MULTIBYTE)      while ((dir < 0) ? (pos = _rl_find_prev_mbchar (rl_line_buffer, pos, MB_FIND_ANY)) != prepos		       : (pos = _rl_find_next_mbchar (rl_line_buffer, pos, 1, MB_FIND_ANY)) != prepos);#else      while ((dir < 0) ? pos-- : ++pos < rl_end);#endif    }  return (0);}/* Search COUNT times for a character read from the current input stream.   FDIR is the direction to search if COUNT is non-negative; otherwise   the search goes in BDIR.  So much is dependent on HANDLE_MULTIBYTE   that there are two separate versions of this function. */#if defined (HANDLE_MULTIBYTE)static int_rl_char_search (count, fdir, bdir)     int count, fdir, bdir;{  char mbchar[MB_LEN_MAX];  int mb_len;  mb_len = _rl_read_mbchar (mbchar, MB_LEN_MAX);  if (count < 0)    return (_rl_char_search_internal (-count, bdir, mbchar, mb_len));  else    return (_rl_char_search_internal (count, fdir, mbchar, mb_len));}#else /* !HANDLE_MULTIBYTE */static int_rl_char_search (count, fdir, bdir)     int count, fdir, bdir;{  int c;  RL_SETSTATE(RL_STATE_MOREINPUT);  c = rl_read_key ();  RL_UNSETSTATE(RL_STATE_MOREINPUT);  if (count < 0)    return (_rl_char_search_internal (-count, bdir, c));  else    return (_rl_char_search_internal (count, fdir, c));}#endif /* !HANDLE_MULTIBYTE */intrl_char_search (count, key)     int count, key;{  return (_rl_char_search (count, FFIND, BFIND));}intrl_backward_char_search (count, key)     int count, key;{  return (_rl_char_search (count, BFIND, FFIND));}/* **************************************************************** *//*								    *//*		   The Mark and the Region.			    *//*								    *//* **************************************************************** *//* Set the mark at POSITION. */int_rl_set_mark_at_pos (position)     int position;{  if (position > rl_end)    return -1;  rl_mark = position;  return 0;}/* A bindable command to set the mark. */intrl_set_mark (count, key)     int count, key;{  return (_rl_set_mark_at_pos (rl_explicit_arg ? count : rl_point));}/* Exchange the position of mark and point. */intrl_exchange_point_and_mark (count, key)     int count, key;{  if (rl_mark > rl_end)    rl_mark = -1;  if (rl_mark == -1)    {      rl_ding ();      return -1;    }  else    SWAP (rl_point, rl_mark);  return 0;}

⌨️ 快捷键说明

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