Handmade Hero»Forums»Code
4 posts
Notepad++ - Build in current cmd.exe shell
Edited by handmade_clutz on
Is there a way to run our build.bat in the current shell from inside Notepad++ so I don't have to switch between the editor and the shell, but still be look over at it and see any compile errors? I have an alias on the desktop to cmd.exe passing the /k w:\handmade\misc\shell.bat switch, and tried making a run command in NP++ like
1
C:\Users\me\Desktop\cmd.exe /k build.bat

but nothing happens. I can run a new shell and possibly set up the environment and run build.bat from there, but that's not what I want.

EDIT: Thanks to mrmixer for making me aware of the NppExec plugin available from the Plugin Manager.
Notepad++ - Build in current cmd.exe shell
https://forums.handmadehero.org/i...um?view=topic&catid=4&id=170#1052

Inside Notepad++ there is a run command. You have to run w:/handmade/code/build.bat when you wish to compile. You can bind this run command to a key combo.
27 posts
Notepad++ - Build in current cmd.exe shell
Class GenericHuman
https://forums.handmadehero.org/i...um?view=topic&catid=4&id=170#1052

Inside Notepad++ there is a run command. You have to run w:/handmade/code/build.bat when you wish to compile. You can bind this run command to a key combo.


The run command is already mapped to F5.

Another option (what I do) is to install this plugin: http://sourceforge.net/projects/nppconsole/.

This gives you a command line that can be docked right inside N++. Then you can just use that instead of a separate cmd instance so you never have to leave N++ window.
4 posts
Notepad++ - Build in current cmd.exe shell
Troncoso
The run command is already mapped to F5.

Another option (what I do) is to install this plugin: http://sourceforge.net/projects/nppconsole/.

This gives you a command line that can be docked right inside N++. Then you can just use that instead of a separate cmd instance so you never have to leave N++ window.


Thanks, doesn't look like anyone knows how to do what I originally wanted but this might work even better. I put the nppconsole.dll in the Program Files (x86)/NotePad++/plugins directory, and it loads fine, but for some reason I can't get the console to move out of the C:\Program Files (x86)\Notepad++ directory, and using the Plugins->NppConsole->"About..." menu to try to pass a \k flag to our shell.bat doesn't work, even using the real absolute path to the file and not our w:\handmade\misc\shell.bat. Also, when I exit Notepad++ it just forgets those settings. Do I need to downgrade my Notepad++ version? I'm using the latest build, but this plugin hasn't been udpated in a few years.
27 posts
Notepad++ - Build in current cmd.exe shell
I found another plugin: http://sourceforge.net/projects/npp-plugins/files/NppExec/

Which is a lot more up to date. It also allows you to set a startup script. Granted, for some reason after it runs, the cmd still doesn't recognize the cl command. I'm still trying to figure that part out...
Notepad++ - Build in current cmd.exe shell
You will most likely have to call the shell.bat inside build.bat because it is resetting the effects of vcvarsall.bat after building. This is what I do when using N++.
Simon Anciaux
1337 posts
Notepad++ - Build in current cmd.exe shell
Edited by Simon Anciaux on Reason: Spelling mistakes
I use nppexec in notepad++. You can install it via the Plugin manager.
Once it's installed you can go to the Plugin menu > nppexec > execute.
You need to set the current directory, then call the bat file.
1
2
cd w:\handmade\code\
nppBuild.bat

Save that in the window.

You can set a shortcut to execute that specific "script" in the shortcut manager, in the plugins tab (look for the name you set when saving).

My nppBuild.bat file contains this
1
2
3
@echo off
call w:\\handmade\\misc\\shell.bat
call w:\\handmade\\code\\build.bat


