Tab stop support

openid
Marcin Kulik 13 years ago
parent dd737d4134
commit c3f3da1318

@ -166,6 +166,7 @@ class AsciiIo.VT
"\x1bP([^\\\\])*?\\\\": (data) -> # DCS, Device Control String "\x1bP([^\\\\])*?\\\\": (data) -> # DCS, Device Control String
"\x1bD": -> @index() "\x1bD": -> @index()
"\x1bE": -> @newLine() "\x1bE": -> @newLine()
"\x1bH": -> @setHorizontalTabStop()
"\x1bM": -> @reverseIndex() "\x1bM": -> @reverseIndex()
"\x1b7": (data) -> # save cursor pos and char attrs "\x1b7": (data) -> # save cursor pos and char attrs
@ -224,7 +225,6 @@ class AsciiIo.VT
@eraseCharacters @n @eraseCharacters @n
when "Z" when "Z"
@goToPriorHorizontalTabStop @n @goToPriorHorizontalTabStop @n
when "b" when "b"
@repeatLastCharacter @n @repeatLastCharacter @n
when "d" # VPA - Vertical Position Absolute when "d" # VPA - Vertical Position Absolute
@ -484,15 +484,43 @@ class AsciiIo.VT
@goToColumn col @goToColumn col
setHorizontalTabStop: -> setHorizontalTabStop: ->
# @tabStops << @cursorX unless _(@tabStops).include(@cursorX)
pos = _(@tabStops).sortedIndex(@cursorX)
@tabStops.splice(pos, 0, @cursorX)
goToNextHorizontalTabStop: (n) ->
x = @getNextTabStop()
@goToRowAndColumn(@cursorY + 1, x + 1)
@updateLine()
goToPriorHorizontalTabStop: (n) ->
x = @getPriorTabStop()
@goToRowAndColumn(@cursorY + 1, x + 1)
@updateLine()
getNextTabStop: ->
for x in @tabStops
if x > @cursorX
return x
@cols
getPriorTabStop: ->
ret = 0
for x in @tabStops
if x > @cursorX
break
goToNextHorizontalTabStop: -> ret = x
goToPriorHorizontalTabStop: -> ret
clearHorizontalTabStop: -> clearHorizontalTabStop: ->
console.log 'clearHorizontalTabStop'
clearAllHorizontalTabStops: -> clearAllHorizontalTabStops: ->
console.log 'clearAllHorizontalTabStops'
saveCursor: -> saveCursor: ->
@savedCol = @cursorX @savedCol = @cursorX
@ -605,6 +633,7 @@ class AsciiIo.VT
@lineData = @normalBuffer @lineData = @normalBuffer
@dirtyLines = {} @dirtyLines = {}
@brush = AsciiIo.Brush.create({}) @brush = AsciiIo.Brush.create({})
@tabStops = (x for x in [0...@cols] when x % 8 is 0)
@fg = @bg = undefined @fg = @bg = undefined
@bright = false @bright = false

Loading…
Cancel
Save