Skip to content

Commit 81229cc

Browse files
author
Matthias Kastner
committed
Merge branch 'mk/search'
* mk/search: Added search field
2 parents 5208f34 + 9f70506 commit 81229cc

File tree

4 files changed

+109
-24
lines changed

4 files changed

+109
-24
lines changed

procedures/CodeBrowser.ipf

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,12 @@ End
565565
static Function sortListByLineNumber(decls, lines)
566566
Wave/T decls
567567
Wave/D lines
568+
569+
// check if sort is necessary
570+
if (Dimsize(decls,0) * Dimsize(lines,0) == 0)
571+
return 0
572+
endif
573+
568574
Duplicate/T/FREE/R=[][0] decls, declCol0
569575
Duplicate/T/FREE/R=[][1] decls, declCol1
570576
Sort/A lines, lines, declCol0, declCol1
@@ -575,6 +581,12 @@ End
575581
static Function sortListByName(decls, lines)
576582
Wave/T decls
577583
Wave/D lines
584+
585+
// check if sort is necessary
586+
if (Dimsize(decls,0) * Dimsize(lines,0) == 0)
587+
return 0
588+
endif
589+
578590
Duplicate/T/FREE/R=[][0] decls, declCol0
579591
Duplicate/T/FREE/R=[][1] decls, declCol1
580592
Sort/A declCol1, lines, declCol0, declCol1
@@ -809,6 +821,8 @@ Function updateListBoxHook()
809821
STRUCT procedure procedure
810822
Variable returnState
811823

824+
String searchString = ""
825+
812826
// load global lists (for sort)
813827
Wave/T decls = getDeclWave()
814828
Wave/I lines = getLineWave()
@@ -833,7 +847,13 @@ Function updateListBoxHook()
833847
saveResults(procedure)
834848
endif
835849

836-
// check if sort is necessary
850+
// check if search is necessary
851+
searchString = getGlobalStr("search")
852+
if(strlen(searchString)>0)
853+
searchAndDelete(decls, lines, searchString)
854+
endif
855+
856+
// switch sort type
837857
if(returnCheckBoxSort())
838858
sortListByName(decls, lines)
839859
else
@@ -843,6 +863,36 @@ Function updateListBoxHook()
843863
return DimSize(decls, 0)
844864
End
845865

866+
Function searchAndDelete(decls, lines, searchString)
867+
Wave/T decls
868+
Wave/I lines
869+
String searchString
870+
871+
Variable i, numEntries
872+
873+
// search and delete backwards for simplicity reasons
874+
numEntries = Dimsize(decls, 0)
875+
for (i = numEntries - 1; i > 0; i -= 1)
876+
if (strsearch(decls[i][1], searchString, 0, 2) == -1)
877+
DeletePoints/M=0 i, 1, decls, lines
878+
endif
879+
endfor
880+
881+
// prevent loss of dimension if no match was found at all.
882+
if (strsearch(decls[0][1], searchString, 0, 2) == -1)
883+
if (Dimsize(decls, 0) == 1)
884+
Redimension/N=(0,-1) decls, lines
885+
else
886+
DeletePoints/M=0 i, 1, decls, lines
887+
endif
888+
endif
889+
End
890+
891+
Function searchReset()
892+
setGlobalStr("search","")
893+
killGlobalStr("search")
894+
End
895+
846896
// Shows the line/function for the function/macro with the given index into decl
847897
// With no index just the procedure file is shown
848898
Function showCode(procedure,[index])

procedures/CodeBrowser_gui.ipf

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,22 @@
77
// This file was created by () byte physics Thomas Braun, [email protected]
88
// (c) 2013
99

10-
Constant panelWidth = 278
10+
Constant panelWidth = 307
1111
Constant panelHeight = 170
12-
Constant panelLeft = 50
13-
Constant panelTop = 50
12+
Constant panelLeft = 100
13+
Constant panelTop = 100
1414
static Constant panelTopHeight= 90
1515
static Constant panelBorder = 5
1616
static Constant moduleCtrlTop = 10
1717
static Constant procCtrlTop = 40
1818
static Constant SortCtrlTop = 70
1919

