1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Implemented /occupants hide

This commit is contained in:
James Booth 2014-10-09 21:27:16 +01:00
parent 778a495fbd
commit 73262221f5
5 changed files with 33 additions and 4 deletions

View File

@ -2797,7 +2797,7 @@ _ui_room_hide_occupants(const char * const room)
{
ProfWin *window = wins_get_by_recipient(room);
if (window && window->subwin) {
cons_debug("Hiding occupants");
wins_hide_subwin(window);
}
}
@ -3097,7 +3097,7 @@ ui_init_module(void)
ui_handle_room_role_list_error = _ui_handle_room_role_list_error;
ui_handle_room_role_list = _ui_handle_room_role_list;
ui_muc_roster = _ui_muc_roster;
ui_room_show_occupants = _ui_room_show_occupants;
ui_room_show_occupants = _ui_room_show_occupants;
ui_room_hide_occupants = _ui_room_hide_occupants;
}

View File

@ -88,6 +88,20 @@ win_create(const char * const title, int cols, win_type_t type)
return new_win;
}
void
win_hide_subwin(ProfWin *window)
{
if (window->subwin) {
delwin(window->subwin);
}
window->subwin = NULL;
window->sub_y_pos = 0;
int cols = getmaxx(stdscr);
wresize(window->win, PAD_SIZE, cols);
win_redraw(window);
}
void
win_free(ProfWin* window)
{
@ -107,7 +121,7 @@ win_update_virtual(ProfWin *window)
int rows, cols;
getmaxyx(stdscr, rows, cols);
if (window->type == WIN_MUC) {
if ((window->type == WIN_MUC) && (window->subwin)) {
pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, ((cols/OCCUPANT_WIN_RATIO) * (OCCUPANT_WIN_RATIO-1)) -1);
pnoutrefresh(window->subwin, window->sub_y_pos, 0, 1, (cols/OCCUPANT_WIN_RATIO) * (OCCUPANT_WIN_RATIO-1), rows-3, cols-1);
} else {

View File

@ -102,5 +102,6 @@ void win_save_print(ProfWin *window, const char show_char, GTimeVal *tstamp, int
void win_save_println(ProfWin *window, const char * const message);
void win_save_newline(ProfWin *window);
void win_redraw(ProfWin *window);
void win_hide_subwin(ProfWin *window);
#endif

View File

@ -305,7 +305,7 @@ wins_resize_all(void)
g_list_free(values);
ProfWin *current_win = wins_get_current();
if (current_win->type == WIN_MUC) {
if ((current_win->type == WIN_MUC) && (current_win->subwin)) {
pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, ((cols/OCCUPANT_WIN_RATIO) * (OCCUPANT_WIN_RATIO-1)) -1);
pnoutrefresh(current_win->subwin, current_win->sub_y_pos, 0, 1, (cols/OCCUPANT_WIN_RATIO) * (OCCUPANT_WIN_RATIO-1), rows-3, cols-1);
} else {
@ -313,6 +313,19 @@ wins_resize_all(void)
}
}
void
wins_hide_subwin(ProfWin *window)
{
int rows, cols;
getmaxyx(stdscr, rows, cols);
win_hide_subwin(window);
ProfWin *current_win = wins_get_current();
if (current_win->type == WIN_MUC) {
pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, cols-1);
}
}
gboolean
wins_duck_exists(void)
{

View File

@ -63,5 +63,6 @@ GList * wins_get_nums(void);
gboolean wins_xmlconsole_exists(void);
ProfWin * wins_get_xmlconsole(void);
gboolean wins_swap(int source_win, int target_win);
void wins_hide_subwin(ProfWin *window);
#endif