Author Topic: Function Definition Jump  (Read 1209 times)

Offline Arthur

  • Hero Member
  • *****
  • Posts: 620
  • Karma: +1/-0
  • He who is ashamed of asking is afraid of learning.
    • View Profile
    • My Blog
Function Definition Jump
« on: March 16, 2009, 03:27:01 pm »
Does that make sense to add a jump to function definition?

One would be able this way to quickly access a function definition (say by right clicking on the function name).

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 772
  • Karma: +6/-0
    • View Profile
Re: Function Definition Jump
« Reply #1 on: March 16, 2009, 04:14:27 pm »
yes this would be nice.

I would do this on my own if only scripting would be available :D

var = getWordUnderCursor
Find "Function " & var

-

I want also to see the very first occur of an var

like:
vPOSx = getX
vPOSy = getY
vWord = getWordUnterCursor
GoTo {TOF}
FIND vWord
MsgBox "Click OK to go back"
setX = vPOSx
setY = vPOSy

--

or i'd like to check if all vars are in DIM area too.

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1666
  • Karma: +29/-2
    • View Profile
    • HippoEDIT
Re: Function Definition Jump
« Reply #2 on: March 16, 2009, 10:42:42 pm »
Hi,

yes idea is not bad, but this is not possible in generic way. HE could not know what is a "function" and where is a "function definition". This is even more complex for variable definition.

And what if function is defined in another file? What to do with functions which have same name but different signatures?
To have full support of such functionality you need language oriented IDE or special plugin for HE. Or script maybe.

But easiest things are possible:
If function definition defined as label, then calling of Smart Navigate (Alt+G) on function usage in the code would jump to label with appropriate name (ehich is a function definition).
This is already possible, and I think should work for VB schema. Try it.

Jumping to first occurance of word on Smart Navigate when all other jumps are not possible is a good idea. I would put this in my todo and maybe would implement next betas.

Best regards,
Alex 

Offline Arthur

  • Hero Member
  • *****
  • Posts: 620
  • Karma: +1/-0
  • He who is ashamed of asking is afraid of learning.
    • View Profile
    • My Blog
Re: Function Definition Jump
« Reply #3 on: March 17, 2009, 02:09:23 am »
Quote
If function definition defined as label
I am not quite following what the above means...

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1666
  • Karma: +29/-2
    • View Profile
    • HippoEDIT
Re: Function Definition Jump
« Reply #4 on: March 17, 2009, 11:55:26 am »
Check basic_spec.xml part LABELS:
Code: [Select]
    <LABELS>
      <Label group="Subroutine" match="\&lt;(public|private)?\s*(sub|function)\s+(\w+)\s*(\([^)]*\))" name="\3" descr="\2 \3 \4" image="5" scope="1">
        <Image if="\2" equal="sub" value="8"/>
        <SubImage if="\1" equal="public" value="1"/>
        <SubImage if="\1" equal="private" value="3"/>
      </Label>
    </LABELS>
The label, is some part of the code that can be referenced from another part of the document (see more detailed description here) and shown in Navigation Bar, Hierarchy Bar, Scroll Info etc. Labels can be described with regular expressions and generally can be any part of the text. But particulary in vb case it is function and subroutines definitions.

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 772
  • Karma: +6/-0
    • View Profile
Re: Function Definition Jump
« Reply #5 on: March 30, 2009, 08:17:15 am »
Beta 1.42 Build 637

Added. Jumping to first occurrence of the word in current top level scope on Smart Navigate.

(means: put cursor inside an word and press Alt+G to go to place where this word is used first time.
Or if you want: set anchor with F7, the use Alt+G, then use Ctrl+F7 to go back to anchor.
Hint: to jump from occurrence to occurrence of an word use Ctrl+F3/Shift+Ctrl+F3)

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 772
  • Karma: +6/-0
    • View Profile
Re: Function Definition Jump
« Reply #6 on: April 01, 2009, 04:42:58 pm »
Beta 1.42 Build 637
Added. Jumping to first occurrence of the word in current top level scope on Smart Navigate.

While using this new feature ... i see it didn't works always.

EDIT: i think i found an issue: this works for me only inside an block?
I have an Block "On Error Resume Next"  to set an bgcolor to my likely.
If i use ALT+G i found only the first occurrence within the same block (as far as i have test it)
If the word would be one line above / outside my block it isn't found.

099 myword
100 On Error Resume Next -block
101 myword
... ...
657 myword --- ALT+G goes only up to line 101, not to line 099


