# Configuration of Chawan Chawan supports configuration of various options like keybindings, user stylesheets, site preferences, etc. The configuration format is very similar to toml, with the following exceptions: * Inline tables may span across multiple lines. * Table arrays can be cleared by setting a variable by the same to the empty array. This allows users to disable default table array rules. Example: ``` omnirule = [] # note: this must be placed at the beginning of the file. [[omnirule]] # this is legal. all default omni-rules are now disabled. ``` Chawan will look for a config file in the $XDG_CONFIG_HOME/chawan/ directory called `config.toml`. (Chawan defaults to ~/.config if the XDG_CONFIG_HOME environment variable is not set.) See the default configuration file in the res/ folder, and bonus configuration files in the bonus/ folder for further examples. **Table of contents** * [Start](#start) * [Search](#search) * [Encoding](#encoding) * [External](#external) * [Network](#network) * [Display](#display) * [Omnirule](#omnirule) * [Siteconf](#siteconf) * [Stylesheets](#stylesheets) * [Keybindings](#keybindings) * [Pager actions](#pager-actions) * [Line-editing actions](#line-editing-actions) * [Appendix](#appendix) * [Regex handling](#regex-handling) * [Path handling](#path-handling) * [Word types](#word-types) * [w3m word](#w3m-word) * [vi word](#vi-word) * [Big word](#big-word) ## Start Start-up options are to be placed in the `[start]` section. Following is a list of start-up options:
Name | Value | Function |
---|---|---|
visual-home | url | Page opened when Chawan is called with the -V option (and no other pages are passed as arguments.) |
startup-script | JavaScript code | Script Chawan runs on start-up. Pages will not be loaded until this function exits. (Note however that asynchronous functions like setTimeout do not block loading.) |
headless | boolean | Whether Chawan should always start in headless mode. Automatically enabled when Chawan is called with -r. |
Name | Value | Function |
---|---|---|
wrap | boolean | When set to true, searchNext/searchPrev wraps around the document. |
Name | Value | Function |
---|---|---|
document-charset | array of charset label strings | List of character sets for loading documents. All listed character sets are enumerated until the document has been decoded without errors. In HTML, meta tags and the BOM may override this with a different charset, so long as the specified charset can decode the document correctly. |
display-charset | string | Character set for keyboard input and displaying documents. Used in dump mode as well. (This means that e.g. `cha -I EUC-JP -O UTF-8 a > b` is equivalent to `iconv -f EUC-JP -t UTF-8`.) |
Name | Value | Function |
---|---|---|
tmpdir | path | Directory used to save temporary files. |
editor | shell command | External editor command. %s is substituted for the file name, %d for the line number. |
mailcap | array of paths | Search path for [mailcap](mailcap.md) files. |
mime-types | array of paths | Search path for [mime.types](mime.types.md) files. |
cgi-dir | array of paths | Search path for [local CGI](localcgi.md) scripts. |
cgi-dir | array of paths | Search path for [urimethodmap](urimethodmap.md) files. |
w3m-cgi-compat | boolean | Enable local CGI compatibility with w3m. In short, it redirects `file:///cgi-bin/*` and `file:///$LIB/cgi-bin/*` to `cgi-bin:*`. For further details, see [localcgi.md](localcgi.md). |
Name | Value | Function |
---|---|---|
vi-numeric-prefix | boolean | Whether vi-style numeric prefixes to commands should be accepted. When set to true, commands that return a function will be called with the numeric prefix as their first argument. Note: this only applies for keybindings defined in [page]. |
Name | Value | Function |
---|---|---|
max-redirect | number | Maximum number of redirections to follow. |
prepend-scheme | string | Prepend this to URLs passed to Chawan without a scheme. Note that local files (`file:` scheme) will always be checked first; only if this fails, Chawan will retry the request with `prepend-scheme` set as the scheme. By default, this is set to "https://". Note that the "://" part is mandatory. |
prepend-https | boolean | Deprecated: use prepend-scheme instead. When set to false, Chawan will act as if prepend-scheme were set to "". |
proxy | URL | Specify a proxy for all network requests Chawan makes. All proxies supported by cURL may be used. Can be overridden by siteconf. |
default-headers | Table | Specify a list of default headers for all HTTP(S) network requests. |
Name | Value | Function |
---|---|---|
color-mode | "monochrome" / "ansi" / "eight-bit" / "true-color" / "auto" | Set the color mode. "auto" for automatic detection, "monochrome"
for black on white, "ansi" for ansi colors, "eight-bit" for 256-color mode, and
"true-color" for true colors. "8bit" is accepted as a legacy alias of "eight-bit". "24bit" is accepted as a legacy alias of "true-color". |
format-mode | "auto" / ["bold", "italic", "underline", "reverse", "strike", "overline", "blink"] | Specifies output formatting modes. Accepts the string "auto" or an array of specific attributes. An empty array (`[]`) disables formatting completely. |
no-format-mode | ["bold", "italic", "underline", "reverse", "strike", "overline", "blink"] | Disable specified formatting modes. |
emulate-overline | boolean | When set to true and the overline formatting attribute is not enabled, overlines are substituted by underlines on the previous line. |
alt-screen | "auto" / boolean | Enable/disable the alternative screen. |
highlight-color | color | Set the highlight color. Both hex values and CSS color names are accepted. |
highlight-marks | boolean | Enable/disable highlighting of marks. |
double-width-ambiguous | boolean | Assume the terminal displays characters in the East Asian Ambiguous category as double-width characters. Useful when e.g. ○ occupies two cells. |
minimum-contrast | number | Specify the minimum difference between the luminance (Y) of the background and the foreground. -1 disables this function (i.e. allows black letters on black background, etc). |
force-clear | boolean | Force the screen to be completely cleared every time it is redrawn. |
set-title | boolean | Set the terminal emulator's window title to that of the current page. |
default-background-color | color | Sets the assumed background color of the terminal. |
default-foreground-color | color | Sets the assumed foreground color of the terminal. |
Name | Value | Function |
---|---|---|
match | regex | Regular expression used to match the input string. Note that websites
passed as arguments are matched as well. Note: regexes are handled according to the [regex handling](#regex-handling) rules. |
substitute-url | JavaScript function | A JavaScript function Chawan will pass the input string to. If a new string is returned, it will be parsed instead of the old one. |
Name | Value | Function |
---|---|---|
url | regex | Regular expression used to match the URL. Either this or the `host` option
must be specified. Note: regexes are handled according to the [regex handling](#regex-handling) rules. |
host | regex | Regular expression used to match the host part of the URL (i.e. domain
name/ip address.) Either this or the `url` option must be specified. Note: regexes are handled according to the [regex handling](#regex-handling) rules. |
rewrite-url | JavaScript function | A JavaScript function Chawan will pass the URL to. If a new URL is returned, it will replace the old one. |
cookie | boolean | Whether loading cookies should be allowed for this URL. By default, this is false for all websites. |
third-party-cookie | array of regexes | Domains for which third-party cookies are allowed on this domain. Note:
this only works for buffers which share the same cookie jar. Note: regexes are handled according to the [regex handling](#regex-handling) rules. |
share-cookie-jar | host | Cookie jar to use for this domain. Useful for e.g. sharing cookies with subdomains. |
referer-from | boolean | Whether or not we should send a Referer header when opening requests originating from this domain. Simplified example: if you click a link on a.com that refers to b.com, and referer-from is true, b.com is sent "a.com" as the Referer header. Defaults to false. |
scripting | boolean | Enable/disable JavaScript execution on this site. |
document-charset | boolean | Specify the default encoding for this site. Overrides document-charset in [encoding]. |
stylesheet | CSS stylesheet | Specify an additional user-stylesheet for this site. Note: other user-stylesheets (specified under [css] or additional matching siteconfs) are not overridden. (In other words, they will be concatenated with this stylesheet to get the final user stylesheet.) |
proxy | URL | Specify a proxy for network requests fetching contents of this buffer. |
Name | Function |
---|---|
`quit()` | Exit the browser. |
`suspend()` | Temporarily suspend the browser (by delivering the client process a
SIGTSTP signal.) Note: this suspends the entire process group, including e.g. buffer processes or CGI scripts. |
Name | Function |
---|---|
`pager.cursorUp(n = 1)` | Move the cursor upwards by n lines, or if n is unspecified, by 1. |
`pager.cursorDown(n = 1)` | Move the cursor downwards by n lines, or if n is unspecified, by 1. |
`pager.cursorLeft(n = 1)` | Move the cursor to the left by n cells, or if n is unspecified, by 1. |
`pager.cursorRight(n = 1)` | Move the cursor to the right by n cells, or if n is unspecified, by 1. |
`pager.cursorLineBegin()` | Move the cursor to the first cell of the line. |
`pager.cursorLineTextStart()` | Move the cursor to the first non-blank character of the line. |
`pager.cursorLineEnd()` | Move the cursor to the last cell of the line. |
`pager.cursorNextWord()`, `pager.cursorNextViWord()`, `pager.cursorNextBigWord()` | Move the cursor to the beginning of the next [word](#word-types). |
`pager.cursorPrevWord()`, `pager.cursorPrevViWord()`, `pager.cursorPrevBigWord()` | Move the cursor to the end of the previous [word](#word-types). |
`pager.cursorWordEnd()`, `pager.cursorViWordEnd()`, `pager.cursorBigWordEnd()` | Move the cursor to the end of the current [word](#word-types), or if already there, to the end of the next word. |
`pager.cursorWordBegin()`, `pager.cursorViWordBegin()`, `pager.cursorBigWordBegin()` | Move the cursor to the beginning of the current [word](#word-types), or if already there, to the end of the previous word. |
`pager.cursorNextLink()` | Move the cursor to the beginning of the next clickable element. |
`pager.cursorPrevLink()` | Move the cursor to the beginning of the previous clickable element. |
`pager.cursorPrevParagraph(n = 1)` | Move the cursor to the beginning of the nth next paragraph. |
`pager.cursorNextParagraph(n = 1)` | Move the cursor to the end of the nth previous paragraph. |
`pager.cursorNthLink(n = 1)` | Move the cursor to the nth link of the document. |
`pager.cursorRevNthLink(n = 1)` | Move the cursor to the nth link of the document, counting backwards from the document's last line. |
`pager.pageDown(n = 1)` | Scroll down by n pages. |
`pager.pageUp(n = 1)` | Scroll up by n pages. |
`pager.pageLeft(n = 1)` | Scroll to the left by n pages. |
`pager.pageRight(n = 1)` | Scroll to the right n pages. |
`pager.halfPageDown(n = 1)` | Scroll forwards by n half pages. |
`pager.halfPageUp(n = 1)` | Scroll backwards by n half pages. |
`pager.halfPageLeft(n = 1)` | Scroll to the left by n half pages. |
`pager.halfPageUp(n = 1)` | Scroll to the right by n half pages. |
`pager.scrollDown(n = 1)` | Scroll forwards by n lines. |
`pager.scrollUp(n = 1)` | Scroll backwards by n lines. |
`pager.scrollLeft(n = 1)` | Scroll to the left by n columns. |
`pager.scrollRight(n = 1)` | Scroll to the right by n columns. |
`pager.click()` | Click the HTML element currently under the cursor. |
`pager.load(url)` | Go to the specified URL. Opens a prompt with the current URL when no parameters are specified; otherwise, the string passed is displayed in the prompt. If this string ends with a newline (e.g. `pager.load("about:chawan\n")`), the URL is loaded directly. |
`pager.dupeBuffer()` | Duplicate the current buffer by loading its source to a new buffer. |
`pager.discardBuffer()` | Discard the current buffer, and move back to its previous sibling buffer, or if that doesn't exist, to its parent. If the current buffer is a root buffer (i.e. it has no parent), move to the next sibling buffer instead. |
`pager.discardTree()` | Discard all child buffers of the current buffer. |
`pager.reload()` | Open a new buffer with the current buffer's URL, replacing the current buffer. |
`pager.reshape()` | Reshape the current buffer (=render the current page anew.) |
`pager.redraw()` | Redraw screen contents. Useful if something messed up the display. |
`pager.toggleSource()` | If viewing an HTML buffer, open a new buffer with its source. Otherwise, open the current buffer's contents as HTML. |
`pager.cursorFirstLine()` | Move to the beginning in the buffer. |
`pager.cursorLastLine()` | Move to the last line in the buffer. |
`pager.cursorTop()` | Move to the first line on the screen. (Equivalent to H in vi.) |
`pager.cursorMiddle()` | Move to the line in the middle of the screen. (Equivalent to M in vi.) |
`pager.cursorBottom()` | Move to the last line on the screen. (Equivalent to L in vi.) |
`pager.lowerPage(n = pager.cursory)` | Move cursor to line n, then scroll up so that the cursor is on the top line on the screen. (`zt` in vim.) |
`pager.lowerPageBegin(n = pager.cursory)` | Move cursor to the first non-blank character of line n, then scroll up
so that the cursor is on the top line on the screen. (`z |
`pager.centerLine(n = pager.cursory)` | Center screen around line n. (`zz` in vim.) |
`pager.centerLineBegin(n = pager.cursory)` | Center screen around line n, and move the cursor to the line's first non-blank character. (`z.` in vi.) |
`pager.raisePage(n = pager.cursory)` | Move cursor to line n, then scroll down so that the cursor is on the top line on the screen. (zb in vim.) |
`pager.lowerPageBegin(n = pager.cursory)` | Move cursor to the first non-blank character of line n, then scroll up so that the cursor is on the last line on the screen. (`z^` in vi.) |
`pager.nextPageBegin(n = pager.cursory)` | If n was given, move to the screen before the nth line and raise the page. Otherwise, go to the previous screen's last line and raise the page. (`z+` in vi.) |
`pager.cursorLeftEdge()` | Move to the first column on the screen. |
`pager.cursorMiddleColumn()` | Move to the column in the middle of the screen. |
`pager.cursorRightEdge()` | Move to the last column on the screen. |
`pager.centerColumn()` | Center screen around the current column. |
`pager.lineInfo()` | Display information about the current line. |
`pager.searchForward()` | Search for a string in the current buffer. |
`pager.searchBackward()` | Search for a string, backwards. |
`pager.isearchForward()` | Incremental-search for a string, highlighting the first result. |
`pager.isearchBackward()` | Incremental-search and highlight the first result, backwards. |
`pager.gotoLine(n?)` | Go to the line passed as the first argument. If no arguments were specified, an input window for entering a line is shown. |
`pager.searchNext(n = 1)` | Jump to the nth next search result. |
`pager.searchPrev(n = 1)` | Jump to the nth previous search result. |
`pager.peek()` | Display an alert message of the current URL. |
`pager.peekCursor()` | Display an alert message of the URL or title under the cursor. Multiple calls allow cycling through the two. (i.e. by default, press u once -> title, press again -> URL) |
`pager.ask(prompt)` | Ask the user for confirmation. Returns a promise which resolves to a
boolean value indicating whether the user responded with yes. Can be used to implement an exit prompt like this: ``` q = 'pager.ask("Do you want to exit Chawan?").then(x => x ? pager.quit() : void(0))' ``` |
`pager.askChar(prompt)` | Ask the user for any character. Like `pager.ask`, but the return value is a character. |
`pager.setMark(id, x = pager.cursorx, y = pager.cursory)` | Set a mark at (x, y) using the name `id`. Returns true if no other mark exists with `id`. If one already exists, it will be overridden and the function returns false. |
`pager.clearMark(id)` | Clear the mark with the name `id`. Returns true if the mark existed, false otherwise. |
`pager.gotoMark(id)` | If the mark `id` exists, jump to its position and return true. Otherwise, do nothing and return false. |
`pager.gotoMarkY(id)` | If the mark `id` exists, jump to the beginning of the line at its Y position and return true. Otherwise, do nothing and return false. |
`pager.getMarkPos(id)` | If the mark `id` exists, return its position as an array where the first element is the X position and the second element is the Y position. If the mark does not exist, return null. |
`pager.findNextMark(x = pager.cursorx, y = pager.cursory)` | Find the next mark after `x`, `y`, if any; and return its id (or null if none were found.) |
`pager.findPrevMark(x = pager.cursorx, y = pager.cursory)` | Find the previous mark before `x`, `y`, if any; and return its id (or null if none were found.) |
`pager.extern(cmd, options = {setenv: true, suspend: true, wait: false})` | Run an external command `cmd`. The `$CHA_URL` and `$CHA_CHARSET` variables
are set when `options.setenv` is true. `options.suspend` suspends the pager
while the command is being executed, and `options.wait` makes it so the user
must press a key before the pager is resumed. Returns true if the command exit successfully, false otherwise. Warning: this has a bug where the output is written to stdout even if suspend is true. Redirect to /dev/null in the command if this is not desired. (This will be fixed in the future.) |
`pager.externCapture(cmd)` | Like extern(), but redirect the command's stdout string into the result. null is returned if the command wasn't executed successfully, or if the command returned a non-zero exit value. |
`pager.externInto(cmd, ins)` | Like extern(), but redirect `ins` into the command's standard input stream. `true` is returned if the command exits successfully, otherwise the return value is `false`. |
`pager.externFilterSource(cmd, buffer = null, contentType = null)` | Redirects the specified (or if `buffer` is null, the current) buffer's
source into `cmd`. Then, it pipes the output into a new buffer, with the content type `contentType` (or, if `contentType` is null, the original buffer's content type). Returns `undefined`. (It should return a promise; TODO.) |
`pager.location` | Getter for the link of the current buffer. Returns a `URL` object. |
`pager.hoverLink` | Getter for the link currently under the cursor. Returns the empty string if no link is found. |
`pager.hoverTitle` | Getter for the title currently under the cursor. Returns the empty string if no title is found. |
`pager.buffer` | Getter for the currently displayed buffer. Returns a `Buffer` object. |
Name | Function |
---|---|
`line.submit()` | Submit line |
`line.cancel()` | Cancel operation |
`line.backspace()` | Delete character before cursor |
`line.delete()` | Delete character after cursor |
`line.clear()` | Clear text before cursor |
`line.kill()` | Clear text after cursor |
`line.clearWord()` | Delete word before cursor |
`line.killWord()` | Delete word after cursor |
`line.backward()` | Move cursor back by one character |
`line.forward()` | Move cursor forward by one character |
`line.prevWord()` | Move cursor to the previous word by one character |
`line.nextWord()` | Move cursor to the previous word by one character |
`line.begin()` | Move cursor to the previous word by one character |
`line.end()` | Move cursor to the previous word by one character |
`line.escape()` | Ignore keybindings for next character |
`line.prevHist()` | Jump to the previous history entry |
`line.nextHist()` | Jump to the next history entry |