Choose comment text

Started by JJK, December 04, 2008, 11:08:59 AM

Previous topic - Next topic

JJK

When I comment any lines, a pertinent bit of text is added before the selected lines (of course, sometimes also at the end depending of current syntax). But no possibility to comment plain text.
I think it would be nice to be able to choose, for plain texts, the text to add before the selected lines, like in EditPlus. Actually we can do it in column mode by selecting a 0-wide column in the beginning of lines. But it is not easy to thus select many lines.

Also for plain texts, there is no outlining space. Normal. But I think that the text is too glued to the left edge of the window.

(request for further versions, not for 1.40)

alex

QuoteBut no possibility to comment plain text.
It is not possible to comment plain text, because plain text does not contain style "comment". Because who knows what is the comment for plain text ;)
But let assume that you want to do quoting for mail. Then right way whould be to inherit from plain text schema and only add comment style calling it Quoting for example. Like this:
File mail_spec.xml:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="syntax.xslt"?>
<XMLConfigSettings>
  <FILEINFO author="HippoEDIT.com" type="LangSpec"/>
  <SYNTAX id="mail" name="Mail" inherit="text" inherit_url="txt_spec.xml">
    <SPECIFICATION>
      <FilePattern mask="*.eml"/>
    </SPECIFICATION>
    <STYLES>
      <Style id="comment" name="Quoting" text="1" bold="0" italic="1" underline="0" clr="Comments" bkclr="#FFFFFFFF">
        <Blocks>
          <Block open="> " close="\n"/>
        </Blocks>
      </Style>
    </STYLES>
  </SYNTAX>
</XMLConfigSettings>


Store this file in you syntax folder, restart, create new document with syntax Mail.
Now you can do the quotting with toolbar or with comment shortcut as for other source code. Is that would be enough?

QuoteAlso for plain texts, there is no outlining space. Normal. But I think that the text is too glued to the left edge of the window.
If comments are defined you can still enable outlining margin ;) But, generally I am already do some small offset on the left side, then there is no outlining margin, but as I see it is not enough. I would provide possibility to control this (not interactivly through the dialog, but with settings.xml, because I think this is to technic to place it into Options dialog).
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

Stefan

#2
Quote from: alex on December 04, 2008, 12:20:18 PM
It is not possible to comment plain text, because plain text does not contain style "comment".
Because who knows what is the comment for plain text ;)
The user knows ;-)

I think a work around is RegEx s&r
Find: ^(.+)$
Replace with: WordBefore $1 WordAfter

An feature to implement would be:
- open dialog with two fields: "Before:" and "After:"
where user can write text or sign to insert before and/or after selected lines or string or word.

I imagine this scenario:
1.) select an word (or an string like A_BCD-EF01, or an whole line or a few lines)
2.) open this suggested command
3.) write your text or sign into the two fields (before/after)
4.) maybe chose an option like (per line) or (per word/string)
5.) press OK

I imaging that way i could
select a few words and surround them all one-by-one with quotes"" with one command.
Or i select a few lines and prefix them with an comment sign.
Or i select a few lines and and put "COPY " in front and " ." behind


EDIT:
Ohh  ::)
but that is no real set-comment-sign / remove-comment-sign function.
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

alex

To sollve this scenarion, I have introduced new template tag %SelectedLine%.

Now if you would create a template like this:

SomethingBefore %SelectedLine% SomethingAfter

Then select some text and execute template by menu or shortcut, you should get every line surrounded by SomethingBefore and SomethingAfter. For example

aaaa
bbbb

->

SomethingBefore aaaa  SomethingAfter
SomethingBefore bbbb  SomethingAfter

And! This should also work for Column selection ;)

Already inside from 1.40.550.

Best regards,
Alex

HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

JJK

