mirror of
https://github.com/irssi/irssi.git
synced 2024-09-01 04:14:16 -04:00
/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
This commit is contained in:
parent
51b1d80fbe
commit
285b33e992
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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 }
|
||||
};
|
||||
|
@ -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[];
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user