1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-01-03 14:57:44 -05:00

Merge pull request #4 from aelmahmoudy/color_textarea

Provide different color for text areas in insert mode.
This commit is contained in:
rkd77 2017-11-22 11:51:10 +01:00 committed by GitHub
commit baf0c5b689
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 5 deletions

View File

@ -294,6 +294,18 @@ static union option_info config_options_info[] = {
"text", 0, "black", "text", 0, "black",
N_("Default text color.")), 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"), INIT_OPT_BOOL("document.browse.links.active_link", N_("Enable color"),
"enable_color", 0, 0, "enable_color", 0, 0,
N_("Enable use of the active link background and text color " N_("Enable use of the active link background and text color "

View File

@ -312,6 +312,8 @@ update_cached_document_options(struct session *ses)
memset(&active_link, 0, sizeof(active_link)); /* Safer. */ 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.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.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.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.invert = get_opt_bool("document.browse.links.active_link.invert", ses);
active_link.underline = get_opt_bool("document.browse.links.active_link.underline", ses); active_link.underline = get_opt_bool("document.browse.links.active_link.underline", ses);

View File

@ -48,6 +48,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.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.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)) if (get_opt_bool("document.colors.increase_contrast", ses))
doo->color_flags |= COLOR_INCREASE_CONTRAST; doo->color_flags |= COLOR_INCREASE_CONTRAST;

View File

@ -20,6 +20,7 @@ struct active_link_options {
unsigned int bold:1; unsigned int bold:1;
unsigned int invert:1; unsigned int invert:1;
struct active_link_options_colors color; 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 /** This mostly acts as a option cache so rendering will be faster. However it

View File

@ -166,7 +166,7 @@ get_link_cursor_offset(struct document_view *doc_view, struct link *link)
/** Initialise a static template character with the colour and attributes /** Initialise a static template character with the colour and attributes
* appropriate for an active link and return that character. */ * appropriate for an active link and return that character. */
static inline struct screen_char * 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; struct document_options *doc_opts;
static struct screen_char template_; static struct screen_char template_;
@ -188,8 +188,13 @@ init_link_drawing(struct document_view *doc_view, struct link *link, int invert)
template_.attr |= SCREEN_ATTR_BOLD; template_.attr |= SCREEN_ATTR_BOLD;
if (doc_opts->active_link.enable_color) { if (doc_opts->active_link.enable_color) {
colors.foreground = doc_opts->active_link.color.foreground; if (input) {
colors.background = doc_opts->active_link.color.background; 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 { } else {
colors.foreground = link->color.foreground; colors.foreground = link->color.foreground;
colors.background = link->color.background; colors.background = link->color.background;
@ -232,6 +237,7 @@ draw_current_link(struct session *ses, struct document_view *doc_view)
struct link *link; struct link *link;
int cursor_offset; int cursor_offset;
int xpos, ypos; int xpos, ypos;
int invert, input;
int i; int i;
assert(term && doc_view && doc_view->vs); assert(term && doc_view && doc_view->vs);
@ -243,8 +249,9 @@ draw_current_link(struct session *ses, struct document_view *doc_view)
link = get_current_link(doc_view); link = get_current_link(doc_view);
if (!link) return; if (!link) return;
i = !link_is_textinput(link) || ses->insert_mode == INSERT_MODE_OFF; invert = !link_is_textinput(link) || ses->insert_mode == INSERT_MODE_OFF;
template_ = init_link_drawing(doc_view, link, i); input = ses->insert_mode == INSERT_MODE_ON;
template_ = init_link_drawing(doc_view, link, invert, input);
if (!template_) return; if (!template_) return;
xpos = doc_view->box.x - doc_view->vs->x; xpos = doc_view->box.x - doc_view->vs->x;