pub enum Preview {
Image(ImageView),
Syntactic(SyntacticView),
Hex(HexView),
ZeroLen(ZeroLenFileView),
IoError(Error),
}
Variants§
Implementations§
source§impl Preview
impl Preview
sourcepub fn new(
path: &Path,
prefered_mode: Option<PreviewMode>,
con: &AppContext
) -> Self
pub fn new(
path: &Path,
prefered_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.
sourcepub fn with_mode(
path: &Path,
mode: PreviewMode,
con: &AppContext
) -> Result<Self, ProgramError>
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
sourcepub fn image(path: &Path) -> Self
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
sourcepub fn unfiltered_text(path: &Path, con: &AppContext) -> Self
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
sourcepub fn unstyled_text(path: &Path, con: &AppContext) -> Self
pub fn unstyled_text(path: &Path, con: &AppContext) -> Self
build a text preview with no syntax highlighting, if possible
sourcepub fn filtered(
&self,
path: &Path,
pattern: InputPattern,
dam: &mut Dam,
con: &AppContext
) -> Option<Self>
pub fn filtered(
&self,
path: &Path,
pattern: InputPattern,
dam: &mut Dam,
con: &AppContext
) -> Option<Self>
try to build a filtered text view. Will return None if the dam gets an event before it’s built
sourcepub fn hex(path: &Path) -> Self
pub fn hex(path: &Path) -> Self
return a hex_view, suitable for binary, or Self::IOError if there was an error
sourcepub fn get_mode(&self) -> Option<PreviewMode>
pub fn get_mode(&self) -> Option<PreviewMode>
return the preview_mode, or None if we’re on IOError