Minor clean

This commit is contained in:
Florian Mounier
2014-02-13 12:30:44 +01:00
parent 1eb4df9003
commit d986ee8ba7
3 changed files with 21 additions and 48 deletions

View File

@@ -36,7 +36,11 @@ ws.onopen = ->
ws.onerror = -> console.log "WebSocket error", arguments
ws.onmessage = (e) -> term.write e.data
ws.onmessage = (e) ->
setTimeout ->
term.write e.data
, 1
ws.onclose = ->
console.log "WebSocket closed", arguments

View File

@@ -35,10 +35,6 @@ cancel = (ev) ->
ev.cancelBubble = true
false
isWide = (ch) ->
return false if ch <= ""
(ch >= "" and ch <= "") or (ch >= "" and ch <= "") or (ch >= "" and ch <= "") or (ch >= "" and ch <= "") or (ch >= "" and ch <= "") or (ch >= "" and ch <= "") or (ch >= "" and ch <= "")
s = 0
State =
normal: s++
@@ -140,7 +136,8 @@ class Terminal
# Terminal lines
@children = [];
for i in [0..@rows]
i = @rows
while i--
div = @document.createElement('div')
@element.appendChild(div)
@children.push(div)
@@ -348,7 +345,7 @@ class Terminal
sendButton ev
else
return if @applicationKeypad
@scrollDisp ev.deltaY | 0
@scrollDisp if ev.deltaY > 0 then 5 else -5
cancel ev
@@ -361,7 +358,6 @@ class Terminal
y = start
if end >= @lines.length
@log "`end` is too large. Most likely a bad CSR."
end = @lines.length - 1
while y <= end
@@ -423,7 +419,7 @@ class Terminal
if ch <= " "
out += "&nbsp;"
else
i++ if isWide(ch)
i++ if "\uff00" < ch < "\uffef"
out += ch
out += "</span>" if i is x
attr = data
@@ -571,7 +567,7 @@ class Terminal
@lines[@y + @ybase][@x] = [@curAttr, ch]
@x++
@updateRange @y
if isWide(ch)
if "\uff00" < ch < "\uffef"
j = @y + @ybase
if @cols < 2 or @x >= @cols
@lines[j][@x - 1] = [@curAttr, " "]
@@ -1037,13 +1033,6 @@ class Terminal
@send "\x1bP" + +valid + "$r" + pt + "\x1b\\"
# Set Termcap/Terminfo Data (xterm, experimental).
when "+p"
break
# Request Termcap/Terminfo String (xterm, experimental)
# Regular xterm does not even respond to this sequence.
# This can cause a small glitch in vim.
# test: echo -ne '\eP+q6b64\e\\'
when "+q"
pt = @currentParam
valid = false
@@ -1085,8 +1074,7 @@ class Terminal
return true if ev.keyCode > 15 and ev.keyCode < 19
# Handle shift insert and ctrl insert copy/paste usefull for typematrix keyboard
if (ev.shiftKey or ev.ctrlKey) and ev.keyCode is 45
return true
return true if (ev.shiftKey or ev.ctrlKey) and ev.keyCode is 45
# Alt-z works as an escape to relay the following keys to the browser.
# usefull to trigger browser shortcuts, i.e.: Alt+Z F5 to reload
@@ -1374,18 +1362,6 @@ class Terminal
@element.classList.remove "bell"
), @visualBell
log: ->
return unless @debug
return if not @context.console or not @context.console.log
args = Array::slice.call(arguments)
@context.console.log.apply @context.console, args
error: ->
return unless @debug
return if not @context.console or not @context.console.error
args = Array::slice.call(arguments)
@context.console.error.apply @console.console, args
resize: (x, y) ->
x = 1 if x < 1
y = 1 if y < 1
@@ -2182,7 +2158,6 @@ class Terminal
when 7
@wraparoundMode = true
when 66
@log "Serial port requested application keypad."
@applicationKeypad = true
# X10 Mouse
# no release, no motion, no wheel, no modifiers.
@@ -2194,7 +2169,6 @@ class Terminal
@normalMouse = params > 1000
@mouseEvents = true
@element.style.cursor = "default"
@log "Binding to mouse events."
when 1004 # send focusin/focusout events
# focusin: ^[[I
# focusout: ^[[O
@@ -2336,7 +2310,6 @@ class Terminal
when 7
@wraparoundMode = false
when 66
@log "Switching back to normal keypad."
@applicationKeypad = false
when 9, 1000, 1002 , 1003 # any event mouse
@x10Mouse = false

