ui/curses: Fix monitor color with -curses when 256 colors
PATCH v2 1/3 ui/curses: Fix monitor color with -curses when 256 colors
If TERM=xterm-256color, COLOR_PAIRS==256 and monitor passes chtype like 0x74xx. Then, the code uses uninitialized color pair. As result, monitor uses black for both of fg and bg color, i.e. terminal is filled by black.
To fix, this initialize above than 64 with default color (fg=white,bg=black).
FIXME: on 256 color, curses may be possible better vga color emulation.
---
ui/curses.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
ui/curses.c renamed from ui/curses.c~support-curses-256color +6 -1
@@ -341,8 +341,13 @@ static void curses_setup(void)nodelay (stdscr, TRUE);nonl ();keypad (stdscr, TRUE);start_color ();raw ();scrollok (stdscr, FALSE); -for (i =0 ; i <64 ; i ++) +for (i =0 ; i <64 ; i++) {init_pair (i, colour_default[i &7 ], colour_default[i >>3 ]); + } +/* Set default color for more than 64. (monitor uses 0x74xx for example) */ +for (i =64 ; i <COLOR_PAIRS ; i++) { +init_pair (i,COLOR_WHITE ,COLOR_BLACK ); + } }static void curses_keyboard_setup (void )
_
PATCH v2 2/3 ui/curses: Support line graphics chars on -curses mode
This converts vga code to curses code in console_write_bh().
With this changes, we can see line graphics (for example, dialog uses) correctly.
---
include/ui/console.h | 12 +++++++++++- ui/curses.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-)
include/ui/console.h renamed from include/ui/console.h~support-curses-border +11 -1
@@ -284,13 +284,23 @@ static inline pixman_format_code_t surfa#ifdef CONFIG_CURSES #include <curses.h> typedef chtype console_ch_t ; +extern chtype vga_to_curses[];#else typedef unsigned long console_ch_t ;#endif static inline void console_write_ch (console_ch_t *dest,uint32_t ch) { -if (!(ch &0xff )) +uint8_t c = ch; +#ifdef CONFIG_CURSES +if (vga_to_curses[c]) { + ch &= ~(console_ch_t )0xff ; + ch |= vga_to_curses[c]; + } +#else +if (c =='\0' ) { ch |=' ' ; + } +#endif *dest = ch; }
ui/curses.c renamed from ui/curses.c~support-curses-border +44 -0
56 lines not on this page · raw message
_
PATCH v2 3/3 ui/curses: Fix pageup/pagedown on -curses
In reply to OGAWA HirofumiCurrent KEY_NPAGE/KEY_PPAGE handling is broken on -curses. Those uses "GREY", but "KEY_MASK" masked out "GREY".
To fix, we have to use correct mask value - SCANCODE_KEYMASK.
Then, this adds support of "shift + pageup/pagedown". With this, -curses mode can use scroll-up/down as usual like other display modes.
---
ui/curses_keys.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
ui/curses_keys.h renamed from ui/curses_keys.h~support-curses-pageup +6 -2
@@ -29,8 +29,7 @@#include "keymaps.h" -#define KEY_RELEASE 0x80 -#define KEY_MASK 0x7f +#define KEY_MASK SCANCODE_KEYMASK#define GREY_CODE 0xe0#define GREY SCANCODE_GREY#define SHIFT_CODE 0x2a
@@ -60,6 +59,8 @@ static const int curses2keysym[CURSES_KE ['\n'] = KEY_ENTER, [27] = 27, [KEY_BTAB] = '\t' | KEYSYM_SHIFT, + [KEY_SPREVIOUS] = KEY_PPAGE | KEYSYM_SHIFT, + [KEY_SNEXT] = KEY_NPAGE | KEYSYM_SHIFT, };static const int curses2keycode[CURSES_KEYS ] = {
@@ -149,6 +150,9 @@ static const int curses2keycode[CURSES_K [KEY_IC] = 82 | GREY, /* Insert */ [KEY_DC] = 83 | GREY, /* Delete */ + [KEY_SPREVIOUS] = 73 | GREY | SHIFT, /* Shift + Page Up */ + [KEY_SNEXT] = 81 | GREY | SHIFT, /* Shift + Page Down */ + ['!'] = 2 | SHIFT, ['@'] = 3 | SHIFT, ['#'] = 4 | SHIFT,
_