On 2/4/2012 9:56 PM, Peter Lustig wrote:
On 1/22/2012 3:44 AM, Nicholas Marriott wrote:
IIRC I sent some comments and heard nothing more.
On Sat, Jan 21, 2012 at 10:50:04PM -0500, Peter Lustig wrote:
Sorry to resurrect an old thread.
Does anyone know what became of this patch? I found no more discussion
of it after this thread, and see no traces of it in the trunk.
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3,
MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users
I'd like to pick up where Stephen Prater left off on this effort.
Here is a patch to "tty.c" that resolves the original problem while
incorporating the recommendations you made back then. Let me know if
there are any issues with it, and I'll be glad to fix them.
My bad. Just found a bug in the patch I submitted: on line 156
'GRID_FLAG_FG256' should be 'GRID_FLAG_BG256'. Here is the fixed version.
--- tty.c.0 2012-01-29 18:38:30.591868756 -0500
+++ tty.c 2012-02-05 17:45:55.450973222 -0500
@@ -31,15 +31,12 @@
#include "tmux.h"
void tty_read_callback(struct bufferevent *, void *);
void tty_error_callback(struct bufferevent *, short, void *);
-int tty_try_256(struct tty *, u_char, const char *);
-int tty_try_88(struct tty *, u_char, const char *);
-
void tty_colours(struct tty *, const struct grid_cell *);
void tty_check_fg(struct tty *, struct grid_cell *);
void tty_check_bg(struct tty *, struct grid_cell *);
void tty_colours_fg(struct tty *, const struct grid_cell *);
void tty_colours_bg(struct tty *, const struct grid_cell *);
@@ -1391,29 +1388,31 @@
tty_check_fg(struct tty *tty, struct grid_cell *gc)
{
u_int colours;
/* Is this a 256-colour colour? */
if (gc->flags & GRID_FLAG_FG256) {
- /* And not a 256 colour mode? */
- if (!(tty->term->flags & TERM_88COLOURS) &&
- !(tty->term_flags & TERM_88COLOURS) &&
- !(tty->term->flags & TERM_256COLOURS) &&
- !(tty->term_flags & TERM_256COLOURS)) {
+ /* And an 88-colour mode? */
+ if ((tty->term->flags & TERM_88COLOURS) ||
+ (tty->term_flags & TERM_88COLOURS)) {
+ gc->fg = colour_256to88(gc->fg);
+ /* Or a 16-colour mode? */
+ } else if (!(tty->term->flags & TERM_256COLOURS) &&
+ !(tty->term_flags & TERM_256COLOURS)) {
gc->fg = colour_256to16(gc->fg);
if (gc->fg & 8) {
gc->fg &= 7;
gc->attr |= GRID_ATTR_BRIGHT;
} else
gc->attr &= ~GRID_ATTR_BRIGHT;
gc->flags &= ~GRID_FLAG_FG256;
}
return;
}
- /* Is this an aixterm colour? */
+ /* Else, is this an aixterm colour and an 8-colour mode? */
colours = tty_term_number(tty->term, TTYC_COLORS);
if (gc->fg >= 90 && gc->fg <= 97 && colours < 16) {
gc->fg -= 90;
gc->attr |= GRID_ATTR_BRIGHT;
}
}
@@ -1422,31 +1421,32 @@
tty_check_bg(struct tty *tty, struct grid_cell *gc)
{
u_int colours;
/* Is this a 256-colour colour? */
if (gc->flags & GRID_FLAG_BG256) {
- /*
- * And not a 256 colour mode? Translate to 16-colour
+ /* And an 88-colour mode? */
+ if ((tty->term->flags & TERM_88COLOURS) ||
+ (tty->term_flags & TERM_88COLOURS)) {
+ gc->bg = colour_256to88(gc->bg);
+ /* Or a 16-colour mode? Translate to 16-colour
* palette. Bold background doesn't exist portably, so just
* discard the bold bit if set.
*/
- if (!(tty->term->flags & TERM_88COLOURS) &&
- !(tty->term_flags & TERM_88COLOURS) &&
- !(tty->term->flags & TERM_256COLOURS) &&
- !(tty->term_flags & TERM_256COLOURS)) {
+ } else if (!(tty->term->flags & TERM_256COLOURS) &&
+ !(tty->term_flags & TERM_256COLOURS)) {
gc->bg = colour_256to16(gc->bg);
if (gc->bg & 8)
gc->bg &= 7;
gc->attr &= ~GRID_ATTR_BRIGHT;
gc->flags &= ~GRID_FLAG_BG256;
}
return;
}
- /* Is this an aixterm colour? */
+ /* Else, is this an aixterm colour and an 8-colour mode? */
colours = tty_term_number(tty->term, TTYC_COLORS);
if (gc->bg >= 90 && gc->bg <= 97 && colours < 16) {
gc->bg -= 90;
gc->attr |= GRID_ATTR_BRIGHT;
}
}
@@ -1455,34 +1455,21 @@
tty_colours_fg(struct tty *tty, const struct grid_cell *gc)
{
struct grid_cell *tc = &tty->cell;
u_char fg = gc->fg;
char s[32];
- /* Is this a 256-colour colour? */
- if (gc->flags & GRID_FLAG_FG256) {
- /* Try as 256 colours or translating to 88. */
- if (tty_try_256(tty, fg, "38") == 0)
- goto save_fg;
- if (tty_try_88(tty, fg, "38") == 0)
- goto save_fg;
- /* Else already handled by tty_check_fg. */
- return;
- }
-
/* Is this an aixterm bright colour? */
- if (fg >= 90 && fg <= 97) {
+ if (!(gc->flags & GRID_FLAG_FG256) &&
+ (fg >= 90 && fg <= 97)) {
xsnprintf(s, sizeof s, "\033[%dm", fg);
tty_puts(tty, s);
- goto save_fg;
- }
-
/* Otherwise set the foreground colour. */
- tty_putcode1(tty, TTYC_SETAF, fg);
+ } else
+ tty_putcode1(tty, TTYC_SETAF, fg);
-save_fg:
/* Save the new values in the terminal current cell. */
tc->fg = fg;
tc->flags &= ~GRID_FLAG_FG256;
tc->flags |= gc->flags & GRID_FLAG_FG256;
}
@@ -1490,73 +1477,30 @@
tty_colours_bg(struct tty *tty, const struct grid_cell *gc)
{
struct grid_cell *tc = &tty->cell;
u_char bg = gc->bg;
char s[32];
- /* Is this a 256-colour colour? */
- if (gc->flags & GRID_FLAG_BG256) {
- /* Try as 256 colours or translating to 88. */
- if (tty_try_256(tty, bg, "48") == 0)
- goto save_bg;
- if (tty_try_88(tty, bg, "48") == 0)
- goto save_bg;
- /* Else already handled by tty_check_bg. */
- return;
- }
-
/* Is this an aixterm bright colour? */
- if (bg >= 90 && bg <= 97) {
+ if (!(gc->flags & GRID_FLAG_BG256) &&
+ (bg >= 90 && bg <= 97)) {
/* 16 colour terminals or above only. */
if (tty_term_number(tty->term, TTYC_COLORS) >= 16) {
xsnprintf(s, sizeof s, "\033[%dm", bg + 10);
tty_puts(tty, s);
- goto save_bg;
- }
- bg -= 90;
- /* no such thing as a bold background */
- }
-
+ } else
+ bg -= 90; /* no such thing as a bold background */
/* Otherwise set the background colour. */
- tty_putcode1(tty, TTYC_SETAB, bg);
+ } else
+ tty_putcode1(tty, TTYC_SETAB, bg);
-save_bg:
/* Save the new values in the terminal current cell. */
tc->bg = bg;
tc->flags &= ~GRID_FLAG_BG256;
tc->flags |= gc->flags & GRID_FLAG_BG256;
}
-int
-tty_try_256(struct tty *tty, u_char colour, const char *type)
-{
- char s[32];
-
- if (!(tty->term->flags & TERM_256COLOURS) &&
- !(tty->term_flags & TERM_256COLOURS))
- return (-1);
-
- xsnprintf(s, sizeof s, "\033[%s;5;%hhum", type, colour);
- tty_puts(tty, s);
- return (0);
-}
-
-int
-tty_try_88(struct tty *tty, u_char colour, const char *type)
-{
- char s[32];
-
- if (!(tty->term->flags & TERM_88COLOURS) &&
- !(tty->term_flags & TERM_88COLOURS))
- return (-1);
- colour = colour_256to88(colour);
-
- xsnprintf(s, sizeof s, "\033[%s;5;%hhum", type, colour);
- tty_puts(tty, s);
- return (0);
-}
-
void
tty_bell(struct tty *tty)
{
tty_putcode(tty, TTYC_BEL);
}
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users