X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=htmlterm.coffee;h=1cfef45f3ed4788b4bbb081c7cb91623a366e617;hb=refs%2Fheads%2Fmaster;hp=829f7578f3dde9e6e2b7d1c428ef271d881dc566;hpb=9c8a049528fc2d75883a76581635335ed98956a6;p=watch-my-terminal.git
diff --git a/htmlterm.coffee b/htmlterm.coffee
index 829f757..1cfef45 100644
--- a/htmlterm.coffee
+++ b/htmlterm.coffee
@@ -60,6 +60,7 @@ class HTMLTerminal
]
@parent_element.css backgroundColor: "##{@palette[0]}", color: "##{@palette[7]}"
+ @redraw()
color_to_css: (i) ->
# handle inverse bit
@@ -90,14 +91,13 @@ class HTMLTerminal
return $('').text(txt)
redraw_now: ->
- console.log('redraw_now')
@parent_element.empty()
# cursor can be just off the right side, but we draw it on the last column in that case
if @term.x >= @term.width
cursor_x = @term.width - 1
else
cursor_x = @term.x
- # invert the cursor TODO: make it blink
+ # invert the cursor
if @term.cursor_visible
@term.attributes[@term.y][cursor_x] ^= 0x080000
for i in [0...@term.text.length]
@@ -112,14 +112,27 @@ class HTMLTerminal
a = @term.attributes[i][j]
txt += @term.text[i][j]
if txt.length
- div.append(@stylize(txt, a))
+ if a is 0x000007
+ # don't output spaces at the end, for better copy/paste
+ ns = txt.length - 1
+ while ns >= 0 and txt.charAt(ns) is ' '
+ ns -= 1
+ if ns >= 0
+ if ns < txt.length - 1
+ txt = txt.substr 0, ns + 1
+ div.append(@stylize(txt, a))
+ else
+ # if entire line is spaces
+ if txt.length is @term.width
+ div.append('
')
+ else
+ div.append(@stylize(txt, a))
@parent_element.append(div)
if @term.cursor_visible
@term.attributes[@term.y][cursor_x] ^= 0x080000
# limit to 50fps
redraw: ->
- console.log('redraw')
if (@redraw_wait)
@redraw_again = true
else