# HG changeset patch # User Mikael Berthe # Date 1399578759 -7200 # Node ID a9440a1d52e5d4979d8b5567acf777c54e2de965 # Parent 5150b3bf4c159331f841563882f2ce7684d975ed# Parent c4a68361883f0b6cbaaae4cea933e083fcf34b93 Merge main with crew diff -r 5150b3bf4c15 -r a9440a1d52e5 mcabber/mcabber/screen.c --- a/mcabber/mcabber/screen.c Thu May 08 19:19:02 2014 +0200 +++ b/mcabber/mcabber/screen.c Thu May 08 21:52:39 2014 +0200 @@ -1138,6 +1138,9 @@ int color = COLOR_GENERAL; bool readmark = FALSE; bool skipline = FALSE; + int autolock; + + autolock = settings_opt_get_int("buffer_smart_scrolling"); prefixwidth = scr_getprefixwidth(); prefixwidth = MIN(prefixwidth, sizeof pref); @@ -1145,6 +1148,8 @@ // Should the window be empty? if (win_entry->bd->cleared) { werase(win_entry->win); + if (autolock && win_entry->bd->lock) + scr_buffer_scroll_lock(0); return; } @@ -1170,8 +1175,8 @@ } else hbuf_head = win_entry->bd->top; - // Get the last CHAT_WIN_HEIGHT lines. - lines = hbuf_get_lines(hbuf_head, CHAT_WIN_HEIGHT); + // Get the last CHAT_WIN_HEIGHT lines, and one more to detect scroll. + lines = hbuf_get_lines(hbuf_head, CHAT_WIN_HEIGHT+1); if (CHAT_WIN_HEIGHT > 1) { // Do we have a read mark? @@ -1327,6 +1332,19 @@ break; } } + line = *(lines+CHAT_WIN_HEIGHT); //line is scrolled out and never written + if (line) { + if (autolock && !win_entry->bd->lock) { + if (!hbuf_jump_readmark(hbuf_head)) + scr_buffer_readmark(TRUE); + scr_buffer_scroll_lock(1); + } + g_free(line->text); + g_free(line); + } else if (autolock && win_entry->bd->lock) { + scr_buffer_scroll_lock(0); + } + g_free(lines); } @@ -2907,6 +2925,7 @@ { winbuf *win_entry; guint isspe; + int autolock; // Get win_entry if (!current_buddy) return; @@ -2915,7 +2934,8 @@ win_entry = scr_search_window(CURRENT_JID, isspe); if (!win_entry) return; - if (!win_entry->bd->lock) { + autolock = settings_opt_get_int("buffer_smart_scrolling"); + if (!win_entry->bd->lock || autolock) { if (action >= 0) hbuf_set_readmark(win_entry->bd->hbuf, action); else diff -r 5150b3bf4c15 -r a9440a1d52e5 mcabber/mcabberrc.example --- a/mcabber/mcabberrc.example Thu May 08 19:19:02 2014 +0200 +++ b/mcabber/mcabberrc.example Thu May 08 21:52:39 2014 +0200 @@ -500,6 +500,14 @@ # Useful when your buddies are chatting from their non-highest priority # resources, forcing you to use /say_to command. #set roster_autolock_resource = 1 +# +# Automatic locking of buffer when scrolled up, and unlocking when scrolled +# to bottom. +# Set 'buffer_smart_scrolling' to 1 to enable. +# Note: manual command "/buffer scroll_lock" will not work when smart scrolling +# is enabled. Command "/buffer scroll_unlock" will only work if there is a new +# message received. +#set buffer_smart_scrolling = 0 # Contacts PGP information # You can provide a PGP key to be used for a given Jabber user, or