QuoteSomethingBefore aaaa  SomethingAfter
Yes, works fine ! Thxs very much.
So now I can surround any line to comment it like this
Quote--- my comment ----
Perfect.
For that I create a template with this code :
Quote%Variable name%%SelectedLine%%Variable name%
BTW you say
Quoteexecute template by menu or shortcut
I see how to execute template by shortcut, but how by menu ?

Another request : in my example (--- my comment ---)  text added before and after line are identical. But if I want 2 different texts, I cannot use %Variable name%. I would need 2 different %variable name%.
Would it be possible to add %Variable name 0% to %Variable name 9%. It would be so wonderful !!

Stefan

#5
Quote from: JJK on December 08, 2008, 04:23:37 PM

Another request : in my example (--- my comment ---)  text added before and after line are identical. But if I want 2 different texts, I cannot use %Variable name%. I would need 2 different %variable name%.
Would it be possible to add %Variable name 0% to %Variable name 9%. It would be so wonderful !!

Hi JJK, the HE var is %SelectedLine% as place holder of the whole line.
The "Before" and the "After" are not %vars%  but plain text.
So you would use this as : Hippo %SelectedLine% EDIT
and therefor you can add what you want 'before' and 'after'
like f.ex.  Copy %SelectedLine% D:\Backups\*.*

Edit:
Ahh, i forgot:
You can create your own 'Input-Boxes' by write %place holder name% in your Code:
f.ex.
%Text To Add In Front% %SelectedLine% %Text to add after%

Now:
1.) select one or more lines
2.) launch this template
3.) you are prompted for the text to insert before first,... and then for the text to insert after.

Or use the same text for 'before' and 'after' by using the same %place holder% twice:
f.ex.
%Text To Add% %SelectedLine% %Text To Add%
This way you are asked only once for an text to insert, and this text is used twice, 1x before and then 1x after.

You can make any combination, like:
Here just some text to insert in front of the lines %SelectedLine% %What text to add as suffix%

or
%Comment sign% %SelectedLine% %Comment sign%  this was for testing only


Quote from: JJK on December 08, 2008, 04:23:37 PM
BTW you say I see how to execute template by shortcut, but how by menu ?
Take a look under "Format"-menu: "Surround by Template"

I think this menu item should get an new name:
- Execute template  ???
- Insert template  ???
- run template  ???

--

Otherwise an great option, i like it :thumpsup:

Improvement suggestion: maybe an optional option to skip blank lines ?
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

alex

If you have some template for you syntax, which contain %SelectedText% or %SelectedLine%, then after you have selected some text, in Main menu Format (or in Context menu submenu Format) you would see submenu Surround by template, with list of templates containing %SelectedText% or %SelectedLine%.

And some more hints:
- if you keep Ctrl pressed when call context menu, with right mouse click, you would get Format Context menu open by default.
- if you have selected text, and press Ctrl + Space (completeion command), you would get a list of all templates, and first would be templates containing %SelectedText% or %SelectedLine%.

About %Variable name% :) .  This is only example. You would get input request popup in all cases when template engine could not resolve template name. And text of inside % % whould be shown in the title of the dialog. So you can use any text, for example %Enter preffix% and %Enter suffix%.

Best regards,
Alex
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

alex

Hello Stefan,

I dont know about the name. It is really only work when you have selected text in your document, and have template with "%SelectedText%" or %SelectedLine% inside... And it is really surrounding. You dont see all templates there.
But maybe I would think about showing all templates in the menu. Then it would be possible to execute any template from the menu, even if there is no selected text. Then and name can be changed.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

Stefan

Quote from: alex on December 08, 2008, 04:53:49 PM
Hello Stefan,

I dont know about the name. It is really only work when you have selected text
And it is really surrounding. You dont see all templates there.
...showing all templates in the menu.

> It is really only work when you have selected text
Ah i see now

> You dont see all templates there.
OK, i have assumed this by my own thinking,  ;D sorry.

Now you have explanaid this,... the item name make sense
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

JJK

To Alex and Stefan
Thanks. It's perfect for me.

Stefan

