1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-22 19:45:54 -04:00

Added seperate values for roster and occupants win sizes

This commit is contained in:
James Booth 2014-11-15 22:59:13 +00:00
parent 3642797146
commit 3a778cc974
3 changed files with 40 additions and 18 deletions

View File

@ -54,6 +54,7 @@
#define CEILING(X) (X-(int)(X) > 0 ? (int)(X+1) : (int)(X))
static int roster_win_percent = 20;
static int occupants_win_percent = 20;
static void _win_print(ProfWin *window, const char show_char, const char * const date_fmt,
int flags, int attrs, const char * const from, const char * const message);
@ -66,6 +67,13 @@ win_roster_cols(void)
return CEILING( (((double)cols) / 100) * roster_win_percent);
}
int
win_occpuants_cols(void)
{
int cols = getmaxx(stdscr);
return CEILING( (((double)cols) / 100) * occupants_win_percent);
}
ProfWin*
win_create(const char * const title, win_type_t type)
{
@ -74,7 +82,7 @@ win_create(const char * const title, win_type_t type)
int cols = getmaxx(stdscr);
if (type == WIN_MUC && prefs_get_boolean(PREF_OCCUPANTS)) {
int subwin_cols = win_roster_cols();
int subwin_cols = win_occpuants_cols();
new_win->win = newpad(PAD_SIZE, cols - subwin_cols);
wbkgd(new_win->win, COLOUR_TEXT);
@ -121,7 +129,12 @@ win_show_subwin(ProfWin *window)
{
if (!window->subwin) {
int cols = getmaxx(stdscr);
int subwin_cols = win_roster_cols();
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();
}
window->subwin = newpad(PAD_SIZE, subwin_cols);
wbkgd(window->subwin, COLOUR_TEXT);
@ -149,9 +162,14 @@ win_update_virtual(ProfWin *window)
{
int rows, cols;
getmaxyx(stdscr, rows, cols);
int subwin_cols = win_roster_cols();
if (((window->type == WIN_MUC) || (window->type == WIN_CONSOLE)) && (window->subwin)) {
if (window->subwin) {
int subwin_cols = 0;
if (window->type == WIN_MUC) {
subwin_cols = win_occpuants_cols();
} else if (window->type == WIN_CONSOLE) {
subwin_cols = win_roster_cols();
}
pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
pnoutrefresh(window->subwin, window->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1);
} else {

View File

@ -105,6 +105,7 @@ void win_redraw(ProfWin *window);
void win_hide_subwin(ProfWin *window);
void win_show_subwin(ProfWin *window);
int win_roster_cols(void);
int win_occpuants_cols(void);
void win_printline_nowrap(WINDOW *win, char *msg);
#endif

View File

@ -285,20 +285,23 @@ wins_get_total_unread(void)
void
wins_resize_all(void)
{
int rows, cols;
getmaxyx(stdscr, rows, cols);
int roster_cols = win_roster_cols();
int cols = getmaxx(stdscr);
GList *values = g_hash_table_get_values(windows);
GList *curr = values;
while (curr != NULL) {
ProfWin *window = curr->data;
if (((window->type == WIN_MUC) || (window->type == WIN_CONSOLE)) && (window->subwin)) {
wresize(window->win, PAD_SIZE, cols - roster_cols);
wresize(window->subwin, PAD_SIZE, roster_cols);
int subwin_cols = 0;
if (window->type == WIN_MUC) {
subwin_cols = win_occpuants_cols();
wresize(window->win, PAD_SIZE, cols - subwin_cols);
wresize(window->subwin, PAD_SIZE, subwin_cols);
ui_muc_roster(window->from);
} else if (window->type == WIN_CONSOLE) {
subwin_cols = win_roster_cols();
wresize(window->win, PAD_SIZE, cols - subwin_cols);
wresize(window->subwin, PAD_SIZE, subwin_cols);
ui_roster();
}
} else {
@ -310,12 +313,7 @@ wins_resize_all(void)
g_list_free(values);
ProfWin *current_win = wins_get_current();
if (((current_win->type == WIN_MUC) || (current_win->type == WIN_CONSOLE)) && (current_win->subwin)) {
pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, (cols-roster_cols)-1);
pnoutrefresh(current_win->subwin, current_win->sub_y_pos, 0, 1, (cols-roster_cols), rows-3, cols-1);
} else {
pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, cols-1);
}
win_update_virtual(current_win);
}
void
@ -337,14 +335,19 @@ wins_show_subwin(ProfWin *window)
{
int rows, cols;
getmaxyx(stdscr, rows, cols);
int roster_cols = win_roster_cols();
int subwin_cols = 0;
win_show_subwin(window);
ProfWin *current_win = wins_get_current();
if (current_win->type == WIN_MUC) {
subwin_cols = win_occpuants_cols();
} else if (current_win->type == WIN_CONSOLE) {
subwin_cols = win_roster_cols();
}
if ((current_win->type == WIN_MUC) || (current_win->type == WIN_CONSOLE)) {
pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, (cols-roster_cols)-1);
pnoutrefresh(current_win->subwin, current_win->sub_y_pos, 0, 1, (cols-roster_cols), rows-3, cols-1);
pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
pnoutrefresh(current_win->subwin, current_win->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1);
}
}