Esempio n. 1
0
static void friendlist_onKey(ToxWindow *self, Tox *m, wint_t key)
{
    if (num_friends == 0)
        return;

    int f = friendlist_index[num_selected];

    /* lock screen and force decision on deletion popup */
    if (pendingdelete.active) {
        if (key == 'y' || key == 'n')
            del_friend_deactivate(self, m, key);

        return;
    }

    if (key == '\n') {
        /* Jump to chat window if already open */
        if (friends[f].chatwin != -1) {
            set_active_window(friends[f].chatwin);
        } else if (get_num_active_windows() < MAX_WINDOWS_NUM) {
            friends[f].chatwin = add_window(m, new_chat(m, friends[f].num));
            set_active_window(friends[f].chatwin);
        } else {
            prep_prompt_win();
            wattron(prompt->window, COLOR_PAIR(RED));
            wprintw(prompt->window, "* Warning: Too many windows are open.\n");
            wattron(prompt->window, COLOR_PAIR(RED));

            alert_window(prompt, WINDOW_ALERT_1, true);
        }
    } else if (key == KEY_DC) {
        del_friend_activate(self, m, f);
    } else {
        select_friend(self, m, key);
    }
}
Esempio n. 2
0
static void friendlist_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
{
    if (num_friends == 0)
        return;

    int f = friendlist_index[num_selected];

    /* lock screen and force decision on deletion popup */
    if (pendingdelete.active) {
        if (key == 'y' || key == 'n')
            del_friend_deactivate(self, m, key);

        return;
    }

    if (key != ltr) {
        if (key == '\n') {
            /* Jump to chat window if already open */
            if (friends[f].chatwin != -1) {
                set_active_window(friends[f].chatwin);
            } else if (get_num_active_windows() < MAX_WINDOWS_NUM) {
                friends[f].chatwin = add_window(m, new_chat(m, friends[f].num));
                set_active_window(friends[f].chatwin);
            } else {
                uint8_t *msg = "* Warning: Too many windows are open.";
                line_info_add(prompt, NULL, NULL, NULL, msg, SYS_MSG, 0, RED);

                alert_window(prompt, WINDOW_ALERT_1, true);
            }
        } else if (key == KEY_DC) {
            del_friend_activate(self, m, f);
        } else {
            select_friend(self, m, key);
        }
    }
}
Esempio n. 3
0
static void friendlist_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
{

    if (self->help->active) {
        help_onKey(self, key);
        return;
    }

    if (key == 'h') {
        help_init_menu(self);
        return;
    }

    if (!blocklist_view && !Friends.num_friends && (key != KEY_RIGHT && key != KEY_LEFT))
        return;

    if (blocklist_view && !Blocked.num_blocked && (key != KEY_RIGHT && key != KEY_LEFT))
        return;

    int f = 0;

    if (blocklist_view == 1 && Blocked.num_blocked)
        f = Blocked.index[Blocked.num_selected];
    else if (Friends.num_friends)
        f = Friends.index[Friends.num_selected];

    /* lock screen and force decision on deletion popup */
    if (PendingDelete.active) {
        if (key == 'y' || key == 'n')
            del_friend_deactivate(self, m, key);

        return;
    }

    if (key == ltr)
        return;

    switch (key) {
        case '\n':
            if (blocklist_view)
                break;

            /* Jump to chat window if already open */
            if (Friends.list[f].chatwin != -1) {
                set_active_window(Friends.list[f].chatwin);
            } else if (get_num_active_windows() < MAX_WINDOWS_NUM) {
                Friends.list[f].chatwin = add_window(m, new_chat(m, Friends.list[f].num));
                set_active_window(Friends.list[f].chatwin);
            } else {
                const char *msg = "* Warning: Too many windows are open.";
                line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, RED, msg);
                sound_notify(prompt, notif_error, NT_WNDALERT_1, NULL);
            }

            break;

        case KEY_DC:
            del_friend_activate(self, m, f);
            break;

        case 'b':
            if (!blocklist_view)
                block_friend(m, f);
            else
                unblock_friend(m, f);
            break;

        case KEY_RIGHT:
        case KEY_LEFT:
            blocklist_view ^= 1;
            break;

        default:
            if (blocklist_view == 0)
                select_friend(self, key, &Friends.num_selected, Friends.num_friends);
            else
                select_friend(self, key, &Blocked.num_selected, Blocked.num_blocked);
            break;
    }
}