Show total count of chars/words in statusbar

pintassilgo
Posts: 24
Joined: 08.03.2023 07:48

Post by pintassilgo »

pintassilgo wrote: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.
Just adding: for selection, the count is instant on Kate not only for chars but also for words! Even on selecting almost an entire file with 50k+ lines and dragging the selection to force update the count many times per second, still Kate handles it flawlessly, count updates are instant and I see no slowness.

Given that, count looks cheap, so I don't know why they added the idle timer for counting chars.
main Alexey
Posts: 2308
Joined: 25.08.2021 18:15

Post by main Alexey »

Teested on a demo app. counting total char count for 100K lines (len do not matter) takes 3ms in Cud
CPU Intel Core i3 3Ghz

I need not just add a macro. I need good coding to optimize it. put it to IdleTimer too. and add 'indexer of lines' .. indexer update will be slow, next calculations are O(log N)..
pintassilgo
Posts: 24
Joined: 08.03.2023 07:48

Post by pintassilgo »

Something like:

- Count instantly if document has up to X lines;
- If higher, use a IdleTimer.

Isn't good enough for a first release? Then it could be optimized in the future.

Both numbers could be exposed as a pair of user options: max of lines to count instantly and time in ms for the timer when the total lines is above the max. This way, users with better hardware could set higher max and shorter timer.

Anyway, the count doesn't need to be added by default, so that users adding it should know it can has a bit of performance impact (actually ~0 in real world for 99,9% of the cases, as editing a 100k file is very uncommon, also it would still be just the tiny 3ms for a modest hardware).

Maybe add a third option to disable char count after Y lines, as an automatic chars count for a giant file is not that useful, can be restricted to Text Statistics.
pintassilgo
Posts: 24
Joined: 08.03.2023 07:48

Post by pintassilgo »

It's done, it was implemented. thanks!
Post Reply