@@ -103,4 +103,45 @@ public void testFeature() throws InterruptedException {
103103 assertThat (term .currentLine (), is (text ));
104104 assertThat (term .lineAtOffset (+1 ), isEmptyString ());
105105 }
106- }
106+
107+ @ Test
108+ public void testCsiSequences () throws InterruptedException {
109+ XTermElement term = $ (XTermElement .class ).first ();
110+ Position pos = term .cursorPosition ();
111+
112+ term .sendKeys ("HELLO" );
113+ assertThat (term .currentLine (), is ("HELLO" ));
114+
115+ // Cursor Home Logical Line
116+ term .write ("\u001b [<H" );
117+ assertThat (term .cursorPosition (), is (pos ));
118+
119+ // Cursor End Logical Line
120+ term .write ("\u001b [<E" );
121+ assertThat (term .cursorPosition (), is (pos .plus (5 , 0 )));
122+
123+ // Cursor Backward Wrapped
124+ term .write ("\u001b [<L" );
125+ assertThat (term .cursorPosition (), is (pos .plus (4 , 0 )));
126+
127+ // Cursor Forward Wrapped
128+ term .write ("\u001b [<R" );
129+ assertThat (term .cursorPosition (), is (pos .plus (5 , 0 )));
130+
131+ // Backspace
132+ term .write ("\u001b [<B" );
133+ assertThat (term .cursorPosition (), is (pos .plus (4 , 0 )));
134+ assertThat (term .currentLine (), is ("HELL" ));
135+
136+ // Delete Characters Wrapped
137+ term .write ("\u001b [<H" );
138+ term .write ("\u001b [<D" );
139+ assertThat (term .cursorPosition (), is (pos ));
140+ assertThat (term .currentLine (), is ("ELL" ));
141+
142+ term .write ("\u001b [<2D" );
143+ assertThat (term .cursorPosition (), is (pos ));
144+ assertThat (term .currentLine (), is ("L" ));
145+ }
146+
147+ }
0 commit comments