summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames McCoy <jamessan@debian.org>2023-01-16 20:15:36 -0500
committerJames McCoy <jamessan@debian.org>2023-01-16 20:15:36 -0500
commitc04c634ae226f12492cb1b245922f2bfb39dc7f4 (patch)
treefba5710e6b801844c4abb7732757950906612ebd
parentcccb0799573cbfb9f7fbb00d25cda4f3c324ff5a (diff)
parent5f3851ffac68d1523515eaa27e507805bbc118ff (diff)
Update to upstream 0.3.1
[git-debrebase anchor: new upstream 0.3.1, merge]
-rw-r--r--Makefile37
-rw-r--r--bin/vterm-ctrl.c4
-rw-r--r--bin/vterm-dump.c3
-rw-r--r--doc/URLs14
-rw-r--r--doc/seqs.txt283
-rw-r--r--find-wide-chars.pl30
-rw-r--r--include/vterm.h11
-rw-r--r--src/encoding/DECdrawing.inc36
-rw-r--r--src/encoding/DECdrawing.tbl31
-rw-r--r--src/encoding/uk.inc6
-rw-r--r--src/encoding/uk.tbl1
-rw-r--r--src/parser.c9
-rw-r--r--src/pen.c20
-rw-r--r--src/screen.c39
-rw-r--r--src/state.c2
-rw-r--r--src/unicode.c28
-rw-r--r--src/vterm.c2
-rw-r--r--src/vterm_internal.h2
-rw-r--r--t/64screen_pen.test26
-rw-r--r--t/69screen_sb_clear.test6
-rw-r--r--t/harness.c37
-rw-r--r--tbl2inc_c.pl30
-rw-r--r--vterm.pc.in2
23 files changed, 186 insertions, 473 deletions
diff --git a/Makefile b/Makefile
index e3aa812..3f28d64 100644
--- a/Makefile
+++ b/Makefile
@@ -36,14 +36,11 @@ INCFILES=$(TBLFILES:.tbl=.inc)
HFILES_INT=$(sort $(wildcard src/*.h)) $(HFILES)
-VERSION_MAJOR=0
-VERSION_MINOR=3
-
VERSION_CURRENT=0
VERSION_REVISION=0
VERSION_AGE=0
-VERSION=$(VERSION_MAJOR).$(VERSION_MINOR)
+VERSION=0.3.1
PREFIX=/usr/local
BINDIR=$(PREFIX)/bin
@@ -111,35 +108,3 @@ install-bin: $(BINFILES)
install -d $(DESTDIR)$(BINDIR)
$(LIBTOOL) --mode=install install $(BINFILES) $(DESTDIR)$(BINDIR)/
-# DIST CUT
-
-DISTDIR=libvterm-$(VERSION)
-
-distdir: $(INCFILES)
- mkdir __distdir
- cp LICENSE CONTRIBUTING __distdir
- mkdir __distdir/src
- cp src/*.c src/*.h src/*.inc __distdir/src
- mkdir __distdir/src/encoding
- cp src/encoding/*.inc __distdir/src/encoding
- mkdir __distdir/include
- cp include/*.h __distdir/include
- mkdir __distdir/bin
- cp bin/*.c __distdir/bin
- mkdir __distdir/t
- cp t/*.test t/harness.c t/run-test.pl __distdir/t
- sed "s,@VERSION@,$(VERSION)," <vterm.pc.in >__distdir/vterm.pc.in
- sed "/^# DIST CUT/Q" <Makefile >__distdir/Makefile
- mv __distdir $(DISTDIR)
-
-TARBALL=$(DISTDIR).tar.gz
-
-dist: distdir
- tar -czf $(TARBALL) $(DISTDIR)
- rm -rf $(DISTDIR)
-
-dist+bzr:
- $(MAKE) dist VERSION=$(VERSION)+bzr`bzr revno`
-
-distdir+bzr:
- $(MAKE) distdir VERSION=$(VERSION)+bzr`bzr revno`
diff --git a/bin/vterm-ctrl.c b/bin/vterm-ctrl.c
index 2bfa85b..2364ee6 100644
--- a/bin/vterm-ctrl.c
+++ b/bin/vterm-ctrl.c
@@ -97,7 +97,7 @@ static void await_c1(unsigned char c1)
}
}
-static char *read_csi()
+static char *read_csi(void)
{
await_c1(0x9B); // CSI
@@ -117,7 +117,7 @@ static char *read_csi()
return strdup(csi);
}
-static char *read_dcs()
+static char *read_dcs(void)
{
await_c1(0x90);
diff --git a/bin/vterm-dump.c b/bin/vterm-dump.c
index 997d3e3..d67880a 100644
--- a/bin/vterm-dump.c
+++ b/bin/vterm-dump.c
@@ -65,6 +65,8 @@ static int parser_control(unsigned char control, void *user)
{
if(control < 0x20)
printf("%s%s%s", special_begin, name_c0[control], special_end);
+ else if(control == 0x7f)
+ printf("%s%s%s", special_begin, "DEL", special_end);
else if(control >= 0x80 && control < 0xa0 && name_c1[control - 0x80])
printf("%s%s%s", special_begin, name_c1[control - 0x80], special_end);
else
@@ -226,6 +228,7 @@ int main(int argc, char *argv[])
VTerm *vt = vterm_new(25, 80);
vterm_set_utf8(vt, 1);
vterm_parser_set_callbacks(vt, &parser_cbs, NULL);
+ vterm_parser_set_emit_nul(vt, true);
int len;
char buffer[1024];
diff --git a/doc/URLs b/doc/URLs
deleted file mode 100644
index 8380f5c..0000000
--- a/doc/URLs
+++ /dev/null
@@ -1,14 +0,0 @@
-ECMA-48:
- http://www.ecma-international.org/publications/standards/Ecma-048.htm
-
-Xterm Control Sequences:
- http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
-
-Digital VT100 User Guide:
- http://vt100.net/docs/vt100-ug/
-
-Digital VT220 Programmer Reference Manual
- http://vt100.net/docs/vt220-rm/
-
-Summary of ANSI standards for ASCII terminals
- http://www.inwap.com/pdp10/ansicode.txt
diff --git a/doc/seqs.txt b/doc/seqs.txt
deleted file mode 100644
index 27f28b9..0000000
--- a/doc/seqs.txt
+++ /dev/null
@@ -1,283 +0,0 @@
-Sequences documented in parens are implicit ones from parser.c, which move
-between states.
-
-1 = VT100
-2 = VT220
-3 = VT320
-x = xterm
-
- C0 controls
-
-123 0x00 = NUL
-123x 0x07 = BEL
-123x 0x08 = BS
-123x 0x09 = HT
-123x 0x0A = LF
-123x 0x0B = VT
-123x 0x0C = FF
-123x 0x0D = CR
-123x 0x0E = LS1
-123x 0x0F = LS0
- (0x18 = CAN)
- (0x1A = SUB)
- (0x1B = ESC)
-
-123 0x7f = DEL (ignored)
-
- C1 controls
-
-123x 0x84 = IND
-123x 0x85 = NEL
-123x 0x88 = HTS
-123x 0x8D = RI
- 23x 0x8E = SS2
- 23x 0x8F = SS3
- (0x90 = DCS)
- (0x98 = SOS)
- (0x9B = CSI)
- (0x9C = ST)
- (0x9D = OSC)
- (0x9E = PM)
- (0x9F = APC)
-
- Escape sequences
- - excluding sequences that are C1 aliases
-
-123x ESC ( = SCS, select character set G0
-123x ESC ) = SCS, select character set G1
- 23x ESC * = SCS, select character set G2
- 23x ESC + = SCS, select character set G3
-123x ESC 7 = DECSC - save cursor
-123x ESC 8 = DECRC - restore cursor
-123x ESC # 3 = DECDHL, double-height line (top half)
-123x ESC # 4 = DECDHL, double-height line (bottom half)
-123x ESC # 5 = DECSWL, single-width single-height line
-123x ESC # 6 = DECDWL, double-width single-height line
-123x ESC # 8 = DECALN
-123 ESC < = Ignored (used by VT100 to exit VT52 mode)
-123x ESC = = DECKPAM, keypad application mode
-123x ESC > = DECKPNM, keypad numeric mode
- 23x ESC Sp F = S7C1T
- 23x ESC Sp G = S8C1T
- (ESC P = DCS)
- (ESC X = SOS)
- (ESC [ = CSI)
- (ESC \ = ST)
- (ESC ] = OSC)
- (ESC ^ = PM)
- (ESC _ = APC)
-123x ESC c = RIS, reset initial state
- 3x ESC n = LS2
- 3x ESC o = LS3
- 3x ESC | = LS3R
- 3x ESC } = LS2R
- 3x ESC ~ = LS1R
-
- DCSes
-
- 3x DCS $ q ST = DECRQSS
- 3x m = Request SGR
- x Sp q = Request DECSCUSR
- 3x " q = Request DECSCA
- 3x r = Request DECSTBM
- x s = Request DECSLRM
-
- CSIs
- 23x CSI @ = ICH
-123x CSI A = CUU
-123x CSI B = CUD
-123x CSI C = CUF
-123x CSI D = CUB
- x CSI E = CNL
- x CSI F = CPL
- x CSI G = CHA
-123x CSI H = CUP
- x CSI I = CHT
-123x CSI J = ED
- 23x CSI ? J = DECSED, selective erase in display
-123x CSI K = EL
- 23x CSI ? K = DECSEL, selective erase in line
- 23x CSI L = IL
- 23x CSI M = DL
- 23x CSI P = DCH
- x CSI S = SU
- x CSI T = SD
- 23x CSI X = ECH
- x CSI Z = CBT
- x CSI ` = HPA
- x CSI a = HPR
- x CSI b = REP
-123x CSI c = DA, device attributes
-123 0 = DA
- 23x CSI > c = DECSDA
- 23 0 = SDA
- x CSI d = VPA
- x CSI e = VPR
-123x CSI f = HVP
-123x CSI g = TBC
-123x CSI h = SM, Set mode
-123x CSI ? h = DECSM, DEC set mode
- CSI j = HPB
- CSI k = VPB
-123x CSI l = RM, Reset mode
-123x CSI ? l = DECRM, DEC reset mode
-123x CSI m = SGR, Set Graphic Rendition
- CSI ? m = DECSGR, private Set Graphic Rendition
-123x CSI n = DSR, Device Status Report
- 23x 5 = operating status
- 23x 6 = CPR = cursor position
- 23x CSI ? n = DECDSR; behaves as DSR but uses CSI ? instead of CSI to respond
- 23x CSI ! p = DECSTR, soft terminal reset
- 3x CSI ? $ p = DECRQM, request private mode
- x CSI Sp q = DECSCUSR (odd numbers blink, even numbers solid)
- 1 or 2 = block
- 3 or 4 = underline
- 5 or 6 = I-beam to left
- x CSI > q = XTVERSION, request version string
- 23x CSI " q = DECSCA, select character attributes
-123x CSI r = DECSTBM
- x CSI s = DECSLRM
- x CSI ' } = DECIC
- x CSI ' ~ = DECDC
-
- OSCs
-
- x OSC 0; = Set icon name and title
- x OSC 1; = Set icon name
- x OSC 2; = Set title
- x OSC 52; = Selection management
-
- Standard modes
-
- 23x SM 4 = IRM
-123x SM 20 = NLM, linefeed/newline
-
- DEC modes
-
-123x DECSM 1 = DECCKM, cursor keys
-123x DECSM 5 = DECSCNM, screen
-123x DECSM 6 = DECOM, origin
-123x DECSM 7 = DECAWM, autowrap
- x DECSM 12 = Cursor blink
- 23x DECSM 25 = DECTCEM, text cursor enable
- x DECSM 69 = DECVSSM, vertical screen split
- x DECSM 1000 = Mouse click/release tracking
- x DECSM 1002 = Mouse click/release/drag tracking
- x DECSM 1003 = Mouse all movements tracking
- x DECSM 1004 = Focus in/out reporting
- x DECSM 1005 = Mouse protocol extended (UTF-8) - not recommended
- x DECSM 1006 = Mouse protocol SGR
- x DECSM 1015 = Mouse protocol rxvt
- x DECSM 1047 = Altscreen
- x DECSM 1048 = Save cursor
- x DECSM 1049 = 1047 + 1048
- x DECSM 2004 = Bracketed paste
-
- Graphic Renditions
-
-123x SGR 0 = Reset
-123x SGR 1 = Bold on
- x SGR 3 = Italic on
-123x SGR 4 = Underline single
- SGR 4:x = Underline style
-123x SGR 5 = Blink on
-123x SGR 7 = Reverse on
- x SGR 8 = Conceal on
- x SGR 9 = Strikethrough on
- SGR 10-19 = Select font
- x SGR 21 = Underline double
- 23x SGR 22 = Bold off
- x SGR 23 = Italic off
- 23x SGR 24 = Underline off
- 23x SGR 25 = Blink off
- 23x SGR 27 = Reverse off
- x SGR 28 = Conceal off
- x SGR 29 = Strikethrough off
- x SGR 30-37 = Foreground ANSI
- x SGR 38 = Foreground alternative palette
- x SGR 39 = Foreground default
- x SGR 40-47 = Background ANSI
- x SGR 48 = Background alternative palette
- x SGR 49 = Background default
- SGR 73 = Superscript on
- SGR 74 = Subscript on
- SGR 75 = Superscript/subscript off
- x SGR 90-97 = Foreground ANSI high-intensity
- x SGR 100-107 = Background ANSI high-intensity
-
-The state storage used by ESC 7 and DECSM 1048/1049 is shared.
-
- Unimplemented sequences:
-
-The following sequences are not recognised by libvterm.
-
-123x 0x05 = ENQ
- 3 0x11 = DC1 (XON)
- 3 0x13 = DC3 (XOFF)
- x ESC % @ = Select default character set
- x ESC % G = Select UTF-8 character set
- x ESC 6 = DECBI, Back Index
-12 ESC Z = DECID, identify terminal
- x DCS + Q = XTGETXRES, Request resource values
- DCS $ q = [DECRQSS]
- 3x " p = Request DECSCL
- x t = Request DECSLPP
- x $ | = Request DECSCPP
- x * | = Request DECSLNS
- 3 $ } = Request DECSASD
- 3 $ ~ = Request DECSSDT
- x DCS + p = XTSETTCAP, set termcap/terminfo data
- x DCS + q = XTGETTCAP, request termcap/terminfo
- 23 DCS { = DECDLD, down-line-loadable character set
- 23x DCS | = DECUDK, user-defined key
- x CSI Sp @ = Shift left columns
- x CSI Sp A = Shift right columns
- x CSI # P = XTPUSHCOLORS, push current dynamic colours to stack
- x CSI # Q = XTPOPCOLORS, pop dynamic colours from stack
- x CSI # R = XTREPORTCOLORS, report current entry on palette stack
- x CSI ? S = XTSMGRAPHICS, set/request graphics attribute
- x CSI > T = XTRMTITLE, reset title mode features
- 23x CSI i = DEC printer control
- x CSI > m = XTMODKEYS, set key modifier options
- x CSI > n = (XTMODKEYS), reset key modifier options
- x CSI $ p = DECRQM, request ANSI mode
- 23x CSI " p = DECSCL, set compatibility level
- x CSI > p = XTSMPOINTER, set resource value pointer mode
-1 x CSI q = DECLL, load LEDs
- x CSI ? r = XTRESTORE, restore DEC private mode values
- x CSI $ r = DECCARA, change attributes in rectangular area
- x CSI > s = XTSHIFTESCAPE, set/reset shift-escape options
- x CSI ? s = XTSAVE, save DEC private mode values
- x CSI t = XTWINOPS, window operations
- x CSI > t = XTSMTITLE, set title mode features
- x CSI $ t = DECRARA, reset attributes in rectangular area
- 3 CSI $ u = DECRQTSR, request terminal state report
- 3 1 = terminal state report
- 3 CSI & u = DECRQUPSS, request user-preferred supplemental set
- x CSI $ v = DECCRA, copy rectangular area
- 3x CSI $ w = DECRQPSR, request presentation state report
- 3x 1 = cursor information report
- 3x 2 = tab stop report
- x CSI ' w = DECEFR, enable filter rectangle
-1 x CSI x = DECREQTPARM, request terminal parameters
- x CSI * x = DECSACE, select attribute change extent
- x CSI $ x = DECFRA, fill rectangular area
-123 CSI y = DECTST, invoke confidence test
- x CSI $ z = DECERA, erase rectangular area
- x CSI # { = XTPUSHSGR, push video attributes onto stack
- x CSI $ { = DECSERA, selective erase in rectangular area
- x CSI # | = XTREPORTSGR, report selected graphic rendition
- x CSI $ | = DECSCPP, select columns per page
- x CSI # } = XTPOPSGR, pop video attributes from stack
- 3 CSI $ } = DECSASD, select active status display
- 3 CSI $ ~ = DECSSDT, select status line type
- 23 SM 2 = KAM, keyboard action
-123 SM 12 = SRM, send/receive
-123 DECSM 2 = DECANM, ANSI/VT52
-123 DECSM 3 = DECCOLM, 132 column
-123 DECSM 4 = DECSCLM, scrolling
-123 DECSM 8 = DECARM, auto-repeat
-12 DECSM 9 = DECINLM, interlace
- 23 DECSM 18 = DECPFF, print form feed
- 23 DECSM 19 = DECPEX, print extent
- 23 DECSM 42 = DECNRCM, national/multinational character
diff --git a/find-wide-chars.pl b/find-wide-chars.pl
deleted file mode 100644
index f7f2205..0000000
--- a/find-wide-chars.pl
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-
-STDOUT->autoflush(1);
-
-sub iswide
-{
- my ( $cp ) = @_;
- return chr($cp) =~ m/\p{East_Asian_Width=Wide}|\p{East_Asian_Width=Fullwidth}/;
-}
-
-my ( $start, $end );
-foreach my $cp ( 0 .. 0x1FFFF ) {
- iswide($cp) or next;
-
- if( defined $end and $end == $cp-1 ) {
- # extend the range
- $end = $cp;
- next;
- }
-
- # start a new range
- printf " { %#04x, %#04x },\n", $start, $end if defined $start;
-
- $start = $end = $cp;
-}
-
-printf " { %#04x, %#04x },\n", $start, $end if defined $start;
diff --git a/include/vterm.h b/include/vterm.h
index c6124a1..c0f0087 100644
--- a/include/vterm.h
+++ b/include/vterm.h
@@ -413,6 +413,11 @@ typedef struct {
void vterm_parser_set_callbacks(VTerm *vt, const VTermParserCallbacks *callbacks, void *user);
void *vterm_parser_get_cbdata(VTerm *vt);
+/* Normally NUL, CAN, SUB and DEL are ignored. Setting this true causes them
+ * to be emitted by the 'control' callback
+ */
+void vterm_parser_set_emit_nul(VTerm *vt, bool emit);
+
// -----------
// State layer
// -----------
@@ -598,6 +603,12 @@ int vterm_screen_is_eol(const VTermScreen *screen, VTermPos pos);
*/
void vterm_screen_convert_color_to_rgb(const VTermScreen *screen, VTermColor *col);
+/**
+ * Similar to vterm_state_set_default_colors(), but also resets colours in the
+ * screen buffer(s)
+ */
+void vterm_screen_set_default_colors(VTermScreen *screen, const VTermColor *default_fg, const VTermColor *default_bg);
+
// ---------
// Utilities
// ---------
diff --git a/src/encoding/DECdrawing.inc b/src/encoding/DECdrawing.inc
new file mode 100644
index 0000000..47093ed
--- /dev/null
+++ b/src/encoding/DECdrawing.inc
@@ -0,0 +1,36 @@
+static const struct StaticTableEncoding encoding_DECdrawing = {
+ { .decode = &decode_table },
+ {
+ [0x60] = 0x25C6,
+ [0x61] = 0x2592,
+ [0x62] = 0x2409,
+ [0x63] = 0x240C,
+ [0x64] = 0x240D,
+ [0x65] = 0x240A,
+ [0x66] = 0x00B0,
+ [0x67] = 0x00B1,
+ [0x68] = 0x2424,
+ [0x69] = 0x240B,
+ [0x6a] = 0x2518,
+ [0x6b] = 0x2510,
+ [0x6c] = 0x250C,
+ [0x6d] = 0x2514,
+ [0x6e] = 0x253C,
+ [0x6f] = 0x23BA,
+ [0x70] = 0x23BB,
+ [0x71] = 0x2500,
+ [0x72] = 0x23BC,
+ [0x73] = 0x23BD,
+ [0x74] = 0x251C,
+ [0x75] = 0x2524,
+ [0x76] = 0x2534,
+ [0x77] = 0x252C,
+ [0x78] = 0x2502,
+ [0x79] = 0x2A7D,
+ [0x7a] = 0x2A7E,
+ [0x7b] = 0x03C0,
+ [0x7c] = 0x2260,
+ [0x7d] = 0x00A3,
+ [0x7e] = 0x00B7,
+ }
+};
diff --git a/src/encoding/DECdrawing.tbl b/src/encoding/DECdrawing.tbl
deleted file mode 100644
index 6e19c50..0000000
--- a/src/encoding/DECdrawing.tbl
+++ /dev/null
@@ -1,31 +0,0 @@
-6/0 = U+25C6 # BLACK DIAMOND
-6/1 = U+2592 # MEDIUM SHADE (checkerboard)
-6/2 = U+2409 # SYMBOL FOR HORIZONTAL TAB
-6/3 = U+240C # SYMBOL FOR FORM FEED
-6/4 = U+240D # SYMBOL FOR CARRIAGE RETURN
-6/5 = U+240A # SYMBOL FOR LINE FEED
-6/6 = U+00B0 # DEGREE SIGN
-6/7 = U+00B1 # PLUS-MINUS SIGN (plus or minus)
-6/8 = U+2424 # SYMBOL FOR NEW LINE
-6/9 = U+240B # SYMBOL FOR VERTICAL TAB
-6/10 = U+2518 # BOX DRAWINGS LIGHT UP AND LEFT (bottom-right corner)
-6/11 = U+2510 # BOX DRAWINGS LIGHT DOWN AND LEFT (top-right corner)
-6/12 = U+250C # BOX DRAWINGS LIGHT DOWN AND RIGHT (top-left corner)
-6/13 = U+2514 # BOX DRAWINGS LIGHT UP AND RIGHT (bottom-left corner)
-6/14 = U+253C # BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL (crossing lines)
-6/15 = U+23BA # HORIZONTAL SCAN LINE-1
-7/0 = U+23BB # HORIZONTAL SCAN LINE-3
-7/1 = U+2500 # BOX DRAWINGS LIGHT HORIZONTAL
-7/2 = U+23BC # HORIZONTAL SCAN LINE-7
-7/3 = U+23BD # HORIZONTAL SCAN LINE-9
-7/4 = U+251C # BOX DRAWINGS LIGHT VERTICAL AND RIGHT
-7/5 = U+2524 # BOX DRAWINGS LIGHT VERTICAL AND LEFT
-7/6 = U+2534 # BOX DRAWINGS LIGHT UP AND HORIZONTAL
-7/7 = U+252C # BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
-7/8 = U+2502 # BOX DRAWINGS LIGHT VERTICAL
-7/9 = U+2A7D # LESS-THAN OR SLANTED EQUAL-TO
-7/10 = U+2A7E # GREATER-THAN OR SLANTED EQUAL-TO
-7/11 = U+03C0 # GREEK SMALL LETTER PI
-7/12 = U+2260 # NOT EQUAL TO
-7/13 = U+00A3 # POUND SIGN
-7/14 = U+00B7 # MIDDLE DOT
diff --git a/src/encoding/uk.inc b/src/encoding/uk.inc
new file mode 100644
index 0000000..da1445d
--- /dev/null
+++ b/src/encoding/uk.inc
@@ -0,0 +1,6 @@
+static const struct StaticTableEncoding encoding_uk = {
+ { .decode = &decode_table },
+ {
+ [0x23] = 0x00a3,
+ }
+};
diff --git a/src/encoding/uk.tbl b/src/encoding/uk.tbl
deleted file mode 100644
index b27b1a2..0000000
--- a/src/encoding/uk.tbl
+++ /dev/null
@@ -1 +0,0 @@
-2/3 = "£"
diff --git a/src/parser.c b/src/parser.c
index 0459a89..b43a549 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -145,11 +145,15 @@ size_t vterm_input_write(VTerm *vt, const char *bytes, size_t len)
string_fragment(vt, string_start, bytes + pos - string_start, false);
string_start = bytes + pos + 1;
}
+ if(vt->parser.emit_nul)
+ do_control(vt, c);
continue;
}
if(c == 0x18 || c == 0x1a) { // CAN, SUB
vt->parser.in_esc = false;
ENTER_NORMAL_STATE();
+ if(vt->parser.emit_nul)
+ do_control(vt, c);
continue;
}
else if(c == 0x1b) { // ESC
@@ -391,3 +395,8 @@ void *vterm_parser_get_cbdata(VTerm *vt)
{
return vt->parser.cbdata;
}
+
+void vterm_parser_set_emit_nul(VTerm *vt, bool emit)
+{
+ vt->parser.emit_nul = emit;
+}
diff --git a/src/pen.c b/src/pen.c
index 704e9d8..2227a6f 100644
--- a/src/pen.c
+++ b/src/pen.c
@@ -241,15 +241,17 @@ void vterm_state_get_palette_color(const VTermState *state, int index, VTermColo
void vterm_state_set_default_colors(VTermState *state, const VTermColor *default_fg, const VTermColor *default_bg)
{
- /* Copy the given colors */
- state->default_fg = *default_fg;
- state->default_bg = *default_bg;
-
- /* Make sure the correct type flags are set */
- state->default_fg.type = (state->default_fg.type & ~VTERM_COLOR_DEFAULT_MASK)
- | VTERM_COLOR_DEFAULT_FG;
- state->default_bg.type = (state->default_bg.type & ~VTERM_COLOR_DEFAULT_MASK)
- | VTERM_COLOR_DEFAULT_BG;
+ if(default_fg) {
+ state->default_fg = *default_fg;
+ state->default_fg.type = (state->default_fg.type & ~VTERM_COLOR_DEFAULT_MASK)
+ | VTERM_COLOR_DEFAULT_FG;
+ }
+
+ if(default_bg) {
+ state->default_bg = *default_bg;
+ state->default_bg.type = (state->default_bg.type & ~VTERM_COLOR_DEFAULT_MASK)
+ | VTERM_COLOR_DEFAULT_BG;
+ }
}
void vterm_state_set_palette_color(VTermState *state, int index, const VTermColor *col)
diff --git a/src/screen.c b/src/screen.c
index 77c0af8..51c7f99 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -281,7 +281,11 @@ static int erase_internal(VTermRect rect, int selective, void *user)
continue;
cell->chars[0] = 0;
- cell->pen = screen->pen;
+ cell->pen = (ScreenPen){
+ /* Only copy .fg and .bg; leave things like rv in reset state */
+ .fg = screen->pen.fg,
+ .bg = screen->pen.bg,
+ };
cell->pen.dwl = info->doublewidth;
cell->pen.dhl = info->doubleheight;
}
@@ -1144,3 +1148,36 @@ void vterm_screen_convert_color_to_rgb(const VTermScreen *screen, VTermColor *co
{
vterm_state_convert_color_to_rgb(screen->state, col);
}
+
+static void reset_default_colours(VTermScreen *screen, ScreenCell *buffer)
+{
+ for(int row = 0; row <= screen->rows - 1; row++)
+ for(int col = 0; col <= screen->cols - 1; col++) {
+ ScreenCell *cell = &buffer[row * screen->cols + col];
+ if(VTERM_COLOR_IS_DEFAULT_FG(&cell->pen.fg))
+ cell->pen.fg = screen->pen.fg;
+ if(VTERM_COLOR_IS_DEFAULT_BG(&cell->pen.bg))
+ cell->pen.bg = screen->pen.bg;
+ }
+}
+
+void vterm_screen_set_default_colors(VTermScreen *screen, const VTermColor *default_fg, const VTermColor *default_bg)
+{
+ vterm_state_set_default_colors(screen->state, default_fg, default_bg);
+
+ if(default_fg && VTERM_COLOR_IS_DEFAULT_FG(&screen->pen.fg)) {
+ screen->pen.fg = *default_fg;
+ screen->pen.fg.type = (screen->pen.fg.type & ~VTERM_COLOR_DEFAULT_MASK)
+ | VTERM_COLOR_DEFAULT_FG;
+ }
+
+ if(default_bg && VTERM_COLOR_IS_DEFAULT_BG(&screen->pen.bg)) {
+ screen->pen.bg = *default_bg;
+ screen->pen.bg.type = (screen->pen.bg.type & ~VTERM_COLOR_DEFAULT_MASK)
+ | VTERM_COLOR_DEFAULT_BG;
+ }
+
+ reset_default_colours(screen, screen->buffers[0]);
+ if(screen->buffers[1])
+ reset_default_colours(screen, screen->buffers[1]);
+}
diff --git a/src/state.c b/src/state.c
index ccc6981..b22fba7 100644
--- a/src/state.c
+++ b/src/state.c
@@ -1862,7 +1862,7 @@ static void request_status_string(VTermState *state, VTermStringFragment frag)
return;
}
- vterm_push_output_sprintf_str(state->vt, C1_DCS, true, "0$r%s", tmp);
+ vterm_push_output_sprintf_str(state->vt, C1_DCS, true, "0$r");
}
static int on_dcs(const char *command, size_t commandlen, VTermStringFragment frag, void *user)
diff --git a/src/unicode.c b/src/unicode.c
index 0d1b5ff..269244f 100644
--- a/src/unicode.c
+++ b/src/unicode.c
@@ -212,19 +212,7 @@ static int mk_wcwidth(uint32_t ucs)
}
-static int mk_wcswidth(const uint32_t *pwcs, size_t n)
-{
- int w, width = 0;
-
- for (;*pwcs && n-- > 0; pwcs++)
- if ((w = mk_wcwidth(*pwcs)) < 0)
- return -1;
- else
- width += w;
-
- return width;
-}
-
+#ifdef USE_MK_WCWIDTH_CJK
/*
* The following functions are the same as mk_wcwidth() and
@@ -302,19 +290,7 @@ static int mk_wcwidth_cjk(uint32_t ucs)
return mk_wcwidth(ucs);
}
-
-static int mk_wcswidth_cjk(const uint32_t *pwcs, size_t n)
-{
- int w, width = 0;
-
- for (;*pwcs && n-- > 0; pwcs++)
- if ((w = mk_wcwidth_cjk(*pwcs)) < 0)
- return -1;
- else
- width += w;
-
- return width;
-}
+#endif
// ################################
// ### The rest added by Paul Evans
diff --git a/src/vterm.c b/src/vterm.c
index b2f61d2..0997887 100644
--- a/src/vterm.c
+++ b/src/vterm.c
@@ -66,6 +66,8 @@ VTerm *vterm_build(const struct VTermBuilder *builder)
vt->parser.callbacks = NULL;
vt->parser.cbdata = NULL;
+ vt->parser.emit_nul = false;
+
vt->outfunc = NULL;
vt->outdata = NULL;
diff --git a/src/vterm_internal.h b/src/vterm_internal.h
index 6aa9007..df9495c 100644
--- a/src/vterm_internal.h
+++ b/src/vterm_internal.h
@@ -227,6 +227,8 @@ struct VTerm
void *cbdata;
bool string_initial;
+
+ bool emit_nul;
} parser;
/* len == malloc()ed size; cur == number of valid bytes */
diff --git a/t/64screen_pen.test b/t/64screen_pen.test
index b21593b..455c282 100644
--- a/t/64screen_pen.test
+++ b/t/64screen_pen.test
@@ -41,21 +41,31 @@ PUSH "x\e[74m0\e[73m2\e[m"
?screen_cell 0,9 = {0x30} width=1 attrs={S_} fg=rgb(240,240,240) bg=rgb(0,0,0)
?screen_cell 0,10 = {0x32} width=1 attrs={S^} fg=rgb(240,240,240) bg=rgb(0,0,0)
-!EL sets reverse and colours to end of line
+!EL sets only colours to end of line, not other attrs
PUSH "\e[H\e[7;33;44m\e[K"
- ?screen_cell 0,0 = {} width=1 attrs={R} fg=rgb(224,224,0) bg=rgb(0,0,224)
- ?screen_cell 0,79 = {} width=1 attrs={R} fg=rgb(224,224,0) bg=rgb(0,0,224)
-
-!DECSCNM xors reverse for entire screen
-PUSH "\e[?5h"
?screen_cell 0,0 = {} width=1 attrs={} fg=rgb(224,224,0) bg=rgb(0,0,224)
?screen_cell 0,79 = {} width=1 attrs={} fg=rgb(224,224,0) bg=rgb(0,0,224)
+
+!DECSCNM xors reverse for entire screen
+PUSH "R\e[?5h"
+ ?screen_cell 0,0 = {0x52} width=1 attrs={} fg=rgb(224,224,0) bg=rgb(0,0,224)
?screen_cell 1,0 = {} width=1 attrs={R} fg=rgb(240,240,240) bg=rgb(0,0,0)
PUSH "\e[?5\$p"
output "\e[?5;1\$y"
PUSH "\e[?5l"
- ?screen_cell 0,0 = {} width=1 attrs={R} fg=rgb(224,224,0) bg=rgb(0,0,224)
- ?screen_cell 0,79 = {} width=1 attrs={R} fg=rgb(224,224,0) bg=rgb(0,0,224)
+ ?screen_cell 0,0 = {0x52} width=1 attrs={R} fg=rgb(224,224,0) bg=rgb(0,0,224)
?screen_cell 1,0 = {} width=1 attrs={} fg=rgb(240,240,240) bg=rgb(0,0,0)
PUSH "\e[?5\$p"
output "\e[?5;2\$y"
+
+!Set default colours
+RESET
+PUSH "ABC\e[31mDEF\e[m"
+ ?screen_cell 0,0 = {0x41} width=1 attrs={} fg=rgb(240,240,240) bg=rgb(0,0,0)
+ ?screen_cell 0,3 = {0x44} width=1 attrs={} fg=rgb(224,0,0) bg=rgb(0,0,0)
+SETDEFAULTCOL rgb(252,253,254)
+ ?screen_cell 0,0 = {0x41} width=1 attrs={} fg=rgb(252,253,254) bg=rgb(0,0,0)
+ ?screen_cell 0,3 = {0x44} width=1 attrs={} fg=rgb(224,0,0) bg=rgb(0,0,0)
+SETDEFAULTCOL rgb(250,250,250) rgb(10,20,30)
+ ?screen_cell 0,0 = {0x41} width=1 attrs={} fg=rgb(250,250,250) bg=rgb(10,20,30)
+ ?screen_cell 0,3 = {0x44} width=1 attrs={} fg=rgb(224,0,0) bg=rgb(10,20,30)
diff --git a/t/69screen_sb_clear.test b/t/69screen_sb_clear.test
new file mode 100644
index 0000000..aaf280c
--- /dev/null
+++ b/t/69screen_sb_clear.test
@@ -0,0 +1,6 @@
+INIT
+WANTSCREEN b
+
+!Clear scrollback
+PUSH "\e[3J"
+ sb_clear
diff --git a/t/harness.c b/t/harness.c
index be468d9..0003e1b 100644
--- a/t/harness.c
+++ b/t/harness.c
@@ -81,6 +81,26 @@ static void print_color(const VTermColor *col)
printf(")");
}
+static VTermColor strpe_color(char **strp)
+{
+ uint8_t r, g, b, idx;
+ int len = 0;
+ VTermColor col;
+
+ if(sscanf(*strp, "rgb(%hhu,%hhu,%hhu)%n", &r, &g, &b, &len) == 3 && len > 0) {
+ *strp += len;
+ vterm_color_rgb(&col, r, g, b);
+ }
+ else if(sscanf(*strp, "idx(%hhu)%n", &idx, &len) == 1 && len > 0) {
+ *strp += len;
+ vterm_color_indexed(&col, idx);
+ }
+ else
+ vterm_color_rgb(&col, 127, 127, 127);
+
+ return col;
+}
+
static VTerm *vt;
static VTermState *state;
static VTermScreen *screen;
@@ -908,6 +928,23 @@ int main(int argc, char **argv)
vterm_screen_flush_damage(screen);
}
+ else if(strstartswith(line, "SETDEFAULTCOL ")) {
+ assert(screen);
+ char *linep = line + 14;
+ while(linep[0] == ' ')
+ linep++;
+ VTermColor fg = strpe_color(&linep);
+ if(linep[0]) {
+ while(linep[0] == ' ')
+ linep++;
+ VTermColor bg = strpe_color(&linep);
+
+ vterm_screen_set_default_colors(screen, &fg, &bg);
+ }
+ else
+ vterm_screen_set_default_colors(screen, &fg, NULL);
+ }
+
else if(line[0] == '?') {
if(streq(line, "?cursor")) {
assert(state);
diff --git a/tbl2inc_c.pl b/tbl2inc_c.pl
deleted file mode 100644
index 38c9963..0000000
--- a/tbl2inc_c.pl
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-
-my ( $encname ) = $ARGV[0] =~ m{/([^/.]+).tbl}
- or die "Cannot parse encoding name out of $ARGV[0]\n";
-
-print <<"EOF";
-static const struct StaticTableEncoding encoding_$encname = {
- { .decode = &decode_table },
- {
-EOF
-
-while( <> ) {
- s/\s*#.*//; # strip comment
-
- s{^(\d+)/(\d+)}{sprintf "[0x%02x]", $1*16 + $2}e; # Convert 3/1 to [0x31]
- s{"(.)"}{sprintf "0x%04x", ord $1}e; # Convert "A" to 0x41
- s{U\+}{0x}; # Convert U+0041 to 0x0041
-
- s{$}{,}; # append comma
-
- print " $_";
-}
-
-print <<"EOF";
- }
-};
-EOF
diff --git a/vterm.pc.in b/vterm.pc.in
index 8d7e59a..681a270 100644
--- a/vterm.pc.in
+++ b/vterm.pc.in
@@ -3,6 +3,6 @@ includedir=@INCDIR@
Name: vterm
Description: Abstract VT220/Xterm/ECMA-48 emulation library
-Version: @VERSION@
+Version: 0.3.1
Libs: -L${libdir} -lvterm
Cflags: -I${includedir}