mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Fix selection and cursor handling for bidi + wide chars.
Commit fec93d5e0
missed a piece: when we hand wcTo to
term_bidi_cache_store and it uses it to set up the mapping between
physical and logical character positions for cursor and selection
handling, it will assume wcTo has as many entries as there are columns
in the terminal. But in fact now wcTo may be shorter than that, so
term_bidi_cache_store also needs to pay attention to the nchars field.
This commit is contained in:
parent
801ab68eac
commit
07ebd88c3a
12
terminal.c
12
terminal.c
@ -4869,10 +4869,10 @@ static void term_bidi_cache_store(Terminal *term, int line, termchar *lbefore,
|
||||
termchar *lafter, bidi_char *wcTo,
|
||||
int width, int size)
|
||||
{
|
||||
int i;
|
||||
int i, j;
|
||||
|
||||
if (!term->pre_bidi_cache || term->bidi_cache_size <= line) {
|
||||
int j = term->bidi_cache_size;
|
||||
j = term->bidi_cache_size;
|
||||
term->bidi_cache_size = line+1;
|
||||
term->pre_bidi_cache = sresize(term->pre_bidi_cache,
|
||||
term->bidi_cache_size,
|
||||
@ -4910,13 +4910,15 @@ static void term_bidi_cache_store(Terminal *term, int line, termchar *lbefore,
|
||||
memset(term->post_bidi_cache[line].forward, 0, width * sizeof(int));
|
||||
memset(term->post_bidi_cache[line].backward, 0, width * sizeof(int));
|
||||
|
||||
for (i = 0; i < width; i++) {
|
||||
for (i = j = 0; j < width; j += wcTo[i].nchars, i++) {
|
||||
int p = wcTo[i].index;
|
||||
|
||||
assert(0 <= p && p < width);
|
||||
|
||||
term->post_bidi_cache[line].backward[i] = p;
|
||||
term->post_bidi_cache[line].forward[p] = i;
|
||||
for (int x = 0; x < wcTo[i].nchars; x++) {
|
||||
term->post_bidi_cache[line].backward[j+x] = p+x;
|
||||
term->post_bidi_cache[line].forward[p+x] = j+x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user