Adding Vertical Lines
-
From reading the OP’s posting, the problem seems to be in tying a toolbar button to running a LuaScript. I’m no expert, but it seems that any time CustomizeToolbar questions come up, the end result is that that plugin is “lacking”. Doesn’t tying a keycombo to the running of the LuaScript work just as well for this?
-
I’m the author of the ExtSettings plugin. You can configure a set of vertical lines using my plugin. Then you need a scripting plugin (e.g. NppExec, LuaScript or PythonScript) to be able to send an event to the Scintilla component of the active view to toggle visibility of this set of lines.
The following example is for the NppExec plugin:
To turn on vertical lines:
sci_sendmsg 2363 3
To turn off vertical lines:sci_sendmsg 2363 1
You can store the above commands to NppExec scripts. The plugin provides the ability to create menu entries for these scripts in the
Macro
menu. Via Shortcut Mapper you can configure keyboard shortcuts to execute them. -
PeterJones, thank you so much for the working documentation links about the macros! All the links I had seen before were broken, so I assumed the whole site was dead. Seriously, thank you for all the context, this is great. It’ll take me a bit to dig through but I may be able to get something working from that. I was considering writing my own darn plugin, but I was hoping that is overkill for this use case.
Working LuaScript code:
editor.EdgeMode = EDGE_MULTILINE for i=1,10 do editor:MultiEdgeAddLine(i*8, 0xBBBBBB) end
And then I just manually change the color to 0xFFFFFF and re-run it to clear the lines. The current reason I can’t use it as a one-button solution is that the menu options presented to me are either run code from the console (so I would need a macro method of putting arbitrary text in the console which I haven’t been able to determine) or run it from the current file (which requires a macro method of loading a specific file which I haven’t been able to get working with any sort of consistency).
Dinkumoil, thank you for your ExtSettings Plugin! I was really excited when I found it, but then didn’t think about using other scripts to interface with it directly. I think your solution with the added hotkeys will work overall, I am implementing it now.
This board is fantastic, thank you all for the high quality replies!
-
the command
sci_sendmsg 2363 1
activates the standard mode of Notepad++, one single line at an arbitrary column (configurable via Preferences dialog). If you want no lines at all change the command tosci_sendmsg 2363 0
. -
For future people reading this thread, here’s a complete tutorial of how to add a set of vertical lines and turn it on/off with a click. I’m sure there’s a cleaner/better way, but at least anyone else trying to work with NASTRAN or other fixed-width files will have something to work with.
To create the lines, you will need to:
- Update to Notepad++ 7.8 or greater (you will likely have to update, it’s a relatively new feature)
- Install some plugins to Notepad
- Plugins -> Plugins Admin
- Select Check Boxes next to Customize Toolbar, ExtSettings, and NPPExec
- Click Install
- Click Yes to restart Notepad++ and Yes to accept changes to machine.
- Add vertical lines via ExtSettings
- Plugins -> ExtSettings -> Extended Settings
- In the bottom left, select a color
- Click on the black color box
- Put in 220 for Red, Green, and Blue (or whatever color you want your lines to be; this makes them a light grey)
- Click OK
- If you do not do this step you will not be able to create lines
- Enter 8 for column
- Click Add
- Enter 16 for column
- Click Add
- Continue for 24, 32, 40, 48, 56, 64, 72, 80.
- Click Close to save the ExtSettings
- You should now have your vertical lines!
You can stop here if you want, but the lines will be on at all times until you delete them in the same menu as above. Let’s add the ability to turn them on and off:
- Add the ability to turn on and off lines via NppExec
- Plugins -> NppExec -> Execute…
- Copy the following text into the box:
sci_sendmsg 2363 3
-
- Click Save…
- Enter LinesOn in the prompt
- Click Save
- Delete all the contents in the Execute… box
- Copy the following text into the box (Yes, it’s different, don’t save the same thing):
sci_sendmsg 2363 1
-
- Click Save…
- Enter LinesOff in the prompt
- Click Save
- Close the Execute… box
- Plugins -> NppExec -> Advanced Options…
- In the bottom left, under “Menu Item”, enter LinesOn
- In the “Associated Script” dropdown, select “LinesOn” script
- Click Add/Modify
- In the bottom left, under “Menu Item”, enter LinesOff
- In the “Associated Script” dropdown, select “LinesOff” script
- Click Add/Modify
- In the top left, check the box next to “Place to the Macros submenu”
- Click OK, OK
- Restart Notepad++
- This lets the new options you added in get selected as a menu item
- Create Buttons to turn the lines on and off
- Plugins -> Customize Toolbar -> Custom Buttons
- Restart Notepad++
- This enables the new buttons. See the hammer icon in the far right of the toolbar? That wasn’t there before.
- Open the file “C:\Users\YOUR_NAME_HERE\AppData\Roaming\Notepad++\plugins\config\CustomizeToolbar.btn”
- Delete all the contents and replace it with the following 2 lines:
Macro,LinesOn,,, Macro,LinesOff,,,
-
- Save the file
- Restart Notepad++ (Last time)
- Click your new LinesOn and LinesOff buttons! They are the hammer icons on the far right.
- When you click LinesOff, if you had already chosen a vertical line at some via the normal Notepad++ menu, it will still be visible.
-
@Charles-Bogel said in Adding Vertical Lines:
For future people reading this thread, here’s a complete tutorial of how to […]
Absolutely awesome! ++ thanks for taking the time to share this tutorial.
Cheers.
-
Just for completeness, latest pythonscript version does support the
newest scintilla features. -
You can assign unique icons to your toolbar buttons as well. The icons have to be in a 8 bits per pixel, 256 colors palletized BMP format with a size of 16 x16 pixels.
You can create such files by opening the icon of your choice in
*.ico
,*.bmp
or*.png
format with MS Paint, included in every version of Windows. Save them to a new file and select256 colors bitmap
as output format. Save them to e.g.%AppData%\Notepad++\plugins\config\CustomToolbarIcons
.In the file
%AppData%\Notepad++\plugins\config\CustomizeToolbar.btn
change the lines you mentioned above to:Macro,LinesOn,,,CustomToolbarIcons\LinesOn.bmp Macro,LinesOff,,,CustomToolbarIcons\LinesOff.bmp
For future readers on a non-english version of Notepad++: The part
Macro,LinesOn
andMacro,LinesOff
describe the “path” through the main menu to the menu items you would have to click to execute the related function. The names of these items have to be localized, i.e. they have to be noted in the language of your user interface. -
@PeterJones said in Adding Vertical Lines:
Unfortunately, even using
sci_sendmsg 2363 3 0 sci_sendmsg 2694 12 11184810
I didn’t see any vertical line get added
I don’t know what I was doing wrong (or maybe the color wasn’t showing up right on my remote-monitor), but now when I run those, it does work as expected.
-
I have just worked my way through this topic to add the vertical lines so I wanted to say thanks for the guidance and just to add that instead of 2 toolbar buttons (On & Off) you can have a toggle button if you use the following NPPExec script (or something like it):
NPP_CONSOLE ? sci_sendmsg 2362 if $(MSG_RESULT) = 3 then sci_sendmsg 2363 0 else sci_sendmsg 2363 3 endif