Author Topic: Mouse Click Push/Pop Tag  (Read 5071 times)

MindprisM

  • Senior Community Member
  • Posts: 127
  • Hero Points: 8
Mouse Click Push/Pop Tag
« on: October 09, 2009, 10:48:42 am »
Mouse Click Push/Pop Tag

Context sensative code navigation using single mouse click.

Sometimes you just want to browse code...

Usage:

Mouse clicked location symbol: X

//clicking at point X in text: Function();
FunctionX();

// push_tags you to here
void Function(){
  stuff();
}

//clicking at points X below...
void Function()X{
  stuff()X;
}

// pop_bookmarks you to previous location


Command line: mmcpp or _on_my_mou_click_pushpop_toggle toggles the click functionality on and off


========================
Implementation:

SlickEdit Version 12.0.3.0 (or others perhaps)

<BadPractice>
Open mouse.e, find command mou_click, go to bottom of function -


   _scroll_style(old_scroll_style);
   //HERE
   return(0);
}



insert:

Code: [Select]
//my.initials+
call_list('_on_my_mou_click');
//my.initials-

</BadPractice>


In vusermacs.e, or elsewhere-

Code: [Select]
// utility
_str get_char(int offset=0){
   get_line(line);
   if (p_col+offset>length(line)||p_col+offset<1) {
      return "";
   }
   return substr(line,p_col+offset,1);
}


boolean _on_my_mou_click_pushpop_enabled=false;

// turn off and on in case it bugs you sometimes
_command void _on_my_mou_click_pushpop_toggle,mmcpp() name_info(','){
   _on_my_mou_click_pushpop_enabled=!_on_my_mou_click_pushpop_enabled;
   message('_on_my_mou_click_pushpop_enabled:'_on_my_mou_click_pushpop_enabled);
}

// call_list calls me
_command int _on_my_mou_click_pushpop() name_info(','VSARG2_MARK|VSARG2_REQUIRES_EDITORCTL){
   if (!_on_my_mou_click_pushpop_enabled) {
      return;
   }
   fe=strip_filename(p_buf_name,'dpn');
   fe=lowcase(fe)
   // add your own extensions below
   if (pos(' 'fe' ',' cs e cpp c h sh ')!=0) {
      if (get_char()=='('){
         cursor_left();
         wordon=cur_word(beg);
         cursor_right();
         //say(wordon);
         push_tag(wordon,'-c');
         return(0);
       }
      if (get_char(-1)==')'&&get_char()=='{'){
         pop_bookmark();
         return(0);
      }
      if (get_char(-1)==')'&&get_char()==';'){
         pop_bookmark();
         return(0);
      }
   }
   return (0);
}

Happy Clicking! 8)

« Last Edit: October 09, 2009, 10:53:47 am by MindprisM »