refactor(grid): reimplement 'rightleft' as a post-processing step

problem: checks for wp->w_p_rl are all over the place, making simple
things like "advance column one cell" incredibly complicated.

solution: always fill linebuf_char[] using an incrementing counter,
and then mirror the buffer as a post-processing step

This was "easier" that I first feared, because the stupid but simple
workaround for things like keeping linenumbers still left-right,
e.g. "mirror them and them mirror them once more" is more or less
what vim did already. So let's just keep doing that.
This commit is contained in:
bfredl
2023-11-03 20:25:52 +01:00
parent acc646ad8f
commit 83db9115af
4 changed files with 97 additions and 199 deletions

View File

@@ -650,9 +650,9 @@ size_t transchar_hex(char *const buf, const int c)
/// Mirror text "str" for right-left displaying.
/// Only works for single-byte characters (e.g., numbers).
void rl_mirror_ascii(char *str)
void rl_mirror_ascii(char *str, char *end)
{
for (char *p1 = str, *p2 = str + strlen(str) - 1; p1 < p2; p1++, p2--) {
for (char *p1 = str, *p2 = (end ? end : str + strlen(str)) - 1; p1 < p2; p1++, p2--) {
char t = *p1;
*p1 = *p2;
*p2 = t;