Code folding scope

Started by Stefan, March 07, 2009, 10:15:19 PM

Previous topic - Next topic

Stefan

Hi Alex.

I try to use this scope
        <Scope open="ooo" close="ccc"/>


within *.txt files
to manually add some signs  (f.ex.  ooo-ccc)  to use code folding.


But this doesn't works. Please, what is wrong?

def_spec.xml
<Style id="template" name="Template (Completion List)" clr="#FFFFFFFF" bkclr="#FFFFFFFF" dstyle="true" image="15" overview="3"/>
      <Style id="normal" name="Normal" dbkclr="false" bold="0" italic="0" underline="1" clr="blue" bkclr="#FFFFFFFF" overview="3">
      <SCOPES>
        <Scope open="ooo" close="ccc"/>
        <Scope open="+++" close="---"/>
      </SCOPES>
      <Keywords>
        <Keyword text="Hello"/>
        <Keyword text="Best regards"/>
        <Keyword text="Glad to here you once more"/>
      </Keywords>
    </Style>
      <Style id="inactive_code" name="Inactive Code" bold="2" italic="2" underline="2" clr="Inactive Code" bkclr="#FFFFFFFF" overview="3"/>
      <Style id="url" name="WWW addresses and E-Mails" underline="1" clr="#FFFFFFFF" bkclr="#FFFFFFFF" hotspot="1" bold="2" italic="2">
        <Blocks>
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

alex

Hello Stefan,

Scopes are not part of the Style blocks.
You should place them outside as:

<SCOPES>
     <Scope open="ooo" close="ccc"/>
     <Scope open="+++" close="---"/>
</SCOPES>
<STYLES>
<Style id="template" name="Template (Completion List)" clr="#FFFFFFFF" bkclr="#FFFFFFFF" dstyle="true" image="15" overview="3"/>
      <Style id="normal" name="Normal" dbkclr="false" bold="0" italic="0" underline="1" clr="blue" bkclr="#FFFFFFFF" overview="3">


If you want to specify in which styles scope is allowed, then you can use container property inside of the Scope node. Example form cbase_spec.xml      <Scope open="region" close="endregion" has_name="true">
        <Containers open="format_tag"/>
      </Scope>
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

Stefan

#2
Many thanks  Alex, this works

</SPECIFICATION>
    <InsertDateTime>
      <Insert format="%d.%m.%Y %H:%M"/>
    </InsertDateTime>

      <SCOPES>
        <Scope open="{" close="}"/>
      </SCOPES>

    <STYLES>
      <Style id="window"



------------------

I think step-by-step i get it :D

To use this Scope-definition in an special "Style" only,
define an "Container"-item for this "Scope" first.


Modify

      <SCOPES>
        <Scope open="{" close="}"/>
      </SCOPES>

to

      <SCOPES>
        <Scope open="{" close="}">
            <containers open="test_container_name"/>
        </Scope>

      </SCOPES>

(Note:
this means:  put this "Scope" into an "Container" called  "test_container_name" .
"test_container_name"  is the ID used to refer to this container. Use an name as ID that YOU like)

---------------

Then modify  (if not already) the "Style"

from
<Style id="xy" name="xy" />

to
<Style id="xy" name="xy" >
</Style>


---------------

and add this code in blue

<Style id="xy" name="xy" >
      <Containers>
          <open id="test_container_name"/>
      </Containers>

</Style>

between Style-Tags.

Note:
this means:   include   Style-"Container" called "test_container_name"   into this  "Style"
to use all definitions from that Container in this Style.


---------------

If this is correct i will add this to FAQ >Adding new Language Syntax< ,........... or you may if you want...
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

alex

Hello Stefan,

not really correct about containers.

The logic is following:
1) You have styles. Styles are described by Blocks, Keywords, and Words conditions and applied to some interval of the text (text block).
2) Styles can be refered by style id. If id is not defined HE uses name attribute.
3) When you define container (or containers) for Scope or another schema object, you instruct HE to allow this Scope, Style or Label etc only in the specified style.

For example this mean:
<Scope open="{" close="}">
   <containers open="test_container_name"/>
</Scope>
Scope with open tag "{" allowed only in the style "test_container_name". If it would be found in some other style, it would be skipped. If you do not specify containers, HE assumes that this object (scope, style or label) allowed only in normal style (style with id = normal, defined in def_spec.xml).

For objects as Scope and Style you can define containers as for open part, as for close part (for scopes also for middle part). For example CSS block in HTML can be started in normal style of html code and can be closed inside CSS normal or comment style.
<Containers>
   <Close id="css:normal"/>
   <Close id="css:comment"/>
</Containers>

If you do not define open container, it would be normal style of current language.

If you want to refer to a style from another syntax schema, you can do this as well, by giving syntax id before style id separated with ":"  :<Style id="style" name="CSS" include="css:normal" ...
This is including of the CSS block in HTML syntax schema.

I would also put this text partially to FAQ topic about creating new syntax schema.
If something is not clear, ask - I would try to explain better ;)
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

Stefan

Thanks, i try to get it :D

One thing i didn't understand:

> allowed only in the style "test_container_name".
i have no such style-id, but i can still use this folding-marks as f.ex.  #-#, ooo-ccc, xxx-xxx.

My def_spec:

   </InsertDateTime>
      <SCOPES>
        <Scope open="xxx" close="xxx">
        <containers open="test"/>
        </Scope>
      </SCOPES>
    <STYLES>
      <Style id="window"
      <Style id="margin" name="S
      <Style id="selected" name=
      <Style id="selected_ina" n
      <Style id="line_number" na
      <Style id="curr_line" name
      <Style id="curr_line_frame
      <Style id="outlining" name
      <Style id="outlining_highl
      <Style id="read_only" name
      <Style id="changed" name="
      <Style id="saved" name="Ch
      <Style id="max_line_length
      <Style id="bookmark" name=
      <Style id="search_result"
      <Style id="incremental_sea
      <Style id="incremental_sea
      <Style id="white_space" na
      <Style id="trailing_white_
      <Style id="typed_text" nam
      <Style id="template" name=
      <Style id="normal" name="N
      <Keywords>
        <Keyword text="Hello"/>
        <Keyword text="Best rega
        <Keyword text="Glad to h
      </Keywords>
    </Style>
      <Style id="inactive_code"
      <Style id="url" name="WWW
        <Blocks>
          <Block open="http://">




-----

And BTW, i can't set ///-\\\  or  --- - +++  as folding marks.  Is this by design?
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

alex

Quote> allowed only in the style "test_container_name".
i have no such style-id, but i can still use this folding-marks as f.ex.  #-#, ooo-ccc, xxx-xxx.
the reason, why you could use it, I think default logic.
Because style with id "test_container_name" not found, it is skipped. Then at the end, there is not containers defined for scope, and HE think that this is default case, and adds normal as container. Do nto know what is the best, do like now, or if invalid container used, disable scope...

QuoteAnd BTW, i can't set ///-\\\  or  --- - +++  as folding marks.  Is this by design?
Not by design, but by limitation :) Currently as scope tags HE can process or sequences of word chars (defined in SPECIFICATION Words) or single char tags (as { }). Here can be any symbol.
Sequences of any symbols are not supported yet.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]