-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: replace
color-backtrace
with color-eyre
This begins a general migration to `eyre` for error handling: https://github.com/yaahc/color-eyre
- Loading branch information
Showing
3 changed files
with
36 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,24 @@ | ||
//! Terminal component | ||
use crate::Component; | ||
use std::fmt; | ||
use termcolor::ColorChoice; | ||
|
||
/// Abscissa terminal subsystem component | ||
#[derive(Component)] | ||
#[derive(Component, Debug)] | ||
#[component(core)] | ||
pub struct Terminal {} | ||
|
||
impl Terminal { | ||
/// Create a new `TerminalComponent` with the given `ColorChoice` | ||
/// Create a new [`Terminal`] component with the given [`ColorChoice`] | ||
pub fn new(color_choice: ColorChoice) -> Terminal { | ||
// TODO(tarcieri): handle terminal reinit (without panicking) | ||
super::init(color_choice); | ||
|
||
if color_choice != ColorChoice::Never { | ||
color_backtrace::install(); | ||
// TODO(tarcieri): avoid panicking here | ||
color_eyre::install().expect("couldn't install color-eyre"); | ||
} | ||
|
||
Self {} | ||
} | ||
} | ||
|
||
impl fmt::Debug for Terminal { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
write!(f, "TerminalComponent {{ stdout, stderr }}") | ||
} | ||
} |