In the options for nppexec there is a menu named "Console output filter". In there you can configure masks that will allow you to jump to errors when you double click on them in the console (didn't find a way to set a shortcut for that, if someone figures a way to do it please share).
1
        %ABSFILE%(%LINE%)*

with colours set to 0x35, 0x76, 0xa4 for "hint" messages (don't remove the spaces at the beginning of the line).
1
%ABSFILE%(%LINE%)*error*

with colors set to 0xff, 0x00, 0x00 for errors.
1
%ABSFILE%(%LINE%)*warning*

with colours set to 0xaa, 0xaa, 0x00 for warnings.

Obviously you can choose other colours ^^.

I would recommend other plugins :
File switcher : allows to switch between opened file by pressing a shortcut and then typing the name of the file in a window.
Switcher : allows to switch between .cpp and .h files.
ScrollPastEOF : allows to scroll the document past the end of the file so you're not forced to edit at the bottom of the window.

I also like to map incremental search instead of regular search on Ctrl + F.
12 posts
None
Notepad++ - Build in current cmd.exe shell
I'm also working with notepad++ and had the same issue. I ended up using a dedicated cmd. It doesn't take much longer to change the window and execute one of the last commands. This way I didn't have to change anything. I'm also working on a vertical screen, so the cmd fits nicely below n++;

You could also get rid of the shell.bat if you add the paths from vcvarsall.bat permanently to PATH:
win + pause -> advanced system settings -> advanced -> Environment Variables -> Path
I don't know if it's good idea to set it permanent, but if you're the only one working on that machine, I don't think that's a problem.
4 posts
Notepad++ - Build in current cmd.exe shell
Edited by handmade_clutz on
mrmixer, that works great, thank you! My NppExec script wasn't showing up in the Run->Modify Shortcut menu for plugins, so I set 'Direct Execute Previous' as F5 and set Plugins->NppExec->'Save all files on execute'. Being able to build and jump to errors/warnings from inside NPP is a nice time-saver. Seems odd that it can't keep a console session alive preserving the current shell environment, guess it was just easier this way.
Simon Anciaux
1337 posts
Notepad++ - Build in current cmd.exe shell
I didn't remember but to be able to set a shortcut for a "script" you need to setup "Menu items" in the nppExec advanced options. Then they'll show up in the shortcut mapper in the plugin commands tab (not the run commands tab).
27 posts
Notepad++ - Build in current cmd.exe shell
Edited by Troncoso on
mrmixer
didn't find a way to set a shortcut for that, if someone figures a way to do it please share).


Don't know if you figured something out for this, but if you go to Plugins > NppExec > Advanced Options

You can add your script to the "Menu Items" section. After you restart, you can go into Settings > Shortcut Mapper and map that menu item to a shortcut (I did CTRL + SHIFT + B ).

Also, you can put "npp_save" at the top of the script to save the current file. I thought that was neat.

I also added a second script called "Run" that will build it and run the exe. Having that one a keyboard short is pretty convenient, too.
Simon Anciaux
1337 posts
Notepad++ - Build in current cmd.exe shell
What I meant was a shortcut to cycle throw errors instead of having to double click on lines in the console.

E.g. Pressing F6 would jump to the first error, F6 again would jump to the next error...
Simon Anciaux
1337 posts
Notepad++ - Build in current cmd.exe shell
I've modified the NppExec plugin so that you can bind keys to go to the next or previous error (based on the console output filters) and the author of the plugin added the changes in. He published the new sources on sourceforge but didn't release a build yet. So here is a build (dll) to put in the plugins folder of NPP.
Andre Bauland
12 posts
Notepad++ - Build in current cmd.exe shell
Edited by Andre Bauland on
Thats all awesome,
but can someone tell me how to get it that if you goto next error it won't open a file if it's not open already?

Edit:
Don't know why but after I wrote this it worked. :oops:
25 posts
None
Notepad++ - Build in current cmd.exe shell
This topic is gold. Thank you guys.

But just one more thing, using NppExec how can I map combo keys to run different scripts?

Let´s say:

Crtl+F6+1 saves all files and runs build.bat
Crtl+F6+2 starts the debuger

and so on...