From d3823e1bb1e3aed9d4bf2859fcb2f708bf59d018 Mon Sep 17 00:00:00 2001 From: Charlie Gordon Date: Wed, 9 Apr 2008 16:51:30 +0000 Subject: [PATCH] fixed shell mode: use ptsname instead of ptsname_r disabled 16 color modes in cygwin, some issues remain if shell is started --- shell.c | 10 ++++++++++ tty.c | 17 +++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/shell.c b/shell.c index d030385..73d2235 100644 --- a/shell.c +++ b/shell.c @@ -96,8 +96,18 @@ static int get_pty(char *tty_str, int size) /* First try Unix98 pseudo tty master */ if ((fd = open("/dev/ptmx", O_RDWR)) >= 0) { +#ifdef CONFIG_CYGWIN + const char *name = ptsname(fd); + + if (name) { + pstrcpy(tty_str, size, name); + if (!grantpt(fd) && !unlockpt(fd)) + return fd; + } +#else if (!ptsname_r(fd, tty_str, size) && !grantpt(fd) && !unlockpt(fd)) return fd; +#endif close(fd); } /* then try BSD pseudo tty pre-created pairs */ diff --git a/tty.c b/tty.c index b134784..b4d3812 100644 --- a/tty.c +++ b/tty.c @@ -505,7 +505,6 @@ static void tty_read_handler(void *opaque) } } -#if 0 unsigned int const tty_full_colors[8] = { QERGB(0x00, 0x00, 0x00), QERGB(0xff, 0x00, 0x00), @@ -516,7 +515,6 @@ unsigned int const tty_full_colors[8] = { QERGB(0x00, 0xff, 0xff), QERGB(0xff, 0xff, 0xff), }; -#endif unsigned int const tty_putty_colors[256] = { QERGB(0x00, 0x00, 0x00), @@ -788,9 +786,16 @@ unsigned int const tty_putty_colors[256] = { #endif }; +#ifdef CONFIG_CYGWIN +int tty_use_bold_as_bright = 1; +unsigned int const *tty_bg_colors = tty_full_colors; +int tty_bg_colors_count = 8; +#else +int tty_use_bold_as_bright = 0; unsigned int const *tty_bg_colors = tty_putty_colors; -unsigned int const *tty_fg_colors = tty_putty_colors; int tty_bg_colors_count = 16; +#endif +unsigned int const *tty_fg_colors = tty_putty_colors; int tty_fg_colors_count = 16; static inline int color_dist(unsigned int c1, unsigned c2) @@ -1101,13 +1106,13 @@ static void tty_term_flush(QEditScreen *s) /* should use array of strings */ bgcolor = TTYCHAR_GETBG(cc); TTY_FPRINTF(s->STDOUT, "\033[%dm", - bgcolor >= 8 ? 100 + bgcolor - 8 : + bgcolor > 7 ? 100 + bgcolor - 8 : 40 + bgcolor); } if (fgcolor != (int)TTYCHAR_GETFG(cc) && ch != ' ') { fgcolor = TTYCHAR_GETFG(cc); /* should use array of strings */ - if (0) { + if (tty_use_bold_as_bright) { /* use bold for high color */ TTY_FPRINTF(s->STDOUT, "\033[%dm", (fgcolor > 7) ? 1 : 22); @@ -1115,7 +1120,7 @@ static void tty_term_flush(QEditScreen *s) 30 + (fgcolor & 7)); } else { TTY_FPRINTF(s->STDOUT, "\033[%dm", - fgcolor >= 8 ? 90 + fgcolor - 8 : + fgcolor > 8 ? 90 + fgcolor - 8 : 30 + fgcolor); } }