lib/sup/modes/scroll-mode.rb in sup-0.0.1 vs lib/sup/modes/scroll-mode.rb in sup-0.0.2
- old
+ new
@@ -12,10 +12,11 @@
k.add :col_right, "Right one column", :right, 'l'
k.add :page_down, "Down one page", :page_down, 'n', ' '
k.add :page_up, "Up one page", :page_up, 'p', :backspace
k.add :jump_to_home, "Jump to top", :home, '^', '1'
k.add :jump_to_end, "Jump to bottom", :end, '$', '0'
+ k.add :jump_to_left, "Jump to the left", '['
end
def initialize opts={}
@topline, @botline, @leftcol = 0, 0, 0
@slip_rows = opts[:slip_rows] || 0 # when we pgup/pgdown,
@@ -46,10 +47,15 @@
def col_right
@leftcol += COL_JUMP
buffer.mark_dirty
end
+ def jump_to_left
+ buffer.mark_dirty unless @leftcol == 0
+ @leftcol = 0
+ end
+
## set top line to l
def jump_to_line l
l = l.clamp 0, lines - 1
return if @topline == l
@topline = l
@@ -61,9 +67,10 @@
def line_up; jump_to_line @topline - 1; end
def page_down; jump_to_line @topline + buffer.content_height - @slip_rows; end
def page_up; jump_to_line @topline - buffer.content_height + @slip_rows; end
def jump_to_home; jump_to_line 0; end
def jump_to_end; jump_to_line lines - buffer.content_height; end
+
def ensure_mode_validity
@topline = @topline.clamp 0, lines - 1
@topline = 0 if @topline < 0 # empty
@botline = [@topline + buffer.content_height, lines].min