Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Set/Get Bookmark in QM Editor item
#1
Bookmarks (tags) at specific points (lines) of an item

Function SetBookm
Code:
Copy      Help
str si.getmacro(getopt(itemid) 1)
str caller.getmacro(getopt(itemid 1) 1);err    caller=si
if ideb; min 0; err out "<>%s : <open ''%s /%i''>%s</open> - Called by : <open>%s</open>%s" NowT si _error.place si caller

;www.quickmacros.com/forum/viewtopic.php?p=31513

int c=GetQmCodeEditor

str newText=F" $BkM []"
;int j=SendMessage(c SCI.SCI_GETCURRENTPOS 0 0)
;SendMessage c SCI.SCI_GOTOPOS j+len(newText)-2 0

int j=SendMessage(c SCI.SCI_GETCURRENTPOS 0 0)
int l=SendMessage(c SCI.SCI_LINEFROMPOSITION j 0)
SendMessage c SCI.SCI_GOTOLINE l 0
SendMessage c SCI.SCI_INSERTTEXT -1 newText
j=SendMessage(c SCI.SCI_GETLINEENDPOSITION l 0)
SendMessage c SCI.SCI_GOTOPOS j 0
0.25
int x y cx cy
GetCaretXY x y cx cy
ShowTooltip "Type the bookmark's label" 3 x y+cy 0 1

Function GetBookm
Code:
Copy      Help
str si.getmacro(getopt(itemid) 1)
str caller.getmacro(getopt(itemid 1) 1);err    caller=si
if ideb; min 0; err out "<>%s : <open ''%s /%i''>%s</open> - Called by : <open>%s</open>%s" NowT si _error.place si caller
;www.quickmacros.com/forum/viewtopic.php?p=31513

int c=GetQmCodeEditor

ARRAY(int) lines
int i=QMEFindAll("$BkM" lines)
if i=0
,beeS 1000 300
,Task_Message "There exist no Bookmarks !" 0 1170 2
,ret
str items s
int lens
for i 0 lines.len
,lens=SendMessage(c SCI.SCI_GETTEXTLENGTH lines[i] 0)
,s.fix(SendMessage(c SCI.SCI_GETLINE lines[i] s.all(lens)))
,_s.get(s 6)
,items.formata("%s" _s)
;,out F"{i+1}. {lines[i]}"

i=ListDialog(items "Select the Label of a Bookmark to Go" "Go to Bookmark" 128)
;outt F"{i} - {lines[i-1]}"
SendMessage(c SCI.SCI_GOTOLINE lines[i-1] 0)
#2
This version also supports "go to #sub".

Function GetBookm
Trigger SF12     Help - how to add the trigger to the macro
Code:
Copy      Help
;get QM editor text
str s.getmacro; if(!s.len) ret

;find all '#sub Name' and ' $BkM optional name' lines
ARRAY(CHARRANGE) a; int i
if(0=findrx(s "(?m)^(?:#sub +(\w+)| \$BkM\b([^\r\n]*))" 0 4 a)) ret

;format items text for ListDialog
str items t
for i 0 a.len
,int isBM=s[a[0 i].cpMin]!='#'
,CHARRANGE& r=a[1+isBM i]
,int n=r.cpMax-r.cpMin; if(n>0) t.get(s r.cpMin n); t.trim; else t=""
,items.formata("%i %s[]" isBM t)

i=ListDialog(items "Subfunctions and code bookmarks" "Go to" 128|4 0 0 0 0 0 "$qm$\function.ico[]$qm$\favorites.ico")-1
if(i<0) ret
int c=GetQmCodeEditor
SendMessage(c SCI.SCI_GOTOPOS a[0 i].cpMin 0)

From SetBookm I removed everything above
int c=GetQmCodeEditor
#3
Thank you very much for your perfect modifications.


Forum Jump:


Users browsing this thread: 2 Guest(s)