Exemple #1
0
/* 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();
}
Exemple #2
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);
}
Exemple #3
0
/* if_layout: Update the layout of the screen based on current terminal size.
 * ----------
 *
 * Return Value: Zero on success, non-zero on failure.
 */
static int if_layout()
{
    /* Verify the window size is reasonable */
    validate_window_sizes();

    /* Initialize the GDB I/O window */
    if (gdb_win == NULL) {
        gdb_win =
                scr_new(get_gdb_row(), get_gdb_col(), get_gdb_height(),
                get_gdb_width());
        if (gdb_win == NULL)
            return 2;
    } else {                    /* Resize the GDB I/O window */
        if (get_gdb_height() > 0)
            scr_move(gdb_win, get_gdb_row(), get_gdb_col(), get_gdb_height(),
                    get_gdb_width());
    }

    /* Initialize TTY I/O window */
    if (tty_win == NULL) {
        tty_win =
                scr_new(get_tty_row(), get_tty_col(), get_tty_height(),
                get_tty_width());
        if (tty_win == NULL)
            return 2;
    } else {                    /* Resize the GDB I/O window */
        if (get_tty_height() > 0)
            scr_move(tty_win, get_tty_row(), get_tty_col(), get_tty_height(),
                    get_tty_width());
    }

    /* Initialize the source viewer window */
    if (src_win == NULL) {
        src_win =
                source_new(get_src_row(), get_src_col(), get_src_height(),
                get_src_width());
        if (src_win == NULL)
            return 3;
    } else {                    /* Resize the source viewer window */
        if (get_src_height() > 0)
            source_move(src_win, get_src_row(), get_src_col(),
                    get_src_height(), get_src_width());
    }

    /* Initialize the status bar window */
    status_win = newwin(get_src_status_height(), get_src_status_width(),
            get_src_status_row(), get_src_status_col());

    /* Initialize the tty status bar window */
    if (tty_win_on)
        tty_status_win =
                newwin(get_tty_status_height(), get_tty_status_width(),
                get_tty_status_row(), get_tty_status_col());

    if_draw();

    return 0;
}
Exemple #4
0
/* if_layout: Update the layout of the screen based on current terminal size.
 * ----------
 *
 * Return Value: Zero on success, -1 on failure.
 */
static int if_layout()
{
    SWINDOW *gdb_scroller_win = NULL;
    SWINDOW *src_viewer_win = NULL;

    if (!curses_initialized)
        return -1;

    /* Verify the window size is reasonable */
    validate_window_sizes();

    /* Resize the source viewer window */
    create_swindow(&src_viewer_win, get_src_height(), get_src_width(),
        get_src_row(), get_src_col());
    if (src_viewer) {
        source_move(src_viewer, src_viewer_win);
    } else {
        src_viewer = source_new(src_viewer_win);
    }

    /* Resize the GDB I/O window */
    create_swindow(&gdb_scroller_win, get_gdb_height(), get_gdb_width(),
        get_gdb_row(), get_gdb_col());
    if (gdb_scroller) {
        scr_move(gdb_scroller, gdb_scroller_win);
    } else {
        gdb_scroller = scr_new(gdb_scroller_win);
    }

    /* Initialize the status bar window */
    create_swindow(&status_win, get_src_status_height(),
        get_src_status_width(), get_src_status_row(), get_src_status_col());

    /* Redraw the interface */
    if_draw();

    return 0;
}
Exemple #5
0
/* This is for the source window status bar */
static int get_src_status_row(void)
{
    /* Usually would be 'get_src_row() + get_src_height()' but
     * the row is 0 */
    return get_src_height();
}
Exemple #6
0
/* source_input: Handles user input to the source window.
 * -------------
 *
 *   sview:     Source viewer object
 *   key:       Keystroke received.
 */
