-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update dependencies and clean up unused ones (#3)
* chore: update dependencies and clean up unused ones * chore: use latest version of syntect-tui * style: format via rustfmt * refactor: fix clippy lints * refactor: fix clippy lints
- Loading branch information
Showing
14 changed files
with
1,679 additions
and
1,194 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,42 +7,38 @@ license = "Apache-2.0" | |
authors = ["Chleba <[email protected]>"] | ||
build = "build.rs" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
ratatui = { version = "0.28.1", features = ["serde", "macros", "unstable-widget-ref", "unstable"] } | ||
ratatui-image = { version = "1.0.5", features = ["crossterm"] } | ||
crossterm = { version = "0.28.1", features = ["serde", "event-stream"] } | ||
tui-big-text = "0.6.0" | ||
better-panic = "0.3.0" | ||
clap = { version = "4.4.5", features = ["derive", "cargo", "wrap_help", "unicode", "string", "unstable-styles"] } | ||
color-eyre = "0.6.2" | ||
syntect = "5.2.0" | ||
clap = { version = "4.5.17", features = ["derive", "cargo", "wrap_help", "unicode", "string", "unstable-styles"] } | ||
config = "0.14.0" | ||
crossterm = { version = "0.27.0", features = ["serde", "event-stream"] } | ||
derive_deref = "1.1.1" | ||
directories = "5.0.1" | ||
futures = "0.3.28" | ||
human-panic = "1.2.0" | ||
human-panic = "2.0.1" | ||
color-eyre = "0.6.2" | ||
dyn-clone = "1.0.11" | ||
rustix = { version = "^0.38.4", optional = true, features = ["stdio", "termios", "fs"]} | ||
image = "0.24.9" | ||
image = { version = "0.25.2", default-features = false, features = ["png", "jpeg"] } | ||
json5 = "0.4.1" | ||
lazy_static = "1.4.0" | ||
libc = "0.2.148" | ||
log = "0.4.20" | ||
pretty_assertions = "1.4.0" | ||
ratatui = { version = "0.26.2", features = ["serde", "macros", "unstable-widget-ref", "unstable"] } | ||
ratatui-image = { version = "1.0.0", features = ["crossterm"] } | ||
serde = { version = "1.0.188", features = ["derive"] } | ||
serde_json = "1.0.107" | ||
lazy_static = "1.5.0" | ||
serde = { version = "1.0.210", features = ["derive"] } | ||
serde_json = "1.0.128" | ||
signal-hook = "0.3.17" | ||
strip-ansi-escapes = "0.2.0" | ||
strum = { version = "0.26.1", features = ["derive"] } | ||
tokio = { version = "1.32.0", features = ["full"] } | ||
tokio-util = "0.7.9" | ||
strum = { version = "0.26.3", features = ["derive"] } | ||
tokio = { version = "1.40.0", features = ["full"] } | ||
tokio-util = "0.7.12" | ||
tracing = "0.1.37" | ||
tracing-error = "0.2.0" | ||
tracing-subscriber = { version = "0.3.17", features = ["env-filter", "serde"] } | ||
tui-big-text = "0.4.3" | ||
base64 = "0.22.1" | ||
syntect = "5.2.0" | ||
syntect-tui = "3.0.2" | ||
syntect-tui = "3.0.4" | ||
|
||
[build-dependencies] | ||
vergen = { version = "8.2.6", features = [ "build", "git", "gitoxide", "cargo" ]} | ||
vergen-gix = { version = "1.0.1", features = ["build"] } | ||
|
||
[dev-dependencies] | ||
pretty_assertions = "1.4.0" |
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,4 +1,8 @@ | ||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
vergen::EmitBuilder::builder().all_build().all_git().emit()?; | ||
Ok(()) | ||
let build = vergen_gix::BuildBuilder::all_build()?; | ||
vergen_gix::Emitter::default() | ||
.add_instructions(&build)? | ||
.add_instructions(&vergen_gix::GixBuilder::all_git()?)? | ||
.emit()?; | ||
Ok(()) | ||
} |
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,124 +1,124 @@ | ||
use color_eyre::eyre::Result; | ||
use crossterm::event::{KeyEvent, MouseEvent}; | ||
use ratatui::layout::Rect; | ||
use ratatui::layout::{Rect, Size}; | ||
use tokio::sync::mpsc::UnboundedSender; | ||
|
||
use crate::{ | ||
action::Action, | ||
config::Config, | ||
tui::{Event, Frame}, | ||
action::Action, | ||
config::Config, | ||
tui::{Event, Frame}, | ||
}; | ||
|
||
pub mod title; | ||
pub mod slides; | ||
pub mod title; | ||
|
||
/// `Component` is a trait that represents a visual and interactive element of the user interface. | ||
/// Implementors of this trait can be registered with the main application loop and will be able to receive events, | ||
/// update state, and be rendered on the screen. | ||
pub trait Component { | ||
/// Register an action handler that can send actions for processing if necessary. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `tx` - An unbounded sender that can send actions. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Result<()>` - An Ok result or an error. | ||
#[allow(unused_variables)] | ||
fn register_action_handler(&mut self, tx: UnboundedSender<Action>) -> Result<()> { | ||
Ok(()) | ||
} | ||
/// Register a configuration handler that provides configuration settings if necessary. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `config` - Configuration settings. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Result<()>` - An Ok result or an error. | ||
#[allow(unused_variables)] | ||
fn register_config_handler(&mut self, config: Config) -> Result<()> { | ||
Ok(()) | ||
} | ||
/// Initialize the component with a specified area if necessary. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `area` - Rectangular area to initialize the component within. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Result<()>` - An Ok result or an error. | ||
fn init(&mut self, area: Rect, json_slides: String) -> Result<()> { | ||
Ok(()) | ||
} | ||
/// Handle incoming events and produce actions if necessary. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `event` - An optional event to be processed. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Result<Option<Action>>` - An action to be processed or none. | ||
fn handle_events(&mut self, event: Option<Event>) -> Result<Option<Action>> { | ||
let r = match event { | ||
Some(Event::Key(key_event)) => self.handle_key_events(key_event)?, | ||
Some(Event::Mouse(mouse_event)) => self.handle_mouse_events(mouse_event)?, | ||
_ => None, | ||
}; | ||
Ok(r) | ||
} | ||
/// Handle key events and produce actions if necessary. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `key` - A key event to be processed. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Result<Option<Action>>` - An action to be processed or none. | ||
#[allow(unused_variables)] | ||
fn handle_key_events(&mut self, key: KeyEvent) -> Result<Option<Action>> { | ||
Ok(None) | ||
} | ||
/// Handle mouse events and produce actions if necessary. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `mouse` - A mouse event to be processed. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Result<Option<Action>>` - An action to be processed or none. | ||
#[allow(unused_variables)] | ||
fn handle_mouse_events(&mut self, mouse: MouseEvent) -> Result<Option<Action>> { | ||
Ok(None) | ||
} | ||
/// Update the state of the component based on a received action. (REQUIRED) | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `action` - An action that may modify the state of the component. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Result<Option<Action>>` - An action to be processed or none. | ||
#[allow(unused_variables)] | ||
fn update(&mut self, action: Action) -> Result<Option<Action>> { | ||
Ok(None) | ||
} | ||
/// Render the component on the screen. (REQUIRED) | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `f` - A frame used for rendering. | ||
/// * `area` - The area in which the component should be drawn. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Result<()>` - An Ok result or an error. | ||
fn draw(&mut self, f: &mut Frame<'_>, area: Rect) -> Result<()>; | ||
/// Register an action handler that can send actions for processing if necessary. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `tx` - An unbounded sender that can send actions. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Result<()>` - An Ok result or an error. | ||
#[allow(unused_variables)] | ||
fn register_action_handler(&mut self, tx: UnboundedSender<Action>) -> Result<()> { | ||
Ok(()) | ||
} | ||
/// Register a configuration handler that provides configuration settings if necessary. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `config` - Configuration settings. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Result<()>` - An Ok result or an error. | ||
#[allow(unused_variables)] | ||
fn register_config_handler(&mut self, config: Config) -> Result<()> { | ||
Ok(()) | ||
} | ||
/// Initialize the component with a specified area if necessary. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `area` - Rectangular area to initialize the component within. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Result<()>` - An Ok result or an error. | ||
fn init(&mut self, _area: Size, json_slides: String) -> Result<()> { | ||
Ok(()) | ||
} | ||
/// Handle incoming events and produce actions if necessary. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `event` - An optional event to be processed. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Result<Option<Action>>` - An action to be processed or none. | ||
fn handle_events(&mut self, event: Option<Event>) -> Result<Option<Action>> { | ||
let r = match event { | ||
Some(Event::Key(key_event)) => self.handle_key_events(key_event)?, | ||
Some(Event::Mouse(mouse_event)) => self.handle_mouse_events(mouse_event)?, | ||
_ => None, | ||
}; | ||
Ok(r) | ||
} | ||
/// Handle key events and produce actions if necessary. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `key` - A key event to be processed. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Result<Option<Action>>` - An action to be processed or none. | ||
#[allow(unused_variables)] | ||
fn handle_key_events(&mut self, key: KeyEvent) -> Result<Option<Action>> { | ||
Ok(None) | ||
} | ||
/// Handle mouse events and produce actions if necessary. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `mouse` - A mouse event to be processed. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Result<Option<Action>>` - An action to be processed or none. | ||
#[allow(unused_variables)] | ||
fn handle_mouse_events(&mut self, mouse: MouseEvent) -> Result<Option<Action>> { | ||
Ok(None) | ||
} | ||
/// Update the state of the component based on a received action. (REQUIRED) | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `action` - An action that may modify the state of the component. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Result<Option<Action>>` - An action to be processed or none. | ||
#[allow(unused_variables)] | ||
fn update(&mut self, action: Action) -> Result<Option<Action>> { | ||
Ok(None) | ||
} | ||
/// Render the component on the screen. (REQUIRED) | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `f` - A frame used for rendering. | ||
/// * `area` - The area in which the component should be drawn. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Result<()>` - An Ok result or an error. | ||
fn draw(&mut self, f: &mut Frame<'_>, area: Rect) -> Result<()>; | ||
} |
Oops, something went wrong.