Question:
shouldn't this be different?
shouldn't my STYLE overwrite inherited style?

to my new syntax:
<SYNTAX id="ahk" name="AutoHotkey Script" inherit="basic" inherit_url="basic_spec.xml">


i have copied this part:
      <Style id="comment" name="Comments" text="1" bold="0" italic="1" underline="0" clr="Comments" bkclr="#FFFFFFFF">
        <Blocks>
          <Block open="> " close="\n"/>
        </Blocks>
      </Style>


and modified "> " to ";"



But i still get an " ' "    (from basic_spec ?? )  as comment sign instead of " ; ".



If i modify " ' " to ";" in basic_spec.xml   
then i have ";" as comment sign in AHK syntax too (and in vbs ...)



Here are the header of my syntax:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="syntax.xslt"?>
<XMLConfigSettings>
  <FILEINFO author="HippoEDIT.com" type="LangSpec"/>
  <SYNTAX id="ahk" name="AutoHotkey Script" inherit="basic" inherit_url="basic_spec.xml">
<SCOPES>
<Scope open="aaa" close="bbb"/>
</SCOPES>
<SPECIFICATION>
    <Words>0-9A-Za-z#_</Words>
      <FilePattern mask="*.ahk"/>
    </SPECIFICATION>
    <STYLES>
      <Style id="comment" name="Comments" text="1" bold="0" italic="1" underline="0" clr="Comments" bkclr="#FFFFFFFF">
        <Blocks>
          <Block open=";" close="\n"/>
        </Blocks>
      </Style>   
      <Style id="objects" extend="true">
        <Keywords>
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

alex

Hello Stefan,

use exclude="true" in style definition. Then comment style would not be inherited from parent and you can use any blocks for commenting style you like. By default HE takes first block for commenting (if no block with start_pos="0" defined).
If you try to comment lines, HE would try to use blocks with  \n (line end) for commenting
If you try to comment not whole line selction it would try to use stream comments (ending with not line end).

Best regards,
Alex.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

Stefan

Can you please help me some more?  i didn't get it to work....

I tried both:

     <Style id="commentes" exclude="true" name="Commentes" text="1" b
       <Blocks>
         <Block open=";" close="\n" exclude="true"/>
       </Blocks>
     </Style>   
     <Style id="objects" extend="true">     


i have found   exclude="true"    with 'Containers' only   in other syntax files
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

alex

:)

Sorry Stefan, I was wrong :)

The attribute name was "override"... It was designed but was not yet used, But should work. Use it inplace of first exclude in Style attributes.

And probably it is a more correct name for style attribute as exclude. But what I see, that it is possible to override style, but not possible to really exclude it from inheritance without overriding.
So, probably exclude would be also created... (but I thought it was already added...)

I would also update FAQ part.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

Stefan

It works it works it works :D

At home it works since 17 March, but not at work, *arrgh*

Now i had time and found it,.....
...of course my new style has to have the same ID as the original style i want to "override".
(while my testing i had renamed it to find an way to get it work)

And the style to handle the comment-sign has to have the right ID-name: "comment"

Now that works
<SYNTAX id="ahk" name="AutoHotkey Script" inherit="basic" inherit_url="basic_spec.xml">
<STYLES>
      <Style id="comment" override="true" name="Comment" text="1" bold="0" italic="1" underline="0" clr="Comments" bkclr="#FFFFFFFF">
        <Blocks>
          <Block open=";" close="\n"/>
        </Blocks>
      </Style>   
        .....
</STYLES>



This means:
my new SYNTAX is inherited from "basic_spec.xml"
but the comment--STYLE  (found in  "basic_spec.xml" too)  i have override inside-this-and-for-this new syntax
by creating an style block with the same ID "comment" (as this is the trigger to use this style for comment settings)
and adding the keyword " override="true" "  to  alter this style for this new syntax and override the original style settings from  "basic_spec.xml"
 
.
Alex, if something is wrong description, please correct me.
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-