Struct webkitten::config::Config
[−]
[src]
pub struct Config { /* fields omitted */ }
Configuration option storage and lookup
Examples
Using a start page setting for new windows
use webkitten::config::Config; use webkitten::ui::BrowserConfiguration; let config = Config::parse(r#" [window] start-page = "file:///path/to/the/page.html" "#).unwrap(); let start_page = config.start_page().unwrap(); assert_eq!("file:///path/to/the/page.html", &start_page);
Replacing CONFIG_DIR
in string options with a preferred path
use webkitten::config::Config; use webkitten::ui::BrowserConfiguration; let config = Config::parse(r#" [general] config-dir = "/path/to/config" [window] start-page = "file://CONFIG_DIR/page.html" "#).unwrap(); let start_page = config.start_page().unwrap(); assert_eq!("file:///path/to/config/page.html", &start_page);
Looking up a custom field
use webkitten::config::Config; use webkitten::ui::BrowserConfiguration; let config = Config::parse(r#" [dependencies] external-path = "/path/to/bin" "#).unwrap(); let path = config.lookup_str("dependencies.external-path").unwrap(); assert_eq!("/path/to/bin", &path);
Overriding a field with site-specific options
use webkitten::config::Config; use webkitten::ui::BrowserConfiguration; let config = Config::parse(r#" [dessert] pie = false [sites."example.us".dessert] pie = true "#).unwrap(); let pie = config.lookup_site_bool("http://example.us/other/stuff.html", "dessert.pie"); assert_eq!(true, pie.unwrap());
Using global fallback for a missing site-specific option
use webkitten::config::Config; use webkitten::ui::BrowserConfiguration; let config = Config::parse(r#" [dependencies] external-path = "/path/to/bin" [sites."example.com".dependencies] external-path = "/path/to/sites-bin" "#).unwrap(); let path = config.lookup_site_str("http://example.co.uk/old", "dependencies.external-path"); assert_eq!("/path/to/bin", &path.unwrap());
Methods
impl Config
[src]
fn default() -> Option<Self>
Create a Configuration
with the default options
fn load(&mut self, path: &str) -> bool
Reload cached configuration from disk returns true if parsing is successful
fn parse_file(path: &str) -> Option<Self>
Parse a file at a path and create a Configuration
if possible
Trait Implementations
impl BrowserConfiguration for Config
[src]
fn parse(raw_input: &str) -> Option<Self>
Parse a string literal into a BrowserConfiguration
fn lookup_bool<'a>(&'a self, key: &'a str) -> Option<bool>
Look up the bool value of a configuration option matching key
fn lookup_raw_str<'a>(&'a self, key: &'a str) -> Option<String>
Look up the string value of a configuration option without any substitutions Read more
fn lookup_str<'a>(&'a self, key: &'a str) -> Option<String>
Look up the string value of a configuration option matching key, replacing string variables where possible Read more
fn lookup_integer<'a>(&'a self, key: &'a str) -> Option<i64>
Look up the integer value of a configuration option matching key
fn lookup_str_table(&self, key: &str) -> Option<HashMap<String, String>>
Look up the string table value of a configuration option matching key
fn lookup_str_vec(&self, key: &str) -> Option<Vec<String>>
Look up the string vector value of a configuration option matching key
fn start_page(&self) -> Option<String>
The page opened with each new window or empty buffer based on window.start-page
Read more
fn new_frame_uses_focused_window(&self) -> bool
Whether to open a buffer in the focused window or a new window when requesting a new frame. Defaults to false
, always opening a new window. Read more
fn config_dir(&self) -> Option<String>
The directory to replace instances of CONFIG_DIR in the configuration file Read more
fn command_interpreter(&self) -> Option<String>
The name of the scripting engine to use for evaluating command files. Defaults to "lua". Read more
fn resolved_command_name(&self, name: &str) -> Option<String>
The name of a command resolving any matching alias in commands.aliases
fn bar_font(&self) -> Option<(String, i64)>
Font to use in the command bar
fn command_matching_prefix(&self, text: &str) -> Option<String>
Find the command to automatically run for a given text prefix
fn command_keybindings(&self) -> HashMap<String, (char, usize)>
Mapping of commands to keybindings by name to key and modifier mask
fn command_disabled(&self, name: &str) -> bool
Whether a command is disabled based on commands.disabled
fn content_filter_path(&self) -> Option<String>
The path to the content filter used in buffers based on general.content-filter
Read more
fn skip_content_filter(&self, uri: &str) -> bool
Whether to skip content filtering based on the site-specific option sites."[HOST]".general.skip-content-filter
. Defaults to false
. Read more
fn use_private_browsing(&self, uri: &str) -> bool
Whether to enable private browsing based on the global option general.private-browsing
and site-specific option sites."[HOST]".general.private-browsing
. Defaults to false
. Read more
fn use_javascript(&self, uri: &str) -> bool
Whether to allow JavaScript to run in a buffer based on the global option general.allow-javascript
and site-specific option sites."[HOST]".general.allow-javascript
. Defaults to true
. Read more
fn use_plugins(&self, uri: &str) -> bool
Whether to allow browser plugins to run in a buffer based on the global option general.allow-plugins
and site-specific option sites."[HOST]".general.allow-plugins
. Defaults to false
. Read more
fn command_search_paths(&self) -> Vec<String>
Paths to search for command scripts using configuration option command.search-paths
Read more
fn default_command(&self) -> Option<String>
Command to run when no other commands are matched using configuration option commands.default
Read more
fn on_buffer_event_commands(&self, event: &BufferEvent) -> Vec<String>
Commands triggered by a buffer event Read more
fn lookup_site_bool<'a>(&'a self, uri: &str, key: &'a str) -> Option<bool>
Look up the bool value of a configuration option matching key formatted as sites."[HOST]".[key]
, falling back to [key]
if no match is found. Read more
fn lookup_site_str<'a>(&'a self, uri: &str, key: &'a str) -> Option<String>
Look up the string value of a configuration option matching key formatted as sites."[HOST]".[key]
, falling back to [key]
if no match is found. Read more
fn lookup_site_str_vec<'a>(
&'a self,
uri: &str,
key: &'a str
) -> Option<Vec<String>>
&'a self,
uri: &str,
key: &'a str
) -> Option<Vec<String>>
Look up the string vector value of a configuration option matching key formatted as sites."[HOST]".[key]
, falling back to [key]
if no match is found. Read more