From a9b848c54810fd88e9423000a2249e47e0f6198b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morel=20B=C3=A9renger?= Date: Tue, 24 May 2016 16:08:50 +0200 Subject: [PATCH] Reverse video mode for currently executing line Use ":set rev true" or ":set reverse_exec_line true" to enable. Disabled by default. TODO: respect syntax colors of the line --- cgdb/cgdbrc.c | 7 ++++++- cgdb/cgdbrc.h | 2 ++ cgdb/sources.c | 8 ++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/cgdb/cgdbrc.c b/cgdb/cgdbrc.c index cc305fe..26d1d30 100644 --- a/cgdb/cgdbrc.c +++ b/cgdb/cgdbrc.c @@ -65,6 +65,7 @@ static struct cgdbrc_config_option cgdbrc_config_options[CGDBRC_WRAPSCAN + 1] = {CGDBRC_AUTOSOURCERELOAD, {1}}, {CGDBRC_CGDB_MODE_KEY, {CGDB_KEY_ESC}}, {CGDBRC_IGNORECASE, {0}}, + {CGDBRC_REVERSE_EXEC_LINE, {0}}, {CGDBRC_SHOWTGDBCOMMANDS, {0}}, {CGDBRC_SYNTAX, {TOKENIZER_LANGUAGE_UNKNOWN}}, {CGDBRC_TABSTOP, {8}}, @@ -108,6 +109,10 @@ static struct ConfigVariable { { "ignorecase", "ic", CONFIG_TYPE_BOOL, &cgdbrc_config_options[CGDBRC_IGNORECASE].variant.int_val}, + /* reverse_exec_line */ + { + "reverse_exec_line", "rev", CONFIG_TYPE_BOOL, + &cgdbrc_config_options[CGDBRC_REVERSE_EXEC_LINE].variant.int_val}, /* showtgdbcommands */ { "showtgdbcommands", "stc", CONFIG_TYPE_FUNC_BOOL, &command_set_stc}, @@ -138,7 +143,7 @@ static struct ConfigVariable { "winsplit", "winsplit", CONFIG_TYPE_FUNC_STRING, command_set_winsplit}, /* wrapscan */ { -"wrapscan", "ws", CONFIG_TYPE_BOOL, + "wrapscan", "ws", CONFIG_TYPE_BOOL, &cgdbrc_config_options[CGDBRC_WRAPSCAN].variant.int_val},}; static int command_do_tgdbcommand(int param); diff --git a/cgdb/cgdbrc.h b/cgdb/cgdbrc.h index bac90bb..dd4e008 100644 --- a/cgdb/cgdbrc.h +++ b/cgdb/cgdbrc.h @@ -105,6 +105,7 @@ enum cgdbrc_option_kind { CGDBRC_AUTOSOURCERELOAD, CGDBRC_CGDB_MODE_KEY, CGDBRC_IGNORECASE, + CGDBRC_REVERSE_EXEC_LINE, CGDBRC_SHOWTGDBCOMMANDS, CGDBRC_SYNTAX, CGDBRC_TABSTOP, @@ -126,6 +127,7 @@ struct cgdbrc_config_option { /* option_kind == CGDBRC_AUTOSOURCERELOAD */ /* option_kind == CGDBRC_CGDB_MODE_KEY */ /* option_kind == CGDBRC_IGNORECASE */ + /* option_kind == CGDBRC_REVERSE_EXEC_LINE */ /* option_kind == CGDBRC_SHOWTGDBCOMMANDS */ /* option_kind == CGDBRC_TABSTOP */ /* option_kind == CGDBRC_TIMEOUT */ diff --git a/cgdb/sources.c b/cgdb/sources.c index 271c422..3a0f5cc 100644 --- a/cgdb/sources.c +++ b/cgdb/sources.c @@ -592,6 +592,7 @@ int source_display(struct sviewer *sview, int focus) else if (line < 0) line = 0; } + int run_line = 0; /* Print 'height' lines of the file, starting at 'line' */ lwidth = (int) log10(sview->cur->buf.length) + 1; @@ -617,6 +618,7 @@ int source_display(struct sviewer *sview, int focus) /* Mark the current line with an arrow */ } else if (line == sview->cur->exe_line) { + run_line = i; switch (sview->cur->buf.breakpts[line]) { case 0: if (hl_groups_get_attr(hl_groups_instance, HLG_ARROW, @@ -733,6 +735,12 @@ int source_display(struct sviewer *sview, int focus) } } + bool config_reverse_exec_line = cgdbrc_get(CGDBRC_REVERSE_EXEC_LINE)->variant.int_val; + if (config_reverse_exec_line) { + mvwchgat(sview->win, run_line, lwidth + 2, getmaxx(sview->win) - lwidth - 2, + A_REVERSE, 0, NULL); + } + wmove(sview->win, height - (line - sview->cur->sel_line), lwidth + 2); wrefresh(sview->win); -- 2.1.4