Permalink
Browse files

Improved scroll region handling

  • Loading branch information...
1 parent 778f228 commit e26dd20385835b71e25456525ea4f7f9eefcf964 @sickill sickill committed Apr 6, 2012
Showing with 14 additions and 3 deletions.
  1. +14 −3 app/assets/javascripts/player/vt.js.coffee
@@ -207,7 +207,11 @@ class AsciiIo.VT
when "n"
@reportRowAndColumn()
when "r" # Set top and bottom margins (scroll region on VT100)
- @setScrollRegion n or 1, m or @lines
+ if n is undefined
+ n = 1
+ if m is undefined
+ m = @lines
+ @setScrollRegion n, m
handlePrivateControlSequence: (data, params) ->
action = data[data.length - 1]
@@ -334,8 +338,15 @@ class AsciiIo.VT
# ----- Scroll control
setScrollRegion: (top, bottom) ->
- @scrollRegion.setTop(top - 1)
- @scrollRegion.setBottom(bottom - 1)
+ if top < 1
+ top = 1
+
+ if bottom > @lines
+ bottom = @lines
+
+ if bottom > top
+ @scrollRegion.setTop(top - 1)
+ @scrollRegion.setBottom(bottom - 1)
setHorizontalTabStop: ->
@tabStops.add(@cursorX)

0 comments on commit e26dd20

Please sign in to comment.