--
With best regards,
Vladislav V. Vorobyev
Thanks,
Nessus
--------------------------------------------------
From: "SteveD" <steve.j...@gmail.com>
Sent: Monday, August 04, 2008 4:33 AM
To: "scite-interest" <scite-i...@googlegroups.com>
Subject: [scite] SciTE-GUI: GUI Extensions for SciTE Lua
----- Original Message -----From: SteveDTo: scite-interestSent: 2008-08-04, 19:33:19Subject: [scite] SciTE-GUI: GUI Extensions for SciTE Lua
##--------- code begin ------------------------
-- Demonstrates a Useful Side Bar for SciTE
-- you can choose to make it a stand-alone window; just uncomment the two lines
-- involving 'gui.window' and comment out the 'w = gui.panel' line.
local append = table.insert
local current_path = props['FileDir']
local ext = props['FileExt']
-- w = gui.window "Files"
-- w:size(width,400)
local width = 120;
local w = gui.panel(width)
local ls = gui.list(true)
local dirs = gui.list(true)
local bookmarks = gui.list(true)
gui.set_panel(w,"right")
ls:size(width,width)
ls:add_column("Files",width);
dirs:add_column("Directories",width)
-- bookmarks:add_column("Bookmarks",width)
w:add(dirs,"top",200)
-- w:add(bookmarks,"top",150)
w:client(ls)
w:show()
function name_of (f)
return f:match('([^\\]+)%.%w+$')
end
local dirsep = '\\'
local function makepath (f)
return current_path..dirsep..f
end
function fill ()
local mask_base = makepath('*.')
local mask = mask_base..current_ext
local files = gui.files(mask)
local same_ext = true
ls:clear()
-- note that gui.files will not return a table if there were no contents!
if not files then
files = gui.files(mask_base..'*')
same_ext = false
end
if files then
for i,f in ipairs(files) do
local name = f
if same_ext then name = name_of(name) end
ls:add_item(name,f)
end
end
local dirlist = gui.files(makepath('*'),true)
dirs:clear()
dirs:add_item ('[..]','..')
for i,d in ipairs(dirlist) do
dirs:add_item('['..d..']',d)
end
end
ls:on_double_click(function(idx)
if not (idx == -1) then
local file = ls:get_item_data(idx)
scite.Open(makepath(file))
end
end)
dirs:on_double_click(function(idx)
if not (idx == -1) then
local dir = dirs:get_item_data(idx)
gui.chdir(dir)
current_path = current_path..dirsep..dir
fill()
end
end)
function OnCommand (id)
if id == IDM_BOOKMARK_TOGGLE then
local line = editor:GetCurLine()
-- is this line already in the list?
local inserting = true
for i = 0,bookmarks:count() - 1 do
if bookmarks:get_item_text(i) == line then
bookmarks:delete_item(i)
inserting = false
break
end
end
if inserting then
local lno = editor:LineFromPosition(editor.CurrentPos)
bookmarks:add_item(line,{props['FilePath'],lno})
end
end
end
bookmarks:on_double_click(function(idx)
if not (idx == -1) then
local pos = bookmarks:get_item_data(idx)
scite.Open(pos[1])
editor:GotoLine(pos[2])
end
end)
local function on_switch ()
local path = props['FileDir']
local ext = props['FileExt']
if path == '' then return end
if path ~= current_path or ext ~= current_ext then
current_path = path
current_ext = ext
fill()
end
end
local oldOnSwitchFile = OnSwitchFile
local oldOnOpen = OnOpen
function OnSwitchFile(file)
on_switch()
if oldOnSwitchFile then oldOnSwitchFile(file) end
end
function OnOpen(file)
on_switch()
if oldOnOpen then oldOnOpen(file) end
end
## ------------- Code End -----------------------------------
instanton,soft_...@126.com
2008-08-07
----- Original Message -----
----- Original Message -----From: SteveDTo: scite-interestSent: 2008-08-07, 22:05:48Subject: [scite] Re: SciTE-GUI: GUI Extensions for SciTE Lua
Hi Steve, is this not the same version as before? I tried the first
release but it didn't work with SciTE 1.74. Is this version of SciTE to old?
> This fresh version brings two things to the party:
> - it can be built using MinGW - there is a makefile. This mostly
> involved bringing some old C++ code into the 21st century.
> - it has a lot more API checks, so it is less likely to crash SciTE.
>
>
I see no makefile in the download above. Sorry, am I missing something?
Thanks,
Doyle
Hi, Steve,
As someone has already pointed out, the link above is the same old version. I saw no changes to either the source code or the comopiled binary.
> This fresh version brings two things to the party:
> - it can be built using MinGW - there is a makefile. This mostly
> involved bringing some old C++ code into the 21st century.
> - it has a lot more API checks, so it is less likely to crash SciTE.
That sounds teriffic.
> I am interested in what new features people have strong feelings
> about. I'd like to add a tree view, since I've done the hard part of
> wrapping it in C++. Also, people may like to attach panels to any
> side (top,left,right,bottom) of the editor pane; may not be my cup of
> tea, but if there's demand I'll generalize the sizing code.
I'll vote for the tree view panel and a tabbed view in place of the output pane. Meanwhile, I strongly suggest to implement a docking property for the floating toolbar, i.e. if placing the floating toolbar on top of the built-in toolbar or next to it, it should appear as a second toolbar attached to the main window. Moreover, it would become more useful if one can use command IDs rather than the lua function names or built-in function names while configuring the toolbar (command IDs can be asigned to any user defined tools, for instance, not only restricted to the ones defined via lua script).
Regards
instanton
Works perfectly. Thank you very much Steve.
I have another feature request: is it possible to enable styling for the panel(s)? I ask this because many SciTE users use dark scheme settings but the default panel background is white which looks inconsistent with the overall colour scheme.
Regards
instanton
Thanks Steve, that works great here.
> The dodgy part of the subclassing is that it assumes that the
> currently active window is actually the SciTE main frame window. From
> there it works from the expected structure of SciTE's windows; the
> first child is the content pane, the first child of that is the main
> editor Scintilla, etc. This does strike me as being rather
> trusting ;) In fact what I need to do is to enumerate all SciTE top-
> level windows (by class) and find the one that belongs to the current
> iinstance.
I don't have the crash problem, and I don't quite understand the subclassing. But I suggest that the side panels should be attached to the SciTE main frame, not just to the editor pane, i.e. if the panel appears at the right, its height should be roughly the sum of that of the editor pane and of the output pane.
One further feature request: I hope that when double clicking on the panel seperator, the corresponding content could be maxmized (i.e. takes up most of the panel space) while the contents under other seperators should be minimized, leaving only the seperator bar visible. If I didn't describe the requested effect well enough, please see the side panel of TeXMaker.
A last question is: is it possible to change the fonts used for tabbars, horizontal seperators etc?
Bests,
instanton
local findRegExp = {
['cxx']="([^.,<>=\n]-[ :][^.,<>=\n%s]+[(][^.<>=)]-[)])[%s\/}]-%b{}",
['h']="([^.,<>=\n]-[ :][^.,<>=\n%s]+[(][^.<>=)]-[)])[%s\/}]-%b{}",
['js']="(\n[^,<>\n]-function[^(]-%b())[^{]-%b{}",
['vbs']="(\n[SsFf][Uu][BbNn][^\r]-)\r",
['css']="([%w.#-_]+)[%s}]-%b{}",
['pas']="\n([pPff][rRuU][oOnN][cC][eEtT][dDiI][uUoO][rRnN].-%b().-)\n",
['py']="\n%s-([dc][el][fa]%s-.-):"
}
local oldOnSwitchFile = OnSwitchFile
function OnSwitchFile(file)
if oldOnSwitchFile then oldOnSwitchFile(file) end
if ls then
-- first clear the list
c=ls:count()-1;
for i=c,0,-1 do
ls:delete_item(0)
end;
-- Fill the lower list with functions
ListProcedures()
end
end
ls:on_double_click(function(idx)
local pos = ls:get_item_data(idx)
--gui.message(pos[2])
if pos then
scite.Open(pos[1])
editor:GotoLine(pos[2])
editor.Focus=true
end
end)
function ListProcedures()
local textAll = editor:GetText()
local findPattern = findRegExp [props["FileExt"]]
if findPattern == nil then
findPattern = "\n[local ]*[SsFf][Uu][BbNn][^ ]* ([^(]*%b())"
end
local count=0
while true do
startPos, endPos, findString = string.find(textAll, findPattern,
startPos)
if startPos == nil then break end
findString = string.gsub (findString, "\r\n", "")
findString = string.gsub (findString, "%s+", " ")
if not IsComment(startPos) then
local line = editor:LineFromPosition(startPos)
if ls then
ls:add_item(findString,{props['FilePath'],line})
else
print(props['FileNameExt']..':'..(line+1)..':\t'..findString)
end
count = count + 1
end
startPos = endPos + 1
end
if not ls then
if count > 0 then
trace("> found "..count.." functions/procedures")
else
trace("> nothing found!")
end
end
end
regards Frank
"my" configuration for the GUI-Extension:
function OnCommand (id)
--if old_OnCommand then result = old_OnCommand(id) end
if id == IDM_BOOKMARK_TOGGLE then
local line = editor:GetCurLine()
line = string.gsub(line,"%c*","")
line = string.gsub(line,"^%s*","")
-- is this line already in the list?
local inserting = true
for i = 0,bookmarks:count() - 1 do
if bookmarks:get_item_text(i) == line then
bookmarks:delete_item(i)
inserting = false
break
end
end
if inserting then
local lno = editor:LineFromPosition(editor.CurrentPos)
bookmarks:add_item(line,{props['FilePath'],lno})
end
end
end
bookmarks:on_double_click(function(idx)
local pos = bookmarks:get_item_data(idx)
if pos then
scite.Open(pos[1])
editor:GotoLine(pos[2])
editor.Focus=true
end
end)
works with ctrl+f2 without problems, but sciteru has a feature to set
Bookmarks by clicking the margin. this seems not to trigger the message
to the script-handler => the bookmark is set, but not added to the list.
here the corresponding code-snippets:
scitebase.cxx:4889:
case SCN_MARGINCLICK: {
if (extender)
handled = extender->OnMarginClick();
if (!handled) {
//!-start-[SetBookmark]
if (notification->margin == 1) {
int lineClick = int(SendEditor(SCI_LINEFROMPOSITION,
notification->position));
BookmarkToggle(lineClick);
}
scitebase.cxx:2041:
void SciTEBase::BookmarkToggle(int lineno) {
if (lineno == -1)
lineno = GetCurrentLineNumber();
if (BookmarkPresent(lineno)) {
BookmarkDelete(lineno);
} else {
BookmarkAdd(lineno);
}
}
scitebase.cxx:2020:
void SciTEBase::BookmarkAdd(int lineno) {
if (lineno == -1)
lineno = GetCurrentLineNumber();
if (!BookmarkPresent(lineno))
SendEditor(SCI_MARKERADD, lineno, markerBookmark);
}
has anybody an idea to fix this?
regards Frank
FW> i changed funcProcList from SciteRu a little bit to work with Scite-GUI.
FW> maybe its useful for anybody:
FW> ...
This interesting decision.
Many magnificent ideas could will be carried out if gui-ext worked well.
It is excellent library but too many bugs.
I cannot work with her till that time while the basic bugs will not be corrected.
The main thing is that in SciTE it becomes impossible to write in Russian
and that panels are displayed very much not stably.
--
mozers
<http://code.google.com/p/scite-ru/>
FW> works with ctrl+f2 without problems, but sciteru has a feature to set
FW> Bookmarks by clicking the margin. this seems not to trigger the message
FW> to the script-handler => the bookmark is set, but not added to the list.
FW> ...
FW> has anybody an idea to fix this?
You are completely right.
At set of a bookmark with click on the margin do not trigger message IDM_BOOKMARK_TOGGLE.
Your decision of this problem will be considered.
--
mozers
<http://code.google.com/p/scite-ru/>
in the screen you can see, that the string is cut off after specific
length (... appended), can this be changed to show the full string?
can anybody help me to change the pas-expression so that only [p]
instead of procedure and [f] instead of function is shown?
here my current regexp:
['pas']="\n([pPff][rRuU][oOnN][cC][eEtT][dDiI][uUoO][rRnN].-%b().-)\n",
this lists like i the screenshot shown.
regards Frank
frank
Sorry I cannot find a way to solve this;
> can anybody help me to change the pas-expression so that only [p]
> instead of procedure and [f] instead of function is shown?
> here my current regexp:
> ['pas']="\n([pPff][rRuU][oOnN][cC][eEtT][dDiI][uUoO][rRnN].-%b().-)\n",
> this lists like i the screenshot shown.
This may be solved by calling the string.gsub method once again before the line
ls:add_item(findString,{props['FilePath'],line})
instanton
local w = gui.panel(200)
local ls = gui.list()
local bookmarks = gui.list()
gui.set_panel(w,"right")
ls:size(100,100)
-- w:add(bookmarks,"top",100)
-- w:add(ls,"top",300)
-- tabs
t = gui.tabbar(w)
t:add_tab("column list",ls)
t:add_tab("bookmarks",bookmarks)
w:client(t)
-- end tabs
w:show()
the previous version with the 2 w:add-lines and without tabbar-code
works fine.
with tabbar, i see the tabbar, not the client of the first tab (ls), the
client-area is grey. if i switch the the tab to the second, the tabbar
dissapears and i see only client of second tab (bookmarks) and can't
switch back.
maybe i don't exactly understod the tabbar-code in the example but the
documentation says not much :)
btw. the bookmark-code also not handling linecount-change because the
line-numbers are added to the list. isn't there a way to access the
bookmarks-list from scite?
regards Frank
local replaceRegExp = {
['pas']={
['[pP][rR][oO][cC][eE][dD][uU][rR][eE]']="[p]",
['[fF][uU][nN][cC][tT][iI][oO][nN]']="[f]"
}
}
local replacePattern = replaceRegExp [props["FileExt"]]
if replacePattern~=nil then
for s,r in replacePattern do
string.gsub (line, s, r)
end
end
in the lua-documentation i also found foreach and foreahi, but it seems
that these 2 functions are not able to get the key-name.
any ideas?
frank
FW> the previous version with the 2 w:add-lines and without tabbar-code
FW> works fine.
FW> with tabbar, i see the tabbar, not the client of the first tab (ls), the
FW> client-area is grey. if i switch the the tab to the second, the tabbar
FW> dissapears and i see only client of second tab (bookmarks) and can't
FW> switch back.
I see the same.
IMHO I understood where is the problem.
Scripts using windows, panels and toolbars gui.dll cannot be connected dynamically.
It is impossible to use command "dofile my_gui_script.lua". :(
That's why all scripts need to be placed only in SciTEStartup.lua. :(
For panels it is necessary to use only global variables.
It's a pity that we have to see panels constantly. :(
Commands "my_panel:show()" and "my_panel:hide()" did not work: (
Only commands "my_window:show()" and "my_window:hide()" work but I want to use panel instead of window.
That's I'm calling bugs.
I might be wrong but I cannot work in this way.
--
mozers
<http://code.google.com/p/scite-ru/>
> i changed funcProcList from SciteRu a little bit to work with Scite-GUI.
> maybe its useful for anybody:
Please see my edition.
http://mozers.net.ru/scite/FuncProcList_GUI.lua
Works with the original SciTE and SciTE-Ru.
--
mozers
<http://code.google.com/p/scite-ru/>
Try it two useful scripts:
http://mozers.net.ru/scite/FileManager.lua works with original SciTE and SciTE-Ru.
Steve Donovan could use it as an example in a gui-ext.
http://mozers.net.ru/scite/FileManagerRu.lua works only on the latest version SciTE-Ru and traces any switching bookmarks with OnSendEditor function.
--
mozers
<http://code.google.com/p/scite-ru/>
Yes.
my_panel:context_menu {
scite.GetTranslation('Show all files')..'|all_files',
scite.GetTranslation('Only current ext')..'|current_ext',
}
--
mozers
<http://code.google.com/p/scite-ru/>
problems with your code:
- line-positions are not updated (if bookmarks moved by
line-adding/deleting)
- bookmarks are not deleted if file is closed
i have my code attached, because there are some events catched, simply
add gui_conf2.luad with dofile to your startup-script (gui_functions.lua
is loaded from there).
hope its useful for anybody
scite-GUI is very useful for me, but some suggestions
is there a possibility to make the tabs multiline and
change font to a smaller one?
can you implement a method to change existing list-items? currently i
delete and insert them :)
also buttons/checkboxes/radiobuttons/labels would be useful for me, and
i think its not difficult to add them (and splitter needed, only a
onclick-handler)
can memo switched to single-line?
btw.
your panel-in-tabpage-example helps me a lot, but i wonder about this line:
panel:client(w)
w is the panel on the tabpage, why is it aligned to client on the
side-panel? the parent is the tabpage and not the side-panel...
*confused* but without this line, the tab is empty. it takes me a lot of
time to get it working by found your code :( this line was the one i missed
but again, many thanks for this extension :)
regards Frank
gui_conf2.lua:
require("gui")
win_parent = gui.window "Side Bar"
local text_path = gui.memo()
win_parent:client(text_path)
SciteUser.properties:
command.name.42.*=TestWindow
command.42.*=win_parent.show
command.mode.42.*=subsystem:lua,savebefore:no
#- command.shortcut.42.*=Alt+Shift+F
also tried with "win_parent.show()", but the window is not shown if the
menuentry is clicked, no error appers on the output pane.
what's wrong with my code?
regards Frank
> I've tried to define a new window to call this by menucommand.
> what's wrong with my code?
This:
> command.42.*=win_parent.show
Correct:
command.42.*=dostring win_parent:show()
--
mozers
<http://code.google.com/p/scite-ru/>
> btw. @mozers: you have a function to show hide the side-panel, but the
> panel is not hidden till i click on it...maybe a refreshing problem.
> is it working for you?
> a useful thing were.if a tools-menuitem can be checked, so we need
> only one menuitem to show/hide.
win:show() and win:hide() only worked for the window.
They do not work for panel.
Panel can be hidden my_panel:size(0,0).
Then you can restore the previous size.
There is no possibility to check the current state of the window or panel.
File http://mozers.net.ru/scite/ext-gui.lua I frequently updated.
In it not only what have. There also that what we wish.
--
mozers
<http://code.google.com/p/scite-ru/>
i use your code with size() to hide the panel, but it's not hidden in
that moment...i have to click on it, then it's hidden.
function SideBar_hide()
pnl_main:size(0, 0)
end
command.name.44.*=SideBar verstecken
command.44.*=SideBar_hide
command.mode.44.*=subsystem:lua,savebefore:no
regards Frank
Yes.
It works only after updating a editor's window.
I use scite.Perform("reloadproperties:") to force window update.
This is very rough decision. It is possible to find a more neutral command or ask Steve that he corrected it.
--
mozers
<http://code.google.com/p/scite-ru/>
SciTE-GUI is a binary extension for SciTE Lua written in C++ which