From 3c156384bade3e0e86a837b1b423d401af3cfdd2 Mon Sep 17 00:00:00 2001 From: bptato Date: Fri, 19 Jan 2024 01:43:46 +0100 Subject: Re-design word handling, add e, E, W, B, etc. * Add functions for moving to the beginning/end of words (vi `b', `e'). * As it turns out, there are many possible interpretations of what a word is. Now we have a function for each reasonable interpretation, and the default settings match those of vi (and w3m in w3m.toml). (Exception: it's still broken on line boundaries... TODO) * Remove `bounds` from lineedit, it was horrible API design and mostly useless. In the future, an API similar to what pager now has could be added. * Update docs, and fix some spacing issues with symbols in the tables. --- doc/config.md | 99 ++++++++++++++++++++++++++++++++++++++++++--------------- doc/localcgi.md | 2 +- 2 files changed, 75 insertions(+), 26 deletions(-) (limited to 'doc') diff --git a/doc/config.md b/doc/config.md index dcc63d6c..cf5cf744 100644 --- a/doc/config.md +++ b/doc/config.md @@ -43,6 +43,10 @@ examples. * [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) @@ -122,7 +126,7 @@ Following is a list of encoding options: document-charset -string/array +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 @@ -315,19 +319,17 @@ Following is a list of display options: color-mode -"monochrome"/"ansi"/"eight-bit","8bit"/"true-color","24bit"/"auto" +"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 a legacy alias of "eight-bit". "24bit" is a legacy alias of -"true-color". (The only difference is that when overriding these values with -the `-o` command line switch, you can use "eight-bit" and "true-color" -without quoting.) +"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", +"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 @@ -349,7 +351,7 @@ overlines are substituted by underlines on the previous line. alt-screen -"auto"/boolean +"auto" / boolean Enable/disable the alternative screen. @@ -529,7 +531,7 @@ false for all websites. third-party-cookie -regex/array of regexes +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) @@ -705,13 +707,29 @@ Note: this does not suspend buffer processes. -`pager.cursorNextWord()` -Move the cursor to the beginning of the next word. +`pager.cursorNextWord()`, `pager.cursorNextViWord()`, +`pager.cursorNextBigWord()` +Move the cursor to the beginning of the next [word](#word-types). -`pager.cursorPrevWord()` -Move the cursor to the end of the previous word. +`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. @@ -853,7 +871,7 @@ buffer. `pager.toggleSource()` -If viewing a HTML buffer, open a new buffer with its source. Otherwise, +If viewing an HTML buffer, open a new buffer with its source. Otherwise, open the current buffer's contents as HTML. @@ -1131,12 +1149,12 @@ value is `false`. -`line.clearWord(bounds)` +`line.clearWord()` Delete word before cursor -`line.killWord(bounds)` +`line.killWord()` Delete word after cursor @@ -1151,12 +1169,12 @@ value is `false`. -`line.prevWord(bounds)` +`line.prevWord()` Move cursor to the previous word by one character -`line.nextWord(bounds)` +`line.nextWord()` Move cursor to the previous word by one character @@ -1187,10 +1205,11 @@ value is `false`. -Some of these entries have an optional `bounds` parameter. If passed, this -must be a JavaScript function that expects one parameter (the current -unicode character), and returns true if the passed character should count -as a word boundary. +Note: to facilitate URL editing, the line editor has a different definition +of what a word is than the pager. For the line editor, a word is either a +sequence of alphanumeric characters, or any single non-alphanumeric +character. (This means that e.g. `https://` consists of four words: `https`, +`:`, `/` and `/`.) ```Examples: # Control+A moves the cursor to the beginning of the line. @@ -1199,9 +1218,6 @@ as a word boundary. # Escape+D deletes everything after the cursor until it reaches a word-breaking # character. 'M-d' = 'line.killWord()' - -# Control+W deletes everything before the cursor until it reaches a space. -'C-w' = 'line.clearWord(x => x == " ")' ``` ## Appendix @@ -1237,6 +1253,39 @@ using the syntax `${%VARIABLE}`: * `${%CHA_LIBEXEC_DIR}`: the directory for all executables Chawan uses for operation. By default, this is `${%CHA_BIN_DIR}/../libexec/chawan`. +### Word types + +Word-based pager commands can operate with different definitions of +words. Currently, these are: + +* w3m words +* vi words +* Big words + +#### w3m word + +A w3m word is a sequence of alphanumeric characters. Symbols are treated +in the same way as whitespace. + +#### vi word + +A vi word is a sequence of alphanumeric characters, OR a sequence of symbols. + +vi words may be separated by whitespace; however, symbolic and alphanumeric +vi words do not have to be whitespace-separated. e.g. following character +sequence contains two words: + +``` +hello[]+{}@`! +``` + +#### Big word + +A big word is a sequence of non-whitespace characters. + +It is essentially the same as a w3m word, but with symbols being defined as +non-whitespace. +