NppExec v0.8.6 has been released!
-
@rdipardo
Thank you! I’ve integrated this - seems to work like a charm!
Now I probably understand the feelings of people who are looking at Python’s or NppExec’s scripts with understanding of the general idea behind them but anyway perceiving the entire script like a form of a magic spell :) -
@Vitalii-Dovgan and all,
It seems like this is mostly wrapped up, but if there’s anything more on the HTML/presentation of the NppExec manual, it would be a better fit in the NppExec repo’s issue section than here.
Of course, discussion on the plugin itself is quite encouraged here. :-)
-
Recently I had made some optimizations around variables handling in NppExec (in the develop branch). So I decided to create a scenario that would help to compare the performance between 0.8.6 and pre-0.8.7. Hence the following simple NppExec’s script was born:
npe_console local -- m- set local N = 20 set local i = 0 :1 set local i ~ $(i) + 1 if $(i) >= 8400 goto 3 if~ $(i) % 100 != 0 goto 1 set local k ~ ord a set local kk = 0 :2 set local c ~ chr $(k) set local v ~ strupper $(c) set local $($(c)_) = $($(c)_)$(v) set local k ~ $(k) + 1 set local kk ~ $(kk) + 1 if $(kk) < $(N) goto 2 goto 1 :3 set local k ~ ord a set local kk = 0 :4 set local c ~ chr $(k) echo $($(c)_) set local k ~ $(k) + 1 set local kk ~ $(kk) + 1 if $(kk) < $(N) goto 4
This script intentionally does not use nested IF-THEN-ELSE because, as I discovered during these tests, all the versions of NppExec prior to pre-0.8.7 (in development) had problems with nested IF-THEN-ELSE. I wonder how it happened that no one had reported that before.
Anyway, here is the script that works in both NppExec 0.8.6 and pre-0.8.7 and here are the average execution times of this script on my i5-6600 CPU @ 3.30GHz :0.8.6 - 2.00 seconds
0.8.7 - 0.65 secondsNot bad, I should say.
Now, if you want the very same script to take extra long time of around 2 minutes and 30 seconds (just compare it to 0.65 seconds!), just replacenpe_console local -- m-
in the beginning of the script withnpe_console local -- m+
. This clearly shows that the implementation ofCNppExecConsole::PrintMessage
which is basically:SendMessage(hRichEdit, EM_EXGETSEL, 0, (LPARAM) &cr); SendMessage(hRichEdit, WM_SETREDRAW, FALSE, 0); SendMessage(hRichEdit, EM_EXSETSEL, 0, (LPARAM) &CHARRANGE{-1, -1}); SendMessage(hRichEdit, EM_SETCHARFORMAT, (WPARAM) dwOptions, (LPARAM) &cf); SendMessage(hRichEdit, EM_REPLACESEL, FALSE, (LPARAM) cszText); SendMessage(hRichEdit, EM_EXSETSEL, 0, (LPARAM) &cr); SendMessage(hRichEdit, EM_SCROLLCARET, 0, 0); SendMessage(hRichEdit, WM_SETREDRAW, TRUE, 0); if (InvalidateRect(hRichEdit, NULL, TRUE)) UpdateWindow(hRichEdit);
is slow as hell.
As you can see, all of these are actually messages to a RichEdit window.
I tried to removeSendMessage(hRichEdit, WM_SETREDRAW, FALSE, 0);
, together withSendMessage(hRichEdit, WM_SETREDRAW, TRUE, 0);
,InvalidateRect(hRichEdit, NULL, TRUE)
andUpdateWindow(hRichEdit)
- and got 3 minutes and 40 seconds - i.e. 1 minute was added to the previous extra long result!
Oh my, is there a way to append text to RichEdit more effectively, without waiting forever? -
@Vitalii-Dovgan said in NppExec v0.8.6 has been released!:
As you can see, all of these are actually messages to a RichEdit window.
It sounds like you’ve got a generic win32 API programming question, then, rather than something specific to Notepad++, and there are other forums on the internet that will have a higher concentration of RichEdit experts than here, where we focus on the specifics to the Plugin/Notepad++ interface.
-
Hmm, told TWICE now to avoid off-topic conversations…
-
Guys, I respect your will to avoid off-topic.
Let’s, however, analyze the content of my last message:- First I’m presenting an interesting NppExec’s script. Not off-topic.
- Second, I’m describing some technical details of NppExec’s implementation. Not off-topic.
- then I mention the details of implementation of
CNppExecConsole::PrintMessage
to illustrate that exactly the implementation of this method adds extra execution time.
Until this point, there’s nothing about “a generic win32 API programming question”, as you mentioned.
Finally, summing up with the slow implementation ofCNppExecConsole::PrintMessage
, I’m asking “is there a way to append text to RichEdit more effectively”. This question was not the goal of the entire text above.
-
@Vitalii-Dovgan said in NppExec v0.8.6 has been released!:
Until this point, there’s nothing about “a generic win32 API programming question”, as you mentioned
And your post, until that point, was on topic. But that point (including the RichEdit question asked) and any followup, is not. That is why I only quoted that single portion in commenting about off-topic, because that was the portion that was going off-topic. (And no, I didn’t do it out of shear meanness or something; when I, as a moderator, get valid private complaints about discussions straying off-topic, I have to address them somehow.)
-
For me it’s hard to keep away from offtopic sometimes because NppExec’s nature is all related to effectiveness and development.
For example, one guy asked about the behavior ofipython
under NppExec. At that point, I did not even know whatipython
is. So, from your perspective, that question could be treated asipython
-specific and, thus, offtopic. However, I invested my time into looking into that problem sinceipython
was running under NppExec, making it NppExec-related in that sense.
Another example: NppExec is distributed with a few .h (C-header) files because NppExec goes as far as loads these .h files during runtime to read the numeric constants from the files. Correspondingly, NppExec supports two-pass parsing of C#define
statements as well as Cenum
statements. From your perspective, C#define
andenum
statements are C-specific and thus can be treated as offtopic - however, it is directly related to NppExec’s code that probably makes them non-offtopic.
Next example: Joseph-Samuel, Lycan Thrope and rdipardo significantly helped with making NppExec’s Manual available online. In terms of NppExec, this is a historical achievement because, from now on, any user of NppExec can access and can be pointed to the online Manual at any time. And this benifit is incommensurably more important than the question of offtopic in the forum. Let me highlight: NppExec Manual would have never been online without Joseph-Samuel’s, Lycan Thrope’s and rdipardo’s help!
You had mentioned that HTML-related things are offtopic here, but you have omitted two truly significant points:- People who read and write here, in this topic, do care about NppExec, so their motivation with helping with some technology-specific solution is much higher than in any other solely technology-specific forum. In terms of HTML, I did not even know what to ask about, and only due to Lycan Thrope, because he knows how NppExec’s Manual chm file looks like, I discovered such things as
frames
in HTML. Then, Joseph-Samuel helped with hosting the HTML Manual on Git (without him, I did not even know that it is possible). Finally, rdipardo helped with the final form of the online/offline Manual. By marking all of this as “offtopic”, you are actually saying: NppExec Manual is not important for Notepad++ Community, we’d prefer to not have the online/offline version in favour of not having technology-specific duscussion in our forum. - While NppExec’s users are free to ask questions about NppExec as a tool and as a technology, I can’t feel free to ask about tools and technologies that are used by NppExec itself. Execuse me, but it looks assymetrical and unfair to me. Again, exactly here, in the forum named “Notepad++ & Plugin Development”, where we have people who care about NppExec and who use different technologies and different tools, there are much higher chances to get an answer. And if people do not have such answer, they just do not reply. For example, in terms of RichEdit, some developer who is interested in Notepad++ and NppExec, might reply e.g.: “RichEdit is an ancient thing, let’s better use another component that has a similar API but is implemented much better. Morover, as I have experience with it and was already thinking about using it NppExec, let’s do it together”. Such an answer would not be possible in any other forum otside of Notepad++'s one.
- People who read and write here, in this topic, do care about NppExec, so their motivation with helping with some technology-specific solution is much higher than in any other solely technology-specific forum. In terms of HTML, I did not even know what to ask about, and only due to Lycan Thrope, because he knows how NppExec’s Manual chm file looks like, I discovered such things as
-
I’m trying to walk the fine line of a moderator, of trying to encourage healthy discussion pertinent to Notepad++ (and here, the development and usage of plugins) while not letting things get off into generic programming questions. Unfortunately, that’s not always easy to do, and it can make people on one or both sides of the viewpoint on a certain discussion unhappy, no matter what I do. Maybe I am being too strict – I’m doing my best, but I’m not perfect.
How is this for a compromise? When an on-topic conversation here starts to edge into things that aren’t Notepad++-specific, you could say, “It looks like we’re straying away from the Notepad++ aspects of my plugin. If you have any ideas on how to improve the SendMessage with the RichText elements, could you please come to my issue#XXXXX which I created to delve deeper into this?” That way, interested readers in this Community would know that you’re having difficulty, and if they think of something, they’ll have an on-topic location for where to give you more details.
-
@PeterJones said in NppExec v0.8.6 has been released!:
How is this for a compromise? When an on-topic conversation here starts to edge into things that aren’t Notepad+±specific,
There’s also the option of taking any discussion you want into a dedicated “chat” right on this site.
So one could say, “if anyone has some ideas for me about ____, please private chat me and we’ll talk further, without potentially bothering any others”
-
Makes sense, thank you! Such obvious things did not come to my mind, but I’m learning :)
I’ve created an issue regarding the RichEdit. Anyone interested please feel free to comment right there:
https://github.com/d0vgan/nppexec/issues/79 -
One more idea that requires help of someone familiar with HTML.
It would be great to add a search index (ability to search for a given word) to the online NppExec Manual.
I’ve created the corresponding issue on github, please feel free to comment right there:
https://github.com/d0vgan/nppexec/issues/80