20-
static StrConstant panel = "CodeBrowser"
20+
static StrConstant panel = "CodeBrowser"
2121
static StrConstant moduleCtrl = "popupNamespace"
2222
static StrConstant procCtrl = "popupProcedure"
23-
static StrConstant listCtrl = "list1"
24-
static StrConstant sortCtrl = "checkboxSort"
23+
static StrConstant listCtrl = "list1"
24+
static StrConstant sortCtrl = "checkboxSort"
25+
static StrConstant searchCtrl = "setSearch"
2526
static StrConstant userDataRawList = "rawList"
2627
static StrConstant userDataNiceList = "niceList"
2728

@@ -44,56 +45,68 @@ Function createPanel()
4445
endif
4546

4647
// define position
47-
Variable panelLeft = 0, panelTop = 0
4848
NewPanel/N=$panel /K=1/W=(panelLeft,panelTop,panelLeft+panelWidth,panelTop+panelHeight) // left,top,right,bottom
4949
String module = GetIndependentModuleName()
5050

51-
PopupMenu $moduleCtrl, win=$panel,pos={panelBorder,moduleCtrlTop}, size={panelWidth-2*panelBorder,20}, bodywidth=200
51+
PopupMenu $moduleCtrl, win=$panel,pos={0,moduleCtrlTop}, size={panelWidth-2*panelBorder,20}, bodywidth=200
5252
PopupMenu $moduleCtrl, win=$panel,title="Namespace"
5353
PopupMenu $moduleCtrl, win=$panel,proc=$(module + "#popupModules"),value=#module + "#generateModuleList()"
5454

55-
PopupMenu $moduleCtrl, userdata(ResizeControlsInfo)= A"!!,@c!!#;-!!#B>J,hm&z!!#](Aon#azzzzzzzzzzzzzz!!#`-A7TLfzz"
55+
PopupMenu $moduleCtrl, userdata(ResizeControlsInfo)= A"!!,Cd!!#;-!!#B>J,hm&z!!#`-A7TLfzzzzzzzzzzzzzz!!#`-A7TLfzz"
5656
PopupMenu $moduleCtrl, userdata(ResizeControlsInfo) += A"zzzzzzzzzzzz!!#u:Du]k<zzzzzzzzzzz"
5757
PopupMenu $moduleCtrl, userdata(ResizeControlsInfo) += A"zzz!!#N3Bk1ct<C]S6zzzzzzzzzzzzz!!!"
5858

59-
PopupMenu $procCtrl, win=$panel,pos={panelBorder,procCtrlTop}, size={panelWidth-2*panelBorder,20}, bodywidth=200
59+
PopupMenu $procCtrl, win=$panel,pos={0,procCtrlTop}, size={panelWidth-2*panelBorder,20}, bodywidth=200
6060
PopupMenu $procCtrl, win=$panel,title="Procedure"
6161
PopupMenu $procCtrl, win=$panel,proc=$(module + "#popupProcedures"),value=#module + "#generateProcedureList()"
6262

63-
PopupMenu $procCtrl, userdata(ResizeControlsInfo)= A"!!,B9!!#>.!!#B:J,hm&z!!#](Aon#azzzzzzzzzzzzzz!!#`-A7TLfzz"
63+
PopupMenu $procCtrl, userdata(ResizeControlsInfo)= A"!!,D/!!#>.!!#B:J,hm&z!!#`-A7TLfzzzzzzzzzzzzzz!!#`-A7TLfzz"
6464
PopupMenu $procCtrl, userdata(ResizeControlsInfo) += A"zzzzzzzzzzzz!!#u:Du]k<zzzzzzzzzzz"
6565
PopupMenu $procCtrl, userdata(ResizeControlsInfo) += A"zzz!!#N3Bk1ct<C]S6zzzzzzzzzzzzz!!!"
6666

6767
DefineGuide/W=$panel UGH0={FT,panelTopHeight}
6868
DefineGuide/W=$panel UGH1={FB,panelBorder}
69-
70-
ListBox $listCtrl, win=$panel,pos={panelBorder,panelTopHeight + panelBorder}, size={panelWidth-2*panelBorder,panelHeight-panelTopHeight-2*panelBorder}
69+
DefineGuide/W=$panel UGHL={FL,panelBorder}
70+
DefineGuide/W=$panel UGHR={FR,panelBorder}
71+
72+
ListBox $listCtrl, win=$panel,pos={panelBorder,panelTopHeight + panelBorder}, size={panelWidth-2*panelBorder, panelHeight-panelTopHeight-2*panelBorder}
7173
ListBox $listCtrl, win=$panel,proc=$(module + "#ListBoxProc")
7274
ListBox $listCtrl, win=$panel,mode=5,selCol=1, widths={4,40}, keySelectCol=1
7375
ListBox $listCtrl, win=$panel,listWave=getDeclWave()
7476

