improved url regex
This commit is contained in:
parent
c4a2ee4840
commit
4940cf4a75
2
TODO.rst
2
TODO.rst
|
@ -1,5 +1,5 @@
|
|||
* tab and shift-tab bindings for completion
|
||||
* better url matching regex
|
||||
* improved matching capabilities (not just urls)
|
||||
* hint mode overlay for urls (like elinks/vimperator/pentadactyl)
|
||||
* scrollback search needs to be improved upstream [1]_
|
||||
* expose keybindings in ``termite.cfg``
|
||||
|
|
14
termite.c
14
termite.c
|
@ -14,7 +14,19 @@
|
|||
|
||||
#define CSI "\x1b["
|
||||
|
||||
static const char * const url_regex = "(ftp|http)s?://[-a-zA-Z0-9.?$%&/=_~#.,:;+()]*";
|
||||
#define USERCHARS "-[:alnum:]"
|
||||
#define USERCHARS_CLASS "[" USERCHARS "]"
|
||||
#define PASSCHARS_CLASS "[-[:alnum:]\\Q,?;.:/!%$^*&~\"#'\\E]"
|
||||
#define HOSTCHARS_CLASS "[-[:alnum:]]"
|
||||
#define HOST HOSTCHARS_CLASS "+(\\." HOSTCHARS_CLASS "+)*"
|
||||
#define PORT "(?:\\:[[:digit:]]{1,5})?"
|
||||
#define PATHCHARS_CLASS "[-[:alnum:]\\Q_$.+!*,;@&=?/~#%\\E]"
|
||||
#define PATHTERM_CLASS "[^\\Q]'.}>) \t\r\n,\"\\E]"
|
||||
#define SCHEME "(?:news:|telnet:|nntp:|file:\\/|https?:|ftps?:|sftp:|webcal:)"
|
||||
#define USERPASS USERCHARS_CLASS "+(?:" PASSCHARS_CLASS "+)?"
|
||||
#define URLPATH "(?:(/" PATHCHARS_CLASS "+(?:[(]" PATHCHARS_CLASS "*[)])*" PATHCHARS_CLASS"*)*"PATHTERM_CLASS ")?"
|
||||
|
||||
static const char * const url_regex = SCHEME "//(?:" USERPASS "\\@)?" HOST PORT URLPATH;
|
||||
|
||||
typedef enum overlay_mode {
|
||||
OVERLAY_HIDDEN = 0,
|
||||
|
|
Loading…
Reference in New Issue