Пример #1
0
/* Updates the status bar */
static void update_status_win(enum win_refresh dorefresh)
{
    int pos;
    int attr;

    attr = hl_groups_get_attr(hl_groups_instance, HLG_STATUS_BAR);

    /* Print white background */
    swin_wattron(status_win, attr);

    for (pos = 0; pos < WIDTH; pos++)
        swin_mvwprintw(status_win, 0, pos, " ");
    /* Show the user which window is focused */
    if (focus == GDB)
        swin_mvwprintw(status_win, 0, WIDTH - 1, "*");
    else if (focus == CGDB || focus == CGDB_STATUS_BAR)
        swin_mvwprintw(status_win, 0, WIDTH - 1, " ");

    swin_wattroff(status_win, attr);

    /* Print the regex that the user is looking for Forward */
    if (sbc_kind == SBC_REGEX && regex_direction_cur) {
        if_display_message("/", dorefresh, WIDTH - 1, "%s", ibuf_get(regex_cur));
        swin_curs_set(1);
    }
    /* Regex backwards */
    else if (sbc_kind == SBC_REGEX) {
        if_display_message("?", dorefresh, WIDTH - 1, "%s", ibuf_get(regex_cur));
        swin_curs_set(1);
    }
    /* A colon command typed at the status bar */
    else if (focus == CGDB_STATUS_BAR && sbc_kind == SBC_NORMAL) {
        const char *command = ibuf_get(cur_sbc);

        if (!command)
            command = "";
        if_display_message(":", dorefresh, WIDTH - 1, "%s", command);
        swin_curs_set(1);
    }
    /* Default: Current Filename */
    else {
        /* Print filename */
        const char *filename = source_current_file(src_viewer);

        if (filename) {
            if_display_message("", dorefresh, WIDTH - 1, "%s", filename);
        }
    }

    if (dorefresh == WIN_REFRESH)
        swin_wrefresh(status_win);
    else
        swin_wnoutrefresh(status_win);
}
Пример #2
0
void if_display_help(void)
{
    char cgdb_help_file[MAXLINE];
    int ret_val = 0;

    fs_util_get_path(PKGDATADIR, "cgdb.txt", cgdb_help_file);
    ret_val = source_set_exec_line(src_win, cgdb_help_file, 1);
    if (ret_val == 0)
        if_draw();
    else if (ret_val == 5)      /* File does not exist */
        if_display_message("No such file: %s", 0, cgdb_help_file);
}
Пример #3
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();
}
Пример #4
0
void if_display_help(void)
{
    char cgdb_help_file[FSUTIL_PATH_MAX];
    int ret_val = 0;

    fs_util_get_path(PKGDATADIR, "cgdb.txt", cgdb_help_file);

    /* File doesn't exist. Try to find cgdb.txt in the build dir in case
     * the user is running a built cgdb binary directly. */
    if (!fs_verify_file_exists(cgdb_help_file))
        fs_util_get_path(TOPBUILDDIR, "doc/cgdb.txt", cgdb_help_file);

    ret_val = source_set_exec_line(src_viewer, cgdb_help_file, 1, 0);

    if (ret_val == 0)
    {
        src_viewer->cur->language = TOKENIZER_LANGUAGE_CGDBHELP;
        source_highlight(src_viewer->cur);
        if_draw();
    }
    else if (ret_val == 5)      /* File does not exist */
        if_display_message("No such file: ", WIN_REFRESH, 0, "%s", cgdb_help_file);
}
Пример #5
0
/* Updates the status bar */
static void update_status_win(void)
{
    int pos;
    char filename[FSUTIL_PATH_MAX];
    int attr;

    if (hl_groups_get_attr(hl_groups_instance, HLG_STATUS_BAR, &attr) == -1)
        return;

    /* Update the tty status bar */
    if (tty_win_on) {
        wattron(tty_status_win, attr);
        for (pos = 0; pos < WIDTH; pos++)
            mvwprintw(tty_status_win, 0, pos, " ");

        mvwprintw(tty_status_win, 0, 0, (char *) tgdb_tty_name(tgdb));
        wattroff(tty_status_win, attr);
    }

    /* Print white background */
    wattron(status_win, attr);
    for (pos = 0; pos < WIDTH; pos++)
        mvwprintw(status_win, 0, pos, " ");
    if (tty_win_on)
        wattron(tty_status_win, attr);
    /* Show the user which window is focused */
    if (focus == GDB)
        mvwprintw(status_win, 0, WIDTH - 1, "*");
    else if (focus == TTY && tty_win_on)
        mvwprintw(tty_status_win, 0, WIDTH - 1, "*");
    else if (focus == CGDB || focus == CGDB_STATUS_BAR)
        mvwprintw(status_win, 0, WIDTH - 1, " ");
    wattroff(status_win, attr);
    if (tty_win_on)
        wattroff(tty_status_win, attr);

    /* Print the regex that the user is looking for Forward */
    if (focus == CGDB_STATUS_BAR && sbc_kind == SBC_REGEX
            && regex_direction_cur) {
        if_display_message("/", WIDTH - 1, "%s", ibuf_get(regex_cur));
        curs_set(1);
    }
    /* Regex backwards */
    else if (focus == CGDB_STATUS_BAR && sbc_kind == SBC_REGEX) {
        if_display_message("?", WIDTH - 1, "%s", ibuf_get(regex_cur));
        curs_set(1);
    }
    /* A colon command typed at the status bar */
    else if (focus == CGDB_STATUS_BAR && sbc_kind == SBC_NORMAL) {
        char *command = ibuf_get(cur_sbc);

        if (!command)
            command = "";
        if_display_message(":", WIDTH - 1, "%s", command);
        curs_set(1);
    }
    /* Default: Current Filename */
    else {
        /* Print filename */
        if (src_win != NULL && source_current_file(src_win, filename) != NULL)
            if_display_message("", WIDTH - 1, "%s", filename);
    }

    wrefresh(status_win);
}
Пример #6
0
Файл: cgdb.c Проект: i4fumi/cgdb
static void process_commands(struct tgdb *tgdb)
{
    struct tgdb_response *item;

    while ((item = tgdb_get_response(tgdb)) != NULL) {
        switch (item->header) {
                /* This updates all the breakpoints */
            case TGDB_UPDATE_BREAKPOINTS:
            {
                struct sviewer *sview = if_get_sview();
                char *file;
                struct tgdb_list *list =
                        item->choice.update_breakpoints.breakpoint_list;
                tgdb_list_iterator *iterator;
                struct tgdb_breakpoint *tb;

                source_clear_breaks(if_get_sview());
                iterator = tgdb_list_get_first(list);

                while (iterator) {
                    /* For each breakpoint */
                    tb = (struct tgdb_breakpoint *)
                            tgdb_list_get_item(iterator);

                    file = tb->file;

                    if (tb->enabled)
                        source_enable_break(sview, file, tb->line);
                    else
                        source_disable_break(sview, file, tb->line);

                    iterator = tgdb_list_next(iterator);
                }

                if_show_file(NULL, 0);
                break;
            }

                /* This means a source file or line number changed */
            case TGDB_UPDATE_FILE_POSITION:
            {
                struct tgdb_file_position *tfp;

                tfp = item->choice.update_file_position.file_position;

                /* Update the file */
                source_reload(if_get_sview(), tfp->absolute_path, 0);

                if_show_file(tfp->absolute_path, tfp->line_number);

                source_set_relative_path(if_get_sview(),
                        tfp->absolute_path, tfp->relative_path);

                break;
            }

                /* This is a list of all the source files */
            case TGDB_UPDATE_SOURCE_FILES:
            {
                struct tgdb_list *list =
                        item->choice.update_source_files.source_files;
                tgdb_list_iterator *i = tgdb_list_get_first(list);
                char *s;

                if_clear_filedlg();

                while (i) {
                    s = tgdb_list_get_item(i);
                    if_add_filedlg_choice(s);
                    i = tgdb_list_next(i);
                }

                if_set_focus(FILE_DLG);
                kui_input_acceptable = 1;
                break;
            }

                /* The user is trying to get a list of source files that make up
                 * the debugged program but libtgdb is claiming that gdb knows
                 * none. */
            case TGDB_SOURCES_DENIED:
                if_display_message("Error:", 0,
                        " No sources available! Was the program compiled with debug?");
                kui_input_acceptable = 1;
                break;

                /* This is the absolute path to the last file the user requested */
            case TGDB_FILENAME_PAIR:
            {
                const char *apath = item->choice.filename_pair.absolute_path;
                const char *rpath = item->choice.filename_pair.relative_path;

                if_show_file((char *) apath, 1);
                source_set_relative_path(if_get_sview(), apath, rpath);
                break;
            }

                /* The source file requested does not exist */
            case TGDB_ABSOLUTE_SOURCE_DENIED:
            {
                struct tgdb_source_file *file =
                        item->choice.absolute_source_denied.source_file;
                if_show_file(NULL, 0);
                /* com can be NULL when tgdb orig requests main file */
                if (file->absolute_path != NULL)
                    if_display_message("No such file:", 0, " %s",
                            file->absolute_path);
                break;
            }
            case TGDB_INFERIOR_EXITED:
            {
                /*
                 * int *status = item->data;
                 * This could eventually go here, but for now, the update breakpoint 
                 * display function makes the status bar go back to the name of the file.
                 *
                 * if_display_message ( "Program exited with value", 0, " %d", *status );
                 */

                /* Clear the cache */
                break;
            }
            case TGDB_UPDATE_COMPLETIONS:
            {
                struct tgdb_list *list =
                        item->choice.update_completions.completion_list;
                do_tab_completion(list);
                break;
            }
            case TGDB_UPDATE_CONSOLE_PROMPT_VALUE:
            {
                const char *new_prompt =
                        item->choice.update_console_prompt_value.prompt_value;
                change_prompt(new_prompt);
                break;
            }
            case TGDB_QUIT:
                cleanup();
                exit(0);
                break;
                /* Default */
            default:
                break;
        }
    }
}