mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Moved win_handle_page to window module
This commit is contained in:
parent
db9a2cf0ab
commit
97aebb6113
115
src/ui/core.c
115
src/ui/core.c
@ -81,7 +81,6 @@ static Display *display;
|
|||||||
static GTimer *ui_idle_time;
|
static GTimer *ui_idle_time;
|
||||||
|
|
||||||
static void _win_handle_switch(const wint_t ch);
|
static void _win_handle_switch(const wint_t ch);
|
||||||
static void _win_handle_page(const wint_t ch, const int result);
|
|
||||||
static void _win_show_history(int win_index, const char * const contact);
|
static void _win_show_history(int win_index, const char * const contact);
|
||||||
static void _ui_draw_term_title(void);
|
static void _ui_draw_term_title(void);
|
||||||
|
|
||||||
@ -180,7 +179,8 @@ ui_get_char(char *input, int *size)
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
wint_t ch = inp_get_char(input, size, &result);
|
wint_t ch = inp_get_char(input, size, &result);
|
||||||
_win_handle_switch(ch);
|
_win_handle_switch(ch);
|
||||||
_win_handle_page(ch, result);
|
ProfWin *current = wins_get_current();
|
||||||
|
win_handle_page(current, ch, result);
|
||||||
if (ch == KEY_RESIZE) {
|
if (ch == KEY_RESIZE) {
|
||||||
ui_resize();
|
ui_resize();
|
||||||
}
|
}
|
||||||
@ -2957,117 +2957,6 @@ _win_handle_switch(const wint_t ch)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_win_handle_page(const wint_t ch, const int result)
|
|
||||||
{
|
|
||||||
ProfWin *current = wins_get_current();
|
|
||||||
int rows = getmaxy(stdscr);
|
|
||||||
int y = getcury(current->layout->win);
|
|
||||||
|
|
||||||
int page_space = rows - 4;
|
|
||||||
int *page_start = &(current->layout->y_pos);
|
|
||||||
|
|
||||||
if (prefs_get_boolean(PREF_MOUSE)) {
|
|
||||||
MEVENT mouse_event;
|
|
||||||
|
|
||||||
if (ch == KEY_MOUSE) {
|
|
||||||
if (getmouse(&mouse_event) == OK) {
|
|
||||||
|
|
||||||
#ifdef PLATFORM_CYGWIN
|
|
||||||
if (mouse_event.bstate & BUTTON5_PRESSED) { // mouse wheel down
|
|
||||||
#else
|
|
||||||
if (mouse_event.bstate & BUTTON2_PRESSED) { // mouse wheel down
|
|
||||||
#endif
|
|
||||||
*page_start += 4;
|
|
||||||
|
|
||||||
// only got half a screen, show full screen
|
|
||||||
if ((y - (*page_start)) < page_space)
|
|
||||||
*page_start = y - page_space;
|
|
||||||
|
|
||||||
// went past end, show full screen
|
|
||||||
else if (*page_start >= y)
|
|
||||||
*page_start = y - page_space;
|
|
||||||
|
|
||||||
current->layout->paged = 1;
|
|
||||||
win_update_virtual(current);
|
|
||||||
} else if (mouse_event.bstate & BUTTON4_PRESSED) { // mouse wheel up
|
|
||||||
*page_start -= 4;
|
|
||||||
|
|
||||||
// went past beginning, show first page
|
|
||||||
if (*page_start < 0)
|
|
||||||
*page_start = 0;
|
|
||||||
|
|
||||||
current->layout->paged = 1;
|
|
||||||
win_update_virtual(current);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// page up
|
|
||||||
if (ch == KEY_PPAGE) {
|
|
||||||
*page_start -= page_space;
|
|
||||||
|
|
||||||
// went past beginning, show first page
|
|
||||||
if (*page_start < 0)
|
|
||||||
*page_start = 0;
|
|
||||||
|
|
||||||
current->layout->paged = 1;
|
|
||||||
win_update_virtual(current);
|
|
||||||
|
|
||||||
// page down
|
|
||||||
} else if (ch == KEY_NPAGE) {
|
|
||||||
*page_start += page_space;
|
|
||||||
|
|
||||||
// only got half a screen, show full screen
|
|
||||||
if ((y - (*page_start)) < page_space)
|
|
||||||
*page_start = y - page_space;
|
|
||||||
|
|
||||||
// went past end, show full screen
|
|
||||||
else if (*page_start >= y)
|
|
||||||
*page_start = y - page_space - 1;
|
|
||||||
|
|
||||||
current->layout->paged = 1;
|
|
||||||
win_update_virtual(current);
|
|
||||||
}
|
|
||||||
|
|
||||||
// switch off page if last line and space line visible
|
|
||||||
if ((y) - *page_start == page_space) {
|
|
||||||
current->layout->paged = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (current->layout->type == LAYOUT_SPLIT) {
|
|
||||||
ProfLayoutSplit *split_layout = (ProfLayoutSplit*)current->layout;
|
|
||||||
int sub_y = getcury(split_layout->subwin);
|
|
||||||
int *sub_y_pos = &(split_layout->sub_y_pos);
|
|
||||||
|
|
||||||
// alt up arrow
|
|
||||||
if ((result == KEY_CODE_YES) && ((ch == 565) || (ch == 337))) {
|
|
||||||
*sub_y_pos -= page_space;
|
|
||||||
|
|
||||||
// went past beginning, show first page
|
|
||||||
if (*sub_y_pos < 0)
|
|
||||||
*sub_y_pos = 0;
|
|
||||||
|
|
||||||
win_update_virtual(current);
|
|
||||||
|
|
||||||
// alt down arrow
|
|
||||||
} else if ((result == KEY_CODE_YES) && ((ch == 524) || (ch == 336))) {
|
|
||||||
*sub_y_pos += page_space;
|
|
||||||
|
|
||||||
// only got half a screen, show full screen
|
|
||||||
if ((sub_y- (*sub_y_pos)) < page_space)
|
|
||||||
*sub_y_pos = sub_y - page_space;
|
|
||||||
|
|
||||||
// went past end, show full screen
|
|
||||||
else if (*sub_y_pos >= sub_y)
|
|
||||||
*sub_y_pos = sub_y - page_space - 1;
|
|
||||||
|
|
||||||
win_update_virtual(current);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_win_show_history(int win_index, const char * const contact)
|
_win_show_history(int win_index, const char * const contact)
|
||||||
{
|
{
|
||||||
|
110
src/ui/window.c
110
src/ui/window.c
@ -357,6 +357,116 @@ win_free(ProfWin* window)
|
|||||||
free(window);
|
free(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
win_handle_page(ProfWin *window, const wint_t ch, const int result)
|
||||||
|
{
|
||||||
|
int rows = getmaxy(stdscr);
|
||||||
|
int y = getcury(window->layout->win);
|
||||||
|
|
||||||
|
int page_space = rows - 4;
|
||||||
|
int *page_start = &(window->layout->y_pos);
|
||||||
|
|
||||||
|
if (prefs_get_boolean(PREF_MOUSE)) {
|
||||||
|
MEVENT mouse_event;
|
||||||
|
|
||||||
|
if (ch == KEY_MOUSE) {
|
||||||
|
if (getmouse(&mouse_event) == OK) {
|
||||||
|
|
||||||
|
#ifdef PLATFORM_CYGWIN
|
||||||
|
if (mouse_event.bstate & BUTTON5_PRESSED) { // mouse wheel down
|
||||||
|
#else
|
||||||
|
if (mouse_event.bstate & BUTTON2_PRESSED) { // mouse wheel down
|
||||||
|
#endif
|
||||||
|
*page_start += 4;
|
||||||
|
|
||||||
|
// only got half a screen, show full screen
|
||||||
|
if ((y - (*page_start)) < page_space)
|
||||||
|
*page_start = y - page_space;
|
||||||
|
|
||||||
|
// went past end, show full screen
|
||||||
|
else if (*page_start >= y)
|
||||||
|
*page_start = y - page_space;
|
||||||
|
|
||||||
|
window->layout->paged = 1;
|
||||||
|
win_update_virtual(window);
|
||||||
|
} else if (mouse_event.bstate & BUTTON4_PRESSED) { // mouse wheel up
|
||||||
|
*page_start -= 4;
|
||||||
|
|
||||||
|
// went past beginning, show first page
|
||||||
|
if (*page_start < 0)
|
||||||
|
*page_start = 0;
|
||||||
|
|
||||||
|
window->layout->paged = 1;
|
||||||
|
win_update_virtual(window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// page up
|
||||||
|
if (ch == KEY_PPAGE) {
|
||||||
|
*page_start -= page_space;
|
||||||
|
|
||||||
|
// went past beginning, show first page
|
||||||
|
if (*page_start < 0)
|
||||||
|
*page_start = 0;
|
||||||
|
|
||||||
|
window->layout->paged = 1;
|
||||||
|
win_update_virtual(window);
|
||||||
|
|
||||||
|
// page down
|
||||||
|
} else if (ch == KEY_NPAGE) {
|
||||||
|
*page_start += page_space;
|
||||||
|
|
||||||
|
// only got half a screen, show full screen
|
||||||
|
if ((y - (*page_start)) < page_space)
|
||||||
|
*page_start = y - page_space;
|
||||||
|
|
||||||
|
// went past end, show full screen
|
||||||
|
else if (*page_start >= y)
|
||||||
|
*page_start = y - page_space - 1;
|
||||||
|
|
||||||
|
window->layout->paged = 1;
|
||||||
|
win_update_virtual(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
// switch off page if last line and space line visible
|
||||||
|
if ((y) - *page_start == page_space) {
|
||||||
|
window->layout->paged = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window->layout->type == LAYOUT_SPLIT) {
|
||||||
|
ProfLayoutSplit *split_layout = (ProfLayoutSplit*)window->layout;
|
||||||
|
int sub_y = getcury(split_layout->subwin);
|
||||||
|
int *sub_y_pos = &(split_layout->sub_y_pos);
|
||||||
|
|
||||||
|
// alt up arrow
|
||||||
|
if ((result == KEY_CODE_YES) && ((ch == 565) || (ch == 337))) {
|
||||||
|
*sub_y_pos -= page_space;
|
||||||
|
|
||||||
|
// went past beginning, show first page
|
||||||
|
if (*sub_y_pos < 0)
|
||||||
|
*sub_y_pos = 0;
|
||||||
|
|
||||||
|
win_update_virtual(window);
|
||||||
|
|
||||||
|
// alt down arrow
|
||||||
|
} else if ((result == KEY_CODE_YES) && ((ch == 524) || (ch == 336))) {
|
||||||
|
*sub_y_pos += page_space;
|
||||||
|
|
||||||
|
// only got half a screen, show full screen
|
||||||
|
if ((sub_y- (*sub_y_pos)) < page_space)
|
||||||
|
*sub_y_pos = sub_y - page_space;
|
||||||
|
|
||||||
|
// went past end, show full screen
|
||||||
|
else if (*sub_y_pos >= sub_y)
|
||||||
|
*sub_y_pos = sub_y - page_space - 1;
|
||||||
|
|
||||||
|
win_update_virtual(window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
win_update_virtual(ProfWin *window)
|
win_update_virtual(ProfWin *window)
|
||||||
{
|
{
|
||||||
|
@ -37,6 +37,8 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
#ifdef HAVE_NCURSESW_NCURSES_H
|
#ifdef HAVE_NCURSESW_NCURSES_H
|
||||||
#include <ncursesw/ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#elif HAVE_NCURSES_H
|
#elif HAVE_NCURSES_H
|
||||||
@ -176,6 +178,7 @@ void win_show_subwin(ProfWin *window);
|
|||||||
int win_roster_cols(void);
|
int win_roster_cols(void);
|
||||||
int win_occpuants_cols(void);
|
int win_occpuants_cols(void);
|
||||||
void win_printline_nowrap(WINDOW *win, char *msg);
|
void win_printline_nowrap(WINDOW *win, char *msg);
|
||||||
|
void win_handle_page(ProfWin *current, const wint_t ch, const int result);
|
||||||
|
|
||||||
int win_unread(ProfWin *window);
|
int win_unread(ProfWin *window);
|
||||||
gboolean win_has_active_subwin(ProfWin *window);
|
gboolean win_has_active_subwin(ProfWin *window);
|
||||||
|
Loading…
Reference in New Issue
Block a user