mtm | Ncurses-based terminal multiplexer |
| download: https://git.y1.nz/archives/mtm.tar.gz | |
| Files | Log | Refs |
vtparser.h
1 /* Copyright (c) 2017-2019 Rob King
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the name of the copyright holder nor the
12 * names of contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS,
19 * COPYRIGHT HOLDERS, OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
22 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 #ifndef VTC_H
28 #define VTC_H
29
30 #include <stddef.h>
31 #include <wchar.h>
32
33 /**** CONFIGURATION
34 * VTPARSER_BAD_CHAR is the character that will be displayed when
35 * an application sends an invalid multibyte sequence to the terminal.
36 */
37 #ifndef VTPARSER_BAD_CHAR
38 #ifdef __STDC_ISO_10646__
39 #define VTPARSER_BAD_CHAR ((wchar_t)0xfffd)
40 #else
41 #define VTPARSER_BAD_CHAR L'?'
42 #endif
43 #endif
44
45 /**** DATA TYPES */
46 #define MAXPARAM 16
47 #define MAXCALLBACK 128
48 #define MAXOSC 100
49 #define MAXBUF 100
50
51 typedef struct VTPARSER VTPARSER;
52 typedef struct STATE STATE;
53 typedef void (*VTCALLBACK)(VTPARSER *v, void *p, wchar_t w, wchar_t iw,
54 int argc, int *argv, const wchar_t *osc);
55
56 struct VTPARSER{
57 STATE *s;
58 int narg, nosc, args[MAXPARAM], inter, oscbuf[MAXOSC + 1];
59 mbstate_t ms;
60 void *p;
61 VTCALLBACK print, osc, cons[MAXCALLBACK], escs[MAXCALLBACK],
62 csis[MAXCALLBACK];
63 };
64
65 typedef enum{
66 VTPARSER_CONTROL,
67 VTPARSER_ESCAPE,
68 VTPARSER_CSI,
69 VTPARSER_OSC,
70 VTPARSER_PRINT
71 } VtEvent;
72
73 /**** FUNCTIONS */
74 VTCALLBACK
75 vtonevent(VTPARSER *vp, VtEvent t, wchar_t w, VTCALLBACK cb);
76
77 void
78 vtwrite(VTPARSER *vp, const char *s, size_t n);
79
80 #endif
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.