Selected text
-
where did you find the Pythonscript
All the PythonScript commands are found in the Plugins > Python Script > Context-Help which is bundled with the PythonScript plugin; that menu command opens a local set of HTML files in your default web browser; in the table of contents on the left, the Notepad++ Object and Editor Object pages will be the ones you use for finding out what goes with
notepad.*
andeditor.*
I’m looking for a way to change the ‘White space symbol’
As far as I can tell, it’s not a “symbol”, per se. SCI_WHITESPACESIZE calls them “dots”. The size is 0 for invisible, or 2 when you turn on viewing whitespace. But when you change the size, using the PythonScript
editor.setWhitespaceSize(size)
command, you see that it’s likely not a symbol/character; it appears that PythonScript is drawing asize ✕ size
square – and if you setsize
bigger than about half the font height, the “dots” start blending together.So if your goal in changing the “symbol” is to make them slightly bigger, you can just use
editor.setWhitespaceSize(size)
to change the dimensions of the “dot”.Otherwise, you can use SCI_SETREPRESENTATION through
editor.setRepresentation(' ', 'SP')
, and it will change the visual display of the space character toSP
in a black box. Change the'SP'
to a string containing whatever black-boxed character(s) you’d like to see. (This is technically not part of the view-whitespace setting; however, it accomplishes the goal of changing what you see instead of the dot.) If you want to undo this change, useeditor.clearRepresentation(' ')
-
@PeterJones said in Selected text:
All the PythonScript commands are found in the Plugins > Python Script > Context-Help which is bundled with the PythonScript plugin; that menu command opens a local set of HTML files in your default web browser; in the table of contents on the left, the Notepad++ Object and Editor Object pages will be the ones you use for finding out what goes with
notepad.*
andeditor.*
I tried your suggestion , Peter :
Plugins > Python Script > Context-Helpbut instead of the PythonScript commands , I got this error-message :
Despite the error-message , the folder does exist !
So I double-clicked on file index.html in folder :
C:\Program Files\Notepad++\plugins\PythonScript\doc
and got the information you described .I’m not sure what caused the error . It could be the space in C:\Program Files… .
-
It looks like it’s building the path incorrectly, with the
c:\program files\notepad++\
portion twice in the path, which isn’t going to work.You might want to go to the PythonScript repo and report that as a minor issue.
-
May ask you how you installed PythonScript plugin and which
version you are using (either use about from the menu or the
output from the console)?
I remember seeing this strange path in an older version of PS,
but should be fixed already. -
@Ekopalypse said in Selected text:
May ask you how you installed PythonScript plugin and which
version you are using (either use about from the menu or the
output from the console)?
I remember seeing this strange path in an older version of PS,
but should be fixed already.This is how I installed Python Script :
• start Notepad++
• in menubar , click on Plugins
• in list , click on Plugins Admin…
• in list , select PythonScript
• click on Installand this is the version I’m using :
-
Thanks, yes, that is the latest stable version.
Hmm strange - I’ll have to do some tests. -
Seems to work for me.
Can you do me another favor and post your debug-info
which is available from the last menu entry, the ? menu? -
@Ekopalypse said in Selected text:
Seems to work for me.
Can you do me another favor and post your debug-info
which is available from the last menu entry, the ? menu?The requested debug-info :
-
This post is deleted! -
@PeterJones said in Selected text:
Otherwise, you can use SCI_SETREPRESENTATION through
editor.setRepresentation(' ', 'SP')
, and it will change the visual display of the space character toSP
in a black box. Change the'SP'
to a string containing whatever black-boxed character(s) you’d like to see. (This is technically not part of the view-whitespace setting; however, it accomplishes the goal of changing what you see instead of the dot.) If you want to undo this change, useeditor.clearRepresentation(' ')
Like I wrote before , I’m looking for a way to use (a small version of) the underscore as White space symbol .
In the Python Script documentation :
file:///C:/Program%20Files/Notepad++/plugins/PythonScript/doc/scintilla.html#scintilla-methodsI found 3 promising Python Script commands to achieve this :
editor.setRepresentation(encodedCharacter, representation)
editor.setWhitespaceFore(useSetting, fore)
editor.setWhitespaceBack(useSetting, back)Then I did some testing (I used ‘-’ instead of ‘_’ for testing purposes) .
Original code :
Script 1
editor.setRepresentation(’ ', ‘-’)
editor.setWhitespaceFore(1,( 64, 64, 64))
editor.setWhitespaceBack(1,(255,255,255))Result after running Script 1 :
• the first command has been executed
• the second and third have been ignoredScript 2
editor.setWhitespaceFore(1,( 64, 64, 64))
editor.setWhitespaceBack(1,(224,224,224))
editor.setRepresentation(’ ', ‘-’)Result after running Script 2:
• the first and second command have been executed .
• the third has been ignored .I’m obviously doing something wrong .
Are those commands commands mutually exclusive ? -
A bit off the trail of this thread now, but when you said:
The dots in the middle of the space-character can be a bit confusing . Changing the color of the White space symbols is not always enough .
I would rather have (a small version of) the underscore as White space symbol .My reply to that is: I don’t know if you’ll be able to achieve something for this that isn’t overwhelmingly intrusive.
I thought of maybe a “squiggle” like spell-checker plugins use for misspelled words; could be the best thing (IMO) here, but it seems like that would make knowing how many whitespace characters are there a bit difficult…
-
@Ruud-Schmeitz said in Selected text:
Are those commands commands mutually exclusive ?
Effectively, yes. Because the setWhitespaceX commands affect the dot-drawing; when you have a representation for the ASCII space character, then it is not displaying the dot-drawing, it is displaying that character in the black-box reverse-video representation. I don’t think there’s a way to manually define the black-box stylings, but I could be wrong.
As to why your script 2 was still showing the whitespace dots rather than the black-box representation, I don’t know… maybe there was a typo (since you just pasted the code in the forum, rather than using the
</>
button to mark the code as plain text, the forum changed ASCII single-quotes into “smart ‘quotes’” some of the time, and I don’t know – maybe you had a syntax error in script 2 that you didn’t notice the error message for.So, I think your choices are
- Use the representation to set the black-boxed hyphen or underscore as the display character of choice for the space character, but give up on independent control of the color
- Use the “dot” drawing with whatever colors you want, and maybe choosing a bigger size to make it slightly more like a small horizontal rectangle
- Apply the squiggle, like Alan suggested
- Rather than squiggle, maybe you could apply a normal underline feature to the normal space character – you can add extra highlighting to a builtin lexer or to a User Defined Language (UDL) using regexes via the script
EnhanceAnyLexer.py
that @Ekopalypse shares in his github repo. I am not sure, when using the “indicator” method that Ekopalypse shows, whether you can influence the underlining property of the match, but I would think so; if so, and you did a regex searching for the space character and applied that indicator, that might do what you want.
I don’t know whether any of these solutions are going to make you happy, but I think they are your best options.
-
@Alan-Kilborn said in Selected text:
My reply to that is: I don’t know if you’ll be able to achieve something for this that isn’t overwhelmingly intrusive.
You’re right , the character replacing the White space symbol shouldn’t be intrusive : that’s why I chose the underscore .
Back in the days , when you couldn’t use capitals in variable-names , the use of underscores was very common , and the result was quite readable .
For example :
new : ObjectPascalUserManual
old : object_pascal_user_manualI thought of maybe a “squiggle” like spell-checker plugins use for misspelled words; could be the best thing (IMO) here, but it seems like that would make knowing how many whitespace characters are there a bit difficult…
And again you’re right : being able to know the number of whitespaces is important . That’s why I wanted a small version of the underscore .
-
@Ruud-Schmeitz said in Selected text:
Back in the (old) days … old : object_pascal_user_manual
I guess I am trapped in the “old days” as this is still my preferred way to name things, in Python.
-
@PeterJones said in Selected text:
So, I think your choices are
- Use the representation to set the black-boxed hyphen or underscore as the display character of choice for the space character, but give up on independent control of the color
- Use the “dot” drawing with whatever colors you want, and maybe choosing a bigger size to make it slightly more like a small horizontal rectangle
- Apply the squiggle, like Alan suggested
- Rather than squiggle, maybe you could apply a normal underline feature to the normal space character – you can add extra highlighting to a builtin lexer or to a User Defined Language (UDL) using regexes via the script
EnhanceAnyLexer.py
that @Ekopalypse shares in his github repo. I am not sure, when using the “indicator” method that Ekopalypse shows, whether you can influence the underlining property of the match, but I would think so; if so, and you did a regex searching for the space character and applied that indicator, that might do what you want.
I don’t know whether any of these solutions are going to make you happy, but I think they are your best options.
Thanks for your suggestions , Peter .
I guess , I’ll have to do some more testing .
🙂 -
@PeterJones said in Selected text:
for.So, I think your choices are
- Use the representation to set the black-boxed hyphen or underscore as the display character of choice for the space character, but give up on independent control of the color
- Use the “dot” drawing with whatever colors you want, and maybe choosing a bigger size to make it slightly more like a small horizontal rectangle
(…)
I don’t know whether any of these solutions are going to make you happy, but I think they are your best options.
Using the representation , resulting in colour-boxed (not only black , also gray , magenta , red etc.) characters , is unacceptable because the result is way to intrusive .
So I’ve decided to go for this option :
editor.setWhitespaceSize(1)
editor.setWhitespaceFore(1,( 64, 64, 64))
editor.setWhitespaceBack(1,(255,255,255))I hope that makes me happy .
😀 -
Concerning the help page issue, I guess you suffer from this issue, don’t you?
-
@Ekopalypse said in Selected text:
Concerning the help page issue, I guess you suffer from this issue, don’t you?
You’re right .
My HTML-files are indeed associated with N++ , and I still get the error-message with Plugins > Python Script > Context-Help .
For testing purposes , I temporarily associated HTML-files with Edge (my default browser) , and then Plugins > Python Script > Context-Help correctly opens the PythonScript HTML help-files in Edge .
But I prefer HTML-files associated with NPP , so as a workaround , I opened file :
C:\Program Files\Notepad++\plugins\PythonScript\doc\index.html
in Edge , and added the opened index-file to Favorites .Because Edge is almost always open on my PCs, this works just as quick as Plugins > Python Script > Context-Help in N++ .
Perhaps even quicker ! 😄 -
@Ruud-Schmeitz said in Selected text:
So I’ve decided to go for this option :
editor.setWhitespaceSize(1)
editor.setWhitespaceFore(1,( 64, 64, 64))
editor.setWhitespaceBack(1,(255,255,255))I hope that makes me happy .
😀Actually it did not !
Selecting the 8 lines of code results in :
Because that’s not what I want , I deleted editor.setWhitespaceBack(1,(255,255,255)) in the startup.py file .
The remaining PythonScript commands :
editor.setWhitespaceSize(1)
editor.setWhitespaceFore(1,( 64, 64, 64))make the selected lines of code look like :
Now I’m happy .
😄