mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-29 17:27:22 +02:00
better
This commit is contained in:
parent
d5f456fa0c
commit
6ee05c1f0a
6 changed files with 102 additions and 33 deletions
|
@ -82,7 +82,6 @@ var Sandbox = Backbone.View.extend({
|
|||
Main.getEvents().trigger('commandSubmittedPassive', value);
|
||||
|
||||
util.splitTextCommand(value, function(command) {
|
||||
console.log('adding command', command);
|
||||
this.commandCollection.add(new Command({
|
||||
rawStr: command,
|
||||
parseWaterfall: this.parseWaterfall
|
||||
|
@ -94,7 +93,8 @@ var Sandbox = Backbone.View.extend({
|
|||
var commandMap = {
|
||||
help: this.helpDialog,
|
||||
reset: this.reset,
|
||||
delay: this.delay
|
||||
delay: this.delay,
|
||||
clear: this.clear
|
||||
};
|
||||
var method = commandMap[command.get('method')];
|
||||
if (!method) { throw new Error('no method for that wut'); }
|
||||
|
@ -102,6 +102,11 @@ var Sandbox = Backbone.View.extend({
|
|||
method.apply(this, [command, deferred]);
|
||||
},
|
||||
|
||||
clear: function(command, deferred) {
|
||||
Main.getEvents().trigger('clearOldCommands');
|
||||
command.finishWith(deferred);
|
||||
},
|
||||
|
||||
delay: function(command, deferred) {
|
||||
var amount = parseInt(command.get('regexResults')[1], 10);
|
||||
setTimeout(function() {
|
||||
|
|
|
@ -39,7 +39,8 @@ var instantCommands = [
|
|||
var regexMap = {
|
||||
'help': /^help($|\s)|\?/,
|
||||
'reset': /^reset($|\s)/,
|
||||
'delay': /^delay (\d+)$/
|
||||
'delay': /^delay (\d+)$/,
|
||||
'clear': /^clear($|\s)/
|
||||
};
|
||||
|
||||
var parse = function(str) {
|
||||
|
|
|
@ -310,6 +310,7 @@ var CommandLineHistoryView = Backbone.View.extend({
|
|||
|
||||
this.collection.on('change', this.scrollDown, this);
|
||||
Main.getEvents().on('commandScrollDown', this.scrollDown, this);
|
||||
Main.getEvents().on('clearOldCommands', this.clearOldCommands, this);
|
||||
},
|
||||
|
||||
addWarning: function(msg) {
|
||||
|
@ -325,20 +326,33 @@ var CommandLineHistoryView = Backbone.View.extend({
|
|||
this.collection.add(command);
|
||||
},
|
||||
|
||||
clearOldCommands: function() {
|
||||
// go through and get rid of every command that is "processed" or done
|
||||
var toDestroy = [];
|
||||
|
||||
this.collection.each(function(command) {
|
||||
console.log('this command', command, command.get('status'));
|
||||
if (command.get('status') !== 'inqueue' &&
|
||||
command.get('status') !== 'processing') {
|
||||
toDestroy.push(command);
|
||||
}
|
||||
}, this);
|
||||
|
||||
_.each(toDestroy, function(command) {
|
||||
command.destroy();
|
||||
}, this);
|
||||
this.scrollDown();
|
||||
},
|
||||
|
||||
scrollDown: function() {
|
||||
// if commandDisplay is ever bigger than #terminal, we need to
|
||||
// add overflow-y to terminal and scroll down
|
||||
var cD = $('#commandDisplay')[0];
|
||||
var t = $('#terminal')[0];
|
||||
|
||||
if ($(t).hasClass('scrolling')) {
|
||||
t.scrollTop = t.scrollHeight;
|
||||
return;
|
||||
}
|
||||
if (cD.clientHeight > t.clientHeight) {
|
||||
$(t).css('overflow-y', 'scroll');
|
||||
$(t).css('overflow-x', 'hidden');
|
||||
$(t).addClass('scrolling');
|
||||
var shouldScroll = (cD.clientHeight > t.clientHeight);
|
||||
$(t).toggleClass('scrolling', shouldScroll);
|
||||
if (shouldScroll) {
|
||||
t.scrollTop = t.scrollHeight;
|
||||
}
|
||||
},
|
||||
|
@ -358,3 +372,4 @@ var CommandLineHistoryView = Backbone.View.extend({
|
|||
|
||||
exports.CommandPromptView = CommandPromptView;
|
||||
exports.CommandLineHistoryView = CommandLineHistoryView;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue