* 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).
* 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.
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.
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).
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.
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
“[](url-2)”.
Here, the URLs are clearly *not* “url)” or “url-1)](url2)”.