I work with an syntax which i am currently test too.
I have this in my syntax:

  <Style id="ErrHand" name="ErrorHandling" text="1" bold="0" italic="0" underline="0" clr="#000000" bkclr="#eeeeee">
        <Blocks>
          <Block open="On Error Resume Next" close="On Error GoTo 0"/>
        </Blocks>
      </Style>



Note, I have an Scope too in this syntax
 <Scope open="On Error Resume Next" close="On Error GoTo 0"/>



AS far as i see/understand:
- Block is used for style, here for setting colors.
- Scope is for folding.
Am i on the right way? :D

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1666
  • Karma: +29/-2
    • View Profile
    • HippoEDIT
Re: Function Definition Jump
« Reply #7 on: April 01, 2009, 05:58:17 pm »
Hi Stefan,

the logic on Smart Navigate is follwing:
when noting else found HE goes to first occcurence which is
- in same top level scope (block)
- has same style (to skip matches in strings and comments, if done in code)

Next:
Styles used for a lot of things, but main purpose is syntax highlighting. Also they used for defining Containers to limit some othr styles or scope or labels (this is in FAQ also). If style switches syntax (embed syntax) it also used for folding.

Scopes used for folding. Mostly. But also for some other things, where it can be logical. For example to limit some actions as search for first occurence or open/close brace.

Regards,
Alex

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 772
  • Karma: +6/-0
    • View Profile
Re: Function Definition Jump
« Reply #8 on: April 01, 2009, 08:03:37 pm »
Oh  ::)
Then it works as indented  :'(
(i thought i could jump to the first occurrence in doc and find out if i had DIM my VAR. OK, waiting for scripting :D)

Thanks for clarifying!

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1666
  • Karma: +29/-2
    • View Profile
    • HippoEDIT
Re: Function Definition Jump
« Reply #9 on: April 29, 2009, 12:04:15 am »
Hello Stefan,

I got an idea, that could help you :)

First Smart Navigate goes to first occurence of the word in the 0-level block (as it now).
But if you call it once more, it goes to first occurence in the document. I think it is not difficult to press Alt+G twice ;)

Would be added in next beta.

Best regards,
Alex.

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 772
  • Karma: +6/-0
    • View Profile
Re: Function Definition Jump
« Reply #10 on: April 29, 2009, 07:59:47 am »
Hello Stefan,

I got an idea, that could help you :)
Upps? Thank you!

Quote
First Smart Navigate goes to first occurence of the word in the 0-level block (as it now).
But if you call it once more, it goes to first occurence in the document.
>it goes to first occurence in the document
GREAT.


Quote
I think it is not difficult to press Alt+G twice ;)
That's pretty fine :D
Thanks

Soon i can use
-- 'Alt+G' twice to find first occurrence of word under cursor
-- then 'Navigate backward' assigned to 'Alt+Shift+G' to go back where i came from



Stefan

Offline urlwolf

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Function Definition Jump
« Reply #11 on: May 02, 2009, 03:32:04 pm »
what if the symbol is defined in another file in the project (which is good practice)?
Would HE jump to the right file?
For that, you may want to use ctags.
Works well for most filetypes.

also, do we have a list of functions on each file? How? I couldn't see it in the project mode
Thanks

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1666
  • Karma: +29/-2
    • View Profile
    • HippoEDIT
Re: Function Definition Jump
« Reply #12 on: May 03, 2009, 05:35:43 pm »
Quote
Would HE jump to the right file?
No. Support of ctags is in plans, but woul be done when plugin support would be added.

Quote
also, do we have a list of functions on each file? How? I couldn't see it in the project mode
There is no special pane for it. In HE function list currently represented as Navigation Bar, shown on top of editor window.
Navigation Bar shows list of labels (described as regex) from document. So the szntax should have them defined and you need to enable Navigation Bar in menu View->Panes.

Best regards,
Alex.

 

Related Topics

  Subject / Started by Replies Last post
1 Replies
394 Views
Last post April 17, 2009, 03:43:58 pm
by alex
1 Replies
517 Views
Last post July 27, 2009, 03:52:53 pm
by alex
2 Replies
403 Views
Last post September 30, 2009, 06:17:38 pm
by Stefan
1 Replies
241 Views
Last post September 24, 2010, 12:46:33 am
by alex
2 Replies
299 Views
Last post November 24, 2010, 03:14:39 am
by jgodfrey