Deleted Added
full compact
teken.c (197853) teken.c (199171)
1/*-
2 * Copyright (c) 2008-2009 Ed Schouten <ed@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 2008-2009 Ed Schouten <ed@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/teken/teken.c 197853 2009-10-08 10:26:49Z ed $
26 * $FreeBSD: head/sys/teken/teken.c 199171 2009-11-11 08:20:19Z ed $
27 */
28
29#include <sys/cdefs.h>
30#if defined(__FreeBSD__) && defined(_KERNEL)
31#include <sys/param.h>
32#include <sys/lock.h>
33#include <sys/systm.h>
34#define teken_assert(x) MPASS(x)

--- 9 unchanged lines hidden (view full) ---

44 if (df != NULL) \
45 fprintf(df, x, ## __VA_ARGS__); \
46} while (0)
47/* debug messages */
48static FILE *df;
49#endif /* __FreeBSD__ && _KERNEL */
50
51/* Private flags for t_stateflags. */
27 */
28
29#include <sys/cdefs.h>
30#if defined(__FreeBSD__) && defined(_KERNEL)
31#include <sys/param.h>
32#include <sys/lock.h>
33#include <sys/systm.h>
34#define teken_assert(x) MPASS(x)

--- 9 unchanged lines hidden (view full) ---

44 if (df != NULL) \
45 fprintf(df, x, ## __VA_ARGS__); \
46} while (0)
47/* debug messages */
48static FILE *df;
49#endif /* __FreeBSD__ && _KERNEL */
50
51/* Private flags for t_stateflags. */
52#define TS_FIRSTDIGIT 0x01 /* First numeric digit in escape sequence. */
53#define TS_INSERT 0x02 /* Insert mode. */
54#define TS_AUTOWRAP 0x04 /* Autowrap. */
55#define TS_ORIGIN 0x08 /* Origin mode. */
56#define TS_WRAPPED 0x10 /* Next character should be printed on col 0. */
57#define TS_8BIT 0x20 /* UTF-8 disabled. */
58#define TS_CONS25 0x40 /* cons25 emulation. */
59#define TS_INSTRING 0x80 /* Inside string. */
52#define TS_FIRSTDIGIT 0x0001 /* First numeric digit in escape sequence. */
53#define TS_INSERT 0x0002 /* Insert mode. */
54#define TS_AUTOWRAP 0x0004 /* Autowrap. */
55#define TS_ORIGIN 0x0008 /* Origin mode. */
56#define TS_WRAPPED 0x0010 /* Next character should be printed on col 0. */
57#define TS_8BIT 0x0020 /* UTF-8 disabled. */
58#define TS_CONS25 0x0040 /* cons25 emulation. */
59#define TS_INSTRING 0x0080 /* Inside string. */
60#define TS_CURSORKEYS 0x0100 /* Cursor keys mode. */
60
61/* Character that blanks a cell. */
62#define BLANK ' '
63
64#include "teken.h"
65#include "teken_wcwidth.h"
66#include "teken_scs.h"
67

--- 406 unchanged lines hidden (view full) ---

474 return (TC_BROWN);
475 else if (r < 3)
476 return (TC_BLACK);
477 else
478 return (TC_WHITE);
479 }
480}
481
61
62/* Character that blanks a cell. */
63#define BLANK ' '
64
65#include "teken.h"
66#include "teken_wcwidth.h"
67#include "teken_scs.h"
68

--- 406 unchanged lines hidden (view full) ---

475 return (TC_BROWN);
476 else if (r < 3)
477 return (TC_BLACK);
478 else
479 return (TC_WHITE);
480 }
481}
482
483static const char * const special_strings_cons25[] = {
484 [TKEY_UP] = "\x1B[A", [TKEY_DOWN] = "\x1B[B",
485 [TKEY_LEFT] = "\x1B[D", [TKEY_RIGHT] = "\x1B[C",
486
487 [TKEY_INSERT] = "\x1B[L", [TKEY_DELETE] = "\x7F",
488 [TKEY_HOME] = "\x1B[H", [TKEY_END] = "\x1B[F",
489 [TKEY_PAGE_UP] = "\x1B[I", [TKEY_PAGE_DOWN] = "\x1B[G",
490
491 [TKEY_F1] = "\x1B[M", [TKEY_F2] = "\x1B[N",
492 [TKEY_F3] = "\x1B[O", [TKEY_F4] = "\x1B[P",
493 [TKEY_F5] = "\x1B[Q", [TKEY_F6] = "\x1B[R",
494 [TKEY_F7] = "\x1B[S", [TKEY_F8] = "\x1B[T",
495 [TKEY_F9] = "\x1B[U", [TKEY_F10] = "\x1B[V",
496 [TKEY_F11] = "\x1B[W", [TKEY_F12] = "\x1B[X",
497};
498
499static const char * const special_strings_ckeys[] = {
500 [TKEY_UP] = "\x1BOA", [TKEY_DOWN] = "\x1BOB",
501 [TKEY_LEFT] = "\x1BOD", [TKEY_RIGHT] = "\x1BOC",
502
503 [TKEY_HOME] = "\x1BOH", [TKEY_END] = "\x1BOF",
504};
505
506static const char * const special_strings_normal[] = {
507 [TKEY_UP] = "\x1B[A", [TKEY_DOWN] = "\x1B[B",
508 [TKEY_LEFT] = "\x1B[D", [TKEY_RIGHT] = "\x1B[C",
509
510 [TKEY_INSERT] = "\x1B[2~", [TKEY_DELETE] = "\x1B[3~",
511 [TKEY_HOME] = "\x1B[H", [TKEY_END] = "\x1B[F",
512 [TKEY_PAGE_UP] = "\x1B[5~", [TKEY_PAGE_DOWN] = "\x1B[6~",
513
514 [TKEY_F1] = "\x1BOP", [TKEY_F2] = "\x1BOQ",
515 [TKEY_F3] = "\x1BOR", [TKEY_F4] = "\x1BOS",
516 [TKEY_F5] = "\x1B[15~", [TKEY_F6] = "\x1B[17~",
517 [TKEY_F7] = "\x1B[18~", [TKEY_F8] = "\x1B[19~",
518 [TKEY_F9] = "\x1B[20~", [TKEY_F10] = "\x1B[21~",
519 [TKEY_F11] = "\x1B[23~", [TKEY_F12] = "\x1B[24~",
520};
521
522const char *
523teken_get_sequence(teken_t *t, unsigned int k)
524{
525
526 /* Cons25 mode. */
527 if (t->t_stateflags & TS_CONS25 &&
528 k < sizeof special_strings_cons25 / sizeof(char *))
529 return (special_strings_cons25[k]);
530
531 /* Cursor keys mode. */
532 if (t->t_stateflags & TS_CURSORKEYS &&
533 k < sizeof special_strings_ckeys / sizeof(char *))
534 return (special_strings_ckeys[k]);
535
536 /* Default xterm sequences. */
537 if (k < sizeof special_strings_normal / sizeof(char *))
538 return (special_strings_normal[k]);
539
540 return (NULL);
541}
542
482#include "teken_state.h"
543#include "teken_state.h"