diff --git a/web/app/sketcher/main2d.js b/web/app/sketcher/main2d.js index 07d71306..e6099af9 100644 --- a/web/app/sketcher/main2d.js +++ b/web/app/sketcher/main2d.js @@ -30,6 +30,9 @@ TCAD.App2D = function() { consoleBtn.click(function() { commandsWin.toggle(); }); + new TCAD.ui.Terminal(commandsWin, function(command) { + return "Command " + command + " executed"; + }); this.winManager.registerResize(dockEl, TCAD.ui.DIRECTIONS.EAST, function() {$('body').trigger('layout'); }); $('body').on('layout', this.viewer.onWindowResize); diff --git a/web/app/ui.js b/web/app/ui.js index 0a14b014..df36f89e 100644 --- a/web/app/ui.js +++ b/web/app/ui.js @@ -4,7 +4,8 @@ TCAD.ui = {}; TCAD.ui.Window = function(el, winManager) { this.root = el; this.neverOpened = !this.root.is(':visible'); - this.tileUpRelative = $('body'); + this.tileUpRelative = $('body'); + this.onShowCallback = null; var root = this.root; var caption = this.root.find('.tool-caption'); caption.each(function() { @@ -20,11 +21,15 @@ TCAD.ui.Window = function(el, winManager) { }; TCAD.ui.Window.prototype.toggle = function() { - if (!this.root.is(':visible')) { + var aboutToShow = !this.root.is(':visible'); + if (aboutToShow) { this.tileUpPolicy(this.neverOpened, this.tileUpRelative); } this.neverOpened = false ; this.root.toggle(); + if (aboutToShow && this.onShowCallback != null) { + this.onShowCallback(this); + } }; TCAD.ui.Window.prototype.tileUpPolicy = function(firstTime, relativeEl) { @@ -374,3 +379,23 @@ TCAD.ui.Dock.prototype.isVisible = function(viewName) { TCAD.ui._maskTest = function (mask, value) { return (mask & value) === value; }; + + +TCAD.ui.Terminal = function(win, commandProcessor) { + this.win = win; + win.onShowCallback = function() { + win.root.find('.terminal-input input').focus(); + }; + + win.root.find('.terminal-input input').keyup(function(e){ + if(e.keyCode == 13) { + var input = win.root.find('.terminal-input input'); + var command = input.val(); + var out = win.root.find('.terminal-output'); + input.val(''); + out.append($('