Author Topic: Idea collecting thread: Side panel  (Read 6559 times)

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Idea collecting thread: Side panel
« on: December 20, 2008, 10:24:10 pm »
Thread renamed from
RFC: Repository Explorer - idea collector
to
Idea collecting thread: Side panel

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

Collection thread for ideas to implement an Item window on the left side of HE window.


Near "File Explorer" and "Project Explorer" i think about an "Repository Explorer"- tab :

  • I want to add "folders" like with 'Project Explorer'
  • Each folder can have sub-folders and files.
  • This is to execute snippets and commands like scripts and external tools.
  • Files show here in this explorer as "folder"  are in real  XLM-Files in HippoEDITs Repository sub-folder
  • This XML files can hold different data with up to 9 topics.
  • 1 or up to 9 of this topics are shown as Columns in RepExplorer
  • ...
<Column1><Show=1><ColName><Data></Data></ColName></Show></Column1>

---

One XLM file could hold recent files list

<Column1> Filename
<Column2> File Path
<Column3> Last size
<Column4> Last Access Date

Show this as Columns in RepEx:
Filename | File Path | Last size | Last Access Date

-

Other could hold list of items for an coding language (like the templates)
<Column1> Key
<Column2> Description ( = name of the item as shown in the list)
<Column3> Shortcut
<Column4> Tool Tip ( = show the Content)
<Column5> Content

--

This way we can see an list of all available items and easy choose the right one.

-

Would be extra nice i we could select more then one item from the list to open/insert/execute them

-

We should be able to use %place holders% within those snippets, like %Date%, %SelectedText%, %CursorPosition%,...

-

As extra i wanna be able to drag & drop an block of text to the list
and be prompted for the other values as 'key' , 'name' , 'shortcut' and so on.

-

Maybe option to allow in what panel the content should be displayed?
Perhaps we can get the option to open two panels the same time?   One left, one right?

<display>1</display>   or   <display>left</display>    to display this  content in left panel

So we can set up to open one list on the left and an another on the right

[   Left panel    ]  [        Document        ]  [ Right Panel ]
[ Choose list |v]                                      [ Choose list |v]
[Ascii.txt          ]                                     [ Snippets  VBS]

00h  NUL ^@                                          For ... Next
01h  SOH ^A                                          If .. Then ..EndIF
02h  STX ^B                                          Do while ... Loop
03h  ETX ^C                                          ...
04h  EOT ^D                                           ...
05h  ENQ ^E                                           ...
06h  ACK ^F
07h  BEL ^G
08h  BS  ^H



-

For what to use?

