Interesting Fixes

This commit is contained in:
Florian Mounier
2016-10-13 17:45:12 +02:00
parent da659b7526
commit b0e1f37cac
8 changed files with 57 additions and 27 deletions

View File

@@ -22,7 +22,7 @@ html, body
color: $fg
body
margin-bottom: .5em
padding-bottom: .5em
white-space: nowrap
overflow-x: hidden
overflow-y: scroll

View File

@@ -258,6 +258,14 @@
return maybePack();
});
Terminal.on('clear', function() {
var hist, newHist;
newHist = document.createElement('div');
newHist.id = 'packed';
hist = document.getElementById('packed');
return butterfly.body.replaceChild(newHist, hist);
});
Popup = (function() {
function Popup() {
this.el = document.getElementById('popup');

File diff suppressed because one or more lines are too long

View File

@@ -2804,7 +2804,7 @@ html, body {
color: #f4ead5; }
body {
margin-bottom: .5em;
padding-bottom: .5em;
white-space: nowrap;
overflow-x: hidden;
overflow-y: scroll;

View File

@@ -314,7 +314,7 @@
this.prefix = "";
this.screen = [];
this.shift = 0;
for (row = k = 0, ref = this.rows; 0 <= ref ? k <= ref : k >= ref; row = 0 <= ref ? ++k : --k) {
for (row = k = 0, ref = this.rows - 1; 0 <= ref ? k <= ref : k >= ref; row = 0 <= ref ? ++k : --k) {
this.screen.push(this.blankLine(false, false));
}
this.setupStops();
@@ -692,7 +692,11 @@
div.classList.add('extended');
}
div.innerHTML = (this.lineToDom(y, line, active)).join('');
results.push(this.active = div);
if (active) {
this.active = div;
this.cursor = div.querySelectorAll('.cursor')[0];
}
results.push(div);
} else {
results.push(void 0);
}
@@ -727,8 +731,13 @@
if (force == null) {
force = false;
}
if ((ref = this.active) != null) {
ref.classList.remove('active');
if (this.active != null) {
this.active.classList.remove('active');
}
if (this.cursor) {
if ((ref = this.cursor.parentNode) != null) {
ref.replaceChild(this.document.createTextNode(this.cursor.textContent), this.cursor);
}
}
dom = this.screenToDom(force);
this.writeDom(dom);
@@ -737,16 +746,14 @@
};
Terminal.prototype._cursorBlink = function() {
var cursor;
this.cursorState ^= 1;
cursor = this.term.querySelector(".cursor");
if (!cursor) {
if (!this.cursor) {
return;
}
if (cursor.classList.contains("reverse-video")) {
return cursor.classList.remove("reverse-video");
if (this.cursor.classList.contains("reverse-video")) {
return this.cursor.classList.remove("reverse-video");
} else {
return cursor.classList.add("reverse-video");
return this.cursor.classList.add("reverse-video");
}
};
@@ -1787,6 +1794,9 @@
if (this.y >= this.rows) {
this.y = this.rows - 1;
}
if (this.y < 0) {
this.y = 0;
}
if (this.x >= this.cols) {
this.x = this.cols - 1;
}
@@ -1946,12 +1956,10 @@
};
Terminal.prototype.clearScrollback = function() {
var results;
results = [];
while (this.term.childElementCount > this.rows) {
results.push(this.term.firstChild.remove());
this.term.firstChild.remove();
}
return results;
return this.emit('clear');
};
Terminal.prototype.tabSet = function() {

File diff suppressed because one or more lines are too long

View File

@@ -21,3 +21,9 @@ maybePack = ->
Terminal.on 'refresh', ->
clearTimeout tid if tid
maybePack()
Terminal.on 'clear', ->
newHist = document.createElement 'div'
newHist.id = 'packed'
hist = document.getElementById 'packed'
butterfly.body.replaceChild newHist, hist

View File

@@ -194,7 +194,7 @@ class Terminal
@prefix = ""
@screen = []
@shift = 0
for row in [0..@rows]
for row in [0..@rows - 1]
@screen.push @blankLine(false, false)
@setupStops()
@skipNextKey = null
@@ -513,7 +513,10 @@ class Terminal
div.classList.add 'active' if active
div.classList.add 'extended' if line.extra
div.innerHTML = (@lineToDom y, line, active).join('')
@active = div
if active
@active = div
@cursor = div.querySelectorAll('.cursor')[0]
div
writeDom: (dom) ->
r = Math.max @term.childElementCount - @rows, 0
@@ -533,7 +536,11 @@ class Terminal
@screen = @screen.slice -@rows
refresh: (force=false) ->
@active?.classList.remove('active')
if @active?
@active.classList.remove('active')
if @cursor
@cursor.parentNode?.replaceChild(
@document.createTextNode(@cursor.textContent), @cursor)
dom = @screenToDom(force)
@writeDom dom
@nativeScrollTo()
@@ -541,12 +548,11 @@ class Terminal
_cursorBlink: ->
@cursorState ^= 1
cursor = @term.querySelector(".cursor")
return unless cursor
if cursor.classList.contains("reverse-video")
cursor.classList.remove "reverse-video"
return unless @cursor
if @cursor.classList.contains("reverse-video")
@cursor.classList.remove "reverse-video"
else
cursor.classList.add "reverse-video"
@cursor.classList.add "reverse-video"
showCursor: ->
unless @cursorState
@@ -1598,6 +1604,7 @@ class Terminal
# make sure the cursor stays on screen
@y = @rows - 1 if @y >= @rows
@y = 0 if @y < 0
@x = @cols - 1 if @x >= @cols
@scrollTop = 0
@scrollBottom = @rows - 1
@@ -1704,6 +1711,7 @@ class Terminal
# Drop DOM history
while @term.childElementCount > @rows
@term.firstChild.remove()
@emit 'clear'
# ESC H Tab Set (HTS is 0x88).
tabSet: ->