Hello,
I try to use indicators but it doesn't work as expected.
When running the script for the first time it marks the first match only
(although I do have multiple matches, confirmed by console.write).
When running the script the second time everything gets cleared,
nothing marked at all.
When running the third time it acts like the first time and so on...
My guess would that n++ is jumping in between the actions and setting the
indicators somehow. As all scripts run on a separate thread, it's entirely
possible that something gets reset - possibly as a result of setting the
indicator in the first place.
It could be we need to create a function that does all these operations in
one go. I've been thinking about trying to provide an interface where you
could provide a function/lambda that you want to call atomically, on the
main n++ thread. This would probably solve this, but admittedly not in an
easy way.
If you or anyone else with more python knowledge than me, would like to
suggest an interface for doing something like that, I'd be keen to hear it!
Hi Dave,
sorry for late answer but I didn't get a notifcation sent that someone had replied.
May I ask you what you mean by
If you or anyone else with more python knowledge than me, would like to
suggest an interface for doing something like that, I'd be keen to hear it!
?
You don't speak about c++ interface do you? If so, sorry I cannot be helpful at all.
If you talk about a python class which acts inbetween, than I might have some ideas
if I could only understand what your request is asking for. Sorry you see I'm not really
a programmer :-(
What I think I understood is,
python script plugin runs on a separated (from npp) thread which, of course, means
that interacting with npps or scintillas interface could lead to the situation that script
hasn't finished it work yet and npp (or any other plugin) jumps in to do something similar
or somesthing which reversed what script has been done so far. Which, I guess, could always
happen, even if that script runs in an atomic way.
Now you think about an additional function, let's called run_atomic, which would get
editor as the first parameter, and a function or lambda as the second paramter. Then you
would like to run this function within the main thread of npp, to prevent, how can I say this,
thread interruption (?) and report the result back to python script plugin.
If I understood this correctly, can this even be guaranteed? What I read about atomic executions is that only the processor itself can be seen as the only trusted resource
to ask for atomic execution.
Thank you for your help
Claudia
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I try to use indicators but it doesn't work as expected.
When running the script for the first time it marks the first match only
(although I do have multiple matches, confirmed by console.write).
When running the script the second time everything gets cleared,
nothing marked at all.
When running the third time it acts like the first time and so on...
My script looks like
Any ideas what I'm doing wrong?
Npp 6.8.7
Python Script 1.0.8
Windows 7 x64
Thank you
Claudia
Last edit: CFrank 2015-12-21
OK, solution seems to be setting indicator styles within for loop.
Hmm, still not sure if this is how it should work.
Claudia
My guess would that n++ is jumping in between the actions and setting the
indicators somehow. As all scripts run on a separate thread, it's entirely
possible that something gets reset - possibly as a result of setting the
indicator in the first place.
It could be we need to create a function that does all these operations in
one go. I've been thinking about trying to provide an interface where you
could provide a function/lambda that you want to call atomically, on the
main n++ thread. This would probably solve this, but admittedly not in an
easy way.
If you or anyone else with more python knowledge than me, would like to
suggest an interface for doing something like that, I'd be keen to hear it!
Cheers
Dave
On Tue, 22 Dec 2015 22:01 CFrank myxin2010@users.sf.net wrote:
Hi Dave,
sorry for late answer but I didn't get a notifcation sent that someone had replied.
May I ask you what you mean by
?
You don't speak about c++ interface do you? If so, sorry I cannot be helpful at all.
If you talk about a python class which acts inbetween, than I might have some ideas
if I could only understand what your request is asking for. Sorry you see I'm not really
a programmer :-(
What I think I understood is,
python script plugin runs on a separated (from npp) thread which, of course, means
that interacting with npps or scintillas interface could lead to the situation that script
hasn't finished it work yet and npp (or any other plugin) jumps in to do something similar
or somesthing which reversed what script has been done so far. Which, I guess, could always
happen, even if that script runs in an atomic way.
Now you think about an additional function, let's called run_atomic, which would get
editor as the first parameter, and a function or lambda as the second paramter. Then you
would like to run this function within the main thread of npp, to prevent, how can I say this,
thread interruption (?) and report the result back to python script plugin.
If I understood this correctly, can this even be guaranteed? What I read about atomic executions is that only the processor itself can be seen as the only trusted resource
to ask for atomic execution.
Thank you for your help
Claudia