View File

@@ -1,5 +1,5 @@
// Generated by CoffeeScript 1.6.3
var $, State, Terminal, alt, bench, cancel, cbench, cols, ctrl, e, first, isWide, quit, resize, rows, s, state, term, virtual_input, ws, ws_url;
var $, State, Terminal, alt, bench, cancel, cbench, cols, ctrl, e, first, quit, resize, rows, s, state, term, virtual_input, ws, ws_url;
term = ws = null;
@@ -28,7 +28,9 @@ ws.onerror = function() {
};
ws.onmessage = function(e) {
return term.write(e.data);
return setTimeout(function() {
return term.write(e.data);
}, 1);
};
ws.onclose = function() {
@@ -185,13 +187,6 @@ cancel = function(ev) {
return false;
};
isWide = function(ch) {
if (ch <= "＀") {
return false;
}
return (ch >= "" && ch <= "ᄒ") || (ch >= "ᅡ" && ch <= "ᅦ") || (ch >= "ᅧ" && ch <= "ᅬ") || (ch >= "ᅭ" && ch <= "ᅲ") || (ch >= "ᅳ" && ch <= "ᅵ") || (ch >= "¢" && ch <= "₩") || (ch >= "" && ch <= "○");
};
s = 0;
State = {
@@ -286,7 +281,7 @@ Terminal = (function() {
};
Terminal.prototype.open = function(parent) {
var div, i, _i, _ref;
var div, i;
this.parent = parent || this.parent;
if (!this.parent) {
throw new Error('Terminal requires a parent element');
@@ -299,7 +294,8 @@ Terminal = (function() {
this.element.style.outline = 'none';
this.element.setAttribute('tabindex', 0);
this.children = [];
for (i = _i = 0, _ref = this.rows; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) {
i = this.rows;
while (i--) {
div = this.document.createElement('div');
this.element.appendChild(div);
this.children.push(div);
@@ -488,7 +484,7 @@ Terminal = (function() {
if (_this.applicationKeypad) {
return;
}
_this.scrollDisp(ev.deltaY | 0);
_this.scrollDisp(ev.deltaY > 0 ? 5 : -5);
}
return cancel(ev);
});
@@ -577,7 +573,7 @@ Terminal = (function() {
if (ch <= " ") {
out += "&nbsp;";
} else {
if (isWide(ch)) {
if (ch > "＀" && (ch >= "" && ch <= "ᄒ") || (ch >= "ᅡ" && ch <= "ᅦ") || (ch >= "ᅧ" && ch <= "ᅬ") || (ch >= "ᅭ" && ch <= "ᅲ") || (ch >= "ᅳ" && ch <= "ᅵ") || (ch >= "¢" && ch <= "₩") || (ch >= "" && ch <= "○")) {
i++;
}
out += ch;
@@ -742,7 +738,7 @@ Terminal = (function() {
this.lines[this.y + this.ybase][this.x] = [this.curAttr, ch];
this.x++;
this.updateRange(this.y);
if (isWide(ch)) {
if (ch > "＀" && (ch >= "" && ch <= "ᄒ") || (ch >= "ᅡ" && ch <= "ᅦ") || (ch >= "ᅧ" && ch <= "ᅬ") || (ch >= "ᅭ" && ch <= "ᅲ") || (ch >= "ᅳ" && ch <= "ᅵ") || (ch >= "¢" && ch <= "₩") || (ch >= "" && ch <= "○")) {
j = this.y + this.ybase;
if (this.cols < 2 || this.x >= this.cols) {
this.lines[j][this.x - 1] = [this.curAttr, " "];