Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Resize height with window

  • Loading branch information...
commit 18712f432f0e814b367837b08ee580afeb78b7e5 1 parent a2507df
@jondistad authored
Showing with 24 additions and 7 deletions.
  1. +1 −3 javascripts/repl.js
  2. +23 −4 javascripts/tty.js
View
4 javascripts/repl.js
@@ -47,6 +47,7 @@ function Fn(form, fn) {
function Bindings() { }
Bindings.Core = function() { }
+ // TODO: This is just for debugging! Remove it for stable release.
_b = Bindings;
function makeFn(argList, body) {
@@ -106,9 +107,6 @@ function Fn(form, fn) {
try {
return jsFn.apply(jsFn, args);
} catch(err) { // Some native functions can't be called with #apply
- console.log(err);
- var dateStr = (new Date()).toJSON().replace(/\W/g, "");
-
var strArgs = [];
for (i in args) strArgs.push("args["+i+"]");
View
27 javascripts/tty.js
@@ -5,7 +5,7 @@
TTY.console = jqObj;
initConsole();
- var $T = TTY.console.find.bind(TTY.console);
+ var $T = function(selector) { return TTY.console.find(selector); }
TTY.screen = $T('ul');
TTY.command = $T('span.command');
@@ -20,9 +20,23 @@
TTY.history = [];
TTY.historyIdx = -1;
TTY.commandCache = "";
+ setRows();
+ function setRows() {
+ var rows = parseInt($(window).height() / 20) - 7;
+ TTY.rows = (rows > 1) ? rows : 1;
+ }
+
+ $(window).resize(function() {
+ var oldRows = TTY.rows;
+ setRows();
+ if (oldRows < TTY.rows)
+ TTY.screen.find('li:hidden').slice(oldRows - TTY.rows).show();
+ else if (oldRows > TTY.rows)
+ TTY.screen.find('li:visible:lt('+oldRows-TTY.rows+')').hide();
+ });
- blinkCursor(800);
+ blinkCursor(1000);
captureKeys();
function initConsole() {
@@ -71,7 +85,7 @@
drawNewLine();
break;
case 12: // C-l
- $T("li.current").prevAll().remove();
+ $T("li.current").prevAll().hide();
break;
case 13: // CR
moveToEnd();
@@ -94,7 +108,6 @@
typingEvent("#buffer", "keydown", function(e) {
if (e.metaKey) return;
- console.log(e.which);
switch (e.which) {
// History back
@@ -360,6 +373,8 @@
$.each(lines, function(i, line) {
var newLine = $('<li>');
newLine.html(escapeHTML(line));
+ if (TTY.screen.find('li:visible').length >= TTY.rows)
+ TTY.screen.find('li:visible:first').hide();
TTY.screen.append(newLine);
});
}
@@ -376,6 +391,10 @@
newLine.find('.after-cursor').html('');
newLine.find('.cursor').html("&nbsp;").addClass("show-cursor");
newLine.find('.prompt').html(escapeHTML(promptStr));
+
+ if (TTY.screen.find('li:visible').length >= TTY.rows)
+ TTY.screen.find('li:visible:first').hide();
+
TTY.screen.append(newLine);
TTY.command = $T('.command');
Please sign in to comment.
Something went wrong with that request. Please try again.