teken.c (187367) | teken.c (187469) |
---|---|
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/dev/syscons/teken/teken.c 187367 2009-01-17 16:37:13Z ed $ | 26 * $FreeBSD: head/sys/dev/syscons/teken/teken.c 187469 2009-01-20 11:34:28Z 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#include "teken.h" | 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#include "teken.h" |
52 |
|
52#ifdef TEKEN_UTF8 53#include "teken_wcwidth.h" 54#else /* !TEKEN_UTF8 */ | 53#ifdef TEKEN_UTF8 54#include "teken_wcwidth.h" 55#else /* !TEKEN_UTF8 */ |
55static inline int 56teken_wcwidth(teken_char_t c __unused) 57{ 58 | |
59#ifdef TEKEN_XTERM | 56#ifdef TEKEN_XTERM |
60 return (c <= 0x1B) ? -1 : 1; | 57#define teken_wcwidth(c) ((c <= 0x1B) ? -1 : 1) |
61#else /* !TEKEN_XTERM */ | 58#else /* !TEKEN_XTERM */ |
62 return (1); | 59#define teken_wcwidth(c) (1) |
63#endif /* TEKEN_XTERM */ | 60#endif /* TEKEN_XTERM */ |
64} | |
65#endif /* TEKEN_UTF8 */ 66 | 61#endif /* TEKEN_UTF8 */ 62 |
63#if defined(TEKEN_XTERM) && defined(TEKEN_UTF8) 64#include "teken_scs.h" 65#else /* !(TEKEN_XTERM && TEKEN_UTF8) */ 66#define teken_scs_process(t, c) (c) 67#define teken_scs_restore(t) 68#define teken_scs_save(t) 69#define teken_scs_set(t, g, ts) 70#define teken_scs_switch(t, g) 71#endif /* TEKEN_XTERM && TEKEN_UTF8 */ 72 |
|
67/* Private flags for teken_format_t. */ 68#define TF_REVERSE 0x08 69 70/* Private flags for t_stateflags. */ 71#define TS_FIRSTDIGIT 0x01 /* First numeric digit in escape sequence. */ 72#define TS_INSERT 0x02 /* Insert mode. */ 73#define TS_AUTOWRAP 0x04 /* Autowrap. */ 74#define TS_ORIGIN 0x08 /* Origin mode. */ --- 149 unchanged lines hidden (view full) --- 224 break; 225 case '\n': 226 case '\x0B': 227 teken_subr_newline(t); 228 break; 229 case '\x0C': 230 teken_subr_newpage(t); 231 break; | 73/* Private flags for teken_format_t. */ 74#define TF_REVERSE 0x08 75 76/* Private flags for t_stateflags. */ 77#define TS_FIRSTDIGIT 0x01 /* First numeric digit in escape sequence. */ 78#define TS_INSERT 0x02 /* Insert mode. */ 79#define TS_AUTOWRAP 0x04 /* Autowrap. */ 80#define TS_ORIGIN 0x08 /* Origin mode. */ --- 149 unchanged lines hidden (view full) --- 230 break; 231 case '\n': 232 case '\x0B': 233 teken_subr_newline(t); 234 break; 235 case '\x0C': 236 teken_subr_newpage(t); 237 break; |
238#if defined(TEKEN_XTERM) && defined(TEKEN_UTF8) 239 case '\x0E': 240 teken_scs_switch(t, 1); 241 break; 242 case '\x0F': 243 teken_scs_switch(t, 0); 244 break; 245#endif /* TEKEN_XTERM && TEKEN_UTF8 */ |
|
232 case '\r': 233 teken_subr_carriage_return(t); 234 break; 235 case '\t': 236 teken_subr_horizontal_tab(t); 237 break; 238 default: 239 t->t_nextstate(t, c); --- 158 unchanged lines hidden --- | 246 case '\r': 247 teken_subr_carriage_return(t); 248 break; 249 case '\t': 250 teken_subr_horizontal_tab(t); 251 break; 252 default: 253 t->t_nextstate(t, c); --- 158 unchanged lines hidden --- |