Copyright © 2006 Pierre Habouzit
*/
-#include <assert.h>
-#include <ctype.h>
-#include <errno.h>
+#include <lib-ui/lib-ui.h>
+
#include <fcntl.h>
#include <pty.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <sys/ioctl.h>
-#include <sys/types.h>
#include <termios.h>
-#include <wchar.h>
#include "madtty.h"
[KEY_PPAGE] = "\e[5~",
[KEY_NPAGE] = "\e[6~",
[KEY_SUSPEND] = "\x1A", /* Ctrl+Z gets mapped to this */
- [KEY_F(1)] = "\e[[A",
- [KEY_F(2)] = "\e[[B",
- [KEY_F(3)] = "\e[[C",
- [KEY_F(4)] = "\e[[D",
- [KEY_F(5)] = "\e[[E",
+ [KEY_F(1)] = "\e[11~",
+ [KEY_F(2)] = "\e[12~",
+ [KEY_F(3)] = "\e[13~",
+ [KEY_F(4)] = "\e[14~",
+ [KEY_F(5)] = "\e[15~",
[KEY_F(6)] = "\e[17~",
[KEY_F(7)] = "\e[18~",
[KEY_F(8)] = "\e[19~",
[KEY_F(9)] = "\e[20~",
[KEY_F(10)] = "\e[21~",
+ [KEY_F(11)] = "\e[23~",
+ [KEY_F(12)] = "\e[24~",
+ [KEY_F(13)] = "\e[25~",
+ [KEY_F(14)] = "\e[26~",
+ [KEY_F(15)] = "\e[28~",
+ [KEY_F(16)] = "\e[29~",
+ [KEY_F(17)] = "\e[31~",
+ [KEY_F(18)] = "\e[32~",
+ [KEY_F(19)] = "\e[33~",
+ [KEY_F(20)] = "\e[34~",
};
static void t_row_set(t_row_t *row, int start, int len, uint16_t attr)
void madtty_init_colors(void)
{
- if (COLORS > 8) {
+ if (COLOR_PAIRS > 64) {
use_default_colors();
- assume_default_colors(-1, -1);
has_default = 1;
for (int bg = -1; bg < 8; bg++) {
}
}
} else {
+ int use_default = use_default_colors() == OK;
for (int bg = 0; bg < 8; bg++) {
for (int fg = 0; fg < 8; fg++) {
- init_pair((7 - fg) * 8 + bg, fg, bg);
+ if (use_default) {
+ init_pair((7 - fg) * 8 + bg,
+ fg == COLOR_WHITE ? -1 : fg,
+ bg == COLOR_BLACK ? -1 : bg);
+ } else {
+ init_pair((7 - fg) * 8 + bg, fg, bg);
+ }
}
}
}
int madtty_color_pair(int fg, int bg)
{
- if (fg < -1)
- fg = -1;
- if (bg < -1)
- bg = -1;
- return COLOR_PAIR(has_default ? (fg + 1) * 16 + bg + 1 : (7 - fg) * 8 + bg);
+ if (has_default) {
+ if (fg < -1)
+ fg = -1;
+ if (bg < -1)
+ bg = -1;
+ return COLOR_PAIR((fg + 1) * 16 + bg + 1);
+ }
+ if (fg < 0)
+ fg = COLOR_WHITE;
+ if (bg < 0)
+ bg = COLOR_BLACK;
+ return COLOR_PAIR((7 - fg) * 8 + bg);
}