Skip to main content

TabManager

Struct TabManager 

Source
pub struct TabManager {
    pub tabs: Vec<TabState>,
    pub active: usize,
}
Expand description

Manages the collection of open tabs within AppState.

There is always at least one tab. active is the index of the currently focused tab in tabs. Invariant: active < tabs.len().

Fields§

§tabs: Vec<TabState>

All open tabs; never empty.

§active: usize

Index of the active (focused) tab. Always < tabs.len().

Implementations§

Source§

impl TabManager

Source

pub fn new(cwd: PathBuf, sort: SortSettings) -> Self

Creates a TabManager with a single initial tab rooted at cwd, ordered by sort.

Source

pub fn active_tab(&self) -> &TabState

Returns a shared reference to the active tab.

Source

pub fn active_tab_mut(&mut self) -> &mut TabState

Returns a mutable reference to the active tab.

Source

pub fn len(&self) -> usize

Returns the number of open tabs.

Read by the status bar for the [2/3] indicator.

Source

pub fn is_empty(&self) -> bool

Returns true if there are no tabs open.

Source

pub fn is_single(&self) -> bool

Returns true when exactly one tab is open.

The status bar shows its tab indicator only when this is false — with one tab there is nothing to disambiguate — and a switch request with one tab says so rather than doing nothing.

Source

pub fn open_tab(&mut self, cwd: PathBuf, sort: SortSettings)

Opens a new tab rooted at cwd, ordered by sort, and switches focus to it.

The new tab is inserted after the currently active tab. Callers pass the outgoing tab’s sort so a new tab inherits the order you were already using rather than snapping back to the configured default.

Source

pub fn close_active_tab(&mut self) -> bool

Closes the active tab.

If this would leave zero tabs, the close is refused (returns false). On success the active index is adjusted so it remains in bounds:

  • If there are tabs to the right, the next one becomes active.
  • Otherwise the previous tab becomes active.

Returns true if the tab was closed, false if it was the last one.

Source

pub fn switch_to(&mut self, index: usize) -> bool

Switches focus to the tab at index.

Returns true if the switch happened (index was valid and different from the current active tab), false otherwise.

Source

pub fn switch_next(&mut self) -> bool

Switches focus to the next tab, wrapping around from the last to the first.

Returns true when there is more than one tab (i.e. a switch happened).

Source

pub fn switch_prev(&mut self) -> bool

Switches focus to the previous tab, wrapping around from the first to the last.

Returns true when there is more than one tab.

Trait Implementations§

Source§

impl Debug for TabManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more