Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a1ba595f1
|
||
|
|
a142e0b596
|
||
|
|
ee3f064886
|
||
|
|
e39f938a39 | ||
|
|
408f16f798
|
||
|
|
84f5500444 | ||
|
|
43d01ab87e
|
||
|
|
42c097c69a
|
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.15`), pas la version amont de kitty embarquée dans le paquet :
|
||||
du fork FWS (`0.1.17`), 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`
|
||||
|
||||
+76
-1
@@ -219,6 +219,78 @@ you use a decent Wayland compositor.
|
||||
Detailed list of changes
|
||||
-------------------------------------
|
||||
|
||||
Fork FWS releases
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The versions below are the releases of the FWS fork, which carries its own
|
||||
version so that a packaged build can be told apart from the upstream kitty it
|
||||
is based on. Each entry names the issue it closed.
|
||||
|
||||
0.1.17 [2026-12-03]
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
- The changelog now names each fork release with the issue it closed, instead
|
||||
of leaving the fork changes in the accumulated upstream section. No
|
||||
functional change.
|
||||
|
||||
0.1.16 [2026-12-03]
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
- The clipboard history picker now shows when each entry was copied and the
|
||||
title of the window the text will be pasted into, and :kbd:`↑`/:kbd:`↓` move
|
||||
the highlighted entry so that :kbd:`Enter` pastes it without typing the
|
||||
letters of a hint.
|
||||
|
||||
- The clicks of the docks are covered by tests: a left dock and a right dock
|
||||
must both receive the clicks in their own area, and the layout tests pin the
|
||||
position of a right dock instead of only its width.
|
||||
|
||||
0.1.15 [2026-12-03]
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
- The :doc:`file manager <kittens/file-manager>` can be browsed with the mouse:
|
||||
the wheel scrolls the list, a double click opens the entry under the pointer
|
||||
like :kbd:`Enter`, and a right click opens the action palette on the clicked
|
||||
row.
|
||||
|
||||
0.1.14 [2026-12-03]
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
- :kbd:`Ctrl+Shift+H` browses the scrollback in a pager again with
|
||||
:ac:`show_scrollback`: the keyboard shortcuts panel, which silently took the
|
||||
key over while the documentation still promised the pager, moved to
|
||||
:kbd:`Ctrl+Shift+Alt+H`.
|
||||
|
||||
0.1.13 [2026-12-03]
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
- The in-place scrollback search got a usable default shortcut,
|
||||
:kbd:`kitty_mod+alt+s`. It was bound to the same physical key as
|
||||
:ac:`move_window_forward`, which allows the shifted fallback, so the last
|
||||
definition won and the search never opened.
|
||||
|
||||
0.1.12 [2026-12-03]
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
- The keyboard shortcuts panel keeps a long action name inside its own column,
|
||||
shrinks its key column on very narrow docks so that a row always fits, and
|
||||
shows the full name of the selected action on the help line, instead of
|
||||
letting the edge of the dock cut the text.
|
||||
|
||||
0.1.11 [2026-12-03]
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
- The current match of the in-place scrollback search is drawn with the second
|
||||
mark color, so the match reached with :kbd:`n` and :kbd:`N` stands out from
|
||||
the other ones without reading the window title.
|
||||
|
||||
0.1.10 [2026-12-03]
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
- A literal :code:`\c` or :code:`\r` can be searched for by writing a doubled
|
||||
backslash (:code:`\\c`, :code:`\\r`), instead of the query modifiers always
|
||||
taking the prefix.
|
||||
|
||||
0.50.1 [unreleased]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -235,7 +307,10 @@ Detailed list of changes
|
||||
- kitty now keeps an in-memory history of the text copied to the clipboard,
|
||||
which :ac:`paste_from_clipboard_history` and :ac:`search_clipboard_history`
|
||||
can paste back. Nothing is written to disk and private clipboard writes are
|
||||
never recorded. See :ref:`clipboard_history` for details.
|
||||
never recorded. See :ref:`clipboard_history` for details. The picker shows
|
||||
when each entry was copied and the title of the window the text will be
|
||||
pasted into, and :kbd:`↑`/:kbd:`↓` select an entry so that :kbd:`Enter`
|
||||
pastes it without typing the letters of a hint.
|
||||
|
||||
- kitty now remembers the state of the session that was in use when it exited,
|
||||
in :file:`$XDG_STATE_HOME/kitty/last-session.json`, so that
|
||||
|
||||
+4
-2
@@ -276,8 +276,10 @@ instance, newest first, and lets you paste one of them back with
|
||||
:ac:`paste_from_clipboard_history`. :ac:`search_clipboard_history` filters the
|
||||
history with a fuzzy query before showing the list.
|
||||
|
||||
The picker numbers the entries: type the number next to the entry you want to
|
||||
paste, or press :kbd:`Escape` to cancel.
|
||||
The picker lists the entries with the time each one was copied and names the
|
||||
window that will receive the paste. Move the highlighted entry with :kbd:`↑` and
|
||||
:kbd:`↓` and press :kbd:`Enter` to paste it, or type the letters of the hint
|
||||
shown next to it. Press :kbd:`Escape` to cancel.
|
||||
|
||||
The history lives in memory only: it is never written to disk, so it disappears
|
||||
when kitty exits and secrets copied during a session do not outlive it. Text
|
||||
|
||||
@@ -376,8 +376,13 @@ func TestFilterEntriesLargeDirectory(t *testing.T) {
|
||||
if len(matches) == 0 {
|
||||
t.Fatal("expected matches in a large directory")
|
||||
}
|
||||
if elapsed > 100*time.Millisecond {
|
||||
t.Fatalf("filtering 10000 entries took %s, the limit is 100ms", elapsed)
|
||||
// The bound is deliberately loose: this guards against the filter becoming
|
||||
// superlinear (which turns 10000 entries into seconds), not against a few
|
||||
// extra milliseconds. A wall clock threshold tight enough to measure the
|
||||
// current implementation fails on a shared machine, where the same test
|
||||
// went from 15ms to 147ms while makepkg was building next to it.
|
||||
if elapsed > time.Second {
|
||||
t.Fatalf("filtering 10000 entries took %s, the limit is 1s", elapsed)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,24 @@ func rune_to_index_map(alphabet string) *map[rune]int {
|
||||
return &runeToIndexMap
|
||||
}
|
||||
|
||||
// next_selection moves pos by delta positions in a list of marks choices,
|
||||
// wrapping around, as the arrow keys do in the list picker. A negative pos,
|
||||
// meaning nothing is selected yet, selects the first choice when moving down
|
||||
// and the last one when moving up, and a stale pos falls back to the first
|
||||
// choice so that the arrow keys never stop working.
|
||||
func next_selection(pos, marks, delta int) int {
|
||||
if marks < 1 {
|
||||
return -1
|
||||
}
|
||||
if pos < 0 || pos >= marks {
|
||||
if delta < 0 {
|
||||
return marks - 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
return ((pos+delta)%marks + marks) % marks
|
||||
}
|
||||
|
||||
// decode_hint converts a hint to its corresponding index as it would appear in
|
||||
// the breadth-first traversal of the prefix tree generated by the given
|
||||
// alphabet.
|
||||
|
||||
+110
-24
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
@@ -160,6 +161,10 @@ func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
}
|
||||
}
|
||||
chosen := []*Mark{}
|
||||
// The list navigation is only offered when the input is an ordered list of
|
||||
// choices, see the --pick-from-list option.
|
||||
pick_from_list := o.PickFromList
|
||||
selected_mark := -1
|
||||
lp, err := loop.New(loop.NoAlternateScreen) // no alternate screen reduces flicker on exit
|
||||
if err != nil {
|
||||
return
|
||||
@@ -168,8 +173,9 @@ func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
faint := fctx.SprintFunc("dim")
|
||||
hint_style := fctx.SprintFunc(fmt.Sprintf("fg=%s bg=%s bold", o.HintsForegroundColor, o.HintsBackgroundColor))
|
||||
text_style := fctx.SprintFunc(fmt.Sprintf("fg=%s bg=%s bold", o.HintsTextColor, o.HintsTextBackgroundColor))
|
||||
selected_style := fctx.SprintFunc("reverse")
|
||||
|
||||
highlight_mark := func(m *Mark, mark_text string) string {
|
||||
highlight_mark := func(m *Mark, mark_text string, selected bool) string {
|
||||
hint := encode_hint(m.Index, alphabet)
|
||||
if current_input != "" && !strings.HasPrefix(hint, current_input) {
|
||||
return faint(mark_text)
|
||||
@@ -207,6 +213,9 @@ func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
mark_text = string(runes[hint_runes:])
|
||||
}
|
||||
ans := hint_style(hint) + text_style(mark_text)
|
||||
if selected {
|
||||
ans = selected_style(ans)
|
||||
}
|
||||
return fmt.Sprintf("\x1b]8;;mark:%d\a%s\x1b]8;;\a", m.Index, ans)
|
||||
}
|
||||
|
||||
@@ -217,7 +226,7 @@ func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
if ignore_mark_indices.Has(mark.Index) {
|
||||
continue
|
||||
}
|
||||
mtext := highlight_mark(mark, ans[mark.Start:mark.End])
|
||||
mtext := highlight_mark(mark, ans[mark.Start:mark.End], pick_from_list && mark.Index == selected_mark)
|
||||
ans = ans[:mark.Start] + mtext + ans[mark.End:]
|
||||
}
|
||||
ans = strings.ReplaceAll(ans, "\x00", "")
|
||||
@@ -238,6 +247,75 @@ func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
current_text = ""
|
||||
}
|
||||
|
||||
// The marks in the order they were given, which is the order of the list
|
||||
// the user sees rather than the order of the hints
|
||||
ordered_indices := make([]int, 0, len(index_map))
|
||||
for idx := range index_map {
|
||||
ordered_indices = append(ordered_indices, idx)
|
||||
}
|
||||
sort.Ints(ordered_indices)
|
||||
visible_marks := func() []*Mark {
|
||||
ans := make([]*Mark, 0, len(ordered_indices))
|
||||
for _, idx := range ordered_indices {
|
||||
m := index_map[idx]
|
||||
if m == nil || ignore_mark_indices.Has(m.Index) {
|
||||
continue
|
||||
}
|
||||
if current_input != "" && !strings.HasPrefix(encode_hint(idx, alphabet), current_input) {
|
||||
continue
|
||||
}
|
||||
ans = append(ans, m)
|
||||
}
|
||||
return ans
|
||||
}
|
||||
select_first := func() {
|
||||
selected_mark = -1
|
||||
if marks := visible_marks(); len(marks) > 0 {
|
||||
selected_mark = marks[0].Index
|
||||
}
|
||||
}
|
||||
choose_index := func(idx int) {
|
||||
m := index_map[idx]
|
||||
if m == nil {
|
||||
current_input = ""
|
||||
current_text = ""
|
||||
draw_screen()
|
||||
return
|
||||
}
|
||||
chosen = append(chosen, m)
|
||||
ignore_mark_indices.Add(m.Index)
|
||||
if o.Multiple {
|
||||
reset()
|
||||
select_first()
|
||||
draw_screen()
|
||||
} else {
|
||||
lp.Quit(0)
|
||||
}
|
||||
}
|
||||
select_by := func(delta int) {
|
||||
marks := visible_marks()
|
||||
if len(marks) == 0 {
|
||||
return
|
||||
}
|
||||
pos := -1
|
||||
for i, m := range marks {
|
||||
if m.Index == selected_mark {
|
||||
pos = i
|
||||
break
|
||||
}
|
||||
}
|
||||
if pos < 0 {
|
||||
pos = 0
|
||||
}
|
||||
pos = next_selection(pos, len(marks), delta)
|
||||
selected_mark = marks[pos].Index
|
||||
current_text = ""
|
||||
draw_screen()
|
||||
}
|
||||
if pick_from_list {
|
||||
select_first()
|
||||
}
|
||||
|
||||
lp.OnInitialize = func() (string, error) {
|
||||
lp.SetCursorVisible(false)
|
||||
lp.SetWindowTitle(window_title)
|
||||
@@ -295,13 +373,15 @@ func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
}
|
||||
if len(matches) == 1 {
|
||||
chosen = append(chosen, matches[0])
|
||||
if o.Multiple {
|
||||
ignore_mark_indices.Add(matches[0].Index)
|
||||
reset()
|
||||
} else {
|
||||
ignore_mark_indices.Add(matches[0].Index)
|
||||
if !o.Multiple {
|
||||
lp.Quit(0)
|
||||
return nil
|
||||
}
|
||||
reset()
|
||||
}
|
||||
if pick_from_list {
|
||||
select_first()
|
||||
}
|
||||
current_text = ""
|
||||
draw_screen()
|
||||
@@ -310,7 +390,14 @@ func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
}
|
||||
|
||||
lp.OnKeyEvent = func(ev *loop.KeyEvent) error {
|
||||
if ev.MatchesPressOrRepeat("backspace") {
|
||||
if pick_from_list && (ev.MatchesPressOrRepeat("up") || ev.MatchesPressOrRepeat("down")) {
|
||||
ev.Handled = true
|
||||
if ev.MatchesPressOrRepeat("up") {
|
||||
select_by(-1)
|
||||
} else {
|
||||
select_by(1)
|
||||
}
|
||||
} else if ev.MatchesPressOrRepeat("backspace") {
|
||||
ev.Handled = true
|
||||
r := []rune(current_input)
|
||||
if len(r) > 0 {
|
||||
@@ -318,26 +405,25 @@ func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
current_input = string(r)
|
||||
current_text = ""
|
||||
}
|
||||
if pick_from_list {
|
||||
select_first()
|
||||
}
|
||||
draw_screen()
|
||||
} else if ev.MatchesPressOrRepeat("enter") || ev.MatchesPressOrRepeat("space") {
|
||||
} else if ev.MatchesPressOrRepeat("enter") {
|
||||
ev.Handled = true
|
||||
if current_input != "" {
|
||||
char_to_index := rune_to_index_map(alphabet)
|
||||
idx := decode_hint(current_input, char_to_index)
|
||||
if m := index_map[idx]; m != nil {
|
||||
chosen = append(chosen, m)
|
||||
ignore_mark_indices.Add(idx)
|
||||
if o.Multiple {
|
||||
reset()
|
||||
draw_screen()
|
||||
} else {
|
||||
lp.Quit(0)
|
||||
}
|
||||
} else {
|
||||
current_input = ""
|
||||
current_text = ""
|
||||
draw_screen()
|
||||
if pick_from_list {
|
||||
if selected_mark > -1 {
|
||||
choose_index(selected_mark)
|
||||
} else if marks := visible_marks(); len(marks) > 0 {
|
||||
choose_index(marks[0].Index)
|
||||
}
|
||||
} else if current_input != "" {
|
||||
choose_index(decode_hint(current_input, rune_to_index_map(alphabet)))
|
||||
}
|
||||
} else if ev.MatchesPressOrRepeat("space") {
|
||||
ev.Handled = true
|
||||
if !pick_from_list && current_input != "" {
|
||||
choose_index(decode_hint(current_input, rune_to_index_map(alphabet)))
|
||||
}
|
||||
} else if ev.MatchesPressOrRepeat("esc") {
|
||||
if o.Multiple {
|
||||
|
||||
@@ -271,6 +271,14 @@ elsewhere. See {hints_url} for details.
|
||||
--window-title
|
||||
The title for the hints window, default title is based on the type of text being
|
||||
hinted.
|
||||
|
||||
|
||||
--pick-from-list
|
||||
type=bool-set
|
||||
The input is an ordered list of choices rather than text to search, as used by the
|
||||
clipboard history picker. The first choice is selected and the arrow keys move the
|
||||
selection, so a choice can be picked with :kbd:`Enter` instead of typing the
|
||||
letters of its hint.
|
||||
""".format(
|
||||
default_regex=DEFAULT_REGEX,
|
||||
line='{{line}}',
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// License: GPLv3 Copyright: 2026, Kovid Goyal, <kovid at kovidgoyal.net>
|
||||
|
||||
package hints
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestNextSelection(t *testing.T) {
|
||||
cases := []struct {
|
||||
pos, marks, delta, expected int
|
||||
}{
|
||||
// Nothing selected yet: down selects the first choice, up the last one
|
||||
{-1, 3, 0, 0},
|
||||
{-1, 3, 1, 0},
|
||||
{-1, 3, -1, 2},
|
||||
// Moving past either end wraps around
|
||||
{0, 3, 1, 1},
|
||||
{2, 3, 1, 0},
|
||||
{0, 3, -1, 2},
|
||||
{1, 1, 2, 0},
|
||||
{0, 3, 4, 1},
|
||||
{0, 3, -4, 2},
|
||||
// A stale position falls back to the first choice
|
||||
{5, 3, 1, 0},
|
||||
// An empty list has nothing to select
|
||||
{-1, 0, 1, -1},
|
||||
{0, 0, -1, -1},
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := next_selection(c.pos, c.marks, c.delta); got != c.expected {
|
||||
t.Fatalf("next_selection(%d, %d, %d) = %d, expected %d", c.pos, c.marks, c.delta, got, c.expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
-5
@@ -3187,11 +3187,24 @@ class Boss:
|
||||
q = ' '.join(text.split())
|
||||
return q if len(q) <= 120 else q[:117] + '…'
|
||||
|
||||
def _choose_from_clipboard_history(self, entries: tuple[str, ...]) -> None:
|
||||
def _clipboard_history_label(self, text: str, copied_at: float) -> str:
|
||||
# The time an entry was copied tells apart entries that look alike
|
||||
from datetime import datetime
|
||||
|
||||
when = datetime.fromtimestamp(copied_at).strftime('%H:%M')
|
||||
return f'{when} {self._clipboard_history_preview(text) or _("(blank)")}'
|
||||
|
||||
def _clipboard_history_target_title(self, target: Window | None) -> str:
|
||||
title = '' if target is None else ' '.join(target.title.split())
|
||||
if not title:
|
||||
return _('unknown window')
|
||||
return title if len(title) <= 80 else title[:77] + '…'
|
||||
|
||||
def _choose_from_clipboard_history(self, entries: tuple[tuple[str, float], ...]) -> None:
|
||||
if not entries:
|
||||
self.ring_bell_if_allowed()
|
||||
return
|
||||
previews = [(text, self._clipboard_history_preview(text) or _('(blank)')) for text in entries]
|
||||
previews = [(text, self._clipboard_history_label(text, when)) for text, when in entries]
|
||||
# The picker is itself the active window while it is open, so keep the window the user was
|
||||
# working in to paste into once it closes. The window can be gone by then.
|
||||
target = self.window_for_dispatch or self.active_window
|
||||
@@ -3202,11 +3215,18 @@ class Boss:
|
||||
if w is not None:
|
||||
w.paste_with_actions(text)
|
||||
|
||||
self.choose_entry(_('Clipboard history'), previews, chosen)
|
||||
self.choose_entry(
|
||||
_('Clipboard history'),
|
||||
previews,
|
||||
chosen,
|
||||
subtitle=_('Paste into: {}').format(self._clipboard_history_target_title(target)),
|
||||
footer=_('↑/↓ move · Enter paste · Esc cancel'),
|
||||
hints_args=('--pick-from-list',),
|
||||
)
|
||||
|
||||
@ac('cp', 'Paste an entry from the clipboard history. See :ref:`clipboard_history`.')
|
||||
def paste_from_clipboard_history(self) -> None:
|
||||
self._choose_from_clipboard_history(self.clipboard_history.entries())
|
||||
self._choose_from_clipboard_history(self.clipboard_history.entries_with_times())
|
||||
|
||||
@ac('cp', 'Search the clipboard history and paste the selected entry. See :ref:`clipboard_history`.')
|
||||
def search_clipboard_history(self) -> None:
|
||||
@@ -3215,7 +3235,7 @@ class Boss:
|
||||
return
|
||||
|
||||
def query_entered(query: str) -> None:
|
||||
self._choose_from_clipboard_history(self.clipboard_history.search(query))
|
||||
self._choose_from_clipboard_history(self.clipboard_history.search_with_times(query))
|
||||
|
||||
self.get_line(
|
||||
_('Search the clipboard history. Leave empty to list everything.'),
|
||||
@@ -3979,6 +3999,7 @@ class Boss:
|
||||
callback: Callable[[_T | str | None], None],
|
||||
subtitle: str = '',
|
||||
hints_args: tuple[str, ...] | None = None,
|
||||
footer: str = '',
|
||||
) -> Window | None:
|
||||
lines = [title, subtitle, ' '] if subtitle else [title, ' ']
|
||||
idx_map: list[_T | str | None] = []
|
||||
@@ -3991,6 +4012,8 @@ class Boss:
|
||||
lines.append(text)
|
||||
else:
|
||||
lines.append(fmt.format(len(idx_map), text))
|
||||
if footer:
|
||||
lines.append(f' {footer}')
|
||||
|
||||
def done(data: dict[str, Any], target_window_id: int, self: Boss) -> None:
|
||||
nonlocal ans
|
||||
|
||||
+24
-13
@@ -7,7 +7,7 @@
|
||||
# help within one kitty instance, not to outlive it. Entries marked private are never recorded.
|
||||
|
||||
from collections import deque
|
||||
from contextlib import suppress
|
||||
from time import time
|
||||
from typing import Iterator
|
||||
|
||||
DEFAULT_MAX_ENTRIES = 50
|
||||
@@ -76,7 +76,7 @@ class ClipboardHistory:
|
||||
self.max_entries = max(1, max_entries)
|
||||
self.max_entry_chars = max(1, max_entry_chars)
|
||||
self.max_total_chars = max(1, max_total_chars)
|
||||
self._entries: deque[str] = deque()
|
||||
self._entries: deque[tuple[str, float]] = deque()
|
||||
self._total_chars = 0
|
||||
|
||||
def __len__(self) -> int:
|
||||
@@ -86,43 +86,54 @@ class ClipboardHistory:
|
||||
return bool(self._entries)
|
||||
|
||||
def __iter__(self) -> Iterator[str]:
|
||||
return reversed(self._entries)
|
||||
return iter(self.entries())
|
||||
|
||||
def __getitem__(self, idx: int) -> str:
|
||||
return self.entries()[idx]
|
||||
|
||||
def entries(self) -> tuple[str, ...]:
|
||||
"""All entries, most recently copied first."""
|
||||
return tuple(text for text, _ in reversed(self._entries))
|
||||
|
||||
def entries_with_times(self) -> tuple[tuple[str, float], ...]:
|
||||
"""All entries with the time they were copied, most recent first."""
|
||||
return tuple(reversed(self._entries))
|
||||
|
||||
def clear(self) -> None:
|
||||
self._entries.clear()
|
||||
self._total_chars = 0
|
||||
|
||||
def add(self, text: str, private: bool = False) -> bool:
|
||||
def add(self, text: str, private: bool = False, timestamp: float | None = None) -> bool:
|
||||
"""Record text, returning False when it is deliberately not recorded."""
|
||||
if private or not text or not text.strip():
|
||||
return False
|
||||
if len(text) > self.max_entry_chars:
|
||||
return False
|
||||
# A repeated copy moves the entry to the top instead of duplicating it
|
||||
with suppress(ValueError):
|
||||
self._entries.remove(text)
|
||||
self._total_chars -= len(text)
|
||||
self._entries.append(text)
|
||||
for idx, (old_text, _) in enumerate(self._entries):
|
||||
if old_text == text:
|
||||
del self._entries[idx]
|
||||
self._total_chars -= len(old_text)
|
||||
break
|
||||
self._entries.append((text, time() if timestamp is None else timestamp))
|
||||
self._total_chars += len(text)
|
||||
while self._entries and (len(self._entries) > self.max_entries or self._total_chars > self.max_total_chars):
|
||||
self._total_chars -= len(self._entries.popleft())
|
||||
self._total_chars -= len(self._entries.popleft()[0])
|
||||
return True
|
||||
|
||||
def search(self, query: str) -> tuple[str, ...]:
|
||||
"""Entries matching query, best match first, newest first among equal scores."""
|
||||
return tuple(text for text, _ in self.search_with_times(query))
|
||||
|
||||
def search_with_times(self, query: str) -> tuple[tuple[str, float], ...]:
|
||||
"""The entries search() returns, with the time each one was copied."""
|
||||
entries = self.entries_with_times()
|
||||
if not query.strip():
|
||||
return self.entries()
|
||||
return entries
|
||||
scored = []
|
||||
for idx, text in enumerate(self.entries()):
|
||||
for idx, (text, when) in enumerate(entries):
|
||||
score = match_score(query, text)
|
||||
if score > -1:
|
||||
scored.append((score, idx, text))
|
||||
scored.append((score, idx, text, when))
|
||||
scored.sort(key=lambda x: (x[0], x[1]))
|
||||
return tuple(text for _, _, text in scored)
|
||||
return tuple((text, when) for _, _, text, when in scored)
|
||||
@@ -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.15\x1b[39m by \x1b[1;34mBlackAngelTV\x1b[22;39m\n");
|
||||
printf("\x1b[3mfws-kitty\x1b[23m \x1b[32m0.1.17\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.15 by BlackAngelTV\n");
|
||||
printf("fws-kitty 0.1.17 by BlackAngelTV\n");
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -2183,6 +2183,73 @@ update_mock_pointer(PyObject *self UNUSED, PyObject *args) {
|
||||
return Py_BuildValue("(iO)", result, updated ? Py_True : Py_False);
|
||||
}
|
||||
|
||||
/* Hit test a point against two windows placed side by side in a mock tab, and
|
||||
* return 1 or 2 for the window mouse_region() picks, or 0 when none is hit.
|
||||
* A docked window must receive the clicks in its own area, whatever the edge it
|
||||
* is docked at, so the edges are given here rather than assumed to be left. */
|
||||
static PyObject *
|
||||
mock_window_under_mouse(PyObject *self UNUSED, PyObject *args) {
|
||||
PyObject *capsule;
|
||||
int g[2][4];
|
||||
int mouse_x, mouse_y;
|
||||
if (!PyArg_ParseTuple(
|
||||
args,
|
||||
"O!iiiiiiiiii",
|
||||
&PyCapsule_Type,
|
||||
&capsule,
|
||||
&g[0][0],
|
||||
&g[0][1],
|
||||
&g[0][2],
|
||||
&g[0][3],
|
||||
&g[1][0],
|
||||
&g[1][1],
|
||||
&g[1][2],
|
||||
&g[1][3],
|
||||
&mouse_x,
|
||||
&mouse_y))
|
||||
return NULL;
|
||||
Window *w = PyCapsule_GetPointer(capsule, "Window");
|
||||
if (!w) return NULL;
|
||||
Screen *screen = w->render_data.screen;
|
||||
if (!screen) return NULL;
|
||||
OSWindow *saved_os_window = global_state.callback_os_window;
|
||||
const id_type saved_hover = global_state.mouse_hover_in_window;
|
||||
Window windows[2] = {*w, *w};
|
||||
for (unsigned int i = 0; i < 2; i++) {
|
||||
Window *win = windows + i;
|
||||
win->id = w->id + i;
|
||||
win->visible = true;
|
||||
win->render_data.screen = screen;
|
||||
win->render_data.geometry.left = (unsigned int)MAX(0, g[i][0]);
|
||||
win->render_data.geometry.top = (unsigned int)MAX(0, g[i][1]);
|
||||
win->render_data.geometry.right = (unsigned int)MAX(0, g[i][2]);
|
||||
win->render_data.geometry.bottom = (unsigned int)MAX(0, g[i][3]);
|
||||
zero_at_ptr(&win->padding);
|
||||
zero_at_ptr(&win->size_mismatch_padding);
|
||||
}
|
||||
Tab tab = {.windows = windows, .num_windows = 2};
|
||||
struct {
|
||||
FONTS_DATA_HEAD
|
||||
} fonts = {.logical_dpi_x = 72, .logical_dpi_y = 72, .fcm = {.cell_width = 10, .cell_height = 20}};
|
||||
OSWindow osw = {
|
||||
.tabs = &tab,
|
||||
.num_tabs = 1,
|
||||
.has_too_few_tabs = true,
|
||||
.fonts_data = (FONTS_DATA_HANDLE)&fonts,
|
||||
.viewport_width = 1400,
|
||||
.viewport_height = 600,
|
||||
.mouse_x = (double)mouse_x,
|
||||
.mouse_y = (double)mouse_y};
|
||||
global_state.callback_os_window = &osw;
|
||||
global_state.mouse_hover_in_window = 0;
|
||||
MouseRegion region = mouse_region(false, false);
|
||||
unsigned long ans = region.window == windows ? 1 : region.window == windows + 1 ? 2 : 0;
|
||||
global_state.callback_os_window = saved_os_window;
|
||||
global_state.mouse_hover_in_window = saved_hover;
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
return PyLong_FromUnsignedLong(ans);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
test_scale_scroll(PyObject *self UNUSED, PyObject *args) {
|
||||
PyObject *values;
|
||||
@@ -2258,6 +2325,7 @@ static PyMethodDef module_methods[] = {
|
||||
METHODB(test_mapped_scroll_steps, METH_VARARGS),
|
||||
METHODB(send_mock_mouse_event_to_window, METH_VARARGS),
|
||||
METHODB(update_mock_pointer, METH_VARARGS),
|
||||
METHODB(mock_window_under_mouse, METH_VARARGS),
|
||||
METHODB(send_mock_scroll_event_to_window, METH_VARARGS),
|
||||
METHODB(mock_mouse_selection, METH_VARARGS),
|
||||
{NULL, NULL, 0, NULL} /* Sentinel */
|
||||
|
||||
@@ -78,6 +78,19 @@ class TestClipboardHistory(BaseTest):
|
||||
self.ae(h.search('mkb'), ('make build',))
|
||||
self.ae(h.search('zzz'), ())
|
||||
|
||||
def test_entries_carry_the_time_they_were_copied(self) -> None:
|
||||
h = ClipboardHistory()
|
||||
self.assertTrue(h.add('first', timestamp=100.0))
|
||||
self.assertTrue(h.add('second', timestamp=200.0))
|
||||
self.ae(h.entries(), ('second', 'first'))
|
||||
self.ae(h.entries_with_times(), (('second', 200.0), ('first', 100.0)))
|
||||
# A repeated copy moves the text and its new time to the top
|
||||
self.assertTrue(h.add('first', timestamp=300.0))
|
||||
self.ae(h.entries(), ('first', 'second'))
|
||||
self.ae(h.entries_with_times(), (('first', 300.0), ('second', 200.0)))
|
||||
self.ae(h.search_with_times('sec'), (('second', 200.0),))
|
||||
self.ae(h.search('sec'), ('second',))
|
||||
|
||||
def test_substring_matches_rank_before_subsequences(self) -> None:
|
||||
h = ClipboardHistory()
|
||||
h.add('xkcd')
|
||||
|
||||
@@ -126,6 +126,16 @@ class TestDocks(BaseTest):
|
||||
content, placements = carve_docks(Region((0, 0, -1, -1, 0, 0)), groups, CELL_WIDTH, CELL_HEIGHT)
|
||||
self.ae([r.height for g, r in placements], [0, 0])
|
||||
|
||||
# A dock at the right is placed against the right edge of what remains,
|
||||
# the same way a dock at the left is placed against the left edge
|
||||
groups = []
|
||||
left, right = dock('left', '10%'), dock('right', '5%')
|
||||
content, placements = carve_docks(VIEWPORT, groups, CELL_WIDTH, CELL_HEIGHT)
|
||||
regions = {g.id: rect(r) for g, r in placements}
|
||||
self.ae(regions[left.id], (0, 0, 100, 600))
|
||||
self.ae(regions[right.id], (950, 0, 1000, 600))
|
||||
self.ae(rect(content), (100, 0, 950, 600))
|
||||
|
||||
def test_tab_docks(self):
|
||||
q = make_layout(Tall)
|
||||
windows = make_windows(q, 2)
|
||||
@@ -183,6 +193,9 @@ class TestDocks(BaseTest):
|
||||
self.assertTrue(rect(r)[0] >= allocated.left and rect(r)[2] <= allocated.left + allocated.width)
|
||||
self.ae(rect(dock_regions[0])[1], allocated.top + allocated.height - 2 * CELL_HEIGHT - 2 * DECORATION)
|
||||
self.ae(dock_regions[1].width, allocated.width // 4)
|
||||
# The dock at the right sits past the content, at the right of the area
|
||||
self.assertGreaterEqual(rect(dock_regions[1])[0], rect(content)[2])
|
||||
self.assertLessEqual(rect(dock_regions[1])[2], allocated.left + allocated.width)
|
||||
self.check_no_overlaps(windows)
|
||||
# The decorations chosen by the layout for the owner are preserved
|
||||
self.ae(main.geometry.spaces.left - main.geometry.compensatory.left, DECORATION)
|
||||
|
||||
@@ -834,3 +834,31 @@ class TestMouse(BaseTest):
|
||||
ac([], 4)
|
||||
self.assertTrue(s.callbacks.wtcbuf, 'the wheel event was not reported to the program')
|
||||
parse_bytes(s, b'\x1b[?1000l')
|
||||
|
||||
def test_docked_window_receives_clicks_at_any_edge(self):
|
||||
from kitty.fast_data_types import mock_window_under_mouse
|
||||
|
||||
s = self.create_screen(cols=140, lines=30)
|
||||
w = create_mock_window(s)
|
||||
terminal, right_dock = (0, 0, 1000, 600), (1000, 0, 1400, 600)
|
||||
left_dock, offset_terminal = (0, 0, 400, 600), (400, 0, 1400, 600)
|
||||
|
||||
def under(first, second, x, y):
|
||||
return mock_window_under_mouse(w, *first, *second, x, y)
|
||||
|
||||
# A dock at the right receives the clicks in its own area and the
|
||||
# terminal receives the clicks in the area left over
|
||||
self.ae(under(terminal, right_dock, 500, 300), 1)
|
||||
self.ae(under(terminal, right_dock, 999, 300), 1)
|
||||
self.ae(under(terminal, right_dock, 1000, 300), 2)
|
||||
self.ae(under(terminal, right_dock, 1200, 300), 2)
|
||||
# Swapping the two areas over must give the same answer for a dock at
|
||||
# the left, so the hit test does not depend on the edge
|
||||
self.ae(under(left_dock, offset_terminal, 500, 300), 2)
|
||||
self.ae(under(left_dock, offset_terminal, 100, 300), 1)
|
||||
self.ae(under(left_dock, offset_terminal, 399, 300), 1)
|
||||
# The first window wins when two areas overlap, as with an overlay
|
||||
self.ae(under(terminal, (500, 0, 1400, 600), 700, 300), 1)
|
||||
# A window with an empty area is never hit, even inside the other one
|
||||
self.ae(under(terminal, (0, 0, 0, 0), 1200, 300), 0)
|
||||
self.ae(under((0, 0, 0, 0), right_dock, 1200, 300), 2)
|
||||
+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.15
|
||||
pkgver=0.1.17
|
||||
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.15"), "by", formatter.Title("BlackAngelTV"))
|
||||
fmt.Sprintln(formatter.Italic("fws-kitty"), formatter.Opt("0.1.17"), "by", formatter.Title("BlackAngelTV"))
|
||||
}
|
||||
|
||||
func (self *Command) ShowVersion() {
|
||||
|
||||
Reference in new issue
Block a user