diff --git a/keymaps/php-debug.cson b/keymaps/php-debug.cson index 5bafe29..1535457 100644 --- a/keymaps/php-debug.cson +++ b/keymaps/php-debug.cson @@ -34,3 +34,9 @@ 'alt-f6': 'php-debug:stepOver' 'alt-f7': 'php-debug:stepIn' 'alt-f8': 'php-debug:stepOut' + +'atom-workspace .php-debug-console atom-text-editor': + 'alt-up': 'php-debug:navigatePreviousConsoleCommand' + 'alt-down': 'php-debug:navigateNextConsoleCommand' + 'up': 'php-debug:navigatePreviousConsoleCommand' + 'down': 'php-debug:navigateNextConsoleCommand' diff --git a/lib/console/php-debug-console-view.coffee b/lib/console/php-debug-console-view.coffee index e712bf8..5f0c228 100644 --- a/lib/console/php-debug-console-view.coffee +++ b/lib/console/php-debug-console-view.coffee @@ -23,6 +23,8 @@ class PhpDebugConsoleView extends ScrollView super @GlobalContext = params.context @visible = false + @stack = [] + @curCommand = -1 curHeight = atom.config.get('php-debug.currentConsoleHeight') if (curHeight) this.element.style.height = curHeight @@ -86,7 +88,6 @@ class PhpDebugConsoleView extends ScrollView @visible setVisible: (@visible) => - if @visible @panel.show() else @@ -97,9 +98,12 @@ class PhpDebugConsoleView extends ScrollView expression = @consoleCommandLine .getModel() .getText() + # enqueue entered command, limit stack size and update index + @stack.push expression + @stack.shift() if @stack.length > 20 + @curCommand = @stack.length @GlobalContext.notifyConsoleMessage(">" + expression) @GlobalContext.getCurrentDebugContext()?.evalExpression(expression) - @consoleCommandLine .getModel() .setText('') @@ -107,3 +111,14 @@ class PhpDebugConsoleView extends ScrollView isEqual: (other) -> other instanceof PhpDebugConsoleView + + prevCommand: () -> + return unless @stack.length + @curCommand -= 1 if @curCommand > 0 + @consoleCommandLine.getModel().setText(@stack[@curCommand]) + + nextCommand: () -> + return unless @stack.length + len = @stack.length + @curCommand += 1 if @curCommand < len + @consoleCommandLine.getModel().setText(if @curCommand < len then @stack[@curCommand] else '') diff --git a/lib/php-debug.coffee b/lib/php-debug.coffee index d255c7b..e32e3e6 100644 --- a/lib/php-debug.coffee +++ b/lib/php-debug.coffee @@ -157,6 +157,8 @@ module.exports = PhpDebug = @subscriptions.add atom.commands.add 'atom-workspace', 'php-debug:stepOut': => @stepOut() @subscriptions.add atom.commands.add 'atom-workspace', 'php-debug:clearAllBreakpoints': => @clearAllBreakpoints() @subscriptions.add atom.commands.add 'atom-workspace', 'php-debug:clearAllWatchpoints': => @clearAllWatchpoints() + @subscriptions.add atom.commands.add 'atom-workspace', 'php-debug:navigatePreviousConsoleCommand': => @navigatePreviousConsoleCommand() + @subscriptions.add atom.commands.add 'atom-workspace', 'php-debug:navigateNextConsoleCommand': => @navigateNextConsoleCommand() @subscriptions.add atom.workspace.addOpener (filePath) => switch filePath when PhpDebugContextUri @@ -480,3 +482,9 @@ module.exports = PhpDebug = marker = @addBreakpointMarker(line, editor) breakpoint.setMarker(marker) @GlobalContext.addBreakpoint breakpoint + + navigatePreviousConsoleCommand: -> + @consoleView.prevCommand() + + navigateNextConsoleCommand: -> + @consoleView.nextCommand()