[vte/wip/sixels: 14/111] sixels: Hook up the sixel parser.
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/wip/sixels: 14/111] sixels: Hook up the sixel parser.
- Date: Sat, 8 Aug 2020 18:42:59 +0000 (UTC)
commit 88325544c2a3ac1d0cd060ab470151f3afece42f
Author: Hans Petter Jansson <hpj cl no>
Date: Sat Aug 8 20:42:48 2020 +0200
sixels: Hook up the sixel parser.
src/parser-cmd.hh | 2 +-
src/parser-dcs.hh | 2 +-
src/vteseq.cc | 76 +++++++------------------------------------------------
3 files changed, 11 insertions(+), 69 deletions(-)
---
diff --git a/src/parser-cmd.hh b/src/parser-cmd.hh
index f8481dd3..a94b9d62 100644
--- a/src/parser-cmd.hh
+++ b/src/parser-cmd.hh
@@ -62,6 +62,7 @@ _VTE_CMD(DECSCUSR) /* set cursor style */
_VTE_CMD(DECSED) /* selective erase in display */
_VTE_CMD(DECSEL) /* selective erase in line */
_VTE_CMD(DECSGR) /* DEC select graphics rendition */
+_VTE_CMD(DECSIXEL) /* SIXEL graphics */
_VTE_CMD(DECSLPP) /* set lines per page */
_VTE_CMD(DECSLRM_OR_SCOSC) /* set left and right margins or SCO save cursor */
_VTE_CMD(DECSR) /* secure reset */
@@ -201,7 +202,6 @@ _VTE_NOP(DECSDPT) /* select digital printed data type */
_VTE_NOP(DECSERA) /* selective erase rectangular area */
_VTE_NOP(DECSEST) /* energy saver time */
_VTE_NOP(DECSFC) /* select flow control */
-_VTE_NOP(DECSIXEL) /* SIXEL graphics */
_VTE_NOP(DECSKCV) /* set key click volume */
_VTE_NOP(DECSLCK) /* set lock key style */
_VTE_NOP(DECSLE) /* select locator events */
diff --git a/src/parser-dcs.hh b/src/parser-dcs.hh
index 6ce2e74f..b2b0b248 100644
--- a/src/parser-dcs.hh
+++ b/src/parser-dcs.hh
@@ -24,7 +24,7 @@ _VTE_NOQ(RLOGIN_MML, DCS, 'm', NONE, 1, HASH ) /* RLogin mu
_VTE_NOQ(DECREGIS, DCS, 'p', NONE, 0, NONE ) /* ReGIS-graphics */
_VTE_NOQ(DECRSTS, DCS, 'p', NONE, 1, CASH ) /* restore-terminal-state */
_VTE_NOQ(XTERM_STCAP, DCS, 'p', NONE, 1, PLUS ) /* xterm set termcap/terminfo */
-_VTE_NOQ(DECSIXEL, DCS, 'q', NONE, 0, NONE ) /* SIXEL-graphics */
+_VTE_SEQ(DECSIXEL, DCS, 'q', NONE, 0, NONE ) /* SIXEL-graphics */
_VTE_SEQ(DECRQSS, DCS, 'q', NONE, 1, CASH ) /* request-selection-or-setting */
_VTE_NOQ(XTERM_RQTCAP, DCS, 'q', NONE, 1, PLUS ) /* xterm request termcap/terminfo */
_VTE_NOQ(DECLBAN, DCS, 'r', NONE, 0, NONE ) /* load-banner-message */
diff --git a/src/vteseq.cc b/src/vteseq.cc
index 4b1d46a1..8dc9cbfc 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -3075,73 +3075,6 @@ Terminal::DECIC(vte::parser::Sequence const& seq)
*/
}
-#if 0
-static void
-vte_sequence_handler_device_control_string (VteTerminalPrivate *that, GValueArray *params)
-{
- GValue *value;
- char *dcs = NULL;
- char *p;
- glong cmd = 0;
- gint param;
- size_t nparams = 0;
- gint dcsparams[DECSIXEL_PARAMS_MAX];
-
- value = g_value_array_get_nth(params, 0);
- if (!value)
- return;
- if (G_VALUE_HOLDS_STRING(value)) {
- /* Copy the string into the buffer. */
- dcs = g_value_dup_string(value);
- }
- else if (G_VALUE_HOLDS_POINTER(value)) {
- dcs = that->ucs4_to_utf8((const guchar *)g_value_get_pointer (value));
- }
- if (! dcs)
- return;
-
- for (p = dcs; p; ++p) {
- switch (*p) {
- case ' ' ... '/':
- cmd = cmd << 8 | *p;
- if (cmd > (1 << 24))
- goto end;
- break;
- case '0' ... '9':
- if (param < 0)
- param = 0;
- param = param * 10 + *p - '0';
- break;
- case ';':
- if (param < 0)
- param = 0;
- if (nparams < sizeof(dcsparams) / sizeof(dcsparams[0]))
- dcsparams[nparams++] = param;
- param = 0;
- break;
- case '@' ... '~':
- cmd = cmd << 8 | *p;
- goto dispatch;
- default:
- goto end;
- }
- }
-
-dispatch:
- switch (cmd) {
- case 'q':
- if (that->m_sixel_enabled)
- that->seq_load_sixel(dcs);
- break;
- default:
- break;
- }
-
-end:
- g_free(dcs);
-}
-#endif
-
void
Terminal::seq_load_sixel(char const* dcs)
{
@@ -4495,6 +4428,15 @@ Terminal::DECSIXEL(vte::parser::Sequence const& seq)
*
* References: VT330
*/
+ if (!m_sixel_enabled)
+ return;
+
+ auto buf = seq.string_utf8();
+ char *dcs = (char *) buf.c_str();
+ if (!dcs)
+ return;
+
+ seq_load_sixel(dcs + 1);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]