Jump to content

MouseHoverCallTips [11/24/2023]


Recommended Posts

They look the same to me. Could you show me what you mean?

Managed by myself by accident, when I put an extra ";" in the comment line it triggers a line break in the calltip which is what I was looking for. However, playing around with the system now I have another problem, if I have a

#include <gui.au3>

in my main.au3 and the gui.au3 contains a function called "Func gui_($method, $params = '') ; comment here" then that calltip shows up when I am editing the gui.au3 but unfortunately not when I'm editing the main.au3 (where the gui_ function is normally used). Any idea what could be going wrong?

Link to comment
Share on other sites

Managed by myself by accident, when I put an extra ";" in the comment line it triggers a line break in the calltip which is what I was looking for. However, playing around with the system now I have another problem, if I have a

#include <gui.au3>

in my main.au3 and the gui.au3 contains a function called "Func gui_($method, $params = '') ; comment here" then that calltip shows up when I am editing the gui.au3 but unfortunately not when I'm editing the main.au3 (where the gui_ function is normally used). Any idea what could be going wrong?

Ok, found out what the problem is and here's a subtle'ish bug report: it seems the MouseHoverCallTips:OnOpen function fails to fire consecutively when loading files via SciTE.session files - hence the MouseHoverCallTips:get_includes_list doesn't get to do its job..etc. Would submit patch but I've never done any Lua work so will have to pass on this one.

Update, this function patch (to CalltipsOnMouseHover.lua) partly fixes the problem with files loaded via session but the initial file displayed still does not show calltips before it has been "switched to".

function MouseHoverCallTips:OnSwitchFile(file_path)
if self:is_au3_file() then
     self:initialize_mouse_dwell()
     self:get_includes_list(file_path, 1)
end
return false
end
Edited by Sunaj
Link to comment
Share on other sites

Also, a question, is it possible to do line breaks in Function comment/description? So as to emulate the format used by for example _ArrayDisplay and others

OK, here is what _ArrayDisplay's calltip looks like when I use the native intellisense:

