コード例 #1
0
ファイル: cgo.c プロジェクト: Happy-Ferret/cgo
int follow_link(int key)
{
    link_t  *link;

    for (link = links; link; link = link->next) {
        if (link->key != key)
            continue;
        switch (link->which) {
            case '0':
                view_file(&config.cmd_text[0], link->host, link->port, link->selector);
                break;
            case '1':
                view_directory(link->host, link->port, link->selector, 1);
                break;
            case '7':
                view_search(link->host, link->port, link->selector);
                break;
            case '5':
            case '9':
                view_download(link->host, link->port, link->selector);
                break;
            case '8':
                view_telnet(link->host, link->port);
                break;
            case 'g':
            case 'I':
            case 'p':
                view_file(&config.cmd_image[0], link->host, link->port, link->selector);
                break;
            case 'h':
                view_file(&config.cmd_browser[0], link->host, link->port, link->selector);
                break;
            case 's':
                view_file(&config.cmd_player[0], link->host, link->port, link->selector);
                break;
            default:
                printf("missing handler [%c]\n", link->which);
                break;
        }
        return 1; /* return the array is broken after view! */
    }
    return 0;
}
コード例 #2
0
int
xdiff_view (const char *file1, const char *file2)
{
    int error;
    WDiff *view;
    WButtonBar *bar;
    Dlg_head *view_dlg;

    /* Create dialog and widgets, put them on the dialog */
    view_dlg =
	create_dlg(0, 0, LINES, COLS, NULL, view_dialog_callback,
		   "[Binary Diff Viewer]", NULL, DLG_WANT_TAB);

    view = g_new0(WDiff, 1);

    init_widget(&view->widget, 0, 0, LINES - 1, COLS,
		(callback_fn)view_callback,
		(mouse_h)view_event);

    widget_want_cursor(view->widget, 0);

    bar = buttonbar_new(1);

    add_widget(view_dlg, bar);
    add_widget(view_dlg, view);

    error = view_init(view, file1, file2);

    /* Please note that if you add another widget,
     * you have to modify view_adjust_size to
     * be aware of it
     */
    if (!error) {
	run_dlg(view_dlg);
	view_search(view, -1);
	view_fini(view, 1);
    }
    destroy_dlg(view_dlg);

    return error;
}
コード例 #3
0
static cb_ret_t
view_handle_key (WDiff *view, int c)
{
    struct display_file *lf = &view->df[view->ord];
    struct display_file *rf = &view->df[view->ord ^ 1];

    c = convert_from_input_c(c);

    switch (c) {
	case 'l':
	    view->display_numbers ^= 1;
	    view->new_frame = 1;
	    return MSG_HANDLED;

	case 'f':
	    view->full ^= 1;
	    view->new_frame = 1;
	    return MSG_HANDLED;

	case '=': /* XXX testing only */
	    if (!view->full) {
		view->bias = 0;
		view->new_frame = 1;
	    }
	    return MSG_HANDLED;

	case '>': /* XXX testing only */
	    if (!view->full) {
		view_compute_split(view, 1);
		view->new_frame = 1;
	    }
	    return MSG_HANDLED;

	case '<': /* XXX testing only */
	    if (!view->full) {
		view_compute_split(view, -1);
		view->new_frame = 1;
	    }
	    return MSG_HANDLED;

	case '+':
	    if (view->subtract) {
		view->subtract--;
		view->new_frame = 1;
	    }
	    return MSG_HANDLED;
	case '-':
	    view->subtract++;
	    view->new_frame = 1;
	    return MSG_HANDLED;

	case '1':
	    lf->move = 1;
	    rf->move ^= 1;
	    return MSG_HANDLED;
	case '2':
	    lf->move ^= 1;
	    rf->move = 1;
	    return MSG_HANDLED;

	case XCTRL('u'): {
	    view->ord ^= 1;
	    return MSG_HANDLED;
	}

	case XCTRL('r'):
	    view_redo(view);
	    return MSG_HANDLED;

	case 'n':
	    find_next_hunk(view);
	    return MSG_HANDLED;

	case 'p':
	    find_prev_hunk(view);
	    return MSG_HANDLED;

	case KEY_DC:
	    view->last_found = -1;
	    return MSG_HANDLED;

	case KEY_F(4):
	    view_edit(view, view->ord);
	    return MSG_HANDLED;

	case KEY_F(14):
	    view_edit(view, view->ord ^ 1);
	    return MSG_HANDLED;

	case KEY_F(17):
	    view_search(view, 1);
	    return MSG_HANDLED;

	case KEY_HOME:
	case ALT ('<'):
	case KEY_M_CTRL | KEY_PPAGE:
	    view->last_found = -1;
	    if (lf->move) lf->offs = 0;
	    if (rf->move) rf->offs = 0;
	    return MSG_HANDLED;

	case KEY_END:
	case ALT ('>'):
	case KEY_M_CTRL | KEY_NPAGE:
	    view->last_found = -1;
	    if (lf->move) lf->offs = view->max - 1;
	    if (rf->move) rf->offs = view->max - 1;
	    return MSG_HANDLED;

	case KEY_UP:
	    if (lf->move) lf->offs -= view->nbytes;
	    if (rf->move) rf->offs -= view->nbytes;
	    return MSG_HANDLED;

	case KEY_DOWN:
	    if (lf->move) lf->offs += view->nbytes;
	    if (rf->move) rf->offs += view->nbytes;
	    return MSG_HANDLED;

	case KEY_NPAGE:
	    if (lf->move) lf->offs += view->pbytes;
	    if (rf->move) rf->offs += view->pbytes;
	    return MSG_HANDLED;

	case KEY_PPAGE:
	    if (lf->move) lf->offs -= view->pbytes;
	    if (rf->move) rf->offs -= view->pbytes;
	    return MSG_HANDLED;

	case KEY_LEFT:
	    if (lf->move) lf->offs--;
	    if (rf->move) rf->offs--;
	    return MSG_HANDLED;

	case KEY_RIGHT:
	    if (lf->move) lf->offs++;
	    if (rf->move) rf->offs++;
	    return MSG_HANDLED;

	case KEY_M_CTRL | KEY_LEFT:
	    if (lf->move) lf->offs -= 16;
	    if (rf->move) rf->offs -= 16;
	    return MSG_HANDLED;

	case KEY_M_CTRL | KEY_RIGHT:
	    if (lf->move) lf->offs += 16;
	    if (rf->move) rf->offs += 16;
	    return MSG_HANDLED;

	case XCTRL('o'):
	    view_other_cmd();
	    return MSG_HANDLED;

	case 't':
	    diff_view(view->file[0], view->file[1]);
	    return MSG_HANDLED;

	case 'q':
	case ESC_CHAR:
	    view->view_quit = 1;
	    return MSG_HANDLED;

	case '\n':
	    return MSG_HANDLED;

#ifdef HAVE_CHARSET
	case XCTRL ('t'):
	    do_select_codepage ();
	    view_update (view);
	    return MSG_HANDLED;
#endif				/* HAVE_CHARSET */
    }

    /* Key not used */
    return MSG_NOT_HANDLED;
}
コード例 #4
0
static void
view_search_cmd (WDiff *view)
{
    view_search(view, 0);
}