[vte] emulation: Port DSR to new parameter glue
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] emulation: Port DSR to new parameter glue
- Date: Tue, 27 Mar 2018 17:42:17 +0000 (UTC)
commit 2d8e0f8f27fb57347ebb4f95baaf8ed8c6c04cad
Author: Christian Persch <chpe src gnome org>
Date: Tue Mar 27 19:40:12 2018 +0200
emulation: Port DSR to new parameter glue
src/parser-cmd.hh | 2 +-
src/parser.cc | 4 +-
src/vteseq-list.hh | 2 -
src/vteseq.cc | 193 ++++++++++++++++++++++++++--------------------------
4 files changed, 100 insertions(+), 101 deletions(-)
---
diff --git a/src/parser-cmd.hh b/src/parser-cmd.hh
index 0c0fdac..0e03269 100644
--- a/src/parser-cmd.hh
+++ b/src/parser-cmd.hh
@@ -122,8 +122,8 @@ _VTE_CMD(DECTME) /* terminal-mode-emulation */
_VTE_CMD(DECTST) /* invoke-confidence-test */
_VTE_CMD(DL) /* delete-line */
_VTE_CMD(DOCS) /* designate-other-coding-system */
-_VTE_CMD(DSR_ANSI) /* device-status-report-ansi */
_VTE_CMD(DSR_DEC) /* device-status-report-dec */
+_VTE_CMD(DSR_ECMA) /* device-status-report-ecma */
_VTE_CMD(ECH) /* erase-character */
_VTE_CMD(ED) /* erase-in-display */
_VTE_CMD(EL) /* erase-in-line */
diff --git a/src/parser.cc b/src/parser.cc
index 0b2715d..f1a60e2 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -534,8 +534,8 @@ static unsigned int vte_parse_host_csi(const struct vte_seq *seq)
return VTE_CMD_XTERM_SRV;
break;
case 'n':
- if (flags == 0) /* DSR ANSI */
- return VTE_CMD_DSR_ANSI;
+ if (flags == 0) /* DSR ECMA */
+ return VTE_CMD_DSR_ECMA;
else if (flags == VTE_SEQ_FLAG_GT) /* XTERM RMR */
return VTE_CMD_XTERM_RRV;
else if (flags == VTE_SEQ_FLAG_WHAT) /* DSR DEC */
diff --git a/src/vteseq-list.hh b/src/vteseq-list.hh
index 4393cb1..43b7e12 100644
--- a/src/vteseq-list.hh
+++ b/src/vteseq-list.hh
@@ -43,14 +43,12 @@ SEQUENCE_HANDLER(cursor_position)
SEQUENCE_HANDLER(cursor_position_top_row)
SEQUENCE_HANDLER(cursor_preceding_line)
SEQUENCE_HANDLER(cursor_up)
-SEQUENCE_HANDLER(dec_device_status_report)
SEQUENCE_HANDLER(dec_media_copy)
SEQUENCE_HANDLER(decreset)
SEQUENCE_HANDLER(decset)
SEQUENCE_HANDLER(delete_characters)
SEQUENCE_HANDLER(delete_lines)
SEQUENCE_HANDLER(device_control_string)
-SEQUENCE_HANDLER(device_status_report)
SEQUENCE_HANDLER(double_height_bottom_half)
SEQUENCE_HANDLER(double_height_top_half)
SEQUENCE_HANDLER(double_width)
diff --git a/src/vteseq.cc b/src/vteseq.cc
index 730217a..b8c8a77 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -2337,96 +2337,6 @@ VteTerminalPrivate::delete_lines(vte::grid::row_t param)
m_text_deleted_flag = TRUE;
}
-/* Device status reports. The possible reports are the cursor position and
- * whether or not we're okay. */
-void
-VteTerminalPrivate::seq_device_status_report(vte::parser::Params const& params)
-{
- int param;
- if (!params.number_at(0, param))
- return;
-
- switch (param) {
- case 5:
- /* Send a thumbs-up sequence. */
- feed_child(_VTE_CAP_CSI "0n", -1);
- break;
- case 6:
- /* Send the cursor position. */
- vte::grid::row_t rowval, origin, rowmax;
- if (m_origin_mode &&
- m_scrolling_restricted) {
- origin = m_scrolling_region.start;
- rowmax = m_scrolling_region.end;
- } else {
- origin = 0;
- rowmax = m_row_count - 1;
- }
- // FIXMEchpe this looks wrong. shouldn't this first clamp to origin,rowmax
and *then* subtract origin?
- rowval = m_screen->cursor.row - m_screen->insert_delta - origin;
- rowval = CLAMP(rowval, 0, rowmax);
- char buf[128];
- g_snprintf(buf, sizeof(buf),
- _VTE_CAP_CSI "%ld;%ldR",
- rowval + 1,
- CLAMP(m_screen->cursor.col + 1, 1, m_column_count));
- feed_child(buf, -1);
- break;
- default:
- break;
- }
-}
-
-/* DEC-style device status reports. */
-void
-VteTerminalPrivate::seq_dec_device_status_report(vte::parser::Params const& params)
-{
- int param;
- if (!params.number_at(0, param))
- return;
-
- switch (param) {
- case 6:
- /* Send the cursor position. */
- vte::grid::row_t rowval, origin, rowmax;
- if (m_origin_mode &&
- m_scrolling_restricted) {
- origin = m_scrolling_region.start;
- rowmax = m_scrolling_region.end;
- } else {
- origin = 0;
- rowmax = m_row_count - 1;
- }
- // FIXMEchpe this looks wrong. shouldn't this first clamp to origin,rowmax
and *then* subtract origin?
- rowval = m_screen->cursor.row - m_screen->insert_delta - origin;
- rowval = CLAMP(rowval, 0, rowmax);
- char buf[128];
- g_snprintf(buf, sizeof(buf),
- _VTE_CAP_CSI "?%ld;%ldR",
- rowval + 1,
- CLAMP(m_screen->cursor.col + 1, 1, m_column_count));
- feed_child(buf, -1);
- break;
- case 15:
- /* Send printer status -- 10 = ready,
- * 11 = not ready. We don't print. */
- feed_child(_VTE_CAP_CSI "?11n", -1);
- break;
- case 25:
- /* Send UDK status -- 20 = locked,
- * 21 = not locked. I don't even know what
- * that means, but punt anyway. */
- feed_child(_VTE_CAP_CSI "?20n", -1);
- break;
- case 26:
- /* Send keyboard status. 50 = no locator. */
- feed_child(_VTE_CAP_CSI "?50n", -1);
- break;
- default:
- break;
- }
-}
-
/* Restore a certain terminal attribute. */
void
VteTerminalPrivate::seq_restore_mode(vte::parser::Params const& params)
@@ -4733,15 +4643,60 @@ VteTerminalPrivate::DOCS(vte::parser::Sequence const& seq)
}
void
-VteTerminalPrivate::DSR_ANSI(vte::parser::Sequence const& seq)
+VteTerminalPrivate::DSR_ECMA(vte::parser::Sequence const& seq)
{
/*
- * DSR_ANSI - device-status-report-ansi
+ * DSR_ECMA - Device Status Report
*
- * TODO: implement
+ * Reports status, or requests a status report.
+ *
+ * Defaults:
+ * arg[0]: 0
+ *
+ * References: ECMA-48 § 8.3.35
*/
- seq_device_status_report(seq);
+ auto param = seq.collect1(0);
+
+ switch (param) {
+ case -1:
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ /* This is a status report */
+ break;
+ case 5:
+ /* Requesting a DSR */
+ feed_child(_VTE_CAP_CSI "0n", -1);
+ break;
+ case 6:
+ /* Requesting a CPR */
+
+ /* Send the cursor position. */
+ vte::grid::row_t rowval, origin, rowmax;
+ if (m_origin_mode &&
+ m_scrolling_restricted) {
+ origin = m_scrolling_region.start;
+ rowmax = m_scrolling_region.end;
+ } else {
+ origin = 0;
+ rowmax = m_row_count - 1;
+ }
+ // FIXMEchpe this looks wrong. shouldn't this first clamp to origin,rowmax and *then*
subtract origin?
+ rowval = m_screen->cursor.row - m_screen->insert_delta - origin;
+ rowval = CLAMP(rowval, 0, rowmax);
+ char buf[128];
+ g_snprintf(buf, sizeof(buf),
+ _VTE_CAP_CSI "%ld;%ldR",
+ rowval + 1,
+ CLAMP(m_screen->cursor.col + 1, 1, m_column_count));
+ feed_child(buf, -1);
+ break;
+ default:
+ break;
+ }
}
void
@@ -4750,10 +4705,56 @@ VteTerminalPrivate::DSR_DEC(vte::parser::Sequence const& seq)
/*
* DSR_DEC - device-status-report-dec
*
- * TODO: implement
+ * Reports status, or requests a status report.
+ *
+ * Defaults:
+ * arg[0]: 0
+ *
+ * References: VT525 5–173
*/
- seq_dec_device_status_report(seq);
+ auto param = seq.collect1(0);
+
+ switch (param) {
+ case 6:
+ /* Send the cursor position. */
+ vte::grid::row_t rowval, origin, rowmax;
+ if (m_origin_mode &&
+ m_scrolling_restricted) {
+ origin = m_scrolling_region.start;
+ rowmax = m_scrolling_region.end;
+ } else {
+ origin = 0;
+ rowmax = m_row_count - 1;
+ }
+ // FIXMEchpe this looks wrong. shouldn't this first clamp to origin,rowmax and *then*
subtract origin?
+ rowval = m_screen->cursor.row - m_screen->insert_delta - origin;
+ rowval = CLAMP(rowval, 0, rowmax);
+ char buf[128];
+ g_snprintf(buf, sizeof(buf),
+ _VTE_CAP_CSI "?%ld;%ldR",
+ rowval + 1,
+ CLAMP(m_screen->cursor.col + 1, 1, m_column_count));
+ feed_child(buf, -1);
+ break;
+ case 15:
+ /* Send printer status -- 10 = ready,
+ * 11 = not ready. We don't print. */
+ feed_child(_VTE_CAP_CSI "?11n", -1);
+ break;
+ case 25:
+ /* Send UDK status -- 20 = locked,
+ * 21 = not locked. I don't even know what
+ * that means, but punt anyway. */
+ feed_child(_VTE_CAP_CSI "?20n", -1);
+ break;
+ case 26:
+ /* Send keyboard status. 50 = no locator. */
+ feed_child(_VTE_CAP_CSI "?50n", -1);
+ break;
+ default:
+ break;
+ }
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]