Page 2 of 3
Posted: 10.03.2023 08:19
by pintassilgo
I guess it's provided by Scintilla lib, not something done directly by NP++ or SciTE, they just get the value.
Posted: 10.03.2023 08:21
by main Alexey
Maybe author(s) can know how Scintilla counts this?
Posted: 10.03.2023 08:24
by pintassilgo
I'll try to ask.
Posted: 10.03.2023 15:55
by pintassilgo
Posted: 10.03.2023 18:36
by Stefan
pintassilgo wrote:
With CudaText, I can't retrieve total words or total chars.
To keep track of my word-count and char-count, I pop up Text Statistics (plugin) via hotkey. For both, selection and entire doc.
Most writing apps show it in the status bar. But they usually do not update the count continuously, you have to do it manually by clicking on that area in the status bar. The moment you type s.th., it changes to "Recount" or "Recalculate".
Not sure if this would make sense for CudaText. It certainly would help to avoid slow-downs while typing or switching through tabs.
pintassilgo wrote: total of chars is important to me to be able to do a very quick and simple check if two files may be identical.
Have you given Differ a try? I love this plugin, especially if your files are
almost identical.
Posted: 10.03.2023 19:29
by pintassilgo
So far they told that, as I was expecting, it's not calculated by the app but by Scintilla, the underlying editing component.
Other noted that the count in Notepad++ is not exactly the number of chars, but the number of bytes in file buffer, which has no cost to retrieve. This seems to be a simple and sufficiently useful approach, if you're interested in adding it to CudaText. Then we'll still have Text Statistic for more precise and granulated results, which aren't needed or suitable to be displayed right into the statusbar.
But they usually do not update the count continuously, you have to do it manually by clicking on that area in the status bar.
The three examples I gave update the count instantly: Notepad++, Kate and SciTE.
Have you given Differ a try? I love this plugin, especially if your files are almost identical.
Yes, thanks, I already use it. A way to compare/diff two files is always the first thing I check when testing an editor to know if it's worth to keep testing it for the possibility of becoming my main editor. So for precise comparison I use Differ, but just looking at the count is a quicker way to discard the possibility that two files can be identical, among other use cases.
Posted: 10.03.2023 20:22
by main Alexey
In the NP++ forum I see ppl said Scintilla gets count of bytes. so it has simple buffer storage, in which getting count of bytes is fast. Cud don't have this storage. it has 'list of lines', so to get char count Cud needs to SUM lens of all list items. it is FOR-LOOP for all lines
Posted: 10.03.2023 20:30
by main Alexey
I mean the 'for-loop' is always slow in programming (on 50K lines text).
Posted: 10.03.2023 21:34
by main Alexey
Ok, i want to add it, even if slow. i want two macros: e.g. xxx for total char cnt, and yyy for char cnt before the caret.
in the config they will be present with limit!
{xxx<111222}
and
{yyy<222333}
where numbers denote the limit- max value. I don't want limit in millisecs. it will be slower to calc.
what do you thiink?
Posted: 11.03.2023 06:55
by pintassilgo
For me it's fine, thanks for agreeing in adding the feature.
From the three editors I have here beside CudaText, SciTE and Notepad++ use Scintilla so the count is of bytes, not of chars. Kate, on the other hand, not only count chars correctly, it also displays the count of words in statusbar. But unlike the Scintilla-based ones, Kate count doesn't update instantly, I can see it waits for like half a second without change in the file to update, so it's clearly a decision made because it's not that cheap.
In the end, it all depends on how much is available for coding the feature.
The easiest, good enough to do the job even if it's not optimized is to count everything every time (the FOR-LOOP for all the lines), limited by size (set by user option) OR using idle timer, not sure which of the two would be better.
With one more conditional, could mix both: count instantly up to X chars. If count is > X, then use a idle timer to update the count. My guess is this is a good balance between not wasting much time working in the feature while still producing good and efficient results.
And there would be room for future optimization if someone helps to code, by caching counts line by line at the start and adding them up, then handling just edit events (typing, pasting, deleting, replacing, moving) to calc the difference between the cached value. This way, *maybe* the count could be made instantly and efficiently even with big files.
Of course these are just my dumb thoughts, as I currently have no ability to code in Pascal nor do I know how the current ATSynEdit structure affects the available options (like the fact it uses "list of lines" instead of "buffer storage").