Size on split-window is -l not -s. Doh.
[tmux-openbsd.git] / tty-acs.c
blob297c51acd5e9de2dd8e7a84c0e598d5d2ea9a31b
1 /* $OpenBSD$ */
3 /*
4 * Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #include <sys/types.h>
21 #include <stdlib.h>
23 #include "tmux.h"
25 int tty_acs_cmp(const void *, const void *);
27 /* Table mapping ACS entries to UTF-8. */
28 struct tty_acs_entry {
29 u_char key;
30 const char *string;
32 const struct tty_acs_entry tty_acs_table[] = {
33 { '+', "\342\206\222" },
34 { ',', "\342\206\220" },
35 { '-', "\342\206\221" },
36 { '.', "\342\206\223" },
37 { '0', "\342\226\256" },
38 { '`', "\342\227\206" },
39 { 'a', "\342\226\222" },
40 { 'f', "\302\260" },
41 { 'g', "\302\261" },
42 { 'h', "\342\226\222" },
43 { 'i', "\342\230\203" },
44 { 'j', "\342\224\230" },
45 { 'k', "\342\224\220" },
46 { 'l', "\342\224\214" },
47 { 'm', "\342\224\224" },
48 { 'n', "\342\224\274" },
49 { 'o', "\342\216\272" },
50 { 'p', "\342\216\273" },
51 { 'q', "\342\224\200" },
52 { 'r', "\342\216\274" },
53 { 's', "\342\216\275" },
54 { 't', "\342\224\234" },
55 { 'u', "\342\224\244" },
56 { 'v', "\342\224\264" },
57 { 'w', "\342\224\254" },
58 { 'x', "\342\224\202" },
59 { 'y', "\342\211\244" },
60 { 'z', "\342\211\245" },
61 { '{', "\317\200" },
62 { '|', "\342\211\240" },
63 { '}', "\302\243" },
64 { '~', "\302\267" }
67 int
68 tty_acs_cmp(const void *key, const void *value)
70 const struct tty_acs_entry *entry = value;
71 u_char ch;
73 ch = *(u_char *) key;
74 return (ch - entry->key);
77 /* Retrieve ACS to output as a string. */
78 const char *
79 tty_acs_get(struct tty *tty, u_char ch)
81 struct tty_acs_entry *entry;
83 /* If not a UTF-8 terminal, use the ACS set. */
84 if (!(tty->flags & TTY_UTF8)) {
85 if (tty->term->acs[ch][0] == '\0')
86 return (NULL);
87 return (&tty->term->acs[ch][0]);
90 /* Otherwise look up the UTF-8 translation. */
91 entry = bsearch(&ch,
92 tty_acs_table, nitems(tty_acs_table), sizeof tty_acs_table[0],
93 tty_acs_cmp);
94 if (entry == NULL)
95 return (NULL);
96 return (entry->string);