From 87b6a3aba580944e3416630a28d7bfacc4c912e1 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Thu, 16 Aug 2018 22:43:18 +0900 Subject: [PATCH] [bim] Improve rendering speed by not sending so many color codes --- apps/bim.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/bim.c b/apps/bim.c index d8b8d2b5..c06838d4 100644 --- a/apps/bim.c +++ b/apps/bim.c @@ -1015,6 +1015,8 @@ void render_line(line_t * line, int width, int offset) { int i = 0; /* Offset in char_t line data entries */ int j = 0; /* Offset in terminal cells */ + int last_color = -1; + /* Set default text colors */ set_colors(COLOR_FG, COLOR_BG); @@ -1079,7 +1081,11 @@ void render_line(line_t * line, int width, int offset) { } /* Syntax hilighting */ - set_fg_color(flag_to_color(c.flags)); + int color = flag_to_color(c.flags); + if (color != last_color) { + set_fg_color(color); + last_color = color; + } /* Render special characters */ if (c.codepoint == '\t') {