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

📄 readline.c

📁 android-w.song.android.widget
💻 C
📖 第 1 页 / 共 3 页
字号:
	      r = RL_ISSTATE (RL_STATE_MULTIKEY) ? -3 : 0;	      cxt = _rl_keyseq_cxt_alloc ();	      if (got_subseq)		cxt->flags |= KSEQ_SUBSEQ;	      cxt->okey = key;	      cxt->oldmap = map;	      cxt->dmap = _rl_dispatching_keymap;	      cxt->subseq_arg = got_subseq || cxt->dmap[ANYOTHERKEY].function;	      RL_SETSTATE (RL_STATE_MULTIKEY);	      _rl_kscxt = cxt;	      return r;		/* don't indicate immediate success */	    }#endif	  newkey = _rl_subseq_getchar (key);	  if (newkey < 0)	    {	      _rl_abort_internal ();	      return -1;	    }	  r = _rl_dispatch_subseq (newkey, _rl_dispatching_keymap, got_subseq || map[ANYOTHERKEY].function);	  return _rl_subseq_result (r, map, key, got_subseq);	}      else	{	  _rl_abort_internal ();	  return -1;	}      break;    case ISMACR:      if (map[key].function != 0)	{	  macro = savestring ((char *)map[key].function);	  _rl_with_macro_input (macro);	  return 0;	}      break;    }#if defined (VI_MODE)  if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap &&      key != ANYOTHERKEY &&      _rl_vi_textmod_command (key))    _rl_vi_set_last (key, rl_numeric_arg, rl_arg_sign);#endif  return (r);}static int_rl_subseq_result (r, map, key, got_subseq)     int r;     Keymap map;     int key, got_subseq;{  Keymap m;  int type, nt;  rl_command_func_t *func, *nf;  if (r == -2)    /* We didn't match anything, and the keymap we're indexed into       shadowed a function previously bound to that prefix.  Call       the function.  The recursive call to _rl_dispatch_subseq has       already taken care of pushing any necessary input back onto       the input queue with _rl_unget_char. */    {      m = _rl_dispatching_keymap;      type = m[ANYOTHERKEY].type;      func = m[ANYOTHERKEY].function;      if (type == ISFUNC && func == rl_do_lowercase_version)	r = _rl_dispatch (_rl_to_lower (key), map);      else if (type == ISFUNC && func == rl_insert)	{	  /* If the function that was shadowed was self-insert, we	     somehow need a keymap with map[key].func == self-insert.	     Let's use this one. */	  nt = m[key].type;	  nf = m[key].function;	  m[key].type = type;	  m[key].function = func;	  r = _rl_dispatch (key, m);	  m[key].type = nt;	  m[key].function = nf;	}      else	r = _rl_dispatch (ANYOTHERKEY, m);    }  else if (r && map[ANYOTHERKEY].function)    {      /* We didn't match (r is probably -1), so return something to	 tell the caller that it should try ANYOTHERKEY for an	 overridden function. */      _rl_unget_char (key);      _rl_dispatching_keymap = map;      return -2;    }  else if (r && got_subseq)    {      /* OK, back up the chain. */      _rl_unget_char (key);      _rl_dispatching_keymap = map;      return -1;    }  return r;}/* **************************************************************** *//*								    *//*			Initializations 			    *//*								    *//* **************************************************************** *//* Initialize readline (and terminal if not already). */intrl_initialize (){  /* If we have never been called before, initialize the     terminal and data structures. */  if (!rl_initialized)    {      RL_SETSTATE(RL_STATE_INITIALIZING);      readline_initialize_everything ();      RL_UNSETSTATE(RL_STATE_INITIALIZING);      rl_initialized++;      RL_SETSTATE(RL_STATE_INITIALIZED);    }  /* Initalize the current line information. */  _rl_init_line_state ();  /* We aren't done yet.  We haven't even gotten started yet! */  rl_done = 0;  RL_UNSETSTATE(RL_STATE_DONE);  /* Tell the history routines what is going on. */  _rl_start_using_history ();  /* Make the display buffer match the state of the line. */  rl_reset_line_state ();  /* No such function typed yet. */  rl_last_func = (rl_command_func_t *)NULL;  /* Parsing of key-bindings begins in an enabled state. */  _rl_parsing_conditionalized_out = 0;#if defined (VI_MODE)  if (rl_editing_mode == vi_mode)    _rl_vi_initialize_line ();#endif  /* Each line starts in insert mode (the default). */  _rl_set_insert_mode (RL_IM_DEFAULT, 1);  return 0;}#if 0#if defined (__EMX__)static void_emx_build_environ (){  TIB *tibp;  PIB *pibp;  char *t, **tp;  int c;  DosGetInfoBlocks (&tibp, &pibp);  t = pibp->pib_pchenv;  for (c = 1; *t; c++)    t += strlen (t) + 1;  tp = environ = (char **)xmalloc ((c + 1) * sizeof (char *));  t = pibp->pib_pchenv;  while (*t)    {      *tp++ = t;      t += strlen (t) + 1;    }  *tp = 0;}#endif /* __EMX__ */#endif/* Initialize the entire state of the world. */static voidreadline_initialize_everything (){#if 0#if defined (__EMX__)  if (environ == 0)    _emx_build_environ ();#endif#endif#if 0  /* Find out if we are running in Emacs -- UNUSED. */  running_in_emacs = sh_get_env_value ("EMACS") != (char *)0;#endif  /* Set up input and output if they are not already set up. */  if (!rl_instream)    rl_instream = stdin;  if (!rl_outstream)    rl_outstream = stdout;  /* Bind _rl_in_stream and _rl_out_stream immediately.  These values     may change, but they may also be used before readline_internal ()     is called. */  _rl_in_stream = rl_instream;  _rl_out_stream = rl_outstream;  /* Allocate data structures. */  if (rl_line_buffer == 0)    rl_line_buffer = (char *)xmalloc (rl_line_buffer_len = DEFAULT_BUFFER_SIZE);  /* Initialize the terminal interface. */  if (rl_terminal_name == 0)    rl_terminal_name = sh_get_env_value ("TERM");  _rl_init_terminal_io (rl_terminal_name);  /* Bind tty characters to readline functions. */  readline_default_bindings ();  /* Initialize the function names. */  rl_initialize_funmap ();  /* Decide whether we should automatically go into eight-bit mode. */  _rl_init_eightbit ();        /* Read in the init file. */  rl_read_init_file ((char *)NULL);  /* XXX */  if (_rl_horizontal_scroll_mode && _rl_term_autowrap)    {      _rl_screenwidth--;      _rl_screenchars -= _rl_screenheight;    }  /* Override the effect of any `set keymap' assignments in the     inputrc file. */  rl_set_keymap_from_edit_mode ();  /* Try to bind a common arrow key prefix, if not already bound. */  bind_arrow_keys ();  /* Enable the meta key, if this terminal has one. */  if (_rl_enable_meta)    _rl_enable_meta_key ();  /* If the completion parser's default word break characters haven't     been set yet, then do so now. */  if (rl_completer_word_break_characters == (char *)NULL)    rl_completer_word_break_characters = (char *)rl_basic_word_break_characters;}/* If this system allows us to look at the values of the regular   input editing characters, then bind them to their readline   equivalents, iff the characters are not bound to keymaps. */static voidreadline_default_bindings (){  if (_rl_bind_stty_chars)    rl_tty_set_default_bindings (_rl_keymap);}/* Reset the default bindings for the terminal special characters we're   interested in back to rl_insert and read the new ones. */static voidreset_default_bindings (){  if (_rl_bind_stty_chars)    {      rl_tty_unset_default_bindings (_rl_keymap);      rl_tty_set_default_bindings (_rl_keymap);    }}/* Bind some common arrow key sequences in MAP. */static voidbind_arrow_keys_internal (map)     Keymap map;{  Keymap xkeymap;  xkeymap = _rl_keymap;  _rl_keymap = map;#if defined (__MSDOS__)  rl_bind_keyseq_if_unbound ("\033[0A", rl_get_previous_history);  rl_bind_keyseq_if_unbound ("\033[0B", rl_backward_char);  rl_bind_keyseq_if_unbound ("\033[0C", rl_forward_char);  rl_bind_keyseq_if_unbound ("\033[0D", rl_get_next_history);#endif  rl_bind_keyseq_if_unbound ("\033[A", rl_get_previous_history);  rl_bind_keyseq_if_unbound ("\033[B", rl_get_next_history);  rl_bind_keyseq_if_unbound ("\033[C", rl_forward_char);  rl_bind_keyseq_if_unbound ("\033[D", rl_backward_char);  rl_bind_keyseq_if_unbound ("\033[H", rl_beg_of_line);  rl_bind_keyseq_if_unbound ("\033[F", rl_end_of_line);  rl_bind_keyseq_if_unbound ("\033OA", rl_get_previous_history);  rl_bind_keyseq_if_unbound ("\033OB", rl_get_next_history);  rl_bind_keyseq_if_unbound ("\033OC", rl_forward_char);  rl_bind_keyseq_if_unbound ("\033OD", rl_backward_char);  rl_bind_keyseq_if_unbound ("\033OH", rl_beg_of_line);  rl_bind_keyseq_if_unbound ("\033OF", rl_end_of_line);#if defined (__MINGW32__)  rl_bind_keyseq_if_unbound ("\340H", rl_get_previous_history);  rl_bind_keyseq_if_unbound ("\340P", rl_get_next_history);  rl_bind_keyseq_if_unbound ("\340M", rl_forward_char);  rl_bind_keyseq_if_unbound ("\340K", rl_backward_char);#endif  _rl_keymap = xkeymap;}/* Try and bind the common arrow key prefixes after giving termcap and   the inputrc file a chance to bind them and create `real' keymaps   for the arrow key prefix. */static voidbind_arrow_keys (){  bind_arrow_keys_internal (emacs_standard_keymap);#if defined (VI_MODE)  bind_arrow_keys_internal (vi_movement_keymap);  /* Unbind vi_movement_keymap[ESC] to allow users to repeatedly hit ESC     in vi command mode while still allowing the arrow keys to work. */  if (vi_movement_keymap[ESC].type == ISKMAP)    rl_bind_keyseq_in_map ("\033", (rl_command_func_t *)NULL, vi_movement_keymap);  bind_arrow_keys_internal (vi_insertion_keymap);#endif}/* **************************************************************** *//*								    *//*		Saving and Restoring Readline's state		    *//*								    *//* **************************************************************** */intrl_save_state (sp)     struct readline_state *sp;{  if (sp == 0)    return -1;  sp->point = rl_point;  sp->end = rl_end;  sp->mark = rl_mark;  sp->buffer = rl_line_buffer;  sp->buflen = rl_line_buffer_len;  sp->ul = rl_undo_list;  sp->prompt = rl_prompt;  sp->rlstate = rl_readline_state;  sp->done = rl_done;  sp->kmap = _rl_keymap;  sp->lastfunc = rl_last_func;  sp->insmode = rl_insert_mode;  sp->edmode = rl_editing_mode;  sp->kseqlen = rl_key_sequence_length;  sp->inf = rl_instream;  sp->outf = rl_outstream;  sp->pendingin = rl_pending_input;  sp->macro = rl_executing_macro;  sp->catchsigs = rl_catch_signals;  sp->catchsigwinch = rl_catch_sigwinch;  return (0);}intrl_restore_state (sp)     struct readline_state *sp;{  if (sp == 0)    return -1;  rl_point = sp->point;  rl_end = sp->end;  rl_mark = sp->mark;  the_line = rl_line_buffer = sp->buffer;  rl_line_buffer_len = sp->buflen;  rl_undo_list = sp->ul;  rl_prompt = sp->prompt;  rl_readline_state = sp->rlstate;  rl_done = sp->done;  _rl_keymap = sp->kmap;  rl_last_func = sp->lastfunc;  rl_insert_mode = sp->insmode;  rl_editing_mode = sp->edmode;  rl_key_sequence_length = sp->kseqlen;  rl_instream = sp->inf;  rl_outstream = sp->outf;  rl_pending_input = sp->pendingin;  rl_executing_macro = sp->macro;  rl_catch_signals = sp->catchsigs;  rl_catch_sigwinch = sp->catchsigwinch;  return (0);}

⌨️ 快捷键说明

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