teken.c revision 221698
1186681Sed/*- 2186681Sed * Copyright (c) 2008-2009 Ed Schouten <ed@FreeBSD.org> 3186681Sed * All rights reserved. 4186681Sed * 5186681Sed * Redistribution and use in source and binary forms, with or without 6186681Sed * modification, are permitted provided that the following conditions 7186681Sed * are met: 8186681Sed * 1. Redistributions of source code must retain the above copyright 9186681Sed * notice, this list of conditions and the following disclaimer. 10186681Sed * 2. Redistributions in binary form must reproduce the above copyright 11186681Sed * notice, this list of conditions and the following disclaimer in the 12186681Sed * documentation and/or other materials provided with the distribution. 13186681Sed * 14186681Sed * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15186681Sed * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16186681Sed * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17186681Sed * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18186681Sed * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19186681Sed * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20186681Sed * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21186681Sed * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22186681Sed * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23186681Sed * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24186681Sed * SUCH DAMAGE. 25186681Sed * 26186681Sed * $FreeBSD: head/sys/teken/teken.c 221698 2011-05-09 16:27:39Z ed $ 27186681Sed */ 28186681Sed 29186681Sed#include <sys/cdefs.h> 30186681Sed#if defined(__FreeBSD__) && defined(_KERNEL) 31186681Sed#include <sys/param.h> 32186681Sed#include <sys/lock.h> 33186681Sed#include <sys/systm.h> 34186681Sed#define teken_assert(x) MPASS(x) 35186681Sed#else /* !(__FreeBSD__ && _KERNEL) */ 36186681Sed#include <sys/types.h> 37186681Sed#include <assert.h> 38206141Sed#include <stdint.h> 39186681Sed#include <stdio.h> 40186681Sed#include <string.h> 41186681Sed#define teken_assert(x) assert(x) 42186681Sed#endif /* __FreeBSD__ && _KERNEL */ 43186681Sed 44221698Sed/* debug messages */ 45221698Sed#define teken_printf(x,...) 46221698Sed 47186681Sed/* Private flags for t_stateflags. */ 48199171Sed#define TS_FIRSTDIGIT 0x0001 /* First numeric digit in escape sequence. */ 49199171Sed#define TS_INSERT 0x0002 /* Insert mode. */ 50199171Sed#define TS_AUTOWRAP 0x0004 /* Autowrap. */ 51199171Sed#define TS_ORIGIN 0x0008 /* Origin mode. */ 52199171Sed#define TS_WRAPPED 0x0010 /* Next character should be printed on col 0. */ 53199171Sed#define TS_8BIT 0x0020 /* UTF-8 disabled. */ 54199171Sed#define TS_CONS25 0x0040 /* cons25 emulation. */ 55199171Sed#define TS_INSTRING 0x0080 /* Inside string. */ 56199171Sed#define TS_CURSORKEYS 0x0100 /* Cursor keys mode. */ 57186681Sed 58186681Sed/* Character that blanks a cell. */ 59186681Sed#define BLANK ' ' 60186681Sed 61197470Sed#include "teken.h" 62197470Sed#include "teken_wcwidth.h" 63197470Sed#include "teken_scs.h" 64197470Sed 65186681Sedstatic teken_state_t teken_state_init; 66186681Sed 67186681Sed/* 68186681Sed * Wrappers for hooks. 69186681Sed */ 70186681Sed 71186681Sedstatic inline void 72186681Sedteken_funcs_bell(teken_t *t) 73186681Sed{ 74186681Sed 75186681Sed t->t_funcs->tf_bell(t->t_softc); 76186681Sed} 77186681Sed 78186681Sedstatic inline void 79186681Sedteken_funcs_cursor(teken_t *t) 80186681Sed{ 81186681Sed 82186681Sed teken_assert(t->t_cursor.tp_row < t->t_winsize.tp_row); 83186681Sed teken_assert(t->t_cursor.tp_col < t->t_winsize.tp_col); 84186681Sed 85186681Sed t->t_funcs->tf_cursor(t->t_softc, &t->t_cursor); 86186681Sed} 87186681Sed 88186681Sedstatic inline void 89186681Sedteken_funcs_putchar(teken_t *t, const teken_pos_t *p, teken_char_t c, 90186681Sed const teken_attr_t *a) 91186681Sed{ 92186681Sed 93186681Sed teken_assert(p->tp_row < t->t_winsize.tp_row); 94186681Sed teken_assert(p->tp_col < t->t_winsize.tp_col); 95186681Sed 96186681Sed t->t_funcs->tf_putchar(t->t_softc, p, c, a); 97186681Sed} 98186681Sed 99186681Sedstatic inline void 100186681Sedteken_funcs_fill(teken_t *t, const teken_rect_t *r, 101186681Sed const teken_char_t c, const teken_attr_t *a) 102186681Sed{ 103186681Sed 104186681Sed teken_assert(r->tr_end.tp_row > r->tr_begin.tp_row); 105186681Sed teken_assert(r->tr_end.tp_row <= t->t_winsize.tp_row); 106186681Sed teken_assert(r->tr_end.tp_col > r->tr_begin.tp_col); 107186681Sed teken_assert(r->tr_end.tp_col <= t->t_winsize.tp_col); 108186681Sed 109186681Sed t->t_funcs->tf_fill(t->t_softc, r, c, a); 110186681Sed} 111186681Sed 112186681Sedstatic inline void 113186681Sedteken_funcs_copy(teken_t *t, const teken_rect_t *r, const teken_pos_t *p) 114186681Sed{ 115186681Sed 116186681Sed teken_assert(r->tr_end.tp_row > r->tr_begin.tp_row); 117186681Sed teken_assert(r->tr_end.tp_row <= t->t_winsize.tp_row); 118186681Sed teken_assert(r->tr_end.tp_col > r->tr_begin.tp_col); 119186681Sed teken_assert(r->tr_end.tp_col <= t->t_winsize.tp_col); 120186681Sed teken_assert(p->tp_row + (r->tr_end.tp_row - r->tr_begin.tp_row) <= t->t_winsize.tp_row); 121186681Sed teken_assert(p->tp_col + (r->tr_end.tp_col - r->tr_begin.tp_col) <= t->t_winsize.tp_col); 122186681Sed 123186681Sed t->t_funcs->tf_copy(t->t_softc, r, p); 124186681Sed} 125186681Sed 126186681Sedstatic inline void 127193184Sedteken_funcs_param(teken_t *t, int cmd, unsigned int value) 128186681Sed{ 129186681Sed 130186681Sed t->t_funcs->tf_param(t->t_softc, cmd, value); 131186681Sed} 132186681Sed 133186681Sedstatic inline void 134186681Sedteken_funcs_respond(teken_t *t, const void *buf, size_t len) 135186681Sed{ 136186681Sed 137186681Sed t->t_funcs->tf_respond(t->t_softc, buf, len); 138186681Sed} 139186681Sed 140186681Sed#include "teken_subr.h" 141186681Sed#include "teken_subr_compat.h" 142186681Sed 143186681Sed/* 144186681Sed * Programming interface. 145186681Sed */ 146186681Sed 147186681Sedvoid 148186681Sedteken_init(teken_t *t, const teken_funcs_t *tf, void *softc) 149186681Sed{ 150186681Sed teken_pos_t tp = { .tp_row = 24, .tp_col = 80 }; 151186681Sed 152186681Sed t->t_funcs = tf; 153186681Sed t->t_softc = softc; 154186681Sed 155186681Sed t->t_nextstate = teken_state_init; 156197117Sed t->t_stateflags = 0; 157197117Sed t->t_utf8_left = 0; 158186681Sed 159186681Sed t->t_defattr.ta_format = 0; 160186681Sed t->t_defattr.ta_fgcolor = TC_WHITE; 161186681Sed t->t_defattr.ta_bgcolor = TC_BLACK; 162186681Sed teken_subr_do_reset(t); 163186681Sed 164186681Sed teken_set_winsize(t, &tp); 165186681Sed} 166186681Sed 167186681Sedstatic void 168186681Sedteken_input_char(teken_t *t, teken_char_t c) 169186681Sed{ 170186681Sed 171197853Sed /* 172197853Sed * There is no support for DCS and OSC. Just discard strings 173197853Sed * until we receive characters that may indicate string 174197853Sed * termination. 175197853Sed */ 176197853Sed if (t->t_stateflags & TS_INSTRING) { 177197853Sed switch (c) { 178197853Sed case '\x1B': 179197853Sed t->t_stateflags &= ~TS_INSTRING; 180197853Sed break; 181197853Sed case '\a': 182197853Sed t->t_stateflags &= ~TS_INSTRING; 183197853Sed return; 184197853Sed default: 185197853Sed return; 186197853Sed } 187197853Sed } 188197853Sed 189186681Sed switch (c) { 190186681Sed case '\0': 191186681Sed break; 192186681Sed case '\a': 193186681Sed teken_subr_bell(t); 194186681Sed break; 195186681Sed case '\b': 196186681Sed teken_subr_backspace(t); 197186681Sed break; 198186681Sed case '\n': 199186681Sed case '\x0B': 200186681Sed teken_subr_newline(t); 201186681Sed break; 202186798Sed case '\x0C': 203186798Sed teken_subr_newpage(t); 204186798Sed break; 205187469Sed case '\x0E': 206197117Sed if (t->t_stateflags & TS_CONS25) 207197117Sed t->t_nextstate(t, c); 208197117Sed else 209197520Sed t->t_curscs = 1; 210187469Sed break; 211187469Sed case '\x0F': 212197117Sed if (t->t_stateflags & TS_CONS25) 213197117Sed t->t_nextstate(t, c); 214197117Sed else 215197520Sed t->t_curscs = 0; 216187469Sed break; 217186681Sed case '\r': 218186681Sed teken_subr_carriage_return(t); 219186681Sed break; 220186681Sed case '\t': 221186681Sed teken_subr_horizontal_tab(t); 222186681Sed break; 223186681Sed default: 224186681Sed t->t_nextstate(t, c); 225186681Sed break; 226186681Sed } 227186681Sed 228186681Sed /* Post-processing assertions. */ 229186681Sed teken_assert(t->t_cursor.tp_row >= t->t_originreg.ts_begin); 230186681Sed teken_assert(t->t_cursor.tp_row < t->t_originreg.ts_end); 231186681Sed teken_assert(t->t_cursor.tp_row < t->t_winsize.tp_row); 232186681Sed teken_assert(t->t_cursor.tp_col < t->t_winsize.tp_col); 233186681Sed teken_assert(t->t_saved_cursor.tp_row < t->t_winsize.tp_row); 234186681Sed teken_assert(t->t_saved_cursor.tp_col < t->t_winsize.tp_col); 235186681Sed teken_assert(t->t_scrollreg.ts_end <= t->t_winsize.tp_row); 236186681Sed teken_assert(t->t_scrollreg.ts_begin < t->t_scrollreg.ts_end); 237186681Sed /* Origin region has to be window size or the same as scrollreg. */ 238186681Sed teken_assert((t->t_originreg.ts_begin == t->t_scrollreg.ts_begin && 239186681Sed t->t_originreg.ts_end == t->t_scrollreg.ts_end) || 240186681Sed (t->t_originreg.ts_begin == 0 && 241186681Sed t->t_originreg.ts_end == t->t_winsize.tp_row)); 242186681Sed} 243186681Sed 244186681Sedstatic void 245186681Sedteken_input_byte(teken_t *t, unsigned char c) 246186681Sed{ 247186681Sed 248186681Sed /* 249186681Sed * UTF-8 handling. 250186681Sed */ 251197117Sed if ((c & 0x80) == 0x00 || t->t_stateflags & TS_8BIT) { 252186681Sed /* One-byte sequence. */ 253186681Sed t->t_utf8_left = 0; 254186681Sed teken_input_char(t, c); 255186681Sed } else if ((c & 0xe0) == 0xc0) { 256186681Sed /* Two-byte sequence. */ 257186681Sed t->t_utf8_left = 1; 258186681Sed t->t_utf8_partial = c & 0x1f; 259186681Sed } else if ((c & 0xf0) == 0xe0) { 260186681Sed /* Three-byte sequence. */ 261186681Sed t->t_utf8_left = 2; 262186681Sed t->t_utf8_partial = c & 0x0f; 263186681Sed } else if ((c & 0xf8) == 0xf0) { 264186681Sed /* Four-byte sequence. */ 265186681Sed t->t_utf8_left = 3; 266186681Sed t->t_utf8_partial = c & 0x07; 267186681Sed } else if ((c & 0xc0) == 0x80) { 268186681Sed if (t->t_utf8_left == 0) 269186681Sed return; 270186681Sed t->t_utf8_left--; 271186681Sed t->t_utf8_partial = (t->t_utf8_partial << 6) | (c & 0x3f); 272186681Sed if (t->t_utf8_left == 0) { 273194293Sed teken_printf("Got UTF-8 char %x\n", t->t_utf8_partial); 274186681Sed teken_input_char(t, t->t_utf8_partial); 275186681Sed } 276186681Sed } 277186681Sed} 278186681Sed 279186681Sedvoid 280186681Sedteken_input(teken_t *t, const void *buf, size_t len) 281186681Sed{ 282186681Sed const char *c = buf; 283186681Sed 284186681Sed while (len-- > 0) 285186681Sed teken_input_byte(t, *c++); 286186681Sed} 287186681Sed 288197117Sedconst teken_pos_t * 289197117Sedteken_get_cursor(teken_t *t) 290197117Sed{ 291197117Sed 292197117Sed return (&t->t_cursor); 293197117Sed} 294197117Sed 295186681Sedvoid 296186681Sedteken_set_cursor(teken_t *t, const teken_pos_t *p) 297186681Sed{ 298186681Sed 299186681Sed /* XXX: bounds checking with originreg! */ 300186681Sed teken_assert(p->tp_row < t->t_winsize.tp_row); 301186681Sed teken_assert(p->tp_col < t->t_winsize.tp_col); 302186681Sed 303186681Sed t->t_cursor = *p; 304186681Sed} 305186681Sed 306188391Sedconst teken_attr_t * 307188391Sedteken_get_curattr(teken_t *t) 308188391Sed{ 309188391Sed 310188391Sed return (&t->t_curattr); 311188391Sed} 312188391Sed 313189617Sedvoid 314189617Sedteken_set_curattr(teken_t *t, const teken_attr_t *a) 315189617Sed{ 316189617Sed 317189617Sed t->t_curattr = *a; 318189617Sed} 319189617Sed 320188391Sedconst teken_attr_t * 321188391Sedteken_get_defattr(teken_t *t) 322188391Sed{ 323188391Sed 324188391Sed return (&t->t_defattr); 325188391Sed} 326188391Sed 327186681Sedvoid 328186681Sedteken_set_defattr(teken_t *t, const teken_attr_t *a) 329186681Sed{ 330186681Sed 331186681Sed t->t_curattr = t->t_saved_curattr = t->t_defattr = *a; 332186681Sed} 333186681Sed 334197117Sedconst teken_pos_t * 335197117Sedteken_get_winsize(teken_t *t) 336197117Sed{ 337197117Sed 338197117Sed return (&t->t_winsize); 339197117Sed} 340197117Sed 341186681Sedvoid 342186681Sedteken_set_winsize(teken_t *t, const teken_pos_t *p) 343186681Sed{ 344186681Sed 345186681Sed t->t_winsize = *p; 346197114Sed teken_subr_do_reset(t); 347186681Sed} 348186681Sed 349197115Sedvoid 350197115Sedteken_set_8bit(teken_t *t) 351197115Sed{ 352197115Sed 353197117Sed t->t_stateflags |= TS_8BIT; 354197115Sed} 355197115Sed 356197117Sedvoid 357197117Sedteken_set_cons25(teken_t *t) 358197117Sed{ 359197117Sed 360197117Sed t->t_stateflags |= TS_CONS25; 361197117Sed} 362197117Sed 363186681Sed/* 364186681Sed * State machine. 365186681Sed */ 366186681Sed 367186681Sedstatic void 368186681Sedteken_state_switch(teken_t *t, teken_state_t *s) 369186681Sed{ 370186681Sed 371186681Sed t->t_nextstate = s; 372186681Sed t->t_curnum = 0; 373186681Sed t->t_stateflags |= TS_FIRSTDIGIT; 374186681Sed} 375186681Sed 376186681Sedstatic int 377186681Sedteken_state_numbers(teken_t *t, teken_char_t c) 378186681Sed{ 379186681Sed 380186681Sed teken_assert(t->t_curnum < T_NUMSIZE); 381186681Sed 382186681Sed if (c >= '0' && c <= '9') { 383186681Sed /* 384186681Sed * Don't do math with the default value of 1 when a 385186681Sed * custom number is inserted. 386186681Sed */ 387186681Sed if (t->t_stateflags & TS_FIRSTDIGIT) { 388186681Sed t->t_stateflags &= ~TS_FIRSTDIGIT; 389186681Sed t->t_nums[t->t_curnum] = 0; 390186681Sed } else { 391186681Sed t->t_nums[t->t_curnum] *= 10; 392186681Sed } 393186681Sed 394186681Sed t->t_nums[t->t_curnum] += c - '0'; 395186681Sed return (1); 396186681Sed } else if (c == ';') { 397186681Sed if (t->t_stateflags & TS_FIRSTDIGIT) 398186681Sed t->t_nums[t->t_curnum] = 0; 399186681Sed 400186681Sed /* Only allow a limited set of arguments. */ 401186681Sed if (++t->t_curnum == T_NUMSIZE) { 402186681Sed teken_state_switch(t, teken_state_init); 403186681Sed return (1); 404186681Sed } 405186681Sed 406186681Sed t->t_stateflags |= TS_FIRSTDIGIT; 407186681Sed return (1); 408186681Sed } else { 409186681Sed if (t->t_stateflags & TS_FIRSTDIGIT && t->t_curnum > 0) { 410186681Sed /* Finish off the last empty argument. */ 411186681Sed t->t_nums[t->t_curnum] = 0; 412186681Sed t->t_curnum++; 413186681Sed } else if ((t->t_stateflags & TS_FIRSTDIGIT) == 0) { 414186681Sed /* Also count the last argument. */ 415186681Sed t->t_curnum++; 416186681Sed } 417186681Sed } 418186681Sed 419186681Sed return (0); 420186681Sed} 421186681Sed 422197522Sedteken_color_t 423197522Sedteken_256to8(teken_color_t c) 424197522Sed{ 425197522Sed unsigned int r, g, b; 426197522Sed 427197522Sed if (c < 16) { 428197522Sed /* Traditional color indices. */ 429197522Sed return (c % 8); 430197522Sed } else if (c >= 244) { 431197522Sed /* Upper grayscale colors. */ 432197522Sed return (TC_WHITE); 433197522Sed } else if (c >= 232) { 434197522Sed /* Lower grayscale colors. */ 435197522Sed return (TC_BLACK); 436197522Sed } 437197522Sed 438197522Sed /* Convert to RGB. */ 439197522Sed c -= 16; 440197522Sed b = c % 6; 441197522Sed g = (c / 6) % 6; 442197522Sed r = c / 36; 443197522Sed 444197522Sed if (r < g) { 445197522Sed /* Possibly green. */ 446197522Sed if (g < b) 447197522Sed return (TC_BLUE); 448197522Sed else if (g > b) 449197522Sed return (TC_GREEN); 450197522Sed else 451197522Sed return (TC_CYAN); 452197522Sed } else if (r > g) { 453197522Sed /* Possibly red. */ 454197522Sed if (r < b) 455197522Sed return (TC_BLUE); 456197522Sed else if (r > b) 457197522Sed return (TC_RED); 458197522Sed else 459197522Sed return (TC_MAGENTA); 460197522Sed } else { 461197522Sed /* Possibly brown. */ 462197522Sed if (g < b) 463197522Sed return (TC_BLUE); 464197522Sed else if (g > b) 465197522Sed return (TC_BROWN); 466197522Sed else if (r < 3) 467197522Sed return (TC_BLACK); 468197522Sed else 469197522Sed return (TC_WHITE); 470197522Sed } 471197522Sed} 472197522Sed 473199171Sedstatic const char * const special_strings_cons25[] = { 474199171Sed [TKEY_UP] = "\x1B[A", [TKEY_DOWN] = "\x1B[B", 475199171Sed [TKEY_LEFT] = "\x1B[D", [TKEY_RIGHT] = "\x1B[C", 476199171Sed 477199175Sed [TKEY_HOME] = "\x1B[H", [TKEY_END] = "\x1B[F", 478199171Sed [TKEY_INSERT] = "\x1B[L", [TKEY_DELETE] = "\x7F", 479199171Sed [TKEY_PAGE_UP] = "\x1B[I", [TKEY_PAGE_DOWN] = "\x1B[G", 480199171Sed 481199171Sed [TKEY_F1] = "\x1B[M", [TKEY_F2] = "\x1B[N", 482199171Sed [TKEY_F3] = "\x1B[O", [TKEY_F4] = "\x1B[P", 483199171Sed [TKEY_F5] = "\x1B[Q", [TKEY_F6] = "\x1B[R", 484199171Sed [TKEY_F7] = "\x1B[S", [TKEY_F8] = "\x1B[T", 485199171Sed [TKEY_F9] = "\x1B[U", [TKEY_F10] = "\x1B[V", 486199171Sed [TKEY_F11] = "\x1B[W", [TKEY_F12] = "\x1B[X", 487199171Sed}; 488199171Sed 489199171Sedstatic const char * const special_strings_ckeys[] = { 490199171Sed [TKEY_UP] = "\x1BOA", [TKEY_DOWN] = "\x1BOB", 491199171Sed [TKEY_LEFT] = "\x1BOD", [TKEY_RIGHT] = "\x1BOC", 492199171Sed 493199171Sed [TKEY_HOME] = "\x1BOH", [TKEY_END] = "\x1BOF", 494199171Sed}; 495199171Sed 496199171Sedstatic const char * const special_strings_normal[] = { 497199171Sed [TKEY_UP] = "\x1B[A", [TKEY_DOWN] = "\x1B[B", 498199171Sed [TKEY_LEFT] = "\x1B[D", [TKEY_RIGHT] = "\x1B[C", 499199171Sed 500199175Sed [TKEY_HOME] = "\x1B[H", [TKEY_END] = "\x1B[F", 501199171Sed [TKEY_INSERT] = "\x1B[2~", [TKEY_DELETE] = "\x1B[3~", 502199171Sed [TKEY_PAGE_UP] = "\x1B[5~", [TKEY_PAGE_DOWN] = "\x1B[6~", 503199171Sed 504199171Sed [TKEY_F1] = "\x1BOP", [TKEY_F2] = "\x1BOQ", 505199171Sed [TKEY_F3] = "\x1BOR", [TKEY_F4] = "\x1BOS", 506199171Sed [TKEY_F5] = "\x1B[15~", [TKEY_F6] = "\x1B[17~", 507199171Sed [TKEY_F7] = "\x1B[18~", [TKEY_F8] = "\x1B[19~", 508199171Sed [TKEY_F9] = "\x1B[20~", [TKEY_F10] = "\x1B[21~", 509199171Sed [TKEY_F11] = "\x1B[23~", [TKEY_F12] = "\x1B[24~", 510199171Sed}; 511199171Sed 512199171Sedconst char * 513199171Sedteken_get_sequence(teken_t *t, unsigned int k) 514199171Sed{ 515199171Sed 516199171Sed /* Cons25 mode. */ 517199171Sed if (t->t_stateflags & TS_CONS25 && 518199171Sed k < sizeof special_strings_cons25 / sizeof(char *)) 519199171Sed return (special_strings_cons25[k]); 520199171Sed 521199171Sed /* Cursor keys mode. */ 522199171Sed if (t->t_stateflags & TS_CURSORKEYS && 523199171Sed k < sizeof special_strings_ckeys / sizeof(char *)) 524199171Sed return (special_strings_ckeys[k]); 525199171Sed 526199171Sed /* Default xterm sequences. */ 527199171Sed if (k < sizeof special_strings_normal / sizeof(char *)) 528199171Sed return (special_strings_normal[k]); 529199171Sed 530199171Sed return (NULL); 531199171Sed} 532199171Sed 533186681Sed#include "teken_state.h" 534