File tree 2 files changed +18
-3
lines changed
2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ impl InMemoryTerm {
26
26
27
27
pub fn reset ( & self ) {
28
28
let mut state = self . state . lock ( ) . unwrap ( ) ;
29
- * state = InMemoryTermState :: new ( state. parser . screen ( ) . size ( ) . 0 , state. width ) ;
29
+ * state = InMemoryTermState :: new ( state. height , state. width ) ;
30
30
}
31
31
32
32
pub fn contents ( & self ) -> String {
@@ -99,6 +99,10 @@ impl TermLike for InMemoryTerm {
99
99
self . state . lock ( ) . unwrap ( ) . width
100
100
}
101
101
102
+ fn height ( & self ) -> u16 {
103
+ self . state . lock ( ) . unwrap ( ) . height
104
+ }
105
+
102
106
fn move_cursor_up ( & self , n : usize ) -> std:: io:: Result < ( ) > {
103
107
match n {
104
108
0 => Ok ( ( ) ) ,
@@ -158,13 +162,15 @@ impl TermLike for InMemoryTerm {
158
162
159
163
struct InMemoryTermState {
160
164
width : u16 ,
165
+ height : u16 ,
161
166
parser : vt100:: Parser ,
162
167
}
163
168
164
169
impl InMemoryTermState {
165
170
pub ( crate ) fn new ( rows : u16 , cols : u16 ) -> InMemoryTermState {
166
171
InMemoryTermState {
167
172
width : cols,
173
+ height : rows,
168
174
parser : Parser :: new ( rows, cols, 0 ) ,
169
175
}
170
176
}
Original file line number Diff line number Diff line change @@ -11,14 +11,19 @@ use console::Term;
11
11
pub trait TermLike : Debug + Send + Sync {
12
12
/// Return the terminal width
13
13
fn width ( & self ) -> u16 ;
14
+ /// Return the terminal height
15
+ fn height ( & self ) -> u16 {
16
+ // FIXME: remove this default impl in the next major version bump
17
+ 20 // sensible default
18
+ }
14
19
15
20
/// Move the cursor up by `n` lines
16
21
fn move_cursor_up ( & self , n : usize ) -> io:: Result < ( ) > ;
17
22
/// Move the cursor down by `n` lines
18
23
fn move_cursor_down ( & self , n : usize ) -> io:: Result < ( ) > ;
19
- /// Move the cursor right by `n` lines
24
+ /// Move the cursor right by `n` chars
20
25
fn move_cursor_right ( & self , n : usize ) -> io:: Result < ( ) > ;
21
- /// Move the cursor left by `n` lines
26
+ /// Move the cursor left by `n` chars
22
27
fn move_cursor_left ( & self , n : usize ) -> io:: Result < ( ) > ;
23
28
24
29
/// Write a string and add a newline.
@@ -36,6 +41,10 @@ impl TermLike for Term {
36
41
self . size ( ) . 1
37
42
}
38
43
44
+ fn height ( & self ) -> u16 {
45
+ self . size ( ) . 0
46
+ }
47
+
39
48
fn move_cursor_up ( & self , n : usize ) -> io:: Result < ( ) > {
40
49
self . move_cursor_up ( n)
41
50
}
You can’t perform that action at this time.
0 commit comments