[ZeroBrane Studio] Re: Unsolicited feature wishlist

  • From: Paul K <paul@xxxxxxxxxxxxx>
  • To: zerobrane@xxxxxxxxxxxxx
  • Date: Sun, 27 Oct 2013 18:45:41 -0700

Hi Jayanth,

Good list; thank you for the feedback! My brief comments:

> 1. Library documentation help browser (just a configurable parameter in 
> user.lua (system/user prefs.)) that allow one to point to URL which is opened 
> in a browser, when developer clicks on "Help > Library-Docs".

Good idea; I put together a plugin (at the bottom of this message)
that adds 'Show Reference' item to the local menu. Wherever you click
on a function or variable and select 'Show Reference', it will open
Lua reference for that item. It will also recognize things like
io.write and Lua API C calls. It also uses Lua 5.2 reference if you
set Lua 5.2 as the current interpreter (and Lua 5.1 reference in all
other cases).

This should be more useful/powerful than just opening one URL from the menu.

> 2. Code browsing / navigation aids, like -
> a. Right-click on function under cursor to open search menu, with sub-menu to

This is most likely coming, although may be not in exactly the same
form, but should provide the same functionality. I envision function
dropdown being replaced with a text box that provides this navigation
with some additional functions.

> b. navigation-bookmark-stack - suppose you are browsing code, and are on a 
> particular line/function/variable... you put a named/unnamed bookmark which 
> is placed on a stack, and you jump to another piece of code, place another 
> bookmark there, and from there further on... so on and so forth. So, one 
> could backtrack their browsing by unfolding stack.

This is most likely coming as well, although I'm not sure about when
or whether it will include the unfolding stack. BTW, there is somewhat
similar functionality (with backtracking) when you use "jump to
definition" with Cmd/Click-Alt-Click (and Alt-Left to go back).

> 3. File organized as projects, s.t. code-analysis understands project scope, 
> with some recommended file organization, and automatic creation of src/, 
> doc/, test/ folders.

Are you suggesting that ZBS should do project creation? Most likely
not, but it shouldn't stop anyone from writing plugins or tools that
do that

> 4. Automatic insertion of LDoc template in files, and before functions (here 
> the dreams just sky-rocket).

This is interesting; I've been thinking about code snippets that could
be used for this as well. Again, not sure when exactly this is coming.

Overall, my current plan is to provide an easy way to install ZBS
addons (including a way to publish/download these), to allow users
conveniently share their plugins/packages/modules. I already have
about two dozens of plugins that do various interesting things and
these can be used as an example for anyone who wants to write their
own.

Paul.

Save this file as packages/showluareference.lua

local G = ...
local id = G.ID("showluareference.showluareferencemenu")
local menuid
local ident = "([a-zA-Z_][a-zA-Z_0-9%.%:]*)"
return {
  name = "Show lua reference plugin",
  description = "Adds showing lua reference option to the editor menu.",
  author = "Paul Kulchenko",
  version = 0.1,

  onMenuEditor = function(self, menu, editor, event)
    local point = editor:ScreenToClient(event:GetPosition())
    local pos = editor:PositionFromPointClose(point.x, point.y)
    if not pos then return end

    local line = editor:LineFromPosition(pos)
    local linetx = editor:GetLine(line)
    local localpos = pos-editor:PositionFromLine(line)
    local selected = editor:GetSelectionStart() ~= editor:GetSelectionEnd()
      and pos >= editor:GetSelectionStart() and pos <= editor:GetSelectionEnd()

    local start = linetx:sub(1,localpos):find(ident.."$")
    local right =
linetx:sub(localpos+1,#linetx):match("^([a-zA-Z_0-9]*)%s*['\"{%(]?")
    local ref = selected
      and editor:GetTextRange(editor:GetSelectionStart(),
editor:GetSelectionEnd())
      or (start and linetx:sub(start,localpos)..right or nil)

    if ref then
      menu:AppendSeparator()
      menu:Append(id, ("Show Reference: %s"):format(ref))
    end

    editor:Connect(id, wx.wxEVT_COMMAND_MENU_SELECTED,
      function()
        local url = ('http://www.lua.org/manual/%s/manual.html#%s'):
          format(ide:GetInterpreter().luaversion or '5.1',
            ref:find('^luaL?_') and ref or 'pdf-'..ref)
        wx.wxLaunchDefaultBrowser(url, 0)
      end)
  end
}

On Sat, Oct 26, 2013 at 11:22 AM, Jayanth Acharya <jayachar88@xxxxxxxxx> wrote:
> Hi Paul,
>
> Here are some unsolicited inputs towards ZBS feature wishlist, for your kind
> consideration.
>
> 1. Library documentation help browser (just a configurable parameter in
> user.lua (system/user prefs.)) that allow one to point to URL which is
> opened in a browser, when developer clicks on "Help > Library-Docs".
>
> 2. Code browsing / navigation aids, like -
>
>  a. Right-click on function under cursor to open search menu, with sub-menu
> to
>     i. search in a module
>    ii. search in a package (directory with sub-directories etc.)
>   iii. search in open-files
>    iv. search in all files
>     v. search in project
>    where 'search' could be same as the standard search with function-name as
> the identifier in exact-case/exact-word
>
>  b. navigation-bookmark-stack - suppose you are browsing code, and are on a
> particular line/function/variable... you put a named/unnamed bookmark which
> is placed on a stack, and you jump to another piece of code, place another
> bookmark there, and from there further on... so on and so forth. So, one
> could backtrack their browsing by unfolding stack.
>     these bookmarks could be temporary i.e. for session only; or permanent,
> i.e. which could survive ZBS restarts, and part of project.
>
> 3. File organized as projects, s.t. code-analysis understands project scope,
> with some recommended file organization, and automatic creation of src/,
> doc/, test/ folders.
>
> 4. Automatic insertion of LDoc template in files, and before functions (here
> the dreams just sky-rocket).
>    a. Whenever a new file is created a document header is added (including
> any custom text)
>    b. Whenever a function's "end" keyword is found, analyze function's
> parameters and return values (just the names) and insert LDoc annotations
> before the function, if such a section isn't already added.
>    c. Have a hot-key combination to jump to the function description (from
> the last "end" closing function declaration), and a hot-key combination to
> jump back, just beyond the "end" closing function declaration.
>

Other related posts: