Page 1 of 1

Further DebugConsole improvements

Posted: Wed Feb 22, 2012 9:53 pm
by yufra
I want a place to organize my thoughts and get feedback on the in-game DebugConsole.
  1. Check for `userdata` when doing tab auto-completion
  2. Auto-complete paths (identify a path by a string starting with a "/" character?)
  3. Add more keyboard shortcuts (candidates)
  4. Fix history position (should be at the end) after re-opening the DebugConsole

Re: Further DebugConsole improvements

Posted: Wed Feb 22, 2012 9:57 pm
by tiger_eye
4. upon bringing up the lua console, arrow-up should scroll commands beginning with the previous command, and arrow-down should scroll through commands beginning with the very first one.

Re: Further DebugConsole improvements

Posted: Wed Feb 22, 2012 10:08 pm
by Canderel
Flashing cursor...

Display the parameters for a function... almost like "help"... (Ctrl-space in a lot of IDE's these days)

Re: Further DebugConsole improvements

Posted: Wed Feb 22, 2012 10:59 pm
by edge2054
delete!! I use delete more then backspace generally.

Re: Further DebugConsole improvements

Posted: Wed Feb 22, 2012 11:21 pm
by yufra
Canderel wrote: Display the parameters for a function... almost like "help"... (Ctrl-space in a lot of IDE's these days)
Implementing this could be very tricky indeed. My first thought is to leverage the Luadoc stuff, but I have no idea how to go about doing that. It would be nice, though...
edge2054 wrote: delete!! I use delete more then backspace generally.
Yup that will definitely be done.

Re: Further DebugConsole improvements

Posted: Thu Feb 23, 2012 2:10 am
by yufra
Alright, here is what I have managed thus far:
  1. Ctrl+A (Home), Ctrl+E (End), and Delete commands added
  2. Blinking cursor position
  3. Path auto-completion
  4. Check for table during auto-completion (fixes tab on userdata)
A help command would be nice, but not going to get done soon. The scroll commands one is surprisingly odd... not sure what is happening there yet. Anyway I have pushed my changes to a Gitorious branch so if you guys can check it out and give feedback I would appreciate it. Cheers!

Re: Further DebugConsole improvements

Posted: Thu Feb 23, 2012 7:37 pm
by yufra
Lies, all lies. Make that one lie. Adding a help feature is going to be very easy and I have it nearly completed. I would appreciate suggestions on the interface for it, though. Here are some examples with the cursor denoted by the "|" character:
  1. game.zone:addEntity|
  2. game.zone:add|Entity
Now say you hit Ctrl+Space for help. In case (1) the comments for the Zone:addEntity function will be returned. In case (2) should we return help? Or say "game.zone.add is not a function"?

Also, what should the output look like? I am planning on doing something like this:

Code: Select all

<<< Help found in /mod/class/Actor.lua line 527 >>>
--- Setup minimap color for this entity
-- You may overload this method to customize your minimap
function _M:setupMinimapInfo(mo, map)

Re: Further DebugConsole improvements

Posted: Thu Feb 23, 2012 7:47 pm
by Canderel
1) is obviously great. Does it give me te parameter names?
2) i think should auto-complete. ie the same as tab, then once chosen do no 1

Re: Further DebugConsole improvements

Posted: Thu Feb 23, 2012 9:28 pm
by yufra
Canderel wrote:1) is obviously great. Does it give me te parameter names?
I am not entirely certain what you mean by "parameter names". The last line of the help output will show the actual function definition, so you can see what the function expects there. Some of the function comments also have parameter explanations, for example this would be the help for engine.Actor.move:

Code: Select all

<<< Help found in /engine/Map.lua line 152 >>>
--- Moves an actor on the map
-- *WARNING*: changing x and y properties manually is *WRONG* and will blow up in your face.  Use this method. Always.
-- @param map the map to move onto
-- @param x coord of the destination
-- @param y coord of the destination
-- @param force if true do not check for the presence of an other entity. *Use wisely*
-- @return true if a move was *ATTEMPTED*. This means the actor will probably want to use energy
function _M:move(x, y, force)
This shows the function definition on the last line, and has some comments about the individual parameters above. The comment on parameters and return values are often missing in the code, but they should be documented and you can bring up ones that need it as you poke around.
2) i think should auto-complete. ie the same as tab, then once chosen do no 1
Fair enough.

Re: Further DebugConsole improvements

Posted: Thu Feb 23, 2012 9:47 pm
by Canderel
Yeah, just after I posted I saw you added docs up to the full declaration of the function. But was on the phone, so edit is too much hassle. :-/

Great work I must say! That thing is already so awesome it's not even funny. :D

Get DarkGod to add it before b38!

Only suggestion now is to display the keyboard shortcuts the first time you open the console (every game the 1st time).

Re: Further DebugConsole improvements

Posted: Fri Feb 24, 2012 2:31 am
by yufra
Canderel wrote: Only suggestion now is to display the keyboard shortcuts the first time you open the console (every game the 1st time).
Great suggestion, I added a header to the latest commit. I am not going to touch this again to give you guys some time to test it and give feedback. I let DG know this is in the works so I think it will make it into b38 just fine.

Re: Further DebugConsole improvements

Posted: Fri Feb 24, 2012 4:30 pm
by yufra
Alright, here is a detailed changelog of what I sent DG this morning:
Added a welcome message and keyboard shortcuts.
Added path string auto-completion.
Added a blinking cursor.
Added Ctrl+Space to show a function's help and Ctrl+Shift+Space to show a function's entire definition.
Added Ctrl+K/Ctrl+End to delete to the end of the line.
Added ordered multi-column display to both auto-completion and table display.
Added Page Up/Down scrolling of the history.
Added special cases for table and function auto-completion where a "." and "(" are added, respectively.
Fixed a few bugs.
DG suggested adding a real cursor rather than inserting a fake character, and pointed me towards `engine.ui.Textbox` for inspiration. I also want to look at adding a scrollbar at some point (DG suggested `engine.ui.Scrollbar`), but for now I think I will be taking a break from these changes. The changes have had limited testing and I have fixed all the bugs that I and tiger_eye found. If you find anything please let me know and I will fix them and probably release an addon fix as well. Thanks again to everyone that helped!