Example #1
0
void
win_update_virtual(ProfWin *window)
{
    int rows, cols;
    getmaxyx(stdscr, rows, cols);
    int subwin_cols = 0;

    switch (window->type) {
    case WIN_CONSOLE:
        if (window->wins.cons.subwin) {
            subwin_cols = win_roster_cols();
            pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
            pnoutrefresh(window->wins.cons.subwin, window->wins.cons.sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1);
        } else {
            pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, cols-1);
        }
        break;
    case WIN_MUC:
        if (window->wins.muc.subwin) {
            subwin_cols = win_occpuants_cols();
            pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
            pnoutrefresh(window->wins.muc.subwin, window->wins.muc.sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1);
        } else {
            pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, cols-1);
        }
        break;
    default:
        pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, cols-1);
        break;
    }
}
Example #2
0
void
win_update_virtual(ProfWin *window)
{
    int cols = getmaxx(stdscr);

    int row_start = screen_mainwin_row_start();
    int row_end = screen_mainwin_row_end();
    if (window->layout->type == LAYOUT_SPLIT) {
        ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout;
        if (layout->subwin) {
            int subwin_cols = 0;
            if (window->type == WIN_MUC) {
                subwin_cols = win_occpuants_cols();
            } else {
                subwin_cols = win_roster_cols();
            }
            pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, (cols-subwin_cols)-1);
            pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, row_start, (cols-subwin_cols), row_end, cols-1);
        } else {
            pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, cols-1);
        }
    } else {
        pnoutrefresh(window->layout->win, window->layout->y_pos, 0, row_start, 0, row_end, cols-1);
    }
}
Example #3
0
void
win_show_subwin(ProfWin *window)
{
    int cols = getmaxx(stdscr);
    int subwin_cols = 0;

    switch (window->type) {
    case WIN_CONSOLE:
        subwin_cols = win_roster_cols();
        window->wins.cons.subwin = newpad(PAD_SIZE, subwin_cols);
        wbkgd(window->wins.cons.subwin, theme_attrs(THEME_TEXT));
        wresize(window->win, PAD_SIZE, cols - subwin_cols);
        win_redraw(window);
        break;
    case WIN_MUC:
        subwin_cols = win_occpuants_cols();
        window->wins.muc.subwin = newpad(PAD_SIZE, subwin_cols);
        wbkgd(window->wins.muc.subwin, theme_attrs(THEME_TEXT));
        wresize(window->win, PAD_SIZE, cols - subwin_cols);
        win_redraw(window);
        break;
    default:
        break;
    }
}
Example #4
0
void
win_resize(ProfWin *window)
{
    int cols = getmaxx(stdscr);

    if (window->layout->type == LAYOUT_SPLIT) {
        ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout;
        if (layout->subwin) {
            int subwin_cols = 0;
            if (window->type == WIN_CONSOLE) {
                subwin_cols = win_roster_cols();
            } else if (window->type == WIN_MUC) {
                subwin_cols = win_occpuants_cols();
            }
            wresize(layout->base.win, PAD_SIZE, cols - subwin_cols);
            wresize(layout->subwin, PAD_SIZE, subwin_cols);
            if (window->type == WIN_CONSOLE) {
                rosterwin_roster();
            } else if (window->type == WIN_MUC) {
                ProfMucWin *mucwin = (ProfMucWin *)window;
                assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
                occupantswin_occupants(mucwin->roomjid);
            }
        } else {
            wresize(layout->base.win, PAD_SIZE, cols);
        }
    } else {
        wresize(window->layout->win, PAD_SIZE, cols);
    }

    win_redraw(window);
}
Example #5
0
ProfWin*
win_create(const char * const title, win_type_t type)
{
    ProfWin *new_win = malloc(sizeof(ProfWin));
    int cols = getmaxx(stdscr);

    new_win->type = type;

    switch (new_win->type) {
    case WIN_CONSOLE:
        new_win->win = newpad(PAD_SIZE, (cols));
        wbkgd(new_win->win, theme_attrs(THEME_TEXT));
        new_win->wins.cons.subwin = NULL;
        new_win->wins.cons.sub_y_pos = 0;
        break;
    case WIN_MUC:
        if (prefs_get_boolean(PREF_OCCUPANTS)) {
            int subwin_cols = win_occpuants_cols();
            new_win->win = newpad(PAD_SIZE, cols - subwin_cols);
            wbkgd(new_win->win, theme_attrs(THEME_TEXT));
            new_win->wins.muc.subwin = newpad(PAD_SIZE, subwin_cols);;
            wbkgd(new_win->wins.muc.subwin, theme_attrs(THEME_TEXT));
        } else {
            new_win->win = newpad(PAD_SIZE, (cols));
            wbkgd(new_win->win, theme_attrs(THEME_TEXT));
            new_win->wins.muc.subwin = NULL;
        }
        new_win->wins.muc.sub_y_pos = 0;
        break;
    default:
        new_win->win = newpad(PAD_SIZE, (cols));
        wbkgd(new_win->win, theme_attrs(THEME_TEXT));
        break;
    }

    if (new_win->type == WIN_MUC_CONFIG) {
        new_win->wins.conf.form = NULL;
    }

    new_win->from = strdup(title);
    new_win->buffer = buffer_create();
    new_win->y_pos = 0;
    new_win->paged = 0;
    new_win->unread = 0;

    if (new_win->type == WIN_CHAT) {
        new_win->wins.chat.resource = NULL;
        new_win->wins.chat.is_otr = FALSE;
        new_win->wins.chat.is_trusted = FALSE;
        new_win->wins.chat.history_shown = FALSE;
    }

    scrollok(new_win->win, TRUE);

    return new_win;
}
Example #6
0
ProfWin*
win_create_muc(const char *const roomjid)
{
    ProfMucWin *new_win = malloc(sizeof(ProfMucWin));
    int cols = getmaxx(stdscr);

    new_win->window.type = WIN_MUC;

    ProfLayoutSplit *layout = malloc(sizeof(ProfLayoutSplit));
    layout->base.type = LAYOUT_SPLIT;

    if (prefs_get_boolean(PREF_OCCUPANTS)) {
        int subwin_cols = win_occpuants_cols();
        layout->base.win = newpad(PAD_SIZE, cols - subwin_cols);
        wbkgd(layout->base.win, theme_attrs(THEME_TEXT));
        layout->subwin = newpad(PAD_SIZE, subwin_cols);;
        wbkgd(layout->subwin, theme_attrs(THEME_TEXT));
    } else {
        layout->base.win = newpad(PAD_SIZE, (cols));
        wbkgd(layout->base.win, theme_attrs(THEME_TEXT));
        layout->subwin = NULL;
    }
    layout->sub_y_pos = 0;
    layout->memcheck = LAYOUT_SPLIT_MEMCHECK;
    layout->base.buffer = buffer_create();
    layout->base.y_pos = 0;
    layout->base.paged = 0;
    scrollok(layout->base.win, TRUE);
    new_win->window.layout = (ProfLayout*)layout;

    new_win->roomjid = strdup(roomjid);
    new_win->unread = 0;
    new_win->unread_mentions = FALSE;
    new_win->unread_triggers = FALSE;
    if (prefs_get_boolean(PREF_OCCUPANTS_JID)) {
        new_win->showjid = TRUE;
    } else {
        new_win->showjid = FALSE;
    }

    new_win->memcheck = PROFMUCWIN_MEMCHECK;

    return &new_win->window;
}
Example #7
0
void
win_refresh_with_subwin(ProfWin *window)
{
    int rows, cols;
    getmaxyx(stdscr, rows, cols);
    int subwin_cols = 0;

    if (window->type == WIN_MUC) {
        ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout;
        subwin_cols = win_occpuants_cols();
        pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
        pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1);
    } else if (window->type == WIN_CONSOLE) {
        ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout;
        subwin_cols = win_roster_cols();
        pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
        pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1);
    }
}
Example #8
0
void
win_refresh_with_subwin(ProfWin *window)
{
    int cols = getmaxx(stdscr);
    int subwin_cols = 0;

    int row_start = screen_mainwin_row_start();
    int row_end = screen_mainwin_row_end();
    if (window->type == WIN_MUC) {
        ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout;
        subwin_cols = win_occpuants_cols();
        pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, (cols-subwin_cols)-1);
        pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, row_start, (cols-subwin_cols), row_end, cols-1);
    } else if (window->type == WIN_CONSOLE) {
        ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout;
        subwin_cols = win_roster_cols();
        pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, (cols-subwin_cols)-1);
        pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, row_start, (cols-subwin_cols), row_end, cols-1);
    }
}
Example #9
0
void
win_show_subwin(ProfWin *window)
{
    int cols = getmaxx(stdscr);
    int subwin_cols = 0;

    if (window->layout->type != LAYOUT_SPLIT) {
        return;
    }

    if (window->type == WIN_MUC) {
        subwin_cols = win_occpuants_cols();
    } else if (window->type == WIN_CONSOLE) {
        subwin_cols = win_roster_cols();
    }

    ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout;
    layout->subwin = newpad(PAD_SIZE, subwin_cols);
    wbkgd(layout->subwin, theme_attrs(THEME_TEXT));
    wresize(layout->base.win, PAD_SIZE, cols - subwin_cols);
    win_redraw(window);
}
Example #10
0
void
win_update_virtual(ProfWin *window)
{
    int rows, cols;
    getmaxyx(stdscr, rows, cols);

    if (window->layout->type == LAYOUT_SPLIT) {
        ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout;
        if (layout->subwin) {
            int subwin_cols = 0;
            if (window->type == WIN_MUC) {
                subwin_cols = win_occpuants_cols();
            } else {
                subwin_cols = win_roster_cols();
            }
            pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
            pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1);
        } else {
            pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, cols-1);
        }
    } else {
        pnoutrefresh(window->layout->win, window->layout->y_pos, 0, 1, 0, rows-3, cols-1);
    }
}