Optimized performance for low-bit-rate terminals. - #199
Conversation
| addch(' '); | ||
| } else if (lambda && matrix[i][j].val != ' ') { | ||
| addstr("λ"); | ||
| } else if (matrix[i][j].val < 0xFF) { |
There was a problem hiding this comment.
Should this be < 0x7f instead? That's where UTF-8 goes multibyte. I think this will mis-display characters in the Latin-1 block.
There was a problem hiding this comment.
These are 32 bit Unicode characters, not multi-byte UTF-8 sequences.
There was a problem hiding this comment.
"These" are indeed wchar_t but addch says vaguely it expects a "character" (but takes a single byte) and so it's not clear to me whether we can write ¶ the pilcrow or similar which are outside ASCII though fit in a single byte. If the terminal speaks UTF-8 (as a modern terminal probably does) then there needs to be 2 bytes emitted by the curses implementation to make that symbol.
I tried to see what happens here and discovered that I'm sufficiently rusty that I wasn't able to write a working test (the painkillers and/or broken left hand may not have helped but eh) but if it does work to emit addch a value like 0xB4 on an UTF-8 terminal that probably deserves a comment.
…bncurses 6.4-4 on Debian 12
Performance was poor on actual physical terminals running at low bit rates, e.g. 1200 baud, because it was repainting the whole screen each time, and being wasteful with cursor motion. This patch adds several optimizations to speed it up significantly:
With this patch, number of bytes written has probably been reduced by around 80%, maybe more.
Thanks!