Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl Application {

let theme_mode = backend.get_theme_mode();
let terminal = Terminal::new(backend)?;
let area = terminal.size().expect("couldn't get terminal size");
let area = terminal.size();
let mut compositor = Compositor::new(area);
let config = Arc::new(ArcSwap::from_pointee(config));
let handlers = handlers::setup(config.clone());
Expand Down Expand Up @@ -542,7 +542,7 @@ impl Application {
}

// redraw the terminal
let area = self.terminal.size().expect("couldn't get terminal size");
let area = self.terminal.size();
self.compositor.resize(area);
self.terminal.clear().expect("couldn't clear terminal");

Expand Down Expand Up @@ -700,7 +700,7 @@ impl Application {
.resize(Rect::new(0, 0, cols, rows))
.expect("Unable to resize terminal");

let area = self.terminal.size().expect("couldn't get terminal size");
let area = self.terminal.size();

self.compositor.resize(area);

Expand Down Expand Up @@ -729,7 +729,7 @@ impl Application {
.resize(Rect::new(0, 0, width, height))
.expect("Unable to resize terminal");

let area = self.terminal.size().expect("couldn't get terminal size");
let area = self.terminal.size();

self.compositor.resize(area);

Expand Down
16 changes: 12 additions & 4 deletions helix-tui/src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,22 @@ where
viewport: Viewport,
}

/// Default terminal size: 80 columns, 24 lines
pub const DEFAULT_TERMINAL_SIZE: Rect = Rect {
x: 0,
y: 0,
width: 80,
height: 24,
};

impl<B> Terminal<B>
where
B: Backend,
{
/// Wrapper around Terminal initialization. Each buffer is initialized with a blank string and
/// default colors for the foreground and the background
pub fn new(backend: B) -> io::Result<Terminal<B>> {
let size = backend.size()?;
let size = backend.size().unwrap_or(DEFAULT_TERMINAL_SIZE);
Terminal::with_options(
backend,
TerminalOptions {
Expand Down Expand Up @@ -159,7 +167,7 @@ where

/// Queries the backend for size and resizes if it doesn't match the previous size.
pub fn autoresize(&mut self) -> io::Result<Rect> {
let size = self.size()?;
let size = self.size();
if size != self.viewport.area {
self.resize(size)?;
};
Expand Down Expand Up @@ -235,7 +243,7 @@ where
}

/// Queries the real size of the backend.
pub fn size(&self) -> io::Result<Rect> {
self.backend.size()
pub fn size(&self) -> Rect {
self.backend.size().unwrap_or(DEFAULT_TERMINAL_SIZE)
}
}
Loading