Comments (9)
editor.hideLines()
is a direct-call to Scintilla's SCI_HIDELINES command.
There is nothing that PythonScript itself can/should do in this case, so this issue is misplaced.
You might want to implement notepad.runMenuCommand(IDM_VIEW_HIDELINES)
in order to get Notepad++'s involvement, i.e., the green triangles.
from pythonscript.
I guess you mean calling the latter of the following two commands:
notepad.runMenuCommand(IDM_VIEW_HIDELINES)
notepad.menuCommand(MENUCOMMAND.VIEW_HIDELINES)
I can't tell that command directly which line to hide though, but have to select that line first, right? The problem is that if the user selects something else while the script is running, then the wrong line gets hidden.
Can I somehow invoke the creation of the green rectangles or something, without requiring the to-be-hidden lines to be selected?
from pythonscript.
I can't tell that command directly which line to hide though, but have to select that line first, right?
Yes, the sequence would be, in script code, to select the lines you want to hide, and then hide them as discussed above.
The problem is that if the user selects something else while the script is running, then the wrong line gets hidden.
Hmm, I'm confused by this. The script is not "running" until you run it, so there's no possibility of overlap with user activity.
Can I somehow invoke the creation of the green rectangles or something, without requiring the to-be-hidden lines to be selected?
Not really, because you'd be using Notepad++'s hide-lines feature, and that operates on the current selection.
I suppose you could do a lot of work, and recreate manually all of the Notepad++ functionality involved in this, but, well, it would be a lot of work.
I think the "menuCommand" stuff is your best path here.
from pythonscript.
While the script is running, the user can select things in the editor. I tried.
If that happens after the script selects the line it wants to hide but before the script hides it, the script will hide the wrong line.
So after hiding the selection, the script should check whether the to-be-hidden lines are actually hidden (otherwise the user migth again select what the script had previously selected, and pass the below-mentioned check without hiding those lines), and only then check whether the selection is as the script intended (otherwise the user might have selected more lines than what the script intended to hide, not realizing that the script will hide the selection).
from pythonscript.
While the script is running, the user can select things in the editor. I tried.
I obviously don't know what you're trying to accomplish with scripting, but I suspect that you are "doing it wrong".
The paradigm for scripts is that a script should either run very fast and finish when invoked, so that any user activity with the editor wouldn't interfere, or, if the script has to take a lot of time (due to the nature of its task), the user knows (or is prompted) not to do anything editor-wise until the script is finished (maybe with a msgbox of "Done!" at its end).
So, with a properly architected script, selecting text via script command to allow another script command to act on that selection, wouldn't really be concerned with the user selecting text simultaneously.
from pythonscript.
For mature software in general, it is not normal if the user has to be told to not click, in order to prevent results that were not intended by the programmer.
I don't mind if a polished UX is beyond the scope of this plugin. In fact, all Notepad++ plugins I tried don't have a polished UX, probably because Notepad++ poses limitations on what plugins can do or how to program what they do.
from pythonscript.
For mature software in general, it is not normal if the user has to be told to not click
Which is why I have seen many websites -- including my financial websites -- give me form submission pages that tell me "please do not click SUBMIT a second time" in one form or another.
Or why Windows provides a way for applications to change the cursor to a circling hourglass, to encourage them not to click while they are doing long-duration things, during which it isn't a good idea to be clicking other buttons. Or why many applications use progress bars in modal dialogs or elsewhere while they are "processing".
BTW, you could use the Win32 API to do similar things in your script: PythonScript allows you to access the various python libraries for interfacing with the win32 API: with some effort, you could change the the cursor to the hourglass while your script is running; or you could do a dialog box with a progress bar (normally, I would suggest a modal dialog, so it doesn't allow you to interact with the Notepad++ window while it's active, which would give you what you want anyway... but in this case, since your script still wants to interact with Notepad++, it might have to be a nonmodal dialog, but just have it not have an OK/CANCEL button, so that it won't go away until your script is done -- you could play around with modal-vs-nonmodal and see if your script can still work). If you need help with how to access win32 API from within PythonScript, Notepad++ Community Forum regulars Ekopalypse, Alan, and I (PeterJones in the forum) all have examples scripts posted in the forum which access such things (search for ctypes
-- Ekopalypse has even shared a bolt-on library which makes creating fancy win32 dialogs in PythonScript easier, though it's still fully-featured).
Or if you want to avoid getting your hands dirty with win32 API, maybe you could just use notepad.setStatusBar(STATUSBARSECTION.DOCTYPE, "new text")
to overwrite the long STATUSBARSECTION.DOCTYPE -- doing multiple of those calls could make a poor-man's progress bar. Or maybe use the occasional editor.flash()
to discourage them. Or maybe try to use a SCINTILLANOTIFICATION.FOCUSIN
notification or similar, to try to hijack any of their actions where they are trying to control the focus (again, I don't know if the script you are running would also trigger those events; that's something you'd have to look into).
Or if the "critical" section of your script is just a small portion of your script, just do something unrelated to draw attention away from their making edits while your script is running briefly, and then complete your action before they have had a chance to come back to try to change the selection.
Those were just a few different ideas I had. You, as the person who knows what you do and don't like in user interfaces and as the programmer of your script and as the person who best knows the users of your script, should be able to come up with some creative way of preventing or at least dissuading the user from selecting text while your script is slowly running commands that could be messed up by the selection changing.
all Notepad++ plugins I tried don't have a polished UX
That's one opinion. I have rather liked the UI and UX for most of the plugins I use on a regular basis. If you don't, I conclude that you've either had a poor exposure to plugins, or you have different UI/UX tastes than I do.
from pythonscript.
...Notepad++ Community Forum regulars Ekopalypse, Alan, and I...
The forum alluded to is found here: https://community.notepad-plus-plus.org
from pythonscript.
Which is why I have seen many websites -- including my financial websites -- give me form submission pages that tell me "please do not click SUBMIT a second time" in one form or another.
Here are some examples of how to improve the UX: https://www.the-art-of-web.com/javascript/doublesubmit/
Or why Windows provides a way for applications to change the cursor to a circling hourglass, to encourage them not to click while they are doing long-duration things, during which it isn't a good idea to be clicking other buttons.
The hourglass indicates that the computer is doing something, and the user will receive the result in the future. Often the user wants to wait for the result and only then decide what to do next; or the result is that new actions become available (for example a game has finished loading). But the hourglass doesn't discourage some users from clicking. Some users with ADHD might even feel a strong urge to do something like clicking things which are usually harmless to click, to not get extremely bored by having to wait.
If the programmer wants clicks to do nothing, it's best to program them to do nothing, when easily possible. Then the software poses fewer risks.
Or why many applications use progress bars in modal dialogs or elsewhere while they are "processing".
The progress bar shows the progress (so the user can get some happiness hormones or learn to estimate the remaining time, if there are no advanced algorithms in place that learn that). While files are being copied with a progress bar for example, the user is allowed to do other things.
BTW, you could use the Win32 API to do similar things in your script: PythonScript allows you to access the various python libraries for interfacing with the win32 API:
Cool, thanks! :)
with some effort, you could change the the cursor to the hourglass while your script is running;
Some users might still click and thus mess up the result. That's suboptimal UX.
I'm not asking you to improve it in this case though.
or you could do a dialog box with a progress bar (normally, I would suggest a modal dialog, so it doesn't allow you to interact with the Notepad++ window while it's active, which would give you what you want anyway... but in this case, since your script still wants to interact with Notepad++, it might have to be a nonmodal dialog, but just have it not have an OK/CANCEL button, so that it won't go away until your script is done -- you could play around with modal-vs-nonmodal and see if your script can still work).
Do you happen to know whether a nonmodal dialog would prevent clicks on the text from changing the text selection?
If you need help with how to access win32 API from within PythonScript, Notepad++ Community Forum regulars Ekopalypse, Alan, and I (PeterJones in the forum) all have examples scripts posted in the forum which access such things (search for
ctypes
-- Ekopalypse has even shared a bolt-on library which makes creating fancy win32 dialogs in PythonScript easier, though it's still fully-featured).
Thanks! By the way, your and Ekopalypse's posts there recently helped me with other things, thanks! :) I didn't upvote yet because that required registration. If upvotes help, let me know.
(And Alan's post "The hide lines feature in Notepad++ is “underdeveloped”" confused me ^^)
Or if you want to avoid getting your hands dirty with win32 API, maybe you could just use
notepad.setStatusBar(STATUSBARSECTION.DOCTYPE, "new text")
to overwrite the long STATUSBARSECTION.DOCTYPE -- doing multiple of those calls could make a poor-man's progress bar. Or maybe use the occasionaleditor.flash()
to discourage them.
Do you mean flashing the editor so that the user is less likely to click it?
Or maybe try to use a
SCINTILLANOTIFICATION.FOCUSIN
notification or similar, to try to hijack any of their actions where they are trying to control the focus (again, I don't know if the script you are running would also trigger those events; that's something you'd have to look into).
Sounds interesting!
Or if the "critical" section of your script is just a small portion of your script, just do something unrelated to draw attention away from their making edits while your script is running briefly, and then complete your action before they have had a chance to come back to try to change the selection.
That would make clicks/problems less likely indeed, but not prevent them.
Those were just a few different ideas I had. You, as the person who knows what you do and don't like in user interfaces and as the programmer of your script and as the person who best knows the users of your script, should be able to come up with some creative way of preventing or at least dissuading the user from selecting text while your script is slowly running commands that could be messed up by the selection changing.
The solution in my comment above seems quite safe. I don't know how it might fail.
all Notepad++ plugins I tried don't have a polished UX
That's one opinion. I have rather liked the UI and UX for most of the plugins I use on a regular basis. If you don't, I conclude that you've either had a poor exposure to plugins, or you have different UI/UX tastes than I do.
I haven't tried a huge number of plugins yet. For the ones I tried, it seemed that their UX was heavily driven by Notepad++'s constraints on what's easy/possible to implement.
from pythonscript.
Related Issues (20)
- [Feature Request] console.show() without putting input focus in console HOT 3
- notepad.prompt() window and multiline input HOT 6
- Unicode characters in message box not displayed correctly HOT 2
- documentation error for notepad.allocateMarker() function HOT 1
- [Feat Req for Documentation] Improvements for selection-setting functions HOT 2
- Problem detecting saved/unsaved file state at startup HOT 5
- [Feat. Req.] Consider adding notepad.getNppConfigDir() HOT 1
- No access to `NPPM_ISDARKMODEENABLED` message
- getLexer and setLexer do not work HOT 14
- editor.rereplace() should not replace if data isn't going to be changed HOT 4
- Run a script and pass parameters to it from an NPP-external script / program? HOT 8
- Separate commands for opening and closing the console from the Plugin menu HOT 5
- Custom autocomplete provider. HOT 3
- ColourElement routines cannot accept alpha values HOT 4
- Problem with editor.research() taking None for maxCount parameter HOT 2
- Run Previous Script HOT 3
- Add Begin/End Select in Column Mode to MENUCOMMAND
- [Feature Req.] Add UI indication of script running/not-running status HOT 2
- Escape key in console should change focus to the current Scintilla Editor buffer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pythonscript.