Simplify editor constructor
This commit is contained in:
parent
c3dee47b46
commit
93ac2604b2
@ -237,14 +237,13 @@ impl Editor {
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let mut instance = Self::default();
|
let size = Self::get_window_size();
|
||||||
|
|
||||||
let size = instance.get_window_size();
|
Editor {
|
||||||
|
screen_cols: size.cols as usize,
|
||||||
instance.screen_cols = size.cols as usize;
|
screen_rows: (size.rows - 2) as usize,
|
||||||
instance.screen_rows = (size.rows - 2) as usize;
|
..Editor::default()
|
||||||
|
}
|
||||||
instance
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
@ -420,7 +419,7 @@ impl Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get terminal size in rows and columns
|
/// Get terminal size in rows and columns
|
||||||
fn get_window_size(&mut self) -> TermSize {
|
fn get_window_size() -> TermSize {
|
||||||
match get_term_size() {
|
match get_term_size() {
|
||||||
Some(size) => size,
|
Some(size) => size,
|
||||||
None => get_cursor_position(),
|
None => get_cursor_position(),
|
||||||
|
Loading…
Reference in New Issue
Block a user