Coder Social home page Coder Social logo

d0vgan / nppexec Goto Github PK

View Code? Open in Web Editor NEW
118.0 6.0 23.0 7.46 MB

NppExec (plugin for Notepad++)

License: GNU General Public License v3.0

C++ 85.03% C 8.63% HTML 2.65% CSS 0.03% Awk 0.03% Batchfile 0.31% SourcePawn 2.68% Python 0.64%
nppexec notepad-plus-plus notepad-plusplus-plugin

nppexec's Introduction

NppExec (plugin for Notepad++)

Here is some brief info about NppExec for new users:

  • NppExec adds a Console window at the bottom of Notepad++'s window; This Console window allows to run different console programs directly in it; Also there is Plugins -> NppExec -> Execute... window that allows to execute NppExec's scripts (set of commands).
  • NppExec's commands and variables are listed in the "NppExec.txt" file.
  • To get more details, type "help" (without the quotes) directly in NppExec's Console. To get a detailed help about any NppExec's command, type "help [command]" - e.g. "help npp_open" or "help set". And don't forget about Plugins -> NppExec -> Help/Manual.

Installation:

  • Just unpack the NppExec zip-archive (the last *dll*.zip under either https://github.com/d0vgan/nppexec/releases or https://sourceforge.net/projects/npp-plugins/files/NppExec/) to the folder "Notepad++\plugins". It will extract the file "NppExec.dll" as well as the "doc\NppExec" and "NppExec" subfolders (the latter one contains header files used by NppExec at runtime).
  • The only difference between the *dll*.zip and *dll*_PA.zip is the plugin folder structure. The *dll*.zip corresponds to the plugin folder structure prior to Notepad++ 7.6.x, whereas the *dll*_PA.zip follows the new plugin folder structure introduced in Notepad++ 7.6.x together with the Plugins Admin.

Note: If you see just blank pages inside the NppExec Manual or see messages similar to "This web content was blocked" or "This web page could not be shown", please follow the instructions below:

Alternatively, a web version of the NppExec Manual can be used:
https://d0vgan.github.io/nppexec/

To support NppExec development:

paypal

nppexec's People

Contributors

bjsam avatar chcg avatar d0vgan avatar david-maisonave avatar gitoffthelawn avatar rdipardo avatar sredna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nppexec's Issues

add Fluent icon for toolbar

As of Notepad++ v8.0, plugin authors need to call NPPM_ADDTOOLBARICON_FORDARKMODE instead of NPPM_ADDTOOLBARICON. (It could be done in an "if", because you can read the NPP version from a plugin; but also, I don't think it hurts to call both messages, so just running both all the time should work as well... though I'm not a plugin developer, so it would be best to confirm that)

modify selected text and save to file

I know that sel_saveto will save the selected text to target file, but how to modify the selected text such as add one blank line then save to target file?

Instructions Not Clear

I extracted the files and then moved the NppExec folder into \Notepadd++\Plugins.
There is no .dll files and nothing has changed in notepad++ when I open.

Scintilla Annotations

Scintilla Documentation
https://www.scintilla.org/ScintillaDoc.html#Annotations

SCI_ANNOTATIONSETTEXT(line line, const char *text)
An annotation may consist of multiple lines separated by '\n'.

A want to add an annotation with multiple lines. The documentation says this works with '\n'. When i use this with 'sci_sendmsg SCI_ANNOTATIONSETTEXT' it doesn't work. It writes the '\n' as chars to the annotation.

Extra internalID being reserved without a function?

Thank you for the v0.7 release. Overall, it looks great.

I noticed that my keyboard shortcut for a NppExec macro no longer worked.

To get it to work, in Notepad++'s shortcuts.xml, I had to change:

<PluginCommand moduleName="NppExec.dll" internalID="22" Ctrl="yes" Alt="no" Shift="yes" Key="50" />

to:

<PluginCommand moduleName="NppExec.dll" internalID="23" Ctrl="yes" Alt="no" Shift="yes" Key="50" />

Simple enough. But note that in Notepad++'s Shortcut Mapper UI, there is now a blank line for NppExec after Help/About. Is this a little bug, or is it intentional? It's like NppExec is reserving an extra internalID that it is not using.

[Enhancement] NppExec error browsing on secondary view

Actually, when browsing for errors listed in the NppExec console output, these are shown in the primary view by default.

I think an option should be added so that when activating one of the listed errors, then a secondary view appears pointing to the same line as reported by the error. Moreover, clicking on each of those errors should still open the related files to the second view, without touching the primary one. If a document is already opened in the primary view, it should then be cloned into the secondary one.

Why this could be useful?

I created a script which shows me the definition of a function given its name. It would be cool to still maintain the focus on the current document I'm currently editing in the first view, while opening these found definition in the secondary view. So, this enhancement would really improve focus.

[Enhancement] Better handling of error navigation in case of multiple NppExec consoles

Let's suppose a situation as follows:

  • ConsoleA active and shown

  • ConsoleB active but hidden in the panels stack

  • HotkeyA: display next/previous error for ConsoleA

  • HotkeyB: display next/previous error for ConsoleB

If I press HotkeyB, then I can actually navigate the errors in the code, but ConsoleB stays hidden. It would be cool to automatically show ConsoleB when activating HotkeyB. Then, once ConsoleB is active, activating HotkeyA should lead to displaying ConsoleA.

How to avoid control process is still running

Hi,
I start a NPPEXEC session as follow:

NPP_SAVE
cd $(CURRENT_DIRECTORY) ## Which is different than TEST_FILE directory
SET TEST_FILE = "G:\PyRevitRun\Test\PyRevitTest.py"
C:\Run\IronPython.2.7.9\net45\ipyw.exe -X:Frames $(TEST_FILE)

It show the dialog and i must to send QUIT() or EXIT() in order to end process which also completely close notepad++ Capature_Screen
I tried to run it directly from its own folder and it run well

NPP_SAVE
cd $(CURRENT_DIRECTORY)  # "G:\PyRevitRun\Test\"
C:\Run\IronPython.2.7.9\net45\ipyw.exe -X:Frames $(FULL_CURRENT_PATH) # "G:\PyRevitRun\Test\PyRevitTest.py"

both cmd and powershell console are ok

cmd: C:\Run\IronPython.2.7.9\net45\ipyw.exe -X:Frames -u "G:\PyRevitRun\Test\PyRevitTest.py"
ps: C:\Run\IronPython.2.7.9\net45\ipyw.exe -X:Frames -u "G:\PyRevitRun\Test\PyRevitTest.py"

Just wonder how to avoid this dialog to continue using NPPEXEC - a really great stuff which mostly reliable in my daily coding
thanks

Integrating NppExec with Notepad++ macros

Hi! Thank you for the powerful extension.

Is it possible to call a Notepad++ macro from an NppExec script?

If not, what about the other way around, calling an NppExec script from a Notepad++ macro?

Help Manual displays empty window on right side (ver. 0.7.1)

I just upgraded NppExec from 0.6.2 to 0.7.1, and when I selected Help/Manual from the menu, it displayed a help file with the left side Contents column populated, but the main window on the right was empty.

To troubleshoot the issue, I open the NppExec_Manual.chm file directly via Windows file explorer, and from there it displayed correctly.
After that, I tried it from the menu again, and it displayed correctly, with the main window show first page of the manual.
I also restarted Notepad++, and I couldn't reproduce the issue.

I'm not sure if this is an issue that only occurs on the first time, or if this is an issue that occurs until opening the file from windows file explorer.

I suspect the code is opening the file without setting the current directory to the file location.

[Enhancement] Option to specify the name/extension of the file containing NppExec scripts

Actually, the file containing the NppExec scripts is:

npes_saved.txt

Adding an option to specify at least the extension of that file would have two big consequences if editing that file inside Notepad++:

  1. Automatic syntax scheme: Notepad++ would automatically recognize the syntax for the NppExec script file based on its extension.
  2. Ability to parse the script file: many parsers exist (SourceCookifier, etc.) and adding a custom extension to the NppExec script file would permit those parsers to enable the correct parsing set according to the file extension. Useful for example for browsing labels, functions, variables etc.

Txt extension is too generic and by specifying a custom extension, the benefits listed above would be guaranteed.

Another really simple option could be replacing the npes_saved.txt format with a new one such as npes_saved.npe.

toolbar icon hover-text

right now, the toolbar icon hover text is "Show console". There are many plugins with a "console" of some sort, so it would be nice if the hover text were "Show NppExec Console".

[Bug] Can't detect paths which include '%20' strings

I'm running a check against an XML file through NppExec. My console output filter is configured as follows::

set Red1 = file:///%ABSFILE%:%LINE%.*

This is the generated command output:

image

The issue is due to the fact that error navigation doesn't work supposedly because the path includes the '%20' substrings, thus it is not recognized:

image

Better folder organization.

Hello,

I noticed that the doc folder doesn't have a folder of its own, it should be doc\NppExec

This is how it is with PythonScript, it has its own documentation folder in the doc folder in the np++ directory.

I would like to see this implemented please.

Also, I noticed that there is a seperate NppExec folder here with 4 different .h files. Where do these files go? I simply copy pasted the whole folder into the plugins folder, the .dll was copy pasted into the same folder too. Please confirm this is the correct way to install it.

I just want users to have an easier time with their installations, for this reason I would like to ask you to include something like a readme file.

Maybe even make something like an installer! (if you can)

thanks for putting the project on github, looking forward to next releases!

enhancement request -- Allow file type association with [Menu items]

Can an option be added to the Advanced Options window which would let users optionally add a file association with the submenu item.
NppExecAdvancedOptionsMenuItems_AddedField
And then add logic to the execute script code so that if the current document file type has an associated submenu item, it will run that script.

This will make it easy to press the same shortcut key to execute a script no matter what file type the users switch to.

With that same logic, I would like to add a default script, having type *.*, where the default script will be used if it can't find any file associations.

Works only if file has no spaces

*Forgive me if this isn't the right place for this

This command works if the file path/name does not contain spaces but it fails if spaces exist.

NPP_RUN PowerShell start-process PowerShell -ArgumentList '-ExecutionPolicy Unrestricted -File "$(FULL_CURRENT_PATH)"'

The reason I think this might be a bug is that the command works fine from powershell with or without spaces in the file path/name.

If I'm wrong and this isn't a bug and there is a way to make it work with spaces please share.

Here's my complete script:
NPP_CONSOLE ?
NPP_SAVE
IF $(EXT_PART) = .ps1
NPP_RUN PowerShell start-process PowerShell -ArgumentList '-ExecutionPolicy Unrestricted -File "$(FULL_CURRENT_PATH)"'
ELSE IF $(EXT_PART) = .bat
NPP_RUN cmd /C "$(FULL_CURRENT_PATH)"
ELSE IF $(EXT_PART) = .cmd
NPP_RUN cmd /C "$(FULL_CURRENT_PATH)"
ELSE
MESSAGEBOX "File type has not been configured in NppExec's 'Run' script" : "NppExec: Run - Unknown File Type" : 1
ENDIF

.bat files can't be invoked without extension

My version: nppExec 0.6 RC2

I have a bunch of .bat files in my %PATH%, which I would like to invoke from nppExec console.

When I execute them from cmd, of course, I don't need to mention the extension. e.g. myScript.bat can be executed in cmd like...
cmd> myScript

But, in nppExec, I need to mention the extension also...
nppExec> myScript.bat

I assure you that this behaviour can be reproduced easily.

Interestingly, for .exe files in %PATH%, nppExec can execute without needing extension.

So, can you please update the plugin so that .bat scripts can be invoked without mentioning extension? Or can this behaviour not be controlled by nppExec?

$(#N) doesn't always evaluate correctly in NppExec 0.62 DLL dated 2021.06.21

with 'START' as a local index variable across the number of files open:
echo $(#$(START)) <-- #$(START) evaluates correctly
echo #$(START) = $(#$(START)) displays ) instead of the file path of the indexed buffer

this code:

echo START=$(START)
set local foo = $(#$(START))
echo foo  = $(foo)
echo #$(START)   = $(#$(START))
echo string $(#$(START))
echo #$(START)   = $(foo)
echo $(#$(START)) <-- #$(START)
echo
echo $(#$(START))echo START=$(START)
set local foo = $(#$(START))
echo foo  = $(foo)
echo #$(START)   = $(#$(START))
echo string $(#$(START))
echo #$(START)   = $(foo)
echo $(#$(START)) <-- #$(START)
echo
echo $(#$(START))

generates:

START=4
foo  = C:\Users\mas\Documents\Lime Kiln Creek\Home Theater\media tweaks needed (2021.07.04).txt
#4   = )
string C:\Users\mas\Documents\Lime Kiln Creek\Home Theater\media tweaks needed (2021.07.04).txt
#4   = C:\Users\mas\Documents\Lime Kiln Creek\Home Theater\media tweaks needed (2021.07.04).txt
C:\Users\mas\Documents\Lime Kiln Creek\Home Theater\media tweaks needed (2021.07.04).txt <-- #4

C:\Users\mas\Documents\Lime Kiln Creek\Home Theater\media tweaks needed (2021.07.04).txt

most of the above cases were created to try to narrow down the misbehavior; only the second case evaluates incorrectly

current debug info:

Notepad++ v8.1.1   (32-bit)
Build time : Jul  1 2021 - 14:04:28
Path : C:\Programs\Notepad++\notepad++.exe
Command Line : 
Admin mode : ON
Local Conf mode : ON
Cloud Config : OFF
OS Name : Windows 7 Professional (64-bit) 
OS Build : 7601.0
Current ANSI codepage : 1252
Plugins : NppExec.dll 

full script file:
nppBuffer.zip

support for ANSI colors

I'm using ANSI colors (ANSI escape codes) rather heavily in my scripts. Running them in nppexec console results in a lot of unreadable gibberish.

I it's possible to support colors it would be great. If not, at least filter out the codes, maybe?

Sending Scintilla Messages

This is likely my result of not finding the right information (npp's docs subdomain is currently down and it seems all hints are pointing there), however...

I have what started as a macro:

<Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
<Action type="3" message="1601" wParam="0" lParam="0" sParam="Test" />
<Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
<Action type="3" message="1702" wParam="0" lParam="784" sParam="" />
<Action type="3" message="1701" wParam="0" lParam="1615" sParam="" />

... which marks in the current NPP textfile any values with "Test", and bookmarks those lines as well. FWIW, my real example includes a regex.

However, I do not want to hardcode the entire search term, with the rest collected from an input box or clipboard. My understanding is that NPP's macros can do neither.

So, in trying NppExec and failing repeatedly, I have whittled the issue down to:

set local NirCmdPath = C:\Local\App\NirCmd\nircmdc.exe
sci_sendmsg 1700 0 0
sci_sendmsg 1601 0 0 "Test"
sci_sendmsg 1625 0 2
sci_sendmsg 1702 0 784
sci_sendmsg 1701 0 1615

... which issues no errors, but also has no effect (nothing is marked in spite of the presence of "Test" and the equivalent macro working). I am not even sure if sci_sendmsg accepts a sparam aside from the help doc mentioning how to use strings when related to sci_sendmsg.

FWIW, this is a more complete version of what I was attempting (marking specific values/lines based on the second column of a pipe-delimited file):

set local NirCmdPath = C:\Local\App\NirCmd\nircmdc.exe
set ourQuote = "
set ourRegex = ^(?:(?:[^\|]*\|){1})\K
inputbox "Mark ID ..."
sci_sendmsg 1700 0 0
set ourCommand = sci_sendmsg 1601 0 0 $(ourQuote)$(ourRegex)$(INPUT)$(ourQuote)
$(OurCommand)
sci_sendmsg 1625 0 2
sci_sendmsg 1702 0 784
sci_sendmsg 1701 0 1615

Any suggestions? Many thanks.

Any way to move "Press any key to continue ..." to a new line ?

I write a c++ program.

#include<iostream>
using namespace std;
int main()
{
	cout<<"Hello World, Enter a number: ";
	int x;	
	cin>>x;
	cout<<"You entered: "<<x;
	return 0;
}

This is my script to compile and run it.

SET G++ = C:\winlibs-x86_64-posix-seh-gcc-10.3.0-llvm-11.1.0-mingw-w64-8.0.0-r1\mingw64\bin\g++.exe
NPP_SAVE // save current file
cd $(CURRENT_DIRECTORY) // go to directory of the current file
"$(G++)" -Wall -std=c++17 -o "$(NAME_PART)" "$(FILE_NAME)"
if $(EXITCODE) != 0 goto Done
NPP_RUN cmd /C "$(NAME_PART)" && pause
:Done

So when I execute this script and after the complete execution of program, I get this type of window:

nppexec

Is there any way to move Press any key to continue... to new line after end of program like in dev-c++:

Hello World, Enter a number: 45
You entered: 45
--------------------------------
Process exited after 2.453 seconds with return value 0
Press any key to continue . . .

Processing of IF statements fails under certain circumstances

Description

Processing of IF statements fail with an error message, when the left hand value of the comparison operator is a string that contains the " sign.

Steps to Reproduce

In one of my scripts there is the line

if "$(CLIPBOARD_TEXT)" != "" goto :SHOW_RESULT

If the clipboard contains text which contains a " sign (for example This is a "testing" text), I get an error message:

; executing: IF "This is a "testing" text
" != "" goto :SHOW_RESULT
- Syntax error in the if-condition.
To prevent unpredictable behavior, the script is stopped.

If I change the line to

if "" != "$(CLIPBOARD_TEXT)" goto :SHOW_RESULT

the statement is processed without an error.

Additional Info

Previous versions of NppExec were able to process this line without any error. Could be related to

changed: now NppExec supports quoted strings in the form of "abc", 'abc' and `abc`.

Applies to

NppExec v0.7
Notepad++ v8.1.2

[Enhancement] Auto expand editor code tree when navigating through clickable NppExec console lines

Let's suppose a clickable line is reported in NppExec console window.

If this line belongs to a collapsed section of code opened in Notepad++, then by activating it through the console, the editor cursor disappears as if it was placed inside the collapsed section of code, and no expanded line is shown in the editor.

It would be a good idea to add an option so that when a clickable line is reported in the NppExec console window, clicking on it would automatically expand the associated line code if collapsed, by finally placing the cursor in the proper line/column position.

Win32 'WriteConsole' doesn't output any text

Notepad++: v8.1.4 (64 bit)
NppExec: v0.7
Compiler: gcc.exe (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0

Hello! I was trying out some Win32 functions in C, when I found out that WriteConsole doesn't work on the "NppExec Console". However, both Command Line and Powershell show the output from the executable.

A fix may not be totally necessary, since a workaround npp_exec $(NAME_PART).exe is present and could be adjusted to my preference, but it would be nice if this was acknowledged, and I would like to learn your perspective on this.

My snippet of C code:

#include <windows.h>

int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, PSTR cmdline, int cmdshow)
{
	// Get command line arguments
	char *args = GetCommandLine();
	
	// Get output handle and other stuff
	HANDLE HStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
	long unsigned int *IndexStdOut = 0;
	
	// Output 'hello world' string
	if (HStdOut != NULL && HStdOut != INVALID_HANDLE_VALUE)
	{
		WriteConsole(HStdOut, args,          strlen(args),          IndexStdOut, NULL);
		WriteConsole(HStdOut, "\n",          1,                     IndexStdOut, NULL);
		WriteConsole(HStdOut, "Hello World", strlen("Hello World"), IndexStdOut, NULL);
	}
	
    return 0;
}

My NppExec script:

npp_save
cd $(CURRENT_DIRECTORY)
gcc -Wall -O3 -std=c99 -s "$(FILE_NAME)" -o "$(NAME_PART).exe"
$(NAME_PART).exe

Screenshots:
image
image

Can't launch PyQt5 via nppexec

The .py file is using PyQt5, code below:

#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
ZetCode PyQt5 tutorial 

In this example, we create a simple
window in PyQt5.

Author: Jan Bodnar
Website: zetcode.com 
Last edited: August 2017
"""

import sys
from PyQt5.QtWidgets import QApplication, QWidget

if __name__ == '__main__':
    
    app = QApplication(sys.argv)

    w = QWidget()
    w.resize(250, 150)
    w.move(300, 300)
    w.setWindowTitle('Simple')
    w.show()
    
    sys.exit(app.exec_())

Nppexec commands below:

NPP_SAVE
CD $(CURRENT_DIRECTORY)
SET python = D:\Program Files (x86)\Python36-32\python.exe
"$(python)" -u "$(FULL_CURRENT_PATH)"
UNSET python

The console shows program is start,
but PyQt5 GUI is NOT launched

assigned keycodes for user scripts shifts up by one

NppExec 0.62 test release (2021.06.20 13:59) (I reference this as 0.62.1 in my testing)

Notepad++ v8.1 (32-bit)
Build time : Jun 17 2021 - 01:52:11
Path : C:\Programs\Notepad++\notepad++.exe
Command Line :
Admin mode : ON
Local Conf mode : ON
Cloud Config : OFF
OS Name : Windows 7 Professional (64-bit)
OS Build : 7601.0
Current ANSI codepage : 1252
Plugins : NppExec.dll

All my configured keycodes for NppExec scripts (as shown in the bottom of the NppExec plugin menu) end up shifted up by one position. Please see the two attached captures: "NppExec 0.62 plugin menu.jpg" is the correct and working version using the dll released on 2021.02.25 11:44 while "NppExec 0.62.1 plugin menu.jpg" shows the resulting 'shift up by one' using the release dated 2021.06.20 13:59. The scripts still work if invoked from the console or the now incorrectly mapped keycodes.

NppExec 0 62 plugin menu
NppExec 0 62 1 plugin menu

Syntax highlighting for NppExec script code

I'm a heavy user of your plugin, so at first I want to say thank you for this useful piece of software.

I created a UDL to add syntax highlighting of NppExec script code, see this Gist. Feel free to use, link to or even distribute it with your plugin.

However, syntax highlighting would be better if it would be possible to precede the target label after a goto command with a colon.

For example, instead of writing

goto Label

it would be nice to be able to write

goto :Label

This way :Label would be highlighted the same way like the target label itself which would enhance code readability.

So, I would like to make a feature request, to be able to write goto Label or goto :Label. Please note: Setting the standard colors of the UDL to the same colors like labels is not an option, because this would also affect literal strings.

Here is a screenshot of a syntax-highlighted NppExec script using my UDL file. Missing highlighting of target labels is emphasized.

grafik

Folder as Workspace

In notepad++ there is very usefull feature - Folder as Workspace. Notepad can show file tree with root in your folder, and you can open any file in it. Usually project build files stored in root folder or in some known location relative project root, but it seems NppExec knows nothing about it, that is why I cannot reference this workspace root in my scripts.
I think it will be very good feature to have this folder in some environment variable

[Enhancement] Prevent NppExec console from appending the '=== READY ===' info

Hi, I've tried most if not all of the NppExec console commands, but I still haven't found a way to prevent the console from appending the following string at the end of each script's execution:

================ READY ================

What I'd like to do is maintain the console output resulting from a previous command, without appending the string in question when each subsequent command is executed. Would that be a possible thing to do?

[Pull Request] Regex logic to handle errors and warnings displayed on console

I created pull request #51, to add the Regex logic.
I tested it on 18 languages by creating Hello World source files with errors.
If you like to test it, I have the source file in this zip file. BadHelloWorld.zip

I used the following NppExec script to test each file:

// * Run any file base on the file extension type
//    ** If script file, run it (using *[Run Handler]*)
//    ** If source code, compile and run
//    ** If Unknown type display a message or modifty this script to perform some other default behavior
//    ** If needed, add additional if conditions for other file types, and the desired execution behavior

// *** Saving current file  *******************************
NPP_SAVE
// *** Turn off internal messages
npe_console local m- --

// *** Option: Set to 1 to turn on console logging which is saved in $(CURRENT_DIRECTORY)
set NppExecConsoleLogging=0

 // ToDo: For non-default installations, modify below paths to match your COMPILER or LANGUAGE RUNNER installation
// *** Compilers  *******************************
// set CppCompilerPath=C:\DMC\dm\bin
// set CppCompiler="$(CppCompilerPath)\dmc.exe"
set CppCompilerPath=C:\MinGW\bin
set CppCompiler="$(CppCompilerPath)\g++.exe"
set C_Compiler="$(CppCompilerPath)\gcc.exe"
set FortranCompiler="$(CppCompilerPath)\gfortran.exe"
set AdaCompiler="$(CppCompilerPath)\xx.exe"
set ObjC_Compiler="$(CppCompilerPath)\gcc.exe"
set CSharpCompiler="C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc"
set VbCompiler="C:\Program Files (x86)\Microsoft Visual Studio\Shared\Packages\Microsoft.Net.Compilers.2.6.1\tools\vbc.exe"
set JavaCompiler="C:\Program Files\Java\jdk1.8.0_202\bin\javac.exe"
set D_CompilerPath=C:\D\dmd2\windows\bin64
set MimPath=C:\Nim\bin

// *** Language Runners  *******************************
set JavaRunner="C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe"
set AwkRunner="C:\Program Files (x86)\GnuWin32\bin\gawk.exe"
set AutoItRunner="C:\Program Files (x86)\AutoIt3\AutoIt3.exe"
set AutoHotKeyRunner="C:\Program Files\AutoHotkey\AutoHotkey.exe"
set R_Runner="C:\Program Files\R\R-4.1.1\bin\x64\Rscript.exe"
set RubyRunner="C:\Ruby30-x64\bin\Ruby.exe"
set RubyWRunner="C:\Ruby30-x64\bin\RubyW.exe"
set LuaRunnerX86="C:\Program Files (x86)\Lua\5.1\lua.exe"
set LuaRunnerX64="C:\Program Files\Lua\lua54.exe"

// *** Set common variables  *******************************
set local ext ~ strlower $(EXT_PART)
set obj =$(CURRENT_DIRECTORY)\$(NAME_PART)
set CompiledBinary=$(obj).exe
set ExecuteBinary="$(CompiledBinary)"
set CompileIt =""
set PostCompile =Echo Compile Success
set NameOfItemToRun =$(NAME_PART)$(EXT_PART)

if $(ext) == .cmd
	cmd /c if not exist "$(CURRENT_DIRECTORY)\$(NAME_PART).cmd" exit 1
	if $(EXITCODE) == 0
		cmd /c $(CURRENT_DIRECTORY)\$(NAME_PART).cmd
		goto :ShowRunStatusResults
	endif
endif
cmd /c if not exist "$(CURRENT_DIRECTORY)\BuildProject.cmd" exit 1
if $(EXITCODE) == 0
	cmd /c $(CURRENT_DIRECTORY)\BuildProject.cmd
	goto :ShowRunStatusResults
endif
cmd /c if not exist "$(CURRENT_DIRECTORY)\..\BuildProject.cmd" exit 1
if $(EXITCODE) == 0
	cmd /c $(CURRENT_DIRECTORY)\..\BuildProject.cmd
	goto :ShowRunStatusResults
endif
cmd /c if not exist "$(CURRENT_DIRECTORY)\..\..\BuildProject.cmd" exit 1
if $(EXITCODE) == 0
	cmd /c $(CURRENT_DIRECTORY)\..\..\BuildProject.cmd
	goto :ShowRunStatusResults
endif

// ToDo: If your script file type is not listed below, create a new *[Run Handler]* by appending a new "else if" block specifying how to handle it.
// *** Common script file types *[Run Handler]*  *******************************
if $(ext) == .awk
	$(AwkRunner) -f "$(FULL_CURRENT_PATH)"
else if $(ext) == .au3
	$(AutoItRunner) "$(FULL_CURRENT_PATH)"
else if $(ext) == .ahk
	$(AutoHotKeyRunner) "$(FULL_CURRENT_PATH)"
else if $(ext) == .bat
	cmd /c ("$(FULL_CURRENT_PATH)")
else if $(ext) == .cmd
	cmd /c ("$(FULL_CURRENT_PATH)")
else if $(ext) == .go
	C:\Program Files\Go\bin\go.exe run "$(FULL_CURRENT_PATH)"
else if $(ext) == .py
	python "$(FULL_CURRENT_PATH)"
else if $(ext) == .pyw
	pythonw "$(FULL_CURRENT_PATH)"
else if $(ext) == .ps1
	powershell -executionpolicy bypass -File "$(FULL_CURRENT_PATH)"
else if $(ext) == .r
	$(R_Runner) "$(FULL_CURRENT_PATH)"
else if $(ext) == .rb
	$(RubyRunner) "$(FULL_CURRENT_PATH)"
else if $(ext) == .rbw
	$(RubyWRunner) "$(FULL_CURRENT_PATH)"
else if $(ext) == .lua
	cmd /c if not exist $(LuaRunnerX64) exit 1
	if $(EXITCODE) == 0
		$(LuaRunnerX64) "$(FULL_CURRENT_PATH)"
	else
		$(LuaRunnerX86) "$(FULL_CURRENT_PATH)"
	endif
else if $(ext) == .inputrc
	NPP_RUN cmd 
else if $(ext) == .vbs
	echo "*** Using CScript to get output to NppExec console window ***"
	cscript.exe "$(FULL_CURRENT_PATH)"
else if $(ext) == .js
	node "$(FULL_CURRENT_PATH)"
else if $(ext) == .php
	php "$(FULL_CURRENT_PATH)"

// *** Common source code file types needing to be compiled before running associated binaries  *******************************
else if $(ext) == .cs
	set CompileIt =$(CSharpCompiler) "$(FULL_CURRENT_PATH)"
	goto :CompileAndExecute
else if $(ext) == .vb
	set CompileIt =$(VbCompiler) "$(FULL_CURRENT_PATH)"
	goto :CompileAndExecute
else if $(ext) == .c
	env_set local PATH = $(path);$(CppCompilerPath);
	set CompileIt =$(C_Compiler) -c  "$(FULL_CURRENT_PATH)"
	set PostCompile =$(C_Compiler) "$(obj).o" -o "$(CompiledBinary)"
	goto :CompileAndExecute
else if $(ext) == .cpp
	env_set local PATH = $(path);$(CppCompilerPath);
	set CompileIt =$(CppCompiler) -c  "$(FULL_CURRENT_PATH)"
	set PostCompile =$(CppCompiler) "$(obj).o" -o "$(CompiledBinary)"
	goto :CompileAndExecute
else if $(ext) == .d
	env_set local PATH = $(path);$(D_CompilerPath);
	set CompileIt =$(D_CompilerPath)\dmd.exe -i -run "$(FULL_CURRENT_PATH)"
	goto :CompileAndExecute
else if $(ext) == .nim
	env_set local PATH = $(path);$(MimPath);
	set CompileIt =$(MimPath)\nim c --verbosity:0 "$(FULL_CURRENT_PATH)"
	goto :CompileAndExecute
else if $(ext) == .f90
	env_set local PATH = $(path);$(CppCompilerPath);
	set CompileIt =$(FortranCompiler)  "$(FULL_CURRENT_PATH)" -o $(NAME_PART)
	goto :CompileAndExecute
else if $(ext) == .java
	set CompileIt =$(JavaCompiler) "$(FULL_CURRENT_PATH)"
	set ExecuteBinary=$(JavaRunner) $(NAME_PART)
	set CompiledBinary=$(NAME_PART).class
	goto :CompileAndExecute
else if $(ext) == .m
	env_set local PATH = $(path);$(CppCompilerPath);$(CppCompilerPath)\include;
	set CompileIt =$(ObjC_Compiler)  -I"c:/GNUstep/GNUstep/System/Library/Headers" -L "c:/GNUstep/GNUstep/System/Library/Libraries" -o $(NAME_PART) "$(FULL_CURRENT_PATH)" -lobjc -lgnustep-base -fconstant-string-class=NSConstantString
	set CompileIt =$(ObjC_Compiler)  `gnustep-config --objc-flags` -o $(NAME_PART) "$(FULL_CURRENT_PATH)" -L /GNUstep/System/Library/Libraries -lobjc -lgnustep-base
	set CompileIt =$(ObjC_Compiler)  --objc-gc -Wall -Werror -g -v "$(FULL_CURRENT_PATH)" -lobjc -o $(NAME_PART)
	goto :CompileAndExecute
else if $(ext) == .objc
	env_set local PATH = $(path);$(CppCompilerPath);
	set CompileIt =$(CppCompiler) -c 
	set PostCompile =$(CppCompiler) "$(obj).o" -o "$(CompiledBinary)"

	// --------------------------------------------------------------------------------------
	// ToDo: ********** If needed, append your new *[Run Handler]* HERE by adding another "else if" block to handle your file extension type. **********
	// --------------------------------------------------------------------------------------
	// Example #1 *[Run Handler]* for files with extension .foo, where MyFooScriptRunner.exe is an executable that knows what to do with (.foo) files.
	else if $(ext) == .foo
	MyFooScriptRunner.exe "$(FULL_CURRENT_PATH)"
	// --------------------------------------------------------------------------------------
	// Example #2 *[Run Handler]* for files with extension .foobar, where DOS knows how to handle (.foobar) files.
	else if $(ext) == .foobar
	cmd /c  "$(FULL_CURRENT_PATH)"
	// --------------------------------------------------------------------------------------
	// Example #3 *[Run Handler]* for files with extension .axter, that is compiled by "a++.exe" which is stored in folder "C:\Program Files\axter". The binary created is of type (*.exe)
	else if $(ext) == .axter
	// Add the compiler folder to PATH so (if needed) it can access other associated binaries in order to compile or link
	env_set local PATH = $(path);"C:\Program Files\axter";
	// Set the compile command so the common handler knows how to compile the file
	set CompileIt ="C:\Program Files\axter\a++.exe" "$(FULL_CURRENT_PATH)"
	// Call the common handler which will compile and then execute the newly created *.exe file.
	goto :CompileAndExecute
	// --------------------------------------------------------------------------------------
	//  Note: 
	//			If binary created is NOT *.exe type, reset CompiledBinary to appropriate binary name.
	//			If compiler has a link phase, use PostCompile to set link details
	// --------------------------------------------------------------------------------------
	// --------------------------------------------------------------------------------------

// *** None of the if conditions were able to handle the file type, so notify user with a warning  *******************************
else
	// If needed, replace the following line with desired default behavior
	set local msg ~ strunescape Warning: Unknown file type!\t[$(EXT_PART)]\nAdd file extension handler to NppExec script.
	messagebox `$(msg)` : "File Type Warning" : warn
	// Example alternate default behavior
	// cmd /c "$(FULL_CURRENT_PATH)"
endif

// *** Show if successful run
:ShowRunStatusResults
if $(EXITCODE) == 0
	echo =============== SUCCESS =============== ===============
	echo **********  Success running $(NameOfItemToRun) **********
else
	echo ============ Run ERROR! =============== ===============
	echo !!!! Error: $(NameOfItemToRun) failed with error: $(EXITCODE) !!!!
	echo $(FULL_CURRENT_PATH) : 1
endif
goto :END

// *** Common Compile handler wrapper  *******************************
:CompileAndExecute
echo Compiling '$(NAME_PART)' to create '$(CompiledBinary)'
echo $(CompileIt) 
$(CompileIt)
if $(EXITCODE) == 0
	$(PostCompile)
	if $(EXITCODE) == 0
		set NameOfItemToRun=$(CompiledBinary)
		echo Running $(ExecuteBinary) ...
		cmd /C if exist "$(CompiledBinary)" $(ExecuteBinary)
		goto :ShowRunStatusResults
	else
		echo =========== Link ERROR! =============== ===============
		echo !!!! Error: Linker error $(FULL_CURRENT_PATH) with error: $(EXITCODE) !!!!
		echo Linker Command=$(PostCompile)
	endif
else
	echo ======== Compile ERROR! =============== ===============
	echo !!!! Error: Failed to compile $(FULL_CURRENT_PATH) with error: $(EXITCODE) !!!!
	echo Compiler Command=$(CompileIt)
endif
:END

if $(NppExecConsoleLogging) == 1
	con_save $(CURRENT_DIRECTORY)\LoggingNppExecuteConsole.tmp
	cmd /c echo ************************************************************************************************************************************************************************************>>$(CURRENT_DIRECTORY)\LoggingNppExecuteConsole.log
	cmd /c echo ***>>$(CURRENT_DIRECTORY)\LoggingNppExecuteConsole.log
	cmd /c type $(CURRENT_DIRECTORY)\LoggingNppExecuteConsole.tmp >> $(CURRENT_DIRECTORY)\LoggingNppExecuteConsole.log
endif
echo ===================================== ===============

Let me know if you have any questions.

INPUTBOX close effect

I was expecting that when the INPUTBOX dialog was closed, the $(INPUT) variable would be an empty string but it rather contains the previously OK'd string. If this behavior is preferred, then there should be a way to detect whether the user action was OK or CANCEL in order for the executing script to know how to proceed.

[Feature request] Make the "======= READY =======" message editable

When I found ot that NppExec had added the feature to deactivate the ======= READY ======= message I was happy, I always tought that that message is a bit cumbersome. But, after deactivating it, I found out that, without a clear indication of when a process/command ends, the experience can become a lot more confusing. Wouldn't it be better if ======= READY ======= was just a default and everyone could set their own personalized "READY" messages? Like the editable prompts that a lot of modern shells feature. Bonus points if there isn't necessarily a forced newline at the end, or, even better, if variable sostitution is supported.

[Enhancement] Automatic line centering during NppExec console error browsing

Scintilla editor provides a command so that it is possible to vertically centre the active line on the screen. It is called SCI_VERTICALCENTRECARET.

It would be very cool to add an option so that when browsing for NppExec error, the activated error line is automatically centred on the screen.

Very often it happens that the highlighted line is placed at the very bottom of the screen once activated, and this makes error navigation not very user-friendly.

Date field

Hello,

I want to suggest the implementation of a "date" variable.
This would be very handy.

Is there a way to achieve this currently?

NppExecScript echo newline, npe_cmdalias, con_colour, and con_filter

1. In my NppExec script, I'm trying to do a single echo with new line, but I can't seem to get it to work.

The reason I need to use a single echo, is because I'm setting a npe_cmdalias key, in which I want it to list the available commands for the script.
Here's an example:
npe_cmdalias ? =echo Console-shortcuts\nR=Run Script\ns=shows all local variables\nh=show NppExec console commands\n!=Show all console commands in detail
In a normal DOS console the following two methods works for producing new lines in a single echo:

echo Method 1
echo R=Run cmd /c ("E:\_Dev\Scripts\NppTest\_WorkingScripts_\ValidScripts\HelloWorld.cmd")&echo\ run=Run cmd /c ("E:\_Dev\Scripts\NppTest\_WorkingScripts_\ValidScripts\HelloWorld.cmd")&echo\ h=show NppExec console commands&echo\ !=Show all console commands in detail

echo Method 2
setlocal EnableDelayedExpansion
(
set \n=^
%=Don't remove this line=%
)
echo R=Run cmd /c ("E:\_Dev\Scripts\NppTest\_WorkingScripts_\ValidScripts\HelloWorld.cmd");!\n! run=Run cmd /c ("E:\_Dev\Scripts\NppTest\_WorkingScripts_\ValidScripts\HelloWorld.cmd");!\n! h=show NppExec console commands;!\n! !=Show all console commands in detail

I can't get any of these methods to work in the script.

  • Is there a way to include new line character in an echo for the NppExec console?

2. I created an alias for help and help all

  npe_cmdalias h =help
  npe_cmdalias ! =help all

The h command works with no problem, but when I try using !, I get the following error:
This command is not supported by the help utility. Try "all /?".

  • Is there a way to get [help all] to work with alias key?

3. Setting color to blue, before issuing the Execute command.

I put this at the top of the script:con_colour fg = 0000FF
Right before I issue the Execute command, i reset the color con_colour fg = 0
I expected that all the output before the execute command would be in blue text, but instead it's being display in green.

  • Does this setting only effect the output from the execute command?
  • If so, is there a way to change the green color from the script?

4. con_filter not working.

I prefixed the output shortcut key with "Console-shortcuts", and created a highlight for it, but it's not working.

set Highlight10 = Console-shortcuts*
set Include5 = *
con_filter +i5 +h10

But the line never gets highlighted. I even tried sending a line in a batch file with the keyword, but it still failed to highlight.

  • Am I doing something wrong?
  • How do I set the color to a specific highlight number?

Submitting Releases.

Hello. I would like to request that compiled releases for the nppexec plugin to be available in the releases tab.
Further updates can also be released here as the development progresses.

Thanks.

Causing other Notepad++ extension DLLs to get loaded twice?

After installing NppExec v0.7, I was looking at some drive access logs.

After updating to v0.7, I noticed that other Notepad++ extension DLLs were being accessed differently than before updating NppExec. They are now being read twice. The new read operations have the pathnames in all capitals, whereas the original read operations were using mixed-case.

Any chance something changed in NppExec v0.7 that could cause this?

Use of $(CURRENT_LINE) and $(CURRENT_COLUMN)

NppExec allows accessing:

$(CURRENT_LINE)  :  current line number
$(CURRENT_COLUMN)  :  current column number

Where can these be used?

I'm trying to copy all text in the current tab to a new tab without changing the position of the cursor in the current tab.

To do this, I created a regular macro that presses Ctrl+A and then Ctrl+C, then creates a new tab, and finally presses Ctrl+V.

I then created an NppExec script to store $(CURRENT_LINE) and $(CURRENT_COLUMN) and call that macro. Within the macro, I want to restore the current cursor position before creating the new tab. That way, when I choose to return to the original tab, the cursor will be at the correct position.

How can this be accomplished?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.