mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Add basic win line up and line down key bindings
This commit is contained in:
parent
ed74e000fe
commit
6be99d1dd5
@ -113,6 +113,8 @@ static int _inp_rl_win_pageup_handler(int count, int key);
|
|||||||
static int _inp_rl_win_pagedown_handler(int count, int key);
|
static int _inp_rl_win_pagedown_handler(int count, int key);
|
||||||
static int _inp_rl_subwin_pageup_handler(int count, int key);
|
static int _inp_rl_subwin_pageup_handler(int count, int key);
|
||||||
static int _inp_rl_subwin_pagedown_handler(int count, int key);
|
static int _inp_rl_subwin_pagedown_handler(int count, int key);
|
||||||
|
static int _inp_rl_win_lineup_handler(int count, int key);
|
||||||
|
static int _inp_rl_win_linedown_handler(int count, int key);
|
||||||
static int _inp_rl_startup_hook(void);
|
static int _inp_rl_startup_hook(void);
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -370,6 +372,9 @@ _inp_rl_addfuncs(void)
|
|||||||
rl_add_funmap_entry("prof_subwin_pageup", _inp_rl_subwin_pageup_handler);
|
rl_add_funmap_entry("prof_subwin_pageup", _inp_rl_subwin_pageup_handler);
|
||||||
rl_add_funmap_entry("prof_subwin_pagedown", _inp_rl_subwin_pagedown_handler);
|
rl_add_funmap_entry("prof_subwin_pagedown", _inp_rl_subwin_pagedown_handler);
|
||||||
rl_add_funmap_entry("prof_win_clear", _inp_rl_win_clear_handler);
|
rl_add_funmap_entry("prof_win_clear", _inp_rl_win_clear_handler);
|
||||||
|
|
||||||
|
rl_add_funmap_entry("prof_win_lineup", _inp_rl_win_lineup_handler);
|
||||||
|
rl_add_funmap_entry("prof_win_linedown", _inp_rl_win_linedown_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Readline callbacks
|
// Readline callbacks
|
||||||
@ -420,6 +425,9 @@ _inp_rl_startup_hook(void)
|
|||||||
rl_bind_keyseq("\\e[6~", _inp_rl_win_pagedown_handler);
|
rl_bind_keyseq("\\e[6~", _inp_rl_win_pagedown_handler);
|
||||||
rl_bind_keyseq("\\eOs", _inp_rl_win_pagedown_handler);
|
rl_bind_keyseq("\\eOs", _inp_rl_win_pagedown_handler);
|
||||||
|
|
||||||
|
rl_bind_keyseq("\\ep", _inp_rl_win_lineup_handler);
|
||||||
|
rl_bind_keyseq("\\el", _inp_rl_win_linedown_handler);
|
||||||
|
|
||||||
rl_bind_key('\t', _inp_rl_tab_handler);
|
rl_bind_key('\t', _inp_rl_tab_handler);
|
||||||
|
|
||||||
// unbind unwanted mappings
|
// unbind unwanted mappings
|
||||||
@ -611,6 +619,22 @@ _inp_rl_win_pagedown_handler(int count, int key)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_inp_rl_win_lineup_handler(int count, int key)
|
||||||
|
{
|
||||||
|
ProfWin *current = wins_get_current();
|
||||||
|
win_line_up(current);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_inp_rl_win_linedown_handler(int count, int key)
|
||||||
|
{
|
||||||
|
ProfWin *current = wins_get_current();
|
||||||
|
win_line_down(current);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_inp_rl_subwin_pageup_handler(int count, int key)
|
_inp_rl_subwin_pageup_handler(int count, int key)
|
||||||
{
|
{
|
||||||
|
@ -520,6 +520,62 @@ win_page_down(ProfWin *window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
win_line_up(ProfWin *window)
|
||||||
|
{
|
||||||
|
int rows = getmaxy(stdscr);
|
||||||
|
int y = getcury(window->layout->win);
|
||||||
|
int page_space = rows - 4;
|
||||||
|
int *page_start = &(window->layout->y_pos);
|
||||||
|
|
||||||
|
*page_start -= 1;
|
||||||
|
|
||||||
|
// went past beginning, show first page
|
||||||
|
if (*page_start < 0)
|
||||||
|
*page_start = 0;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
win_line_down(ProfWin *window)
|
||||||
|
{
|
||||||
|
window->layout->paged = 0;
|
||||||
|
|
||||||
|
int win_rows = getmaxy(stdscr) - 4;
|
||||||
|
int win_curr_row = getcury(window->layout->win);
|
||||||
|
int curr_y_pos = window->layout->y_pos;
|
||||||
|
if (win_curr_row - curr_y_pos < win_rows) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int *page_start = &(window->layout->y_pos);
|
||||||
|
|
||||||
|
*page_start += 1;
|
||||||
|
|
||||||
|
// only got half a screen, show full screen
|
||||||
|
if ((win_curr_row - (*page_start)) < win_rows)
|
||||||
|
*page_start = win_curr_row - win_rows;
|
||||||
|
|
||||||
|
// went past end, show full screen
|
||||||
|
else if (*page_start >= win_curr_row)
|
||||||
|
*page_start = win_curr_row - win_rows - 1;
|
||||||
|
|
||||||
|
window->layout->paged = 1;
|
||||||
|
win_update_virtual(window);
|
||||||
|
|
||||||
|
// switch off page if last line and space line visible
|
||||||
|
if ((win_curr_row) - *page_start == win_rows) {
|
||||||
|
window->layout->paged = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
win_sub_page_down(ProfWin *window)
|
win_sub_page_down(ProfWin *window)
|
||||||
{
|
{
|
||||||
|
@ -79,5 +79,7 @@ void win_page_up(ProfWin *window);
|
|||||||
void win_page_down(ProfWin *window);
|
void win_page_down(ProfWin *window);
|
||||||
void win_sub_page_down(ProfWin *window);
|
void win_sub_page_down(ProfWin *window);
|
||||||
void win_sub_page_up(ProfWin *window);
|
void win_sub_page_up(ProfWin *window);
|
||||||
|
void win_line_up(ProfWin *window);
|
||||||
|
void win_line_down(ProfWin *window);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user