summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Balaev <mail@void.so>2024-02-14 13:31:39 +0300
committerPavel Balaev <mail@void.so>2024-02-14 13:53:28 +0300
commit6be81c23e4fb3cdf2d3738c92735972d7674b957 (patch)
tree2e20714a6ab1a8ea4794bfdd241be3814c59822b
parent8225ef18fda48a1f31774a739c18cfd3bc81f4cc (diff)
cfg: error text color
New config variable: `err_color`
-rw-r--r--CHANGES4
-rw-r--r--nemu.cfg.sample3
-rw-r--r--src/nm_cfg_file.c18
-rw-r--r--src/nm_cfg_file.h2
-rw-r--r--src/nm_main_loop.c8
5 files changed, 34 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index d6b90f7..6da62b5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+v3.3.1 - future
+------------------------
+ - Feature: error text color config option
+
v3.3.0 - 04.10.2023
------------------------
- Feature: support vga none option
diff --git a/nemu.cfg.sample b/nemu.cfg.sample
index d3f2e70..3759692 100644
--- a/nemu.cfg.sample
+++ b/nemu.cfg.sample
@@ -14,6 +14,9 @@ db = /home/user/.nemu.db
# override highlight color of running VM's. Example:
# hl_color = 00afd7
+# override error text color. Example:
+# err_color = ff45c1
+
# glyph_checkbox = 1
# glyph_separator = 0
diff --git a/src/nm_cfg_file.c b/src/nm_cfg_file.c
index cd178b7..186fb2f 100644
--- a/src/nm_cfg_file.c
+++ b/src/nm_cfg_file.c
@@ -46,6 +46,7 @@ static const char NM_INI_S_DMON[] = "nemu-monitor";
static const char NM_INI_P_VM[] = "vmdir";
static const char NM_INI_P_DB[] = "db";
static const char NM_INI_P_HL[] = "hl_color";
+static const char NM_INI_P_ERR[] = "err_color";
static const char NM_INI_P_CS[] = "cursor_style";
static const char NM_INI_P_DEBUG_PATH[] = "debug_path";
static const char NM_INI_P_PROT[] = "spice_default";
@@ -295,6 +296,21 @@ void nm_cfg_init(bool bypass_cfg)
cfg.hl_color.r, cfg.hl_color.g, cfg.hl_color.b);
}
nm_str_trunc(&tmp_buf, 0);
+ if (nm_get_opt_param(ini, NM_INI_S_MAIN, NM_INI_P_ERR, &tmp_buf) == NM_OK) {
+ if (tmp_buf.len != 6) {
+ nm_bug(_("cfg: incorrect color value %s, example:cd1430"),
+ tmp_buf.data);
+ }
+
+ nm_cfg_get_color(0, &cfg.err_color.r, &tmp_buf);
+ nm_cfg_get_color(2, &cfg.err_color.g, &tmp_buf);
+ nm_cfg_get_color(4, &cfg.err_color.b, &tmp_buf);
+
+ cfg.err_is_set = 1;
+ nm_debug("Error color: r:%d g:%d b:%d\n",
+ cfg.err_color.r, cfg.err_color.g, cfg.err_color.b);
+ }
+ nm_str_trunc(&tmp_buf, 0);
if (nm_get_opt_param(ini, NM_INI_S_MAIN, NM_INI_P_CS, &tmp_buf) == NM_OK) {
if (tmp_buf.len != 1) {
nm_bug(_("cfg: incorrect cursor style value %s, example:1"),
@@ -580,6 +596,8 @@ static void nm_generate_cfg(const char *home, const nm_str_t *cfg_path)
"debug_path = /tmp/nemu_debug.log\n\n");
fprintf(cfg_file, "# override highlight color of running VM's. "
"Example:\n# hl_color = 00afd7\n\n");
+ fprintf(cfg_file, "# override error text color. "
+ "Example:\n# err_color = cd1430\n\n");
fprintf(cfg_file, "# glyph_checkbox = 1\n# "
"glyph_separator = 0\n\n");
fprintf(cfg_file,
diff --git a/src/nm_cfg_file.h b/src/nm_cfg_file.h
index eddbfc7..e31f39c 100644
--- a/src/nm_cfg_file.h
+++ b/src/nm_cfg_file.h
@@ -41,6 +41,7 @@ typedef struct {
nm_str_t qemu_bin_path;
nm_vect_t qemu_targets;
nm_rgb_t hl_color;
+ nm_rgb_t err_color;
nm_glyph_t glyphs;
nm_str_t debug_path;
uint64_t daemon_sleep;
@@ -63,6 +64,7 @@ typedef struct {
uint32_t spice_default:1;
uint32_t log_enabled:1;
uint32_t hl_is_set:1;
+ uint32_t err_is_set:1;
uint32_t debug:1;
} nm_cfg_t;
diff --git a/src/nm_main_loop.c b/src/nm_main_loop.c
index 67f70cf..f886d74 100644
--- a/src/nm_main_loop.c
+++ b/src/nm_main_loop.c
@@ -58,7 +58,6 @@ void nm_start_main_loop(void)
nm_filter = NM_INIT_FILTER;
init_pair(NM_COLOR_BLACK, COLOR_BLACK, COLOR_WHITE);
- init_pair(NM_COLOR_RED, COLOR_RED, COLOR_WHITE);
if (cfg->hl_is_set && can_change_color()) {
init_color(COLOR_WHITE + 1,
cfg->hl_color.r, cfg->hl_color.g, cfg->hl_color.b);
@@ -66,6 +65,13 @@ void nm_start_main_loop(void)
} else {
init_pair(NM_COLOR_HIGHLIGHT, COLOR_GREEN, -1);
}
+ if (cfg->err_is_set && can_change_color()) {
+ init_color(COLOR_WHITE + 2,
+ cfg->err_color.r, cfg->err_color.g, cfg->err_color.b);
+ init_pair(NM_COLOR_RED, COLOR_WHITE + 2, COLOR_WHITE);
+ } else {
+ init_pair(NM_COLOR_RED, COLOR_RED, COLOR_WHITE);
+ }
nm_create_windows();
nm_init_help_main();