summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2008-10-02 18:54:06 +0200
committerSebastien Helleu <flashcode@flashtux.org>2008-10-02 18:54:06 +0200
commit239dd464d5af94c7136de7d61841d62d59bcf796 (patch)
tree2e73a954735c93eeb168d12ee51a6d53760c2313 /src
parent2ffd141cf497e4c9e4953d302a0eae4c9592c0c3 (diff)
downloadweechat-239dd464d5af94c7136de7d61841d62d59bcf796.zip
Add new option scroll_page_percent to choose percent of height to scroll with page_up and page_down keys (task #8702)
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-config.c7
-rw-r--r--src/core/wee-config.h1
-rw-r--r--src/gui/curses/gui-curses-window.c29
3 files changed, 30 insertions, 7 deletions
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index 5053680e3..83a069269 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -98,6 +98,7 @@ struct t_config_option *config_look_read_marker;
struct t_config_option *config_look_save_config_on_exit;
struct t_config_option *config_look_save_layout_on_exit;
struct t_config_option *config_look_scroll_amount;
+struct t_config_option *config_look_scroll_page_percent;
struct t_config_option *config_look_set_title;
/* config, colors section */
@@ -1061,6 +1062,12 @@ config_weechat_init ()
N_("how many lines to scroll by with scroll_up and "
"scroll_down"),
NULL, 1, INT_MAX, "3", NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL);
+ config_look_scroll_page_percent = config_file_new_option (
+ weechat_config_file, ptr_section,
+ "scroll_page_percent", "integer",
+ N_("percent of screen to scroll when scrolling one page up or down "
+ "(for example 100 means one page, 50 half-page)"),
+ NULL, 1, 100, "100", NULL, NULL, NULL, NULL, NULL, NULL);
config_look_set_title = config_file_new_option (
weechat_config_file, ptr_section,
"set_title", "boolean",
diff --git a/src/core/wee-config.h b/src/core/wee-config.h
index afa4c05fa..dee0e6fe7 100644
--- a/src/core/wee-config.h
+++ b/src/core/wee-config.h
@@ -104,6 +104,7 @@ extern struct t_config_option *config_look_read_marker;
extern struct t_config_option *config_look_save_config_on_exit;
extern struct t_config_option *config_look_save_layout_on_exit;
extern struct t_config_option *config_look_scroll_amount;
+extern struct t_config_option *config_look_scroll_page_percent;
extern struct t_config_option *config_look_set_title;
extern struct t_config_option *config_color_separator;
diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c
index dcdfe4a4f..bc0a3f7ca 100644
--- a/src/gui/curses/gui-curses-window.c
+++ b/src/gui/curses/gui-curses-window.c
@@ -762,10 +762,18 @@ void
gui_window_page_up (struct t_gui_window *window)
{
char scroll[32];
+ int num_lines;
if (!gui_ok)
return;
+ num_lines = ((window->win_chat_height - 1) *
+ CONFIG_INTEGER(config_look_scroll_page_percent)) / 100;
+ if (num_lines < 1)
+ num_lines = 1;
+ else if (num_lines > window->win_chat_height - 1)
+ num_lines = window->win_chat_height - 1;
+
switch (window->buffer->type)
{
case GUI_BUFFER_TYPE_FORMATED:
@@ -774,8 +782,8 @@ gui_window_page_up (struct t_gui_window *window)
gui_chat_calculate_line_diff (window, &window->start_line,
&window->start_line_pos,
(window->start_line) ?
- (-1) * (window->win_chat_height - 1) :
- (-1) * ((window->win_chat_height - 1) * 2));
+ (-1) * (num_lines) :
+ (-1) * (num_lines + window->win_chat_height - 1));
gui_chat_draw (window->buffer, 0);
if (!window->scroll)
{
@@ -789,7 +797,7 @@ gui_window_page_up (struct t_gui_window *window)
if (window->start_line)
{
snprintf (scroll, sizeof (scroll), "-%d",
- window->win_chat_height);
+ num_lines + 1);
gui_window_scroll (window, scroll);
hook_signal_send ("window_scrolled",
WEECHAT_HOOK_SIGNAL_POINTER, window);
@@ -808,12 +816,19 @@ void
gui_window_page_down (struct t_gui_window *window)
{
struct t_gui_line *ptr_line;
- int line_pos;
+ int line_pos, num_lines;
char scroll[32];
if (!gui_ok)
return;
+ num_lines = ((window->win_chat_height - 1) *
+ CONFIG_INTEGER(config_look_scroll_page_percent)) / 100;
+ if (num_lines < 1)
+ num_lines = 1;
+ else if (num_lines > window->win_chat_height - 1)
+ num_lines = window->win_chat_height - 1;
+
switch (window->buffer->type)
{
case GUI_BUFFER_TYPE_FORMATED:
@@ -821,14 +836,14 @@ gui_window_page_down (struct t_gui_window *window)
{
gui_chat_calculate_line_diff (window, &window->start_line,
&window->start_line_pos,
- window->win_chat_height - 1);
+ num_lines);
/* check if we can display all */
ptr_line = window->start_line;
line_pos = window->start_line_pos;
gui_chat_calculate_line_diff (window, &ptr_line,
&line_pos,
- window->win_chat_height - 1);
+ num_lines);
if (!ptr_line)
{
window->start_line = NULL;
@@ -847,7 +862,7 @@ gui_window_page_down (struct t_gui_window *window)
break;
case GUI_BUFFER_TYPE_FREE:
snprintf (scroll, sizeof (scroll), "+%d",
- window->win_chat_height);
+ num_lines + 1);
gui_window_scroll (window, scroll);
hook_signal_send ("window_scrolled",
WEECHAT_HOOK_SIGNAL_POINTER, window);