예제 #1
0
void
change_line_handler (int editing)
{
  struct ui *ui = current_ui;

  /* We can only have one instance of readline, so we only allow
     editing on the main UI.  */
  if (ui != main_ui)
    return;

  /* Don't try enabling editing if the interpreter doesn't support it
     (e.g., MI).  */
  if (!interp_supports_command_editing (top_level_interpreter ())
      || !interp_supports_command_editing (command_interp ()))
    return;

  if (editing)
    {
      gdb_assert (ui == main_ui);

      /* Turn on editing by using readline.  */
      ui->call_readline = gdb_rl_callback_read_char_wrapper;
    }
  else
    {
      /* Turn off editing by using gdb_readline_no_editing_callback.  */
      if (ui->command_editing)
	gdb_rl_callback_handler_remove ();
      ui->call_readline = gdb_readline_no_editing_callback;
    }
  ui->command_editing = editing;
}
예제 #2
0
static struct interp *
find_mi_interpreter (void)
{
  struct interp *interp;

  interp = top_level_interpreter ();
  if (ui_out_is_mi_like_p (interp_ui_out (interp)))
    return interp;

  interp = command_interp ();
  if (ui_out_is_mi_like_p (interp_ui_out (interp)))
    return interp;

  return NULL;
}