From 35f071f61c7af179207d02a8cb959b6d99912d74 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 26 Feb 2019 07:12:13 +0000 Subject: [PATCH] Minor refactoring in terminal.c. The actual calls to win_draw_{text,cursor} in do_paint() were duplicated in two places, and I may want to change them soon, so it's convenient to centralise them. --- terminal.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/terminal.c b/terminal.c index 5844795d..e977fd6b 100644 --- a/terminal.c +++ b/terminal.c @@ -5040,6 +5040,16 @@ static termchar *term_bidi_line(Terminal *term, struct termline *ldata, return lchars; } +static void do_paint_draw(Terminal *term, termline *ldata, int x, int y, + wchar_t *ch, int ccount, + unsigned long attr, truecolour tc) +{ + win_draw_text(term->win, x, y, ch, ccount, attr, ldata->lattr, tc); + if (attr & (TATTR_ACTCURS | TATTR_PASCURS)) + win_draw_cursor(term->win, x, y, ch, ccount, + attr, ldata->lattr, tc); +} + /* * Given a context, update the window. */ @@ -5344,13 +5354,8 @@ static void do_paint(Terminal *term) } if (break_run) { - if ((dirty_run || last_run_dirty) && ccount > 0) { - win_draw_text(term->win, start, i, ch, ccount, - attr, ldata->lattr, tc); - if (attr & (TATTR_ACTCURS | TATTR_PASCURS)) - win_draw_cursor(term->win, start, i, ch, ccount, attr, - ldata->lattr, tc); - } + if ((dirty_run || last_run_dirty) && ccount > 0) + do_paint_draw(term, ldata, start, i, ch, ccount, attr, tc); start = j; ccount = 0; attr = tattr; @@ -5444,13 +5449,8 @@ static void do_paint(Terminal *term) } } } - if (dirty_run && ccount > 0) { - win_draw_text(term->win, start, i, ch, ccount, - attr, ldata->lattr, tc); - if (attr & (TATTR_ACTCURS | TATTR_PASCURS)) - win_draw_cursor(term->win, start, i, ch, ccount, - attr, ldata->lattr, tc); - } + if (dirty_run && ccount > 0) + do_paint_draw(term, ldata, start, i, ch, ccount, attr, tc); unlineptr(ldata); }