diff options
author | Nalin Dahyabhai <nalin@src.gnome.org> | 2002-07-16 19:31:16 +0000 |
---|---|---|
committer | Nalin Dahyabhai <nalin@src.gnome.org> | 2002-07-16 19:31:16 +0000 |
commit | 38d95c7257845a9eb875692a1f2caaf5e628630b (patch) | |
tree | 06e1d7ed13446ea507e5b1bc39dac735f2731d42 | |
parent | a84fc373e7868673715a4ef9ebec2165300cda16 (diff) |
Guess at an appropriate bold version of the foreground color instead ofvte_0_4_9
* src/vte.c (vte_terminal_set_colors): Guess at an appropriate bold version of
the foreground color instead of hard-coding in a default.
* src/vte.c, src/vte.h (vte_terminal_set_color_bold): Add.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/vte.c | 63 | ||||
-rw-r--r-- | src/vte.h | 4 | ||||
-rw-r--r-- | src/vteapp.c | 4 | ||||
-rw-r--r-- | vte.spec | 1 |
6 files changed, 74 insertions, 5 deletions
@@ -1,4 +1,9 @@ 2002-07-16 nalin + * src/vte.c (vte_terminal_set_colors): Guess at an appropriate bold + version of the foreground color instead of hard-coding in a default. + * src/vte.c, src/vte.h (vte_terminal_set_color_bold): Add. + +2002-07-16 nalin * src/trie.c: Correctly check for g_iconv_open() failure. * src/vte.c (vte_terminal_set_encoding): Try to give a meaningful error when g_iconv_open() fails, even though we're screwed. diff --git a/src/Makefile.am b/src/Makefile.am index aeec9c9..56abc64 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,7 +30,7 @@ libvte_la_SOURCES = \ vteaccess.h libvte_la_LIBADD = @LIBS@ @XFT_LIBS@ @GTK_LIBS@ @X_LIBS@ -libvte_la_LDFLAGS = -version-info 2:0:1 +libvte_la_LDFLAGS = -version-info 3:0:2 CLEANFILES = marshal.c marshal.h @@ -4740,6 +4740,62 @@ vte_terminal_set_color_int(VteTerminal *terminal, int entry, #endif } +static void +vte_terminal_generate_bold(const struct vte_palette_entry *foreground, + const struct vte_palette_entry *background, + double factor, + GdkColor *bold) +{ + double fy, fcb, fcr, by, bcb, bcr, r, g, b; + g_return_if_fail(foreground != NULL); + g_return_if_fail(background != NULL); + g_return_if_fail(bold != NULL); + fy = 0.2990 * foreground->red + + 0.5870 * foreground->green + + 0.1140 * foreground->blue; + fcb = -0.1687 * foreground->red + + -0.3313 * foreground->green + + 0.5000 * foreground->blue; + fcr = 0.5000 * foreground->red + + -0.4187 * foreground->green + + -0.0813 * foreground->blue; + by = 0.2990 * background->red + + 0.5870 * background->green + + 0.1140 * background->blue; + bcb = -0.1687 * background->red + + -0.3313 * background->green + + 0.5000 * background->blue; + bcr = 0.5000 * background->red + + -0.4187 * background->green + + -0.0813 * background->blue; + fy = factor * fy - by; + fcb = factor * fcb - bcb; + fcr = factor * fcr - bcr; + r = fy + 1.402 * fcr; + g = fy + 0.34414 * fcb - 0.71414 * fcr; + b = fy + 1.722 * fcb; +#ifdef VTE_DEBUG + if (vte_debug_on(VTE_DEBUG_MISC)) { + fprintf(stderr, "Calculated bold = (%lf,%lf,%lf)", r, g, b); + } +#endif + bold->red = CLAMP(r, 0, 0xffff); + bold->green = CLAMP(g, 0, 0xffff); + bold->blue = CLAMP(b, 0, 0xffff); +#ifdef VTE_DEBUG + if (vte_debug_on(VTE_DEBUG_MISC)) { + fprintf(stderr, "= (%04x,%04x,%04x).\n", + bold->red, bold->green, bold->blue); + } +#endif +} + +/* Set the bold foreground color. */ +void +vte_terminal_set_color_bold(VteTerminal *terminal, const GdkColor *bold) +{ + vte_terminal_set_color_int(terminal, VTE_BOLD_FG, bold); +} /* Set the foreground color. */ void @@ -4809,9 +4865,10 @@ vte_terminal_set_colors(VteTerminal *terminal, } break; case VTE_BOLD_FG: - color.red = 0xffff; - color.blue = 0xffff; - color.green = 0xffff; + vte_terminal_generate_bold(&terminal->pvt->palette[VTE_DEF_FG], + &terminal->pvt->palette[VTE_DEF_BG], + 1.8, + &color); break; case 0 + 0: case 0 + 1: @@ -143,10 +143,12 @@ void vte_terminal_set_scroll_on_keystroke(VteTerminal *terminal, gboolean scroll); /* Set the color scheme. */ +void vte_terminal_set_color_bold(VteTerminal *terminal, + const GdkColor *bold); void vte_terminal_set_color_foreground(VteTerminal *terminal, const GdkColor *fore); void vte_terminal_set_color_background(VteTerminal *terminal, - const GdkColor *fore); + const GdkColor *back); void vte_terminal_set_colors(VteTerminal *terminal, const GdkColor *foreground, const GdkColor *background, diff --git a/src/vteapp.c b/src/vteapp.c index 97691c5..da0d034 100644 --- a/src/vteapp.c +++ b/src/vteapp.c @@ -96,6 +96,7 @@ main(int argc, char **argv) const char *terminal = NULL; const char *command = NULL; int opt; + GdkColor fore, back; const char *usage = "Usage: %s " "[ [-B image] | [-T] ] " "[-a] " @@ -103,6 +104,8 @@ main(int argc, char **argv) "[-c command] " "[-f font] " "[-t terminaltype]\n"; + back.red = back.green = back.blue = 0xffff; + fore.red = fore.green = fore.blue = 0x7000; /* Parse some command-line options. */ while ((opt = getopt(argc, argv, "B:Tabc:f:ht:")) != -1) { switch (opt) { @@ -190,6 +193,7 @@ main(int argc, char **argv) vte_terminal_set_background_transparent(VTE_TERMINAL(widget), TRUE); } + vte_terminal_set_colors(VTE_TERMINAL(widget), &fore, &back, NULL, 0); if (terminal != NULL) { vte_terminal_set_emulation(VTE_TERMINAL(widget), terminal); } @@ -59,6 +59,7 @@ make install DESTDIR=$RPM_BUILD_ROOT %changelog * Tue Jul 16 2002 Nalin Dahyabhai <nalin@redhat.com> 0.4.9-1 - check for iconv failures properly and report them more aggressively +- guess at a proper default bold color (#68965) * Mon Jul 15 2002 Nalin Dahyabhai <nalin@redhat.com> - cosmetic fixes |