read terminfo entries for keypad #78

pull/85/head
nick black 5 years ago committed by Nick Black
parent 6a5c21cacd
commit 4cc0ce037d

@ -474,3 +474,4 @@ to implement".
* [Unicode 12.1 Full Emoji List](https://unicode.org/emoji/charts/full-emoji-list.html)
* [Unicode Standard Annex #29 Text Segmenation](http://www.unicode.org/reports/tr29)
* [Unicode Standard Annex #15 Normalization Forms](https://unicode.org/reports/tr15/)
* [The TTY demystified](http://www.linusakesson.net/programming/tty/)

@ -18,6 +18,8 @@
#include "version.h"
#include "egcpool.h"
#define ESC "\x1b"
// A plane is memory for some rectilinear virtual window, plus current cursor
// state for that window. A notcurses context describes a single terminal, and
// has a z-order of planes (I see no advantage to maintaining a poset, and we
@ -81,6 +83,15 @@ typedef struct notcurses {
char* italoff; // CELL_STYLE_ITALIC (disable)
char* smkx; // enter keypad transmit mode (keypad_xmit)
char* rmkx; // leave keypad transmit mode (keypad_local)
// special keys
char* left; // kcub1
char* right; // kcuf1
char* up; // kcuu1
char* down; // kcud1
char* npage; // knp
char* ppage; // kpp
struct termios tpreserved; // terminal state upon entry
bool RGBflag; // terminfo-reported "RGB" flag for 24bpc directcolor
ncplane* top; // the contents of our topmost plane (initially entire screen)
@ -527,6 +538,12 @@ interrogate_terminfo(notcurses* nc, const notcurses_options* opts){
term_verify_seq(&nc->italoff, "ritm");
term_verify_seq(&nc->op, "op");
term_verify_seq(&nc->clear, "clear");
term_verify_seq(&nc->left, "kcub1");
term_verify_seq(&nc->right, "kcuf1");
term_verify_seq(&nc->up, "kcuu1");
term_verify_seq(&nc->down, "kcud1");
term_verify_seq(&nc->npage, "knp");
term_verify_seq(&nc->ppage, "kpp");
// Some terminals cannot combine certain styles with colors. Don't advertise
// support for the style in that case.
int nocolor_stylemask = tigetnum("ncv");
@ -697,7 +714,7 @@ int ncplane_fg_rgb8(ncplane* n, int r, int g, int b){
// 3 for foreground, 4 for background, ugh FIXME
static int
term_esc_rgb(FILE* out, int esc, unsigned r, unsigned g, unsigned b){
#define RGBESC1 "\x1b["
#define RGBESC1 ESC "["
#define RGBESC2 "8;2;"
// rrr;ggg;bbbm
char rgbesc[] = RGBESC1 " " RGBESC2 " ";
@ -970,6 +987,7 @@ int notcurses_render(notcurses* nc){
}
uint32_t curattr = 0; // current attributes set (does not include colors)
term_emit(nc->clear, out, false);
unsigned lastr, lastg, lastb;
for(y = 0 ; y < nc->stdscr->leny ; ++y){
// FIXME previous line could have ended halfway through multicol. what happens?
// FIXME also must explicitly move to next line if we're to deal with
@ -978,8 +996,6 @@ int notcurses_render(notcurses* nc){
unsigned r, g, b, br, bg, bb;
const ncplane* p;
const cell* c = visible_cell(nc, y, x, &p);
assert(c);
assert(p);
// we allow these to be set distinctly, but terminfo only supports using
// them both via the 'op' capability. unless we want to generate the 'op'
// escapes ourselves, if either is set to default, we first send op, and

@ -32,7 +32,9 @@ class CellTest : public :: testing::Test {
TEST_F(CellTest, SetStyles) {
cell c;
int dimy, dimx;
memset(&c, 0, sizeof(c));
notcurses_term_dim_yx(nc_, &dimy, &dimx);
cell_styles_set(&c, CELL_STYLE_ITALIC);
ASSERT_EQ(1, cell_load(n_, &c, "s"));
EXPECT_EQ(0, ncplane_fg_rgb8(n_, 255, 255, 255));
@ -41,6 +43,12 @@ TEST_F(CellTest, SetStyles) {
ncplane_cursor_yx(n_, &y, &x);
EXPECT_EQ(1, x);
EXPECT_EQ(0, y);
for(y = 0 ; y < dimy ; ++y){
ncplane_cursor_move_yx(n_, y, 0);
for(x = 0 ; x < dimx ; ++x){
EXPECT_EQ(1, ncplane_putc(n_, &c));
}
}
EXPECT_EQ(0, notcurses_render(nc_));
}

Loading…
Cancel
Save