46 #include "readline/readline.h"
68 #define CTRL_CHAR(c) \
69 ((c) < control_character_threshold && (((c) & 0x80) == 0))
105 #define TUI_USE_PIPE_FOR_READLINE
131 #ifdef TUI_USE_PIPE_FOR_READLINE
156 static int tui_skip_line = -1;
161 while ((c = *
string++) != 0)
169 else if (tui_skip_line != 1)
177 getyx (w, line, col);
182 }
while ((col % 8) != 0);
190 getyx (w,
TUI_CMD_WIN->detail.command_info.cur_line,
229 start_line =
TUI_CMD_WIN->detail.command_info.start_line;
230 wmove (w, start_line, 0);
233 for (in = 0; prompt && prompt[in]; in++)
235 waddch (w, prompt[in]);
236 getyx (w, line, col);
241 for (in = 0; in <= rl_end; in++)
247 getyx (w, c_line, c_pos);
253 c = (
unsigned char) rl_line_buffer[in];
257 waddch (w,
CTRL_CHAR (c) ? UNCTRL (c) :
'?');
262 getyx (w, line, col);
267 }
while ((col % 8) != 0);
275 getyx (w,
TUI_CMD_WIN->detail.command_info.start_line,
278 getyx (w, line, col);
284 getyx (w,
TUI_CMD_WIN->detail.command_info.start_line,
288 wmove (w, c_line, c_pos);
289 TUI_CMD_WIN->detail.command_info.cur_line = c_line;
292 TUI_CMD_WIN->detail.command_info.start_line -= height - 1;
307 xfree (tui_rl_saved_prompt);
308 tui_rl_saved_prompt = rl_prompt != NULL ? xstrdup (rl_prompt) : NULL;
318 #ifdef TUI_USE_PIPE_FOR_READLINE
327 size =
read (tui_readline_pipe[0], buf,
sizeof (buf) - 1);
375 wmove (w,
TUI_CMD_WIN->detail.command_info.cur_line, 0);
377 wmove (w,
TUI_CMD_WIN->detail.command_info.cur_line, 0);
406 rl_getc_func_t *prev = rl_getc_function;
412 rl_getc_function = prev;
424 rl_get_screen_size (&displayer.
height, &displayer.
width);
447 extern int _rl_echoing_p;
452 tui_old_rl_redisplay_function = rl_redisplay_function;
453 tui_old_rl_deprep_terminal = rl_deprep_term_function;
454 tui_old_rl_prep_terminal = rl_prep_term_function;
455 tui_old_rl_getc_function = rl_getc_function;
456 tui_old_rl_display_matches_hook = rl_completion_display_matches_hook;
457 tui_old_rl_outstream = rl_outstream;
458 tui_old_rl_echoing_p = _rl_echoing_p;
467 rl_already_prompted = 0;
503 rl_already_prompted = 0;
513 tui_cont_sig (
int sig)
530 signal (sig, tui_cont_sig);
539 signal (SIGCONT, tui_cont_sig);
550 #ifdef TUI_USE_PIPE_FOR_READLINE
555 error (
_(
"Cannot create pipe for readline"));
557 tui_rl_outstream = fdopen (tui_readline_pipe[1],
"w");
558 if (tui_rl_outstream == 0)
559 error (
_(
"Cannot redirect readline output"));
561 setvbuf (tui_rl_outstream, (
char*) NULL, _IOLBF, 0);
564 (void) fcntl (tui_readline_pipe[0], F_SETFL, O_NONBLOCK);
567 (void) fcntl (tui_readline_pipe[0], F_SETFL, O_NDELAY);
572 tui_rl_outstream = stdout;
586 #ifdef TUI_USE_PIPE_FOR_READLINE
604 wmove (w,
TUI_CMD_WIN->detail.command_info.cur_line, 0);
618 int py =
TUI_CMD_WIN->detail.command_info.cur_line;
619 px += rl_end - rl_point;
630 if (ch ==
'\n' || ch ==
'\r' || ch ==
'\f')
632 if (ch == KEY_BACKSPACE)
640 ch_pending = wgetch (w);
654 if (ch_pending != ERR)
656 ungetch (ch_pending);
676 for (ncol = col, n_adjust = 0, s =
string; s; )
678 s = strpbrk (s,
"\t");
681 ncol += (s -
string) + n_adjust;
684 n_adjust += 8 - (ncol % 8) - 1;
690 ret = q =
xmalloc (strlen (
string) + n_adjust + 1);
693 for (ncol = col, s =
string; s; )
695 const char *s1 = strpbrk (s,
"\t");
700 strncpy (q, s, s1 - s);
707 }
while ((ncol % 8) != 0);
static FILE * tui_rl_outstream
ssize_t read(int fd, void *buf, size_t count)
static rl_vintfunc_t * tui_old_rl_prep_terminal
static struct ui_file * tui_stderr
static struct ui_file * tui_stdout
static rl_voidfunc_t * tui_old_rl_deprep_terminal
static int tui_readline_pipe[2]
int gdb_pipe_cloexec(int filedes[2])
struct ui_file * gdb_stdout
struct ui_out * cli_out_new(struct ui_file *stream)
static int tui_mld_read_key(const struct match_list_displayer *displayer)
static char * tui_rl_saved_prompt
static void tui_prep_terminal(int notused1)
static void tui_mld_crlf(const struct match_list_displayer *displayer)
static void tui_mld_puts(const struct match_list_displayer *displayer, const char *s)
void tui_redisplay_readline(void)
void tui_puts(const char *string)
mld_read_key_ftype * read_key
void add_file_handler(int fd, handler_func *proc, gdb_client_data client_data)
int key_is_end_sequence(int ch)
void tui_refresh_all_win(void)
static void tui_mld_flush(const struct match_list_displayer *displayer)
static FILE * tui_old_rl_outstream
void tui_set_key_mode(enum tui_key_mode mode)
static void tui_mld_erase_entire_line(const struct match_list_displayer *displayer)
static void tui_putc(char c)
static int tui_old_rl_echoing_p
static struct ui_file * tui_old_stdout
struct ui_out * tui_old_uiout
int async_command_editing_p
static void tui_mld_beep(const struct match_list_displayer *displayer)
static void tui_rl_display_match_list(char **matches, int len, int max)
void tui_setup_io(int mode)
struct ui_file * gdb_stdlog
static rl_getc_func_t * tui_old_rl_getc_function
void tui_initialize_io(void)
unsigned int tui_dispatch_ctrl_char(unsigned int ch)
static rl_voidfunc_t * tui_old_rl_redisplay_function
static rl_compdisp_func_t * tui_old_rl_display_matches_hook
static struct ui_file * tui_old_stderr
char * tui_expand_tabs(const char *string, int col)
struct ui_file * gdb_stderr
static int tui_mld_getc(FILE *fp)
struct ui_file * tui_fileopen(FILE *stream)
static void tui_deprep_terminal(void)
int call_stdin_event_handler_again_p
struct ui_file * gdb_stdtarg
int key_is_backspace(int ch)
mld_erase_entire_line_ftype * erase_entire_line
static void tui_readline_output(int error, gdb_client_data data)
struct ui_file * gdb_stdtargerr
static void tui_mld_putch(const struct match_list_displayer *displayer, int ch)
struct ui_out * current_uiout
void gdb_display_match_list(char **matches, int len, int max, const struct match_list_displayer *displayer)
struct ui_out * tui_out_new(struct ui_file *stream)
enum tui_key_mode tui_current_key_mode
void error(const char *fmt,...)
const ULONGEST const LONGEST len
int key_is_start_sequence(int ch)