pub struct Renderer { /* private fields */ }Expand description
Terminal renderer for Wikipedia content.
Renders to any Write target — use Renderer::stdout for normal
display, or [Renderer::to_buf] to capture ANSI-colored output into a
Vec<u8> (e.g. for piping into a pager).
§Example
use wiky::{Config, Renderer};
let config = Config::default();
let theme = config.active_theme();
let renderer = Renderer::stdout(theme, 100, true);
renderer.print_message("Hello, wiky! ✨");Implementations§
Source§impl Renderer
impl Renderer
Sourcepub fn stdout(theme: Theme, width: u16, emoji: bool) -> Self
pub fn stdout(theme: Theme, width: u16, emoji: bool) -> Self
Create a renderer that writes to stdout.
Sourcepub fn new(theme: Theme, width: u16, emoji: bool) -> Self
pub fn new(theme: Theme, width: u16, emoji: bool) -> Self
Backwards-compatible constructor alias.
Sourcepub fn article_to_string(&self, article: &Article) -> String
pub fn article_to_string(&self, article: &Article) -> String
Render a full article into a colored String.
Sourcepub fn search_to_string(&self, query: &str, results: &[SearchResult]) -> String
pub fn search_to_string(&self, query: &str, results: &[SearchResult]) -> String
Render search results into a colored String.
Sourcepub fn summary_to_string(&self, article: &Article) -> String
pub fn summary_to_string(&self, article: &Article) -> String
Render a summary into a colored String.
Sourcepub fn render_article(&self, article: &Article)
pub fn render_article(&self, article: &Article)
Render a full Article to stdout.
Sourcepub fn render_summary(&self, article: &Article)
pub fn render_summary(&self, article: &Article)
Render only the summary of an article to stdout.
Sourcepub fn render_search_results(&self, query: &str, results: &[SearchResult])
pub fn render_search_results(&self, query: &str, results: &[SearchResult])
Render a list of search results to stdout.
Sourcepub fn print_message(&self, msg: &str)
pub fn print_message(&self, msg: &str)
Print a plain message to stdout.
Sourcepub fn dim_str(&self, s: &str) -> String
pub fn dim_str(&self, s: &str) -> String
Return a dim-colored string (useful for callers that do their own printing).
Sourcepub fn print_success(&self, msg: &str)
pub fn print_success(&self, msg: &str)
Print a success message to stdout.
Sourcepub fn print_error(&self, msg: &str)
pub fn print_error(&self, msg: &str)
Print an error message to stderr.
Sourcepub fn render_config_info(&self, config: &Config)
pub fn render_config_info(&self, config: &Config)
Render current config settings to stdout.
Sourcepub fn render_themes_list(&self)
pub fn render_themes_list(&self)
Render the list of available themes to stdout.
Sourcepub fn render_disambiguation(&self, article: &Article, opts: &[DisambigOption])
pub fn render_disambiguation(&self, article: &Article, opts: &[DisambigOption])
Render a disambiguation page options to stdout as a numbered list.