Browse Source

Merge remote-tracking branch 'remotes/onefifth/master'

master
Youen Toupin 8 years ago
parent
commit
071bc6d9e1
  1. 4
      README.md
  2. 13
      server/wxLdb/ui/mainWindow.lua
  3. 18
      server/wxLdb/ui/sourcePage.lua
  4. 66
      server/wxLdb/wxLdbController.lua

4
README.md

@ -1,3 +1,7 @@
### NOTE
This is a modified fork of the [original GRLD project](https://github.com/neuoy/GRLD/master/) for personal use and should be considered **unstable**. Anyone looking to use GRLD should check out the [official repo](https://github.com/neuoy/GRLD/master/) unless they are specifically looking for the modifications provided in this version. The original readme contents remain below.
# GRLD # GRLD
Graphical Remote Lua Debugger, a debugger for the lua programming language Graphical Remote Lua Debugger, a debugger for the lua programming language

13
server/wxLdb/ui/mainWindow.lua

@ -66,7 +66,13 @@ function meta.__index:init()
self.idleUpdates = {} self.idleUpdates = {}
self.frame:Connect( wx.wxEVT_IDLE, function( event ) self:onIdleUpdate_( event ) end ) self.frame:Connect( wx.wxEVT_IDLE, function( event ) self:onIdleUpdate_( event ) end )
self.events = { onBreakPointChanged = {}, onFileOpen = {}, onFileClosed = {}, onApplicationExiting = {} } self.events = {
onBreakPointChanged = {},
onFileOpen = {},
onFileClosed = {},
onApplicationExiting = {},
onScrollChanged = {}
}
end end
function meta.__index:show( show ) function meta.__index:show( show )
@ -272,6 +278,7 @@ function meta.__index:getSourcePage( source )
page.pageIdx = self.sourceBook:GetPageCount() page.pageIdx = self.sourceBook:GetPageCount()
self.sourceBook:AddPage( page:getRoot(), name ) self.sourceBook:AddPage( page:getRoot(), name )
page:registerEvent( "onBreakPointChanged", function( ... ) self:runEvents_( "onBreakPointChanged", source, ... ) end ) page:registerEvent( "onBreakPointChanged", function( ... ) self:runEvents_( "onBreakPointChanged", source, ... ) end )
page:registerEvent( "onScrollChanged", function( ... ) self:runEvents_( "onScrollChanged", source, ... ) end )
end end
return page return page
end end
@ -341,6 +348,10 @@ function meta.__index:setActive()
self.active = true self.active = true
end end
function meta.__index:raise()
self.frame:Raise()
end
function meta.__index:onIdleUpdate_( event ) function meta.__index:onIdleUpdate_( event )
local currentPageIdx = self.sourceBook:GetSelection() local currentPageIdx = self.sourceBook:GetSelection()
for _, page in pairs( self.sourcePages ) do for _, page in pairs( self.sourcePages ) do

18
server/wxLdb/ui/sourcePage.lua

@ -5,6 +5,8 @@ local ui =
editor = require( "ui.editor" ), editor = require( "ui.editor" ),
} }
local wx = require( "wx" )
local lfs = require( "lfs" ) local lfs = require( "lfs" )
local assert = assert local assert = assert
@ -23,7 +25,10 @@ function new( parent, source )
local page = {} local page = {}
setmetatable( page, meta ) setmetatable( page, meta )
page.editor = ui.editor.new( parent ) page.editor = ui.editor.new( parent )
page.events = { onBreakPointChanged = {} } page.events = {
onBreakPointChanged = {},
onScrollChanged = {},
}
page:setSource_( source ) page:setSource_( source )
page.editor.breakpointCallback = function( line ) page.editor.breakpointCallback = function( line )
page:runEvents_( "onBreakPointChanged", line ) page:runEvents_( "onBreakPointChanged", line )
@ -53,6 +58,9 @@ function meta.__index:update()
assert( string.sub( self.source, 1, 1 ) == "@" ) assert( string.sub( self.source, 1, 1 ) == "@" )
local fileName = string.sub( self.source, 2 ) local fileName = string.sub( self.source, 2 )
local scrollPosition = self:GetScrollPos()
self:runEvents_( "onScrollChanged", scrollPosition )
local newDate = lfs.attributes( fileName, "modification" ) or 0 local newDate = lfs.attributes( fileName, "modification" ) or 0
if newDate > self.sourceDate then if newDate > self.sourceDate then
print( "reloading source file "..fileName ) print( "reloading source file "..fileName )
@ -78,6 +86,14 @@ function meta.__index:getFocus()
return ed:GetCurrentLine() + 1 return ed:GetCurrentLine() + 1
end end
function meta.__index:SetScrollPos( pos )
self.editor.editor:LineScroll(0, pos)
end
function meta.__index:GetScrollPos()
return self.editor.editor:GetScrollPos( wx.wxVERTICAL )
end
function meta.__index:setCurrentLine( line ) function meta.__index:setCurrentLine( line )
local editor = self.editor.editor local editor = self.editor.editor
if self.currentLine == line then return end if self.currentLine == line then return end

