dail8859 / SurroundSelection

Notepad++ plugin to automatically surround the selection in quotes/brackets/parenthesis
GNU General Public License v2.0
54 stars 5 forks source link

User configurable surrounding text and keyboard actions #7

Open pidgeon777 opened 5 years ago

pidgeon777 commented 5 years ago

Here is an idea I had which, in my opinion, could hugely enhance your plugin functionality.

I was thinking about adding a user settings window like the following:

 _________________ ___________ ____________ 
|                 |           |            |
| Key Combination | Left Text | Right Text |
|_________________|___________|____________|
|_________________|___________|____________|
|                 |           |            |
|    Shift + (    |     (     |      )     |
|_________________|___________|____________|
|                 |           |            |
|     Alt + "     |     "     |      "     |
|_________________|___________|____________|
|                 |           |            |
|     Ctrl + t    |   <tag>   |   </tag>   |
|_________________|___________|____________|
|                 |           |            |
|    Shift + c    |    /*     |     */     |
|_________________|___________|____________|
|                 |           |            |
|        l        |    //     |            |
|_________________|___________|____________|
|                 |           |            |
|        p        | print("   |     ");    |
|_________________|___________|____________|

by also giving a change to the user to add or remove any kind and number of Key Combinations and Text combos.

The configuration could be finally saved and loaded through an INI file.

What do you think?

pidgeon777 commented 5 years ago

I've already thought of an even better idea:

 _________________ ______________________________
|                 |                              |
| Key Combination |             Text             |
|_________________|______________________________|
|_________________|______________________________|
|                 |                              |
|    Shift + (    |            (%SEL%)           |
|_________________|______________________________|
|                 |                              |
|     Alt + "     |            "%SEL%"           |
|_________________|______________________________|
|                 |                              |
|     Ctrl + t    | <a><b>%SEL%</b>TXT %SEL%</a> |
|_________________|______________________________|
|                 |                              |
|    Shift + c    |         /* %SEL% */          |
|_________________|______________________________|
|                 |                              |
|        l        |         // %SEL%             |
|_________________|______________________________|
|                 |                              |
|        p        | printf("%SEL%: %d\n",%SEL%); |
|_________________|______________________________|

By doing so, the selection could simply be replaced with the associated text, where %SEL% (or a similar tag) would contain the original selected text.

I hope you will consider my suggestion, I think it would expand the potential of your plugin even more.

pidgeon777 commented 5 years ago

By adding the ability to handle even multiple selections (e.g. an array SEL[] of multiple selections), it would be even more awesome.

dail8859 commented 5 years ago

I know you opened this a while ago but I did see it and have given it some thought. The reason being that in some of the examples above, this plugin probably isn't the best to use. The whole reason this plugin exists is to catch keyboard input before Notepad++ gets it...that way it can capture [ before it gets inserted into the document, since these are not normal shortcuts.

Since some of the key combinations above (e.g. Ctrl+T) are a normal shortcut, this can easily be done without hooking the keyboard input. And honestly the easiest way I know of is to use LuaScript (one of my other plugins) and you can create some of these in 3 lines of code. You can also do the same thing with PythonScript. It also adds the flexibility to do things like transform the text in other ways...such as escaping HTML sequences, surrounding the text depending on language type (e.g. use print(%SEL%) for Python, and console.log(%SEL%) for JavaScript, etc).

The other thing to note...is that if the Scintilla version Notepad++ uses is ever updated, then most of the functionality of this plugin isn't needed.