aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2023-04-18 22:46:35 -0500
committerGitHub <noreply@github.com>2023-04-18 22:46:35 -0500
commitae9350107bc11f4e5fcd60a017fe942e93aaec75 (patch)
tree63b479cd3faebc11d6ab92db961145b57af77229
parent7021de793f9945789276db2dd1006aac64f24495 (diff)
parent988ce9dce47d485e02dbde35573de3d14065b27e (diff)
downloadvt100-rust-ae9350107bc11f4e5fcd60a017fe942e93aaec75.tar.gz
vt100-rust-ae9350107bc11f4e5fcd60a017fe942e93aaec75.zip
Merge pull request #10 from FuegoFro/handle_previous_next_line
Add support for CSI E/F (next and previous line)
-rw-r--r--src/perform.rs2
-rw-r--r--src/screen.rs12
-rw-r--r--tests/data/fixtures/relative_movement.in4
-rw-r--r--tests/data/fixtures/relative_movement/18.json13
-rw-r--r--tests/data/fixtures/relative_movement/18.typescript1
-rw-r--r--tests/data/fixtures/relative_movement/19.json13
-rw-r--r--tests/data/fixtures/relative_movement/19.typescript1
-rw-r--r--tests/data/fixtures/relative_movement/20.json13
-rw-r--r--tests/data/fixtures/relative_movement/20.typescript1
-rw-r--r--tests/data/fixtures/relative_movement/21.json13
-rw-r--r--tests/data/fixtures/relative_movement/21.typescript1
11 files changed, 74 insertions, 0 deletions
diff --git a/src/perform.rs b/src/perform.rs
index c3c2e70..d528cb4 100644
--- a/src/perform.rs
+++ b/src/perform.rs
@@ -59,6 +59,8 @@ impl vte::Perform for WrappedScreen {
'B' => self.0.cud(canonicalize_params_1(params, 1)),
'C' => self.0.cuf(canonicalize_params_1(params, 1)),
'D' => self.0.cub(canonicalize_params_1(params, 1)),
+ 'E' => self.0.cnl(canonicalize_params_1(params, 1)),
+ 'F' => self.0.cpl(canonicalize_params_1(params, 1)),
'G' => self.0.cha(canonicalize_params_1(params, 1)),
'H' => self.0.cup(canonicalize_params_2(params, 1, 1)),
'J' => self.0.ed(canonicalize_params_1(params, 0)),
diff --git a/src/screen.rs b/src/screen.rs
index ad54694..6eeb2e3 100644
--- a/src/screen.rs
+++ b/src/screen.rs
@@ -1083,6 +1083,18 @@ impl Screen {
self.grid_mut().col_dec(offset);
}
+ // CSI E
+ pub(crate) fn cnl(&mut self, offset: u16) {
+ self.grid_mut().col_set(0);
+ self.grid_mut().row_inc_clamp(offset);
+ }
+
+ // CSI F
+ pub(crate) fn cpl(&mut self, offset: u16) {
+ self.grid_mut().col_set(0);
+ self.grid_mut().row_dec_clamp(offset);
+ }
+
// CSI G
pub(crate) fn cha(&mut self, col: u16) {
self.grid_mut().col_set(col - 1);
diff --git a/tests/data/fixtures/relative_movement.in b/tests/data/fixtures/relative_movement.in
index 1e744f5..f8339af 100644
--- a/tests/data/fixtures/relative_movement.in
+++ b/tests/data/fixtures/relative_movement.in
@@ -15,3 +15,7 @@
\x1b[500B
\x1b[500A
\x1b[24;80H\x1b[1ma\x1b[A
+\x1b[5;5H\x1b[3F
+\x1b[5;5H\x1b[F
+\x1b[5;5H\x1b[3E
+\x1b[5;5H\x1b[E
diff --git a/tests/data/fixtures/relative_movement/18.json b/tests/data/fixtures/relative_movement/18.json
new file mode 100644
index 0000000..8dde982
--- /dev/null
+++ b/tests/data/fixtures/relative_movement/18.json
@@ -0,0 +1,13 @@
+{
+ "contents": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n a",
+ "cells": {
+ "23,79": {
+ "contents": "a",
+ "bold": true
+ }
+ },
+ "cursor_position": [
+ 1,
+ 0
+ ]
+} \ No newline at end of file
diff --git a/tests/data/fixtures/relative_movement/18.typescript b/tests/data/fixtures/relative_movement/18.typescript
new file mode 100644
index 0000000..300ac2e
--- /dev/null
+++ b/tests/data/fixtures/relative_movement/18.typescript
@@ -0,0 +1 @@
+ \ No newline at end of file
diff --git a/tests/data/fixtures/relative_movement/19.json b/tests/data/fixtures/relative_movement/19.json
new file mode 100644
index 0000000..f151bb2
--- /dev/null
+++ b/tests/data/fixtures/relative_movement/19.json
@@ -0,0 +1,13 @@
+{
+ "contents": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n a",
+ "cells": {
+ "23,79": {
+ "contents": "a",
+ "bold": true
+ }
+ },
+ "cursor_position": [
+ 3,
+ 0
+ ]
+} \ No newline at end of file
diff --git a/tests/data/fixtures/relative_movement/19.typescript b/tests/data/fixtures/relative_movement/19.typescript
new file mode 100644
index 0000000..6dfedc0
--- /dev/null
+++ b/tests/data/fixtures/relative_movement/19.typescript
@@ -0,0 +1 @@
+ \ No newline at end of file
diff --git a/tests/data/fixtures/relative_movement/20.json b/tests/data/fixtures/relative_movement/20.json
new file mode 100644
index 0000000..479a1bd
--- /dev/null
+++ b/tests/data/fixtures/relative_movement/20.json
@@ -0,0 +1,13 @@
+{
+ "contents": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n a",
+ "cells": {
+ "23,79": {
+ "contents": "a",
+ "bold": true
+ }
+ },
+ "cursor_position": [
+ 7,
+ 0
+ ]
+} \ No newline at end of file
diff --git a/tests/data/fixtures/relative_movement/20.typescript b/tests/data/fixtures/relative_movement/20.typescript
new file mode 100644
index 0000000..17d2b03
--- /dev/null
+++ b/tests/data/fixtures/relative_movement/20.typescript
@@ -0,0 +1 @@
+ \ No newline at end of file
diff --git a/tests/data/fixtures/relative_movement/21.json b/tests/data/fixtures/relative_movement/21.json
new file mode 100644
index 0000000..ab71e23
--- /dev/null
+++ b/tests/data/fixtures/relative_movement/21.json
@@ -0,0 +1,13 @@
+{
+ "contents": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n a",
+ "cells": {
+ "23,79": {
+ "contents": "a",
+ "bold": true
+ }
+ },
+ "cursor_position": [
+ 5,
+ 0
+ ]
+} \ No newline at end of file
diff --git a/tests/data/fixtures/relative_movement/21.typescript b/tests/data/fixtures/relative_movement/21.typescript
new file mode 100644
index 0000000..b704ed4
--- /dev/null
+++ b/tests/data/fixtures/relative_movement/21.typescript
@@ -0,0 +1 @@
+ \ No newline at end of file