-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathopen_local_symbol.e
executable file
·2217 lines (1941 loc) · 80.1 KB
/
open_local_symbol.e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
////////////////////////////////////////////////////////////////////////////////////////////////
// © by HS2 - 2007-2014
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
// 'open local symbol' (ols) - 'list-tags-plus' :)
//
// derived from open_local_symbol.e thankfully posted by asandler (Alexander) here:
// http://community.slickedit.com/index.php?topic=2245.msg9334#msg9334
// some features added by hs2
// changes:
// 071026 - added tag filter support
// - improved copy/~append to clipboard
//
// 071101 - added class name (configurable) to symbol list
// - added more word separators (wildcards), CaSe sensitivity and begin/end [^,$] support
// Note that '_' is not longer a separator by default (configurable - @see OLS_WORD_SEPARATORS)
// - added C_BACKSPACE to delete last token/separator only
// - added end-of-string 'cursor'
// - minor form changes
// 071116 - added quick tag filter support incl. hotkeys (see Defs TB -> Quick Filters)
// - fixed a stack-dump occured when <ENTER> with empty tree
// 071117 - quite a lot of internal changes due to some performance problems
// 071118 - performance was better but still bad user experience on laaarge buffers (e.g. 'builtins.e')
// -> solved using (async) timer based design
// -> change proposal to SlickTeam to resolve an issue with using the Preview TB by user macros
// @see tagwin.e - _UpdateTagWindow()
// 071121 - added context menu and a few more config items
// 071123 - added Preview TB support
// 071127 - fixed stupid bug in the font setup, changed on_resize(), fixed typo (seperator -> separator)
// 071127+1 - fixed issue with suffix match and relaxed word order
// 071128 - maybe expand hidden line on goto tag
// - fixed bug in update_return_type _TreeSetCaption was called w/o referencing 'symbols.'tree control
// - added on_close handler (ALT-F4 / system menu) could close use w/o notice
// - added workaround (solution ?) for sync problem curr. buffer <-> curr. context (tag_clear_context)
// 071205 - added 'goto line' if just a number is entered as filter (and there is no matching symbol of course)
// 071212 - dialog is now non-modal and is updated on buffer switch / on_got_focus
// - added ALT-modifier (leave filter/caption) which might be useful when switching to another buffer
// to go to a tag using the current filter (and the dialog is not dismissed)
// - added sth. like 1 level history (curr. just the last cfgs are toggled on TAB
// 080218 - use ';#;' instead of possibly ambiguous '#' as info seperator
// 080405 - use adaptive timer depending on number of visible tags for 'update_tree' for better user experience
// even with files containing a HUGE number of symbols as 'slick.sh'
// 080406 - fixed a few minor issues with auto-activating Preview TB if dialog looses focus
// 080407 - show references feature
// - I've seen VERY RARE situations, where there context was not updated correctly (empty).
// So it's changed back to the original method incl. tag_clear_context() which seems to ALWAYS work.
// 080417 - better init all statics on editor invocation - @see definit()
// - skip _on_got_focus '_switchbuf_' calls - @see stdprocs.e - _on_got_focus()
// - init/reset _ols_window_id to '0' instead of '-1'
// - use get_ols_window_id() to retrieve and verify 'ols' p_window_id in callbacks
// 080417 - bug fix for Preview TB autohide handling in on_got_focus and
// minor fix in on_lost_focus if the mouse is in Preview TB window
// 080804 - added (missing) A-V shortcut: toggle 'CaSe sensitivity'
// 090930 - fixed (missing) tree re-init on 'Include 'Class::' on filtering' toggle
// 120611 - workaround for #pragma option bug in V17 RTM (strip_filename is deprecated)
// 141123 - v4.0.9.0:
// - SE version specific wrappers for V19 toolbar -> toolwindow change and threaded tagging engine (also applies to V18)
// - omit default OLS_AUTO_ACTIVATE_PREVIEW due to focus issue with V19
// - added MindprisM subword/smart abbreviation match
// - removed '=+-' from OLS_WORD_SEPARATORS colliding with (C++) operators
// 141124 - v4.0.9.1: fixed tag filter bug in V19 code path
// 141124 - v4.0.9.2: got missing code from MindprisM to complete 'SubWord match'
// HS2-2DO: - clipboard support (paste filter text), convert to tool window, help/description w/ examples
// use better icons (access specifier !)
// KNOWN ISSUES:
// - it's possible that no bitmaps are displayed e.g. if 'ols' is invoked during SE startup/init phase
// we could use cb_prepare_expand(p_active_form, p_window_id, TREE_ROOT_INDEX); to gain early access
// to the bitmaps but it seems that is way too expensive !
// - V19: focus issue of ols dialog on (auto-)activating Preview or References
#define OLS_VERSION "ols v4.0.9.2 (SE >= v12.0.3)"
#pragma option(strict,on)
// #region Imports // can't use #region b/c it's not backward compatible to v12.0.3
#include 'slick.sh'
#include 'tagsdb.sh'
#include 'toolbar.sh'
#import "cbrowser.e"
#import "clipbd.e"
#import "context.e"
#import "cutil.e"
#import "main.e"
#import "pushtag.e"
#import "seldisp.e"
#import "stdprocs.e"
#import "tags.e"
#import "tagwin.e"
#import "tagrefs.e"
#import "toolbar.e"
#import "util.e"
// #endregion
#if __VERSION__ < 13
extern int _find_formobj(_str form_name, _str option='', ...); // not declared in slick.sh for v12.0.3
extern _command typeless show(_str cmdline="", ...);
#endif
#if __VERSION__ < 17
#define STRIP_FILENAME strip_filename
#else
#define STRIP_FILENAME _strip_filename
#endif
#if __VERSION__ < 19
#import "tbautohide.e"
#endif
#if __VERSION__ < 18
#define _OLS_LOCK_CONTEXT()
#else
#import "se/tags/TaggingGuard.e"
// make sure that the context doesn't get modified by a background thread.
#define _OLS_LOCK_CONTEXT() se.tags.TaggingGuard sentry; sentry.lockContext(false);
#endif
////////////////////////////////////////////////////////////////////////////////////////////////
// hardwired config defintions
// user defined tag filter - @see tagsdb.sh
// Note: It's not a big deal to add a few more user sets. Could do that on demand...
#define OLS_TAG_FILTER_USER (VS_TAGFILTER_ANYPROC | VS_TAGFILTER_ANYDATA)
// font config - @see setEditFont
// Note: set to '0' to use the font attributes/settings of the form 'open_local_symbol' (@see below)
#define OLS_FILT_FONT CFG_DIALOG // CFG_DIALOG, CFG_SBCS_DBCS_SOURCE_WINDOW, ...
#define OLS_TREE_FONT CFG_DIALOG // CFG_DIALOG, CFG_SBCS_DBCS_SOURCE_WINDOW, ...
// pseudo cursor curr. abusing special '&' char (which underlines the next char in captions as accelerator)
// Any other string or char such as '.', '|', '´' or even '±' is possible
// Note: Be aware that for some fonts underline is visually identical underscore.
#define OLS_EOS '&.' // '&|' to get a kind of an I-beam cursor, or '& ', '&_', ...
// I think that in almost all use cases filtering is done CaSe insensitive.
// Hence even if one has switched to CaSe sens. filtering it's reset (on exit) that next time 'ols' is started
// we are in the CaSe insensitive mode again.
// However, this can be disabled by setting OLS_CASE_SENS_RESET_ON_EXIT to 'false'.
#define OLS_CASE_SENS_RESET_ON_EXIT true
// used to set p_SpaceY (determines the extra spacing in twips between each line) property of the tree
#define OLS_TREE_LINE_SPACING 24 // SE default: 50
// update delays in [ms]
// Note: Some fine tuning might be needed if 'ols' is not running smoothly (e.g. lags on key presses)
// OLS_UPDATE_SYMBOLS_TIME is auto-tuned depending on the number of symbols follwing this formula
// Tupdate = OLS_UPDATE_SYMBOLS_TIME * (1 + (Nsymbols / OLS_UPDATE_SYMBOLS_SCALE)) with
// Tupdate is limited to OLS_UPDATE_SYMBOLS_TIME_MAX - @see update_tree
#define OLS_UPDATE_SYMBOLS_TIME_MIN 100 // [ms]
#define OLS_UPDATE_SYMBOLS_SCALE 600 // [num symbols]
#define OLS_UPDATE_SYMBOLS_TIME_MAX 500 // [ms]
#define OLS_UPDATE_PREVIEW_TIME 200 // [ms]
#define OLS_UPDATE_REINIT_TIME 200 // [ms]
// used to separate words/tokens - @see events 'word separators' below and get_word_separators()
// Note: '^' / '$' are the only supported regex chars for begin (token) / end matching.
// '\' might be used to quote e.g. '$' regex (valid part of a symbol name in e.g. Perl)
// I think there is no need to change this set b/c it may lead to surprising filter results.
#define OLS_WORD_SEPARATORS ' ,;#?*'
////////////////////////////////////////////////////////////////////////////////////////////////
enum_flags OLS_FLAGS
{
// include class names 'class::' on filtering
// Hint: Use a ':' token (Slick-C: '.') to filter classes/members.
OLS_USE_CLASS_NAME
// set for smart CaSe sensitivity [per word/token]
// Note: This is simply done by verifying 'strcmp (word, lowcase (word))'
, OLS_SMART_CASE_SENS
// auto-activate / unhide Preview TB (if not set it's only used when already active or (auto)-hidden
, OLS_AUTO_ACTIVATE_PREVIEW
// leave an unnamed bookmark @ current location when goto tag or not
// Note: The opposite happens when a SHIFT/CTRL modifier is pressed on ENTER.
, OLS_LEAVE_BOOKMARK
// sort by line (or alpha)
, OLS_SORT_BY_LINE
// use 'LINE' type clipboards for copy/append symbols
// Note: 'CHAR' type is used otherwise and mult. symbols are appended / concatenated SPACE separated
, OLS_COPY_APPEND_BY_LINE
// strict word/token order on filtering
, OLS_STRICT_WORD_ORDER
// show return type in tree (excluded from filtering)
// Note: The current word order setting is visualized in title / status line as follows:
// Strict word order ON (OLS_STRICT_WORD_ORDER set) -> '101 TAGS- in ...' ('-' appended)
// Strict word order OFF (OLS_STRICT_WORD_ORDER not set) -> '101 TAGS~ in ...' ('~' appended)
, OLS_SHOW_RETURN_TYPE
// set for CaSe sensitivity of *all* words/tokens (OLS_SMART_CASE_SENS is 'overridden').
// Note: The current CaSe sens. setting is visualized in title / status line as follows:
// CaSe sens ON (OLS_CASE_SENS set) -> '101 TAGS- in ...' ('TAGS' upcase)
// CaSe smart sens ON (OLS_SMART_CASE_SENS set) -> '101 Tags~ in ...' ('Tags' capitalized)
// CaSe (smart)sens OFF (OLS_*_CASE_SENS not set) -> '101 tags~ in ...' ('tags' lowcase)
, OLS_CASE_SENS
// initially add a '^' (prefix match) regex on invokation
, OLS_INITAL_PREFIXMATCH
// dismiss/close dialog on goto tag
, OLS_DISMISS
// subword/smart abbreviation match
, OLS_SUBWORD
};
// default 'ols' setup: 0x43F == 1087
// HS2-2DO: omit default OLS_AUTO_ACTIVATE_PREVIEW due to focus issue with V19
// int def_ols_flags = OLS_USE_CLASS_NAME | OLS_SMART_CASE_SENS | OLS_AUTO_ACTIVATE_PREVIEW |
// default 'ols' setup: 0x43B == 1083
int def_ols_flags = OLS_USE_CLASS_NAME | OLS_SMART_CASE_SENS |
OLS_LEAVE_BOOKMARK | OLS_SORT_BY_LINE | OLS_COPY_APPEND_BY_LINE |
OLS_DISMISS;
// default 'ols' tag filter
// Note: '0' -> use default filter set for 'Defs TB' (def_proctree_flags)
int def_ols_tag_filter = 0;
////////////////////////////////////////////////////////////////////////////////////////////////
// event config
defeventtab open_local_symbol;
def 'a'-'z' = _ols_on_key;
def 'A'-'Z' = _ols_on_key;
def '0'-'9' = _ols_on_key;
def '~' = _ols_on_key; // easy match all destructors ;)
def ':' = _ols_on_key; // might be used to match all classes/members
def '/' = _ols_on_key;
def '<' = _ols_on_key;
def '>' = _ols_on_key;
def '"' = _ols_on_key;
def '''' = _ols_on_key;
def '_' = _ols_on_key;
def '.' = _ols_on_key;
def '@' = _ols_on_key;
// word separators (internally converted to SPACEs) - @see get_word_separators()
def ' ' = _ols_on_key;
def ',' = _ols_on_key;
def ';' = _ols_on_key;
def '\' = _ols_on_key;
def '=' = _ols_on_key;
def '#' = _ols_on_key;
def '?' = _ols_on_key;
def '+' = _ols_on_key;
def '-' = _ols_on_key;
def '*' = _ols_on_key;
// case sensitivity hotkeys
// Note: There are also explicit '_ols_on_key_case_sens_on/off' fct.s available)
def 'A-V' = _ols_on_key_case_sens_toggle;
def 'A-PGUP' = _ols_on_key_case_sens_toggle;
def 'A-PGDN' = _ols_on_key_case_sens_toggle;
// regex (hot)keys
// e.g. 'ols ^_' -> matches all '_' prefixed symbols also containing 'ols' (non-strcit word order)
// e.g. '_ol nu$' -> matches all symbols containing '_ol' which end with 'nu' (here: '_ols_on_key_show_menu')
def '^' = _ols_on_key_begin_token_toggle;
def '!' = _ols_on_key_begin_token_toggle;
def '$' = _ols_on_key_end_toggle;
def '(' = _ols_on_key_end_toggle;
def ')' = _ols_on_key_end_toggle;
// add. regex hotkeys - might be helpful too
def 'A-HOME' = _ols_on_key_begin_toggle; // simply toggles a '^' in front of the first token
def 'A-S-HOME' = _ols_on_key_begin_token_toggle; // simply toggles a '^' in front of the curr./last token
def 'C-^' = _ols_on_key_begin_token_toggle; // simply toggles a '^' in front of the first token
def 'A-END' = _ols_on_key_end_toggle; // simply toggles a '$' at the end of the last token
// other
def 'A-M' = _ols_on_key_show_menu;
def 'TAB' = _ols_on_key_last_cfg;
// add direct config toggle hotkeys
def 'S-A-.' = _ols_on_key_references;
def 'A-R' = _ols_on_key_references;
def 'A-T' = _ols_on_key_show_return_type_toggle;
def 'A-L' = _ols_on_key_sort_by_line_toggle;
def 'A-O' = _ols_on_key_strict_word_order_toggle;
// quick type filter hotkeys - might be helpful too
def 'A-F' = _ols_on_key_quick_type_func;
def 'A-P' = _ols_on_key_quick_type_proto;
def 'A-D' = _ols_on_key_quick_type_data;
def 'A-S' = _ols_on_key_quick_type_struct;
def 'A-C' = _ols_on_key_quick_type_const;
def 'A-E' = _ols_on_key_quick_type_else;
def 'A-A' = _ols_on_key_quick_type_all;
def 'A-B' = _ols_on_key_quick_type_proctree;
def 'A-Z' = _ols_on_key_quick_type_proctree; // add 'easy access' hotkey
def 'A-Y' = _ols_on_key_quick_type_proctree; // add 'easy access' hotkey for QWERTZ keymap
def 'A-U' = _ols_on_key_quick_type_user;
def 'A-X' = _ols_on_key_quick_type_user; // add 'easy access' hotkey
// copy(-append) symbols
def 'C-C' = _ols_on_copy;
def 'C-S-C' = _ols_on_copy_append;
def 'C-INS' = _ols_on_copy;
def 'C-S-INS' = _ols_on_copy_append;
// Brief support
def 'PAD-PLUS' = _ols_on_copy;
def 'S-PAD-PLUS'= _ols_on_copy_append;
// preview
def 'A-W' = _ols_on_preview;
// refresh
def 'A-H' = _ols_on_refresh;
def 'F5' = _ols_on_refresh;
////////////////////////////////////////////////////////////////////////////////////////////////
#define OLS_FORM_NAME 'open_local_symbol'
_form open_local_symbol {
p_backcolor=0x80000005;
p_border_style=BDS_SIZABLE;
p_caption='Open Local Symbol';
p_clip_controls=false;
p_forecolor=0x80000008;
p_height=6741;
p_width=11210;
p_x=4046;
p_y=1391;
p_eventtab=open_local_symbol;
_label symbol_name {
p_alignment=AL_LEFT;
p_auto_size=false;
p_backcolor=0x80000008;
p_border_style=BDS_SUNKEN;
p_caption=OLS_EOS;
p_font_bold=false;
p_font_italic=false;
p_font_name='Bitstream Vera Sans Mono';
p_font_size=8;
p_font_underline=false;
p_forecolor=0x80000008;
p_height=264;
p_tab_index=2;
p_width=11084;
p_word_wrap=false;
p_x=60;
p_y=35;
}
_tree_view symbols {
p_after_pic_indent_x=50;
p_backcolor=0x80000005;
p_border_style=BDS_FIXED_SINGLE;
p_clip_controls=false;
p_CheckListBox=false;
p_CollapsePicture='_lbminus.bmp';
p_ColorEntireLine=false;
p_EditInPlace=false;
p_delay=0;
p_ExpandPicture='_lbplus.bmp';
p_font_bold=false;
p_font_italic=false;
p_font_name='Bitstream Vera Sans Mono';
p_font_size=8;
p_font_underline=false;
p_forecolor=0x80000008;
p_Gridlines=TREE_GRID_NONE;
p_height=6351;
p_LevelIndent=0;
p_LineStyle=TREE_DOTTED_LINES;
p_multi_select=MS_NONE;
p_NeverColorCurrent=false;
p_ShowRoot=false;
p_AlwaysColorCurrent=false;
p_SpaceY=OLS_TREE_LINE_SPACING;
p_scroll_bars=SB_VERTICAL;
p_tab_index=1;
p_tab_stop=true;
p_width=11084;
p_x=70;
p_y=324;
p_eventtab2=_ul2_tree;
}
}
#define OLS_MENU_NAME 'open_local_symbol_menu'
_menu open_local_symbol_menu {
"Same as Defs T&B", "ols-menu-cmd _ols_on_key_quick_type_proctree", "","","";
"Show &all tags", "ols-menu-cmd _ols_on_key_quick_type_all", "","","";
"&User defined only", "ols-menu-cmd _ols_on_key_quick_type_user", "","","";
"&Functions only", "ols-menu-cmd _ols_on_key_quick_type_func", "","","";
"&Prototypes only", "ols-menu-cmd _ols_on_key_quick_type_proto", "","","";
"&Data only", "ols-menu-cmd _ols_on_key_quick_type_data", "","","";
"&Structs/classes only", "ols-menu-cmd _ols_on_key_quick_type_struct", "","","";
"&Constants only", "ols-menu-cmd _ols_on_key_quick_type_const", "","","";
"&Everytag else", "ols-menu-cmd _ols_on_key_quick_type_else", "","","";
"-","","","","";
"&References", "ols-menu-cmd _ols_on_key_references", "","","";
"Show Return &type", "ols-menu-cmd _ols_on_key_show_return_type_toggle", "","","";
"Sort by &Line", "ols-menu-cmd _ols_on_key_sort_by_line_toggle", "","","";
"CaSe sensiti&vty", "ols-menu-cmd _ols_on_key_case_sens_toggle", "","","";
submenu "&More Options", "","","" {
"Include '&Class::' on filtering", "ols-menu-cmd _ols_on_key_use_class_name_toggle", "","","";
"&Smart CaSe sensitivity", "ols-menu-cmd _ols_on_key_smart_case_sens_toggle", "","","";
"&Auto-activate Preview TB", "ols-menu-cmd _ols_on_key_auto_activate_preview_toggle", "","","";
"Leave &Bookmark on goto tag", "ols-menu-cmd _ols_on_key_leave_bookmark_toggle", "","","";
"&Dismiss on goto tag", "ols-menu-cmd _ols_on_key_dismiss_toggle", "","","";
"Strict word &Order", "ols-menu-cmd _ols_on_key_strict_word_order_toggle", "","","";
"Inital &Prefix match", "ols-menu-cmd _ols_on_key_inital_prefixmatch_toggle", "","","";
"Sub&Word match", "ols-menu-cmd _ols_on_key_subword_toggle", "","","";
"Cop&y/Append by Line", "ols-menu-cmd _ols_on_key_copy_append_by_line_toggle", "","","";
"-","","","","";
OLS_VERSION, "ols-version", "","","";
}
"-","","","","";
"Cop&y to clipboard", "ols-menu-cmd _ols_on_copy", "","","";
"Appe&nd to clipboard", "ols-menu-cmd _ols_on_copy_append", "","","";
"-","","","","";
"Activate Previe&w TB", "ols-menu-cmd _ols_on_preview", "","","";
"Refres&h", "ols-menu-cmd _ols_on_refresh", "","","";
}
////////////////////////////////////////////////////////////////////////////////////////////////
// some internally used enum/flags/values ...
enum OLS_INIT_TREE_MODE
{
OLS_INIT_TREE_TAGFILTER
, OLS_INIT_TREE_INITIAL
, OLS_INIT_TREE_SORT
};
static _str _ols_cur_buf_name = '';
static int _ols_cur_tree_index = -1;
static int _ols_num_context = 0;
static int _ols_num_tags = 0;
static int _ols_cur_context_id = 0;
static int _ols_PreviewTimerId = -1;
static int _ols_UpdateTimerId = -1;
static int _ols_ReInitTimerId = -1;
static int _ols_window_id = 0;
static boolean _ols_use_tagwin = false;
typedef struct ols_cfg_
{
int flags;
int tag_filter;
_str filter_text;
} ols_cfg;
static ols_cfg _ols_last_cfg, prev_ols_cfg, curr_ols_cfg;
// used to check if we really need to mark the def_ vars changed
// @see open_local_symbol.on_create
static int prev_def_ols_tag_filter = 0;
static int prev_def_ols_flags = 0;
static int orig_autohide_delay = 0;
// even more version wrappers :(
#if __VERSION__ < 19
static int _ols_get_tw_autohide_delay() { return def_toolbar_autohide_delay; }
static void _ols_set_tw_autohide_delay( int ah_delay ) { def_toolbar_autohide_delay = ah_delay; }
static boolean _ols_is_autohide( _str form_name )
{
return (_tbIsAuto("_tbtagwin_form",true) != 0);
}
static void _ols_maybe_restore_autohide( _str form_name )
{
autohide_delay := _ols_get_tw_autohide_delay();
if ( autohide_delay != orig_autohide_delay )
{
_ols_set_tw_autohide_delay(orig_autohide_delay);
int tagwin_wid = _tbGetWid( form_name );
if (tagwin_wid) _tbMaybeAutoHide( tagwin_wid, false );
}
}
#else
static int _ols_get_tw_autohide_delay() { return (int)_default_option(VSOPTION_TOOLWINDOW_AUTOHIDE_DELAY); }
static void _ols_set_tw_autohide_delay(int ah_delay) { _default_option(VSOPTION_TOOLWINDOW_AUTOHIDE_DELAY, (_str)ah_delay); }
static boolean _ols_is_autohide( _str form_name )
{
int tagwin_wid = _tbGetWid( form_name );
return (tagwin_wid && tw_is_auto(tagwin_wid));
}
static void _ols_maybe_restore_autohide( _str form_name )
{
autohide_delay := _ols_get_tw_autohide_delay();
if ( autohide_delay != orig_autohide_delay )
{
_ols_set_tw_autohide_delay(orig_autohide_delay);
int tagwin_wid = _tbGetWid( form_name );
// HS2-2DO: tab group ?
if (tagwin_wid && tw_is_auto_raised(tagwin_wid)) tw_auto_lower( tagwin_wid );
}
}
#endif
////////////////////////////////////////////////////////////////////////////////////////////////
definit()
{
if (arg(1)!='L')
{
// better init all statics on editor invocation
_ols_cur_buf_name = '';
_ols_cur_tree_index = -1;
_ols_num_context = 0;
_ols_num_tags = 0;
_ols_cur_context_id = 0;
_ols_PreviewTimerId = -1;
_ols_UpdateTimerId = -1;
_ols_ReInitTimerId = -1;
_ols_window_id = 0;
_ols_use_tagwin = false;
_ols_last_cfg.flags = def_ols_flags;
_ols_last_cfg.tag_filter = def_ols_tag_filter;
_ols_last_cfg.filter_text = OLS_EOS;
prev_ols_cfg = curr_ols_cfg = _ols_last_cfg;
}
}
defload()
{
// try to close dialog on re-load if it's still hanging around (not dismissed)
// HS2-2DO: Even after closing the dialog I'm getting an 'Invalid Function pointer' stack dump ???
// The 'Invalid Function pointer' always occurs if the module was recompiled due to changes.
formwid := _find_formobj(OLS_FORM_NAME);
if ( formwid > 0 ) formwid._ols_goto_tag( true );
// HS2-CHG: (old) proposal to avoid unintended idle update of the 'Preview TB'
// @see tagwin.e - _UpdateTagWindow()
#if __VERSION__<13
// check if 'tagwin.e' patch was applied
int index = find_index( 'maybe_add_tagwin_noupdate_form', PROC_TYPE );
if ( index ) call_index( OLS_FORM_NAME, index );
#endif
}
static int get_ols_window_id()
{
if ( (_ols_window_id > 0) && (!_iswindow_valid( _ols_window_id ) || (_ols_window_id.p_active_form.p_name != OLS_FORM_NAME)) )
_ols_window_id = 0;
return _ols_window_id;
}
static void get_word_separators( _str &word_separators )
{
word_separators = OLS_WORD_SEPARATORS;
// I've added a bit lang. specific magic here - could be extended for other langs too...
// maybe remove '-' from 'word_separators' b/c it's used in Slick event handler symbols
if ( strieq( _mdi.p_child.p_mode_name, 'Slick-C' ) )
word_separators = translate( word_separators, '', '-', '' );
}
////////////////////////////////////////////////////////////////////////////////////////////////
// subword/smart abbreviation matching enhancement provided by MindprisM
// see http://community.slickedit.com/index.php/topic,2245.msg37161.html#msg37161
//
// examples:
// - 'abcDefghi' matched by 'ad'
// - 'AbcDefGhi' matched by 'ag' or 'dg'
// - 'AbcDEFghi' matched by 'ag' or 'dg' or 'def'
// - 'AbcDefghi' not mathced by, 'ae'
// MindprisM++
_str str_item(_str s,int i,_str d='\n',_str defa=''){
typeless a[];
split(s,d,a);
if (a._length()==0) {
return defa;
}
if (i==-1) {
i=a._length()-1;
}
if (i>a._length()-1) {
return defa;
}
return a[i];
}
_str str_abbr_code(_str s_){
/**
* Creates a string of abbr code characters to use for fast find
* purposes. It will capture:
* <ul>
* <li> All numbers 0-9
* <li> All capitals A-Z
* <li> All alpha transitions; where this char is alpha, but previous is not
* <li> All transitions to lower, provided previous 2 or more chars are upper
* <li> The first char, if alpha
* <ul>
*
* Example:<br>
* <code> str_abbr_code('abcDefGHIjkl-m_1a2b') // returns
* 'aDGHIjm1a2b'
* </code>
*
* @param s_ The subject string
*
* @return abbr code chars
*/
//
// when lower to upper
// abcDef = D
//
// when non-abc to abc
// .abc = a
// 12a = a
//
// when number
// 12a =12
//
// when upper
// abcDEF = DEF
//
// when multiupper to lower
// abcDEFghi = g
//
// when first and alpha or num
//
_str r='';
int x=0;
_str abc='ABCDEFGHIJKLMNOPQRSTUVWXYZ';
_str n='1234567890';
int prev_case=-1;
int prev_abc=-1;
int mult_up=-1;
for (x=0;x<length(s_);x++) {
_str i=substr(s_,x+1,1);
boolean is_abc=pos(upcase(i),abc)!=0;
boolean is_num=pos(i,n)!=0;
boolean is_low=pos(i,lowcase(abc))!=0;
boolean is_up=pos(i,abc)!=0;
if (
pos(i,abc)!=0 //all uppers
||pos(i,n)!=0 //all nums
||(prev_abc!=1&&is_abc) //abc trans
||(mult_up==1&&is_low) //mult upper lower
||(x==0&&(is_abc||is_num))
) {
if (pos(i,abc)!=0&&prev_case==1) {
} else {
r=r i;
}
} else {
}
if (is_up&&prev_case==1) {
mult_up=1;
} else {
mult_up=0;
}
if (is_up) {
prev_case=1;
} else {
prev_case=0;
}
if (is_abc) {
prev_abc=1;
} else {
prev_abc=0;
}
}
return r;
}
boolean str_abbr_code_match(_str s_,_str t_,int min_ct_=-1){
/**
* Determine if two abbr codes match sufficiently, where:
* <ul>
* <li>if s_ and t_ are identical return true
* <li>if s_ and t_ are identical with numbers removed return
* true
* <li>if s_ and t_ ordered match gap count is zero return
* true (ie s_ is in t_)
* <li>if s_ and t_ with numbers removed, ordered match gap
* count is zero return true (ie s_ is in t_)
* <li>When min_ct_==-1 then:
* <ul>
* <li>if length s_ is more than one third the length of t_
* and gap count, with or without nums, is not -1, return
* true
* </ul>
* <li>When min_ct_!=-1 and length of s_ is more than or
* equal to min_ct_ then:
* <ul>
* <li>if gap count, with or without nums, is not -1,
* return true
* </ul>
* <li>Otherwize, when min_ct_!=-1 and length of s_ is less
* than min_ct_ then:
* <ul>
* <li>if gap count, with or without nums, is not -1 and
* less than or equal to one third of the length of s
* return true
* </ul>
* </ul>
*
* @param s_ Souce abbr code
* @param t_ Target abbr code
* @param min_ct_ When source abbr code reaches this length, do not require a gap
*
* @return
*/
// if identical = true
// if strip nums identical = true
// if ordered match and no gaps = true
// if gaps and ordered match 50 pct or more = true
if (s_==t_) {
return true;
}
_str nums='0123456789';
_str ss=str_remove_chars(s_,nums);
_str tt=str_remove_chars(t_,nums);
if (ss==tt) {
return true;
}
int gc1=str_ordered_match(s_,t_);
if (gc1==0) {
return true;
}
if (min_ct_==-1&&length(s_)>=length(t_) intdiv 3) {
if (gc1!=-1) {
return true;
}
if (str_ordered_match(ss,tt)!=-1) {
return true;
}
return false;
}
int gc2=str_ordered_match(ss,tt);
if (length(s_)>=min_ct_) {
if (gc1!=-1) {
return true;
}
if (gc2!=-1) {
return true;
}
return false;
} else {
if (gc1!=-1&&gc1<=length(s_) intdiv 3) {
return true;
}
if (gc2!=-1&&gc2<=length(ss) intdiv 3) {
return true;
}
return false;
}
return false;
}
_str str_remove_chars(_str s_, _str c_){
/**
* Remove all characters in c_ from s_ and return the result
*
* @param s_ Source string
* @param c_ characters to remove
*
* @return s_ without any of the characters in c_
*/
_str r='';
int x;
for (x=0;x<length(s_);x++) {
_str i=substr(s_,x+1,1);
if (pos(i,c_)==0) {
r=r i;
}
}
return r;
}
int str_ordered_match(_str s_,_str t_){
/**
* Given source and target strings which are abbr codes, if souce characters are in target in same order we return a gap count, otherwise return -1
* <br>
* Example of gap count:<br>
* <code> s_='acf'; t_='abcdef';// gap count of 2, first
* representing b, second representing de
* </code>
*
* @param s_ The souce, can be shorter than target
* @param t_ the target, if shorter than source, return -1
*
* @return 0 if perfect match, -1 if failed to match, gap count otherwize
*/
// returns -1 if no match, else return number of gaps
// if t is abcdefghi
// then def returns 0
// then df returns 1
// then adg returns 2
// then z returns -1
// then az returns -1
//
if (s_==t_) {
return 0;
}
if (pos(s_,t_)!=0) {
return 0;
}
//say('=============');
//say('t_:'t_);
//say('substr(t_,1,1):'substr(t_,1,1));
int ct=0;
boolean pg=false;
_str s=s_;
int x;
for (x=0;x<length(t_);x++) {
_str i=substr(t_,x+1,1);
//say('x:'x 'i:'i ' s:'s)
if (i==substr(s,1,1)) {
//say('i==substr(s,1,1)');
if (length(s)==1) {
return ct;
}
s=substr(s,2);
pg=false;
} else {
//say('i!=substr(s,1,1)');
if (!pg) {
if (length(s)!=length(s_)) {
ct++;
}
}
pg=true;
}
}
return -1;
}
// MindprisM--
////////////////////////////////////////////////////////////////////////////////////////////////
static void PreviewTimerCallback( int context_id )
{
_kill_timer( _ols_PreviewTimerId ); _ols_PreviewTimerId = -1;
VS_TAG_BROWSE_INFO cm;
tag_browse_info_init( cm );
_OLS_LOCK_CONTEXT();
tag_get_context_info( context_id, cm );
cb_refresh_output_tab( cm, true, true, true );
}
static void UpdateTimerCallback()
{
_kill_timer( _ols_UpdateTimerId ); _ols_UpdateTimerId = -1;
ols_wid := get_ols_window_id();
if ( !ols_wid ) return;
orig_wid := p_window_id;
p_window_id = ols_wid;
_update_tree();
p_window_id = orig_wid;
}
static void ReInitTimerCallback()
{
_kill_timer( _ols_ReInitTimerId ); _ols_ReInitTimerId = -1;
ols_wid := get_ols_window_id();
if ( !ols_wid ) return;
orig_wid := p_window_id;
p_window_id = ols_wid;
init_tree( def_ols_tag_filter, OLS_INIT_TREE_INITIAL );
p_window_id = orig_wid;
}
static void _update_tree( boolean on_init_tree = false )
{
if ( _ols_use_tagwin && ( _ols_PreviewTimerId != -1 ) ) { _kill_timer( _ols_PreviewTimerId ); _ols_PreviewTimerId = -1; }
_str pattern = substr( symbol_name.p_caption, 1, length( symbol_name.p_caption ) - length( OLS_EOS ) );
int index = symbols._TreeGetFirstChildIndex( TREE_ROOT_INDEX );
int first_match = -1, patlen = length( pattern );
if ( (patlen == 0) || ((patlen == 1) && (substr( pattern, 1, patlen ) :== '^')) )
first_match = _ols_cur_tree_index;
// prepare string_match params
// convert all word separators to SPACEs
get_word_separators( auto word_separators );
pattern = translate( pattern, ' ', word_separators );
// un-regex special '~'and ':' chars (used for d'tor / class search e.g. in C/C++ buffers)
// pattern = _escape_re_chars ( pattern );
pattern = stranslate( pattern, '\~', '~' );
pattern = stranslate( pattern, '\:', ':' );
pattern = stranslate( pattern, '\@', '@' );
patlen = length( pattern );
int hidden, found, count, prev_pos, cur_pos;
_str pattmp, name, word, posopt;
boolean any_word_order = ( 0 == (def_ols_flags & OLS_STRICT_WORD_ORDER) );
boolean smart_case_sens = ( 0 != (def_ols_flags & OLS_SMART_CASE_SENS) );
boolean case_sens = ( 0 != (def_ols_flags & OLS_CASE_SENS) );
boolean subword = ( 0 != (def_ols_flags & OLS_SUBWORD) );
// HS2-NOT: _TreeBeginUpdate is also done on 1st init_tree()
if ( !on_init_tree && (index > 0) ) symbols._TreeBeginUpdate(index);
while ( index >= 0 )
{
hidden = 0;
if ( patlen > 0 )
{
name = symbols._TreeGetUserInfo( index );
name = substr( name, 1, pos( ';#;', name ) -1 );
// HS2-NOT: inlined string_match to sqeeze out as much performance as possible
// hidden = string_match( pattern, name, 0 != (def_ols_flags & OLS_STRICT_WORD_ORDER) ) ? 0 : TREENODE_HIDDEN;
// looking for occurrences of all pattern tokens in name (in any/strict order)
// need a copy of pattern b/c strip_last_word is 'destructive'
pattmp = pattern;
found = count = 0; prev_pos = MAXINT;
loop
{
word = strip_last_word( pattmp );
if ( 0 == length( word ) ) break;
count++;
// check for smart CaSe sensitivity per token (maybe overidden by OLS_STRING_MATCH_CASE)
posopt = ( ( smart_case_sens && strcmp (word, lowcase (word))) || case_sens ) ? 'R' : 'RI';
cur_pos = pos( word, name, 1, posopt );
if ( cur_pos )
{
if ( any_word_order ) found++;
else if ( cur_pos < prev_pos ) { found++; prev_pos = cur_pos; }
}
}
hidden = ( found == count ) ? 0 : TREENODE_HIDDEN;
// MindprisM subword/smart abbr. match
if ( subword )
{ //m.c.r+
//dont step on locals
if (count==1) {
_str n2=name;
if (pos(name,'::')!=0) {
_str junk;
parse name with junk'::'n2;
}
//_str caps=opf_str_caps_of(n2);
_str acode=str_abbr_code(str_item(n2,0,'('));
//say('acode:'acode);
if (str_abbr_code_match(pattern,lowcase(acode),4)) {
hidden =0;
}
}
} //m.c.r-
}
if ( (first_match < 0) && !hidden ) first_match = index;
symbols._TreeSetInfo( index, -1, 0, 0, hidden );
index = symbols._TreeGetNextSiblingIndex( index );
}
symbols._TreeEndUpdate(TREE_ROOT_INDEX);
if ( first_match >= 0 )
{
symbols._TreeSetCurIndex( first_match );
symbols.call_event(CHANGE_SELECTED, first_match, symbols, ON_CHANGE, 'W');
}
if ( on_init_tree && !(def_ols_flags & OLS_SORT_BY_LINE) ) symbols._TreeSortCaption(TREE_ROOT_INDEX, 'I');
symbols._TreeRefresh();
}
static void maybe_add_return_type( _str &name, _str &return_type, _str &type_name )
{
// HS2-DBG: maybe_add_return_type
// if ( pos( 'var', type_name ) ) say ("name:" name " return_type: " return_type " type_name: " type_name);
if ( (def_ols_flags & OLS_SHOW_RETURN_TYPE) && ( (length( return_type ) > 0) || (length( type_name ) > 0) ) )
{
// HS2-DBG: lang. sens. return type hack
if ( !strcmp(type_name, 'define') )
{
if ( strcmp(return_type, 'typeless' ) ) name = name :+ " " :+ return_type;
}
else if ( !strcmp(type_name, 'eventtab' ) ) name = type_name :+ " " :+ name;
else if ( !strcmp(type_name, 'typedef' ) ) name = type_name :+ " " :+ return_type :+ " " :+ name;
else if ( !strcmp(type_name, 'enum' ) ) name = type_name :+ " " :+ name;
else if ( !strcmp(type_name, 'enumc' ) ) name = name :+ " " :+ return_type;
else if ( !strcmp(type_name, 'struct' ) ) name = type_name :+ " " :+ name;
else if ( !strcmp(type_name, 'union' ) ) name = type_name :+ " " :+ name;
else if ( !strcmp(substr (return_type, 1, 1), '=') ) name = name :+ " " :+ return_type;