aboutsummaryrefslogtreecommitdiff
path: root/url-mode.c (follow)
Commit message (Collapse)AuthorAgeLines
* Merge branch 'refactor-key-bindings'Daniel Eklöf2021-02-08-3/+3
|\
| * key-bindings: refactor: use a single type for all key bindingsDaniel Eklöf2021-02-08-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Up until now, the various key binding modes (“normal”, “search” and “url”) have used their own struct definitions for their key bindings. The only reason for this was to have a properly typed “action” (using the appropriate “action” enum). This caused lots of duplicated code. This patch refactors this to use a single struct definition for the “unparsed” key bindings handled by the configuration, and another single definition for “parsed” bindings used while handling input. This allows us to implement configuration parsing, keymap translation and so on using one set of functions, regardless of key binding mode.
* | url-mode: ‘%’ is a valid URI character (but don’t allow it at the end)Daniel Eklöf2021-02-08-2/+2
| | | | | | | | Closes #338
* | misc: when free:ing tll lists, prefer tll_remove() over tll_free()Daniel Eklöf2021-02-08-2/+2
|/ | | | | | | | | | | | | | | | | | | In many places we have the following pattern: tll_foreach(list, it) free(it->item.thing); tll_free(list); Since all tll functions are macros, and thus inlined, and since tll_free in itself expands to a tll_foreach(), the above pattern expands to more native code than necessary. This is somewhat smaller: tll_foreach(list, it) { free(it->item.thing); tll_remove(list, it); }
* url-mode: urls_render(): early exit when URL list is emptyDaniel Eklöf2021-02-07-0/+3
|
* url-mode: generate-key-combos: minor efficiency tweaksDaniel Eklöf2021-02-07-7/+8
| | | | | | | | | | | | * Use a do..while loop; this lets us drop the second half of the loop condition. * Call wcslen(prefix) once, *before* iterating the alphabet characters. * Step through the alphabet characters using a pointer, as this avoids an indexed load (with possibly an imul instruction in e.g. -Os builds).
* url-mode: be consistent; use xmalloc() + xrealloc()Daniel Eklöf2021-02-07-4/+4
|
* url-mode: early exit when assigning key combos to empty listDaniel Eklöf2021-02-07-0/+3
|
* url-mode: input: backspace reverts the last keyDaniel Eklöf2021-02-07-2/+11
|
* url-mode: fix key sequence generationDaniel Eklöf2021-02-07-32/+52
| | | | | | | | * We were using the ‘back’ element of the list as prefix for the next iteration of sequences, instead of the element at index ‘offset’ * ALEN() on a wchar_t[] includes the NULL terminator. We don’t want that.
* url-mode: generate key combinations using vimium’s algorithmDaniel Eklöf2021-02-07-16/+47
|
* url-mode: refresh rendered URLs after accepting a keyDaniel Eklöf2021-02-07-0/+1
|
* url-mode: urls_assign_key_combos(): remove URLs when all key combos have been used upDaniel Eklöf2021-02-07-15/+24
|
* url-mode: add ftp://, ftps://, file://, gemini:// and gopher://Daniel Eklöf2021-02-07-0/+5
|
* url-mode: urls_collect(): URL list pointer as an argumentDaniel Eklöf2021-02-07-48/+50
|
* url-mode: underline URLs using the color from colors.urlsDaniel Eklöf2021-02-07-0/+46
| | | | | | | | | | | | | | | | | | | | | | This is implemented by allocating one of the (few!) remaining bits in the cells’ attribute struct to indicate the cell should be “URL highlighted”. render_cell() looks at this bit and draws an underline using the color from colors.urls (defaults to regular3 - i.e. yellow). A new function, url_tag_cells(), iterates the currently detected URLs and sets the new ‘url’ attribute flag on the affected cells. Note: this is done in a separate function to keep urls_collect() free from as many dependencies as possible. urls_reset() is updated to *clear* the ‘url’ flag (and thus implicitly also results in a grid refresh, _if_ there were any URLs). We now exit URL mode on *any* client application input. This needs to be so since we can’t know if the URLs we previously detected are still valid.
* url-mode: store absolute row numbers in start/end coordinatesDaniel Eklöf2021-02-07-0/+3
| | | | | | | | | | | | | | | | | This allows us to update the jump label positions when the viewport changes. This in turn allows us to stay in URL mode while the user is using the mouse to scroll in the scrollback history. Scrolling with the keyboard is currently not possible, since input handling in URL mode does not recognize “regular” key bindings. We _could_ add scrollback up/down bindings to URL mode too, but lets not, for the time being. (Note: an alternative to this patch is to disallow mouse scrolling too. Then we could have kept the URL start/end as viewport local coordinates).
* url-mode: make the end coordinate *inclusive*Daniel Eklöf2021-02-07-0/+5
|
* url-mode: refactor: break out URL activation to a separate functionDaniel Eklöf2021-02-07-37/+42
|
* url-mode: auto-detect: use wcsncasecmp() instead of towlower()Daniel Eklöf2021-02-07-7/+8
| | | | | When matching the URI scheme, use wcsncasecmp() when comparing the strings, instead of calling towlower() on each cell.
* url-mode: auto-detect: don’t store the lower-cased URL; use original casingDaniel Eklöf2021-02-07-5/+5
|
* config: add show-urls-copy actionDaniel Eklöf2021-02-07-17/+33
| | | | | | This works just like show-urls-launch, except that instead of opening the URL (typically using xdg-open), it is placed in the clipboard when activated.
* url-mode: auto-detect: don’t line-wrap URL is row isn’t line-wrappedDaniel Eklöf2021-02-07-0/+3
|
* url-mode: auto-detect: heuristics for parenthesis and bracketsDaniel Eklöf2021-02-07-7/+40
| | | | | | | | | | While parenthesis and brackets _are_ valid URL characters, there are many times when we do *not* want them to be part of the URL. For example, in markdown we write “[text](url)”, or even “[![alt-text](url-1)](url-2)”. Here, the URLs are clearly *not* “url)” or “url-1)](url2)”.
* url-mode: use ‘url-launch’ from config to open URLsDaniel Eklöf2021-02-07-1/+16
|
* url-mode: urls_reset() do an early return if we don’t have any URLsDaniel Eklöf2021-02-07-0/+3
|
* url-mode: fix ‘n’ parameter to wcstombs()Daniel Eklöf2021-02-07-4/+8
|
* urls: initial support for detecting URLs and rendering jump-labelsDaniel Eklöf2021-02-07-0/+337
The jump labels work, but is currently hardcoded to use xdg-open