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

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2224
  • Karma: +37/-3
    • 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]

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, 09:18:56 PM by alex »