You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
433 B
CoffeeScript
29 lines
433 B
CoffeeScript
13 years ago
|
class AsciiIo.TabStops
|
||
|
|
||
|
constructor: (@cols) ->
|
||
|
@stops = (x for x in [0...@cols] when x % 8 is 0)
|
||
|
|
||
|
add: (col) ->
|
||
|
unless _(@stops).include(col)
|
||
|
pos = _(@stops).sortedIndex(col)
|
||
|
@stops.splice(pos, 0, col)
|
||
|
|
||
|
next: (cursorX) ->
|
||
|
for x in @stops
|
||
|
if x > cursorX
|
||
|
return x
|
||
|
|
||
|
@cols
|
||
|
|
||
|
prev: (cursorX) ->
|
||
|
ret = 0
|
||
|
|
||
|
for x in @stops
|
||
|
if x > cursorX
|
||
|
break
|
||
|
|
||
|
ret = x
|
||
|
|
||
|
ret
|
||
|
|