66
server/wxLdb/wxLdbController.lua

@ -11,6 +11,8 @@ local ui =
} }
local lfs = require( "lfs" ) local lfs = require( "lfs" )
local wx = require( "wx" )
require( "coxpcall" ) require( "coxpcall" )
local coxpcall = coxpcall local coxpcall = coxpcall
local copcall = copcall local copcall = copcall
@ -37,6 +39,15 @@ local meta = { __index = {} }
local complexValueManagerMeta = { __index = {} } local complexValueManagerMeta = { __index = {} }
local function createClientConfig(name)
return {
name = name,
mappings = {},
breakpoints = {},
scrollPositions = {},
}
end
function new( engine, window ) function new( engine, window )
local res = local res =
{ {
@ -133,6 +144,7 @@ function meta.__index:run_()
self.window:registerEvent( "onBreakPointChanged", wrapCb( function( ... ) self:onBreakPointChanged_( ... ) end ) ) self.window:registerEvent( "onBreakPointChanged", wrapCb( function( ... ) self:onBreakPointChanged_( ... ) end ) )
self.window:registerEvent( "onFileOpen", wrapCb( function( ... ) self:onFileOpen_( ... ) end ) ) self.window:registerEvent( "onFileOpen", wrapCb( function( ... ) self:onFileOpen_( ... ) end ) )
self.window:registerEvent( "onFileClosed", wrapCb( function( ... ) self:onFileClosed_( ... ) end ) ) self.window:registerEvent( "onFileClosed", wrapCb( function( ... ) self:onFileClosed_( ... ) end ) )
self.window:registerEvent( "onScrollChanged", wrapCb(function( ... ) self:onScrollChanged_( ...) end ) )
self.window:registerEvent( "onApplicationExiting", wrapCb( function( ... ) self:onApplicationExiting_( ... ) end ) ) self.window:registerEvent( "onApplicationExiting", wrapCb( function( ... ) self:onApplicationExiting_( ... ) end ) )
@ -143,7 +155,7 @@ function meta.__index:run_()
self.window.watch.evaluateCallback = wrapCb( function( expr ) return self:evaluateExpression_( expr ) end ) self.window.watch.evaluateCallback = wrapCb( function( expr ) return self:evaluateExpression_( expr ) end )
self.configs.global = { name = "global", breakpoints = {} } self.configs.global = createClientConfig('global')
self:loadConfig_( "global" ) self:loadConfig_( "global" )
self:sleep_() self:sleep_()
@ -200,6 +212,22 @@ function meta.__index:run_()
end end
end end
function meta.__index:getActiveClientConfig_()
local activeClientId = self.activeClient
if activeClientId == nil then
return self.configs.global
end
local clientData = self.clients[activeClientId]
if clientData == nil then
return self.configs.global
end
return clientData.config
end
function meta.__index:evaluateExpression_( expr ) function meta.__index:evaluateExpression_( expr )
local clientId = self.activeClient local clientId = self.activeClient
local client = self.engine.getClient( clientId ) local client = self.engine.getClient( clientId )
@ -224,6 +252,7 @@ function meta.__index:refreshSourcePageFocus_( remoteSource, line )
local clientData = assert( self.clients[clientId] ) local clientData = assert( self.clients[clientId] )
local sourceType = string.sub( remoteSource, 1, 1 ) local sourceType = string.sub( remoteSource, 1, 1 )
if sourceType == "@" then if sourceType == "@" then
self.window:raise()
print( "Setting focus to "..remoteSource.."("..line..")" ) print( "Setting focus to "..remoteSource.."("..line..")" )
remoteSource = grldc.utilities.normalizePath( string.sub( remoteSource, 2 ) ) remoteSource = grldc.utilities.normalizePath( string.sub( remoteSource, 2 ) )
local source, remotePath, remoteFile = self:getLocalSource_( clientId, remoteSource ) local source, remotePath, remoteFile = self:getLocalSource_( clientId, remoteSource )
@ -396,6 +425,17 @@ function meta.__index:onApplicationExiting_()
self.window.threads:setData( nil ) self.window.threads:setData( nil )
end end
function meta.__index:refreshScrollPosition_()
local config = self:getActiveClientConfig_()
for source, sp in pairs( config.scrollPositions ) do
local page = self.window:getSourcePage( source )
if page ~= nil then
page:SetScrollPos(sp)
end
end
end
function meta.__index:refreshBreakPoints_() function meta.__index:refreshBreakPoints_()
local clientId = self.activeClient local clientId = self.activeClient
local config = nil local config = nil
@ -459,6 +499,7 @@ function meta.__index:onFileOpen_( path )
self:setSourceFocus_( source, 1 ) self:setSourceFocus_( source, 1 )
self:refreshPointers_() self:refreshPointers_()
self:refreshBreakPoints_() self:refreshBreakPoints_()
self:refreshScrollPosition_()
end end
function meta.__index:onFileClosed_( source ) function meta.__index:onFileClosed_( source )
@ -467,6 +508,12 @@ function meta.__index:onFileClosed_( source )
end end
end end
function meta.__index:onScrollChanged_( source, position )
local clientConfig = self:getActiveClientConfig_()
clientConfig.scrollPositions[source] = position
clientConfig.dirty = true
end
function meta.__index:onThreadClicked_( clientId, threadId ) function meta.__index:onThreadClicked_( clientId, threadId )
print( "Thread clicked: client="..clientId..", thread="..threadId ) print( "Thread clicked: client="..clientId..", thread="..threadId )
local clientData = self.clients[clientId] local clientData = self.clients[clientId]
@ -683,7 +730,7 @@ function meta.__index:onNewClient_( clientId )
local client = self.engine.getClient( clientId ) local client = self.engine.getClient( clientId )
local name = client:name() local name = client:name()
if self.configs[name] == nil then if self.configs[name] == nil then
self.configs[name] = { name = name, mappings = {}, breakpoints = {} } self.configs[name] = createClientConfig(name)
self:loadConfig_( name ) self:loadConfig_( name )
end end
self.clients[clientId] = { dirty = true, activeThread = "current", activeLevel = 1, config = self.configs[name] } self.clients[clientId] = { dirty = true, activeThread = "current", activeLevel = 1, config = self.configs[name] }
@ -741,12 +788,19 @@ function meta.__index:saveConfig_( name )
openFiles[page.pageIdx+1] = source openFiles[page.pageIdx+1] = source
end end
local breakpoints = clientConfig.breakpoints local breakpoints = clientConfig.breakpoints
local scrollPositions = clientConfig.scrollPositions
local path = "clients/"..name.."/config.lua" local path = "clients/"..name.."/config.lua"
lfs.mkdir( "clients" ) lfs.mkdir( "clients" )
lfs.mkdir( "clients/"..name ) lfs.mkdir( "clients/"..name )
local file = assert( io.open( path, "w" ) ) local file = assert( io.open( path, "w" ) )
file:write( grldc.net.serialize( { mappings = clientConfig.mappings, openFiles = openFiles, breakpoints = breakpoints, breakOnConnection = clientConfig.breakOnConnection } ) ) file:write( grldc.net.serialize( {
mappings = clientConfig.mappings,
openFiles = openFiles,
breakpoints = breakpoints,
scrollPositions = scrollPositions,
breakOnConnection = clientConfig.breakOnConnection
} ) )
file:close() file:close()
print( "Saved config \""..name.."\"" ) print( "Saved config \""..name.."\"" )
clientConfig.lastConfigSave = os.time() clientConfig.lastConfigSave = os.time()
@ -774,6 +828,12 @@ function meta.__index:loadConfig_( name )
end end
end end
end end
if config.scrollPositions ~= nil then
for source, sp in pairs( config.scrollPositions ) do
clientConfig.scrollPositions[source] = sp
end
end
end end
if clientConfig.breakOnConnection == nil then if clientConfig.breakOnConnection == nil then
clientConfig.breakOnConnection = true clientConfig.breakOnConnection = true

Loading…
Cancel
Save