Commit 8b9cc7d7 authored by Christian Persch's avatar Christian Persch

parser: Complete SCI infrastructure

Add (empty) list of known CSI functions, and test for them.
parent 9dabb0f4
......@@ -73,6 +73,7 @@ libvte_@VTE_API_MAJOR_VERSION@_@VTE_API_MINOR_VERSION@_la_SOURCES = \
parser-glue.hh \
parser-osc.hh \
parser-reply.hh \
parser-sci.hh \
parser-sgr.hh \
parser-string.hh \
pty.cc \
......@@ -267,6 +268,7 @@ parser_cat_SOURCES = \
parser-glue.hh \
parser-osc.hh \
parser-reply.hh \
parser-sci.hh \
parser-sgr.hh \
parser-string.hh \
parser-cat.cc \
......@@ -310,6 +312,7 @@ test_parser_SOURCES = \
parser-glue.hh \
parser-osc.hh \
parser-reply.hh \
parser-sci.hh \
parser-sgr.hh \
parser-string.hh \
$(NULL)
......
/*
* Copyright © 2018 Christian Persch
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#if !defined(_VTE_SEQ) || !defined(_VTE_NOQ)
#error "Must define _VTE_SEQ and _VTE_NOQ before including this file"
#endif
......@@ -765,6 +765,29 @@ test_seq_sci(void)
test_seq_sci(f, false);
}
G_GNUC_UNUSED
static void
test_seq_sci_known(uint32_t f,
unsigned int cmd)
{
vte_seq_builder b{VTE_SEQ_SCI, f};
auto rv = feed_parser(b);
g_assert_cmpint(rv, ==, VTE_SEQ_SCI);
g_assert_cmpint(seq.command(), ==, cmd);
}
static void
test_seq_sci_known(void)
{
parser.reset();
#define _VTE_SEQ(cmd,type,f,p,ni,i) \
test_seq_sci_known(f, VTE_CMD_##cmd);
#include "parser-sci.hh"
#undef _VTE_SEQ
}
static void
test_seq_csi_known(uint32_t f,
uint32_t p,
......@@ -1482,6 +1505,7 @@ main(int argc,
g_test_add_func("/vte/parser/sequences/csi/clear", test_seq_csi_clear);
g_test_add_func("/vte/parser/sequences/csi/max", test_seq_csi_max);
g_test_add_func("/vte/parser/sequences/sci", test_seq_sci);
g_test_add_func("/vte/parser/sequences/sci/known", test_seq_sci_known);
g_test_add_func("/vte/parser/sequences/dcs", test_seq_dcs);
g_test_add_func("/vte/parser/sequences/dcs/known", test_seq_dcs_known);
g_test_add_func("/vte/parser/sequences/osc", test_seq_osc);
......
......@@ -439,7 +439,13 @@ static unsigned int vte_parse_host_dcs(const struct vte_seq *seq)
static unsigned int vte_parse_host_sci(const struct vte_seq *seq)
{
return VTE_CMD_NONE;
switch (_VTE_SEQ_CODE(seq->terminator, 0)) {
#define _VTE_SEQ(cmd,type,f,p,ni,i) \
case _VTE_SEQ_CODE(f, 0): return VTE_CMD_##cmd;
#include "parser-sci.hh"
#undef _VTE_SEQ
default: return VTE_CMD_NONE;
}
}
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment