[Geany] calltips for python?
Jeff Pohlmeyer
yetanothergeek at xxxxx
Fri Feb 22 22:12:12 UTC 2008
Following John's idea, here is a Lua script to implement
some crude "bubbletip" support...
First, create the calltips file:
~/.geany/plugins/geanylua/support/calltips
This syntax for the file is simply pairs of lines,
the first line is the identifier and the second is
the calltip. for example:
-------------<snip>-------------
someword
This is the calltip for some word
anotherword
This is the calltip for another word
thirdword
This is the calltip for the third word
-------------</snip>-------------
Next, make a copy of the script shown below
and put it somewhere in your scripts folder,
for instance:
~/.geany/plugins/geanylua/show-calltips.lua
-------------<snip>-------------
-- @ACCEL@ <Shift><Control>h
if geany.count()==0 then
return
end
local ds=geany.dirsep
local tipfile=geany.appinfo().scriptdir..ds.."support"..ds.."calltips"
local token=#geany.word()>0 and geany.word() or
geany.text():sub(1,geany.caret()):gsub("(.*%W)(%a%w*)(.*)", "%2")
if not (token and #token>0) then
return
end
local tips, err=io.open(tipfile)
if not tips then
geany.message("Can't file tips file!",err)
return
end
local found=nil
for line in tips:lines() do
if found then
found=line
break
end
if line==token then
found=line
end
end
tips:close()
if found then
geany.scintilla("CALLTIPSHOW", geany.caret(), found)
end
-------------</snip>-------------
And then restart Geany.
Now, when you type any one of the identifiers from the calltips
file and then press [Ctrl][Shift]H you should see a calltip for
that identifier.
Notes:
Identifiers must start with an alphabetic character, followed
by zero or more alphanumeric characters. (But the calltip itself
can contain puncuation, etc.)
You still need to press [Escape] to get the calltip to
disappear when you are done with it.
You can change the first line of the script to something
else if you want a different hotkey.
It should also be possible to use different calltips files
for different filetypes by testing the .ext field from the
geany.fileinfo function, but I will leave that as an exercise
for the reader :-)
- Jeff
More information about the Users
mailing list