Macro language
-
Notepad++ is great but I really miss a macro language. I understand it would be a major change but it would have several advantages:
- the possibility for everybody to develop rich scripts with conditional logic and prompts
- a potentially higher backward compatibility with respect plugins
- the need not to depend on plugins for simple logic, that is, to reserve plugins for complicated stuff
A lot of editors have script languages. A JavaScript-like language would be great (ECMAscript standard). To make simple to create an API to Notepad++ commands, we could define a single API function to access them, for example NotepadCommand(), whose parameters would be based on a set of constants as follows:
NotepadCommand(cmd, parm1, …, parmN);
For example:
NotepadCommand(“Npp_InsertText”, “Npp_CursorPosition”, “Text to be inserted” );
to insert a text at cursor position. Any comment?
-
@Dario-de-Judicibus-0 said in Macro language:
A lot of editors have script languages
And so does Notepad++.
The one I am most familiar with is Pythonscript (it’s a plugin), but there are others.we could define a single API function to access them
NotepadCommand(“Npp_InsertText”, “Npp_CursorPosition”, “Text to be inserted” );So Pythonscript uses some objects to define an API, examples:
notepad.save(
filename)
editor.insertText(
position, text_to_insert)
-
https://github.com/notepad-plus-plus/notepad-plus-plus/issues/4028 << built-in would be perfect, but … right now you have to deal with plugins.
-
@ArkadiuszMichalski said in Macro language:
built-in would be perfect, but … right now you have to deal with plugins
Notepad++ developers aren’t going to spend their time making something inside Notepad++ that is supported (and very well supported) outside (plugin).
-
@Dario-de-Judicibus-0 said in Macro language:
A JavaScript-like language would be great (E
Checkout jN Notepad++ plugin. Can be installed from plugin admin.
-
@Alan-Kilborn I did not know of Phytonscript. It is not part of the basic package, isn’t it? Any other script language can be used with Notepad++? Where can I fond docs?
-
@Ekopalypse Great! Thank you.
-
@Ekopalypse I installed JN and I got a lot of new menu which looks like quite cryptic. I cannot find a clear documentation of available API or a User Manual. Can you give me a link to any document could help me to develop JS for Notepad++? Of course, I already know JS but I need a reference of NPP API’s. Thank you in adavnce.
-
https://github.com/sieukrem/jn-npp-plugin/wiki << just press (Pages 10) button in right site. And for API you see description:
API documentation you find in plugins/jn/API/api.xml
But I’m not sure if this api.xml still exist in actual JN version. I have old copy but can’t upload here.
jN is “specific” because add entries in Menu bar (not in Plugin menu), they cannot be accessed from other plugins, etc. By default, it adds a lot of scripts, if you do not need them, create another folder in the
NPP\plugins\jN\jN\includes
directory (e.g._off
) and put unnecessary scripts in it (or remove them). -
I got api.xml but I found really few info, just related to menus. What I am looking for are NPP API’s. For example, I want to duplicate current file, so I want to know which are the methods equivalent to
Ctrl-A
Ctrl-C
Get current name to define a new one -> newName = myOwnFuncToGenerate(currName)
Get current folder in case “follow current document” is NOT set --> currFolder
Get current language to use the same ->currLang
Ctrl-N
Ctrl-V
Set language to currLang
Save as newName in currFolderWhat I cannot find is a REFERENCE to Editor methods and similar.
-
-
In api.xml you have some commands for IEditor, you can also check existing scripts have they use this obj.
runMenuCmd(cmd)
- runs a specified build-in menu command of Notepad++. -
@ArkadiuszMichalski It looks like there is no way to get current file language and set new file to same langua. So gain, what is really missing in Notepad++ is a specific macro language. This plugin is quite cumbersome to use and badly documented.
-
@Dario-de-Judicibus-0 said in Macro language:
This plugin is quite cumbersome to use and badly documented.
Not all plugins are created equal.
You do know that plugins are not created/maintained by the same team that does Notepad++, right?So (a)gain, what is really missing in Notepad++ is a specific macro language.
I think if you try a scripting plugin that is well-done (Pythonscript, LuaScript), you’ll find that your “again” statement is “not strong”.
-
@Dario-de-Judicibus-0 said in Macro language:
It looks like there is no way to get current file language and set new file to same langua.
Editor.currentView.lang;
see, …\Notepad++\plugins\jN\jN\Doc\API\api.xml
- есть множество примеров использования плагина и вики на гитхабе.