Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- TIME_STAMP 2014-02-02 18:39:30 v 0.1
- --[[
- In Startup.lua
- "dofile('path\\MySideBar.lua')"
- ]]
- require "gui"
- FileSwitch = EventClass:new(Common)
- FileOpen = EventClass:new(Common)
- FileSave = EventClass:new(Common)
- local IsCommentOrString = function(iPos)
- if ('1 2 7'):find(tostring(editor.StyleAt[iPos])) then
- return true
- else
- return false
- end
- end
- local current_path
- -- Sidebar als eigenes Window?
- local win = tonumber(props['sidebar.win']) == 1
- local tab_index, tabLast_index = 0, 0
- local panel_width = tonumber(props['sidebar.width']) or 230
- local win_height = tonumber(props['position.height']) or 600
- local sidebar_position = props['sidebar.position']=='left' and 'left' or 'right'
- -- Funktionen alphabetisch oder nach Auftreten sortieren
- local func_sort = props['sidebar.func.sort'] == 'alpha' and 'alpha' or 'order'
- local func_call_height = props['sidebar.func.call.height'] or win_height/250
- local func_marked_height = props['sidebar.func.marked.height'] or win_height/250
- -- Tab2 erstellen
- local tab0 = gui.panel(panel_width)
- -- Listview Funktionen >> Positionen Aufrufe (markierte Funktion)
- local list_func3 = gui.list(true)
- list_func3:add_column("Markierter Aufruf - Positionen", 600)
- tab0:add(list_func3, "bottom", func_marked_height)
- list_func3:on_double_click(function()
- local sel_item = list_func3:get_selected_item()
- if sel_item == -1 then return end
- -- Gehe zu Position "sel_item"
- end)
- -- Listview Funktionen >> Aufrufe
- local list_func2 = gui.list(true)
- list_func2:add_column("#", 30)
- list_func2:add_column("Aufrufe", 600)
- list_func2:on_select(function()
- local sel_item = list_func2:get_selected_item()
- if sel_item == -1 then return end
- -- "list_func3" leeren
- -- Für Eintrag in "list_func3" Positionen eintragen
- end)
- tab0:add(list_func2, "bottom", func_call_height)
- -- Listview Funktionen >> Deklarationen
- local list_func = gui.list(true)
- list_func:add_column("Deklarationen", 600)
- list_func:on_double_click(function()
- local sel_item = list_func:get_selected_item()
- if sel_item == -1 then return end
- -- "sel_item" ist Funktion
- -- Gehe zu Position der Deklaration
- end)
- tab0:client(list_func)
- -- Tab2 erstellen
- local tab1 = gui.panel(panel_width)
- -- Textfeld
- local memo_path = gui.memo()
- tab1:add(memo_path, "top", 22)
- -- Listview
- local list_dir = gui.list(false,false)
- tab1:client(list_dir)
- -- Parent Window erstellen (eigenständiges Wnd od. Panel)
- local win_parent
- if win then
- win_parent = gui.window "Side Bar"
- win_parent:size(panel_width + 24, 600)
- win_parent:on_close(function() props['sidebar.show']=0 end)
- else
- win_parent = gui.panel(panel_width)
- --~ gui.set_panel(win_parent, sidebar_position)
- end
- -- Tabbar erstellen und Tabs zuordnen
- local tabs = gui.tabbar(win_parent)
- tabs:add_tab("Funktionen", tab0)
- tabs:add_tab("Dateien", tab1)
- tabs:on_select(function(idx) tab_index = idx end )
- win_parent:client(tab1)
- win_parent:client(tab0)
- -------------------------------------------------------------------------------
- local GetFuncsFromBuffer = function(func_sort)
- if props['FileExt']:upper() ~= 'AU3' then return end
- local n, tfuncsDeclared, tFuncsCall, tFuncsCallOut = 0, {}, {}, {}
- -- Declarations: { [pos] = FuncName }
- for iStart, sFunc in editor:GetText():gmatch('[Ff][Uu][Nn][Cc]%s+()([%w_]+)%s*%b()') do
- if not IsCommentOrString(iStart) then tFuncsDeclared[iStart] = sFunc end
- end
- -- Calls
- for iStart, sFunc in editor:GetText():gmatch('()([%w_]+)%s*%b()') do
- if (not IsCommentOrString(iStart)) and
- (not tFuncsDeclared[iStart]) and
- (not (props['au3.keywords.keywords']):find(sFunc:lower())) then
- tFuncsCall[iStart] = sFunc
- n = n +1
- end
- end
- -- New table for calls with content: [function name] = { count occurences, { table positions }}
- if n > 0 then
- for k, v in pairs(tFuncCall) do
- if not tFuncsCallOut[v] then
- tFuncsCallOut[v] = {1, {k}}
- else
- local count, tPos = tFuncsCallOut[v][1], tFuncsCallOut[v][2]
- count = count +1
- table.insert(tPos, k)
- tFuncsCallOut[v][1] = count
- tFuncsCallOut[v][2] = tPos
- end
- end
- end
- return tfuncsDeclared, tFuncsCallOut
- end
- -- T E S T -- (Skript uber Hotkey aus au3-Skript heraus aufrufen)
- --~ tD, tC = GetFuncsFromBuffer()
- -- print('DEKLARATIONEN')
- -- for k, v in pairs(tD) do print(k,v) end
- --~ tD = SortTable(tD)
- --~ print('DEKLARATIONEN - SORTIERT')
- --~ for k = 1, #tD do print(tD[k][1], tD[k][2]) end
- ----------------------------------------------------------------------------------------------
- --~ if func_sort == 'order' then
- --~ -- Deklarierte Funktionen nach Position sortieren:
- --~ local SortTable = function()
- --~ local tSort = {}
- --~ for k, v in pairs(tFuncsDeclared) do tSort[#tSort+1] = k end
- --~ table.sort(tSort)
- --~ for k = 1, #tSort do
- --~ tFDeclaredSorted[k] = {tSort[k], tFuncsDeclared[tSort[k]]}
- --~ end
- --~ --if #tFDeclaredSorted > 0 then for k = 1, #tFDeclaredSorted do print(tFDeclaredSorted[k][1], tFDeclaredSorted[k][2]) end end
- --~ end
- --~ else
- -- Aufgerufene Funktionen nach Namen sortieren
- --~ local tSort = {}
- --~ for f, t in pairs(tC) do tSort[#tSort+1] = f end
- --~ table.sort(tSort)
- --~ print('\nAUFRUFE - SORTIERT')
- --~ for k = 1, #tSort do
- --~ local s, t = tSort[k], tC[tSort[k]]
- --~ local count, tpos = t[1], t[2]
- --~ table.sort(tpos)
- --~ s = s..'['..count..']\t'
- --~ for _, v in pairs(tpos) do s = s..v..'\t' end
- --~ print(s)
- --~ end
- ----------------------------------------------------------------------------------------------
- -------------------------------------------------------------------------------
- -- Events
- local line_count
- function OnSwitch()
- --~ line_count = editor.LineCount
- if tab0:bounds() then -- visible FileMan
- local path = props['FileDir']
- if path == '' then return end
- current_path = path:gsub('\\$','')..'\\'
- --~ FileMan_ListFILL()
- elseif tab1:bounds() then -- visible Funk/Bmk
- --~ Functions_GetNames()
- --~ Functions_ListFILL()
- --~ Bookmarks_ListFILL()
- --~ elseif tab2:bounds() then -- visible Abbrev
- --~ Abbreviations_ListFILL()
- end
- gui.pass_focus()
- end
- function FileSwitch:OnSwitchFile()
- OnSwitch()
- end
- function FileOpen:OnOpen()
- OnSwitch()
- end
- function FileSave:OnSave()
- OnSwitch()
- end
- tabs:on_select(function(ind)
- tab_index=ind
- OnSwitch()
- end)
- local SideBar_Show, SideBar_Hide
- if win then
- SideBar_Show = function()
- win_parent:show()
- props['sidebar.show']=1
- OnSwitch()
- end
- SideBar_Hide = function()
- win_parent:hide()
- props['sidebar.show']=0
- end
- else
- SideBar_Show = function()
- gui.set_panel(win_parent, sidebar_position)
- props['sidebar.show']=1
- OnSwitch()
- end
- SideBar_Hide = function()
- gui.set_panel()
- props['sidebar.show']=0
- end
- end
- SideBar_Show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement