mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-19 23:14:55 +02:00
Hints kitten: Overhaul making it more intelligent
It now uses information about the geometry of the screen. So URLs that stretch over multiple lines are detected even if there is a hard line break in between (some programs like mutt generate these).
This commit is contained in:
30
kitty_tests/hints.py
Normal file
30
kitty_tests/hints.py
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
from . import BaseTest
|
||||
|
||||
|
||||
class TestHints(BaseTest):
|
||||
|
||||
def test_url_hints(self):
|
||||
from kittens.hints.main import parse_hints_args, functions_for, mark, convert_text
|
||||
args = parse_hints_args([])[0]
|
||||
pattern, post_processors = functions_for(args)
|
||||
|
||||
def create_marks(text, cols=20):
|
||||
text = convert_text(text, cols)
|
||||
return tuple(mark(pattern, post_processors, text, args))
|
||||
|
||||
def t(text, url, cols=20):
|
||||
marks = create_marks(text, cols)
|
||||
urls = [m.text for m in marks]
|
||||
self.ae(urls, [url])
|
||||
|
||||
u = 'http://test.me/'
|
||||
t(u, 'http://test.me/')
|
||||
t('"{}"'.format(u), u)
|
||||
t('({})'.format(u), u)
|
||||
t(u + '\nxxx', u + 'xxx', len(u))
|
||||
t('link:{}[xxx]'.format(u), u)
|
||||
Reference in New Issue
Block a user