_ArrayDisplay (Const ByRef $avArray [, $sTitle = "Array: ListView Display" [, $iItemLimit = -1 [, $iTranspose = 0 [, $sSeparator = "" [, $sReplace = "|" [, $sHeader = ""]]]]]])
Displays given 1D or 2D array array in a listview. (Requires: #include <Array.au3>)

And here is what it looks like when I use Mousehover --> Calltip:

_ArrayDisplay (Const ByRef $avArray [, $sTitle = "Array: ListView Display" [, $iItemLimit = -1 [, $iTranspose = 0 [, $sSeparator = "" [, $sReplace = "|" [, $sHeader = ""]]]]]])
Displays given 1D or 2D array array in a listview.
(Requires: #include <Array.au3>)

I did decide to put the (requires:... section on its own line.

Managed by myself by accident, when I put an extra ";" in the comment line it triggers a line break in the calltip which is what I was looking for.

Are you referring to when you have a func definition with a comment on the same line?
Func my_awesome_function() ; this is my awesome function.
If so then you shouldn't have to put two semi colons. So I will look into that.

Edit: OK, if you want an extra line feed then yes just put two semi colons.

Ok, found out what the problem is and here's a subtle'ish bug report: it seems the MouseHoverCallTips:OnOpen function fails to fire consecutively when loading files via SciTE.session files - hence the MouseHoverCallTips:get_includes_list doesn't get to do its job..etc. Would submit patch but I've never done any Lua work so will have to pass on this one.

Update, this function patch (to CalltipsOnMouseHover.lua) partly fixes the problem with files loaded via session but the initial file displayed still does not show calltips before it has been "switched to".

function MouseHoverCallTips:OnSwitchFile(file_path)
if self:is_au3_file() then
     self:initialize_mouse_dwell()
     self:get_includes_list(file_path, 1)
end
return false
end
Thank you. I will look into this some more.

Edit: Ok, I don't experience the issue that you describe. Maybe I have misunderstood?

Edited by jaberwocky6669
Link to comment
Share on other sites

Thank you. I will look into this some more.

Edit: Ok, I don't experience the issue that you describe. Maybe I have misunderstood?

First of all the line break thing is all fine: as you say I can put semi colons in the comment to allow for as many/few line breaks as I need.

Secondarily: The session loading issue remains for me: I have two files, alpha.au3 and beta.au3 and I call a Func in alpha.au3 with the name firstfunc($ding) and that Func is located in beta.au3 (which is included in alpha.au3 of course). Now I take those two files and save them in a session when alpha.au3 is in focus (SciTE.session), next time I open the session file I do not get the calltip displayed on firstfunc($ding).

I tried incl. the firstfunc($ding) function directly in alpha.au3 and then the calltip works (?!).

With the patch/hack I submitted above I can let firstfunc($ding) function remain in beta.au3 and switch back and forth between the two tabs and then all is normal with the calltip inside the alpha.au3 file. This is a minor issue but it is there >_<

Link to comment
Share on other sites

Really I set it up just now exactly as you described with the names all the same and I saved them into a session. I then opened the session and I get a calltip every time.

I'm hoping someone else will weigh in here and try it out too.

Edited by jaberwocky6669
Link to comment
Share on other sites

Really I set it up just now exactly as you described with the names all the same and I saved them into a session. I then opened the session and I get a calltip every time.

I'm hoping someone else will weigh in here and try it out too.

Thanks for taking the time, I have included my code below with comments to describe issue, also I have uninstalled/reinstalled SciTE and AutoIt to make sure that the setup isn't wonky; unfortunately still seeing issue, I don't need to use session file to see issue now (might have been same all along, sorry about that). FInal detail: I'm on Win7 32bit edition, all updated..etc.

file: alpha.au3

#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.8.1, SciTE Version : 6/10/2012
Script Function:
Test CallTipsOnMouseHover.lua versus include files
#ce ----------------------------------------------------------------------------
#include"beta.au3"

alpha_firstfunc('testing') ; this comes up fine
beta_secondfunc('testing again') ; i see no call tip here?!

Func alpha_firstfunc($dang) ; here's alpha_firstfunc calltip, note the intelligent parameter
ConsoleWrite('@@ (13) :(' & @MIN & ':' & @SEC & ') firstfunc(): ' & $dang & @CR) ;### Function Trace
EndFunc

file: beta.au3

Func beta_secondfunc($ding) ; here's beta_secondfunc calltip, note the intelligent parameter
ConsoleWrite('@@ (13) :(' & @MIN & ':' & @SEC & ') firstfunc(): ' & $ding & @CR) ;### Function Trace
EndFunc

edit: couple of comment typos and file description clarified

Edited by Sunaj
Link to comment
Share on other sites

Ok, finally found correct solution to my problem: this function, inside CalltipsOnMouseHover.lua:

function MouseHoverCallTips:get_include_from_line(line)
if not line then return '' end
if string.find(line, "^%s*#include%s+") then
 
  -- Anything between <, >, ', or "
  local include = string.match(line, "[\<\"\']%s*.+\.au3%s*[\'\"\>]")
  if include == nil then return '' end
  return string.sub(include, 2, -2)
end
return ''
end

does NOT do what it is intended to do unless I change this line:

if string.find(line, "^%s*#include%s+") then

to read:

if string.find(line, "#include") then

instead.. then all is fine, I don't understand why I'm am the only one seeing this problem, tried it out on two computers so far and can replicate just fine. Anywho, I'm a happy camper now so.. over and out.

Link to comment
Share on other sites

Ahh, I see why now. The '+' in "^%s*#include%s+" searches for one or more spaces. I changed it to '*' to search for zero or more spaces.

Thanks for the bug report! I'll include your name in the list of contributors.

Edited by jaberwocky6669
Link to comment
Share on other sites

  • 2 weeks later...

Another nugget spotted: if you are using a function in an included file (say include.au3) that is written in out in the mother script (main.au3) then the calltip fails to show up when browsing the include file, after a bit of debugging I noticed that the main.au3 script was not being put into the "self.IncludesTable" and hence no joy. Here's a modified version of get_includes_list that makes it work fine on my end:

function MouseHoverCallTips:get_includes_list(file_path, accumulator)
    -- If file_path only contains a filename then prepend a file path
    if not string.find(file_path, "^%a:\\") then
        file_path = props["FileDir"] .. '\\' .. file_path
    end

    local file = io.open(file_path)

    if file then
        local include_name = ''
        for line in file:lines() do
            if string.len(line) > 0 then
                include_name = self:get_include_from_line(line)
                if string.len(include_name) > 0 then
                    table.insert(self.IncludesTable, include_name)
                end
            end
        end
    end
    -- new bit start
    local index = file_path:match'^.*()\\'
    local file_clean = string.sub(file_path, index+1)
    if not self:table_contains(self.IncludesTable, file_clean) then
        table.insert(self.IncludesTable, file_clean)
    end
    -- new bit end
    if accumulator == #self.IncludesTable then
        file:close()
        self.IncludesTable = self:filter_duplicate_entries(self.IncludesTable)
    end

    return true
end

On a side note: your code has helped me getting started with Lua, appreciated.

Edit: formatting redone on code paste

Edited by Sunaj
Link to comment
Share on other sites

I went ahead and posted your change without testing it because it looks good to me and I trust you.

Thanks, although practically I will have to add another bit to make the whole thing work; when I posted above code last night I forgot this little helper function which is needed to do the table_contains check:

function MouseHoverCallTips:table_contains(table, element)
for _, value in pairs(table) do
  if value == element then
   return true
  end
end
return false
end
Link to comment
Share on other sites

Fill out this template:

-- Description:
--
-- Parameters:
--       table -
--       element -
-- Author(s):
--      sunaj

Sorry, been kinda busy lately with school etc.

Edited by jaberwocky6669
Link to comment
Share on other sites

Fill out this template:

-- Description:
--
-- Parameters:
--       table -
--       element -
-- Author(s):
--      sunaj

Sorry, been kinda busy lately with school etc.

Sure, here goes (filled it in with original author's name/url for transparency):

-- Description:
--   "table_contains" returns boolean true if the value passed to it is found in the table passed to it
-- Parameters:
--   table - table to check
--   element - value to check for in table
-- Author(s):
--   Wookai (use in CalltipsOnMouseHover.lua by Sunaj)
--   url: http://stackoverflow.com/questions/2282444/how-to-check-if-a-table-contains-an-element-in-lua
Link to comment
Share on other sites

  • 4 months later...

*whew* Allright, NOW! I spent literally all day chasing one pipe dream after another and now I feel confident that this works.  See >OP for more details on the latest feature!

Link to comment
Share on other sites

  • jaberwacky changed the title to MouseHoverCallTips [11/24/2023]

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...