/** * Capture a regular expression from the user, one key at a time. * This modifies the global variables regex_cur and regex_last. * * \param sview * The source viewer. * * \return * 0 if user gave a regex, otherwise 1. */ static int status_bar_regex_input(struct sviewer *sview, int key) { int regex_icase = cgdbrc_get(CGDBRC_IGNORECASE)->variant.int_val; /* Flag to indicate we're done with regex mode, need to switch back */ int done = 0; /* Recieve a regex from the user. */ switch (key) { case '\r': case '\n': case CGDB_KEY_CTRL_M: /* Save for future searches via 'n' or 'N' */ if (regex_last != NULL) { ibuf_free(regex_last); } regex_last = ibuf_dup(regex_cur); regex_direction_last = regex_direction_cur; source_search_regex(sview, ibuf_get(regex_last), 2, regex_direction_last, regex_icase); if_draw(); done = 1; break; case 8: case 127: /* Backspace or DEL key */ if (ibuf_length(regex_cur) == 0) { done = 1; } else { ibuf_delchar(regex_cur); source_search_regex(sview, ibuf_get(regex_cur), 1, regex_direction_cur, regex_icase); if_draw(); update_status_win(); } break; default: if (kui_term_is_cgdb_key(key)) { const char *keycode = kui_term_get_keycode_from_cgdb_key(key); int length = strlen(keycode), i; for (i = 0; i < length; i++) ibuf_addchar(regex_cur, keycode[i]); } else { ibuf_addchar(regex_cur, key); } source_search_regex(sview, ibuf_get(regex_cur), 1, regex_direction_cur, regex_icase); if_draw(); update_status_win(); }; if (done) { ibuf_free(regex_cur); regex_cur = NULL; if_set_focus(CGDB); } return 0; }
/* if_draw: Draws the interface on the screen. * -------- */ void if_draw(void) { /* Only redisplay the filedlg if it is up */ if (focus == FILE_DLG) { filedlg_display(fd); return; } update_status_win(); if (get_src_height() != 0 && get_gdb_height() != 0) wrefresh(status_win); if (tty_win_on) wrefresh(tty_status_win); if (get_src_height() > 0) source_display(src_win, focus == CGDB); if (tty_win_on && get_tty_height() > 0) scr_refresh(tty_win, focus == TTY); if (get_gdb_height() > 0) scr_refresh(gdb_win, focus == GDB); /* This check is here so that the cursor goes to the * cgdb window. The cursor would stay in the gdb window * on cygwin */ if (get_src_height() > 0 && focus == CGDB) wrefresh(src_win->win); }
/* if_draw: Draws the interface on the screen. * -------- */ void if_draw(void) { if (!curses_initialized) return; /* Only redisplay the filedlg if it is up */ if (focus == FILE_DLG) { filedlg_display(fd); return; } update_status_win(WIN_NO_REFRESH); if (get_src_height() != 0 && get_gdb_height() != 0) swin_wnoutrefresh(status_win); if (get_src_height() > 0) source_display(src_viewer, focus == CGDB, WIN_NO_REFRESH); separator_display(cur_split_orientation == WSO_VERTICAL); if (get_gdb_height() > 0) scr_refresh(gdb_scroller, focus == GDB, WIN_NO_REFRESH); /* This check is here so that the cursor goes to the * cgdb window. The cursor would stay in the gdb window * on cygwin */ if (get_src_height() > 0 && focus == CGDB) swin_wnoutrefresh(src_viewer->win); swin_doupdate(); }
static int status_bar_normal_input(int key) { /* Flag to indicate we're done with status mode, need to switch back */ int done = 0; /* The goal of this state is to recieve a command from the user. */ switch (key) { case '\r': case '\n': case CGDB_KEY_CTRL_M: /* Found a command */ if_run_command(src_win, cur_sbc); done = 1; break; case 8: case 127: /* Backspace or DEL key */ if (ibuf_length(cur_sbc) == 0) { done = 1; } else { ibuf_delchar(cur_sbc); update_status_win(); } break; default: if (kui_term_is_cgdb_key(key)) { const char *keycode = kui_term_get_keycode_from_cgdb_key(key); int length = strlen(keycode), i; for (i = 0; i < length; i++) ibuf_addchar(cur_sbc, keycode[i]); } else { ibuf_addchar(cur_sbc, key); } update_status_win(); break; }; if (done) { ibuf_free(cur_sbc); cur_sbc = NULL; if_set_focus(CGDB); } return 0; }
static void if_run_command(struct sviewer *sview, struct ibuf *ibuf_command) { char *command = ibuf_get(ibuf_command); /* refresh and return if the user entered no data */ if (ibuf_length(ibuf_command) == 0) { if_draw(); return; } if (command_parse_string(command)) { if_display_message("Unknown command: ", 0, "%s", command); } else { update_status_win(); } if_draw(); }
/** * Capture a regular expression from the user, one key at a time. * This modifies the global variables regex_cur and regex_last. * * \param sview * The source viewer. * * \return * 0 if user gave a regex, otherwise 1. */ static int gdb_input_regex_input(struct scroller *scr, int key) { int regex_icase = cgdbrc_get_int(CGDBRC_IGNORECASE); /* Flag to indicate we're done with regex mode, need to switch back */ int done = 0; /* Receive a regex from the user. */ switch (key) { case '\r': case '\n': case CGDB_KEY_CTRL_M: /* Save for future searches via 'n' or 'N' */ ibuf_free(regex_last); regex_last = ibuf_dup(regex_cur); regex_direction_last = regex_direction_cur; scr_search_regex(scr, ibuf_get(regex_last), 2, regex_direction_last, regex_icase); if_draw(); done = 1; break; case 8: case 127: /* Backspace or DEL key */ if (ibuf_length(regex_cur) == 0) { done = 1; scr_search_regex(scr, "", 2, regex_direction_cur, regex_icase); } else { ibuf_delchar(regex_cur); scr_search_regex(scr, ibuf_get(regex_cur), 1, regex_direction_cur, regex_icase); if_draw(); update_status_win(WIN_REFRESH); } break; default: if (kui_term_is_cgdb_key(key)) { const char *keycode = kui_term_get_keycode_from_cgdb_key(key); int length = strlen(keycode), i; for (i = 0; i < length; i++) ibuf_addchar(regex_cur, keycode[i]); } else { ibuf_addchar(regex_cur, key); } scr_search_regex(scr, ibuf_get(regex_cur), 1, regex_direction_cur, regex_icase); if_draw(); update_status_win(WIN_REFRESH); }; if (done) { gdb_scroller->in_search_mode = 0; ibuf_free(regex_cur); regex_cur = NULL; sbc_kind = SBC_NORMAL; if_set_focus(GDB); } return 0; }