75-
ListBox $listCtrl, userdata(ResizeControlsInfo)= A"!!,?X!!#@\"!!#B@!!#?Ez!!#](Aon\"Qzzzzzzzzzzzzzz!!#o2B4uAezz"
77+
ListBox $listCtrl, userdata(ResizeControlsInfo)= A"!!,?X!!#@\"!!#BNJ,hopz!!#](Aon\"Qzzzzzzzzzzzzzz!!#o2B4uAezz"
7678
ListBox $listCtrl, userdata(ResizeControlsInfo) += A"zzzzzzzzzzzz!!#N3Bk1ct<C]S6zzzzzzzzzz"
7779
ListBox $listCtrl, userdata(ResizeControlsInfo) += A"zzz!!#N3Bk1ct<C]S7zzzzzzzzzzzzz!!!"
7880

7981
CheckBox $sortCtrl, win=$panel, pos={panelBorder+70,SortCtrlTop},size={40,20},value=prefs.panelCheckboxSort
8082
CheckBox $sortCtrl, win=$panel, title="sort"
8183
CheckBox $sortCtrl, win=$panel, proc=$(module + "#checkboxSort")
8284

83-
CheckBox $sortCtrl, userdata(ResizeControlsInfo)= A"!!,EP!!#?E!!#=o!!#<(z!!#`-A7TLfzzzzzzzzzzzzzz!!#o2B4uAezz"
85+
CheckBox $sortCtrl, userdata(ResizeControlsInfo)= A"!!,EP!!#?E!!#=o!!#<(z!!#](Aon#azzzzzzzzzzzzzz!!#`-A7TLfzz"
8486
CheckBox $sortCtrl, userdata(ResizeControlsInfo) += A"zzzzzzzzzzzz!!#u:DuaGl<C]S6zzzzzzzzzz"
8587
CheckBox $sortCtrl, userdata(ResizeControlsInfo) += A"zzz!!#N3Bk1ct<C]S6zzzzzzzzzzzzz!!!"
8688

89+
setGlobalStr("search", "")
90+
91+
SetVariable $searchCtrl, pos={panelBorder + 118, SortCtrlTop - 2}, size={175.00, 18.00}, proc=$(module + "#searchSet"),title = "search"
92+
SetVariable $searchCtrl, limits={-inf,inf,0}, value=$(pkgFolder + ":search"), live = 1
93+
94+
SetVariable $searchCtrl, userdata(ResizeControlsInfo)= A"!!,F[!!#?A!!#A>!!#<Hz!!#](Aon#azzzzzzzzzzzzzz!!#o2B4uAezz"
95+
SetVariable $searchCtrl, userdata(ResizeControlsInfo) += A"zzzzzzzzzzzz!!#u:DuaGl<C]S6zzzzzzzzzz"
96+
SetVariable $searchCtrl, userdata(ResizeControlsInfo) += A"zzz!!#N3Bk1ct<C]S6zzzzzzzzzzzzz!!!"
97+
8798
SetWindow $panel, hook(mainHook)=$(module + "#panelHook")
8899

