Author Topic: Syntax files and Code Templates  (Read 903 times)

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 774
  • Karma: +6/-0
    • View Profile
Syntax files and Code Templates
« on: November 10, 2009, 04:36:22 pm »
741 and 735

I have an problem with an keyword

I have an keyword "buttons" but can't execute them
because with TAB-key the word "buttons" is expanded to "BUTTONSHADOW"

\data\syntax\basic_spec.xml:    <Keyword text="BUTTONSHADOW"/>
\data\syntax\vbs_spec.xml:      <Keyword text="buttons" descr="vbOKOnly 0 Display OK button only.\n vbOKCancel 1 Displ...

Note: I have ENTER disabled as trigger, i want to use TAB only.
I can click or press enter while in Ctrl+Space dialog, but that only completes "butto" to "buttons" but doesn't insert the expanded CT

What would be an solution here?
* modify trigger chars "buttons" to have no conflict?
* have an option to hold CTRL while clicking in Ctrl+Space dialog to expand the CT?
* do i smtg wrong?
Stefan, HippoEDIT beta tester  (HippoEDIT News On Twitter: http://twitter.com/hippoedit/)

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1712
  • Karma: +29/-2
    • View Profile
    • HippoEDIT
Re: Syntax files and Code Templates
« Reply #1 on: November 10, 2009, 04:51:25 pm »
Sorry, Stefan... But did not get you.

Does <Keyword text="buttons" descr="vbOKOnly 0 Display OK button only.\n vbOKCancel 1 Displ...
has a pattern defined?

because otherwise it should not expand to something.

Also on tab you can accept hint, and what would be a result depends from what is shown in tooltip :)

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 774
  • Karma: +6/-0
    • View Profile
Re: Syntax files and Code Templates
« Reply #2 on: November 10, 2009, 08:48:32 pm »
A> Does <Keyword
A> has a pattern defined?
A>
A> because otherwise it should not expand to something.

Arrrgh, of course not. (unbelievable, just a few months not worked with this... and already forgot all )
And i had sworn it had works before. Sorry for that.
But this keyword was born to show tool tip only (hold cursor over word "buttons" and see tool tip)

Now, after adding an pattern i CAN left click or press enter on CT in CT-dialog, it works.





The only irritation is
that i see "BUTTONSHADOW" in tool tip
if i had typed "buttons"
and pressing TAB then "buttons" is expanded to "BUTTONSHADOW"

Shouldn't (don't know what is better) the shortest match be taken to expand?
Or Is there an rule which match is taken into account first?
* first ground (base) syntax file, then inherited one
* or did you take STYLE name=" " into account?



Next question:
i didn't remember right now, is there an option to auto open CT-dialog
if there are more then one possible match in list?

I mean: If i type "button" i get an black tool tip "buttons" which indicate that there are more then one matches
and i have to press Ctrl+Space on my own to get the list.... i think i have seen other editors who auto provide the list.





OHH, and pressing TAB while this black tool tip appears - is inserting the CT.
(i type "button", the black tool tip shows "buttons", i press TAB and CT is inserted)
This was irritation because the keyword is "buttons" but it works with "button"


No request (right now  :P ) .... just stumbling over that today again... and i guess you are interested what little problems your users get from time to time.

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 774
  • Karma: +6/-0
    • View Profile
Re: Syntax files and Code Templates
« Reply #3 on: November 11, 2009, 01:59:12 pm »
741

An another question:

I test to use an own syntax file.
I do that by:
   * copy VBS syntax to VBS_own
   * inherit VBS_own from VBS
   * oben an *.VBS file with VBS_own syntax


My configurations:

1 - I have basic_spec.xml
     <Style id="functions" name="Functions" image="12" bold="0" italic="0" underline="0" clr="Keyword3" bkclr="#FFFFFFFF">
        <Keywords pattern="%CurrentWord%([%|%])">
          <Keyword text="Abs"/>

