Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions keymaps/php-debug.cson
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@
'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'
19 changes: 17 additions & 2 deletions lib/console/php-debug-console-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -86,7 +88,6 @@ class PhpDebugConsoleView extends ScrollView
@visible

setVisible: (@visible) =>

if @visible
@panel.show()
else
Expand All @@ -97,13 +98,27 @@ 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('')
event.cancel()

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 '')
19 changes: 15 additions & 4 deletions lib/context/context-variable-list-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,24 @@ class ContextVariableListView extends View
@content: (params) ->
dataname = if params.name then params.name else ''
dataname = if !!params.parent then params.parent + '.' + dataname else dataname
nameIsNumeric = /^\d+$/.test(params.name)
label = params.name
if !params.parent # root taxonomy (Locals, etc.)
labelClass = 'syntax--type'
else if params.parent.indexOf('.') == -1 # variable
labelClass = 'syntax--variable'
else # array key, object property
labelClass = "syntax--property #{if nameIsNumeric then 'syntax--constant syntax--numeric' else 'syntax--string'}"
label = '"' + params.name + '"'
valueClass = switch params.type
when 'array' then 'syntax--support syntax--function'
when 'object' then 'syntax--entity syntax--name syntax--type'
else ''
@li class: "context-variable-list-view", =>
@details 'data-name': dataname, =>
@summary =>
@span class: 'variable php', params.name
@span class: 'type php', params.summary
@span class: "variable php syntax--php #{labelClass}", label
@span class: "type php syntax--php syntax--#{params.type} #{valueClass}", params.summary
@ul outlet: "contextVariableList"

initialize: ({@variables,@autoopen,@parent,@name,@openpaths}) ->
Expand All @@ -25,5 +38,3 @@ class ContextVariableListView extends View
if @variables
for variable in @variables
@contextVariableList.append(new ContextVariableView({variable:variable, parent: path,openpaths:@openpaths}))


43 changes: 38 additions & 5 deletions lib/context/context-variable-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ helpers = require '../helpers'

module.exports =
class ContextVariableView extends View

@content: =>
@li class: 'native-key-bindings', =>
@div class: 'native-key-bindings', tabindex: -1, outlet: 'variableView'
Expand All @@ -12,12 +13,28 @@ class ContextVariableView extends View
@render()

renderScalar: ({label,value}) ->
"<span class=\"variable php\">#{label}</span><span class=\"type php\">#{value}</span>"
labelIsNumeric = /^\d+$/.test(label)
if @parent == 'User defined constants'
labelClass = "variable php syntax--php syntax--constant"
else
labelClass = 'variable php syntax--php ' + switch label[0]
when '$' then 'syntax--variable'
else "syntax--property #{if labelIsNumeric then 'syntax--constant syntax--numeric' else 'syntax--string'}"
label = '"'+label+'"' if !labelIsNumeric and label[0] != '$'
valueClass = "type php syntax--php syntax--#{@variable.type} " + switch @variable.type
when 'bool', 'null', 'numeric' then 'syntax--constant'
when 'object' then 'syntax--entity syntax--name syntax--type'
when 'uninitialized' then 'syntax--comment'
else ''
"<span class=\"#{labelClass}\">#{label}</span><span class=\"#{valueClass}\">#{value}</span>"

render: ->
ContextVariableListView = require "./context-variable-list-view"
label = @variable.label
openChildren = false
mapValue = {
bool: { '0': 'false', '1': 'true' },
}
if @openpaths?
for open in @openpaths
if !!@parent
Expand All @@ -34,22 +51,38 @@ class ContextVariableView extends View
when 'numeric'
@variableView.append(@renderScalar({label: label, value:@variable.value}))
when 'bool'
@variableView.append(@renderScalar({label: label, value:@variable.value}))
@variableView.append(@renderScalar({label: label, value: mapValue.bool[@variable.value]}))
when 'uninitialized'
@variableView.append(@renderScalar({label:label, value:"?"}))
when 'error'
@variableView.append(@renderScalar({label:label, value:helpers.escapeHtml(@variable.value)}))
when 'null'
@variableView.append(@renderScalar({label: label, value: "null"}))
when 'array'
summary ="array["+@variable.length+"]"
@variableView.append(new ContextVariableListView({name: label, summary: summary, variables: @variable.value, autoopen: openChildren,parent:@parent,openpaths:@openpaths}))
summary ="array["+(@variable.length || @variable.value.length)+"]"
@variableView.append(new ContextVariableListView({
name: label,
summary: summary,
variables: @variable.value,
autoopen: openChildren,
parent:@parent,
openpaths:@openpaths,
type: @variable.type,
}))
when 'object'
summary ="object"
if @variable.className
summary += " ["+@variable.className+"]"
properties = @variable.value
@variableView.append(new ContextVariableListView({name:label, summary: summary, variables: properties, autoopen: openChildren, parent:@parent,openpaths:@openpaths}))
@variableView.append(new ContextVariableListView({
name:label,
summary: summary,
variables: properties,
autoopen: openChildren,
parent:@parent,
openpaths:@openpaths,
type: @variable.type,
}))
when 'resource'
@variableView.append(@renderScalar({label:label, value: "\""+helpers.escapeHtml(@variable.value)+"\""}))
else
Expand Down
19 changes: 19 additions & 0 deletions lib/context/context-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,23 @@ class ContextView extends View
openChildren = true
break

cbDeepNaturalSort = (a,b) ->
aIsNumeric = /^\d+$/.test(a.name)
bIsNumeric = /^\d+$/.test(b.name)
# cannot exist two equal keys, so skip case of returning 0
if aIsNumeric && bIsNumeric # order numbers
return if (parseInt(a.name, 10) < parseInt(b.name, 10)) then -1 else 1
else if !aIsNumeric && !bIsNumeric # order strings
return if (a.name < b.name) then -1 else 1
else # string first (same behavior that PHP's `ksort`)
return if aIsNumeric then 1 else -1

fnWalkVar = (contextVar) ->
if Array.isArray(contextVar)
for item in contextVar
if Array.isArray(item.value)
fnWalkVar(item.value)
contextVar.sort(cbDeepNaturalSort)

fnWalkVar(@context.context.variables)
@contextListView.append(new ContextVariableListView( {name: @context.name, summary: null, variables: @context.context.variables, autoopen: openChildren, openpaths:@autoopen, parent:null}))
6 changes: 3 additions & 3 deletions lib/engines/dbgp/dbgp-instance.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,10 @@ class DbgpInstance extends DebugContext
type: variable.$.type
}

if variable.$.fullname?
datum.label = variable.$.fullname
else if variable.$.name?
if variable.$.name?
datum.label = variable.$.name
else if variable.$.fullname?
datum.label = variable.$.fullname

switch variable.$.type
when "string"
Expand Down
9 changes: 9 additions & 0 deletions lib/php-debug.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,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
Expand Down Expand Up @@ -298,6 +300,7 @@ module.exports = PhpDebug =
if bp.getPath() == path && bp.getLine() == line
breakpoint = bp
break
return if !breakpoint
@settingsView = new BreakpointSettingsView({breakpoint:breakpoint,context:@GlobalContext})
@settingsView.attach()

Expand Down Expand Up @@ -438,3 +441,9 @@ module.exports = PhpDebug =
marker = @addBreakpointMarker(line, editor)
breakpoint.setMarker(marker)
@GlobalContext.addBreakpoint breakpoint

navigatePreviousConsoleCommand: ->
@consoleView.prevCommand()

navigateNextConsoleCommand: ->
@consoleView.nextCommand()