asciinema.org/app/assets/javascripts/player/renderers/base.js.coffee
2012-03-22 21:27:05 +01:00

46 lines
994 B
CoffeeScript

class AsciiIo.Renderer.Base extends Backbone.View
events:
'click': 'onClick'
initialize: (options) ->
@cols = options.cols
@lines = options.lines
@showCursor true
@startCursorBlink()
onClick: ->
@trigger('terminal-click')
render: (changes, cursorX, cursorY) ->
for n, fragments of changes
c = if parseInt(n) is cursorY then cursorX else undefined
@renderLine n, fragments || [], c
renderLine: (n, data, cursorX) ->
throw '#renderLine not implemented'
afterInsertedToDom: ->
showCursor: (show) ->
throw '#showCursor not implemented'
blinkCursor: ->
throw '#blinkCursor not implemented'
resetCursorState: ->
startCursorBlink: ->
@cursorTimerId = setInterval(@blinkCursor.bind(this), 500)
stopCursorBlink: ->
if @cursorTimerId
clearInterval @cursorTimerId
@cursorTimerId = null
restartCursorBlink: ->
@stopCursorBlink()
@resetCursorState()
@startCursorBlink()
visualBell: ->