Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d83fbc71e3 | ||
|
|
cbee630d4c
|
||
|
|
4df542f590
|
||
|
|
b406be9394 | ||
|
|
4ca4a516ae
|
||
|
|
f616651c49
|
No files matched your search
@@ -302,7 +302,7 @@ _branch=feat/file-manager-panel
|
||||
### Publication automatique
|
||||
|
||||
`version`, à la racine, est la source de vérité des releases. Il suit la version
|
||||
du fork FWS (`0.1.9`), pas la version amont de kitty embarquée dans le paquet :
|
||||
du fork FWS (`0.1.11`), pas la version amont de kitty embarquée dans le paquet :
|
||||
c'est elle qui nomme le tag, la release et le paquet
|
||||
`fws-kitty-<version>-<rel>`. Il doit rester égal à `pkgver` dans
|
||||
`packaging/PKGBUILD` et à la version affichée par `fws-kitty`
|
||||
|
||||
+5
-2
@@ -31,10 +31,13 @@ Search scrollback in place :sc:`search_scrollback_prompt`
|
||||
|
||||
The in-place search highlights every match without replacing the screen with a
|
||||
pager. Prefix the query with ``\c`` to match case sensitively and with ``\r``
|
||||
to use a regular expression; both modifiers can be combined. While the search
|
||||
to use a regular expression; both modifiers can be combined. Write a doubled
|
||||
backslash (``\\c``, ``\\r``) to search for those prefixes literally. While the search
|
||||
is active, :kbd:`n` jumps to the next match, :kbd:`N` to the previous one and
|
||||
:kbd:`Escape` ends it. The ``[current/total]`` counter is shown in the window
|
||||
title and matches use the first marker color (see :opt:`mark1_foreground`).
|
||||
title, matches use the first mark color (see :opt:`mark1_foreground`) and the
|
||||
current match uses the second one (:opt:`mark2_foreground`), so it stands out
|
||||
from the other matches.
|
||||
The :ac:`scrollback_search_next`, :ac:`scrollback_search_prev` and
|
||||
:ac:`clear_scrollback_search` actions can also be mapped directly.
|
||||
|
||||
|
||||
+5
-2
@@ -277,8 +277,11 @@ Detailed list of changes
|
||||
highlights every match without opening the pager, shows the
|
||||
:code:`[current/total]` counter in the window title and moves between matches
|
||||
with :kbd:`n` and :kbd:`N`. Prefix the query with :code:`\c` for a case
|
||||
sensitive search and :code:`\r` for a regular expression. See
|
||||
:doc:`basic` for the details.
|
||||
sensitive search and :code:`\r` for a regular expression; write a doubled
|
||||
backslash (:code:`\\c`, :code:`\\r`) to search for those prefixes literally.
|
||||
The current match is drawn with the second mark color, so the match reached
|
||||
with :kbd:`n` and :kbd:`N` is visible without looking at the window title.
|
||||
See :doc:`basic` for the details.
|
||||
|
||||
- A configurable :opt:`leader` key now opens a which-key panel listing every
|
||||
multi-key mapping available under that prefix, without waiting for a timeout.
|
||||
|
||||
@@ -424,10 +424,10 @@ handle_fast_commandline(CLISpec *cli_spec, const char *instance_group_prefix) {
|
||||
if (get_bool_cli_val(cli_spec, "version")) {
|
||||
if (isatty(STDOUT_FILENO)) {
|
||||
printf("\x1b[3mkitty\x1b[23m \x1b[32m%s\x1b[39m created by \x1b[1;34mKovid Goyal\x1b[22;39m\n", KITTY_VERSION);
|
||||
printf("\x1b[3mfws-kitty\x1b[23m \x1b[32m0.1.9\x1b[39m by \x1b[1;34mBlackAngelTV\x1b[22;39m\n");
|
||||
printf("\x1b[3mfws-kitty\x1b[23m \x1b[32m0.1.11\x1b[39m by \x1b[1;34mBlackAngelTV\x1b[22;39m\n");
|
||||
} else {
|
||||
printf("kitty %s created by Kovid Goyal\n", KITTY_VERSION);
|
||||
printf("fws-kitty 0.1.9 by BlackAngelTV\n");
|
||||
printf("fws-kitty 0.1.11 by BlackAngelTV\n");
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
+19
-1
@@ -2,7 +2,7 @@
|
||||
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import re
|
||||
from collections.abc import Callable, Generator, Iterable, Sequence
|
||||
from collections.abc import Callable, Generator, Iterable, Mapping, Sequence
|
||||
from re import Pattern
|
||||
from typing import Union
|
||||
|
||||
@@ -29,6 +29,24 @@ def marker_from_regex(expression: Union[str, 'Pattern[str]'], color: int, flags:
|
||||
return marker
|
||||
|
||||
|
||||
def marker_from_spans(spans: Mapping[str, Sequence[tuple[int, int, int]]]) -> MarkerFunc:
|
||||
"""A marker built from pre-computed spans, keyed by the text of their line.
|
||||
|
||||
Each span is (start, end, color), where color is a mark number. Marker
|
||||
functions receive one line at a time without its number, hence the lookup
|
||||
by text.
|
||||
"""
|
||||
|
||||
def marker(text: str, left_address: int, right_address: int, color_address: int) -> Generator[None, None, None]:
|
||||
for start, end, color in spans.get(text, ()):
|
||||
set_uint_at_address(left_address, start)
|
||||
set_uint_at_address(right_address, end - 1)
|
||||
set_uint_at_address(color_address, max(1, min(color, 3)))
|
||||
yield
|
||||
|
||||
return marker
|
||||
|
||||
|
||||
def marker_from_multiple_regex(regexes: Iterable[tuple[int, str]], flags: int = re.UNICODE) -> MarkerFunc:
|
||||
expr = ''
|
||||
color_map = {}
|
||||
|
||||
@@ -6,17 +6,24 @@
|
||||
The query parser and the matcher live here, away from the screen code, so that
|
||||
they can be tested without a running terminal. A query can start with two
|
||||
modifiers, in any order: ``\\c`` makes matching case sensitive and ``\\r``
|
||||
treats the query as a regular expression.
|
||||
treats the query as a regular expression. A doubled backslash escapes the
|
||||
modifier syntax, so that the two prefixes can be searched for literally.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from collections.abc import Sequence
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
CASE_SENSITIVE_MODIFIER = 'c'
|
||||
REGEX_MODIFIER = 'r'
|
||||
|
||||
# Mark numbers (see :opt:`mark1_background`) used to highlight the matches. The
|
||||
# current match gets its own color so that it stands out from the other ones.
|
||||
MATCH_COLOR = 1
|
||||
CURRENT_MATCH_COLOR = 2
|
||||
|
||||
|
||||
class InvalidQuery(ValueError):
|
||||
pass
|
||||
@@ -51,12 +58,36 @@ class ScrollbackSearch:
|
||||
def __len__(self) -> int:
|
||||
return len(self.matches)
|
||||
|
||||
@property
|
||||
def current_match(self) -> Match | None:
|
||||
return self.matches[self.index] if self.matches else None
|
||||
|
||||
def marker_spans(self, lines: Sequence[str]) -> dict[str, tuple[tuple[int, int, int], ...]]:
|
||||
"""Spans to highlight, keyed by the text of the line holding them.
|
||||
|
||||
Marker functions are called once per line with only its text, never with
|
||||
its number, so the spans are grouped by line text. Lines that are
|
||||
identical to the current one are therefore highlighted alike, which the
|
||||
user cannot tell apart since their text is the same.
|
||||
"""
|
||||
current = self.current_match
|
||||
spans: dict[str, list[tuple[int, int, int]]] = {}
|
||||
for match in self.matches:
|
||||
color = CURRENT_MATCH_COLOR if match == current else MATCH_COLOR
|
||||
spans.setdefault(lines[match.line], []).append((match.start, match.end, color))
|
||||
return {text: tuple(found) for text, found in spans.items()}
|
||||
|
||||
|
||||
def parse_query(raw: str) -> Query:
|
||||
text = (raw or '').strip()
|
||||
case_sensitive = is_regex = False
|
||||
while len(text) > 1 and text[0] == '\\':
|
||||
modifier = text[1].lower()
|
||||
if modifier == '\\':
|
||||
# A doubled backslash stands for a literal one and ends the modifier
|
||||
# section, which is the only way to search for \c or \r themselves.
|
||||
text = text[1:]
|
||||
break
|
||||
if modifier == CASE_SENSITIVE_MODIFIER:
|
||||
case_sensitive = True
|
||||
elif modifier == REGEX_MODIFIER:
|
||||
|
||||
+23
-6
@@ -827,6 +827,7 @@ class Window:
|
||||
self.actions_on_removal: list[Callable[['Window'], None]] = []
|
||||
self.current_marker_spec: tuple[str, str | tuple[tuple[int, str], ...]] | None = None
|
||||
self.scrollback_search: ScrollbackSearch | None = None
|
||||
self.scrollback_search_spans: dict[str, tuple[tuple[int, int, int], ...]] = {}
|
||||
self.scrollback_search_mode: str = ''
|
||||
self.scrollback_search_saved_marker: tuple[str, str | tuple[tuple[int, str], ...]] | None = None
|
||||
self.scrollback_search_saved_title: str | None = None
|
||||
@@ -2676,8 +2677,10 @@ class Window:
|
||||
'sc',
|
||||
"""
|
||||
Search the scrollback in place, highlighting every match. Prefix the query with \\c for a case
|
||||
sensitive search and with \\r for a regular expression. Matches are navigated with n and N and
|
||||
the search ends with Escape. The [current/total] counter is shown in the window title.
|
||||
sensitive search and with \\r for a regular expression. To search for those two strings literally,
|
||||
write a double backslash instead (``\\\\c`` and ``\\\\r``). Matches are navigated with n and N and
|
||||
the search ends with Escape. The [current/total] counter is shown in the window title and the
|
||||
current match uses the second mark color.
|
||||
""",
|
||||
)
|
||||
def search_scrollback_prompt(self) -> bool | None:
|
||||
@@ -2691,7 +2694,10 @@ class Window:
|
||||
self.clear_scrollback_search()
|
||||
|
||||
get_boss().get_line(
|
||||
_('Search the scrollback. Prefix the query with \\c for a case sensitive search and \\r for a regular expression.'),
|
||||
_(
|
||||
'Search the scrollback. Prefix the query with \\c for a case sensitive search and \\r for a regular expression.'
|
||||
' Write a double backslash to search for those strings literally.'
|
||||
),
|
||||
done,
|
||||
window=self,
|
||||
prompt=_('search> '),
|
||||
@@ -2724,12 +2730,12 @@ class Window:
|
||||
ring_bell(self.os_window_id)
|
||||
return
|
||||
self.clear_scrollback_search()
|
||||
from .marks import marker_from_regex
|
||||
|
||||
self.scrollback_search = ScrollbackSearch(query, pattern, matches, total_lines=len(lines))
|
||||
search = ScrollbackSearch(query, pattern, matches, total_lines=len(lines))
|
||||
self.scrollback_search = search
|
||||
self.scrollback_search_spans = search.marker_spans(lines)
|
||||
self.scrollback_search_saved_marker = self.current_marker_spec
|
||||
self.scrollback_search_saved_title = self.override_title
|
||||
self.screen.set_marker(marker_from_regex(pattern, 1))
|
||||
self._push_scrollback_search_mode()
|
||||
self._goto_scrollback_match(0)
|
||||
|
||||
@@ -2738,6 +2744,7 @@ class Window:
|
||||
if self.scrollback_search is None:
|
||||
return
|
||||
self.scrollback_search = None
|
||||
self.scrollback_search_spans = {}
|
||||
self.screen.set_marker()
|
||||
self.current_marker_spec = None
|
||||
saved = self.scrollback_search_saved_marker
|
||||
@@ -2781,8 +2788,18 @@ class Window:
|
||||
search.index = index % len(search.matches)
|
||||
match = search.matches[search.index]
|
||||
self.set_title(f'[{search.index + 1}/{len(search.matches)}] {search.query.text}')
|
||||
self._refresh_scrollback_search_marker()
|
||||
self.screen.scroll_to_absolute(scroll_offset_for(match, search.total_lines, self.screen.lines))
|
||||
|
||||
def _refresh_scrollback_search_marker(self) -> None:
|
||||
from .marks import marker_from_spans
|
||||
|
||||
# Clear first, as set_marker() only releases the previous callable when
|
||||
# it is called without one. Marking every line again is needed anyway to
|
||||
# recolor the match that was current until now.
|
||||
self.screen.set_marker()
|
||||
self.screen.set_marker(marker_from_spans(self.scrollback_search_spans))
|
||||
|
||||
def _push_scrollback_search_mode(self) -> None:
|
||||
from .fast_data_types import GLFW_FKEY_ESCAPE, GLFW_MOD_SHIFT
|
||||
from .options.utils import KeyboardMode, KeyDefinition, SingleKey
|
||||
|
||||
@@ -5,8 +5,11 @@ import re
|
||||
import time
|
||||
|
||||
from kitty.scrollback_search import (
|
||||
CURRENT_MATCH_COLOR,
|
||||
MATCH_COLOR,
|
||||
InvalidQuery,
|
||||
Match,
|
||||
ScrollbackSearch,
|
||||
compile_query,
|
||||
find_matches,
|
||||
parse_query,
|
||||
@@ -46,6 +49,25 @@ class TestScrollbackSearch(BaseTest):
|
||||
with self.assertRaises(InvalidQuery):
|
||||
compile_query(parse_query('\\r ('))
|
||||
|
||||
def test_parse_query_escaped_backslash(self):
|
||||
# A doubled backslash searches text starting with a backslash instead of
|
||||
# being read as a modifier, so both modifier prefixes remain reachable.
|
||||
for raw, expected in (('\\\\c', '\\c'), ('\\\\r', '\\r'), ('\\\\C', '\\C'), ('\\\\', '\\')):
|
||||
with self.subTest(raw=raw):
|
||||
q = parse_query(raw)
|
||||
self.ae((q.text, q.case_sensitive, q.is_regex), (expected, False, False))
|
||||
|
||||
# Modifiers still combine with an escaped prefix in the searched text
|
||||
q = parse_query('\\c\\\\r')
|
||||
self.ae((q.text, q.case_sensitive, q.is_regex), ('\\r', True, False))
|
||||
|
||||
# The escaped prefix is matched like any other text, case insensitively
|
||||
# by default, and the case sensitive modifier still applies to it.
|
||||
matches = find_matches(['a \\c b', 'a \\C b'], parse_query('\\\\c'))
|
||||
self.ae([(m.line, m.start, m.end) for m in matches], [(0, 2, 4), (1, 2, 4)])
|
||||
matches = find_matches(['a \\c b', 'a \\C b'], parse_query('\\c\\\\c'))
|
||||
self.ae([(m.line, m.start, m.end) for m in matches], [(0, 2, 4)])
|
||||
|
||||
def test_find_matches_plain(self):
|
||||
lines = ['needle at start', 'Needle again', 'nothing', 'a needle here']
|
||||
matches = find_matches(lines, parse_query('needle'))
|
||||
@@ -64,6 +86,28 @@ class TestScrollbackSearch(BaseTest):
|
||||
# Empty matches are skipped and do not loop forever
|
||||
self.ae(find_matches(['abc'], parse_query('\\r x*')), [])
|
||||
|
||||
def test_current_match(self):
|
||||
lines = ['one 17 here', 'nothing', '17 and 17']
|
||||
query = parse_query('17')
|
||||
matches = find_matches(lines, query)
|
||||
search = ScrollbackSearch(query, compile_query(query), matches, total_lines=len(lines))
|
||||
self.ae(len(search), 3)
|
||||
self.ae(search.current_match, Match(0, 4, 6))
|
||||
search.index = 2
|
||||
self.ae(search.current_match, Match(2, 7, 9))
|
||||
|
||||
# The current match is the only one with its own color, and navigation
|
||||
# moves that color along
|
||||
spans = search.marker_spans(lines)
|
||||
self.ae(spans['one 17 here'], ((4, 6, MATCH_COLOR),))
|
||||
self.ae(spans['17 and 17'], ((0, 2, MATCH_COLOR), (7, 9, CURRENT_MATCH_COLOR)))
|
||||
search.index = 1
|
||||
self.ae(search.marker_spans(lines)['17 and 17'], ((0, 2, CURRENT_MATCH_COLOR), (7, 9, MATCH_COLOR)))
|
||||
|
||||
# Wrapping the index keeps exactly one current match selected
|
||||
search.index = 4 % len(search.matches)
|
||||
self.ae(sum(1 for found in search.marker_spans(lines).values() for span in found if span[2] == CURRENT_MATCH_COLOR), 1)
|
||||
|
||||
def test_scroll_offset(self):
|
||||
self.ae(scroll_offset_for(Match(0, 0, 1), 100, 10), 90)
|
||||
self.ae(scroll_offset_for(Match(50, 0, 1), 100, 10), 43)
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
pkgname=fws-kitty
|
||||
# Fork version from the version file: it names the release and the package.
|
||||
# The upstream kitty release built inside is tracked by _kittyver below.
|
||||
pkgver=0.1.9
|
||||
pkgver=0.1.11
|
||||
pkgrel=1
|
||||
pkgdesc='Fast, feature-rich, GPU based terminal (FWS fork with the file-manager kitten)'
|
||||
arch=('x86_64' 'aarch64')
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ func ShowError(err error) {
|
||||
|
||||
func (self *Command) version_string(formatter *markup.Context) string {
|
||||
return fmt.Sprintln(formatter.Italic(self.CommandStringForUsage()), formatter.Opt(kitty.VersionString+kitty.VersionSuffix), "created by", formatter.Title("Kovid Goyal")) +
|
||||
fmt.Sprintln(formatter.Italic("fws-kitty"), formatter.Opt("0.1.9"), "by", formatter.Title("BlackAngelTV"))
|
||||
fmt.Sprintln(formatter.Italic("fws-kitty"), formatter.Opt("0.1.11"), "by", formatter.Title("BlackAngelTV"))
|
||||
}
|
||||
|
||||
func (self *Command) ShowVersion() {
|
||||
|
||||
Reference in new issue
Block a user