static void source_input(struct sviewer *sview, int key)
{
  static int number_line=0;

   
  if ('0' <= key && key <= '9') {
   number_line=number_line *10 ;
   number_line=number_line+key-'0';
  } else {
    if (key!='g'){
      number_line=0;
    }
    switch (key) {
        case CGDB_KEY_UP:
        case 'k':              /* VI-style up-arrow */
            source_vscroll(sview, -1);
            break;
        case CGDB_KEY_DOWN:
        case 'j':              /* VI-style down-arrow */
            source_vscroll(sview, 1);
            break;
        case CGDB_KEY_LEFT:
        case 'h':
            source_hscroll(sview, -1);
            break;
        case CGDB_KEY_RIGHT:
        case 'l':
            source_hscroll(sview, 1);
            break;
        case CGDB_KEY_CTRL_U:  /* VI-style 1/2 page up */
            source_vscroll(sview, -(get_src_height() / 2));
            break;
        case CGDB_KEY_PPAGE:
        case CGDB_KEY_CTRL_B:  /* VI-style page up */
            source_vscroll(sview, -(get_src_height() - 1));
            break;
        case CGDB_KEY_CTRL_D:  /* VI-style 1/2 page down */
            source_vscroll(sview, (get_src_height() / 2));
            break;
        case CGDB_KEY_NPAGE:
        case CGDB_KEY_CTRL_F:  /* VI-style page down */
            source_vscroll(sview, get_src_height() - 1);
            break;
        case 'g':              /* beggining of file */
            if (last_key_pressed == 'g')
                source_set_sel_line(sview, 1);
            else
              if (number_line>0)
              {
                source_set_sel_line(sview, number_line);
                last_key_pressed=0;
                number_line=0;
              }
            break;
        case 'G':              /* end of file */
            source_set_sel_line(sview, 10000000);
            break;
        case '=':
            /* inc window by 1 */
            increase_win_height(0);
            break;
        case '-':
            /* dec window by 1 */
            decrease_win_height(0);
            break;
        case '+':
            /* inc to jump or inc tty */
            increase_win_height(1);
            break;
        case '_':
            /* dec to jump or dec tty */
            decrease_win_height(1);
            break;
        case 'o':
            /* Causes file dialog to be opened */
        {
            extern int kui_input_acceptable;

            kui_input_acceptable = 0;
            tgdb_request_ptr request_ptr;

            request_ptr = tgdb_request_inferiors_source_files(tgdb);
            handle_request(tgdb, request_ptr);
        }
            break;
        case ' ':
        {
            enum tgdb_breakpoint_action t = TGDB_BREAKPOINT_ADD;

            toggle_breakpoint(sview, t);
        }
            break;
        case 't':
        {
            enum tgdb_breakpoint_action t = TGDB_TBREAKPOINT_ADD;

            toggle_breakpoint(sview, t);
        }
            break;
        default:
            break;
    }

  }

    /* Some extended features that are set by :set sc */
    if_draw();
}
Exemple #7
0
/* This is for the source window status bar */
static int get_src_status_row(void)
{
    return get_src_row() + get_src_height();
}
Exemple #8
0
/* source_input: Handles user input to the source window.
 * -------------
 *
 *   sview:     Source viewer object
 *   key:       Keystroke received.
 */
static void source_input(struct sviewer *sview, int key)
{
    switch (key) {
        case CGDB_KEY_UP:
        case 'k': {             /* VI-style up-arrow */
            int lineno = 1;
            cgdb_string_to_int(ibuf_get(G_line_number), &lineno);
            source_vscroll(sview, -lineno);
            break;
        }
        case CGDB_KEY_DOWN:
        case 'j': {             /* VI-style down-arrow */
            int lineno = 1;
            cgdb_string_to_int(ibuf_get(G_line_number), &lineno);
            source_vscroll(sview, lineno);
            break;
        }
        case CGDB_KEY_LEFT:
        case 'h':
            source_hscroll(sview, -1);
            break;
        case CGDB_KEY_RIGHT:
        case 'l':
            source_hscroll(sview, 1);
            break;
        case CGDB_KEY_CTRL_U:  /* VI-style 1/2 page up */
            source_vscroll(sview, -(get_src_height() / 2));
            break;
        case CGDB_KEY_PPAGE:
        case CGDB_KEY_CTRL_B:  /* VI-style page up */
            source_vscroll(sview, -(get_src_height() - 1));
            break;
        case CGDB_KEY_CTRL_D:  /* VI-style 1/2 page down */
            source_vscroll(sview, (get_src_height() / 2));
            break;
        case CGDB_KEY_NPAGE:
        case CGDB_KEY_CTRL_F:  /* VI-style page down */
            source_vscroll(sview, get_src_height() - 1);
            break;
        case 'g':              /* beginning of file */
            if (last_key_pressed == 'g')
                source_set_sel_line(sview, 1);
            break;
        case 'G': {              /* end of file or a line number */
            int lineno = -1;
            cgdb_string_to_int(ibuf_get(G_line_number), &lineno);
            source_set_sel_line(sview, lineno);
            break;
        }
        case '=':
            /* inc window by 1 */
            increase_win_height(0);
            break;
        case '-':
            /* dec window by 1 */
            decrease_win_height(0);
            break;
        case '+':
            increase_win_height(1);
            break;
        case '_':
            decrease_win_height(1);
            break;
        case 'o':
            /* Causes file dialog to be opened */
        {
            extern int kui_input_acceptable;

            kui_input_acceptable = 0;

            tgdb_request_inferiors_source_files(tgdb);
        }
            break;
        case ' ':
        {
            enum tgdb_breakpoint_action t = TGDB_BREAKPOINT_ADD;

            toggle_breakpoint(sview, t);
        }
            break;
        case 't':
        {
            enum tgdb_breakpoint_action t = TGDB_TBREAKPOINT_ADD;

            toggle_breakpoint(sview, t);
        }
            break;
        default:
            break;
    }

    /* Store digits into G_line_number for 'G' command. */
    if (key >= '0' && key <= '9') {
        ibuf_addchar(G_line_number, key);
    } else {
        ibuf_clear(G_line_number);
    }

    /* Some extended features that are set by :set sc */
    if_draw();
}