Enum broot::preview::Preview

source ·
pub enum Preview {
    Dir(DirView),
    Image(ImageView),
    Syntactic(SyntacticView),
    Hex(HexView),
    ZeroLen(ZeroLenFileView),
    IoError(Error),
}

Variants§

§

Dir(DirView)

§

Image(ImageView)

§

Syntactic(SyntacticView)

§

Hex(HexView)

§

ZeroLen(ZeroLenFileView)

§

IoError(Error)

Implementations§

source§

impl Preview

source

pub fn new( path: &Path, preferred_mode: Option<PreviewMode>, con: &AppContext ) -> Self

build a preview, never failing (but the preview can be Preview::IOError). If the preferred mode can’t be applied, an other mode is chosen.

source

pub fn with_mode( path: &Path, mode: PreviewMode, con: &AppContext ) -> Result<Self, ProgramError>

try to build a preview with the designed mode, return an error if that wasn’t possible

source

pub fn dir( path: &Path, pattern: InputPattern, dam: &Dam, con: &AppContext ) -> Self

build a dir preview

source

pub fn image(path: &Path) -> Self

build an image view, unless the file can’t be interpreted as an image, in which case a hex view is used

source

pub fn unfiltered_text(path: &Path, con: &AppContext) -> Self

build a text preview (maybe with syntaxic coloring) if possible, a hex (binary) view if content isnt’t UTF8, a ZeroLen file if there’s no length (it’s probably a linux pseudofile) or a IOError when there’s a IO problem

source

pub fn unstyled_text(path: &Path, con: &AppContext) -> Self

build a text preview with no syntax highlighting, if possible

source

pub fn filtered( &self, path: &Path, pattern: InputPattern, dam: &mut Dam, con: &AppContext ) -> Option<Self>

try to build a filtered view. Will return None if the dam gets an event before it’s built

source

pub fn hex(path: &Path) -> Self

return a hex_view, suitable for binary, or Self::IOError if there was an error

source

pub fn get_mode(&self) -> Option<PreviewMode>

return the preview_mode, or None if we’re on IOError or Directory

source

pub fn pattern(&self) -> InputPattern

source

pub fn try_scroll(&mut self, cmd: ScrollCommand) -> bool

source

pub fn is_filterable(&self) -> bool

source

pub fn get_selected_line(&self) -> Option<String>

source

pub fn get_selected_line_number(&self) -> Option<LineNumber>

source

pub fn try_select_line_number(&mut self, number: usize) -> bool

source

pub fn unselect(&mut self)

source

pub fn try_select_y(&mut self, y: u16) -> bool

source

pub fn move_selection(&mut self, dy: i32, cycle: bool)

source

pub fn select_first(&mut self)

source

pub fn select_last(&mut self)

source

pub fn display( &mut self, w: &mut W, disc: &DisplayContext<'_>, area: &Area ) -> Result<(), ProgramError>

source

pub fn display_info( &mut self, w: &mut W, screen: Screen, panel_skin: &PanelSkin, area: &Area ) -> Result<(), ProgramError>

Auto Trait Implementations§

§

impl !RefUnwindSafe for Preview

§

impl !Send for Preview

§

impl !Sync for Preview

§

impl Unpin for Preview

§

impl !UnwindSafe for Preview

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> 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.