Skip to content

Commit

Permalink
Add config option for continuous scroll behavior
Browse files Browse the repository at this point in the history
Add config option for continuous scroll behavior

Add continuous scroll option to default config
  • Loading branch information
cscorley authored and gauteh committed Mar 23, 2014
1 parent f31ee51 commit 0b9c8bf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/sup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ def load_config filename
:slip_rows => 0,
:col_jump => 2,
:stem_language => "english",
:sync_back_to_maildir => false
:sync_back_to_maildir => false,
:continuous_scroll => false
}
if File.exists? filename
config = Redwood::load_yaml_obj filename
Expand Down
13 changes: 10 additions & 3 deletions lib/sup/modes/line_cursor_mode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def cursor_down
call_load_more_callbacks buffer.content_height if @curpos >= lines - [buffer.content_height/2,1].max
return false unless @curpos < lines - 1

if @curpos == botline - 3
if @curpos == botline - 3 and $config[:continuous_scroll]
# load more lines, one at a time.
jump_to_line topline + 1
@curpos += 1
Expand All @@ -104,6 +104,9 @@ def cursor_down
set_status
buffer.commit
end
elsif @curpos >= botline - 1
page_down
set_cursor_pos topline
else
@curpos += 1
unless buffer.dirty?
Expand All @@ -118,7 +121,8 @@ def cursor_down

def cursor_up
return false unless @curpos > @cursor_top
if @curpos == topline + 3

if @curpos == topline + 3 and $config[:continuous_scroll]
jump_to_line topline - 1
@curpos -= 1
unless buffer.dirty?
Expand All @@ -127,6 +131,10 @@ def cursor_up
set_status
buffer.commit
end
elsif @curpos == topline
old_topline = topline
page_up
set_cursor_pos [old_topline - 1, topline].max
else
@curpos -= 1
unless buffer.dirty?
Expand Down Expand Up @@ -192,5 +200,4 @@ def call_load_more_callbacks size
@load_more_q.push size if $config[:load_more_threads_when_scrolling]
end
end

end

0 comments on commit 0b9c8bf

Please sign in to comment.