-
Notifications
You must be signed in to change notification settings - Fork 22
/
README
80 lines (55 loc) · 2.04 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
VTParse - an implementation of Paul Williams' DEC compatible state machine parser
<http://www.vt100.net/emu/dec_ansi_parser>
Author: Joshua Haberman <[email protected]>
This code is in the public domain.
BUILDING
========
Ruby is required at build time to generate the tables in C. To build the library
and test program, just type make:
$ make
<this will create the test program and libvtparse.a>
I have only tested the build on Mac OS X and Linux, but it should build anywhere
Ruby and GCC are available. Other C compilers should work as well, I just haven't
tried them.
TEST PROGRAM
============
The test program shows how to use vtparse. To see what kind of data is returned
by the library, try:
--------------------------------
$ vim > terminaloutput
<type ':q<ENTER>' to exit vim, even though you won't see it>
$ ./test < terminaloutput | head -16
Received action ESC_DISPATCH
Char: 0x37 ('7')
Received action CSI_DISPATCH
Char: 0x68 ('h')
1 Intermediate chars:
0x3f ('?')
1 Parameters:
47
Received action CSI_DISPATCH
Char: 0x68 ('h')
1 Intermediate chars:
0x3f ('?')
1 Parameters:
1
---------------------------------
VERIFYING
=========
You can also verify the validity of the state tables by running:
$ ruby vtparse_check_tables.rb
Tables had all necessary transitions defined.
This checks to make sure that state transitions are defined for all states, for all
characters 0-0xA0.
TODO
====
One possible enhancement is to allow the client to pass a return value from the
callback to say "stop parsing." The vtparse() function could return the number
of bytes consumed from the input buffer. This would be quite simple to do if
someone needed this functionality, but I don't, so I didn't bother.
Currently there is no explicit character set support. I don't know enough about
the relevant standards to know if vtparse should have character set support, or
what that support would look like. Suggestions along this vein are very welcome!
CREDITS
=======
Thanks to Julian Scheid for several bugfixes and enhancements.