Skip to main content

App

Struct App 

Source
pub struct App { /* private fields */ }

Implementations§

Source§

impl App

Source

pub fn create( repo: Rc<Repository>, size: (u16, u16), args: &Args, config: Arc<Config>, enable_async_cmds: bool, piped: Option<Paged>, ) -> Res<Self>

Source

pub fn run(&mut self, term: &mut Term, max_tick_delay: Duration) -> Res<()>

Source

pub fn update(&mut self, term: &mut Term, event: Option<Event>) -> Res<()>

Source

pub fn update_screens(&mut self) -> Res<()>

Source

pub fn rerender_screens(&mut self) -> Res<()>

Rebuild every screen, leaving each cursor where it was in the diff rather than on the line number it happened to occupy. For a re-render of the same content (a renderer feature turned on or off), the rows move but the place in the patch does not.

Source

pub fn handle_event(&mut self, term: &mut Term, event: Event) -> Res<()>

Source

pub fn redraw_now(&mut self, term: &mut Term) -> Res<()>

Source

pub fn stage_redraw(&mut self)

Source

pub fn close_menu(&mut self)

Source

pub fn inhibit_close_menu(&mut self)

Source

pub fn display_info<S: Into<Cow<'static, str>>>(&mut self, message: S)

Displays an Info message to the CmdLog.

Source

pub fn display_error<S: Into<Cow<'static, str>>>(&mut self, message: S)

Displays an Error message to the CmdLog.

Source

pub fn run_cmd( &mut self, term: &mut Term, input: &[u8], cmd: Command, ) -> Res<()>

Runs a Command and handles its output. Will block awaiting its completion.

Source

pub fn run_cmd_async( &mut self, term: &mut Term, input: &[u8], cmd: Command, ) -> Res<()>

Runs a Command and handles its output asynchronously (if async commands are enabled). Will return Ok(()) if one is already running.

Source

pub fn run_cmd_interactive(&mut self, term: &mut Term, cmd: Command) -> Res<()>

Source

pub fn hide_menu(&mut self)

Source

pub fn confirm(&mut self, term: &mut Term, prompt: &'static str) -> Res<()>

Source

pub fn pick( &mut self, term: &mut Term, picker_state: PickerState, ) -> Res<Option<PickerData>>

Show a picker and wait for user to select an item or cancel.

Returns:

  • Ok(Some(data)) - User selected an item
  • Ok(None) - User cancelled (Esc or Ctrl-C)
  • Err(e) - An error occurred
§Example
ⓘ
let items = vec![
    PickerItem::new("main", PickerData::Item("main".to_string())),
    PickerItem::new("develop", PickerData::Item("develop".to_string())),
];
let picker = PickerState::new("Select branch", items, false);

match app.pick(term, picker)? {
    Some(PickerData::Item(name)) => {
        // User selected a branch
        println!("Selected: {}", name);
    }
    Some(PickerData::CustomInput(_)) => {
        // Should not happen when allow_custom_input is false
    }
    None => {
        // User cancelled
        println!("Cancelled");
    }
}
Source

pub fn pick_commit(&mut self, term: &mut Term) -> Res<Option<String>>

Choose a commit by moving around a log view: the screen is pushed with its own keymap, and the loop runs until select_commit names one or the screen is closed.

Auto Trait Implementations§

§

impl !Freeze for App

§

impl !RefUnwindSafe for App

§

impl !Send for App

§

impl !Sync for App

§

impl !UnwindSafe for App

§

impl Unpin for App

§

impl UnsafeUnpin for App

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.