diff --git a/README.md b/README.md index 49322e422..6086bfa15 100644 --- a/README.md +++ b/README.md @@ -981,45 +981,42 @@ int cell_duplicate(struct ncplane* n, cell* targ, const cell* c); // Release resources held by the cell 'c'. void cell_release(struct ncplane* n, cell* c); -#define CELL_STYLE_SHIFT 16u #define CELL_STYLE_MASK 0xffff0000ul -#define CELL_ALPHA_MASK 0x0000fffful -// these are used for the style bitfield *after* it is shifted -#define CELL_STYLE_STANDOUT 0x0001u -#define CELL_STYLE_UNDERLINE 0x0002u -#define CELL_STYLE_REVERSE 0x0004u -#define CELL_STYLE_BLINK 0x0008u -#define CELL_STYLE_DIM 0x0010u -#define CELL_STYLE_BOLD 0x0020u -#define CELL_STYLE_INVIS 0x0040u -#define CELL_STYLE_PROTECT 0x0080u -#define CELL_STYLE_ITALIC 0x0100u +#define CELL_STYLE_STANDOUT 0x00800000ul +#define CELL_STYLE_UNDERLINE 0x00400000ul +#define CELL_STYLE_REVERSE 0x00200000ul +#define CELL_STYLE_BLINK 0x00100000ul +#define CELL_STYLE_DIM 0x00080000ul +#define CELL_STYLE_BOLD 0x00040000ul +#define CELL_STYLE_INVIS 0x00020000ul +#define CELL_STYLE_PROTECT 0x00010000ul +#define CELL_STYLE_ITALIC 0x01000000ul + // Set the specified style bits for the cell 'c', whether they're actively // supported or not. static inline void cell_styles_set(cell* c, unsigned stylebits){ - c->attrword = (c->attrword & ~CELL_STYLE_MASK) | - ((stylebits & 0xffff) << 16u); + c->attrword = (c->attrword & ~CELL_STYLE_MASK) | ((stylebits & CELL_STYLE_MASK)); } -// Get the style bits, shifted over into the LSBs. +// Extract the style bits from the cell's attrword. static inline unsigned cell_styles(const cell* c){ - return (c->attrword & CELL_STYLE_MASK) >> 16u; + return c->attrword & CELL_STYLE_MASK; } // Add the specified styles (in the LSBs) to the cell's existing spec, whether // they're actively supported or not. static inline void cell_styles_on(cell* c, unsigned stylebits){ - c->attrword |= ((stylebits & 0xffff) << 16u); + c->attrword |= (stylebits & CELL_STYLE_MASK; } // Remove the specified styles (in the LSBs) from the cell's existing spec. static inline void cell_styles_off(cell* c, unsigned stylebits){ - c->attrword &= ~((stylebits & 0xffff) << 16u); + c->attrword &= ~(stylebits & CELL_STYLE_MASK); } // does the cell contain an East Asian Wide codepoint? diff --git a/include/notcurses.h b/include/notcurses.h index 08879b2a0..74f62e3af 100644 --- a/include/notcurses.h +++ b/include/notcurses.h @@ -192,6 +192,16 @@ wchar_supppuab_p(wchar_t w){ #define NCKEY_F18 suppuabize(38) #define NCKEY_F19 suppuabize(39) #define NCKEY_F20 suppuabize(40) +#define NCKEY_F21 suppuabize(41) +#define NCKEY_F22 suppuabize(42) +#define NCKEY_F23 suppuabize(43) +#define NCKEY_F24 suppuabize(44) +#define NCKEY_F25 suppuabize(45) +#define NCKEY_F26 suppuabize(46) +#define NCKEY_F27 suppuabize(47) +#define NCKEY_F28 suppuabize(48) +#define NCKEY_F29 suppuabize(49) +#define NCKEY_F30 suppuabize(50) // ... leave room for up to 100 function keys, egads #define NCKEY_ENTER suppuabize(121) #define NCKEY_CLS suppuabize(122) // "clear-screen or erase" @@ -257,7 +267,7 @@ API const struct ncplane* notcurses_stdplane_const(const struct notcurses* nc); API struct ncplane* notcurses_newplane(struct notcurses* nc, int rows, int cols, int yoff, int xoff, void* opaque); -// Returns a 16-bit bitmask in the LSBs of supported curses-style attributes +// Returns a 16-bit bitmask of supported curses-style attributes // (CELL_STYLE_UNDERLINE, CELL_STYLE_BOLD, etc.) The attribute is only // indicated as supported if the terminal can support it together with color. // For more information, see the "ncv" capability in terminfo(5). @@ -640,7 +650,8 @@ channel_get_b(unsigned channel){ // Extract the three 8-bit R/G/B components from a 32-bit channel. static inline unsigned -channel_get_rgb(unsigned channel, unsigned* r, unsigned* g, unsigned* b){ +channel_get_rgb(unsigned channel, unsigned* RESTRICT r, unsigned* RESTRICT g, + unsigned* RESTRICT b){ *r = channel_get_r(channel); *g = channel_get_g(channel); *b = channel_get_b(channel); @@ -1090,44 +1101,41 @@ API int cell_duplicate(struct ncplane* n, cell* targ, const cell* c); // Release resources held by the cell 'c'. API void cell_release(struct ncplane* n, cell* c); -#define CELL_STYLE_SHIFT 16u #define CELL_STYLE_MASK 0xffff0000ul -// these are used for the style bitfield *after* it is shifted -#define CELL_STYLE_STANDOUT 0x0080u -#define CELL_STYLE_UNDERLINE 0x0040u -#define CELL_STYLE_REVERSE 0x0020u -#define CELL_STYLE_BLINK 0x0010u -#define CELL_STYLE_DIM 0x0008u -#define CELL_STYLE_BOLD 0x0004u -#define CELL_STYLE_INVIS 0x0002u -#define CELL_STYLE_PROTECT 0x0001u -#define CELL_STYLE_ITALIC 0x0100u +#define CELL_STYLE_STANDOUT 0x00800000ul +#define CELL_STYLE_UNDERLINE 0x00400000ul +#define CELL_STYLE_REVERSE 0x00200000ul +#define CELL_STYLE_BLINK 0x00100000ul +#define CELL_STYLE_DIM 0x00080000ul +#define CELL_STYLE_BOLD 0x00040000ul +#define CELL_STYLE_INVIS 0x00020000ul +#define CELL_STYLE_PROTECT 0x00010000ul +#define CELL_STYLE_ITALIC 0x01000000ul // Set the specified style bits for the cell 'c', whether they're actively // supported or not. static inline void cell_styles_set(cell* c, unsigned stylebits){ - c->attrword = (c->attrword & ~CELL_STYLE_MASK) | - ((stylebits & 0xffff) << CELL_STYLE_SHIFT); + c->attrword = (c->attrword & ~CELL_STYLE_MASK) | ((stylebits & CELL_STYLE_MASK)); } -// Get the style bits, shifted over into the LSBs. +// Extract the style bits from the cell's attrword. static inline unsigned cell_styles(const cell* c){ - return (c->attrword & CELL_STYLE_MASK) >> CELL_STYLE_SHIFT; + return c->attrword & CELL_STYLE_MASK; } // Add the specified styles (in the LSBs) to the cell's existing spec, whether // they're actively supported or not. static inline void cell_styles_on(cell* c, unsigned stylebits){ - c->attrword |= ((stylebits & 0xffff) << CELL_STYLE_SHIFT); + c->attrword |= (stylebits & CELL_STYLE_MASK); } // Remove the specified styles (in the LSBs) from the cell's existing spec. static inline void cell_styles_off(cell* c, unsigned stylebits){ - c->attrword &= ~((stylebits & 0xffff) << CELL_STYLE_SHIFT); + c->attrword &= ~(stylebits & CELL_STYLE_MASK); } // Use the default color for the foreground. diff --git a/src/input/input.cpp b/src/input/input.cpp index 7feca5685..def083630 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -39,6 +39,24 @@ const char* nckeystr(wchar_t spkey){ case NCKEY_F10: return "F10"; case NCKEY_F11: return "F11"; case NCKEY_F12: return "F12"; + case NCKEY_F13: return "F13"; + case NCKEY_F14: return "F14"; + case NCKEY_F15: return "F15"; + case NCKEY_F16: return "F16"; + case NCKEY_F17: return "F17"; + case NCKEY_F18: return "F18"; + case NCKEY_F19: return "F19"; + case NCKEY_F20: return "F20"; + case NCKEY_F21: return "F21"; + case NCKEY_F22: return "F22"; + case NCKEY_F23: return "F23"; + case NCKEY_F24: return "F24"; + case NCKEY_F25: return "F25"; + case NCKEY_F26: return "F26"; + case NCKEY_F27: return "F27"; + case NCKEY_F28: return "F28"; + case NCKEY_F29: return "F29"; + case NCKEY_F30: return "F30"; case NCKEY_BACKSPACE: return "backspace"; case NCKEY_CENTER: return "center"; case NCKEY_ENTER: return "enter"; diff --git a/src/lib/input.c b/src/lib/input.c index 9f4ed76bb..d4726c2c0 100644 --- a/src/lib/input.c +++ b/src/lib/input.c @@ -256,6 +256,16 @@ int prep_special_keys(notcurses* nc){ { .tinfo = "kf18", .key = NCKEY_F18, }, { .tinfo = "kf19", .key = NCKEY_F19, }, { .tinfo = "kf20", .key = NCKEY_F20, }, + { .tinfo = "kf21", .key = NCKEY_F21, }, + { .tinfo = "kf22", .key = NCKEY_F22, }, + { .tinfo = "kf23", .key = NCKEY_F23, }, + { .tinfo = "kf24", .key = NCKEY_F24, }, + { .tinfo = "kf25", .key = NCKEY_F25, }, + { .tinfo = "kf26", .key = NCKEY_F26, }, + { .tinfo = "kf27", .key = NCKEY_F27, }, + { .tinfo = "kf28", .key = NCKEY_F28, }, + { .tinfo = "kf29", .key = NCKEY_F29, }, + { .tinfo = "kf30", .key = NCKEY_F30, }, { .tinfo = "kent", .key = NCKEY_ENTER, }, { .tinfo = "kclr", .key = NCKEY_CLS, }, { .tinfo = "kc1", .key = NCKEY_DLEFT, }, @@ -280,8 +290,7 @@ int prep_special_keys(notcurses* nc){ continue; } if(seq[0] != ESC){ - fprintf(stderr, "Terminfo's %s is not an escape sequence (%zub)\n", - k->tinfo, strlen(seq)); +//fprintf(stderr, "Terminfo's %s is not an escape sequence (%zub)\n", k->tinfo, strlen(seq)); continue; } //fprintf(stderr, "support for terminfo's %s: %s\n", k->tinfo, seq); diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 10ce3cd7a..6fa4c9587 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -1036,11 +1036,11 @@ term_setstyles(const notcurses* nc, FILE* out, uint32_t* curattr, const cell* c, } int ret = 0; // if only italics changed, don't emit any sgr escapes. xor of current and - // target ought have all 0s in the lower 16 bits if only italics changed. - if((cellattr ^ *curattr) & 0xffffu){ + // target ought have all 0s in the lower 8 bits if only italics changed. + if((cellattr ^ *curattr) & 0x00ff0000ul){ *normalized = true; // FIXME this is pretty conservative // if everything's 0, emit the shorter sgr0 - if(nc->sgr0 && ((cellattr & 0xffff) == 0)){ + if(nc->sgr0 && ((cellattr & CELL_STYLE_MASK) == 0)){ if(term_emit("sgr0", nc->sgr0, out, false) < 0){ ret = -1; } @@ -1555,29 +1555,28 @@ int notcurses_palette_size(const notcurses* nc){ // turn on any specified stylebits void ncplane_styles_on(ncplane* n, unsigned stylebits){ ncplane_lock(n); - n->attrword |= ((stylebits & 0xffff) << 16u); + n->attrword |= (stylebits & CELL_STYLE_MASK); ncplane_unlock(n); } // turn off any specified stylebits void ncplane_styles_off(ncplane* n, unsigned stylebits){ ncplane_lock(n); - n->attrword &= ~((stylebits & 0xffff) << 16u); + n->attrword &= ~(stylebits & CELL_STYLE_MASK); ncplane_unlock(n); } // set the current stylebits to exactly those provided void ncplane_styles_set(ncplane* n, unsigned stylebits){ ncplane_lock(n); - n->attrword = (n->attrword & ~CELL_STYLE_MASK) | - ((stylebits & 0xffff) << 16u); + n->attrword = (n->attrword & ~CELL_STYLE_MASK) | ((stylebits & CELL_STYLE_MASK)); ncplane_unlock(n); } unsigned ncplane_styles(const ncplane* n){ unsigned ret; ncplane_lock(n); - ret = (n->attrword & CELL_STYLE_MASK) >> 16u; + ret = (n->attrword & CELL_STYLE_MASK); ncplane_unlock(n); return ret; }