Author Topic: how can i add the bookmark mark on sidebar ?  (Read 168 times)

jcelle

  • Community Member
  • Posts: 88
  • Hero Points: 4
how can i add the bookmark mark on sidebar ?
« 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.

Graeme

  • Senior Community Member
  • Posts: 2443
  • Hero Points: 322
Re: how can i add the bookmark mark on sidebar ?
« Reply #1 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.

jcelle

  • Community Member
  • Posts: 88
  • Hero Points: 4
Re: how can i add the bookmark mark on sidebar ?
« Reply #2 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.

Graeme

  • Senior Community Member
  • Posts: 2443
  • Hero Points: 322
Re: how can i add the bookmark mark on sidebar ?
« Reply #3 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

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);


jcelle

  • Community Member
  • Posts: 88
  • Hero Points: 4
Re: how can i add the bookmark mark on sidebar ?
« Reply #4 on: July 01, 2020, 06:12:41 am »
Hi Graeme, you made a happy man !
Thanks

jcelle

  • Community Member
  • Posts: 88
  • Hero Points: 4
Re: how can i add the bookmark mark on sidebar ?
« Reply #5 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.

Graeme

  • Senior Community Member
  • Posts: 2443
  • Hero Points: 322
Re: how can i add the bookmark mark on sidebar ?
« Reply #6 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;
      }
   }
}

jcelle

  • Community Member
  • Posts: 88
  • Hero Points: 4
Re: how can i add the bookmark mark on sidebar ?
« Reply #7 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.