(just for the record, it's standard, i just have modified "keyowrd default pattern" for testing to see what is pasting in.)


2 - i have vbs_spec.xml
<SYNTAX id="vbs" name="Visual Basic Script" inherit="basic" inherit_url="basic_spec.xml">
      <Style id="functions" extend="true">
        <Keywords>
          <Keyword text="Echo"/>
        </Keywords>
      </Style>

(just for the record, it's standard)


3 - - i have an own syntax file "vbs-Stefan_spec.xml"
 <SYNTAX id="vbs_own" name="Visual Basic Script own" inherit="vbs" inherit_url="vbs_spec.xml">
      <Style id="functions" override="true" name="Functions" image="12" bold="0" italic="0" underline="0" clr="Keyword3" bkclr="#FFFFFFFF">
 <!--       <Keywords pattern="%CurrentWord%(%|%)"> -->
          <Keyword text="Abs" pattern="Abs TEST" descr="Abs(number) - Returns the absolute value of a specified number"/>



Question 1)
If i have an document with "Visual Basic Script own" syntax
and execute Abs -keyword
i get Abs([ ])
instead of  Abs TEST

I think override="true" makes me independent from basic_spec , for this style ?
Or did override "only" skip style from next lower syntax? but not from first-basic syntax.
EDIT: No, i think not, because i tested this now, i changed the parent syntax to 'basic'
"vbs-Stefan_spec.xml"
  <SYNTAX id="vbs_own" name="Visual Basic Script own" inherit="basic" inherit_url="basic_spec.xml">
      <Style id="functions" override="true"

and i get also still Abs([ ])



Question 2)
not tested yet, i think you know it:
can i have an keyword-own-pattern (f.ex. like seen for Abs-keyword)
which overrides the keyword-default-pattern, here "%CurrentWord%(%|%)"
I mean: for all keywords an () is added, but for Abs where no () is added but 'Abs TEST' is inserted.

Puh, i hope you understand me :D
« Last Edit: November 11, 2009, 02:19:22 pm by Stefan »

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1712
  • Karma: +29/-2
    • View Profile
    • HippoEDIT
Re: Syntax files and Code Templates
« Reply #4 on: November 11, 2009, 04:53:15 pm »
Hi Stefan,

for first topic:
the problem is that if you add pattern to keywords, it is NOT a real CT. It is just some kind of extend for keyword inserting to to one more step to intellisense. So it does not change a priority of this item on hint calculation.

If you add REAL CT with Code Templates, it would have always priority against all keywords and would be always shown in tip if you type CT key. Otherwise statistic rules are used. Also hints equal to typed term is not suggested.

No there is no option to show completion list automatically. And there is a reason for this. Recalculating of the complete list, takes much more time as code hint, and would make typing slower.

List of CT (do not mix with keywords) can be shown with command Edit.ShowTemplates.

for second topic:
yes, override should reset all inherited keywords (with patterns etc), if not this is a bug. Form code I see this is done. But I would check

Quote
an i have an keyword-own-pattern (f.ex. like seen for Abs-keyword)
just try to add pattern to a keyword...
<Keyword text="Echo" desc="" pattern=""/>
this is mentioned here, search for pattern.

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1712
  • Karma: +29/-2
    • View Profile
    • HippoEDIT
Re: Syntax files and Code Templates
« Reply #5 on: November 11, 2009, 06:14:55 pm »
Quote
<SYNTAX id="vbs_own" name="Visual Basic Script own" inherit="vbs" inherit_url="vbs_spec.xml">
      <Style id="functions" override="true" name="Functions" image="12" bold="0" italic="0" underline="0" clr="Keyword3" bkclr="#FFFFFFFF">
 <!--       <Keywords pattern="%CurrentWord%(%|%)"> -->
          <Keyword text="Abs" pattern="Abs TEST" descr="Abs(number) - Returns the absolute value of a specified number"/>

Stefan... Maybe you have forgotten <Keywords></Keywords> around Keyword?
Because  by me everything works. So I assume you did a mistake in definition...

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 774
  • Karma: +6/-0
    • View Profile
Re: Syntax files and Code Templates
« Reply #6 on: November 12, 2009, 03:37:48 pm »
A> for first topic:
Thanks for clarifying.
I will come back if i had test some more.

A> for second topic:
As you tell me it has to work, i tested with fresh HE installation and new created own_spec... and yes it works.
Then I checked my old and my new spec and didn't find why it should not work there too  ::)  but i will check some more.
If i didn't find the mistake i send you the file, but first i want to solve it on my own.
Thanks for you support.

 

Related Topics

  Subject / Started by Replies Last post
XML Code templates

Started by JJK « 1 2 » Bug reports

16 Replies
2549 Views
Last post December 04, 2008, 01:42:33 pm
by JJK
6 Replies
1681 Views
Last post January 24, 2009, 12:52:16 pm
by Stefan
2 Replies
590 Views
Last post December 11, 2008, 12:01:06 pm
by alex
3 Replies
657 Views
Last post March 02, 2009, 01:51:51 am
by alex
4 Replies
888 Views
Last post March 04, 2009, 05:25:29 pm
by alex