Welcome to "
HippoEDIT explained"
Today we will learn something about "
Navigation Bar" (see picture on the end)
Navigation bar and Labels.
How much time you want to navigate between classes in
you CSS, functions in your C file or sections in INI
file? Now it is possible with help of Navigation bar
and Labels. If you have Labels defined for your syntax,
Navigation Bar, located on top go your document, would
show you list of the labels found in the document.
Helps to filter and navigate to any label, see current
label when navigating in source code, go fast to label
definition in the document with one mouse click. You
can think about Navigation Bar and Labels as about
Function List, used in other editors, but they are much
more powerful. With Label you can define any regular
expression that should represent label, use result of
the match to form Name of the Label and Description,
select which image should be used depending on result
of additional evaluation, or define sub image that can
represent, for example, visibility of label (Private,
Protected or Public). You can bind Label with Scope and
it would be shown on Hierarchy Bar and in Scroll Tip.
Found labels are also used for Smart Navigate, so if
you would call the command on some usage of the label,
you would be driven to label definition.
Please note that Alex have explain the basic about this in the topic
"Adding new Language Syntax" already.
I only take this information and test it how this works to get an better understanding for it.
This may be from interest for others, so i share here my experiences on the way to succeed
(Please note that english isn't my mother language, so perhaps something may be not well written)Navigation Bar could also be called "Function List" or "Code Browser"
Basically a place where you see a list of functions, variables modules and classes in currently active file.
You can enable the "
Navigation Bar" by checking the menu option "View > Panes > [X] Navigation Bar"
The
Navigation Bar can be used mostly in any syntax.
It depends (configured) on
labels definitions from syntax schema.
See this other topic
"Adding new Language Syntax" for more information about this.
For example:
<LABELS>
<Label group="Subroutine" match="\<(sub|function)[\s\[]+(\w+)[\s\]]*(\([^)]*\))" name="\2" descr="\1 \2 \3" image="8" scope="1">
<Image if="\1" equal="sub" value="8"/>
</Label>
<Label group="Class" match="\<(public|private)?\s+class\s+(\w+)\s*" name="\2" descr="Class \2" image="4" scope="1">
<SubImage if="\1" equal="public" value="1"/>
</Label>
</LABELS>Here the label "Subroutine" will match lines containing "Sub" and "Function" words.
Next i will try to explain the RegEx a bit...
Example source code line:
typedef struct _infobox {Label definition in HippoEDIT syntax file:
<Label group="Structure" match="struct\s+(\w+)[^\;{]*\{" name="\1" scope="1" image="9"/> The RegEx (regular expression) term to match an string for an "struct" definition in *.c is defined here as:
match="
struct\s+(\w+)[^\;{]*\{"
The RegEx we use is the part between the both "..." quotes.
To understand this syntax you may want to learn something about RegEx first, if you not already know it.
Good place to learn are for example:
http://en.wikipedia.org/wiki/Regular_expressionhttp://de.wikipedia.org/wiki/Regul%C3%A4rer_Ausdruckhttp://www.boost.org/doc/libs/1_40_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.htmlhttp://www.regular-expressions.info/http://regexlib.com/- - -
I will try to explain this RegEx as good as i can, but i doesn't want to copy an regular expression HowTo here.
The RegEx "
struct\s+(\w+)[^\;{]*\{" can be split into several parts:
struct
\s+
(\w+)
[^\;{]*
\{
That means:
struct find the chars 'struct' literally
\s+ followed by 'one or more' (+) 'whitespace' (\s)
(\w+) followed by 'one or more' (+) 'alphabetic chars' (\w). This part is grouped by (...) to back reference to later.
[^\;{]* NOT followed by 'null or more' (*) of any of the signs found between [...], as this are ';' and '{'
\{ but followed by an '}' sign.
The "Name" -part of the definition is used to give the found source code line an Name, displayed in the Navigation Bar.
name="\1" '\1' means: take that what was found with (\w+), what is "
_infobox" in our case
- - -
Note:If the
Navigation Bar do not show you anything for some syntax, probably labels are not defined for this syntax.
In this case you can add the labels by yourself.
See this other topic
"Adding new Language Syntax" > here < for more information about this.
- - -
Note:The HippoEDIT syntax engine (HSE) would use an LABEL only in "normal" style.
So if we want to use our LABEL with an other STYLE such as "comment" style for example,
we have to told HSE to use the LABEL in that style too.
We do that by adding an CONTAINER advice to the LABEL definition: <Containers open="comment"/>
Example:
Here i have created an LABEL in my VBS syntax.
The term here to catch is "
'//ToDo:"
This means, i want to write '//todo: in my code and the "match"-RegEx of the following label definition
should match this term and show it into the "Navigation Bar", so i can jump through all ToDo's line in my code.
Now, because this ToDo lines are of course commented out in my code
i had to advice the HSE to match my label in comments too.
I have done this by adding the string "<Containers open="comment"/>" to my LABEL:
<LABELS>
<Label group="ToDo" match="//ToDo:\s*(\w*?)\s+(.*?)$" name="ToDoName \1" descr="ToDoDesc \1 \2" image="6" scope="1">
<Image if="\1" equal="ToDo" value="9"/>
<Containers open="comment"/>
</Label>
</LABELS>The CONTAINER "comment" again do point to an STYLE named "comment" in an <lang>_spec syntax xml.
This comment style for my VBS syntax is inherited from "basic_spec.xml"
and looks like this:
<Style id="comment" name="Comments" text="1" bold="0" italic="1" underline="0" clr="Comments" bkclr="#FFFFFFFF">
<Blocks>
<Block open="'" close="\n"/>
<Block open="REM" close="\n"/>
</Blocks>That means that ' and REM are comment signs.
- -
If you want that this LABEL works for different STYLES
you can add one or more CONTAINER for every STYLE you want.
You can add your own STYLE definition or go the "inherit - way" back to look for an existing STYLE.
My vbs_spec.xml is inherited from "basic_spec.xml",
that is inherited from "defsource_spec.xml"
which is inherited again from "def_spec.xml"
Examples:
--- Use the label in normal style only:
No container needed here.
<Label group="ToDo" match="" name="" descr="" image="6" scope="1">
<Image if="\1" equal="ToDo" value="9"/>
</Label>
--- Use the label in, f.ex. comment style only:
<Label group="ToDo" match="" name="" descr="" image="6" scope="1">
<Image if="\1" equal="ToDo" value="9"/>
<Containers open="comment"/> </Label>
--- Use the label in comment AND normal style:
<Label group="ToDo" match="" name="" descr="" image="6" scope="1">
<Image if="\1" equal="ToDo" value="9"/>
<Containers open="comment"/>
<Containers open="normal"/> </Label>
See this other topic
"Adding new Language Syntax" for more information about this.
- - -