Problem with Margins in PythonScript Plugin and Margins in Distraction Free mode
-
@Alan-Kilborn
I’ve just read your "thread script’ that you’ve linked here. And have jumped on PythonScript basics by Peter Jones again.What I’ve found is that I’ve set Margins in Machine script “startup.py” instead of User Script. It seems I cannot make it appear as a User script. Maybe that is the problem?
Plugins > Python Script > Scripts > (Samples | startup)
Also Plugins > Python Script > Configuration > User Scripts is empty.
I don’t have any User sripts shown.
I’ve also seen this article where one guy suggested this script:
import ctypes from ctypes.wintypes import RECT FindWindow = ctypes.windll.user32.FindWindowW GetWindowRect = ctypes.windll.user32.GetWindowRect Rect = RECT() nppHandle = FindWindow(u'Notepad++', None) notepad.runMenuCommand("View", "Post-It") if GetWindowRect(nppHandle, ctypes.byref(Rect)) != 0: w = Rect.right editor.setMarginLeft(w/3) editor.setMarginRight(w/3)
Again I’ve Plugins > Python Script > New Script and pasted it there, named it and saved it in:
C:\ProgramFiles\Notepad++\plugins\Config\PythonScript\scripts folder. But again - nothing changed.I’ve again tried to access it through Plugins > Python Script > Configuration but under “User scrips” I’ve again found an empty list.
While Plugins > Python Script > Scripts > (Samples | startup) is show again. I don’t have any (user) scripts shown in there as an option. Not even grayed out.
What am I missing?
Let the adventure begin!
If you get anywhere with it, I’m sure it will be interesting, so posting back here to let others know how it went would be goodOh I will definitely post it here if I make it.
Also, is “update-ui” the only difference I’d need to change in given script or is this just a more general example to illustrate how I go about achieving desired behavior in “buffer-activated” environment ? Or whatever it is called.
-
…startup.py…
You don’t want to change any “machine” scripts (e.g. its startup.py) at all.
There’s info about getting user
startup.py
going HERE.Really, though, you don’t want to do a lot of coding in user
startup.py
, you want to keep that fairly clean and call out to separately named scripts.I’ve also seen this article where one guy suggested this script
I don’t see the relevance of that, other than it calls the margin functions you want to call…
Also, is “update-ui” the only difference I’d need to change in given script or is this just a more general example to illustrate how I go about achieving desired behavior in “buffer-activated” environment ? Or whatever it is called.
The pointer to the other script was just for showing how to do a callback function in general; nothing else about that script is relevant.
-
@Alan-Kilborn I’ve read that post from Peter Jones but, as mentioned in my last comment - nothing shows up and/or changes.
I cannot make any User script to appear in Plugins > Python Script > Scripts
I’ve read your “thread script” post and at the end of it the same thing was linked. So I’ve read it and tried to have User scripts work, but it just doesn’t appear anywhere.
The pointer to the other script was just for showing how to do a callback function in general; nothing else about that script is relevant.
Oh okay. Thanks.
-
@Neko-Nekokovic said in Problem with Margins in PythonScript Plugin and Margins in Distraction Free mode:
I cannot make any User script to appear in Plugins > Python Script > Scripts
Even if you manually create a file in the correct place?
For me, sometimes the New Script wants to save my intended new file in a weird directory, i.e., not the Scripts directory. :-(
So if it happened to do that to you, then you went to the Scripts menu, that script wouldn’t appear.So by “manually create” I mean, make a .py file without using the New Script command…
If you suspect the same kind of weird thing is happening to you, try opening one of the “Samples” scripts by holding Ctrl while clicking on it in the menus, then when it opens do a SaveAs but when saving move up one folder level, i.e., don’t save it in the “Samples” folder, but the parent of samples. And give it a new base name, e.g. “testme.py”.
Then see iftestme
appears in the Scripts menu. -
Even if you manually create a file in the correct place?
Yes. Well, this is a bit different. I’m unable to create a new text file in C:\ProgramFiles\Notepad++\plugins\Config\PythonScript\scripts
The only option I have is this
So to overcome this what I’ve managed to do is - I’ve created a text file on Desktop. Pasted python scirpt there. Saved it as a .py file. And then successfully moved it over in:
C:\ProgramFiles\Notepad++\plugins\Config\PythonScript\scriptsThat’s how “proba.py” and “startup.py” are there. Upon moving, it asked me to “Continue” with Admin rights which I have clicked.
If you suspect the same kind of weird thing is happening to you, try opening one of the “Samples” scripts by holding Ctrl while clicking on it in the menus, then when it opens do a SaveAs but when saving move up one folder level, i.e., don’t save it in the “Samples” folder, but the parent of samples. And give it a new base name, e.g. “testme.py”.
Then see if testme appears in the Scripts menu.
That worked indeed! Now I see “proba.py” listed.
But if I go Plugins > Python Script > Configuration every script that I see is under “Machine scripts” and none in “User scripts”.
-
@Alan-Kilborn The thing that I’ve found in one of the above linked posts is this. This is exactly what I’ve want and it seems that someone managed to make it that way.
Although I’d exclude numbers as well, but that is trivial.
But the thing that I don’t understand in this picture, or in that post is - A guy below said that it was a feature that was going to be available after v7.9.6 release. Do you know anything about it?
-
Oh, wait, it appears I gave bad advice. The “Samples” are considered “machine scripts”. :-(
Sorry, but I honestly don’t think about this much, because I don’t have such troubles…OK, so user scripts are under
...\Config\PythonScript\scripts
(note the important part of that is “Config”).Machine scripts are NOT under
Config
.The only option I have is this
So if “this” is a link to a screenshot, don’t do that, just Ctrl+v paste an image directly. Nobody is clicking links that aren’t immediately recognizable.
But if I go Plugins > Python Script > Configuration every script that I see is under “Machine scripts” and none in “User scripts”.
You have clicked on this, right?:
-
@Neko-Nekokovic said in Problem with Margins in PythonScript Plugin and Margins in Distraction Free mode:
The thing that I’ve found in one of the above linked posts is this. This is exactly what I’ve want and it seems that someone managed to make it that way.
Again, nobody is clicking on such a “this” link.
Paste a screenshot right into your posting.But the thing that I don’t understand in this picture, or in that post is - A guy below said that it was a feature that was going to be available after v7.9.6 release. Do you know anything about it?
I can’t answer questions deriving from links I’m not clicking on. :-)
-
So if “this” is a link to a screenshot, don’t do that, just Ctrl+v paste an image directly. Nobody is clicking links that aren’t immediately recognizable.
Ah, okay.
And that was from a post named “Is there a distraction-free writing mode like Vimroom(a plugin of Vim)?” on this website. So if you don’t want to click a link of it, you can go there and find this part.
-
You have clicked on this, right?
Yes. That’s what I meant when I said “User Scripts” is empty.
-
@Neko-Nekokovic said in Problem with Margins in PythonScript Plugin and Margins in Distraction Free mode:
And that was from a post named “Is there a distraction-free writing mode like Vimroom(a plugin of Vim)?” on this website. So if you don’t want to click a link of it, you can go there and find this part.
Or YOU could have just provided this link.
-
@Alan-Kilborn said in Problem with Margins in PythonScript Plugin and Margins in Distraction Free mode:
A guy below said that it was a feature that was going to be available after v7.9.6
That “guy” is the author of Notepad++. :-)
Turns out after reviewing that other thread that he meant “Distraction free mode” would be available…and that made it into v8.0 (there was no v7.9.6). -
Or YOU could have just provided this link.
I guess there is a misunderstanding here.
You’ve said earlier:
Again, nobody is clicking on such a “this” link.
And in the last comment you’ve said:
Or YOU could have just provided this link.
I understand that pictures should have been pasted as images, but either way you cannot know what is on the “link” no matter how I name it. You don’t know if it’s a link to a post or a link to an image. If you’re not clicking “this link” then why would I provide a link in the first place?
I guess you can have a preview when you hover over a link, but https://ibb.co/… is a popular domain as far as I know. I’ve seen it many times since many people link images from imgBB website and that is their domain. It’s quite popular so I don’t understand what was the problem.
I guess we don’t understand each other here.
That “guy” is the author of Notepad++. :-)
Ah cool.
Oh only Distraction Free mode. :/But in that post, the picture shows exactly what I want to achieve. I guess it is possible, I just don’t know how.
-
@Neko-Nekokovic said in Problem with Margins in PythonScript Plugin and Margins in Distraction Free mode:
I guess we don’t understand each other here.
I think we do…
I guess you can have a preview when you hover over a link
Yep, which is exactly how I know where links lead, no matter what they say, e.g. a blue/purple this.
but https://ibb.co/… is a popular domain as far as I know
And it is blocked by my I.T. department since it is so popular.
And since I do all of my Notepad++ work on my work PC, in my spare time at work, I can’t click on those links. Well, I can, but they won’t lead anywhere.But in that post, the picture shows exactly what I want to achieve
I think first things first…you need to get beyond problems with putting script files in user scripts folder and having them appear in the Notepad++ menus…are you beyond that?
-
@Alan-Kilborn said in Problem with Margins in PythonScript Plugin and Margins in Distraction Free mode:
I think we do…
Well we haven’t on this very issue then.And it is blocked by my I.T. department since it is so popular.
What does that mean? Which I.T. department? I don’t understand what that means. Why would a link from imgBB be banned or blocked?
Is there any other “imageToLink” website that isn’t blocked by anyone and that you would happily open even if it’s a picture in the link? What about Imgur? I’m curious now. I’ve never heard that someone blocks that website. Is there any specific reason? (Well I am sure there is, the question is rather - what is the reason behind the block?)
I think first things first…you need to get beyond problems with putting script files in user scripts folder and having them appear in the Notepad++ menus…are you beyond that?
Yeah I agree. Well, no. I’ve managed to make them appear only if I put them in “Machine Scripts”. If I save them in Config/PythonScript/scripts nothing seems to show up.
I should fix that first definitely. I hope I’ll find a way. Currently I have no idea how to overcome that.
-
@Neko-Nekokovic said in Problem with Margins in PythonScript Plugin and Margins in Distraction Free mode:
Which I.T. department?
Umm, the one where I am employed?
Why would a link from imgBB be banned or blocked?
To keep people from going there.
Is there any other “imageToLink” website that isn’t blocked by anyone and that you would happily open even if it’s a picture in the link? What about Imgur?
Imgur was used here before the forum software got the ability to directly paste images. So, yes, I could access that one.
But it is all kind of pointless, because we CAN paste here directly and there is no reason at all to user external sites for such things. -
I have not read the whole thread but from what I understand you
have Npp installed and so I assume your configuration directory
is the one in APPDATA, could that be?
If not, can you paste your debug information, which is available
from the last menu item (the ? menu
)? -
I know this is going back to the beginning, but I’ve been away for a few days.
@Neko-Nekokovic originally said,
lso is it possible that I can edit Margin values inside of Distraction Free mode? Currently the default is quite a bit “wider” than my 80 characters centered.
yes. That’s why there’s a setting for it.
On my current monitor, which could handle about 230 characters wide in true full-screen mode (View > Toggle Full Screen): if Settings > Preferences > Margins/Border/Edge > Padding > Distraction Free is at 9 (the widest), I get about 170 characters wide in Distraction Free mode, and at 3 (the narrowest), I get about 70 characters wide; and at the default 4, I get about 110 characters wide.
If that’s not enough range for you, then you will have to go through the PythonScript rigamarole, as has already been described to you.
As has been described, though I’ll phrase it differently:
C:\Program Files\Notepad++\plugins\PythonScript\scripts
is for “machine scripts”. For a standard installation, user scripts will go in the%AppData%
config directory, which is technically%AppData%\Notepad++\plugins\config\PythonScript\scripts
(which you can paste directly into Windows Explorer or the File > Save As dialog) – this will probably resolve to something likeC:\users\<your user name here>\AppData\Roaming\Notepad++\plugins\config\PythonScript\scripts
, but the infinite number of Windows conifgurations possible means this is not guaranteed – whereas just pasting in the%AppData%
-based path will work on any Windows installation I’ve used in the last couple decades. And, as @Ekopalypse said, if you are having trouble finding the user-scripts directory, using the ?-menu’s Debug Info, and copying that debug info and pasting into your reply, will tell us where your user-script location will be. -
Umm, the one where I am employed?
And where are you employed?
To keep people from going there.
Oh come on man, that’s circular.
“Why is it banned? Because people should not use it.
Why should people not use it? Because it’s banned.”Why would you want to keep someone from using imgBB or Imgur?
Imgur was used here before the forum software got the ability to directly paste images. So, yes, I could access that one.
But it is all kind of pointless, because we CAN paste here directly and there is no reason at all to user external sites for such things.It’s really not the problem to paste a picture instead of posting a hyperlink. Sure if that’s “the standard” on this forum I’ll do it. Not a big deal anyway.
But I’m curious about the reasons imgBB or imgur are advised not to be used. This is the first time I ever heard of that and I’d like to know the reasoning behind it.
-
@Ekopalypse Hi, first thanks for the comment.
I understand you have Npp installed and so I assume your configuration directory is the one in APPDATA, could that be?
No I don’t have a Configuration directory in %Appdata%/Notepad++ (neither in the parent directory, that is only %Appdata%)
If not, can you paste your debug information, which is available from the last menu item (the ? menu)?
I sure can. Here it is:
Notepad++ v8.4.4 (64-bit) Build time : Jul 15 2022 - 17:54:42 Path : C:\Program Files\Notepad++\notepad++.exe Command Line : "C:\Users\krete\Desktop\Alat\Filozof\New Text Document.txt" Admin mode : OFF Local Conf mode : OFF Cloud Config : OFF OS Name : Windows 10 Pro (64-bit) OS Version : 21H2 OS Build : 19044.2006 Current ANSI codepage : 1252
(Don’t know why there is such a big gap below the picture. I’ve tried to Edit, but I cannot make it shorter for some reason. Sorry)