Skip to content

Commit

Permalink
Configurable blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
vtortola committed Aug 18, 2014
1 parent 5a7cf73 commit e5e2526
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
.config(['terminalConfigurationProvider', function (terminalConfigurationProvider) {

terminalConfigurationProvider.config('vintage').outputDelay = 10;
terminalConfigurationProvider.config('vintage').allowTypingWriteDisplaying = false;
terminalConfigurationProvider.config('vintage').typeSoundUrl ='example/content/type.wav';
terminalConfigurationProvider.config('vintage').startSoundUrl ='example/content/start.wav';
}])
Expand Down
17 changes: 11 additions & 6 deletions src/vtortola.ng-terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
me.getTypeEffect = null;
me.getStartEffect = null;
me.outputDelay = 0;
me.allowTypingWriteDisplaying = true;

return me;
};
Expand Down Expand Up @@ -139,7 +140,7 @@
var config = terminalConfiguration(configName);
$scope.prompt = promptCreator(config);
$scope.outputDelay = config.outputDelay;

$scope.allowTypingWriteDisplaying = config.allowTypingWriteDisplaying;
if (config.getTypeEffect) {
config.getTypeEffect.then(function (effect) {
$scope.typeSound = effect;
Expand Down Expand Up @@ -330,7 +331,7 @@
});

target.on("keypress", function (e) {
if (scope.showPrompt)
if(scope.showPrompt || scope.allowTypingWriteDisplaying)
scope.keypress(e.which);
e.preventDefault();
});
Expand All @@ -341,18 +342,22 @@
e.preventDefault();
}
if (e.keyCode == 8) {
scope.backspace();
if (scope.showPrompt || scope.allowTypingWriteDisplaying)
scope.backspace();
e.preventDefault();
}
else if (e.keyCode == 13) {
scope.execute();
if (scope.showPrompt || scope.allowTypingWriteDisplaying)
scope.execute();
}
else if (e.keyCode == 38) {
scope.previousCommand();
if (scope.showPrompt || scope.allowTypingWriteDisplaying)
scope.previousCommand();
e.preventDefault();
}
else if (e.keyCode == 40) {
scope.nextCommand();
if (scope.showPrompt || scope.allowTypingWriteDisplaying)
scope.nextCommand();
e.preventDefault();
}
});
Expand Down

0 comments on commit e5e2526

Please sign in to comment.