Skip to content

Commit 9a3a9df

Browse files
author
Noam Lewis
committed
trivial code sharing
1 parent 65894c6 commit 9a3a9df

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,13 @@ impl State {
9999
return Position::new(a.x.max(b.x), a.y.max(b.y));
100100
}
101101

102+
fn text_area(&self, window_area: Rect) -> Rect {
103+
Rect::new(0, 0, window_area.width, window_area.height - 1)
104+
}
105+
102106
fn scroll_to_cursor(&mut self, window_area: Rect) {
103107
// bring cursor into view
104-
let text_area = Rect::new(0, 0, window_area.width, window_area.height - 1);
108+
let text_area = self.text_area(window_area);
105109
let left_margin_width = self.left_margin_width();
106110

107111
let max_pos = Position::new(
@@ -333,7 +337,7 @@ impl State {
333337

334338
fn draw_frame(&mut self, frame: &mut Frame) {
335339
let window_area = frame.area();
336-
let text_area = Rect::new(0, 0, window_area.width, window_area.height - 1);
340+
let text_area = self.text_area(window_area);
337341
let status_area = Rect::new(0, window_area.height - 1, window_area.width, 1);
338342
let left_margin_width = self.left_margin_width();
339343
let cursor = self.cursor;

0 commit comments

Comments
 (0)