summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Cervin <albert@acervin.com>2024-05-06 22:44:40 +0200
committerAlbert Cervin <albert@acervin.com>2024-05-06 22:44:40 +0200
commit292b2786a513f4a058889fc088598cb5acf1bcc5 (patch)
treeda0619b8cd98791a42393a333486b6638fabc4b7
parentad0cd5c036f0080ee8d97db2e67b8d54186d1e33 (diff)
downloaddged-292b2786a513f4a058889fc088598cb5acf1bcc5.tar.gz
dged-292b2786a513f4a058889fc088598cb5acf1bcc5.tar.xz
dged-292b2786a513f4a058889fc088598cb5acf1bcc5.zip
Add inverted colors mode
Also use color constants in some more places.
-rw-r--r--src/dged/buffer_view.c12
-rw-r--r--src/dged/display.c7
-rw-r--r--src/dged/display.h7
3 files changed, 21 insertions, 5 deletions
diff --git a/src/dged/buffer_view.c b/src/dged/buffer_view.c
index 0ba269c..6d77822 100644
--- a/src/dged/buffer_view.c
+++ b/src/dged/buffer_view.c
@@ -313,8 +313,9 @@ static uint32_t render_line_numbers(struct buffer_view *view,
uint32_t relline = 0;
for (; relline < height && line < nlines_buf; ++line, ++relline) {
- command_list_set_index_color_bg(commands, 8);
- command_list_set_index_color_fg(commands, line == view->dot.line ? 15 : 7);
+ command_list_set_index_color_bg(commands, Color_BrightBlack);
+ command_list_set_index_color_fg(
+ commands, line == view->dot.line ? Color_BrightWhite : Color_White);
uint32_t chars = snprintf(buf, 16, "%*d", longest_nchars + 1, line + 1);
command_list_draw_text_copy(commands, 0, relline, (uint8_t *)buf, chars);
command_list_reset_color(commands);
@@ -322,8 +323,8 @@ static uint32_t render_line_numbers(struct buffer_view *view,
}
for (; relline < height; ++relline) {
- command_list_set_index_color_bg(commands, 8);
- command_list_set_index_color_fg(commands, 7);
+ command_list_set_index_color_bg(commands, Color_BrightBlack);
+ command_list_set_index_color_fg(commands, Color_White);
command_list_draw_repeated(commands, 0, relline, ' ', longest_nchars + 1);
command_list_reset_color(commands);
command_list_draw_repeated(commands, longest_nchars + 1, relline, ' ', 1);
@@ -363,7 +364,8 @@ static void render_modeline(struct modeline *modeline, struct buffer_view *view,
modeline->buffer[len] = '\0';
}
- command_list_set_index_color_bg(commands, 8);
+ command_list_set_index_color_bg(commands, Color_BrightBlack);
+ command_list_set_index_color_fg(commands, Color_White);
command_list_draw_text(commands, 0, height - 1, modeline->buffer,
strlen((char *)modeline->buffer));
command_list_reset_color(commands);
diff --git a/src/dged/display.c b/src/dged/display.c
index 675140a..bc604f0 100644
--- a/src/dged/display.c
+++ b/src/dged/display.c
@@ -351,6 +351,13 @@ void command_list_set_color_bg(struct command_list *list, uint8_t red,
cmd->len = snprintf((char *)cmd->fmt, 64, "48;2;%d;%d;%d", red, green, blue);
}
+void command_list_set_inverted_colors(struct command_list *list) {
+ struct push_fmt_cmd *cmd =
+ add_command(list, RenderCommand_PushFormat)->push_fmt;
+ cmd->fmt[0] = '7';
+ cmd->len = 1;
+}
+
void command_list_reset_color(struct command_list *list) {
add_command(list, RenderCommand_ClearFormat);
}
diff --git a/src/dged/display.h b/src/dged/display.h
index aae2614..7e3d62c 100644
--- a/src/dged/display.h
+++ b/src/dged/display.h
@@ -187,6 +187,13 @@ void command_list_set_color_fg(struct command_list *list, uint8_t red,
uint8_t green, uint8_t blue);
/**
+ * Set colors to be inverted.
+ *
+ * Sets background as foreground and vice versa.
+ */
+void command_list_set_inverted_colors(struct command_list *list);
+
+/**
* Reset the color and styling information.
*
* The following draw commands will have their formatting reset to the default.