コード例 #1
0
ファイル: nbfgets.c プロジェクト: Bhagita/virtualagc
/**
 * Why sometimes the input stream returns huge numbers is beyond me
 * Maybe a Code::Blocks stream issue
 * ... [RSB] The readline documentation does not describe what the 
 * legal return values of rl_getc() are.  There's no reason to suppose
 * (without going through the rl_getc() source code) that they are 
 * always 8-bit characters.  so we need to catch illegal characters
 * and fix them somehow.  On Vista, all kinds of rotten garbage can be
 * returned, so we go out of our way to reject and clear the input
 * buffer in this case.
 */
int rl_getchar(FILE *stream)
{
#if 0 // RSB

   char c;
#ifdef WIN32
   while ((c = (char) rl_getc(stream) ) == 10); /* Ignore LF */
#else
   c = /*(char)*/ rl_getc (stream);
#endif
   return ((int)c);
   
#else // 0

  int c;
  while (1)
    {
      c = rl_getc (stream);
#ifdef WIN32
      if (c == '\n')
        continue;
#endif
      if (c < 1 || c >= 0x7F)
        continue;
      break;
    }
  return (c);

#endif // 0
}
コード例 #2
0
ファイル: vi_mode.c プロジェクト: AOSC-Dev/metahtml
int
rl_vi_change_char (int count, int key)
{
  int c;

  if (vi_redoing)
    c = _rl_vi_last_replacement;
  else
    _rl_vi_last_replacement = c = rl_getc (rl_instream);

  if (c == '\033' || c == CTRL ('C'))
    return -1;

  while (count-- && rl_point < rl_end)
    {
      rl_begin_undo_group ();

      rl_delete (1, c);
      rl_insert (1, c);
      if (count == 0)
	rl_backward (1, c);

      rl_end_undo_group ();
    }
  return (0);
}
コード例 #3
0
ファイル: inputwin.c プロジェクト: diagprov/profanity
static int
_inp_rl_getc(FILE *stream)
{
    int ch = rl_getc(stream);
    if (_inp_printable(ch)) {
        ProfWin *window = wins_get_current();
        cmd_reset_autocomplete(window);
    }
    return ch;
}
コード例 #4
0
ファイル: ui-readline.c プロジェクト: AdKwiatkos/ekg2
/*
 * my_getc()
 *
 * pobiera znak z klawiatury obs³uguj±c w miêdzyczasie sieæ.
 */
int my_getc(FILE *f)
{
	if (ui_need_refresh) {
		ui_need_refresh = 0;
		rl_get_screen_size(&screen_lines, &screen_columns);
		if (screen_lines < 1)
			screen_lines = 24;
		if (screen_columns < 1)
			screen_columns = 80;
		ui_screen_width = screen_columns;
		ui_screen_height = screen_lines;
	}
	return rl_getc(f);
}
コード例 #5
0
ファイル: vi_mode.c プロジェクト: AOSC-Dev/metahtml
int
rl_vi_char_search (int count, int key)
{
  static char target;
  static int orig_dir, dir;
  int pos;

  if (key == ';' || key == ',')
    dir = (key == ';' ? orig_dir : -orig_dir);
  else
    {
      if (vi_redoing)
	target = _rl_vi_last_search_char;
      else
	_rl_vi_last_search_char = target = rl_getc (rl_instream);

      switch (key)
        {
        case 't':
          orig_dir = dir = FTO;
          break;

        case 'T':
          orig_dir = dir = BTO;
          break;

        case 'f':
          orig_dir = dir = FFIND;
          break;

        case 'F':
          orig_dir = dir = BFIND;
          break;
        }
    }

  pos = rl_point;

  while (count--)
    {
      if (dir < 0)
	{
	  if (pos == 0)
	    {
	      DING ();
	      return -1;
	    }

	  pos--;
	  do
	    {
	      if (rl_line_buffer[pos] == target)
		{
		  if (dir == BTO)
		    rl_point = pos + 1;
		  else
		    rl_point = pos;
		  break;
		}
	    }
	  while (pos--);

	  if (pos < 0)
	    {
	      DING ();
	      return -1;
	    }
	}
      else
	{			/* dir > 0 */
	  if (pos >= rl_end)
	    {
	      DING ();
	      return -1;
	    }

	  pos++;
	  do
	    {
	      if (rl_line_buffer[pos] == target)
		{
		  if (dir == FTO)
		    rl_point = pos - 1;
		  else
		    rl_point = pos;
		  break;
		}
	    }
	  while (++pos < rl_end);

	  if (pos >= (rl_end - 1))
	    {
	      DING ();
	      return -1;
	    }
	}
    }
  return (0);
}