diff --git a/src/encoding.rs b/src/encoding.rs index 4a0a5a4..4abed2e 100644 --- a/src/encoding.rs +++ b/src/encoding.rs @@ -1,7 +1,14 @@ /// Encoding of Gopher response. Only UTF8 and CP437 are supported. -pub(crate) enum Encoding { +#[derive(Copy, Clone)] +pub enum Encoding { /// Unicode UTF8, /// https://en.wikipedia.org/wiki/Code_page_437 CP437, } + +impl Default for Encoding { + fn default() -> Self { + Encoding::UTF8 + } +} diff --git a/src/text.rs b/src/text.rs index 93a7d62..cc56233 100644 --- a/src/text.rs +++ b/src/text.rs @@ -72,6 +72,10 @@ impl View for Text { self.wide } + fn encoding(&self) -> Encoding { + self.encoding + } + fn respond(&mut self, c: Key) -> Action { match c { Key::Home => { @@ -200,7 +204,7 @@ impl Text { mode: config.mode, tls, tor: config.tor, - encoding: Encoding::UTF8, + encoding: Encoding::default(), wide: config.wide, } } diff --git a/src/ui/view.rs b/src/ui/view.rs index f4bff94..24ceb08 100644 --- a/src/ui/view.rs +++ b/src/ui/view.rs @@ -1,5 +1,7 @@ -use crate::ui; -use std::fmt; +use { + crate::{encoding::Encoding, ui}, + std::fmt, +}; /// Views represent what's on screen, a Gopher Menu/Text/etc item. pub trait View: fmt::Display { @@ -23,4 +25,8 @@ pub trait View: fmt::Display { fn wide(&mut self) -> bool; /// Set the current screen size. fn term_size(&mut self, cols: usize, rows: usize); + /// The current encoding. + fn encoding(&self) -> Encoding { + Encoding::default() + } }