The color is controlled by

  document.browse.links.active_link.insert_mode_colors.background
  document.browse.links.active_link.insert_mode_colors.text

Also avoid overloading local variable "i" in get_current_link().
---
 src/config/options.inc  |   12 ++++++++++++
 src/document/document.c |    2 ++
 src/document/options.c  |    2 ++
 src/document/options.h  |    1 +
 src/viewer/text/link.c  |   17 ++++++++++++-----
 5 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/src/config/options.inc b/src/config/options.inc
index 340ab93..7098854 100644
--- a/src/config/options.inc
+++ b/src/config/options.inc
@@ -294,6 +294,18 @@ static struct option_info config_options_info[] = {
                "text", 0, "black",
                N_("Default text color.")),
 
+       INIT_OPT_TREE("document.browse.links.active_link", N_("Insert mode 
colors"),
+               "insert_mode_colors", 0,
+               N_("Insert mode colors.")),
+
+       INIT_OPT_COLOR("document.browse.links.active_link.insert_mode_colors", 
N_("Background color for text field in insert mode."),
+               "background", 0, "#0000ff",
+               N_("Background color for text field in insert mode.")),
+
+       INIT_OPT_COLOR("document.browse.links.active_link.insert_mode_colors", 
N_("Text color for text field in insert mode"),
+               "text", 0, "black",
+               N_("Text color for text field in insert mode.")),
+
        INIT_OPT_BOOL("document.browse.links.active_link", N_("Enable color"),
                "enable_color", 0, 0,
                N_("Enable use of the active link background and text color "
diff --git a/src/document/document.c b/src/document/document.c
index 5424f6f..19ee2d0 100644
--- a/src/document/document.c
+++ b/src/document/document.c
@@ -234,6 +234,8 @@ update_cached_document_options(struct session *ses)
        memset(&active_link, 0, sizeof(active_link));   /* Safer. */
        active_link.color.foreground = 
get_opt_color("document.browse.links.active_link.colors.text", ses);
        active_link.color.background = 
get_opt_color("document.browse.links.active_link.colors.background", ses);
+       active_link.insert_mode_color.foreground = 
get_opt_color("document.browse.links.active_link.insert_mode_colors.text", ses);
+       active_link.insert_mode_color.background = 
get_opt_color("document.browse.links.active_link.insert_mode_colors.background",
 ses);
        active_link.enable_color = 
get_opt_bool("document.browse.links.active_link.enable_color", ses);
        active_link.invert = 
get_opt_bool("document.browse.links.active_link.invert", ses);
        active_link.underline = 
get_opt_bool("document.browse.links.active_link.underline", ses);
diff --git a/src/document/options.c b/src/document/options.c
index b681fda..9208d64 100644
--- a/src/document/options.c
+++ b/src/document/options.c
@@ -52,6 +52,8 @@ init_document_options(struct session *ses, struct 
document_options *doo)
 
        doo->active_link.color.foreground = 
get_opt_color("document.browse.links.active_link.colors.text", ses);
        doo->active_link.color.background = 
get_opt_color("document.browse.links.active_link.colors.background", ses);
+       doo->active_link.insert_mode_color.foreground = 
get_opt_color("document.browse.links.active_link.insert_mode_colors.text", ses);
+       doo->active_link.insert_mode_color.background = 
get_opt_color("document.browse.links.active_link.insert_mode_colors.background",
 ses);
 
        if (get_opt_bool("document.colors.increase_contrast", ses))
                doo->color_flags |= COLOR_INCREASE_CONTRAST;
diff --git a/src/document/options.h b/src/document/options.h
index d3bd29a..52c1956 100644
--- a/src/document/options.h
+++ b/src/document/options.h
@@ -20,6 +20,7 @@ struct active_link_options {
        unsigned int bold:1;
        unsigned int invert:1;
        struct active_link_options_colors color;
+       struct active_link_options_colors insert_mode_color;
 };
 
 /** This mostly acts as a option cache so rendering will be faster. However it
diff --git a/src/viewer/text/link.c b/src/viewer/text/link.c
index a9021b0..eaa15f1 100644
--- a/src/viewer/text/link.c
+++ b/src/viewer/text/link.c
@@ -165,7 +165,7 @@ get_link_cursor_offset(struct document_view *doc_view, 
struct link *link)
 /** Initialise a static template character with the colour and attributes
  * appropriate for an active link and return that character. */
 static inline struct screen_char *
-init_link_drawing(struct document_view *doc_view, struct link *link, int 
invert)
+init_link_drawing(struct document_view *doc_view, struct link *link, int 
invert, int input)
 {
        struct document_options *doc_opts;
        static struct screen_char template;
@@ -187,8 +187,13 @@ init_link_drawing(struct document_view *doc_view, struct 
link *link, int invert)
                template.attr |= SCREEN_ATTR_BOLD;
 
        if (doc_opts->active_link.enable_color) {
-               colors.foreground = doc_opts->active_link.color.foreground;
-               colors.background = doc_opts->active_link.color.background;
+               if (input) {
+                       colors.foreground = 
doc_opts->active_link.insert_mode_color.foreground;
+                       colors.background = 
doc_opts->active_link.insert_mode_color.background;
+               } else {
+                       colors.foreground = 
doc_opts->active_link.color.foreground;
+                       colors.background = 
doc_opts->active_link.color.background;
+               }
        } else {
                colors.foreground = link->color.foreground;
                colors.background = link->color.background;
@@ -231,6 +236,7 @@ draw_current_link(struct session *ses, struct document_view 
*doc_view)
        struct link *link;
        int cursor_offset;
        int xpos, ypos;
+       int invert, input;
        int i;
 
        assert(term && doc_view && doc_view->vs);
@@ -242,8 +248,9 @@ draw_current_link(struct session *ses, struct document_view 
*doc_view)
        link = get_current_link(doc_view);
        if (!link) return;
 
-       i = !link_is_textinput(link) || ses->insert_mode == INSERT_MODE_OFF;
-       template = init_link_drawing(doc_view, link, i);
+       invert = !link_is_textinput(link) || ses->insert_mode == 
INSERT_MODE_OFF;
+       input = ses->insert_mode == INSERT_MODE_ON;
+       template = init_link_drawing(doc_view, link, invert, input);
        if (!template) return;
 
        xpos = doc_view->box.x - doc_view->vs->x;
-- 
1.6.3

_______________________________________________
elinks-dev mailing list
elinks-dev@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-dev

Reply via email to