- recent file list
- snippets (code templates    or   boilerplate's like "Best regards\nStefan"
- show text file (f.ex. list of ASCII-chars, telephone numbers, quick list for keywords + snipplets,  todo's ... whatever...)
- File Explorer (implemented)
- Projects (implemented)
- Sessions ( just store list of current open files for tomorrow)
- Code Templates (insert %Date%) 
- choose and execute macros, scripts and tools
- Favorites  (files (*.txt, *.vbs, *.chm), folders, web URLs, ...)



-

Here i have an screenshot how this could look like.
And whit an shortcut i can open here an "Finder" to easy find an item
by typing in some chars which could be in the item name:

.
« Last Edit: April 21, 2009, 12:13:20 pm by Stefan »
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

Offline Arthur

  • Registered User
  • Hero Member
  • *
  • Posts: 653
  • Karma: +1/-0
  • He who is ashamed of asking is afraid of learning.
    • View Profile
    • My Blog
Re: Idea collecting thread: Side panel
« Reply #1 on: April 23, 2009, 09:43:51 pm »
That would be neat to store my code snippets in the side panel! May be the future macros/HE scripts can sit there too?
It is common, by the way, to implement that for HTML tags as found in other editors.

rjbull

  • Guest
Re: Idea collecting thread: Side panel
« Reply #2 on: May 29, 2009, 02:02:48 pm »
Maybe snippets/boilerplates could have user-defined variables e.g. $first_name, $last_name for making "personalised" texts, or for putting URLs in correctly in SMF forums?  A little menu would pop up asking you to fill in the named blanks before generating the complete text?  A bit like Konrad Papala's Ka Type In, or the more advanced template features in Comfort Keys?  (but maybe that doesn't fit with a programmers' editor)


Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Re: Idea collecting thread: Side panel
« Reply #3 on: May 29, 2009, 04:46:58 pm »
Hi rjbull, thanks.

> user-defined variables e.g. $first_name,
Such feature is already there in HippoEDIT ==> http://forum.hippoedit.com/index.php/topic,83.msg207.html#msg207
and i am sure this would be used for snippets too.

But it's good to have this suggestion here in this tread too, thanks.

(We even talked about interactive macro-snippets  like seen with E)



Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Re: Idea collecting thread: Side panel
« Reply #4 on: July 25, 2009, 07:14:11 pm »
Perhaps a few ideas for snippets implementation?



*snipMate.txt*  Plugin for using TextMate-style snippets in Vim.
http://www.vim.org/scripts/script.php?script_id=2540

Quote
SYNTAX                                                        *snippet-syntax*

The syntax for snippets in *.snippets files is the following: >

 snippet trigger
    expanded text
   more expanded text

Note that the first hard tab after the snippet trigger is required, and not
expanded in the actual snippet. The syntax for *.snippet files is the same,
only without the trigger declaration and starting indentation.

Also note that snippets must be defined using hard tabs. They can be expanded
to spaces later if desired (see |snipMate-indenting|).





"#" is used as a line-comment character in *.snippets files; however, they can
only be used outside of a snippet declaration. E.g.: >

 # this is a correct comment
 snippet trigger
    expanded text
 snippet another_trigger
    # this isn't a comment!
   expanded text







By default, the cursor is placed at the end of a snippet. To specify where the
cursor is to be placed next, use "${#}", where the # is the number of the tab
stop. E.g., to place the cursor first on the id of a <div> tag, and then allow
the user to press <tab> to go to the middle of it:
 >
 snippet div
    <div id="${1}">
      ${2}
   </div>
<










                        *snipMate-placeholders* *snipMate-${#:}* *snipMate-$#*
Placeholders ~

Placeholder text can be supplied using "${#:text}", where # is the number of
the tab stop. This text then can be copied throughout the snippet using "$#",
given # is the same number as used before. So, to make a C for loop: >

 snippet for
    for (${2:i}; $2 < ${1:count}; $1++) {
      ${4}
   }

This will cause "count" to first be selected and change if the user starts
typing. When <tab> is pressed, the "i" in ${2}'s position will be selected;
all $2 variables will default to "i" and automatically be updated if the user
starts typing.
NOTE: "$#" syntax is used only for variables, not for tab stops as in TextMate.







Variables within variables are also possible. For instance: >

 snippet opt
    <option value="${1:option}">${2:$1}</option>

Will, as usual, cause "option" to first be selected and update all the $1
variables if the user starts typing. Since one of these variables is inside of
${2}, this text will then be used as a placeholder for the next tab stop,
allowing the user to change it if he wishes.

To copy a value throughout a snippet without supplying default text, simply
use the "${#:}" construct without the text; e.g.: >

 snippet foo
    ${1:}bar$1







Interpolated Vim Script ~

Snippets can also contain Vim script (here HippoEDIT variables) commands that are executed (via |eval()|)
when the snippet is inserted. Commands are given inside backticks (`...`); for
TextMates's functionality, use the |system()| function. E.g.: >

 snippet date
    `system("date +%Y-%m-%d")`

will insert the current date, assuming you are on a Unix system. Note that you
can also (and should) use |strftime()| for this example.




Filename([{expr}] [, {defaultText}])             *snipMate-filename* *Filename()*

Since the current filename is used often in snippets, a default function
has been defined for it in snipMate.vim, appropriately called Filename().



With no arguments, the default filename without an extension is returned;
the first argument specifies what to place before or after the filename,
and the second argument supplies the default text to be used if the file
has not been named. "$1" in the first argument is replaced with the filename;
if you only want the filename to be returned, the first argument can be left
blank. Examples: >

 snippet filename
    `Filename()`
 snippet filename_with_default
    `Filename('', 'name')`
 snippet filename_foo
    `filename('$1_foo')`

The first example returns the filename if it the file has been named, and an
empty string if it hasn't. The second returns the filename if it's been named,
and "name" if it hasn't. The third returns the filename followed by "_foo" if
it has been named, and an empty string if it hasn't.







                                                                   *multi_snip*
To specify that a snippet can have multiple matches in a *.snippets file, use
this syntax: >

 snippet trigger A description of snippet #1
    expand this text
 snippet trigger A description of snippet #2
    expand THIS text!

In this example, when "trigger<tab>" is typed, a numbered menu containing all
of the descriptions of the "trigger" will be shown; when the user presses the
corresponding number, that snippet will then be expanded.



Example Snippets for C:
Code: [Select]
# If Condition
snippet if
if (${1:/* condition */}) {
${2:/* code */}
}
snippet el
else {
${1}
}
# Tertiary conditional
snippet t
${1:/* condition */} ? ${2:a} : ${3:b}
# Do While Loop
snippet do
do {
${2:/* code */}
} while (${1:/* condition */});
# While Loop
snippet wh
while (${1:/* condition */}) {
${2:/* code */}
}
# For Loop
snippet for
for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
${4:/* code */}
}
# Custom For Loop
snippet forr
for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
${5:/* code */}
}
# Function
snippet fun
${1:void} ${2:function_name}(${3})
{
${4:/* code */}
}


Snippets for HTML
Quote

# Generic Doctype
snippet doctype HTML 4.01 Strict
   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""
   "http://www.w3.org/TR/html4/strict.dtd">
snippet doctype HTML 4.01 Transitional
   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""    "http://www.w3.org/TR/html4/loose.dtd">

snippet doctype HTML 5
   <!DOCTYPE HTML>

snippet doctype XHTML 1.0 Frameset
   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

snippet doctype XHTML 1.0 Strict
   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">



snippet html
   <html>
   ${1}
   </html>
snippet xhtml
   <html xmlns="http://www.w3.org/1999/xhtml">
   ${1}
   </html>

snippet body
   <body>
      ${1}
   </body>

snippet head
   <head>
      <meta http-equiv="content-type" content="text/html; charset=utf-8"`Close()`>

      <title>${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
      ${2}
   </head>

snippet title
   <title>${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}</title>${2}

snippet script
   <script type="text/javascript" charset="utf-8">
      ${1}
   </script>${2}

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2170
  • Karma: +37/-3
    • View Profile
    • HippoEDIT
Re: Idea collecting thread: Side panel
« Reply #5 on: July 26, 2009, 10:53:12 am »
Hello Stefan,

thanks for suggestions. Would take it into account (I am already thinking about enhancements for code templates). And snippets is basically code templates in HE terminology.

Another question here... I see that such notation of defining of variables (fex ${1:option}">${2:$1}) is rather popular and widely used (in TextMate/InType/E-TextEditor snippets, in EmEditor etc) and probably it is better to change HE style of definitions (%something%) to vim notation. It would make easier to copy snippets from other editors and make migration easier.

The problem can be only that I do not want to support two notations in same time and maybe old user scripts would be non working (installed code templates I would update). Or maybe I can provide migrate tool... Do not know.

What do you think?

Best regards,
Alex.

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Re: Idea collecting thread: Side panel
« Reply #6 on: July 26, 2009, 01:16:42 pm »
You mean instead of
%SelectedText%
%Year%
%AppDir%

using
${SelectedText}
${Year}
${AppDir}

include an number as position marker for the next used item to jump from 1 to 2 to 3 to...
${1:SelectedText}
${3:Year}
${2:AppDir}

and just an number to jump from one place to next.
$4
$5



All $placeholders with the same number are modified at the same time you modify one of them
<a href="www.$1">$1[/url]
<a href="www.hippo">hippo[/url]

or
Function $1()
...
$1 =
End Function //$1




Then we could just take  a look at snipplr.com  and paste an interesting snippet into HippoEDIT like
   1.       <label for="$1" />$2</label>
   2.       <input id="$1" name="$1" type="text" />
(http://snipplr.com/view/8890/textmate-snippet-for-html--paired-input-and-label/)
and it should work.


Could be a clever option.
It seams some people searching for an good alternative with textmate/e-editor like snippets.



---------

Good explanation of snippets can be found here http://manual.macromates.com/en/snippets


Good idea is also regex functionality inside of $placeholders like:
Quote
In the format string we can use \u to uppercase the next character, so a snippet that only asks for the name of the instance variable once could look like this:

- (${1:id})${2:foo}
{
    return $2;
}

- (void)set${2/./\u$0/}:($1)aValue
{
    [$2 autorelease];
    $2 = [aValue retain];
}

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2170
  • Karma: +37/-3
    • View Profile
    • HippoEDIT
Re: Idea collecting thread: Side panel
« Reply #7 on: July 26, 2009, 10:40:08 pm »
Yes, I mean something like you have mention :)
And the point is that there are much more existing snippets for textmate as HippoEDIT has, so this can be very helpful...
Only the problem is migrating.
I would try to add this 1.50, after scripting and plugin support.

Thanks for your help Stefan, and detailed response ;)

 

Related Topics

  Subject / Started by Replies Last post
15 Replies
10193 Views
Last post April 21, 2009, 11:27:55 am
by Stefan
39 Replies
15304 Views
Last post April 22, 2010, 06:40:49 pm
by alex
18 Replies
8257 Views
Last post June 17, 2016, 11:09:59 pm
by alex
2 Replies
3067 Views
Last post April 20, 2010, 09:28:57 pm
by Theno
4 Replies
1677 Views
Last post December 22, 2010, 03:02:09 am
by vi.