From 2caf3cd8632874b0bc382d946d6bf4c6ec8f5c95 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 15 Oct 2004 11:11:19 +0000 Subject: [PATCH] Store line widths in the bidi cache, so we don't fail to re-bidi a line when the window size changes. git-svn-id: svn://svn.tartarus.org/sgt/putty@4631 cda61777-01e9-0310-a592-d414129be87e --- terminal.c | 36 ++++++++++++++++++++++-------------- terminal.h | 7 ++++++- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/terminal.c b/terminal.c index 800a4f3f..1c10bf0f 100644 --- a/terminal.c +++ b/terminal.c @@ -1294,8 +1294,8 @@ void term_free(Terminal *term) sfree(term->wcTo); for (i = 0; i < term->bidi_cache_size; i++) { - sfree(term->pre_bidi_cache[i]); - sfree(term->post_bidi_cache[i]); + sfree(term->pre_bidi_cache[i].chars); + sfree(term->post_bidi_cache[i].chars); } sfree(term->pre_bidi_cache); sfree(term->post_bidi_cache); @@ -4161,11 +4161,14 @@ static int term_bidi_cache_hit(Terminal *term, int line, if (line >= term->bidi_cache_size) return FALSE; /* cache doesn't have this many lines */ - if (!term->pre_bidi_cache[line]) + if (!term->pre_bidi_cache[line].chars) return FALSE; /* cache doesn't contain _this_ line */ + if (term->pre_bidi_cache[line].width != width) + return FALSE; /* line is wrong width */ + for (i = 0; i < width; i++) - if (!termchars_equal(term->pre_bidi_cache[line] + i, lbefore + i)) + if (!termchars_equal(term->pre_bidi_cache[line].chars+i, lbefore+i)) return FALSE; /* line doesn't match cache */ return TRUE; /* it didn't match. */ @@ -4179,24 +4182,29 @@ static void term_bidi_cache_store(Terminal *term, int line, termchar *lbefore, term->bidi_cache_size = line+1; term->pre_bidi_cache = sresize(term->pre_bidi_cache, term->bidi_cache_size, - termchar *); + struct bidi_cache_entry); term->post_bidi_cache = sresize(term->post_bidi_cache, term->bidi_cache_size, - termchar *); + struct bidi_cache_entry); while (j < term->bidi_cache_size) { - term->pre_bidi_cache[j] = term->post_bidi_cache[j] = NULL; + term->pre_bidi_cache[j].chars = + term->post_bidi_cache[j].chars = NULL; + term->pre_bidi_cache[j].width = + term->post_bidi_cache[j].width = -1; j++; } } - sfree(term->pre_bidi_cache[line]); - sfree(term->post_bidi_cache[line]); + sfree(term->pre_bidi_cache[line].chars); + sfree(term->post_bidi_cache[line].chars); - term->pre_bidi_cache[line] = snewn(width, termchar); - term->post_bidi_cache[line] = snewn(width, termchar); + term->pre_bidi_cache[line].width = width; + term->pre_bidi_cache[line].chars = snewn(width, termchar); + term->post_bidi_cache[line].width = width; + term->post_bidi_cache[line].chars = snewn(width, termchar); - memcpy(term->pre_bidi_cache[line], lbefore, width * TSIZE); - memcpy(term->post_bidi_cache[line], lafter, width * TSIZE); + memcpy(term->pre_bidi_cache[line].chars, lbefore, width * TSIZE); + memcpy(term->post_bidi_cache[line].chars, lafter, width * TSIZE); } /* @@ -4399,7 +4407,7 @@ static void do_paint(Terminal *term, Context ctx, int may_optimise) lchars = term->ltemp; } else { - lchars = term->post_bidi_cache[i]; + lchars = term->post_bidi_cache[i].chars; } } else lchars = ldata->chars; diff --git a/terminal.h b/terminal.h index 9bc13127..66304117 100644 --- a/terminal.h +++ b/terminal.h @@ -65,6 +65,11 @@ struct termline { struct termchar *chars; }; +struct bidi_cache_entry { + int width; + struct termchar *chars; +}; + struct terminal_tag { int compatibility_level; @@ -247,7 +252,7 @@ struct terminal_tag { int ltemp_size; bidi_char *wcFrom, *wcTo; int wcFromTo_size; - termchar **pre_bidi_cache, **post_bidi_cache; + struct bidi_cache_entry *pre_bidi_cache, *post_bidi_cache; int bidi_cache_size; }; -- 2.11.0