mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added union for window types
This commit is contained in:
parent
0f7519663d
commit
0ce924465f
134
src/ui/core.c
134
src/ui/core.c
@ -695,7 +695,7 @@ _ui_redraw_all_room_rosters(void)
|
|||||||
while (curr != NULL) {
|
while (curr != NULL) {
|
||||||
int num = GPOINTER_TO_INT(curr->data);
|
int num = GPOINTER_TO_INT(curr->data);
|
||||||
ProfWin *window = wins_get_by_num(num);
|
ProfWin *window = wins_get_by_num(num);
|
||||||
if (window->type == WIN_MUC && window->subwin) {
|
if (window->type == WIN_MUC && window->wins.muc.subwin) {
|
||||||
char *room = window->from;
|
char *room = window->from;
|
||||||
ui_muc_roster(room);
|
ui_muc_roster(room);
|
||||||
}
|
}
|
||||||
@ -715,7 +715,7 @@ _ui_hide_all_room_rosters(void)
|
|||||||
while (curr != NULL) {
|
while (curr != NULL) {
|
||||||
int num = GPOINTER_TO_INT(curr->data);
|
int num = GPOINTER_TO_INT(curr->data);
|
||||||
ProfWin *window = wins_get_by_num(num);
|
ProfWin *window = wins_get_by_num(num);
|
||||||
if (window->type == WIN_MUC && window->subwin) {
|
if (window->type == WIN_MUC && window->wins.muc.subwin) {
|
||||||
char *room = window->from;
|
char *room = window->from;
|
||||||
ui_room_hide_occupants(room);
|
ui_room_hide_occupants(room);
|
||||||
}
|
}
|
||||||
@ -735,7 +735,7 @@ _ui_show_all_room_rosters(void)
|
|||||||
while (curr != NULL) {
|
while (curr != NULL) {
|
||||||
int num = GPOINTER_TO_INT(curr->data);
|
int num = GPOINTER_TO_INT(curr->data);
|
||||||
ProfWin *window = wins_get_by_num(num);
|
ProfWin *window = wins_get_by_num(num);
|
||||||
if (window->type == WIN_MUC && window->subwin == NULL) {
|
if (window->type == WIN_MUC && window->wins.muc.subwin == NULL) {
|
||||||
char *room = window->from;
|
char *room = window->from;
|
||||||
ui_room_show_occupants(room);
|
ui_room_show_occupants(room);
|
||||||
}
|
}
|
||||||
@ -2875,14 +2875,14 @@ _ui_roster_contact(PContact contact)
|
|||||||
(prefs_get_boolean(PREF_ROSTER_OFFLINE)))) {
|
(prefs_get_boolean(PREF_ROSTER_OFFLINE)))) {
|
||||||
theme_item_t presence_colour = theme_main_presence_attrs(presence);
|
theme_item_t presence_colour = theme_main_presence_attrs(presence);
|
||||||
|
|
||||||
wattron(window->subwin, theme_attrs(presence_colour));
|
wattron(window->wins.cons.subwin, theme_attrs(presence_colour));
|
||||||
|
|
||||||
GString *msg = g_string_new(" ");
|
GString *msg = g_string_new(" ");
|
||||||
g_string_append(msg, name);
|
g_string_append(msg, name);
|
||||||
win_printline_nowrap(window->subwin, msg->str);
|
win_printline_nowrap(window->wins.cons.subwin, msg->str);
|
||||||
g_string_free(msg, TRUE);
|
g_string_free(msg, TRUE);
|
||||||
|
|
||||||
wattroff(window->subwin, theme_attrs(presence_colour));
|
wattroff(window->wins.cons.subwin, theme_attrs(presence_colour));
|
||||||
|
|
||||||
if (prefs_get_boolean(PREF_ROSTER_RESOURCE)) {
|
if (prefs_get_boolean(PREF_ROSTER_RESOURCE)) {
|
||||||
GList *resources = p_contact_get_available_resources(contact);
|
GList *resources = p_contact_get_available_resources(contact);
|
||||||
@ -2891,14 +2891,14 @@ _ui_roster_contact(PContact contact)
|
|||||||
Resource *resource = curr_resource->data;
|
Resource *resource = curr_resource->data;
|
||||||
const char *resource_presence = string_from_resource_presence(resource->presence);
|
const char *resource_presence = string_from_resource_presence(resource->presence);
|
||||||
theme_item_t resource_presence_colour = theme_main_presence_attrs(resource_presence);
|
theme_item_t resource_presence_colour = theme_main_presence_attrs(resource_presence);
|
||||||
wattron(window->subwin, theme_attrs(resource_presence_colour));
|
wattron(window->wins.cons.subwin, theme_attrs(resource_presence_colour));
|
||||||
|
|
||||||
GString *msg = g_string_new(" ");
|
GString *msg = g_string_new(" ");
|
||||||
g_string_append(msg, resource->name);
|
g_string_append(msg, resource->name);
|
||||||
win_printline_nowrap(window->subwin, msg->str);
|
win_printline_nowrap(window->wins.cons.subwin, msg->str);
|
||||||
g_string_free(msg, TRUE);
|
g_string_free(msg, TRUE);
|
||||||
|
|
||||||
wattroff(window->subwin, theme_attrs(resource_presence_colour));
|
wattroff(window->wins.cons.subwin, theme_attrs(resource_presence_colour));
|
||||||
|
|
||||||
curr_resource = g_list_next(curr_resource);
|
curr_resource = g_list_next(curr_resource);
|
||||||
}
|
}
|
||||||
@ -2912,9 +2912,9 @@ static void
|
|||||||
_ui_roster_contacts_by_presence(const char * const presence, char *title)
|
_ui_roster_contacts_by_presence(const char * const presence, char *title)
|
||||||
{
|
{
|
||||||
ProfWin *window = wins_get_console();
|
ProfWin *window = wins_get_console();
|
||||||
wattron(window->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
wattron(window->wins.cons.subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||||
win_printline_nowrap(window->subwin, title);
|
win_printline_nowrap(window->wins.cons.subwin, title);
|
||||||
wattroff(window->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
wattroff(window->wins.cons.subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||||
GSList *contacts = roster_get_contacts_by_presence(presence);
|
GSList *contacts = roster_get_contacts_by_presence(presence);
|
||||||
if (contacts) {
|
if (contacts) {
|
||||||
GSList *curr_contact = contacts;
|
GSList *curr_contact = contacts;
|
||||||
@ -2931,12 +2931,12 @@ static void
|
|||||||
_ui_roster_contacts_by_group(char *group)
|
_ui_roster_contacts_by_group(char *group)
|
||||||
{
|
{
|
||||||
ProfWin *window = wins_get_console();
|
ProfWin *window = wins_get_console();
|
||||||
wattron(window->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
wattron(window->wins.cons.subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||||
GString *title = g_string_new(" -");
|
GString *title = g_string_new(" -");
|
||||||
g_string_append(title, group);
|
g_string_append(title, group);
|
||||||
win_printline_nowrap(window->subwin, title->str);
|
win_printline_nowrap(window->wins.cons.subwin, title->str);
|
||||||
g_string_free(title, TRUE);
|
g_string_free(title, TRUE);
|
||||||
wattroff(window->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
wattroff(window->wins.cons.subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||||
GSList *contacts = roster_get_group(group);
|
GSList *contacts = roster_get_group(group);
|
||||||
if (contacts) {
|
if (contacts) {
|
||||||
GSList *curr_contact = contacts;
|
GSList *curr_contact = contacts;
|
||||||
@ -2955,9 +2955,9 @@ _ui_roster_contacts_by_no_group(void)
|
|||||||
ProfWin *window = wins_get_console();
|
ProfWin *window = wins_get_console();
|
||||||
GSList *contacts = roster_get_nogroup();
|
GSList *contacts = roster_get_nogroup();
|
||||||
if (contacts) {
|
if (contacts) {
|
||||||
wattron(window->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
wattron(window->wins.cons.subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||||
win_printline_nowrap(window->subwin, " -no group");
|
win_printline_nowrap(window->wins.cons.subwin, " -no group");
|
||||||
wattroff(window->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
wattroff(window->wins.cons.subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||||
GSList *curr_contact = contacts;
|
GSList *curr_contact = contacts;
|
||||||
while (curr_contact) {
|
while (curr_contact) {
|
||||||
PContact contact = curr_contact->data;
|
PContact contact = curr_contact->data;
|
||||||
@ -2975,7 +2975,7 @@ _ui_roster(void)
|
|||||||
if (window) {
|
if (window) {
|
||||||
char *by = prefs_get_string(PREF_ROSTER_BY);
|
char *by = prefs_get_string(PREF_ROSTER_BY);
|
||||||
if (g_strcmp0(by, "presence") == 0) {
|
if (g_strcmp0(by, "presence") == 0) {
|
||||||
werase(window->subwin);
|
werase(window->wins.cons.subwin);
|
||||||
_ui_roster_contacts_by_presence("chat", " -Available for chat");
|
_ui_roster_contacts_by_presence("chat", " -Available for chat");
|
||||||
_ui_roster_contacts_by_presence("online", " -Online");
|
_ui_roster_contacts_by_presence("online", " -Online");
|
||||||
_ui_roster_contacts_by_presence("away", " -Away");
|
_ui_roster_contacts_by_presence("away", " -Away");
|
||||||
@ -2985,7 +2985,7 @@ _ui_roster(void)
|
|||||||
_ui_roster_contacts_by_presence("offline", " -Offline");
|
_ui_roster_contacts_by_presence("offline", " -Offline");
|
||||||
}
|
}
|
||||||
} else if (g_strcmp0(by, "group") == 0) {
|
} else if (g_strcmp0(by, "group") == 0) {
|
||||||
werase(window->subwin);
|
werase(window->wins.cons.subwin);
|
||||||
GSList *groups = roster_get_groups();
|
GSList *groups = roster_get_groups();
|
||||||
GSList *curr_group = groups;
|
GSList *curr_group = groups;
|
||||||
while (curr_group) {
|
while (curr_group) {
|
||||||
@ -2997,10 +2997,10 @@ _ui_roster(void)
|
|||||||
} else {
|
} else {
|
||||||
GSList *contacts = roster_get_contacts();
|
GSList *contacts = roster_get_contacts();
|
||||||
if (contacts) {
|
if (contacts) {
|
||||||
werase(window->subwin);
|
werase(window->wins.cons.subwin);
|
||||||
wattron(window->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
wattron(window->wins.cons.subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||||
win_printline_nowrap(window->subwin, " -Roster");
|
win_printline_nowrap(window->wins.cons.subwin, " -Roster");
|
||||||
wattroff(window->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
wattroff(window->wins.cons.subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||||
GSList *curr_contact = contacts;
|
GSList *curr_contact = contacts;
|
||||||
while (curr_contact) {
|
while (curr_contact) {
|
||||||
PContact contact = curr_contact->data;
|
PContact contact = curr_contact->data;
|
||||||
@ -3021,88 +3021,88 @@ _ui_muc_roster(const char * const room)
|
|||||||
if (window) {
|
if (window) {
|
||||||
GList *occupants = muc_roster(room);
|
GList *occupants = muc_roster(room);
|
||||||
if (occupants) {
|
if (occupants) {
|
||||||
werase(window->subwin);
|
werase(window->wins.muc.subwin);
|
||||||
|
|
||||||
if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) {
|
if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) {
|
||||||
wattron(window->subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
|
wattron(window->wins.muc.subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
|
||||||
win_printline_nowrap(window->subwin, " -Moderators");
|
win_printline_nowrap(window->wins.muc.subwin, " -Moderators");
|
||||||
wattroff(window->subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
|
wattroff(window->wins.muc.subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
|
||||||
GList *roster_curr = occupants;
|
GList *roster_curr = occupants;
|
||||||
while (roster_curr) {
|
while (roster_curr) {
|
||||||
Occupant *occupant = roster_curr->data;
|
Occupant *occupant = roster_curr->data;
|
||||||
if (occupant->role == MUC_ROLE_MODERATOR) {
|
if (occupant->role == MUC_ROLE_MODERATOR) {
|
||||||
const char *presence_str = string_from_resource_presence(occupant->presence);
|
const char *presence_str = string_from_resource_presence(occupant->presence);
|
||||||
theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
|
theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
|
||||||
wattron(window->subwin, theme_attrs(presence_colour));
|
wattron(window->wins.muc.subwin, theme_attrs(presence_colour));
|
||||||
|
|
||||||
GString *msg = g_string_new(" ");
|
GString *msg = g_string_new(" ");
|
||||||
g_string_append(msg, occupant->nick);
|
g_string_append(msg, occupant->nick);
|
||||||
win_printline_nowrap(window->subwin, msg->str);
|
win_printline_nowrap(window->wins.muc.subwin, msg->str);
|
||||||
g_string_free(msg, TRUE);
|
g_string_free(msg, TRUE);
|
||||||
|
|
||||||
wattroff(window->subwin, theme_attrs(presence_colour));
|
wattroff(window->wins.muc.subwin, theme_attrs(presence_colour));
|
||||||
}
|
}
|
||||||
roster_curr = g_list_next(roster_curr);
|
roster_curr = g_list_next(roster_curr);
|
||||||
}
|
}
|
||||||
|
|
||||||
wattron(window->subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
|
wattron(window->wins.muc.subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
|
||||||
win_printline_nowrap(window->subwin, " -Participants");
|
win_printline_nowrap(window->wins.muc.subwin, " -Participants");
|
||||||
wattroff(window->subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
|
wattroff(window->wins.muc.subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
|
||||||
roster_curr = occupants;
|
roster_curr = occupants;
|
||||||
while (roster_curr) {
|
while (roster_curr) {
|
||||||
Occupant *occupant = roster_curr->data;
|
Occupant *occupant = roster_curr->data;
|
||||||
if (occupant->role == MUC_ROLE_PARTICIPANT) {
|
if (occupant->role == MUC_ROLE_PARTICIPANT) {
|
||||||
const char *presence_str = string_from_resource_presence(occupant->presence);
|
const char *presence_str = string_from_resource_presence(occupant->presence);
|
||||||
theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
|
theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
|
||||||
wattron(window->subwin, theme_attrs(presence_colour));
|
wattron(window->wins.muc.subwin, theme_attrs(presence_colour));
|
||||||
|
|
||||||
GString *msg = g_string_new(" ");
|
GString *msg = g_string_new(" ");
|
||||||
g_string_append(msg, occupant->nick);
|
g_string_append(msg, occupant->nick);
|
||||||
win_printline_nowrap(window->subwin, msg->str);
|
win_printline_nowrap(window->wins.muc.subwin, msg->str);
|
||||||
g_string_free(msg, TRUE);
|
g_string_free(msg, TRUE);
|
||||||
|
|
||||||
wattroff(window->subwin, theme_attrs(presence_colour));
|
wattroff(window->wins.muc.subwin, theme_attrs(presence_colour));
|
||||||
}
|
}
|
||||||
roster_curr = g_list_next(roster_curr);
|
roster_curr = g_list_next(roster_curr);
|
||||||
}
|
}
|
||||||
|
|
||||||
wattron(window->subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
|
wattron(window->wins.muc.subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
|
||||||
win_printline_nowrap(window->subwin, " -Visitors");
|
win_printline_nowrap(window->wins.muc.subwin, " -Visitors");
|
||||||
wattroff(window->subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
|
wattroff(window->wins.muc.subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
|
||||||
roster_curr = occupants;
|
roster_curr = occupants;
|
||||||
while (roster_curr) {
|
while (roster_curr) {
|
||||||
Occupant *occupant = roster_curr->data;
|
Occupant *occupant = roster_curr->data;
|
||||||
if (occupant->role == MUC_ROLE_VISITOR) {
|
if (occupant->role == MUC_ROLE_VISITOR) {
|
||||||
const char *presence_str = string_from_resource_presence(occupant->presence);
|
const char *presence_str = string_from_resource_presence(occupant->presence);
|
||||||
theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
|
theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
|
||||||
wattron(window->subwin, theme_attrs(presence_colour));
|
wattron(window->wins.muc.subwin, theme_attrs(presence_colour));
|
||||||
|
|
||||||
GString *msg = g_string_new(" ");
|
GString *msg = g_string_new(" ");
|
||||||
g_string_append(msg, occupant->nick);
|
g_string_append(msg, occupant->nick);
|
||||||
win_printline_nowrap(window->subwin, msg->str);
|
win_printline_nowrap(window->wins.muc.subwin, msg->str);
|
||||||
g_string_free(msg, TRUE);
|
g_string_free(msg, TRUE);
|
||||||
|
|
||||||
wattroff(window->subwin, theme_attrs(presence_colour));
|
wattroff(window->wins.muc.subwin, theme_attrs(presence_colour));
|
||||||
}
|
}
|
||||||
roster_curr = g_list_next(roster_curr);
|
roster_curr = g_list_next(roster_curr);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wattron(window->subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
|
wattron(window->wins.muc.subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
|
||||||
win_printline_nowrap(window->subwin, " -Occupants\n");
|
win_printline_nowrap(window->wins.muc.subwin, " -Occupants\n");
|
||||||
wattroff(window->subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
|
wattroff(window->wins.muc.subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
|
||||||
GList *roster_curr = occupants;
|
GList *roster_curr = occupants;
|
||||||
while (roster_curr) {
|
while (roster_curr) {
|
||||||
Occupant *occupant = roster_curr->data;
|
Occupant *occupant = roster_curr->data;
|
||||||
const char *presence_str = string_from_resource_presence(occupant->presence);
|
const char *presence_str = string_from_resource_presence(occupant->presence);
|
||||||
theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
|
theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
|
||||||
wattron(window->subwin, theme_attrs(presence_colour));
|
wattron(window->wins.muc.subwin, theme_attrs(presence_colour));
|
||||||
|
|
||||||
GString *msg = g_string_new(" ");
|
GString *msg = g_string_new(" ");
|
||||||
g_string_append(msg, occupant->nick);
|
g_string_append(msg, occupant->nick);
|
||||||
win_printline_nowrap(window->subwin, msg->str);
|
win_printline_nowrap(window->wins.muc.subwin, msg->str);
|
||||||
g_string_free(msg, TRUE);
|
g_string_free(msg, TRUE);
|
||||||
|
|
||||||
wattroff(window->subwin, theme_attrs(presence_colour));
|
wattroff(window->wins.muc.subwin, theme_attrs(presence_colour));
|
||||||
roster_curr = g_list_next(roster_curr);
|
roster_curr = g_list_next(roster_curr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3116,7 +3116,7 @@ static void
|
|||||||
_ui_room_show_occupants(const char * const room)
|
_ui_room_show_occupants(const char * const room)
|
||||||
{
|
{
|
||||||
ProfWin *window = wins_get_by_recipient(room);
|
ProfWin *window = wins_get_by_recipient(room);
|
||||||
if (window && !window->subwin) {
|
if (window && !window->wins.muc.subwin) {
|
||||||
wins_show_subwin(window);
|
wins_show_subwin(window);
|
||||||
ui_muc_roster(room);
|
ui_muc_roster(room);
|
||||||
}
|
}
|
||||||
@ -3126,7 +3126,7 @@ static void
|
|||||||
_ui_room_hide_occupants(const char * const room)
|
_ui_room_hide_occupants(const char * const room)
|
||||||
{
|
{
|
||||||
ProfWin *window = wins_get_by_recipient(room);
|
ProfWin *window = wins_get_by_recipient(room);
|
||||||
if (window && window->subwin) {
|
if (window && window->wins.muc.subwin) {
|
||||||
wins_hide_subwin(window);
|
wins_hide_subwin(window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3135,7 +3135,7 @@ static void
|
|||||||
_ui_show_roster(void)
|
_ui_show_roster(void)
|
||||||
{
|
{
|
||||||
ProfWin *window = wins_get_console();
|
ProfWin *window = wins_get_console();
|
||||||
if (window && !window->subwin) {
|
if (window && !window->wins.cons.subwin) {
|
||||||
wins_show_subwin(window);
|
wins_show_subwin(window);
|
||||||
ui_roster();
|
ui_roster();
|
||||||
}
|
}
|
||||||
@ -3145,7 +3145,7 @@ static void
|
|||||||
_ui_hide_roster(void)
|
_ui_hide_roster(void)
|
||||||
{
|
{
|
||||||
ProfWin *window = wins_get_console();
|
ProfWin *window = wins_get_console();
|
||||||
if (window && window->subwin) {
|
if (window && window->wins.cons.subwin) {
|
||||||
wins_hide_subwin(window);
|
wins_hide_subwin(window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3182,7 +3182,6 @@ _win_handle_page(const wint_t * const ch, const int result)
|
|||||||
ProfWin *current = wins_get_current();
|
ProfWin *current = wins_get_current();
|
||||||
int rows = getmaxy(stdscr);
|
int rows = getmaxy(stdscr);
|
||||||
int y = getcury(current->win);
|
int y = getcury(current->win);
|
||||||
int sub_y = getcury(current->subwin);
|
|
||||||
|
|
||||||
int page_space = rows - 4;
|
int page_space = rows - 4;
|
||||||
int *page_start = &(current->y_pos);
|
int *page_start = &(current->y_pos);
|
||||||
@ -3257,27 +3256,38 @@ _win_handle_page(const wint_t * const ch, const int result)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((current->type == WIN_MUC) || (current->type == WIN_CONSOLE)) {
|
if ((current->type == WIN_MUC) || (current->type == WIN_CONSOLE)) {
|
||||||
|
int sub_y = 0;
|
||||||
|
int *sub_y_pos = NULL;
|
||||||
|
|
||||||
|
if (current->type == WIN_MUC) {
|
||||||
|
sub_y = getcury(current->wins.muc.subwin);
|
||||||
|
sub_y_pos = &(current->wins.muc.sub_y_pos);
|
||||||
|
} else if (current->type == WIN_CONSOLE) {
|
||||||
|
sub_y = getcury(current->wins.cons.subwin);
|
||||||
|
sub_y_pos = &(current->wins.cons.sub_y_pos);
|
||||||
|
}
|
||||||
|
|
||||||
// alt up arrow
|
// alt up arrow
|
||||||
if ((result == KEY_CODE_YES) && ((*ch == 565) || (*ch == 337))) {
|
if ((result == KEY_CODE_YES) && ((*ch == 565) || (*ch == 337))) {
|
||||||
current->sub_y_pos -= page_space;
|
*sub_y_pos -= page_space;
|
||||||
|
|
||||||
// went past beginning, show first page
|
// went past beginning, show first page
|
||||||
if (current->sub_y_pos < 0)
|
if (*sub_y_pos < 0)
|
||||||
current->sub_y_pos = 0;
|
*sub_y_pos = 0;
|
||||||
|
|
||||||
win_update_virtual(current);
|
win_update_virtual(current);
|
||||||
|
|
||||||
// alt down arrow
|
// alt down arrow
|
||||||
} else if ((result == KEY_CODE_YES) && ((*ch == 524) || (*ch == 336))) {
|
} else if ((result == KEY_CODE_YES) && ((*ch == 524) || (*ch == 336))) {
|
||||||
current->sub_y_pos += page_space;
|
*sub_y_pos += page_space;
|
||||||
|
|
||||||
// only got half a screen, show full screen
|
// only got half a screen, show full screen
|
||||||
if ((sub_y- (current->sub_y_pos)) < page_space)
|
if ((sub_y- (*sub_y_pos)) < page_space)
|
||||||
current->sub_y_pos = sub_y - page_space;
|
*sub_y_pos = sub_y - page_space;
|
||||||
|
|
||||||
// went past end, show full screen
|
// went past end, show full screen
|
||||||
else if (current->sub_y_pos >= sub_y)
|
else if (*sub_y_pos >= sub_y)
|
||||||
current->sub_y_pos = sub_y - page_space - 1;
|
*sub_y_pos = sub_y - page_space - 1;
|
||||||
|
|
||||||
win_update_virtual(current);
|
win_update_virtual(current);
|
||||||
}
|
}
|
||||||
|
118
src/ui/window.c
118
src/ui/window.c
@ -76,27 +76,39 @@ win_occpuants_cols(void)
|
|||||||
ProfWin*
|
ProfWin*
|
||||||
win_create(const char * const title, win_type_t type)
|
win_create(const char * const title, win_type_t type)
|
||||||
{
|
{
|
||||||
ProfWin *new_win = malloc(sizeof(struct prof_win_t));
|
ProfWin *new_win = malloc(sizeof(ProfWin));
|
||||||
new_win->from = strdup(title);
|
|
||||||
int cols = getmaxx(stdscr);
|
int cols = getmaxx(stdscr);
|
||||||
|
|
||||||
if (type == WIN_MUC && prefs_get_boolean(PREF_OCCUPANTS)) {
|
switch (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();
|
int subwin_cols = win_occpuants_cols();
|
||||||
new_win->win = newpad(PAD_SIZE, cols - subwin_cols);
|
new_win->win = newpad(PAD_SIZE, cols - subwin_cols);
|
||||||
wbkgd(new_win->win, theme_attrs(THEME_TEXT));
|
wbkgd(new_win->win, theme_attrs(THEME_TEXT));
|
||||||
|
new_win->wins.muc.subwin = newpad(PAD_SIZE, subwin_cols);;
|
||||||
new_win->subwin = newpad(PAD_SIZE, subwin_cols);
|
wbkgd(new_win->wins.muc.subwin, theme_attrs(THEME_TEXT));
|
||||||
wbkgd(new_win->subwin, theme_attrs(THEME_TEXT));
|
|
||||||
} else {
|
} else {
|
||||||
new_win->win = newpad(PAD_SIZE, (cols));
|
new_win->win = newpad(PAD_SIZE, (cols));
|
||||||
wbkgd(new_win->win, theme_attrs(THEME_TEXT));
|
wbkgd(new_win->win, theme_attrs(THEME_TEXT));
|
||||||
|
new_win->wins.muc.subwin = NULL;
|
||||||
new_win->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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new_win->from = strdup(title);
|
||||||
new_win->buffer = buffer_create();
|
new_win->buffer = buffer_create();
|
||||||
new_win->y_pos = 0;
|
new_win->y_pos = 0;
|
||||||
new_win->sub_y_pos = 0;
|
|
||||||
new_win->paged = 0;
|
new_win->paged = 0;
|
||||||
new_win->unread = 0;
|
new_win->unread = 0;
|
||||||
new_win->history_shown = 0;
|
new_win->history_shown = 0;
|
||||||
@ -113,11 +125,24 @@ win_create(const char * const title, win_type_t type)
|
|||||||
void
|
void
|
||||||
win_hide_subwin(ProfWin *window)
|
win_hide_subwin(ProfWin *window)
|
||||||
{
|
{
|
||||||
if (window->subwin) {
|
switch (window->type) {
|
||||||
delwin(window->subwin);
|
case WIN_CONSOLE:
|
||||||
|
if (window->wins.cons.subwin) {
|
||||||
|
delwin(window->wins.cons.subwin);
|
||||||
|
}
|
||||||
|
window->wins.cons.subwin = NULL;
|
||||||
|
window->wins.cons.sub_y_pos = 0;
|
||||||
|
break;
|
||||||
|
case WIN_MUC:
|
||||||
|
if (window->wins.muc.subwin) {
|
||||||
|
delwin(window->wins.muc.subwin);
|
||||||
|
}
|
||||||
|
window->wins.muc.subwin = NULL;
|
||||||
|
window->wins.muc.sub_y_pos = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
window->subwin = NULL;
|
|
||||||
window->sub_y_pos = 0;
|
|
||||||
|
|
||||||
int cols = getmaxx(stdscr);
|
int cols = getmaxx(stdscr);
|
||||||
wresize(window->win, PAD_SIZE, cols);
|
wresize(window->win, PAD_SIZE, cols);
|
||||||
@ -127,20 +152,26 @@ win_hide_subwin(ProfWin *window)
|
|||||||
void
|
void
|
||||||
win_show_subwin(ProfWin *window)
|
win_show_subwin(ProfWin *window)
|
||||||
{
|
{
|
||||||
if (!window->subwin) {
|
|
||||||
int cols = getmaxx(stdscr);
|
int cols = getmaxx(stdscr);
|
||||||
int subwin_cols = 0;
|
int subwin_cols = 0;
|
||||||
if (window->type == WIN_CONSOLE) {
|
|
||||||
|
switch (window->type) {
|
||||||
|
case WIN_CONSOLE:
|
||||||
subwin_cols = win_roster_cols();
|
subwin_cols = win_roster_cols();
|
||||||
} else if (window->type == WIN_MUC) {
|
window->wins.cons.subwin = newpad(PAD_SIZE, subwin_cols);
|
||||||
subwin_cols = win_occpuants_cols();
|
wbkgd(window->wins.cons.subwin, theme_attrs(THEME_TEXT));
|
||||||
}
|
|
||||||
|
|
||||||
window->subwin = newpad(PAD_SIZE, subwin_cols);
|
|
||||||
wbkgd(window->subwin, theme_attrs(THEME_TEXT));
|
|
||||||
|
|
||||||
wresize(window->win, PAD_SIZE, cols - subwin_cols);
|
wresize(window->win, PAD_SIZE, cols - subwin_cols);
|
||||||
win_redraw(window);
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,9 +180,22 @@ win_free(ProfWin* window)
|
|||||||
{
|
{
|
||||||
buffer_free(window->buffer);
|
buffer_free(window->buffer);
|
||||||
delwin(window->win);
|
delwin(window->win);
|
||||||
if (window->subwin) {
|
|
||||||
delwin(window->subwin);
|
switch (window->type) {
|
||||||
|
case WIN_CONSOLE:
|
||||||
|
if (window->wins.cons.subwin) {
|
||||||
|
delwin(window->wins.cons.subwin);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case WIN_MUC:
|
||||||
|
if (window->wins.muc.subwin) {
|
||||||
|
delwin(window->wins.muc.subwin);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
free(window->chat_resource);
|
free(window->chat_resource);
|
||||||
free(window->from);
|
free(window->from);
|
||||||
form_destroy(window->form);
|
form_destroy(window->form);
|
||||||
@ -163,19 +207,31 @@ win_update_virtual(ProfWin *window)
|
|||||||
{
|
{
|
||||||
int rows, cols;
|
int rows, cols;
|
||||||
getmaxyx(stdscr, rows, cols);
|
getmaxyx(stdscr, rows, cols);
|
||||||
|
|
||||||
if (window->subwin) {
|
|
||||||
int subwin_cols = 0;
|
int subwin_cols = 0;
|
||||||
if (window->type == WIN_MUC) {
|
|
||||||
subwin_cols = win_occpuants_cols();
|
switch (window->type) {
|
||||||
} else if (window->type == WIN_CONSOLE) {
|
case WIN_CONSOLE:
|
||||||
|
if (window->wins.cons.subwin) {
|
||||||
subwin_cols = win_roster_cols();
|
subwin_cols = win_roster_cols();
|
||||||
}
|
|
||||||
pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
|
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);
|
pnoutrefresh(window->wins.cons.subwin, window->wins.cons.sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1);
|
||||||
} else {
|
} else {
|
||||||
pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, cols-1);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -57,7 +57,6 @@
|
|||||||
#define PAD_SIZE 1000
|
#define PAD_SIZE 1000
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
WIN_UNUSED,
|
|
||||||
WIN_CONSOLE,
|
WIN_CONSOLE,
|
||||||
WIN_CHAT,
|
WIN_CHAT,
|
||||||
WIN_MUC,
|
WIN_MUC,
|
||||||
@ -67,20 +66,50 @@ typedef enum {
|
|||||||
} win_type_t;
|
} win_type_t;
|
||||||
|
|
||||||
typedef struct prof_win_t {
|
typedef struct prof_win_t {
|
||||||
|
|
||||||
|
win_type_t type;
|
||||||
|
|
||||||
|
WINDOW *win;
|
||||||
|
ProfBuff buffer;
|
||||||
char *from;
|
char *from;
|
||||||
char *chat_resource;
|
char *chat_resource;
|
||||||
WINDOW *win;
|
int y_pos;
|
||||||
WINDOW *subwin;
|
int paged;
|
||||||
ProfBuff buffer;
|
|
||||||
win_type_t type;
|
|
||||||
gboolean is_otr;
|
gboolean is_otr;
|
||||||
gboolean is_trusted;
|
gboolean is_trusted;
|
||||||
int y_pos;
|
|
||||||
int sub_y_pos;
|
|
||||||
int paged;
|
|
||||||
int unread;
|
int unread;
|
||||||
int history_shown;
|
int history_shown;
|
||||||
DataForm *form;
|
DataForm *form;
|
||||||
|
|
||||||
|
union {
|
||||||
|
// WIN_CONSOLE
|
||||||
|
struct {
|
||||||
|
WINDOW *subwin;
|
||||||
|
int sub_y_pos;
|
||||||
|
} cons;
|
||||||
|
|
||||||
|
// WIN_CHAT
|
||||||
|
struct {
|
||||||
|
} chat;
|
||||||
|
|
||||||
|
// WIN_MUC
|
||||||
|
struct {
|
||||||
|
WINDOW *subwin;
|
||||||
|
int sub_y_pos;
|
||||||
|
} muc;
|
||||||
|
|
||||||
|
// WIN_MUC_CONFIG
|
||||||
|
struct {
|
||||||
|
} conf;
|
||||||
|
|
||||||
|
// WIN_PRIVATE
|
||||||
|
struct {
|
||||||
|
} priv;
|
||||||
|
|
||||||
|
// WIN_XML
|
||||||
|
struct {
|
||||||
|
} xml;
|
||||||
|
} wins;
|
||||||
} ProfWin;
|
} ProfWin;
|
||||||
|
|
||||||
ProfWin* win_create(const char * const title, win_type_t type);
|
ProfWin* win_create(const char * const title, win_type_t type);
|
||||||
|
@ -291,22 +291,34 @@ wins_resize_all(void)
|
|||||||
GList *curr = values;
|
GList *curr = values;
|
||||||
while (curr != NULL) {
|
while (curr != NULL) {
|
||||||
ProfWin *window = curr->data;
|
ProfWin *window = curr->data;
|
||||||
if (((window->type == WIN_MUC) || (window->type == WIN_CONSOLE)) && (window->subwin)) {
|
|
||||||
int subwin_cols = 0;
|
int subwin_cols = 0;
|
||||||
if (window->type == WIN_MUC) {
|
|
||||||
subwin_cols = win_occpuants_cols();
|
switch (window->type) {
|
||||||
wresize(window->win, PAD_SIZE, cols - subwin_cols);
|
case WIN_CONSOLE:
|
||||||
wresize(window->subwin, PAD_SIZE, subwin_cols);
|
if (window->wins.cons.subwin) {
|
||||||
ui_muc_roster(window->from);
|
|
||||||
} else if (window->type == WIN_CONSOLE) {
|
|
||||||
subwin_cols = win_roster_cols();
|
subwin_cols = win_roster_cols();
|
||||||
wresize(window->win, PAD_SIZE, cols - subwin_cols);
|
wresize(window->win, PAD_SIZE, cols - subwin_cols);
|
||||||
wresize(window->subwin, PAD_SIZE, subwin_cols);
|
wresize(window->wins.cons.subwin, PAD_SIZE, subwin_cols);
|
||||||
ui_roster();
|
ui_roster();
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
wresize(window->win, PAD_SIZE, cols);
|
wresize(window->win, PAD_SIZE, cols);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case WIN_MUC:
|
||||||
|
if (window->wins.muc.subwin) {
|
||||||
|
subwin_cols = win_occpuants_cols();
|
||||||
|
wresize(window->win, PAD_SIZE, cols - subwin_cols);
|
||||||
|
wresize(window->wins.muc.subwin, PAD_SIZE, subwin_cols);
|
||||||
|
ui_muc_roster(window->from);
|
||||||
|
} else {
|
||||||
|
wresize(window->win, PAD_SIZE, cols);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
wresize(window->win, PAD_SIZE, cols);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
win_redraw(window);
|
win_redraw(window);
|
||||||
curr = g_list_next(curr);
|
curr = g_list_next(curr);
|
||||||
}
|
}
|
||||||
@ -342,12 +354,12 @@ wins_show_subwin(ProfWin *window)
|
|||||||
ProfWin *current_win = wins_get_current();
|
ProfWin *current_win = wins_get_current();
|
||||||
if (current_win->type == WIN_MUC) {
|
if (current_win->type == WIN_MUC) {
|
||||||
subwin_cols = win_occpuants_cols();
|
subwin_cols = win_occpuants_cols();
|
||||||
|
pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
|
||||||
|
pnoutrefresh(current_win->wins.muc.subwin, current_win->wins.muc.sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1);
|
||||||
} else if (current_win->type == WIN_CONSOLE) {
|
} else if (current_win->type == WIN_CONSOLE) {
|
||||||
subwin_cols = win_roster_cols();
|
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-subwin_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);
|
pnoutrefresh(current_win->wins.cons.subwin, current_win->wins.cons.sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user