Handle native window resize for when it's possible (app mode). Fix a weird bug for backspace at EOL

This commit is contained in:
Florian Mounier
2015-05-15 11:57:01 +02:00
parent 7d8f3b2845
commit 89a7e05f55
5 changed files with 64 additions and 29 deletions

View File

@@ -1,29 +1,34 @@
from contextlib import contextmanager
import sys
@contextmanager
def html():
print('\x1bP;HTML|')
sys.stdout.write('\x1bP;HTML|')
yield
print('\x1bP')
sys.stdout.write('\x1bP')
sys.stdout.flush()
@contextmanager
def image(mime='image'):
print('\x1bP;IMAGE|%s;' % mime)
sys.stdout.write('\x1bP;IMAGE|%s;' % mime)
yield
print('\x1bP')
sys.stdout.write('\x1bP\n')
sys.stdout.flush()
@contextmanager
def prompt():
print('\x1bP;PROMPT|')
sys.stdout.write('\x1bP;PROMPT|')
yield
print('\x1bP')
sys.stdout.write('\x1bP')
sys.stdout.flush()
@contextmanager
def text():
print('\x1bP;TEXT|')
sys.stdout.write('\x1bP;TEXT|')
yield
print('\x1bP')
sys.stdout.write('\x1bP')
sys.stdout.flush()

File diff suppressed because one or more lines are too long

View File

@@ -237,7 +237,7 @@
this.applicationKeypad = false;
this.applicationCursor = false;
this.originMode = false;
this.wraparoundMode = false;
this.autowrap = true;
this.normal = null;
this.charset = null;
this.gcharset = null;
@@ -777,6 +777,9 @@
this.x = 0;
break;
case "\b":
if (this.x >= this.cols) {
this.x--;
}
if (this.x > 0) {
this.x--;
}
@@ -799,9 +802,11 @@
ch = this.charset[ch];
}
if (this.x >= this.cols) {
this.screen[this.y + this.shift].wrap = true;
if (this.autowrap) {
this.screen[this.y + this.shift].wrap = true;
this.nextLine();
}
this.x = 0;
this.nextLine();
}
this.putChar(ch);
this.x++;
@@ -1654,6 +1659,13 @@
}
};
Terminal.prototype.resizeWindowPlease = function(cols) {
var margin, width;
margin = window.innerWidth - this.body.clientWidth;
width = cols * this.charSize.width + margin;
return resizeTo(width, window.innerHeight);
};
Terminal.prototype.setupStops = function(i) {
var results;
if (i != null) {
@@ -1865,7 +1877,7 @@
}
}
this.x = col;
return this.y = row;
return this.y = row + (this.originMode ? this.scrollTop : 0);
};
Terminal.prototype.eraseInDisplay = function(params) {
@@ -2246,11 +2258,13 @@
return this.setgCharset(3, Terminal.prototype.charsets.US);
case 3:
this.savedCols = this.cols;
return this.resize(132, this.rows);
this.resize(132, this.rows);
this.resizeWindowPlease(132);
return this.reset();
case 6:
return this.originMode = true;
case 7:
return this.wraparoundMode = true;
return this.autowrap = true;
case 66:
return this.applicationKeypad = true;
case 9:
@@ -2322,11 +2336,13 @@
if (this.cols === 132 && this.savedCols) {
this.resize(this.savedCols, this.rows);
}
this.resizeWindowPlease(80);
this.reset();
return delete this.savedCols;
case 6:
return this.originMode = false;
case 7:
return this.wraparoundMode = false;
return this.autowrap = false;
case 66:
return this.applicationKeypad = false;
case 9:
@@ -2474,7 +2490,7 @@
this.cursorHidden = false;
this.insertMode = false;
this.originMode = false;
this.wraparoundMode = false;
this.autowrap = true;
this.applicationKeypad = false;
this.applicationCursor = false;
this.scrollTop = 0;

File diff suppressed because one or more lines are too long

View File

@@ -100,7 +100,6 @@ class Terminal
@body.contentEditable = 'true'
@initmouse()
# setTimeout(@resize.bind(@), 100)
cloneAttr: (a, char=null) ->
bg: a.bg
@@ -142,7 +141,7 @@ class Terminal
@applicationKeypad = false
@applicationCursor = false
@originMode = false
@wraparoundMode = false
@autowrap = true
@normal = null
# charset
@@ -609,6 +608,8 @@ class Terminal
# '\b'
when "\b"
# Cap on overflow
@x-- if @x >= @cols
@x-- if @x > 0
# '\t'
@@ -632,9 +633,10 @@ class Terminal
if ch >= " "
ch = @charset[ch] if @charset?[ch]
if @x >= @cols
@screen[@y + @shift].wrap = true
if @autowrap
@screen[@y + @shift].wrap = true
@nextLine()
@x = 0
@nextLine()
@putChar ch
@x++
@@ -1543,6 +1545,12 @@ class Terminal
@normal = null
@reset() if x or y
resizeWindowPlease: (cols) ->
# This is only when running butterfly in app mode when resizeTo is available
margin = window.innerWidth - @body.clientWidth
width = cols * @charSize.width + margin
resizeTo width, window.innerHeight
setupStops: (i) ->
if i?
i = @prevStop(i) unless @tabs[i]
@@ -1687,8 +1695,7 @@ class Terminal
col = @cols - 1 if col >= @cols
@x = col
@y = row
@y = row + if @originMode then @scrollTop else 0
# CSI Ps J Erase in Display (ED).
# Ps = 0 -> Erase Below (default).
@@ -2250,10 +2257,13 @@ class Terminal
when 3 # 132 col mode
@savedCols = @cols
@resize 132, @rows
@resizeWindowPlease 132
@reset()
# For app mode
when 6
@originMode = true
when 7
@wraparoundMode = true
@autowrap = true
when 66
@applicationKeypad = true
# X10 Mouse
@@ -2407,11 +2417,14 @@ class Terminal
@applicationCursor = false
when 3
@resize @savedCols, @rows if @cols is 132 and @savedCols
@resizeWindowPlease 80
@reset()
# App mode
delete @savedCols
when 6
@originMode = false
when 7
@wraparoundMode = false
@autowrap = false
when 66
@applicationKeypad = false
when 9, 1000, 1002 , 1003 # any event mouse
@@ -2611,7 +2624,7 @@ class Terminal
@cursorHidden = false
@insertMode = false
@originMode = false
@wraparoundMode = false # autowrap
@autowrap = true
@applicationKeypad = false # ?
@applicationCursor = false
@scrollTop = 0