SlickEdit Community

SlickEdit Product Discussion => SlickEditĀ® => Slick-CĀ® Macro Programming => Topic started by: jcelle on June 28, 2020, 10:21:36 AM

Title: how can i add the bookmark mark on sidebar ?
Post by: jcelle on June 28, 2020, 10:21:36 AM
Hello slick-c gurus !
Does anyone knows what function I could use to toggle display of some bookmark icon on the left margin ?
Thanks in advance.
Title: Re: how can i add the bookmark mark on sidebar ?
Post by: Graeme on June 29, 2020, 06:44:10 AM
Do you want to toggle the bookmark itself or just the display of the bookmark?  In tools -> options ->editing -> bookmarks  - the "show set bookmarks" option allows you to hide or show bookmarks.  If you want to toggle the bookmark itself  - maybe toggle-bookmark()  - applies to the bookmark on the current line.
Title: Re: how can i add the bookmark mark on sidebar ?
Post by: jcelle on June 29, 2020, 06:55:15 AM
Hi Grame and thanks for your reply.
I want only the GUI part: I have written my own slick-c bookmark functions to limit the bookmark navigation to the current buffer: each buffer has its set of bookmarks and I want to jump within the buffer only (hence the other question you replied to about testing a hashtable key).
It works pretty fine though I do not have the GUI part.
Not sure if I want to mix with real SlickEdit bookmarks using toggle_bookmark() as I still need those when using tag navigation.
Title: Re: how can i add the bookmark mark on sidebar ?
Post by: Graeme on June 29, 2020, 08:36:48 AM
Ah, in that case you can use line markers
see _LineMarkerAdd etc. in the help and MarkerFunctions category.
They attach to a line so that if lines are inserted or deleted they stay on the correct line.
If you want an example, I used them in my xretrace macros here - see xretrace.e
https://community.slickedit.com/index.php/topic,16598.msg64005.html#msg64005 (https://community.slickedit.com/index.php/topic,16598.msg64005.html#msg64005)

Code: [Select]
   retrace_line_marker_pic_index_cur = _find_or_add_picture(XRETRACE_PATH :+ '_xretrcur.png@native');

      _LineMarkerAdd(retrace_region_line_marker_window_id, retrace_current_line, 1, 1,
                     retrace_line_marker_pic_index_cur_now, retrace_marker_type_id, "xretrace" );

   retrace_marker_type_id = _MarkerTypeAlloc();
   _MarkerTypeSetPriority(retrace_marker_type_id, 241);

Title: Re: how can i add the bookmark mark on sidebar ?
Post by: jcelle on July 01, 2020, 06:12:41 AM
Hi Graeme, you made a happy man !
Thanks
Title: Re: how can i add the bookmark mark on sidebar ?
Post by: jcelle on July 01, 2020, 09:35:44 PM
Hi again,
What you mentioned about this marker being attached to the line despite inserts or deletions is interesting: is there a way to retrieve the 'new' line number so that I can jump back to the line properly ?
Currently I am using goto_line which indeed can bring me to another line than the original one I memorized. (I wish I had a goto_marker)
All the best.
Title: Re: how can i add the bookmark mark on sidebar ?
Post by: Graeme on July 02, 2020, 12:00:27 AM
Yes, in xretrace I do it like this

Code: [Select]
static void update_retrace_line_numbers(dlist & alist)
{
   xretrace_item * ip;
   VSLINEMARKERINFO info1;
   dlist_iterator iter = dlist_begin(alist);
   for( ; dlist_iter_valid(iter); dlist_next(iter)) {
      ip = dlist_getp(iter);
      if (ip->marker_id_valid && (_LineMarkerGet(ip->line_marker_id, info1) == 0)) {
         ip->last_line = info1.LineNum;
      }
   }
}
Title: Re: how can i add the bookmark mark on sidebar ?
Post by: jcelle on July 02, 2020, 05:33:55 AM
Very nice !
I had tried to find such a _LineMarkeGet function in the documentation but it is apparently missing!
I have downloaded xretrace files and couldn't dive into so far, but will do when I am in holidays soon.
Thanks for your quick update Graeme.