@@ -9,7 +9,10 @@ fn prints_prompt() -> std::io::Result<()> {
9
9
terminal. read_from_pty ( & mut pty, Some ( Duration :: from_millis ( 50 ) ) ) ?;
10
10
11
11
let text = extract_text ( terminal. inner ( ) ) ;
12
+ #[ cfg( not( windows) ) ]
12
13
assert_eq ! ( & text[ 0 ] [ ..13 ] , "~/reedline〉" ) ;
14
+ #[ cfg( windows) ]
15
+ assert_eq ! ( & text[ 0 ] [ ..13 ] , "~\\ reedline〉" ) ;
13
16
14
17
Ok ( ( ) )
15
18
}
@@ -27,7 +30,6 @@ fn echos_input() -> std::io::Result<()> {
27
30
28
31
assert_eq ! ( & text[ 0 ] [ 13 ..25 ] , "Hello World!" ) ;
29
32
assert_eq ! ( & text[ 1 ] [ 0 ..26 ] , "We processed: Hello World!" ) ;
30
- assert_eq ! ( & text[ 2 ] [ 0 ..13 ] , "~/reedline〉" ) ;
31
33
32
34
Ok ( ( ) )
33
35
}
@@ -47,7 +49,6 @@ fn backspace() -> std::io::Result<()> {
47
49
let text = extract_text ( terminal. inner ( ) ) ;
48
50
assert_eq ! ( & text[ 0 ] [ 13 ..25 ] , "Hello Bread!" ) ;
49
51
assert_eq ! ( & text[ 1 ] [ 0 ..26 ] , "We processed: Hello Bread!" ) ;
50
- assert_eq ! ( & text[ 2 ] [ 0 ..13 ] , "~/reedline〉" ) ;
51
52
52
53
Ok ( ( ) )
53
54
}
@@ -68,7 +69,7 @@ fn history() -> std::io::Result<()> {
68
69
pty. writer ( ) . write_all ( b"\x1b [A" ) ?;
69
70
terminal. read_from_pty ( & mut pty, Some ( Duration :: from_millis ( 50 ) ) ) ?;
70
71
let text = extract_text ( terminal. inner ( ) ) ;
71
- assert_eq ! ( & text[ 4 ] [ ..21 ] , "~/reedline〉 Goodbye!" ) ;
72
+ assert_eq ! ( & text[ 4 ] [ 13 ..21 ] , "Goodbye!" ) ;
72
73
73
74
// press Enter to execute it
74
75
pty. writer ( ) . write_all ( b"\r " ) ?;
@@ -80,19 +81,19 @@ fn history() -> std::io::Result<()> {
80
81
pty. writer ( ) . write_all ( b"\x1b [A\x1b [A" ) ?;
81
82
terminal. read_from_pty ( & mut pty, Some ( Duration :: from_millis ( 50 ) ) ) ?;
82
83
let text = extract_text ( terminal. inner ( ) ) ;
83
- assert_eq ! ( & text[ 6 ] [ ..25 ] , "~/reedline〉 Hello World!" ) ;
84
+ assert_eq ! ( & text[ 6 ] [ 13 ..25 ] , "Hello World!" ) ;
84
85
85
86
// arrow down twice
86
87
pty. writer ( ) . write_all ( b"\x1b [B\x1b [B" ) ?;
87
88
terminal. read_from_pty ( & mut pty, Some ( Duration :: from_millis ( 50 ) ) ) ?;
88
89
let text = extract_text ( terminal. inner ( ) ) ;
89
- assert_eq ! ( & text[ 6 ] [ ..25 ] , "~/reedline〉 " ) ;
90
+ assert_eq ! ( & text[ 6 ] [ 13 ..25 ] , " " ) ;
90
91
91
92
// type "Hel" then arrow up
92
93
pty. writer ( ) . write_all ( b"Hel\x1b [A" ) ?;
93
94
terminal. read_from_pty ( & mut pty, Some ( Duration :: from_millis ( 50 ) ) ) ?;
94
95
let text = extract_text ( terminal. inner ( ) ) ;
95
- assert_eq ! ( & text[ 6 ] [ ..25 ] , "~/reedline〉 Hello World!" ) ;
96
+ assert_eq ! ( & text[ 6 ] [ 13 ..25 ] , "Hello World!" ) ;
96
97
97
98
// TODO: not sure how reverse search works in Reedline
98
99
@@ -119,7 +120,7 @@ fn word_movement() -> std::io::Result<()> {
119
120
terminal. read_from_pty ( & mut pty, Some ( Duration :: from_millis ( 50 ) ) ) ?;
120
121
121
122
let text = extract_text ( terminal. inner ( ) ) ;
122
- assert_eq ! ( & text[ 0 ] [ ..26 ] , "~/reedline〉 foo bazar baz" ) ;
123
+ assert_eq ! ( & text[ 0 ] [ 13 ..26 ] , "foo bazar baz" ) ;
123
124
assert_eq ! ( & text[ 1 ] [ ..27 ] , "We processed: foo bazar baz" ) ;
124
125
125
126
Ok ( ( ) )
@@ -139,7 +140,7 @@ fn clear_screen() -> std::io::Result<()> {
139
140
terminal. read_from_pty ( & mut pty, Some ( Duration :: from_millis ( 50 ) ) ) ?;
140
141
141
142
let text = extract_text ( terminal. inner ( ) ) ;
142
- assert_eq ! ( & text[ 0 ] [ ..25 ] , "~/reedline〉 Hello again!" ) ;
143
+ assert_eq ! ( & text[ 0 ] [ 13 ..25 ] , "Hello again!" ) ;
143
144
144
145
Ok ( ( ) )
145
146
}
@@ -157,25 +158,25 @@ fn emacs_keybinds() -> std::io::Result<()> {
157
158
pty. writer ( ) . write_all ( b"\x1a " ) ?;
158
159
terminal. read_from_pty ( & mut pty, Some ( Duration :: from_millis ( 50 ) ) ) ?;
159
160
let text = extract_text ( terminal. inner ( ) ) ;
160
- assert_eq ! ( & text[ 0 ] [ ..25 ] , "~/reedline〉 Hello " ) ;
161
+ assert_eq ! ( & text[ 0 ] [ 13 ..25 ] , "Hello " ) ;
161
162
162
163
// redo with Ctrl-g
163
164
pty. writer ( ) . write_all ( b"\x07 " ) ?;
164
165
terminal. read_from_pty ( & mut pty, Some ( Duration :: from_millis ( 50 ) ) ) ?;
165
166
let text = extract_text ( terminal. inner ( ) ) ;
166
- assert_eq ! ( & text[ 0 ] [ ..25 ] , "~/reedline〉 Hello World!" ) ;
167
+ assert_eq ! ( & text[ 0 ] [ 13 ..25 ] , "Hello World!" ) ;
167
168
168
169
// delete "World" with alt+left, alt+backspace
169
170
pty. writer ( ) . write_all ( b"\x1b [1;3D\x1b \x7f " ) ?;
170
171
terminal. read_from_pty ( & mut pty, Some ( Duration :: from_millis ( 50 ) ) ) ?;
171
172
let text = extract_text ( terminal. inner ( ) ) ;
172
- assert_eq ! ( & text[ 0 ] [ ..25 ] , "~/reedline〉 Hello ! " ) ;
173
+ assert_eq ! ( & text[ 0 ] [ 13 ..25 ] , "Hello ! " ) ;
173
174
174
175
// make "Hello" ALL CAPS with alt+b, alt+u
175
176
pty. writer ( ) . write_all ( b"\x1b b\x1b u" ) ?;
176
177
terminal. read_from_pty ( & mut pty, Some ( Duration :: from_millis ( 50 ) ) ) ?;
177
178
let text = extract_text ( terminal. inner ( ) ) ;
178
- assert_eq ! ( & text[ 0 ] [ ..25 ] , "~/reedline〉 HELLO ! " ) ;
179
+ assert_eq ! ( & text[ 0 ] [ 13 ..25 ] , "HELLO ! " ) ;
179
180
180
181
Ok ( ( ) )
181
182
}
0 commit comments