Author Topic: hotspots and select-next-word snafu  (Read 5669 times)

bercikr

  • Community Member
  • Posts: 45
  • Hero Points: 2
hotspots and select-next-word snafu
« on: June 02, 2008, 03:11:32 pm »
Hi Ryan,

   I had a question about the select-word and/or select-next-word command. I have been working on a little hack to emulate the code navigation style of eclipse code templates using aliases and hotspots and the select-next-word command. Without going into too much detail, it looks like the select-next-word and the select-word command seem to clear the hotspots somehow. I have looked through the code and I noticed that the clear-hotspots command is not being explicitly called but they are being cleared nonetheless. Could you shed some light on why this might be happening?

Thanks,
Rob

Ryan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 987
  • Hero Points: 77
Re: hotspots and select-next-word snafu
« Reply #1 on: June 02, 2008, 06:02:12 pm »
I think I might need to see the code you are trying to run for this one...as you said, it doesn't look like clear_hotspots is getting called in either of those functions.  Something might be deleting the the markers out from under you, but I'm not sure.  If you can post or email me the code and what it's supposed to do and where you think the hotspots are getting nuked, I'll take a look.

- Ryan

bercikr

  • Community Member
  • Posts: 45
  • Hero Points: 2
Re: hotspots and select-next-word snafu
« Reply #2 on: June 02, 2008, 06:49:24 pm »
Hey Ryan,

   This one is pretty easy to replicate even without seeing any code. If you add the following alias to a language:

Code: [Select]
for( int %\cvar_name = 0; %\c some_test; %\c var_name++){
%\c
}

then try cycling through the hot-spots using next-hotspot, this works. However, if you were to execute select-next-word or select-word, then next-hotspot will stop working.

-Rob

Ryan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 987
  • Hero Points: 77
Re: hotspots and select-next-word snafu
« Reply #3 on: June 02, 2008, 08:41:38 pm »
Hmm...even easier than that, if you just cursor to the right after expanding the alias, and invoke next-hotspot, it doesn't work. 

I've looked into it and it appears that in order to use hotspots you have to be in a hotspot.  Check out the _OnUpdate_next_hotspot function, which eventually checks for the current hotspot.  If it can't find one, it returns disabled (which means it won't run the command).  When you run select_word (or whatever) you are moving out of a hotspot into an area between hotspots, and it's getting confused.

It looks like the feature was implemented this way, so I'll have to double check with another developer who might be able to give me some insight on what the deal is, I'll keep you posted  :-\.

- Ryan

UPDATE:  Yea, it's just how it's implemented.  It can be smartened up, though.  Basically instead of current_hotspot only returning a hotspot if the cursor is actually within a hotspot, you would want to return the nearest hotspot if the cursor is between hotspots. 

I'm not sure if I'll get a chance to mess with this soon, so if you want to have a go at it the code you want to look at is in hotspots.e around line 131 where it is checking the current offset versus the offset and length of a hotspot.  If that condition isn't true, but the cursor is between two hotspots, I think if you return the index of the previous hotspot this will get you the desired behavior.
« Last Edit: June 03, 2008, 02:34:58 pm by Ryan »

bercikr

  • Community Member
  • Posts: 45
  • Hero Points: 2
Re: hotspots and select-next-word snafu
« Reply #4 on: June 03, 2008, 03:28:31 pm »
Alright, I will mess with it today and maybe try and post the changes here if it's clean enough.