X-Git-Url: https://jasonwoof.com/gitweb/?p=watch-my-terminal.git;a=blobdiff_plain;f=server.coffee;h=5beaa97c70a8aafbf14aaf2bcdf5ef2dbd256c78;hp=bf3a7502449f2e42e975283c4e5d5e8c310cb8b7;hb=a5f32e3687419a20da142d86f1d4e4f44b60cb52;hpb=55d03d755b1b783e32faa32bf0a4d59260660184 diff --git a/server.coffee b/server.coffee index bf3a750..5beaa97 100644 --- a/server.coffee +++ b/server.coffee @@ -77,11 +77,15 @@ io.sockets.on 'connection', (socket) -> encode_screen = (height, width, text, attributes) -> state = '' for y in [0...height] - for x in [0...width] - if attributes[y][x] isnt a - state += attr_diff a, attributes[y][x] - a = attributes[y][x] - state += text[y][x] + max = width - 1 + while max >= 0 and text[y][max] is ' ' and (attributes[y][max] & 0x08ff00) is 0 + max -= 1 + if max >= 0 + for x in [0..max] + if attributes[y][x] isnt a + state += attr_diff a, attributes[y][x] + a = attributes[y][x] + state += text[y][x] if y < height - 1 state += '\n' return state