89-
SetWindow $panel, userdata(ResizeControlsInfo)= A"!!*'\"z!!#BE!!#A9zzzzzzzzzzzzzzzzzzzzz"
90-
SetWindow $panel, userdata(ResizeControlsInfo) += A"zzzzzzzzzzzzzzzzzzzzzzzzz"
91-
SetWindow $panel, userdata(ResizeControlsInfo) += A"zzzzzzzzzzzzzzzzzzz!!!"
92-
SetWindow $panel, userdata(ResizeControlsGuides)= "UGH0;UGH1;"
93-
SetWindow $panel, userdata(ResizeControlsInfoUGH0)= A":-hTC3`S[@0KW?-:-)m'A7]4jDg-86E][6':dmEFF(KAR85E,T>#.mm5tj<o4&A^O8Q88W:-(Bh/het@7o`,K756hm<'*TM8OQ!&3]g5.9MeM`8Q88W:-(Bh3r"
94-
SetWindow $panel, userdata(ResizeControlsInfoUGH1)= A":-hTC3`S[@0frH.:-)m'A7]4jDg-86E][6':dmEFF(KAR85E,T>#.mm5tj<o4&A^O8Q88W:-(*g0J5%54%E:B6q&gk7RB1,<CoSI1-.Kp78-NR;b9q[:JNr.3r"
100+
SetWindow $panel ,userdata(ResizeControlsInfo)= A"!!*'\"z!!#BSJ,hqdzzzzzzzzzzzzzzzzzzzzz"
101+
SetWindow $panel ,userdata(ResizeControlsInfo) += A"zzzzzzzzzzzzzzzzzzzzzzzzz"
102+
SetWindow $panel ,userdata(ResizeControlsInfo) += A"zzzzzzzzzzzzzzzzzzz!!!"
103+
SetWindow $panel ,userdata(ResizeControlsGuides)= "UGH0;UGH1;UGHL;UGHR;"
104+
SetWindow $panel ,userdata(ResizeControlsInfoUGH0)= A":-hTC3`S[@0KW?-:-(a\\A7\\)JDg-86E][6':dmEFF(KAR85E,T>#.mm5tj<o4&A^O8Q88W:-(Bh/het@7o`,K756hm<'*TM8OQ!&3]g5.9MeM`8Q88W:-(Bh3r"
105+
SetWindow $panel ,userdata(ResizeControlsInfoUGH1)= A":-hTC3`S[@0frH.:-(a\\A7\\)JDg-86E][6':dmEFF(KAR85E,T>#.mm5tj<o4&A^O8Q88W:-(*g0J5%54%E:B6q&gk7RB1,<CoSI1-.Kp78-NR;b9q[:JNr.3r"
95106

96-
SetWindow $panel, userdata(oneTimeInit)= "1"
107+
SetWindow $panel ,userdata(oneTimeInit)= "1"
108+
SetWindow $panel ,userdata(ResizeControlsInfoUGHL)= A":-hTC3`S[@9KQ<I:-(a\\A7\\)JDg-86E][6':dmEFF(KAR85E,T>#.mm5tj<n4&A^O8Q88W:-(6b0JGRY<CoSI0fhct4%E:B6q&jl4&SL@:et\"]<(Tk\\3]/u"
109+
SetWindow $panel ,userdata(ResizeControlsInfoUGHR)= A":-hTC3`S[@;EIrO:-(a\\A7\\)JDg-86E][6':dmEFF(KAR85E,T>#.mm5tj<n4&A^O8Q88W:-(0b2_Hd<4%E:B6q&gk7T)<<<CoSI1-.Kp78-NR;b9q[:JNr.3r"
97110

98111
resizeToPackagePrefs()
99112
DoUpdate/W=$panel
@@ -354,6 +367,25 @@ Function returnCheckBoxSort()
354367
endif
355368
End
356369

370+
Function searchSet(sva) : SetVariableControl
371+
STRUCT WMSetVariableAction &sva
372+
373+
switch( sva.eventCode )
374+
case 1: // mouse up
375+
case 2: // Enter key
376+
case 3: // Live update
377+
Variable dval = sva.dval
378+
String sval = sva.sval
379+
setGlobalStr("search", sval)
380+
updateListBoxHook()
381+
break
382+
case -1: // control being killed
383+
break
384+
endswitch
385+
386+
return 0
387+
End
388+
357389

358390
Function listBoxProc(lba) : ListBoxControl
359391
STRUCT WMListboxAction &lba

procedures/CodeBrowser_hooks.ipf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ Function preparePanelClose()
6161
STRUCT CodeBrowserPrefs prefs
6262
FillPackagePrefsStruct(prefs)
6363
SavePackagePrefsToDisk(prefs)
64+
65+
// reset global gui variables
66+
searchReset()
6467
End
6568

6669
Function panelHook(s)

procedures/CodeBrowser_preferences.ipf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// This file was created by () byte physics Thomas Braun, [email protected]
77
// (c) 2013
88

9-
static Constant kPrefsVersion = 102
9+
static Constant kPrefsVersion = 103
1010
static StrConstant kPackageName = "CodeBrowser"
1111
static StrConstant kPrefsFileName = "CodeBrowser.bin"
1212
static Constant kPrefsRecordID = 0

0 commit comments

Comments
 (0)