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

Added scroll support to occupant list

This commit is contained in:
James Booth 2014-10-07 21:12:19 +01:00
parent 639796384a
commit b8ba9b038c
9 changed files with 51 additions and 24 deletions

View File

@ -97,6 +97,7 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
while(cmd_result == TRUE) {
wint_t ch = ERR;
int result;
size = 0;
while(ch != '\n') {
@ -113,14 +114,14 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
g_timer_start(timer);
}
ui_handle_special_keys(&ch, inp, size);
ui_handle_special_keys(&ch, result, inp, size);
#ifdef HAVE_LIBOTR
otr_poll();
#endif
jabber_process_events();
ui_update();
ch = ui_get_char(inp, &size);
ch = ui_get_char(inp, &size, &result);
}
inp[size++] = '\0';

View File

@ -693,9 +693,6 @@ handle_muc_self_online(const char * const room, const char * const nick, gboolea
muc_invites_remove(room);
muc_roster_set_complete(room);
GList *roster = muc_roster(room);
ui_room_roster(room, roster, NULL);
char *subject = muc_subject(room);
if (subject != NULL) {
ui_room_subject(room, NULL, subject);

View File

@ -80,7 +80,7 @@ static Display *display;
static GTimer *ui_idle_time;
static void _win_handle_switch(const wint_t * const ch);
static void _win_handle_page(const wint_t * const ch);
static void _win_handle_page(const wint_t * const ch, const int result);
static void _win_show_history(WINDOW *win, int win_index,
const char * const contact);
static void _ui_draw_term_title(void);
@ -175,9 +175,9 @@ _ui_close(void)
}
static wint_t
_ui_get_char(char *input, int *size)
_ui_get_char(char *input, int *size, int *result)
{
wint_t ch = inp_get_char(input, size);
wint_t ch = inp_get_char(input, size, result);
if (ch != ERR) {
ui_reset_idle_time();
}
@ -585,11 +585,11 @@ _ui_disconnected(void)
}
static void
_ui_handle_special_keys(const wint_t * const ch, const char * const inp,
_ui_handle_special_keys(const wint_t * const ch, const int result, const char * const inp,
const int size)
{
_win_handle_switch(ch);
_win_handle_page(ch);
_win_handle_page(ch, result);
if (*ch == KEY_RESIZE) {
ui_resize(*ch, inp, size);
}
@ -2806,11 +2806,12 @@ _win_handle_switch(const wint_t * const ch)
}
static void
_win_handle_page(const wint_t * const ch)
_win_handle_page(const wint_t * const ch, const int result)
{
ProfWin *current = wins_get_current();
int rows = getmaxy(stdscr);
int y = getcury(current->win);
int sub_y = getcury(current->subwin);
int page_space = rows - 4;
int *page_start = &(current->y_pos);
@ -2883,6 +2884,33 @@ _win_handle_page(const wint_t * const ch)
if ((y) - *page_start == page_space) {
current->paged = 0;
}
if (current->type == WIN_MUC) {
// alt up arrow
if ((result == KEY_CODE_YES) && (*ch == 565)) {
current->sub_y_pos -= page_space;
// went past beginning, show first page
if (current->sub_y_pos < 0)
current->sub_y_pos = 0;
win_update_virtual(current);
// alt down arrow
} else if ((result == KEY_CODE_YES) && (*ch == 524)) {
current->sub_y_pos += page_space;
// only got half a screen, show full screen
if ((sub_y- (current->sub_y_pos)) < page_space)
current->sub_y_pos = sub_y - page_space;
// went past end, show full screen
else if (current->sub_y_pos >= sub_y)
current->sub_y_pos = sub_y - page_space - 1;
win_update_virtual(current);
}
}
}
static void

View File

@ -120,7 +120,7 @@ inp_block(void)
}
wint_t
inp_get_char(char *input, int *size)
inp_get_char(char *input, int *size, int *result)
{
wint_t ch;
int display_size = 0;
@ -131,7 +131,7 @@ inp_get_char(char *input, int *size)
// echo off, and get some more input
noecho();
int result = wget_wch(inp_win, &ch);
*result = wget_wch(inp_win, &ch);
gboolean in_command = FALSE;
if ((display_size > 0 && input[0] == '/') ||
@ -140,12 +140,12 @@ inp_get_char(char *input, int *size)
}
if (prefs_get_boolean(PREF_STATES)) {
if (result == ERR) {
if (*result == ERR) {
prof_handle_idle();
}
if (prefs_get_boolean(PREF_OUTTYPE)
&& (result != ERR)
&& (result != KEY_CODE_YES)
&& (*result != ERR)
&& (*result != KEY_CODE_YES)
&& !in_command
&& _printable(ch)) {
prof_handle_activity();
@ -153,8 +153,8 @@ inp_get_char(char *input, int *size)
}
// if it wasn't an arrow key etc
if (!_handle_edit(result, ch, input, size)) {
if (_printable(ch) && result != KEY_CODE_YES) {
if (!_handle_edit(*result, ch, input, size)) {
if (_printable(ch) && *result != KEY_CODE_YES) {
if (*size >= INP_WIN_MAX) {
return ERR;
}

View File

@ -36,7 +36,7 @@
#define UI_INPUTWIN_H
void create_input_window(void);
wint_t inp_get_char(char *input, int *size);
wint_t inp_get_char(char *input, int *size, int *result);
void inp_win_reset(void);
void inp_win_resize(const char * input, const int size);
void inp_put_back(void);

View File

@ -66,7 +66,7 @@ void (*ui_close)(void);
void (*ui_resize)(const int ch, const char * const input,
const int size);
GSList* (*ui_get_recipients)(void);
void (*ui_handle_special_keys)(const wint_t * const ch, const char * const inp,
void (*ui_handle_special_keys)(const wint_t * const ch, const int result, const char * const inp,
const int size);
gboolean (*ui_switch_win)(const int i);
void (*ui_next_win)(void);
@ -223,7 +223,7 @@ void (*ui_update_presence)(const resource_presence_t resource_presence,
void (*ui_about)(void);
void (*ui_statusbar_new)(const int win);
wint_t (*ui_get_char)(char *input, int *size);
wint_t (*ui_get_char)(char *input, int *size, int *result);
void (*ui_input_clear)(void);
void (*ui_input_nonblocking)(void);
void (*ui_replace_input)(char *input, const char * const new_input, int *size);

View File

@ -65,7 +65,6 @@ win_create(const char * const title, int cols, win_type_t type)
wbkgd(new_win->win, COLOUR_TEXT);
new_win->subwin = newpad(PAD_SIZE, cols/OCCUPANT_WIN_SIZE);
wvline(new_win->subwin, 0, 0);
wbkgd(new_win->subwin, COLOUR_TEXT);
} else {
new_win->win = newpad(PAD_SIZE, (cols));
@ -76,6 +75,7 @@ win_create(const char * const title, int cols, win_type_t type)
new_win->buffer = buffer_create();
new_win->y_pos = 0;
new_win->sub_y_pos = 0;
new_win->paged = 0;
new_win->unread = 0;
new_win->history_shown = 0;
@ -109,7 +109,7 @@ win_update_virtual(ProfWin *window)
if (window->type == WIN_MUC) {
pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, ((cols/OCCUPANT_WIN_SIZE) * (OCCUPANT_WIN_SIZE-1)) -1);
pnoutrefresh(window->subwin, 0, 0, 1, (cols/OCCUPANT_WIN_SIZE) * (OCCUPANT_WIN_SIZE-1), rows-3, cols-1);
pnoutrefresh(window->subwin, window->sub_y_pos, 0, 1, (cols/OCCUPANT_WIN_SIZE) * (OCCUPANT_WIN_SIZE-1), rows-3, cols-1);
} else {
pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, cols-1);
}

View File

@ -75,6 +75,7 @@ typedef struct prof_win_t {
gboolean is_otr;
gboolean is_trusted;
int y_pos;
int sub_y_pos;
int paged;
int unread;
int history_shown;

View File

@ -307,7 +307,7 @@ wins_resize_all(void)
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/OCCUPANT_WIN_SIZE) * (OCCUPANT_WIN_SIZE-1)) -1);
pnoutrefresh(current_win->subwin, 0, 0, 1, (cols/OCCUPANT_WIN_SIZE) * (OCCUPANT_WIN_SIZE-1), rows-3, cols-1);
pnoutrefresh(current_win->subwin, current_win->sub_y_pos, 0, 1, (cols/OCCUPANT_WIN_SIZE) * (OCCUPANT_WIN_SIZE-1), rows-3, cols-1);
} else {
pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, cols-1);
}