summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-08-14 01:14:26 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-08-14 01:14:26 +0000
commit285b33e99244bb3c7a5c5b63bf0d0650299b728c (patch)
tree8f748a3396bf176b16795f9d3027a0a8bb5d64b1
parent51b1d80fbe1853f64f530b4d58c77b516979ad90 (diff)
downloadirssi-285b33e99244bb3c7a5c5b63bf0d0650299b728c.zip
/SET scroll ON - should the windows be scrolled by default when you're at
bottom. /WINDOW SCROLL ON|OFF|DEFAULT - Window specific scrolling behaviour, also saved in windows layout. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1751 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r--src/fe-text/gui-windows.c11
-rw-r--r--src/fe-text/gui-windows.h3
-rw-r--r--src/fe-text/mainwindows-layout.c26
-rw-r--r--src/fe-text/module-formats.c2
-rw-r--r--src/fe-text/module-formats.h4
-rw-r--r--src/fe-text/textbuffer-commands.c30
-rw-r--r--src/fe-text/textbuffer-view.c21
-rw-r--r--src/fe-text/textbuffer-view.h7
8 files changed, 88 insertions, 16 deletions
diff --git a/src/fe-text/gui-windows.c b/src/fe-text/gui-windows.c
index e8f5dae3..48c1feb7 100644
--- a/src/fe-text/gui-windows.c
+++ b/src/fe-text/gui-windows.c
@@ -46,7 +46,8 @@ static GUI_WINDOW_REC *gui_window_init(WINDOW_REC *window,
gui->view = textbuffer_view_create(textbuffer_create(),
window->width, window->height,
settings_get_int("indent"),
- settings_get_bool("indent_always"));
+ settings_get_bool("indent_always"),
+ settings_get_bool("scroll"));
return gui;
}
@@ -313,10 +314,15 @@ static void read_settings(void)
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
WINDOW_REC *rec = tmp->data;
+ GUI_WINDOW_REC *gui = WINDOW_GUI(rec);
- textbuffer_view_set_default_indent(WINDOW_GUI(rec)->view,
+ textbuffer_view_set_default_indent(gui->view,
settings_get_int("indent"),
settings_get_bool("indent_always"));
+
+ textbuffer_view_set_scroll(gui->view,
+ gui->use_scroll ? gui->scroll :
+ settings_get_bool("scroll"));
}
special_vars_add_signals(prompt, 4, funcs);
@@ -332,6 +338,7 @@ void gui_windows_init(void)
settings_add_bool("lookandfeel", "indent_always", FALSE);
settings_add_str("lookandfeel", "prompt", "[$[.15]T] ");
settings_add_str("lookandfeel", "prompt_window", "[$winname] ");
+ settings_add_bool("lookandfeel", "scroll", TRUE);
prompt = NULL; prompt_window = NULL;
window_create_override = -1;
diff --git a/src/fe-text/gui-windows.h b/src/fe-text/gui-windows.h
index 4b9792ce..220b4661 100644
--- a/src/fe-text/gui-windows.h
+++ b/src/fe-text/gui-windows.h
@@ -14,6 +14,9 @@ typedef struct {
MAIN_WINDOW_REC *parent;
TEXT_BUFFER_VIEW_REC *view;
+ unsigned int scroll:1;
+ unsigned int use_scroll:1;
+
unsigned int sticky:1;
unsigned int use_insert_after:1;
LINE_REC *insert_after;
diff --git a/src/fe-text/mainwindows-layout.c b/src/fe-text/mainwindows-layout.c
index a97995e0..b92fe108 100644
--- a/src/fe-text/mainwindows-layout.c
+++ b/src/fe-text/mainwindows-layout.c
@@ -26,22 +26,31 @@
#include "mainwindows.h"
#include "gui-windows.h"
+#include "textbuffer-view.h"
static void sig_layout_window_save(WINDOW_REC *window, CONFIG_NODE *node)
{
WINDOW_REC *active;
+ GUI_WINDOW_REC *gui;
- if (WINDOW_GUI(window)->sticky) {
+ gui = WINDOW_GUI(window);
+ if (gui->sticky) {
iconfig_node_set_bool(node, "sticky", TRUE);
- active = WINDOW_MAIN(window)->active;
+ active = gui->parent->active;
if (window != active)
iconfig_node_set_int(node, "parent", active->refnum);
}
+
+ if (gui->use_scroll)
+ iconfig_node_set_bool(node, "scroll", gui->scroll);
}
static void sig_layout_window_restore(WINDOW_REC *window, CONFIG_NODE *node)
{
WINDOW_REC *parent;
+ GUI_WINDOW_REC *gui;
+
+ gui = WINDOW_GUI(window);
parent = window_find_refnum(config_node_get_int(node, "parent", -1));
if (parent != NULL)
@@ -49,6 +58,11 @@ static void sig_layout_window_restore(WINDOW_REC *window, CONFIG_NODE *node)
if (config_node_get_bool(node, "sticky", FALSE))
gui_window_set_sticky(window);
+ if (config_node_get_str(node, "scroll", NULL) != NULL) {
+ gui->use_scroll = TRUE;
+ gui->scroll = config_node_get_bool(node, "scroll", TRUE);
+ textbuffer_view_set_scroll(gui->view, gui->scroll);
+ }
}
static void main_window_save(MAIN_WINDOW_REC *window, CONFIG_NODE *node)
@@ -136,8 +150,8 @@ static void sig_layout_reset(void)
void mainwindows_layout_init(void)
{
- signal_add("layout window save", (SIGNAL_FUNC) sig_layout_window_save);
- signal_add("layout window restore", (SIGNAL_FUNC) sig_layout_window_restore);
+ signal_add("layout save window", (SIGNAL_FUNC) sig_layout_window_save);
+ signal_add("layout restore window", (SIGNAL_FUNC) sig_layout_window_restore);
signal_add("layout save", (SIGNAL_FUNC) sig_layout_save);
signal_add_first("layout restore", (SIGNAL_FUNC) sig_layout_restore);
signal_add("layout reset", (SIGNAL_FUNC) sig_layout_reset);
@@ -145,8 +159,8 @@ void mainwindows_layout_init(void)
void mainwindows_layout_deinit(void)
{
- signal_remove("layout window save", (SIGNAL_FUNC) sig_layout_window_save);
- signal_remove("layout window restore", (SIGNAL_FUNC) sig_layout_window_restore);
+ signal_remove("layout save window", (SIGNAL_FUNC) sig_layout_window_save);
+ signal_remove("layout restore window", (SIGNAL_FUNC) sig_layout_window_restore);
signal_remove("layout save", (SIGNAL_FUNC) sig_layout_save);
signal_remove("layout restore", (SIGNAL_FUNC) sig_layout_restore);
signal_remove("layout reset", (SIGNAL_FUNC) sig_layout_reset);
diff --git a/src/fe-text/module-formats.c b/src/fe-text/module-formats.c
index 248bd03e..928d569a 100644
--- a/src/fe-text/module-formats.c
+++ b/src/fe-text/module-formats.c
@@ -38,6 +38,8 @@ FORMAT_REC gui_text_formats[] =
{ "window_set_sticky", "Window set sticky", 0 },
{ "window_unset_sticky", "Window is not sticky anymore", 0 },
{ "window_info_sticky", "Sticky : $0", 1, { 0 } },
+ { "window_scroll", "Window scroll mode is now $0", 1, { 0 } },
+ { "window_scroll_unknown", "Unknown scroll mode $0, must be ON, OFF or DEFAULT", 1, { 0 } },
{ NULL, NULL, 0 }
};
diff --git a/src/fe-text/module-formats.h b/src/fe-text/module-formats.h
index 055b2b04..e1f6e31f 100644
--- a/src/fe-text/module-formats.h
+++ b/src/fe-text/module-formats.h
@@ -15,7 +15,9 @@ enum {
TXT_WINDOW_NOT_STICKY,
TXT_WINDOW_SET_STICKY,
TXT_WINDOW_UNSET_STICKY,
- TXT_WINDOW_INFO_STICKY
+ TXT_WINDOW_INFO_STICKY,
+ TXT_WINDOW_SCROLL,
+ TXT_WINDOW_SCROLL_UNKNOWN
};
extern FORMAT_REC gui_text_formats[];
diff --git a/src/fe-text/textbuffer-commands.c b/src/fe-text/textbuffer-commands.c
index 2de83515..502b3881 100644
--- a/src/fe-text/textbuffer-commands.c
+++ b/src/fe-text/textbuffer-commands.c
@@ -19,10 +19,12 @@
*/
#include "module.h"
+#include "module-formats.h"
#include "signals.h"
#include "commands.h"
#include "misc.h"
#include "levels.h"
+#include "settings.h"
#include "printtext.h"
#include "gui-windows.h"
@@ -55,6 +57,32 @@ static void cmd_clear(const char *data)
cmd_params_free(free_arg);
}
+static void cmd_window_scroll(const char *data)
+{
+ GUI_WINDOW_REC *gui;
+
+ gui = WINDOW_GUI(active_win);
+ if (g_strcasecmp(data, "default") == 0) {
+ gui->use_scroll = FALSE;
+ } else if (g_strcasecmp(data, "on") == 0) {
+ gui->use_scroll = TRUE;
+ gui->scroll = TRUE;
+ } else if (g_strcasecmp(data, "off") == 0) {
+ gui->use_scroll = TRUE;
+ gui->scroll = FALSE;
+ } else if (*data != '\0') {
+ printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
+ TXT_WINDOW_SCROLL_UNKNOWN, data);
+ return;
+ }
+
+ printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
+ TXT_WINDOW_SCROLL, !gui->use_scroll ? "DEFAULT" :
+ gui->scroll ? "ON" : "OFF");
+ textbuffer_view_set_scroll(gui->view, gui->use_scroll ?
+ gui->scroll : settings_get_bool("scroll"));
+}
+
static void cmd_scrollback(const char *data, SERVER_REC *server,
WI_ITEM_REC *item)
{
@@ -268,6 +296,7 @@ static void sig_away_changed(SERVER_REC *server)
void textbuffer_commands_init(void)
{
command_bind("clear", NULL, (SIGNAL_FUNC) cmd_clear);
+ command_bind("window scroll", NULL, (SIGNAL_FUNC) cmd_window_scroll);
command_bind("scrollback", NULL, (SIGNAL_FUNC) cmd_scrollback);
command_bind("scrollback clear", NULL, (SIGNAL_FUNC) cmd_scrollback_clear);
command_bind("scrollback goto", NULL, (SIGNAL_FUNC) cmd_scrollback_goto);
@@ -284,6 +313,7 @@ void textbuffer_commands_init(void)
void textbuffer_commands_deinit(void)
{
command_unbind("clear", (SIGNAL_FUNC) cmd_clear);
+ command_unbind("window scroll", (SIGNAL_FUNC) cmd_window_scroll);
command_unbind("scrollback", (SIGNAL_FUNC) cmd_scrollback);
command_unbind("scrollback clear", (SIGNAL_FUNC) cmd_scrollback_clear);
command_unbind("scrollback goto", (SIGNAL_FUNC) cmd_scrollback_goto);
diff --git a/src/fe-text/textbuffer-view.c b/src/fe-text/textbuffer-view.c
index e27a7826..c7959774 100644
--- a/src/fe-text/textbuffer-view.c
+++ b/src/fe-text/textbuffer-view.c
@@ -373,7 +373,8 @@ static void textbuffer_view_init_ypos(TEXT_BUFFER_VIEW_REC *view)
TEXT_BUFFER_VIEW_REC *textbuffer_view_create(TEXT_BUFFER_REC *buffer,
int width, int height,
int default_indent,
- int longword_noindent)
+ int longword_noindent,
+ int scroll)
{
TEXT_BUFFER_VIEW_REC *view;
@@ -387,7 +388,8 @@ TEXT_BUFFER_VIEW_REC *textbuffer_view_create(TEXT_BUFFER_REC *buffer,
view->width = width;
view->height = height;
view->default_indent = default_indent;
- view->longword_noindent = longword_noindent;
+ view->longword_noindent = longword_noindent;
+ view->scroll = scroll;
view->cache = textbuffer_cache_get(view->siblings, width);
textbuffer_view_init_bottom(view);
@@ -443,6 +445,11 @@ void textbuffer_view_set_default_indent(TEXT_BUFFER_VIEW_REC *view,
view->longword_noindent = longword_noindent;
}
+void textbuffer_view_set_scroll(TEXT_BUFFER_VIEW_REC *view, int scroll)
+{
+ view->scroll = scroll;
+}
+
static int view_get_linecount_all(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line)
{
int linecount;
@@ -764,11 +771,13 @@ static void view_insert_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line)
}
if (view->bottom) {
- if (view->ypos >= view->height) {
+ if (view->scroll && view->ypos >= view->height) {
linecount = view->ypos-view->height+1;
view_scroll(view, &view->startline,
&view->subline, linecount, FALSE);
view->ypos -= linecount;
+ } else {
+ view->bottom = view_is_bottom(view);
}
if (view->window != NULL) {
@@ -779,8 +788,10 @@ static void view_insert_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line)
subline = -ypos;
ypos = 0;
}
- view_line_draw(view, line, subline, ypos,
- view->height - ypos);
+ if (ypos < view->height) {
+ view_line_draw(view, line, subline, ypos,
+ view->height - ypos);
+ }
}
}
diff --git a/src/fe-text/textbuffer-view.h b/src/fe-text/textbuffer-view.h
index 51973acf..d49798df 100644
--- a/src/fe-text/textbuffer-view.h
+++ b/src/fe-text/textbuffer-view.h
@@ -45,7 +45,8 @@ typedef struct {
int width, height;
int default_indent;
- int longword_noindent:1;
+ unsigned int longword_noindent:1;
+ unsigned int scroll:1; /* scroll down automatically when at bottom */
TEXT_BUFFER_CACHE_REC *cache;
int ypos; /* cursor position - visible area is 0..height-1 */
@@ -72,13 +73,15 @@ typedef struct {
TEXT_BUFFER_VIEW_REC *textbuffer_view_create(TEXT_BUFFER_REC *buffer,
int width, int height,
int default_indent,
- int longword_noindent);
+ int longword_noindent,
+ int scroll);
/* Destroy the view. */
void textbuffer_view_destroy(TEXT_BUFFER_VIEW_REC *view);
/* Change the default indent position */
void textbuffer_view_set_default_indent(TEXT_BUFFER_VIEW_REC *view,
int default_indent,
int longword_noindent);
+void textbuffer_view_set_scroll(TEXT_BUFFER_VIEW_REC *view, int scroll);
/* Resize the view. */
void textbuffer_view_resize(TEXT_BUFFER_VIEW_REC *view, int width, int height);