Menu

#1060 Statusbar messaging

Completed
open
nobody
None
5
2014-08-12
2014-07-12
klo
No

I assume there is no way to print message to statusbar (from Lua).
According documentation, SciTE statusbar accepts several predefined properties.

I think some messages are better delivered to statusbar, instead printing to output pane.
I also think this is obvious, but as example consider user defined Lua function which may inform if changes are made in current buffer, or print number of changes or just any informational message, which may not be necessarily too important to print in output pane every time, thus distracting the user.

I'll try to suggest raw implementation but as I'm not a C++ programmer, don't know if this is best way.
Thinking about it, I thought that maybe easiest way to provide this feature is by providing global property which can be displayed on statusbar as one more property. Let’s call it LuaStatusMessage. This property should auto-reset after 10 seconds or so, to blank.

So I would be allowed to add to my statusbar $(LuaStatusMessage) property, just like I'm allowed to set $(LineNumber) and similar. From my Lua code I can set my message by doing: editor.LuaStatusMessage = my_message which will display this global property on statusbar.

Discussion

  • klo

    klo - 2014-07-12

    Just found this: https://sourceforge.net/p/scintilla/feature-requests/838/#32f7
    Wish I saw it before typing so much...

    Here is how I made it:

    :::lua
    local LuaStatusMessage = ''
    function OnUpdateUI()
    
        props['LuaStatusMessage'] = LuaStatusMessage
        if props['CurrentPos'] ~= editor.CurrentPos then
            LuaStatusMessage = ''
        end
        props['CurrentPos'] = editor.CurrentPos
    
    end
    

    so message is reset on cursor position change, after displaying the message.

     
  • klo

    klo - 2014-07-12

    Above function would not reset message if user defined Lua function changes cursor while executed.

    This would work in such case:

    :::lua
    local LuaStatusMessage = ''
    local timer = 0
    function OnUpdateUI()
    
        props['LuaStatusMessage'] = LuaStatusMessage
        if LuaStatusMessage ~= '' and timer == 0 then
            timer = os.time()
        end
        if timer > 0 and (os.time() - timer) > 10 then
            LuaStatusMessage = ''
            timer = 0
        end
    
    end
    

    but I wonder if there is a better way?

     

    Last edit: klo 2014-07-12

Log in to post a comment.

MongoDB Logo MongoDB