Show total count of chars/words in statusbar
-
- Posts: 24
- Joined: 08.03.2023 07:48
-
- Posts: 2308
- Joined: 25.08.2021 18:15
-
- Posts: 24
- Joined: 08.03.2023 07:48
Asked here: https://community.notepad-plus-plus.org ... char-count
Let's see if someone steps up to help.
Let's see if someone steps up to help.
To keep track of my word-count and char-count, I pop up Text Statistics (plugin) via hotkey. For both, selection and entire doc.pintassilgo wrote: With CudaText, I can't retrieve total words or total chars.
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.
Have you given Differ a try? I love this plugin, especially if your files are almost identical.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.
-
- Posts: 24
- Joined: 08.03.2023 07:48
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.
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.
The three examples I gave update the count instantly: Notepad++, Kate and SciTE.But they usually do not update the count continuously, you have to do it manually by clicking on that area in the status bar.
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.Have you given Differ a try? I love this plugin, especially if your files are almost identical.
-
- Posts: 2308
- Joined: 25.08.2021 18:15
-
- Posts: 2308
- Joined: 25.08.2021 18:15
-
- Posts: 2308
- Joined: 25.08.2021 18:15
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?
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?
-
- Posts: 24
- Joined: 08.03.2023 07:48
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").
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").