Author Topic: How Auto-brackets (pair symbols) and Surround Selection works  (Read 2326 times)

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2183
  • Karma: +37/-3
    • View Profile
    • HippoEDIT
How Auto-brackets (pair symbols) and Surround Selection works
« on: November 06, 2009, 11:06:13 am »
Everything is based on symbol pairs defined in OpenClose node of spec XMLs.
Code: [Select]
<SPECIFICATION>
   <OpenClose>()[]{}''""</OpenClose>
</SPECIFICATION>

Here is the list of rules used:
  • Editor does not do parsing for all previously open/close pair symbols. It just add close one or remove both, if you delete close, and char before close one, is open symbol
  • For symmetric pairs (as “”) rules are more strict. You should have spaces (or delimiters) around
  • For asymmetric, next char should be delimiter, otherwise close symbol will not be added
  • Auto adding does not work in “text” styles (comments, strings)
  • If you type open + close symbol fast. HippoEDIT will “eat” auto added. But if you do it after bigger delay, you would get “duplicated” close one. This is by design. Editor remembers only last auto closed pair, but not all of them.
  • Editor executes adding of pair symbol action only after typing open symbol
  • Deletes back of both pair symbols, if there is no other characters or white space between open/close symbols
  • There is similar function exists, that can be useful: Surround Selection. If you select some text and then press any of open symbols, selection should be surrounded by open close symbol
  • You can control what should be treated as pair symbol by direct modifying of xml spec files

To achieve behavior with different formatting for some of the pair symbols, you can use code templates.
Add code template with { as a key and text like this:
{
%|%
}
And after typing { you would see tooltip for expanding template or you can directly call it with Ctrl+Enter.
From my side, next beta I would add some extension, that adding of pair symbol should not be executed, if exist template with key equal to open symbol.
« Last Edit: June 19, 2010, 08:18:56 pm by alex »

 

Related Topics

  Subject / Started by Replies Last post
2 Replies
1914 Views
Last post February 19, 2009, 04:23:39 pm
by Arthur
11 Replies
2756 Views
Last post May 16, 2009, 12:32:01 am
by alex
3 Replies
1672 Views
Last post August 02, 2010, 12:18:30 am
by alex
24 Replies
3701 Views
Last post May 15, 2015, 08:11:39 pm
by alex
2 Replies
1366 Views
Last post November 26, 2015, 04:54:19 am
by junrall