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]

Create a Configuration with the default options

Reload cached configuration from disk returns true if parsing is successful

Parse a file at a path and create a Configuration if possible

Trait Implementations

impl BrowserConfiguration for Config
[src]

Parse a string literal into a BrowserConfiguration

Look up the bool value of a configuration option matching key

Look up the string value of a configuration option without any substitutions Read more

Look up the string value of a configuration option matching key, replacing string variables where possible Read more

Look up the integer value of a configuration option matching key

Look up the string table value of a configuration option matching key

Look up the string vector value of a configuration option matching key

The page opened with each new window or empty buffer based on window.start-page Read more

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

The directory to replace instances of CONFIG_DIR in the configuration file Read more

The name of the scripting engine to use for evaluating command files. Defaults to "lua". Read more

The name of a command resolving any matching alias in commands.aliases

Font to use in the command bar

Find the command to automatically run for a given text prefix

Mapping of commands to keybindings by name to key and modifier mask

Whether a command is disabled based on commands.disabled

The path to the content filter used in buffers based on general.content-filter Read more

Whether to skip content filtering based on the site-specific option sites."[HOST]".general.skip-content-filter. Defaults to false. Read more

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

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

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

Paths to search for command scripts using configuration option command.search-paths Read more

Command to run when no other commands are matched using configuration option commands.default Read more

Commands triggered by a buffer event Read more

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

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

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