Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] refactor: Rewrite drawing #534

Closed
wants to merge 3 commits into from
Closed
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
88 changes: 85 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ sysinfo = "0.18.2"
thiserror = "1.0.24"
toml = "0.5.8"
tui = { version = "0.14.0", features = ["crossterm"], default-features = false }
twox-hash = "1.6.0"
typed-builder = "0.9.0"
unicode-segmentation = "1.7.1"
unicode-width = "0.1"
Expand Down
16 changes: 8 additions & 8 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ pub struct AppConfigFields {
#[derive(TypedBuilder)]
pub struct AppState {
#[builder(default = false, setter(skip))]
awaiting_second_char: bool,
awaiting_second_char: bool, // TODO: Move out to input

#[builder(default, setter(skip))]
second_char: Option<char>,
second_char: Option<char>, // TODO: Move out to input

#[builder(default, setter(skip))]
pub dd_err: Option<String>,
Expand All @@ -83,7 +83,7 @@ pub struct AppState {
pub is_frozen: bool,

#[builder(default = Instant::now(), setter(skip))]
last_key_press: Instant,
last_key_press: Instant, // TODO: Move out to input

#[builder(default, setter(skip))]
pub canvas_data: canvas::DisplayableData,
Expand Down Expand Up @@ -129,11 +129,11 @@ pub struct AppState {
}

#[cfg(target_os = "windows")]
const MAX_SIGNAL: usize = 1;
const MAX_KILL_SIGNAL: usize = 1;
#[cfg(target_os = "linux")]
const MAX_SIGNAL: usize = 64;
const MAX_KILL_SIGNAL: usize = 64;
#[cfg(target_os = "macos")]
const MAX_SIGNAL: usize = 31;
const MAX_KILL_SIGNAL: usize = 31;

impl AppState {
pub fn reset(&mut self) {
Expand Down Expand Up @@ -967,7 +967,7 @@ impl AppState {
if self.delete_dialog_state.is_showing_dd {
let mut new_signal = match self.delete_dialog_state.selected_signal {
KillSignal::Cancel => 8,
KillSignal::Kill(signal) => min(signal + 8, MAX_SIGNAL),
KillSignal::Kill(signal) => min(signal + 8, MAX_KILL_SIGNAL),
};
if new_signal > 31 && new_signal < 42 {
new_signal += 2;
Expand Down Expand Up @@ -2133,7 +2133,7 @@ impl AppState {
.max_scroll_index
.saturating_sub(1);
} else if self.delete_dialog_state.is_showing_dd {
self.delete_dialog_state.selected_signal = KillSignal::Kill(MAX_SIGNAL);
self.delete_dialog_state.selected_signal = KillSignal::Kill(MAX_KILL_SIGNAL);
}
}

Expand Down
20 changes: 1 addition & 19 deletions src/app/layout_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -947,25 +947,7 @@ impl std::str::FromStr for BottomWidgetType {
"empty" => Ok(BottomWidgetType::Empty),
"battery" | "batt" => Ok(BottomWidgetType::Battery),
_ => Err(BottomError::ConfigError(format!(
"\"{}\" is an invalid widget name.

Supported widget names:
+--------------------------+
| cpu |
+--------------------------+
| mem, memory |
+--------------------------+
| net, network |
+--------------------------+
| proc, process, processes |
+--------------------------+
| temp, temperature |
+--------------------------+
| disk |
+--------------------------+
| batt, battery |
+--------------------------+
",
"\"{}\" is an invalid widget name.",
s
))),
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/widget_states/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub enum CursorDirection {
}

/// AppScrollWidgetState deals with fields for a scrollable app's current state.
#[derive(Default)]
#[derive(Debug, Default)]
pub struct AppScrollWidgetState {
pub current_scroll_position: usize,
pub previous_scroll_position: usize,
Expand Down Expand Up @@ -99,7 +99,7 @@ impl Default for AppHelpDialogState {
}

/// Meant for canvas operations involving table column widths.
#[derive(Default)]
#[derive(Debug, Default)]
pub struct CanvasTableWidthState {
pub desired_column_widths: Vec<u16>,
pub calculated_column_widths: Vec<u16>,
Expand Down
Loading