Deleted Added
full compact
teken_demo.c (196786) teken_demo.c (197115)
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_demo.c 196786 2009-09-03 16:31:11Z ed $
26 * $FreeBSD: head/sys/teken/teken_demo.c 197115 2009-09-12 10:34:34Z ed $
27 */
28
29#include <sys/ioctl.h>
30
31#include <assert.h>
32#include <errno.h>
33#include <inttypes.h>
34#include <locale.h>

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

90 assert(p->tp_row < NROWS);
91 assert(p->tp_col < NCOLS);
92
93 getyx(stdscr, y, x);
94
95 px = &buffer[p->tp_col][p->tp_row];
96
97 /* Convert Unicode to UTF-8. */
27 */
28
29#include <sys/ioctl.h>
30
31#include <assert.h>
32#include <errno.h>
33#include <inttypes.h>
34#include <locale.h>

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

90 assert(p->tp_row < NROWS);
91 assert(p->tp_col < NCOLS);
92
93 getyx(stdscr, y, x);
94
95 px = &buffer[p->tp_col][p->tp_row];
96
97 /* Convert Unicode to UTF-8. */
98#ifdef TEKEN_UTF8
99 if (px->c < 0x80) {
100 str[0] = px->c;
101 } else if (px->c < 0x800) {
102 str[0] = 0xc0 | (px->c >> 6);
103 str[1] = 0x80 | (px->c & 0x3f);
104 } else if (px->c < 0x10000) {
105 str[0] = 0xe0 | (px->c >> 12);
106 str[1] = 0x80 | ((px->c >> 6) & 0x3f);
107 str[2] = 0x80 | (px->c & 0x3f);
108 } else {
109 str[0] = 0xf0 | (px->c >> 18);
110 str[1] = 0x80 | ((px->c >> 12) & 0x3f);
111 str[2] = 0x80 | ((px->c >> 6) & 0x3f);
112 str[3] = 0x80 | (px->c & 0x3f);
113 }
98 if (px->c < 0x80) {
99 str[0] = px->c;
100 } else if (px->c < 0x800) {
101 str[0] = 0xc0 | (px->c >> 6);
102 str[1] = 0x80 | (px->c & 0x3f);
103 } else if (px->c < 0x10000) {
104 str[0] = 0xe0 | (px->c >> 12);
105 str[1] = 0x80 | ((px->c >> 6) & 0x3f);
106 str[2] = 0x80 | (px->c & 0x3f);
107 } else {
108 str[0] = 0xf0 | (px->c >> 18);
109 str[1] = 0x80 | ((px->c >> 12) & 0x3f);
110 str[2] = 0x80 | ((px->c >> 6) & 0x3f);
111 str[3] = 0x80 | (px->c & 0x3f);
112 }
114#else /* !TEKEN_UTF8 */
115 str[0] = px->c;
116#endif /* TEKEN_UTF8 */
117
118 if (px->a.ta_format & TF_BOLD)
119 attr |= A_BOLD;
120 if (px->a.ta_format & TF_UNDERLINE)
121 attr |= A_UNDERLINE;
122 if (px->a.ta_format & TF_BLINK)
123 attr |= A_BLINK;
124 if (px->a.ta_format & TF_REVERSE)

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

289 char b[256];
290 ssize_t bl;
291 const int ccolors[8] = {
292 COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW,
293 COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE
294 };
295 int i, j;
296
113
114 if (px->a.ta_format & TF_BOLD)
115 attr |= A_BOLD;
116 if (px->a.ta_format & TF_UNDERLINE)
117 attr |= A_UNDERLINE;
118 if (px->a.ta_format & TF_BLINK)
119 attr |= A_BLINK;
120 if (px->a.ta_format & TF_REVERSE)

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

285 char b[256];
286 ssize_t bl;
287 const int ccolors[8] = {
288 COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW,
289 COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE
290 };
291 int i, j;
292
297#ifdef TEKEN_UTF8
298 setlocale(LC_CTYPE, "UTF-8");
293 setlocale(LC_CTYPE, "UTF-8");
299#endif /* TEKEN_UTF8 */
300
301 tp.tp_row = ws.ws_row = NROWS;
302 tp.tp_col = ws.ws_col = NCOLS;
303
304 switch (forkpty(&ptfd, NULL, NULL, &ws)) {
305 case -1:
306 perror("forkpty");
307 exit(1);
308 case 0:
309#ifdef TEKEN_XTERM
310 setenv("TERM", "xterm", 1);
311#else /* !TEKEN_XTERM */
312 setenv("TERM", "cons25", 1);
313#endif /* TEKEN_XTERM */
294
295 tp.tp_row = ws.ws_row = NROWS;
296 tp.tp_col = ws.ws_col = NCOLS;
297
298 switch (forkpty(&ptfd, NULL, NULL, &ws)) {
299 case -1:
300 perror("forkpty");
301 exit(1);
302 case 0:
303#ifdef TEKEN_XTERM
304 setenv("TERM", "xterm", 1);
305#else /* !TEKEN_XTERM */
306 setenv("TERM", "cons25", 1);
307#endif /* TEKEN_XTERM */
314#ifdef TEKEN_UTF8
315 setenv("LC_CTYPE", "UTF-8", 0);
308 setenv("LC_CTYPE", "UTF-8", 0);
316#endif /* TEKEN_UTF8 */
317 execlp("zsh", "-zsh", NULL);
318 execlp("bash", "-bash", NULL);
319 execlp("sh", "-sh", NULL);
320 _exit(1);
321 }
322
323 teken_init(&t, &tf, NULL);
324 teken_set_winsize(&t, &tp);

--- 45 unchanged lines hidden ---
309 execlp("zsh", "-zsh", NULL);
310 execlp("bash", "-bash", NULL);
311 execlp("sh", "-sh", NULL);
312 _exit(1);
313 }
314
315 teken_init(&t, &tf, NULL);
316 teken_set_winsize(&t, &tp);

--- 45 unchanged lines hidden ---