예제 #1
0
파일: ui.c 프로젝트: jens-na/abook-call
int
statusline_msg(const char *msg)
{
    int c;

    clear_statusline();
    statusline_addstr(msg);
    c = getch();
#ifdef DEBUG
    fprintf(stderr, "statusline_msg(\"%s\")\n", msg);
#endif
    clear_statusline();

    return c;
}
예제 #2
0
파일: ui.c 프로젝트: jens-na/abook-call
void
ui_print_database()
{
    FILE *handle;
    char *command = opt_get_str(STR_PRINT_COMMAND);
    int mode;

    if(list_is_empty())
        return;

    switch(statusline_askchoice(_("Print <a>ll, print <s>elected, or <c>ancel?"), S_("keybindings:all/selected/cancel|asc"), 3)) {
    case 1:
        mode = ENUM_ALL;
        break;
    case 2:
        if( !selected_items() ) {
            statusline_msg(_("No selected items"));
            return;
        }
        mode = ENUM_SELECTED;
        break;
    default:
        refresh_screen();
        return;
    }

    clear_statusline();

    if( ! *command || (handle = popen(command, "w")) == NULL)
        return;

    fexport("text", handle, mode);

    pclose(handle);
}
예제 #3
0
파일: ui.c 프로젝트: jens-na/abook-call
void
ui_find(int next)
{
    int item = -1;
    static char findstr[MAX_FIELD_LEN];
    int search_fields[] = {NAME, EMAIL, NICK, -1};

    clear_statusline();

    if(next) {
        if(!*findstr)
            return;
    } else {
        char *s;
        s = ui_readline("/", findstr, MAX_FIELD_LEN - 1, 0);
        refresh_screen();
        if(s == NULL) {
            return; /* user cancelled (ctrl-G) */
        } else {
            strncpy(findstr, s, MAX_FIELD_LEN);
            free(s);
        }
    }

    if( (item = find_item(findstr, list_get_curitem() + !!next,
                          search_fields)) < 0 &&
            (item = find_item(findstr, 0, search_fields)) >= 0)
        statusline_addstr(_("Search hit bottom, continuing at top"));

    if(item >= 0) {
        list_set_curitem(item);
        refresh_list();
    }
}
예제 #4
0
파일: ui.c 프로젝트: jens-na/abook-call
char *
ask_filename(const char *prompt)
{
    char *buf = NULL;

    clear_statusline();

    buf = ui_readline(prompt, NULL, -1, 1);

    return buf;
}
예제 #5
0
static void
clear_statusline_timer_proc(XtPointer client_data, XtIntervalId *id)
{
    UNUSED(client_data);
    UNUSED(id);
    
    if (clear_timeout_id) {
	clear_statusline();
	clear_timeout_id = 0;
    }
}
예제 #6
0
파일: ui.c 프로젝트: jens-na/abook-call
void
ui_remove_items()
{
    if(list_is_empty())
        return;

    if(statusline_ask_boolean(_("Remove selected item(s)"), TRUE))
        remove_selected_items();

    clear_statusline();
    refresh_list();
}
예제 #7
0
파일: ui.c 프로젝트: jens-na/abook-call
void
display_help(int help)
{
    int i;
    char **tbl;
    WINDOW *helpw;

    switch(help) {
    case HELP_MAIN:
        tbl = mainhelp;
        break;
    case HELP_EDITOR:
        tbl = editorhelp;
        break;
    default:
        return;
    }

    helpw = newwin(LINES - 5, COLS - 6, 2, 3);
    erase();
    headerline(_("help"));

    for(i = 0; tbl[i] != NULL; i++) {
        waddstr(helpw, gettext(tbl[i]));
        if( (!((i + 1) % (LINES - 8))) ||
                (tbl[i + 1] == NULL) ) {
            refresh();
            wrefresh(helpw);
            refresh_statusline();
            if(statusline_msg(_("Press any key to continue..."))
                    == 'q')
                break;
            wclear(helpw);
        }
    }

    clear_statusline();
    delwin(helpw);
}
예제 #8
0
파일: ui.c 프로젝트: jens-na/abook-call
int
statusline_ask_boolean(const char *msg, int def)
{
    int ret;
    char *msg2 = strconcat(msg,  def ? _(" (Y/n)?") : _(" (y/N)?"), NULL);
    char ch;

    statusline_addstr(msg2);

    free(msg2);

    ch = tolower(getch());

    if(ch == *(S_("keybinding for no|n")))
        ret = FALSE;
    else if(ch == *(S_("keybinding for yes|y")))
        ret = TRUE;
    else
        ret = def;

    clear_statusline();

    return ret;
}