Skip to content

Commit

Permalink
undo rustfmt changes
Browse files Browse the repository at this point in the history
  • Loading branch information
xubaiwang committed Oct 10, 2024
1 parent 595c78b commit 4f4ca2f
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 122 deletions.
46 changes: 17 additions & 29 deletions src/app/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,15 @@ use {
},
std::{
io::Write,
path::{
Path,
PathBuf,
},
path::{Path, PathBuf},
str::FromStr,
sync::{
Arc,
Mutex,
},
},
strict::NonEmptyVec,
termimad::{
EventSource,
EventSourceOptions,
},
termimad::{EventSource, EventSourceOptions},
};

/// The GUI
Expand Down Expand Up @@ -241,10 +235,7 @@ impl App {
/// Close the panel too if that was its only state.
/// Close nothing and return false if there's not
/// at least two states in the app.
fn remove_state(
&mut self,
con: &AppContext,
) -> bool {
fn remove_state(&mut self, con: &AppContext) -> bool {
self.panels[self.active_panel_idx].remove_state()
|| self.close_panel(self.active_panel_idx, con)
}
Expand Down Expand Up @@ -448,13 +439,12 @@ impl App {
}
Internal::panel_right_no_open => {
// we either move to the right or close the leftest panel
new_active_panel_idx =
if self.active_panel_idx + 1 == self.panels.len().get() {
self.close_panel(0, con);
None
} else {
Some(self.active_panel_idx + 1)
};
new_active_panel_idx = if self.active_panel_idx + 1 == self.panels.len().get() {
self.close_panel(0, con);
None
} else {
Some(self.active_panel_idx + 1)
};
}
Internal::search_again => {
if let Some(raw_pattern) = &self.panel().last_raw_pattern {
Expand Down Expand Up @@ -554,8 +544,7 @@ impl App {
purpose,
direction,
} => {
if let Err(s) = self.new_panel(state, purpose, direction, is_input_invocation, con)
{
if let Err(s) = self.new_panel(state, purpose, direction, is_input_invocation, con) {
error = Some(s);
}
}
Expand Down Expand Up @@ -825,15 +814,14 @@ impl App {
// when a long search is running, and interrupt it if needed
w.flush()?;
let combine_keys = conf.enable_kitty_keyboard.unwrap_or(false) && con.is_tty;
let event_source = EventSource::with_options(EventSourceOptions {
combine_keys,
..Default::default()
})?;
let event_source = EventSource::with_options(
EventSourceOptions {
combine_keys,
..Default::default()
}
)?;
con.keyboard_enhanced = event_source.supports_multi_key_combinations();
info!(
"event source is combining: {}",
event_source.supports_multi_key_combinations()
);
info!("event source is combining: {}", event_source.supports_multi_key_combinations());

let rx_events = event_source.receiver();
let mut dam = Dam::from(rx_events);
Expand Down
55 changes: 12 additions & 43 deletions src/app/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use {
crate::{
command::*,
display::{
flags_display,
status_line,
Areas,
Screen,
W,
WIDE_STATUS,
flags_display,
},
errors::ProgramError,
keys::KEY_FORMAT,
Expand All @@ -17,10 +17,7 @@ use {
verb::*,
},
termimad::{
minimad::{
Alignment,
Composite,
},
minimad::{Alignment, Composite},
TimedEvent,
},
};
Expand Down Expand Up @@ -58,10 +55,7 @@ impl Panel {
}
}

pub fn set_error(
&mut self,
text: String,
) {
pub fn set_error(&mut self, text: String) {
self.status = Status::from_error(text);
}
pub fn set_message<S: Into<String>>(
Expand Down Expand Up @@ -95,12 +89,7 @@ impl Panel {
};
let result = self.states[state_idx].on_command(w, app_state, &cc);
let has_previous_state = self.states.len() > 1;
self.status = self.state().get_status(
app_state,
&cc,
has_previous_state,
self.areas.status.width as usize,
);
self.status = self.state().get_status(app_state, &cc, has_previous_state, self.areas.status.width as usize);
result
}

Expand All @@ -121,12 +110,7 @@ impl Panel {
},
};
let has_previous_state = self.states.len() > 1;
self.status = self.state().get_status(
app_state,
&cc,
has_previous_state,
self.areas.status.width as usize,
);
self.status = self.state().get_status(app_state, &cc, has_previous_state, self.areas.status.width as usize);
}

/// do the next pending task stopping as soon as there's an event
Expand All @@ -138,8 +122,7 @@ impl Panel {
con: &AppContext,
dam: &mut Dam,
) -> Result<(), ProgramError> {
self.mut_state()
.do_pending_task(app_state, screen, con, dam)
self.mut_state().do_pending_task(app_state, screen, con, dam)
}

pub fn has_pending_task(&self) -> bool {
Expand All @@ -158,14 +141,10 @@ impl Panel {
let sel_info = self.states[self.states.len() - 1].sel_info(app_state);
let mode = self.state().get_mode();
let panel_state_type = self.state().get_type();
self.input
.on_event(w, event, con, sel_info, app_state, mode, panel_state_type)
self.input.on_event(w, event, con, sel_info, app_state, mode, panel_state_type)
}

pub fn push_state(
&mut self,
new_state: Box<dyn PanelState>,
) {
pub fn push_state(&mut self, new_state: Box<dyn PanelState>) {
self.input.set_content(&new_state.get_starting_input());
self.states.push(new_state);
}
Expand All @@ -181,10 +160,7 @@ impl Panel {
}
/// remove the verb invocation from the input but keep
/// the filter if there's one
pub fn clear_input_invocation(
&mut self,
con: &AppContext,
) {
pub fn clear_input_invocation(&mut self, con: &AppContext) {
let mut command_parts = CommandParts::from(self.input.get_content());
if command_parts.verb_invocation.is_some() {
command_parts.verb_invocation = None;
Expand All @@ -194,10 +170,7 @@ impl Panel {
self.mut_state().set_mode(con.initial_mode());
}

pub fn set_input_content(
&mut self,
content: &str,
) {
pub fn set_input_content(&mut self, content: &str) {
self.input.set_content(content);
}

Expand All @@ -206,10 +179,7 @@ impl Panel {
}

/// change the argument of the verb in the input, if there's one
pub fn set_input_arg(
&mut self,
arg: String,
) {
pub fn set_input_arg(&mut self, arg: String) {
let mut command_parts = CommandParts::from(self.input.get_content());
if let Some(invocation) = &mut command_parts.verb_invocation {
invocation.args = Some(arg);
Expand Down Expand Up @@ -247,8 +217,7 @@ impl Panel {
let flags_len = flags_display::visible_width(&flags);
if input_area.width > input_content_len + 1 + flags_len {
input_area.width -= flags_len + 1;
disc.screen
.goto(w, input_area.left + input_area.width, input_area.top)?;
disc.screen.goto(w, input_area.left + input_area.width, input_area.top)?;
flags_display::write(w, &flags, disc.panel_skin)?;
}
}
Expand Down
Loading

0 comments on commit 4f4ca2f

Please sign in to comment.