|
|
|
@ -5,6 +5,7 @@ class AsciiIo.TerminalView extends Backbone.View
|
|
|
|
|
initialize: (options) ->
|
|
|
|
|
@cols = options.cols
|
|
|
|
|
@lines = options.lines
|
|
|
|
|
@cachedSpans = {}
|
|
|
|
|
|
|
|
|
|
@createChildElements()
|
|
|
|
|
@showCursor true
|
|
|
|
@ -49,7 +50,7 @@ class AsciiIo.TerminalView extends Backbone.View
|
|
|
|
|
if prevBrush
|
|
|
|
|
html += '</span>'
|
|
|
|
|
|
|
|
|
|
html += @createSpan(brush, i is cursorX)
|
|
|
|
|
html += @spanFromBrush(brush, i is cursorX)
|
|
|
|
|
|
|
|
|
|
prevBrush = brush
|
|
|
|
|
|
|
|
|
@ -62,7 +63,11 @@ class AsciiIo.TerminalView extends Backbone.View
|
|
|
|
|
|
|
|
|
|
@$el.find(".line:eq(" + n + ")").html html #.join("")
|
|
|
|
|
|
|
|
|
|
createSpan: (brush, hasCursor) ->
|
|
|
|
|
spanFromBrush: (brush, hasCursor) ->
|
|
|
|
|
key = "#{AsciiIo.Brush.hash(brush)}_#{hasCursor}"
|
|
|
|
|
span = @cachedSpans[key]
|
|
|
|
|
|
|
|
|
|
if not span
|
|
|
|
|
span = ""
|
|
|
|
|
|
|
|
|
|
if hasCursor or brush.fg isnt undefined or brush.bg isnt undefined or brush.bright or brush.underline
|
|
|
|
@ -81,6 +86,8 @@ class AsciiIo.TerminalView extends Backbone.View
|
|
|
|
|
span += " cursor visible" if hasCursor
|
|
|
|
|
span += "\">"
|
|
|
|
|
|
|
|
|
|
@cachedSpans[key] = span
|
|
|
|
|
|
|
|
|
|
span
|
|
|
|
|
|
|
|
|
|
showCursor: (show) ->
|
|
|
|
|