Compare commits
15
Commits
v0.1.8
...
de13151af1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de13151af1
|
||
|
|
fab02aa915
|
||
|
|
f324f5fff2
|
||
|
|
bcf3fdff7b
|
||
|
|
90e6355841 | ||
|
|
ea29472b27 | ||
|
|
9c1bf4d84f
|
||
|
|
93055004a9
|
||
|
|
4fb1402d9e
|
||
|
|
a12a05e666
|
||
|
|
4b59b3a375
|
||
|
|
86982b79be
|
||
|
|
fb87a7306f
|
||
|
|
01c1531119
|
||
|
|
4d10615cc4
|
No files matched your search
@@ -0,0 +1,121 @@
|
|||||||
|
# Installer et lancer la version de développement
|
||||||
|
|
||||||
|
Ce document explique comment compiler puis lancer kitty depuis les sources, en
|
||||||
|
local sur **Arch Linux** ou depuis **Windows/macOS via Docker**.
|
||||||
|
|
||||||
|
kitty ne se compile pas nativement sous Windows : `./dev.sh` ne fournit les
|
||||||
|
dépendances précompilées que pour Linux et macOS. Le dépôt est donc développé
|
||||||
|
sur Windows mais compilé et exécuté contre Arch Linux (la distribution cible),
|
||||||
|
soit dans le conteneur fourni, soit dans un Arch natif (machine ou WSL2).
|
||||||
|
|
||||||
|
## Dépendances
|
||||||
|
|
||||||
|
Arch Linux, tous les paquets listés dans `docs/build.rst` :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo pacman -S --needed base-devel git go python \
|
||||||
|
harfbuzz zlib libpng lcms2 xxhash openssl shader-slang \
|
||||||
|
pixman cairo freetype2 fontconfig libcanberra systemd-libs simde \
|
||||||
|
libx11 libxcb libxrandr libxinerama libxcursor libxi libxrender \
|
||||||
|
xorgproto libxkbcommon libxkbcommon-x11 mesa dbus \
|
||||||
|
wayland wayland-protocols wayland-utils tar xz rsync which file
|
||||||
|
```
|
||||||
|
|
||||||
|
`go` doit être au moins la version indiquée dans `go.mod` (actuellement 1.26).
|
||||||
|
|
||||||
|
## Option 1 : Arch Linux natif
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git clone <url-du-depot> FWS-Kitty && cd FWS-Kitty
|
||||||
|
./dev.sh build
|
||||||
|
./kitty/launcher/kitty
|
||||||
|
```
|
||||||
|
|
||||||
|
`./dev.sh build` télécharge les dépendances précompilées dans `dependencies/`
|
||||||
|
(et une police NERD dans `fonts/`), puis compile le C, le Go et les kittens.
|
||||||
|
Pour re-télécharger les dépendances : `./dev.sh deps`.
|
||||||
|
|
||||||
|
Raccourcis utiles :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./dev.sh build --debug # symboles de debug
|
||||||
|
./dev.sh build --debug --sanitize
|
||||||
|
./dev.sh build -h # toutes les options
|
||||||
|
```
|
||||||
|
|
||||||
|
`kitty` et `kitten` sont produits dans `kitty/launcher/`. Créez des liens
|
||||||
|
symboliques vers eux dans un dossier de votre `PATH` pour les lancer de partout.
|
||||||
|
L'exécutable compilé retrouve ses sources par le chemin où `./dev.sh build` a
|
||||||
|
été lancé : si vous déplacez le dossier, faites `make clean && ./dev.sh build`.
|
||||||
|
|
||||||
|
### Affichage
|
||||||
|
|
||||||
|
kitty a besoin d'un serveur graphique. Sous Arch natif c'est votre session
|
||||||
|
X11/Wayland. Dans WSL2, activez WSLg (Windows 11) : `./kitty/launcher/kitty`
|
||||||
|
s'ouvre alors dans une fenêtre Windows. Sans WSLg, il faut un serveur X
|
||||||
|
(par exemple VcXsrv) et un `DISPLAY` correct.
|
||||||
|
|
||||||
|
## Option 2 : Docker (depuis Windows ou macOS)
|
||||||
|
|
||||||
|
Le dépôt fournit `Dockerfile.arch`, une image Arch Linux avec toutes les
|
||||||
|
dépendances ci-dessus.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# construire l'image (à refaire seulement si le Dockerfile change)
|
||||||
|
docker build -f Dockerfile.arch -t kitty-arch-dev .
|
||||||
|
|
||||||
|
# compiler kitty : les artefacts restent dans le dépôt
|
||||||
|
docker run --rm -v "C:/chemin/vers/FWS-Kitty:/src" -w /src kitty-arch-dev sh dev.sh build
|
||||||
|
|
||||||
|
# lancer
|
||||||
|
docker run --rm -it -v "C:/chemin/vers/FWS-Kitty:/src" -w /src kitty-arch-dev ./kitty/launcher/kitty
|
||||||
|
```
|
||||||
|
|
||||||
|
Sous Git Bash, préfixez les commandes par `MSYS_NO_PATHCONV=1` pour éviter que
|
||||||
|
les chemins `/src` soient réécrits en chemins Windows.
|
||||||
|
|
||||||
|
Vérification rapide sans interface graphique :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker run --rm -v "C:/chemin/vers/FWS-Kitty:/src" -w /src kitty-arch-dev \
|
||||||
|
./kitty/launcher/kitty --version
|
||||||
|
```
|
||||||
|
|
||||||
|
Le conteneur n'a pas d'affichage : pour voir la fenêtre, montez le socket X11 ou
|
||||||
|
utilisez un Arch natif/WSLg.
|
||||||
|
|
||||||
|
## Tests et vérifications
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./test.py # suite complète (Python + Go)
|
||||||
|
./test.py --module screen # tests d'un module Python
|
||||||
|
./test.py MyFunction # un test Go nommé TestMyFunction
|
||||||
|
./test.py type-check # vérification de types
|
||||||
|
ruff check --fix # lint Python
|
||||||
|
```
|
||||||
|
|
||||||
|
Le Makefile expose les mêmes entrées : `make debug`, `make test`, `make clean`.
|
||||||
|
|
||||||
|
## Dépannage
|
||||||
|
|
||||||
|
**`dev.sh: $'\r': command not found` ou `make` qui échoue** : fins de ligne
|
||||||
|
CRLF dans l'arbre de travail. Le dépôt est normalisé en LF via `.gitattributes` ;
|
||||||
|
corrigez localement avec :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git config core.autocrlf false
|
||||||
|
git rm --cached -r -q . && git reset --hard
|
||||||
|
```
|
||||||
|
|
||||||
|
**`X11/extensions/XInput2.h: No such file or directory`** : il manque `libxi`
|
||||||
|
(pour XInput2) sur la machine ou dans l'image.
|
||||||
|
|
||||||
|
**`undefined: err` dans `bypy/devenv.go`** : erreur corrigée dans le dépôt ;
|
||||||
|
mettez à jour votre branche si vous la rencontrez.
|
||||||
|
|
||||||
|
**Compilation très lente sur Windows** : le montage Docker depuis `C:` est
|
||||||
|
lent ; préférez un Arch natif/WSL pour les builds répétés.
|
||||||
|
|
||||||
|
**`kitty: command not found` après installation** : les binaires sont dans
|
||||||
|
`kitty/launcher/` ; ajoutez ce dossier à votre `PATH` ou créez des liens
|
||||||
|
symboliques.
|
||||||
@@ -0,0 +1,342 @@
|
|||||||
|
# FWS-Kitty
|
||||||
|
|
||||||
|
FWS-Kitty est le fork **FWS** de [kitty](https://sw.kovidgoyal.net/kitty/), un
|
||||||
|
terminal GPU rapide et riche en fonctionnalités. Le fork ajoute un
|
||||||
|
**gestionnaire de fichiers** (`kitten file-manager`) : un panneau latéral
|
||||||
|
pilotable au clavier qui change le répertoire courant du shell, crée, renomme et
|
||||||
|
supprime des entrées, et ouvre les fichiers dans l'éditeur.
|
||||||
|
|
||||||
|
Ce document décrit tout le cycle de vie du projet : récupérer le code, compiler,
|
||||||
|
lancer, utiliser l'explorateur, tester, construire le paquet Arch et dépanner.
|
||||||
|
`DEV.md` reste le guide de développement condensé, `README.asciidoc` est le
|
||||||
|
README d'origine de kitty.
|
||||||
|
|
||||||
|
## Contenu de la branche `feat/file-manager-panel`
|
||||||
|
|
||||||
|
| Chemin | Rôle |
|
||||||
|
| --- | --- |
|
||||||
|
| `kittens/file_manager/main.go` | Interface du panneau (rendu, touches, souris, actions fichiers) |
|
||||||
|
| `kittens/file_manager/main.py` | Définition des options, des raccourcis et du résultat renvoyé au shell |
|
||||||
|
| `kittens/file_manager/main_test.go` | Tests unitaires des fonctions pures |
|
||||||
|
| `kittens/file_manager/cli_generated.go`, `conf_generated.go` | Générés à la compilation, **non versionnés** |
|
||||||
|
| `tools/cmd/tool/main.go` | Enregistre `kitten file-manager` dans le binaire `kitten` |
|
||||||
|
| `docs/kittens/file-manager.rst` | Documentation utilisateur du panneau |
|
||||||
|
| `packaging/PKGBUILD`, `packaging/README.md` | Paquet pacman `fws-kitty` |
|
||||||
|
|
||||||
|
Les fichiers `*_generated.go` sont listés dans `.gitignore` : ils sont produits
|
||||||
|
par le code de génération à chaque `./dev.sh build`. Un `go build ./...` lancé
|
||||||
|
avant cette étape échoue avec `undefined: create_cmd` ou `undefined: Options`,
|
||||||
|
c'est normal.
|
||||||
|
|
||||||
|
## Prérequis
|
||||||
|
|
||||||
|
- **Linux x86_64 ou aarch64** (Arch Linux recommandé : c'est la cible du fork).
|
||||||
|
Windows et macOS ne compilent pas nativement, voir la section Docker.
|
||||||
|
- **Python >= 3.12** (voir `pyproject.toml`).
|
||||||
|
- **Go >= 1.26** (voir `go.mod`).
|
||||||
|
- Un serveur graphique X11 ou Wayland : le panneau s'affiche dans une fenêtre
|
||||||
|
kitty, il n'existe pas de mode texte seul.
|
||||||
|
|
||||||
|
Sur Arch Linux, tous les paquets de compilation :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo pacman -S --needed base-devel git go python \
|
||||||
|
harfbuzz zlib libpng lcms2 xxhash openssl shader-slang \
|
||||||
|
pixman cairo freetype2 fontconfig libcanberra systemd-libs simde \
|
||||||
|
libx11 libxcb libxrandr libxinerama libxcursor libxi libxrender \
|
||||||
|
xorgproto libxkbcommon libxkbcommon-x11 mesa dbus \
|
||||||
|
wayland wayland-protocols wayland-utils tar xz rsync which file
|
||||||
|
```
|
||||||
|
|
||||||
|
Pour le paquet Arch, `makepkg` a besoin en plus de `pkgconf` et `ncurses`.
|
||||||
|
|
||||||
|
## Récupérer le code
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git clone <url-du-depot> FWS-Kitty
|
||||||
|
cd FWS-Kitty
|
||||||
|
git checkout feat/file-manager-panel
|
||||||
|
git pull
|
||||||
|
```
|
||||||
|
|
||||||
|
Le dépôt est normalisé en **LF** par `.gitattributes`. Si vous voyez des erreurs
|
||||||
|
du type `dev.sh: $'\r': command not found`, corrigez la copie de travail :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git config core.autocrlf false
|
||||||
|
git rm --cached -r -q . && git reset --hard
|
||||||
|
```
|
||||||
|
|
||||||
|
`packaging/` doit être présent après le `git pull` : sans lui, la section
|
||||||
|
« Paquet Arch » est impossible. Si le dossier manque, la branche n'a pas été
|
||||||
|
poussée complètement.
|
||||||
|
|
||||||
|
## Compiler
|
||||||
|
|
||||||
|
Tout passe par `./dev.sh`, qui télécharge un bundle de dépendances précompilées
|
||||||
|
(Python, pkg-config, Sphinx, polices…) dans `dependencies/`, puis appelle
|
||||||
|
`setup.py`.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./dev.sh deps # une seule fois, ou après une erreur de dépendances
|
||||||
|
./dev.sh build
|
||||||
|
```
|
||||||
|
|
||||||
|
`./dev.sh build` compile le C, génère le code Go (dont la configuration et la
|
||||||
|
ligne de commande du gestionnaire de fichiers), puis compile les kittens et les
|
||||||
|
outils. Les binaires finaux sont :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
kitty/launcher/kitty # le terminal
|
||||||
|
kitty/launcher/kitten # le lanceur de kittens (dont file-manager)
|
||||||
|
```
|
||||||
|
|
||||||
|
Options utiles :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./dev.sh build --debug # symboles de debug
|
||||||
|
./dev.sh build --debug --sanitize
|
||||||
|
./dev.sh build -h # toutes les options
|
||||||
|
```
|
||||||
|
|
||||||
|
`dependencies/` est local et ignoré par git : il n'est jamais récupéré par un
|
||||||
|
`git pull`, et il peut exister sous forme de simple archive téléchargée. Depuis
|
||||||
|
cette version, `build` vérifie la présence du Python du bundle et relance
|
||||||
|
automatiquement `deps` s'il manque. En cas de doute :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
rm -rf dependencies
|
||||||
|
./dev.sh deps && ./dev.sh build
|
||||||
|
```
|
||||||
|
|
||||||
|
Pour lancer les binaires sans chemin complet, ajoutez `kitty/launcher` au
|
||||||
|
`PATH`, ou créez des liens symboliques :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ln -s "$PWD/kitty/launcher/kitty" ~/.local/bin/kitty
|
||||||
|
ln -s "$PWD/kitty/launcher/kitten" ~/.local/bin/kitten
|
||||||
|
```
|
||||||
|
|
||||||
|
Le binaire retrouve ses sources par le chemin où `./dev.sh build` a été lancé :
|
||||||
|
si le dossier est déplacé, faites `make clean && ./dev.sh build`.
|
||||||
|
|
||||||
|
## Lancer kitty
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./kitty/launcher/kitty
|
||||||
|
```
|
||||||
|
|
||||||
|
Vérification rapide sans interface graphique :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./kitty/launcher/kitty --version # kitty 0.50.0 ...
|
||||||
|
./kitty/launcher/kitten --version # kitten 0.50.0 ...
|
||||||
|
```
|
||||||
|
|
||||||
|
Sous WSL2, activez WSLg (Windows 11) pour obtenir une fenêtre, sinon exportez un
|
||||||
|
`DISPLAY` vers un serveur X. Dans un conteneur, montez le socket X11 ou le
|
||||||
|
socket Wayland ; une image sans affichage ne peut pas montrer le panneau.
|
||||||
|
|
||||||
|
### Docker (depuis Windows ou macOS)
|
||||||
|
|
||||||
|
`Dockerfile.arch` fournit un Arch Linux avec toutes les dépendances :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker build -f Dockerfile.arch -t kitty-arch-dev .
|
||||||
|
docker run --rm -v "$PWD:/src" -w /src kitty-arch-dev sh dev.sh build
|
||||||
|
docker run --rm -it -v "$PWD:/src" -w /src kitty-arch-dev ./kitty/launcher/kitty
|
||||||
|
```
|
||||||
|
|
||||||
|
Sous Git Bash, préfixez par `MSYS_NO_PATHCONV=1` pour que `/src` ne soit pas
|
||||||
|
réécrit en chemin Windows. Le conteneur n'a pas d'affichage par défaut.
|
||||||
|
|
||||||
|
## Utiliser l'explorateur de fichiers
|
||||||
|
|
||||||
|
Le panneau doit tourner **dans kitty** : c'est un kitten, pas un programme
|
||||||
|
autonome. Depuis un shell lancé dans kitty :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
kitten file-manager # répertoire courant
|
||||||
|
kitten file-manager ~/Projets # répertoire de départ
|
||||||
|
kitten file-manager --show-hidden
|
||||||
|
```
|
||||||
|
|
||||||
|
Raccourci pour l'avoir en permanence dans un dock latéral, à ajouter dans
|
||||||
|
`~/.config/kitty/kitty.conf` :
|
||||||
|
|
||||||
|
```conf
|
||||||
|
map ctrl+shift+e launch --type=window-dock --dock-edge=left --dock-size=60 kitten file-manager
|
||||||
|
```
|
||||||
|
|
||||||
|
Un fichier validé s'ouvre dans un nouvel onglet, donc en pleine fenêtre même
|
||||||
|
depuis un dock, et le panneau reprend la main à la fermeture de l'éditeur. En
|
||||||
|
revanche, kitty ne rend jamais le résultat d'un `launch --type=window-dock` au
|
||||||
|
shell : `Ctrl+Entrée` dans un dock ne peut donc pas faire de `cd`.
|
||||||
|
|
||||||
|
### Raccourcis par défaut
|
||||||
|
|
||||||
|
| Touche | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| `Entrée` | Ouvre la sélection : entre dans le répertoire, ou ouvre le fichier dans l'éditeur dans un nouvel onglet ; le panneau revient à la fermeture de l'éditeur |
|
||||||
|
| `→` / `L` | Entre dans le répertoire sélectionné sans toucher au shell |
|
||||||
|
| `←` / `Retour arrière` / `H` | Remonte au répertoire parent |
|
||||||
|
| `Ctrl+Entrée` / `C` | Déplace le shell vers le répertoire affiché, sans tenir compte de la sélection |
|
||||||
|
| `↑` / `K`, `↓` / `J` | Déplace la sélection |
|
||||||
|
| `Page préc.` / `Ctrl+B`, `Page suiv.` / `Ctrl+F` | Déplace la sélection d'une page |
|
||||||
|
| `Début` / `G`, `Fin` / `Maj+G` | Première / dernière entrée |
|
||||||
|
| `N` | Crée un fichier (nom saisi dans la ligne d'état) |
|
||||||
|
| `Maj+N` | Crée un répertoire |
|
||||||
|
| `R` | Renomme l'entrée sélectionnée |
|
||||||
|
| `D` | Supprime après confirmation par `Y` (jamais récursivement) |
|
||||||
|
| `Y` | Copie le chemin dans le presse-papiers |
|
||||||
|
| `.` | Affiche ou masque les entrées cachées |
|
||||||
|
| `Ctrl+R` | Recharge le répertoire |
|
||||||
|
| `Échap` / `Q` | Ferme sans rien changer |
|
||||||
|
|
||||||
|
Un clic gauche sélectionne une entrée. Tous les raccourcis sont redéfinissables.
|
||||||
|
|
||||||
|
### Limites à connaître
|
||||||
|
|
||||||
|
- `Entrée` reste dans le panneau et fonctionne partout, dock compris.
|
||||||
|
`Ctrl+Entrée` agit sur la fenêtre qui a lancé le panneau : dans un dock ou un
|
||||||
|
panneau du bureau, le changement de répertoire n'a personne à qui s'appliquer,
|
||||||
|
lancez l'explorateur depuis un shell pour `cd`.
|
||||||
|
- L'éditeur s'ouvre toujours dans un nouvel onglet, plein écran ; fermer
|
||||||
|
l'éditeur referme l'onglet et rend le panneau tel qu'il était.
|
||||||
|
- L'édition passe par kitty : le fichier doit être accessible en lecture et en
|
||||||
|
écriture. Pour un fichier de root, utilisez `sudo -e` depuis le shell.
|
||||||
|
- La suppression d'un répertoire non vide affiche une erreur, jamais une
|
||||||
|
suppression récursive.
|
||||||
|
|
||||||
|
## Configurer l'explorateur
|
||||||
|
|
||||||
|
Les réglages vivent dans `~/.config/kitty/file-manager.conf` (même syntaxe que
|
||||||
|
`kitty.conf`) :
|
||||||
|
|
||||||
|
```conf
|
||||||
|
# Afficher les fichiers cachés à l'ouverture
|
||||||
|
show_hidden yes
|
||||||
|
|
||||||
|
# name (défaut) ou mtime (plus récent d'abord)
|
||||||
|
sort_by mtime
|
||||||
|
|
||||||
|
# Remplacer un raccourci
|
||||||
|
map toggle_hidden ctrl+h toggle_hidden
|
||||||
|
map delete x delete
|
||||||
|
```
|
||||||
|
|
||||||
|
Actions disponibles : `quit`, `move_up`, `move_down`, `page_up`, `page_down`,
|
||||||
|
`home`, `end`, `activate`, `enter_dir`, `parent_dir`, `cd_here`,
|
||||||
|
`toggle_hidden`, `create_file`, `create_dir`, `rename`, `delete`, `copy_path`,
|
||||||
|
`refresh`.
|
||||||
|
|
||||||
|
L'éditeur est celui de kitty : l'option `editor` de `kitty.conf`, ou `VISUAL`
|
||||||
|
puis `EDITOR` quand elle vaut `.` (le défaut). Pour forcer nano, mettez
|
||||||
|
`editor nano` dans `kitty.conf`, pas dans `file-manager.conf`.
|
||||||
|
|
||||||
|
## Tester et vérifier
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./test.py # suite complète (Python + Go)
|
||||||
|
./test.py --module kittens/file_manager # tests Go du panneau
|
||||||
|
./test.py TestTruncateToWidth # un test Go nommé
|
||||||
|
./test.py type-check # vérification de types
|
||||||
|
ruff check --fix # lint Python
|
||||||
|
```
|
||||||
|
|
||||||
|
Sans passer par `test.py`, les tests Go du panneau se lancent directement :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
go test ./kittens/file_manager/
|
||||||
|
```
|
||||||
|
|
||||||
|
Après une modification du Go ou du Python du kitten, `./dev.sh build` est
|
||||||
|
obligatoire : c'est lui qui régénère `cli_generated.go` / `conf_generated.go`
|
||||||
|
et réinstalle les modules Python du panneau.
|
||||||
|
|
||||||
|
## Construire la documentation
|
||||||
|
|
||||||
|
La documentation HTML et les pages de manuel demandent Sphinx :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./dev.sh deps --for-docs
|
||||||
|
./dev.sh docs
|
||||||
|
```
|
||||||
|
|
||||||
|
La page `docs/kittens/file-manager.rst` est incluse par le motif `kittens/*` du
|
||||||
|
sommaire (`docs/kittens_intro.rst`) et embarque les options générées.
|
||||||
|
|
||||||
|
## Paquet Arch
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd packaging
|
||||||
|
makepkg -f # -s pour installer les dépendances manquantes
|
||||||
|
```
|
||||||
|
|
||||||
|
Le résultat est `fws-kitty-<version>-<rel>-<arch>.pkg.tar.zst`. Le paquet
|
||||||
|
s'appelle `fws-kitty`, remplace `kitty` via `provides`/`conflicts` et installe
|
||||||
|
les binaires dans `/usr/bin`.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo pacman -U fws-kitty-*.pkg.tar.zst
|
||||||
|
kitty --version
|
||||||
|
kitten --version
|
||||||
|
kitten file-manager --help
|
||||||
|
```
|
||||||
|
|
||||||
|
`makepkg` construit depuis la branche `_branch` du `PKGBUILD` (`main` par
|
||||||
|
défaut). Pour empaqueter cette branche avant fusion, modifiez la ligne en haut
|
||||||
|
du fichier (une variable d'environnement ne suffit pas, le `PKGBUILD`
|
||||||
|
réaffecte `_branch`) :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
_branch=feat/file-manager-panel
|
||||||
|
```
|
||||||
|
|
||||||
|
La publication dans un dépôt pacman (`repo-add`, configuration client,
|
||||||
|
automatisation) est détaillée dans `packaging/README.md`.
|
||||||
|
|
||||||
|
## Dépannage
|
||||||
|
|
||||||
|
| Symptôme | Cause et solution |
|
||||||
|
| --- | --- |
|
||||||
|
| `fork/exec .../dependencies/linux-amd64/bin/python: no such file or directory` | Bundle de dépendances incomplet. `build` le détecte maintenant et relance `deps` ; sinon `rm -rf dependencies && ./dev.sh deps`. |
|
||||||
|
| `undefined: create_cmd`, `undefined: Options`, `undefined: NewConfig` | Code Go généré absent (fichiers ignorés par git). Lancer `./dev.sh build`, pas `go build ./...`. |
|
||||||
|
| `Unknown kitten: file-manager` ou l'aide ne le liste pas | Binaire `kitten` obsolète : relancer `./dev.sh build` et utiliser `kitty/launcher/kitten`. |
|
||||||
|
| `+file-manager is not a known kitten` | Le panneau s'appelle `kitten file-manager` (sans `+`). |
|
||||||
|
| `kitten: command not found` | Les binaires sont dans `kitty/launcher/` : chemin complet, `PATH` ou lien symbolique. |
|
||||||
|
| `Ctrl+Entrée` ferme le panneau sans changer de répertoire | Lancé dans un dock : `cd` n'a pas de shell cible. Lancer l'explorateur depuis une fenêtre de shell. |
|
||||||
|
| `... is not readable and writeable` en ouvrant un fichier | L'édition passe par kitty et demande un accès en lecture et écriture. Ouvrir le fichier avec `sudo -e` depuis le shell. |
|
||||||
|
| Rien ne s'affiche / pas de fenêtre | Pas de serveur graphique : session X11/Wayland, WSLg, ou socket monté dans Docker. |
|
||||||
|
| `X11/extensions/XInput2.h: No such file` | Installer `libxi` (XInput2). |
|
||||||
|
| `dev.sh: $'\r': command not found` | Fins de ligne CRLF, voir « Récupérer le code ». |
|
||||||
|
| Compilation très lente sous Windows | Montage Docker depuis `C:` : préférer un Arch natif, WSL2 ou un volume local. |
|
||||||
|
| `error: failed to init transaction (unable to lock database)` avec `makepkg -s` | Un autre pacman tourne, ou utilisez `makepkg -f --nodeps` avec les dépendances déjà installées. |
|
||||||
|
|
||||||
|
### Vérifier que la branche est complète
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git status --short # doit être vide (ou seulement des artefacts ignorés)
|
||||||
|
git ls-files packaging # doit lister PKGBUILD et README.md
|
||||||
|
./dev.sh build
|
||||||
|
./test.py --module kittens/file_manager
|
||||||
|
./kitty/launcher/kitten file-manager --help
|
||||||
|
```
|
||||||
|
|
||||||
|
`packaging/` est actuellement **non versionné** : tant qu'il n'est pas commité
|
||||||
|
et poussé, un `git pull` sur une autre machine ne le récupère pas.
|
||||||
|
|
||||||
|
## Organisation du dépôt
|
||||||
|
|
||||||
|
| Dossier | Contenu |
|
||||||
|
| --- | --- |
|
||||||
|
| `kitty/` | Cœur du terminal (C, Python) |
|
||||||
|
| `kittens/` | Kittens intégrés, dont `file_manager/` |
|
||||||
|
| `tools/` | Outils Go (`kitten`, `kitty`, complétion) |
|
||||||
|
| `glfw/`, `glad/`, `3rdparty/` | Fenêtrage et dépendances embarquées |
|
||||||
|
| `docs/` | Documentation Sphinx (FR) |
|
||||||
|
| `gen/`, `bypy/` | Génération de code et scripts de build |
|
||||||
|
| `packaging/` | Paquet Arch |
|
||||||
|
| `kitty_tests/` | Tests Python |
|
||||||
|
|
||||||
|
Licence : GPL-3.0-only (`LICENSE`).
|
||||||
+18
-4
@@ -367,6 +367,18 @@ func prepend(env_var, path string) {
|
|||||||
os.Setenv(env_var, path+val)
|
os.Setenv(env_var, path+val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func python_exe() string {
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "linux":
|
||||||
|
return filepath.Join(root_dir(), "bin", "python")
|
||||||
|
case `darwin`:
|
||||||
|
return filepath.Join(root_dir(), macos_python)
|
||||||
|
default:
|
||||||
|
exit("Building is only supported on Linux and macOS")
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func setup_to_run_python() (python string) {
|
func setup_to_run_python() (python string) {
|
||||||
root := root_dir()
|
root := root_dir()
|
||||||
for _, x := range os.Environ() {
|
for _, x := range os.Environ() {
|
||||||
@@ -379,18 +391,20 @@ func setup_to_run_python() (python string) {
|
|||||||
case "linux":
|
case "linux":
|
||||||
prepend("LD_LIBRARY_PATH", filepath.Join(root, "lib"))
|
prepend("LD_LIBRARY_PATH", filepath.Join(root, "lib"))
|
||||||
os.Setenv("PYTHONHOME", root)
|
os.Setenv("PYTHONHOME", root)
|
||||||
python = filepath.Join(root, "bin", "python")
|
|
||||||
case `darwin`:
|
case `darwin`:
|
||||||
python = filepath.Join(root, macos_python)
|
|
||||||
default:
|
default:
|
||||||
exit("Building is only supported on Linux and macOS")
|
exit("Building is only supported on Linux and macOS")
|
||||||
}
|
}
|
||||||
return
|
return python_exe()
|
||||||
}
|
}
|
||||||
|
|
||||||
func build(args []string) {
|
func build(args []string) {
|
||||||
chdir_to_base()
|
chdir_to_base()
|
||||||
if _, err := os.Stat(folder); err != nil {
|
// Check the Python binary instead of the dependencies folder: the folder
|
||||||
|
// survives a git pull (it is gitignored, so a clone has none) but can
|
||||||
|
// contain only the cached tarball, which used to fail later with a
|
||||||
|
// cryptic missing Python error instead of downloading the bundle.
|
||||||
|
if _, err := os.Stat(python_exe()); err != nil {
|
||||||
dependencies(nil)
|
dependencies(nil)
|
||||||
}
|
}
|
||||||
root := root_dir()
|
root := root_dir()
|
||||||
|
|||||||
@@ -222,6 +222,14 @@ Detailed list of changes
|
|||||||
0.50.1 [unreleased]
|
0.50.1 [unreleased]
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
- A new :doc:`file manager kitten <kittens/file-manager>`, run with
|
||||||
|
:code:`kitten file-manager`, that browses directories in a side panel and
|
||||||
|
changes the working directory of the shell that launched it without leaving
|
||||||
|
the shell. It opens files in the configured editor, optionally through
|
||||||
|
:code:`sudo`, and can open them in its own window with :code:`--open-here` so
|
||||||
|
that it stays usable in a dock. It also copies paths and creates, renames and
|
||||||
|
deletes entries after a confirmation
|
||||||
|
|
||||||
- :doc:`choose-files <kittens/choose-files>`: Fix concurrent custom preview
|
- :doc:`choose-files <kittens/choose-files>`: Fix concurrent custom preview
|
||||||
commands occasionally receiving the path of a different file.
|
commands occasionally receiving the path of a different file.
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,125 @@
|
|||||||
|
.. _file_manager:
|
||||||
|
|
||||||
|
Gestionnaire de fichiers
|
||||||
|
=========================
|
||||||
|
|
||||||
|
.. only:: man
|
||||||
|
|
||||||
|
Aperçu
|
||||||
|
------
|
||||||
|
|
||||||
|
Le gestionnaire de fichiers affiche le contenu d'un répertoire dans un panneau
|
||||||
|
latéral, pilotable entièrement au clavier, et change le répertoire courant du
|
||||||
|
shell qui l'a lancé. Il remplace la plupart des :code:`cd` : on descend dans
|
||||||
|
l'arborescence avec :kbd:`Entrée`, puis :kbd:`Ctrl+Entrée` ferme le panneau et
|
||||||
|
déplace le shell, sans perdre l'environnement, l'historique ni l'état de la
|
||||||
|
session.
|
||||||
|
|
||||||
|
Lancer le panneau avec :code:`kitten file-manager`, ou depuis une
|
||||||
|
:ref:`fenêtre dockée <docks>` pour l'avoir en permanence à côté du shell::
|
||||||
|
|
||||||
|
map ctrl+shift+e launch --type=window-dock --dock-edge=left --dock-size=60 kitten file-manager
|
||||||
|
|
||||||
|
Il peut aussi tourner dans un :doc:`panneau du bureau </kittens/panel>` ou dans
|
||||||
|
n'importe quelle :term:`fenêtre kitty <window>` classique.
|
||||||
|
|
||||||
|
Le répertoire de départ est celui de la fenêtre courante, sauf si un répertoire
|
||||||
|
est passé en argument ou avec ``--start-dir``.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
Le changement de répertoire ne peut viser que la fenêtre depuis laquelle le
|
||||||
|
panneau a été lancé. Lancé dans un dock ou un panneau du bureau, il ne change
|
||||||
|
donc pas le répertoire du shell : :kbd:`Ctrl+Entrée` ferme le panneau sans
|
||||||
|
déplacer le shell. Lancez le panneau depuis une fenêtre de shell pour changer
|
||||||
|
de répertoire.
|
||||||
|
|
||||||
|
L'ouverture d'un fichier, elle, fonctionne partout : le panneau confie le
|
||||||
|
fichier à kitty, qui lance l'éditeur dans un nouvel onglet. Le fichier
|
||||||
|
dispose ainsi de toute la fenêtre même depuis un dock, et le panneau reprend
|
||||||
|
la main à la fermeture de l'éditeur, avec la même sélection.
|
||||||
|
|
||||||
|
|
||||||
|
Actions
|
||||||
|
-------
|
||||||
|
|
||||||
|
:kbd:`Entrée`
|
||||||
|
Si la sélection est un répertoire, le panneau y descend, exactement comme
|
||||||
|
avec :kbd:`→`. Si c'est un fichier, il est ouvert dans l'éditeur de kitty
|
||||||
|
(:opt:`editor`, :envvar:`VISUAL` ou :envvar:`EDITOR`) dans un nouvel onglet ;
|
||||||
|
le panneau reste ouvert et retrouve sa sélection lorsque l'éditeur se ferme.
|
||||||
|
|
||||||
|
Le nouvel onglet est ce qui donne au fichier toute la fenêtre : dans un
|
||||||
|
dock, exécuter l'éditeur dans le panneau le réduirait à la largeur du dock.
|
||||||
|
L'édition passe par le protocole d'édition de kitty, le fichier doit donc
|
||||||
|
être accessible en lecture et en écriture ; pour un fichier de root,
|
||||||
|
utilisez :code:`sudo -e` depuis le shell.
|
||||||
|
|
||||||
|
:kbd:`→` ou :kbd:`L`
|
||||||
|
descend dans le répertoire sélectionné sans toucher au shell.
|
||||||
|
|
||||||
|
:kbd:`←`, :kbd:`Retour arrière` ou :kbd:`H`
|
||||||
|
remonte au répertoire parent.
|
||||||
|
|
||||||
|
:kbd:`Ctrl+Entrée` ou :kbd:`C`
|
||||||
|
déplace le shell vers la sélection si c'est un répertoire, sinon vers le
|
||||||
|
répertoire affiché, puis ferme le panneau.
|
||||||
|
|
||||||
|
:kbd:`N` et :kbd:`Maj+N`
|
||||||
|
créent un fichier, respectivement un répertoire, dans le répertoire
|
||||||
|
affiché. Le nom se saisit dans la ligne d'état.
|
||||||
|
|
||||||
|
:kbd:`R`
|
||||||
|
renomme l'entrée sélectionnée.
|
||||||
|
|
||||||
|
:kbd:`D`
|
||||||
|
supprime l'entrée sélectionnée après confirmation par :kbd:`y`. Les
|
||||||
|
répertoires ne sont jamais supprimés récursivement : un répertoire non vide
|
||||||
|
provoque une erreur.
|
||||||
|
|
||||||
|
:kbd:`Y`
|
||||||
|
copie le chemin de la sélection dans le presse-papiers.
|
||||||
|
|
||||||
|
:kbd:`.`
|
||||||
|
affiche ou masque les entrées cachées.
|
||||||
|
|
||||||
|
:kbd:`Échap` ou :kbd:`Q`
|
||||||
|
ferme le panneau sans rien changer.
|
||||||
|
|
||||||
|
|
||||||
|
.. _file-manager-shortcuts:
|
||||||
|
|
||||||
|
Raccourcis et configuration
|
||||||
|
-----------------------------
|
||||||
|
|
||||||
|
Tous les raccourcis sont configurables dans :file:`file-manager.conf`, dans le
|
||||||
|
répertoire de configuration de kitty, avec la même syntaxe que les mappages de
|
||||||
|
:file:`kitty.conf`. La valeur par défaut, suivie d'un exemple de
|
||||||
|
personnalisation::
|
||||||
|
|
||||||
|
# ~/.config/kitty/file-manager.conf
|
||||||
|
show_hidden yes
|
||||||
|
sort_by mtime
|
||||||
|
map quit esc quit
|
||||||
|
map toggle_hidden ctrl+h toggle_hidden
|
||||||
|
map delete x delete
|
||||||
|
|
||||||
|
Les actions disponibles sont :code:`quit`, :code:`move_up`, :code:`move_down`,
|
||||||
|
:code:`page_up`, :code:`page_down`, :code:`home`, :code:`end`,
|
||||||
|
:code:`activate`, :code:`enter_dir`, :code:`parent_dir`, :code:`cd_here`,
|
||||||
|
:code:`toggle_hidden`, :code:`create_file`, :code:`create_dir`,
|
||||||
|
:code:`rename`, :code:`delete`, :code:`copy_path` et :code:`refresh`.
|
||||||
|
|
||||||
|
Deux réglages d'apparence sont aussi disponibles : ``show_hidden`` affiche les
|
||||||
|
entrées cachées à l'ouverture du panneau et ``sort_by`` vaut ``name`` (tri par
|
||||||
|
nom en ignorant la casse) ou ``mtime`` (tri par date de dernière modification).
|
||||||
|
|
||||||
|
L'éditeur n'est pas choisi par le panneau : le fichier est confié à kitty, qui
|
||||||
|
utilise son option :opt:`editor` de :file:`kitty.conf`. Quand celle-ci vaut
|
||||||
|
:code:`.` (le défaut), :envvar:`VISUAL` puis :envvar:`EDITOR` sont utilisés,
|
||||||
|
avec repli sur le premier éditeur connu installé. Pour forcer nano, ajoutez
|
||||||
|
:code:`editor nano` dans :file:`kitty.conf`.
|
||||||
|
|
||||||
|
.. include:: /generated/conf-kitten-file_manager.rst
|
||||||
|
|
||||||
|
.. include:: /generated/cli-kitten-file_manager.rst
|
||||||
Whitespace-only changes.
@@ -0,0 +1,836 @@
|
|||||||
|
// License: GPLv3 Copyright: 2026, FWS
|
||||||
|
|
||||||
|
package file_manager
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/kovidgoyal/kitty/tools/cli"
|
||||||
|
"github.com/kovidgoyal/kitty/tools/config"
|
||||||
|
"github.com/kovidgoyal/kitty/tools/tui"
|
||||||
|
"github.com/kovidgoyal/kitty/tools/tui/loop"
|
||||||
|
"github.com/kovidgoyal/kitty/tools/wcswidth"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = fmt.Print
|
||||||
|
|
||||||
|
// Entry is a single item of the listing. ModTime is kept as a unix timestamp
|
||||||
|
// so that sorting by date does not require stat()ing every entry again.
|
||||||
|
type Entry struct {
|
||||||
|
Name string
|
||||||
|
IsDir bool
|
||||||
|
ModTime int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type input_purpose int
|
||||||
|
|
||||||
|
const (
|
||||||
|
input_none input_purpose = iota
|
||||||
|
input_create_file
|
||||||
|
input_create_dir
|
||||||
|
input_rename
|
||||||
|
)
|
||||||
|
|
||||||
|
// Pure helpers, kept free of terminal state so that they can be unit tested
|
||||||
|
// without a tty.
|
||||||
|
|
||||||
|
func is_hidden_name(name string) bool {
|
||||||
|
return strings.HasPrefix(name, ".")
|
||||||
|
}
|
||||||
|
|
||||||
|
func sort_entries(entries []Entry, sort_by string) {
|
||||||
|
sort.SliceStable(entries, func(i, j int) bool {
|
||||||
|
a, b := entries[i], entries[j]
|
||||||
|
if a.IsDir != b.IsDir {
|
||||||
|
return a.IsDir
|
||||||
|
}
|
||||||
|
if sort_by == "mtime" && a.ModTime != b.ModTime {
|
||||||
|
return a.ModTime > b.ModTime
|
||||||
|
}
|
||||||
|
return strings.ToLower(a.Name) < strings.ToLower(b.Name)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func read_dir(dir string, show_hidden bool, sort_by string) ([]Entry, error) {
|
||||||
|
items, err := os.ReadDir(dir)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
entries := make([]Entry, 0, len(items))
|
||||||
|
for _, item := range items {
|
||||||
|
name := item.Name()
|
||||||
|
if !show_hidden && is_hidden_name(name) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
e := Entry{Name: name, IsDir: item.IsDir()}
|
||||||
|
if info, ierr := item.Info(); ierr == nil {
|
||||||
|
e.ModTime = info.ModTime().Unix()
|
||||||
|
}
|
||||||
|
entries = append(entries, e)
|
||||||
|
}
|
||||||
|
sort_entries(entries, sort_by)
|
||||||
|
return entries, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func entry_path(dir, name string) string {
|
||||||
|
return filepath.Join(dir, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func parent_of(dir string) string {
|
||||||
|
return filepath.Dir(dir)
|
||||||
|
}
|
||||||
|
|
||||||
|
func validate_entry_name(name string) error {
|
||||||
|
if name == "" || name == "." || name == ".." {
|
||||||
|
return fmt.Errorf("A file name is required")
|
||||||
|
}
|
||||||
|
if strings.ContainsRune(name, '/') || strings.ContainsRune(name, 0) || strings.ContainsRune(name, os.PathSeparator) {
|
||||||
|
return fmt.Errorf("%#v is not a valid file name as it contains a path separator", name)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func create_file(dir, name string) (string, error) {
|
||||||
|
if err := validate_entry_name(name); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
path := entry_path(dir, name)
|
||||||
|
f, err := os.OpenFile(path, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o644)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if err = f.Close(); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return path, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func create_subdir(dir, name string) (string, error) {
|
||||||
|
if err := validate_entry_name(name); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
path := entry_path(dir, name)
|
||||||
|
if err := os.Mkdir(path, 0o755); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return path, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func rename_entry(dir, old_name, new_name string) (string, error) {
|
||||||
|
if err := validate_entry_name(new_name); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if old_name == new_name {
|
||||||
|
return entry_path(dir, old_name), nil
|
||||||
|
}
|
||||||
|
dest := entry_path(dir, new_name)
|
||||||
|
if _, err := os.Lstat(dest); err == nil {
|
||||||
|
return "", fmt.Errorf("%#v already exists", new_name)
|
||||||
|
}
|
||||||
|
if err := os.Rename(entry_path(dir, old_name), dest); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return dest, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete_entry removes a file, a symlink or an empty directory. Recursive
|
||||||
|
// deletion is deliberately not done here so that a misplaced keypress cannot
|
||||||
|
// wipe out a tree of files.
|
||||||
|
func delete_entry(dir, name string) error {
|
||||||
|
if name == "" || name == "." || name == ".." {
|
||||||
|
return fmt.Errorf("Cannot delete %#v", name)
|
||||||
|
}
|
||||||
|
return os.Remove(entry_path(dir, name))
|
||||||
|
}
|
||||||
|
|
||||||
|
func resolve_start_dir(candidate string) (string, error) {
|
||||||
|
if candidate == "" {
|
||||||
|
cwd, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
candidate = cwd
|
||||||
|
}
|
||||||
|
abs, err := filepath.Abs(candidate)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
info, err := os.Stat(abs)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if !info.IsDir() {
|
||||||
|
abs = filepath.Dir(abs)
|
||||||
|
}
|
||||||
|
return abs, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func truncate_to_width(s string, max_width int) string {
|
||||||
|
if max_width <= 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
if wcswidth.Stringwidth(s) <= max_width {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
runes := []rune(s)
|
||||||
|
for len(runes) > 0 && wcswidth.Stringwidth(string(runes))+1 > max_width {
|
||||||
|
runes = runes[:len(runes)-1]
|
||||||
|
}
|
||||||
|
return string(runes) + "\u2026"
|
||||||
|
}
|
||||||
|
|
||||||
|
type Handler struct {
|
||||||
|
lp *loop.Loop
|
||||||
|
screen_size loop.ScreenSize
|
||||||
|
conf *Config
|
||||||
|
cwd string
|
||||||
|
entries []Entry
|
||||||
|
selected int
|
||||||
|
scroll int
|
||||||
|
show_hidden bool
|
||||||
|
input_purpose input_purpose
|
||||||
|
text_buffer string
|
||||||
|
rename_source string
|
||||||
|
confirm_name string
|
||||||
|
message string
|
||||||
|
result_action string
|
||||||
|
result_path string
|
||||||
|
shortcut_tracker config.ShortcutTracker
|
||||||
|
keyboard_shortcuts []*config.KeyAction
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) initialize() (string, error) {
|
||||||
|
sz, err := h.lp.ScreenSize()
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
h.screen_size = sz
|
||||||
|
h.lp.SetCursorVisible(false)
|
||||||
|
h.lp.AllowLineWrapping(false)
|
||||||
|
h.lp.SetWindowTitle("File manager")
|
||||||
|
if err = h.load(h.cwd); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
h.draw_screen()
|
||||||
|
h.lp.SendOverlayReady()
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// load reads dir and adopts it as the current directory. Selection is clamped
|
||||||
|
// rather than reset so that reloading a directory after an action keeps the
|
||||||
|
// cursor near where it was.
|
||||||
|
func (h *Handler) load(dir string) error {
|
||||||
|
entries, err := read_dir(dir, h.show_hidden, h.conf.Sort_by)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
h.cwd = dir
|
||||||
|
h.entries = entries
|
||||||
|
if h.selected >= len(entries) {
|
||||||
|
h.selected = max(0, len(entries)-1)
|
||||||
|
}
|
||||||
|
if h.scroll > h.selected {
|
||||||
|
h.scroll = h.selected
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) select_name(name string) {
|
||||||
|
if name == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for i, e := range h.entries {
|
||||||
|
if e.Name == name {
|
||||||
|
h.selected = i
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) selected_entry() (Entry, bool) {
|
||||||
|
if h.selected < 0 || h.selected >= len(h.entries) {
|
||||||
|
return Entry{}, false
|
||||||
|
}
|
||||||
|
return h.entries[h.selected], true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) reload() {
|
||||||
|
name := ""
|
||||||
|
if e, ok := h.selected_entry(); ok {
|
||||||
|
name = e.Name
|
||||||
|
}
|
||||||
|
if err := h.load(h.cwd); err != nil {
|
||||||
|
h.message = err.Error()
|
||||||
|
h.draw_screen()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
h.select_name(name)
|
||||||
|
h.message = ""
|
||||||
|
h.draw_screen()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) change_dir(dir string) {
|
||||||
|
if err := h.load(dir); err != nil {
|
||||||
|
h.message = err.Error()
|
||||||
|
h.draw_screen()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
h.selected, h.scroll, h.message = 0, 0, ""
|
||||||
|
h.draw_screen()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) move_selection(delta int) {
|
||||||
|
if len(h.entries) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
h.selected += delta
|
||||||
|
h.selected = max(0, h.selected)
|
||||||
|
h.selected = min(h.selected, len(h.entries)-1)
|
||||||
|
h.draw_screen()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) cancel_input() {
|
||||||
|
h.input_purpose = input_none
|
||||||
|
h.text_buffer = ""
|
||||||
|
h.rename_source = ""
|
||||||
|
h.message = ""
|
||||||
|
h.draw_screen()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) start_input(purpose input_purpose) {
|
||||||
|
h.input_purpose = purpose
|
||||||
|
h.text_buffer = ""
|
||||||
|
h.message = ""
|
||||||
|
h.draw_screen()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) start_rename() {
|
||||||
|
e, ok := h.selected_entry()
|
||||||
|
if !ok {
|
||||||
|
h.lp.Beep()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
h.input_purpose = input_rename
|
||||||
|
h.rename_source = e.Name
|
||||||
|
h.text_buffer = e.Name
|
||||||
|
h.message = ""
|
||||||
|
h.draw_screen()
|
||||||
|
}
|
||||||
|
|
||||||
|
// commit_input applies the pending create/rename operation. The name is
|
||||||
|
// trimmed because a trailing space is almost never intended in a file name.
|
||||||
|
func (h *Handler) commit_input() {
|
||||||
|
name := strings.TrimSpace(h.text_buffer)
|
||||||
|
purpose := h.input_purpose
|
||||||
|
source := h.rename_source
|
||||||
|
h.input_purpose = input_none
|
||||||
|
h.text_buffer = ""
|
||||||
|
h.rename_source = ""
|
||||||
|
var err error
|
||||||
|
var created string
|
||||||
|
switch purpose {
|
||||||
|
case input_create_file:
|
||||||
|
created, err = create_file(h.cwd, name)
|
||||||
|
case input_create_dir:
|
||||||
|
created, err = create_subdir(h.cwd, name)
|
||||||
|
case input_rename:
|
||||||
|
created, err = rename_entry(h.cwd, source, name)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
h.message = err.Error()
|
||||||
|
h.draw_screen()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err = h.load(h.cwd); err != nil {
|
||||||
|
h.message = err.Error()
|
||||||
|
h.draw_screen()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
h.select_name(filepath.Base(created))
|
||||||
|
h.message = ""
|
||||||
|
h.draw_screen()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) start_delete() {
|
||||||
|
e, ok := h.selected_entry()
|
||||||
|
if !ok {
|
||||||
|
h.lp.Beep()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
h.confirm_name = e.Name
|
||||||
|
h.message = ""
|
||||||
|
h.draw_screen()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) perform_delete() {
|
||||||
|
name := h.confirm_name
|
||||||
|
h.confirm_name = ""
|
||||||
|
if err := delete_entry(h.cwd, name); err != nil {
|
||||||
|
h.message = err.Error()
|
||||||
|
h.draw_screen()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := h.load(h.cwd); err != nil {
|
||||||
|
h.message = err.Error()
|
||||||
|
}
|
||||||
|
h.select_name(name)
|
||||||
|
h.message = fmt.Sprintf("Deleted %s", name)
|
||||||
|
h.draw_screen()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) copy_selected_path() {
|
||||||
|
path := h.cwd
|
||||||
|
if e, ok := h.selected_entry(); ok {
|
||||||
|
path = entry_path(h.cwd, e.Name)
|
||||||
|
}
|
||||||
|
h.lp.CopyTextToClipboard(path)
|
||||||
|
h.message = fmt.Sprintf("Copied %s", path)
|
||||||
|
h.draw_screen()
|
||||||
|
}
|
||||||
|
|
||||||
|
// activate implements the primary action: the selected directory is opened in
|
||||||
|
// the panel, the selected file is opened in the editor. Enter used to quit the
|
||||||
|
// panel and cd the shell, which did nothing when the panel was docked.
|
||||||
|
func (h *Handler) activate() {
|
||||||
|
e, ok := h.selected_entry()
|
||||||
|
if !ok {
|
||||||
|
h.lp.Beep()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if e.IsDir {
|
||||||
|
h.enter_dir()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
h.open_file(entry_path(h.cwd, e.Name))
|
||||||
|
}
|
||||||
|
|
||||||
|
// edit_args is the client side of kitty's edit protocol. The terminal opens the
|
||||||
|
// editor in a new tab, which gives the file a whole window even when the panel
|
||||||
|
// is docked. The tab closes when the editor exits and the panel is redrawn in
|
||||||
|
// place, instead of handing the command to the shell and disappearing.
|
||||||
|
func edit_args(path string) []string {
|
||||||
|
return []string{"edit-in-kitty", "--type=tab", path}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) open_file(path string) {
|
||||||
|
exe, err := os.Executable()
|
||||||
|
if err != nil {
|
||||||
|
h.message = err.Error()
|
||||||
|
h.draw_screen()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// The loop must give up the tty while edit-in-kitty talks to the terminal,
|
||||||
|
// otherwise both processes compete for input and escape code responses.
|
||||||
|
err = h.lp.SuspendAndRun(func() error {
|
||||||
|
cmd := exec.Command(exe, edit_args(path)...)
|
||||||
|
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
||||||
|
return cmd.Run()
|
||||||
|
})
|
||||||
|
var ee *exec.ExitError
|
||||||
|
if err != nil && !errors.As(err, &ee) {
|
||||||
|
h.message = err.Error()
|
||||||
|
}
|
||||||
|
// The editor may have changed or removed the file, so refresh the listing.
|
||||||
|
if lerr := h.load(h.cwd); lerr != nil {
|
||||||
|
h.message = lerr.Error()
|
||||||
|
} else {
|
||||||
|
h.select_name(filepath.Base(path))
|
||||||
|
}
|
||||||
|
h.draw_screen()
|
||||||
|
}
|
||||||
|
|
||||||
|
// enter_dir browses into the selected directory inside the panel, leaving the
|
||||||
|
// working directory of the shell untouched.
|
||||||
|
func (h *Handler) enter_dir() {
|
||||||
|
e, ok := h.selected_entry()
|
||||||
|
if !ok || !e.IsDir {
|
||||||
|
h.lp.Beep()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
h.change_dir(entry_path(h.cwd, e.Name))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) change_shell_dir_to(path string) {
|
||||||
|
h.result_action, h.result_path = "cd", path
|
||||||
|
h.lp.Quit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// change_shell_dir ends the kitten with a request to change the directory of
|
||||||
|
// the shell that hosted it, to the selected directory, or to the one being
|
||||||
|
// browsed when a file is selected.
|
||||||
|
func (h *Handler) change_shell_dir() {
|
||||||
|
path := h.cwd
|
||||||
|
if e, ok := h.selected_entry(); ok && e.IsDir {
|
||||||
|
path = entry_path(h.cwd, e.Name)
|
||||||
|
}
|
||||||
|
h.change_shell_dir_to(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) perform_action(name string) {
|
||||||
|
switch name {
|
||||||
|
case "quit":
|
||||||
|
h.lp.Quit(0)
|
||||||
|
case "move_up":
|
||||||
|
h.move_selection(-1)
|
||||||
|
case "move_down":
|
||||||
|
h.move_selection(1)
|
||||||
|
case "page_up":
|
||||||
|
h.move_selection(-max(1, int(h.screen_size.HeightCells)-3))
|
||||||
|
case "page_down":
|
||||||
|
h.move_selection(max(1, int(h.screen_size.HeightCells)-3))
|
||||||
|
case "home":
|
||||||
|
h.selected = 0
|
||||||
|
h.draw_screen()
|
||||||
|
case "end":
|
||||||
|
if len(h.entries) > 0 {
|
||||||
|
h.selected = len(h.entries) - 1
|
||||||
|
}
|
||||||
|
h.draw_screen()
|
||||||
|
case "parent_dir":
|
||||||
|
h.change_dir(parent_of(h.cwd))
|
||||||
|
case "activate":
|
||||||
|
h.activate()
|
||||||
|
case "enter_dir":
|
||||||
|
h.enter_dir()
|
||||||
|
case "cd_here":
|
||||||
|
h.change_shell_dir()
|
||||||
|
case "toggle_hidden":
|
||||||
|
h.show_hidden = !h.show_hidden
|
||||||
|
h.reload()
|
||||||
|
case "create_file":
|
||||||
|
h.start_input(input_create_file)
|
||||||
|
case "create_dir":
|
||||||
|
h.start_input(input_create_dir)
|
||||||
|
case "rename":
|
||||||
|
h.start_rename()
|
||||||
|
case "delete":
|
||||||
|
h.start_delete()
|
||||||
|
case "copy_path":
|
||||||
|
h.copy_selected_path()
|
||||||
|
case "refresh":
|
||||||
|
h.reload()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) handle_input_key(ev *loop.KeyEvent) error {
|
||||||
|
switch {
|
||||||
|
case ev.MatchesPressOrRepeat("escape"):
|
||||||
|
ev.Handled = true
|
||||||
|
h.cancel_input()
|
||||||
|
case ev.MatchesPressOrRepeat("enter"):
|
||||||
|
ev.Handled = true
|
||||||
|
h.commit_input()
|
||||||
|
case ev.MatchesPressOrRepeat("backspace"):
|
||||||
|
ev.Handled = true
|
||||||
|
if h.text_buffer != "" {
|
||||||
|
g := wcswidth.SplitIntoGraphemes(h.text_buffer)
|
||||||
|
h.text_buffer = strings.Join(g[:len(g)-1], "")
|
||||||
|
}
|
||||||
|
h.draw_screen()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) handle_confirm_key(ev *loop.KeyEvent) error {
|
||||||
|
switch {
|
||||||
|
case ev.MatchesPressOrRepeat("escape"):
|
||||||
|
ev.Handled = true
|
||||||
|
h.confirm_name = ""
|
||||||
|
h.draw_screen()
|
||||||
|
case ev.MatchesPressOrRepeat("enter"):
|
||||||
|
ev.Handled = true
|
||||||
|
h.perform_delete()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) on_key_event(ev *loop.KeyEvent) error {
|
||||||
|
if h.input_purpose != input_none {
|
||||||
|
return h.handle_input_key(ev)
|
||||||
|
}
|
||||||
|
if h.confirm_name != "" {
|
||||||
|
return h.handle_confirm_key(ev)
|
||||||
|
}
|
||||||
|
if ac := h.shortcut_tracker.Match(ev, h.keyboard_shortcuts); ac != nil {
|
||||||
|
ev.Handled = true
|
||||||
|
h.perform_action(ac.Name)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
// Fallbacks so the panel stays usable when the user has replaced the
|
||||||
|
// default shortcuts wholesale.
|
||||||
|
switch {
|
||||||
|
case ev.MatchesPressOrRepeat("escape"):
|
||||||
|
ev.Handled = true
|
||||||
|
h.perform_action("quit")
|
||||||
|
case ev.MatchesPressOrRepeat("enter"):
|
||||||
|
ev.Handled = true
|
||||||
|
h.perform_action("activate")
|
||||||
|
case ev.MatchesPressOrRepeat("up"):
|
||||||
|
ev.Handled = true
|
||||||
|
h.perform_action("move_up")
|
||||||
|
case ev.MatchesPressOrRepeat("down"):
|
||||||
|
ev.Handled = true
|
||||||
|
h.perform_action("move_down")
|
||||||
|
case ev.MatchesPressOrRepeat("backspace"):
|
||||||
|
ev.Handled = true
|
||||||
|
h.perform_action("parent_dir")
|
||||||
|
case ev.MatchesPressOrRepeat("right"):
|
||||||
|
ev.Handled = true
|
||||||
|
h.perform_action("enter_dir")
|
||||||
|
case ev.MatchesPressOrRepeat("left"):
|
||||||
|
ev.Handled = true
|
||||||
|
h.perform_action("parent_dir")
|
||||||
|
case ev.MatchesPressOrRepeat("page_up"):
|
||||||
|
ev.Handled = true
|
||||||
|
h.perform_action("page_up")
|
||||||
|
case ev.MatchesPressOrRepeat("page_down"):
|
||||||
|
ev.Handled = true
|
||||||
|
h.perform_action("page_down")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) on_text(text string, from_key_event bool, in_bracketed_paste bool) error {
|
||||||
|
if h.confirm_name != "" {
|
||||||
|
switch strings.ToLower(strings.TrimSpace(text)) {
|
||||||
|
case "y":
|
||||||
|
h.perform_delete()
|
||||||
|
case "n":
|
||||||
|
h.confirm_name = ""
|
||||||
|
h.draw_screen()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if h.input_purpose != input_none {
|
||||||
|
h.text_buffer += text
|
||||||
|
h.draw_screen()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) on_resize(old, new_size loop.ScreenSize) error {
|
||||||
|
h.screen_size = new_size
|
||||||
|
h.draw_screen()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) row_to_entry(cell_y int) int {
|
||||||
|
screen_row := cell_y + 1
|
||||||
|
list_start := 2
|
||||||
|
list_height := int(h.screen_size.HeightCells) - 1 - list_start
|
||||||
|
if screen_row < list_start || screen_row >= list_start+list_height {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
idx := h.scroll + (screen_row - list_start)
|
||||||
|
if idx < 0 || idx >= len(h.entries) {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return idx
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) on_mouse_event(ev *loop.MouseEvent) error {
|
||||||
|
switch ev.Event_type {
|
||||||
|
case loop.MOUSE_CLICK:
|
||||||
|
if ev.Buttons&loop.LEFT_MOUSE_BUTTON != 0 {
|
||||||
|
if idx := h.row_to_entry(ev.Cell.Y); idx >= 0 {
|
||||||
|
h.selected = idx
|
||||||
|
h.draw_screen()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case loop.MOUSE_MOVE:
|
||||||
|
h.lp.ClearPointerShapes()
|
||||||
|
if h.row_to_entry(ev.Cell.Y) >= 0 {
|
||||||
|
h.lp.PushPointerShape(loop.POINTER_POINTER)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) entry_text(e Entry, width int) string {
|
||||||
|
name := e.Name
|
||||||
|
if e.IsDir {
|
||||||
|
name += "/"
|
||||||
|
}
|
||||||
|
return " " + truncate_to_width(name, width-2)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) padded_entry_text(e Entry, width int) string {
|
||||||
|
text := h.entry_text(e, width)
|
||||||
|
if pad := width - wcswidth.Stringwidth(text); pad > 0 {
|
||||||
|
text += strings.Repeat(" ", pad)
|
||||||
|
}
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) input_prompt() string {
|
||||||
|
switch h.input_purpose {
|
||||||
|
case input_create_file:
|
||||||
|
return "New file:"
|
||||||
|
case input_create_dir:
|
||||||
|
return "New directory:"
|
||||||
|
case input_rename:
|
||||||
|
return fmt.Sprintf("Rename %s to:", h.rename_source)
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) status_text() string {
|
||||||
|
if h.message != "" {
|
||||||
|
return " " + truncate_to_width(h.message, max(1, int(h.screen_size.WidthCells)-1))
|
||||||
|
}
|
||||||
|
if len(h.entries) == 0 {
|
||||||
|
return " Empty directory"
|
||||||
|
}
|
||||||
|
e, ok := h.selected_entry()
|
||||||
|
if !ok {
|
||||||
|
return " Empty directory"
|
||||||
|
}
|
||||||
|
kind := "file"
|
||||||
|
if e.IsDir {
|
||||||
|
kind = "directory"
|
||||||
|
}
|
||||||
|
return fmt.Sprintf(" %d/%d - %s - modified %s", h.selected+1, len(h.entries), kind, time.Unix(e.ModTime, 0).Format("2006-01-02 15:04"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) draw_screen() {
|
||||||
|
h.lp.StartAtomicUpdate()
|
||||||
|
defer h.lp.EndAtomicUpdate()
|
||||||
|
h.lp.ClearScreen()
|
||||||
|
|
||||||
|
width := int(h.screen_size.WidthCells)
|
||||||
|
height := int(h.screen_size.HeightCells)
|
||||||
|
if width < 10 || height < 4 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
h.lp.MoveCursorTo(1, 1)
|
||||||
|
h.lp.QueueWriteString(h.lp.SprintStyled("bold fg=bright-green", truncate_to_width(h.cwd, width)))
|
||||||
|
|
||||||
|
list_start := 2
|
||||||
|
status_y := height - 1
|
||||||
|
list_height := status_y - list_start
|
||||||
|
if list_height < 1 {
|
||||||
|
list_height = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(h.entries) > 0 {
|
||||||
|
h.selected = max(0, min(h.selected, len(h.entries)-1))
|
||||||
|
} else {
|
||||||
|
h.selected, h.scroll = 0, 0
|
||||||
|
}
|
||||||
|
if h.selected < h.scroll {
|
||||||
|
h.scroll = h.selected
|
||||||
|
}
|
||||||
|
if h.selected >= h.scroll+list_height {
|
||||||
|
h.scroll = h.selected - list_height + 1
|
||||||
|
}
|
||||||
|
h.scroll = max(0, min(h.scroll, max(0, len(h.entries)-list_height)))
|
||||||
|
|
||||||
|
for row := 0; row < list_height; row++ {
|
||||||
|
idx := h.scroll + row
|
||||||
|
if idx >= len(h.entries) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
e := h.entries[idx]
|
||||||
|
h.lp.MoveCursorTo(1, list_start+row)
|
||||||
|
switch {
|
||||||
|
case idx == h.selected:
|
||||||
|
h.lp.QueueWriteString(h.lp.SprintStyled("reverse", h.padded_entry_text(e, width)))
|
||||||
|
case e.IsDir:
|
||||||
|
h.lp.QueueWriteString(h.lp.SprintStyled("fg=bright-blue", h.entry_text(e, width)))
|
||||||
|
default:
|
||||||
|
h.lp.QueueWriteString(h.entry_text(e, width))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
h.lp.MoveCursorTo(1, status_y)
|
||||||
|
h.lp.QueueWriteString(h.lp.SprintStyled("dim", h.status_text()))
|
||||||
|
|
||||||
|
h.lp.MoveCursorTo(1, height)
|
||||||
|
switch {
|
||||||
|
case h.input_purpose != input_none:
|
||||||
|
prompt := h.input_prompt() + " "
|
||||||
|
h.lp.QueueWriteString(h.lp.SprintStyled("fg=bright-yellow", prompt))
|
||||||
|
h.lp.QueueWriteString(h.text_buffer)
|
||||||
|
h.lp.SetCursorVisible(true)
|
||||||
|
h.lp.MoveCursorTo(1+wcswidth.Stringwidth(prompt+h.text_buffer), height)
|
||||||
|
case h.confirm_name != "":
|
||||||
|
h.lp.SetCursorVisible(false)
|
||||||
|
h.lp.QueueWriteString(h.lp.SprintStyled("bold fg=bright-red", fmt.Sprintf("Delete %s? [y/N] ", h.confirm_name)))
|
||||||
|
default:
|
||||||
|
h.lp.SetCursorVisible(false)
|
||||||
|
hints := "Enter: open ->: enter Ctrl+Enter: cd here <-: up .: hidden n: new file r: rename d: delete y: copy q: quit"
|
||||||
|
h.lp.QueueWriteString(h.lp.SprintStyled("dim", truncate_to_width(hints, width)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// result_payload is the JSON data handed over to the Python result handler.
|
||||||
|
func (h *Handler) result_payload() map[string]string {
|
||||||
|
return map[string]string{"action": h.result_action, "path": h.result_path}
|
||||||
|
}
|
||||||
|
|
||||||
|
func load_config(opts *Options) (*Config, error) {
|
||||||
|
ans := NewConfig()
|
||||||
|
p := config.ConfigParser{LineHandler: ans.Parse}
|
||||||
|
if err := p.LoadConfig("file-manager.conf", opts.Config, opts.Override); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ans, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func main(_ *cli.Command, opts *Options, args []string) (rc int, err error) {
|
||||||
|
conf, err := load_config(opts)
|
||||||
|
if err != nil {
|
||||||
|
return 1, err
|
||||||
|
}
|
||||||
|
candidate := opts.StartDir
|
||||||
|
if len(args) > 0 {
|
||||||
|
candidate = args[0]
|
||||||
|
}
|
||||||
|
start_dir, err := resolve_start_dir(candidate)
|
||||||
|
if err != nil {
|
||||||
|
return 1, err
|
||||||
|
}
|
||||||
|
lp, err := loop.New()
|
||||||
|
if err != nil {
|
||||||
|
return 1, err
|
||||||
|
}
|
||||||
|
h := &Handler{lp: lp, conf: conf, cwd: start_dir, show_hidden: opts.ShowHidden || conf.Show_hidden}
|
||||||
|
h.keyboard_shortcuts = config.ResolveShortcuts(conf.KeyboardShortcuts)
|
||||||
|
lp.MouseTrackingMode(loop.FULL_MOUSE_TRACKING)
|
||||||
|
|
||||||
|
lp.OnInitialize = func() (string, error) { return h.initialize() }
|
||||||
|
lp.OnFinalize = func() string { return "" }
|
||||||
|
lp.OnKeyEvent = h.on_key_event
|
||||||
|
lp.OnText = h.on_text
|
||||||
|
lp.OnResize = h.on_resize
|
||||||
|
lp.OnMouseEvent = h.on_mouse_event
|
||||||
|
|
||||||
|
if err = lp.Run(); err != nil {
|
||||||
|
return 1, err
|
||||||
|
}
|
||||||
|
if ds := lp.DeathSignalName(); ds != "" {
|
||||||
|
fmt.Println("Killed by signal:", ds)
|
||||||
|
lp.KillIfSignalled()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
rc = lp.ExitCode()
|
||||||
|
if h.result_action != "" {
|
||||||
|
output := tui.KittenOutputSerializer()
|
||||||
|
if s, serr := output(h.result_payload()); serr == nil {
|
||||||
|
fmt.Println(s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func EntryPoint(parent *cli.Command) {
|
||||||
|
create_cmd(parent, main)
|
||||||
|
}
|
||||||
@@ -0,0 +1,218 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# License: GPL v3 Copyright: 2026, FWS
|
||||||
|
|
||||||
|
import shlex
|
||||||
|
import sys
|
||||||
|
from functools import partial
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from kitty.conf.types import Definition
|
||||||
|
from kitty.constants import appname
|
||||||
|
from kitty.simple_cli_definitions import CONFIG_HELP, CompletionSpec
|
||||||
|
from kitty.typing_compat import BossType
|
||||||
|
|
||||||
|
from ..tui.handler import result_handler
|
||||||
|
|
||||||
|
definition = Definition(
|
||||||
|
'!kittens.file_manager',
|
||||||
|
)
|
||||||
|
|
||||||
|
agr = definition.add_group
|
||||||
|
egr = definition.end_group
|
||||||
|
opt = definition.add_option
|
||||||
|
map = definition.add_map
|
||||||
|
|
||||||
|
agr('appearance', 'Appearance')
|
||||||
|
|
||||||
|
opt(
|
||||||
|
'show_hidden',
|
||||||
|
'no',
|
||||||
|
option_type='to_bool',
|
||||||
|
long_text="""
|
||||||
|
Show entries whose name starts with a full stop when the panel opens. The setting
|
||||||
|
can be toggled at runtime with the :ref:`toggle_hidden <file-manager-shortcuts>`
|
||||||
|
shortcut.
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
|
||||||
|
opt(
|
||||||
|
'sort_by',
|
||||||
|
'name',
|
||||||
|
long_text="""
|
||||||
|
How to order entries. :code:`name` lists directories first, then files, both
|
||||||
|
sorted by name ignoring case. :code:`mtime` lists directories first, then files
|
||||||
|
sorted by last modification time, most recent first.
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
|
||||||
|
egr()
|
||||||
|
|
||||||
|
agr('opening', 'Opening files')
|
||||||
|
|
||||||
|
opt(
|
||||||
|
'editor',
|
||||||
|
'',
|
||||||
|
long_text="""
|
||||||
|
Deprecated and ignored. Files are opened through kitty's edit protocol, so the
|
||||||
|
editor is the :opt:`editor` option of :file:`kitty.conf`, with :envvar:`VISUAL`
|
||||||
|
then :envvar:`EDITOR` used when it is :code:`.` (the default). The option is
|
||||||
|
still accepted so that existing configuration files keep loading.
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
|
||||||
|
opt(
|
||||||
|
'open_with_sudo',
|
||||||
|
'no',
|
||||||
|
option_type='to_bool',
|
||||||
|
long_text="""
|
||||||
|
Deprecated and ignored. kitty's edit protocol sends the file back when the
|
||||||
|
editor exits and therefore needs a file the user can write to. Open privileged
|
||||||
|
files with :code:`sudo -e` from the shell instead.
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
|
||||||
|
egr()
|
||||||
|
|
||||||
|
agr('shortcuts', 'Keyboard shortcuts')
|
||||||
|
|
||||||
|
map('Quit without changing directory', 'quit q quit')
|
||||||
|
map('Quit without changing directory', 'quit esc quit')
|
||||||
|
map('Move selection up', 'move_up up move_up')
|
||||||
|
map('Move selection up', 'move_up --allow-fallback=shifted,ascii k move_up')
|
||||||
|
map('Move selection down', 'move_down down move_down')
|
||||||
|
map('Move selection down', 'move_down --allow-fallback=shifted,ascii j move_down')
|
||||||
|
map('Move selection up by a page', 'page_up page_up page_up')
|
||||||
|
map('Move selection up by a page', 'page_up --allow-fallback=shifted,ascii ctrl+b page_up')
|
||||||
|
map('Move selection down by a page', 'page_down page_down page_down')
|
||||||
|
map('Move selection down by a page', 'page_down --allow-fallback=shifted,ascii ctrl+f page_down')
|
||||||
|
map('Select first entry', 'home home home')
|
||||||
|
map('Select first entry', 'home --allow-fallback=shifted,ascii g home')
|
||||||
|
map('Select last entry', 'end end end')
|
||||||
|
map('Select last entry', 'end shift+g end')
|
||||||
|
map(
|
||||||
|
'Open the selection',
|
||||||
|
'activate enter activate',
|
||||||
|
long_text="""
|
||||||
|
When the selection is a directory it is opened in the panel, exactly like the
|
||||||
|
:ref:`enter_dir <file-manager-shortcuts>` shortcut. When it is a file, the panel
|
||||||
|
opens it in kitty's editor (:opt:`editor`, :envvar:`VISUAL` or
|
||||||
|
:envvar:`EDITOR`) in a new tab, and is drawn again with the same selection once
|
||||||
|
the editor exits. The new tab is what gives the file a whole window even when
|
||||||
|
the panel runs in a dock.
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
map(
|
||||||
|
'Browse into the selected directory',
|
||||||
|
'enter_dir right enter_dir',
|
||||||
|
long_text="""
|
||||||
|
Move the panel into the selected directory without changing the shell's working
|
||||||
|
directory. Use the :ref:`cd_here <file-manager-shortcuts>` shortcut to also
|
||||||
|
change the shell's directory.
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
map('Browse into the selected directory', 'enter_dir --allow-fallback=shifted,ascii l enter_dir')
|
||||||
|
map('Browse into the parent directory', 'parent_dir left parent_dir')
|
||||||
|
map('Browse into the parent directory', 'parent_dir backspace parent_dir')
|
||||||
|
map('Browse into the parent directory', 'parent_dir --allow-fallback=shifted,ascii h parent_dir')
|
||||||
|
map(
|
||||||
|
'Change shell directory to the directory being browsed',
|
||||||
|
'cd_here ctrl+enter cd_here',
|
||||||
|
long_text="""
|
||||||
|
Changes the shell's working directory to the directory currently shown in the
|
||||||
|
panel, regardless of the selection.
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
map('Change shell directory to the directory being browsed', 'cd_here --allow-fallback=shifted,ascii c cd_here')
|
||||||
|
map('Toggle display of hidden entries', 'toggle_hidden --allow-fallback=shifted,ascii . toggle_hidden')
|
||||||
|
map('Create a new file', 'create_file --allow-fallback=shifted,ascii n create_file')
|
||||||
|
map('Create a new directory', 'create_dir shift+n create_dir')
|
||||||
|
map('Rename the selected entry', 'rename --allow-fallback=shifted,ascii r rename')
|
||||||
|
map(
|
||||||
|
'Delete the selected entry',
|
||||||
|
'delete --allow-fallback=shifted,ascii d delete',
|
||||||
|
long_text="""
|
||||||
|
Deletes a file, a symbolic link or an empty directory after asking for
|
||||||
|
confirmation. Directories are never deleted recursively.
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
map('Copy the path of the selection to the clipboard', 'copy_path --allow-fallback=shifted,ascii y copy_path')
|
||||||
|
map('Reload the current directory', 'refresh --allow-fallback=shifted,ascii ctrl+r refresh')
|
||||||
|
|
||||||
|
egr()
|
||||||
|
|
||||||
|
OPTIONS = partial(
|
||||||
|
"""\
|
||||||
|
--start-dir
|
||||||
|
Directory to start browsing in. Defaults to the current working directory.
|
||||||
|
|
||||||
|
|
||||||
|
--show-hidden
|
||||||
|
type=bool-set
|
||||||
|
Show hidden files when the panel opens.
|
||||||
|
|
||||||
|
|
||||||
|
--open-here
|
||||||
|
type=bool-set
|
||||||
|
Deprecated and ignored. Files are always opened in a new tab, so this flag is
|
||||||
|
only accepted so that existing mappings keep working.
|
||||||
|
|
||||||
|
|
||||||
|
--config -c
|
||||||
|
type=list
|
||||||
|
completion=type:file ext:conf group:"Config files" kwds:none,NONE
|
||||||
|
{config_help}
|
||||||
|
|
||||||
|
|
||||||
|
--override -o
|
||||||
|
type=list
|
||||||
|
Override individual configuration options, can be specified multiple times.
|
||||||
|
Syntax: :italic:`name=value`. For example: :italic:`-o show_hidden=yes`
|
||||||
|
|
||||||
|
""".format,
|
||||||
|
config_help=CONFIG_HELP.format(conf_name='file-manager', appname=appname),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def main(args: list[str]) -> None:
|
||||||
|
raise SystemExit('This kitten must be run from a kitty.conf mapping')
|
||||||
|
|
||||||
|
|
||||||
|
def change_directory(w: Any, path: str) -> None:
|
||||||
|
# Writing to the pty, unlike pasting, makes the shell run the command. When
|
||||||
|
# the shell is busy, only paste the text so that it can be edited instead of
|
||||||
|
# feeding it into whatever program is running.
|
||||||
|
cmd = 'cd ' + shlex.quote(path)
|
||||||
|
if w.at_prompt:
|
||||||
|
w.write_to_child(cmd + '\r')
|
||||||
|
else:
|
||||||
|
w.paste_text(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
@result_handler(has_ready_notification=True)
|
||||||
|
def handle_result(args: list[str], data: dict[str, Any], target_window_id: int, boss: BossType) -> None:
|
||||||
|
if not data:
|
||||||
|
return
|
||||||
|
action, path = data.get('action'), data.get('path')
|
||||||
|
if action != 'cd' or not path:
|
||||||
|
return
|
||||||
|
w = boss.window_id_map.get(target_window_id)
|
||||||
|
if w is None:
|
||||||
|
boss.ring_bell_if_allowed()
|
||||||
|
return
|
||||||
|
change_directory(w, path)
|
||||||
|
|
||||||
|
|
||||||
|
help_text = 'Browse directories in a side panel and change the working directory of the shell without leaving it'
|
||||||
|
usage = '[directory]'
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main(sys.argv)
|
||||||
|
elif __name__ == '__doc__':
|
||||||
|
cd = sys.cli_docs # type: ignore
|
||||||
|
cd['usage'] = usage
|
||||||
|
cd['options'] = OPTIONS
|
||||||
|
cd['help_text'] = help_text
|
||||||
|
cd['short_desc'] = 'Browse directories and change the shell directory'
|
||||||
|
cd['args_completion'] = CompletionSpec.from_string('type:directory')
|
||||||
|
elif __name__ == '__conf__':
|
||||||
|
sys.options_definition = definition # type: ignore
|
||||||
@@ -0,0 +1,223 @@
|
|||||||
|
// License: GPLv3 Copyright: 2026, FWS
|
||||||
|
|
||||||
|
package file_manager
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSortEntriesDirectoriesFirstThenByName(t *testing.T) {
|
||||||
|
entries := []Entry{
|
||||||
|
{Name: "zebra.txt"},
|
||||||
|
{Name: "alpha.txt"},
|
||||||
|
{Name: "Beta.txt"},
|
||||||
|
{Name: "zdir", IsDir: true},
|
||||||
|
{Name: "adir", IsDir: true},
|
||||||
|
}
|
||||||
|
sort_entries(entries, "name")
|
||||||
|
expected := []string{"adir", "zdir", "alpha.txt", "Beta.txt", "zebra.txt"}
|
||||||
|
for i, name := range expected {
|
||||||
|
if entries[i].Name != name {
|
||||||
|
t.Fatalf("wrong order at %d: wanted %s got %s", i, name, entries[i].Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSortEntriesByModificationTime(t *testing.T) {
|
||||||
|
entries := []Entry{
|
||||||
|
{Name: "old.txt", ModTime: 10},
|
||||||
|
{Name: "new.txt", ModTime: 30},
|
||||||
|
{Name: "mid.txt", ModTime: 20},
|
||||||
|
{Name: "dir", IsDir: true, ModTime: 1},
|
||||||
|
}
|
||||||
|
sort_entries(entries, "mtime")
|
||||||
|
expected := []string{"dir", "new.txt", "mid.txt", "old.txt"}
|
||||||
|
for i, name := range expected {
|
||||||
|
if entries[i].Name != name {
|
||||||
|
t.Fatalf("wrong order at %d: wanted %s got %s", i, name, entries[i].Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadDirSkipsHiddenFilesUnlessRequested(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
for _, name := range []string{"visible.txt", ".hidden.txt"} {
|
||||||
|
if err := os.WriteFile(filepath.Join(dir, name), nil, 0o644); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := os.Mkdir(filepath.Join(dir, "sub"), 0o755); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
entries, err := read_dir(dir, false, "name")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(entries) != 2 {
|
||||||
|
t.Fatalf("wanted 2 entries, got %d: %#v", len(entries), entries)
|
||||||
|
}
|
||||||
|
if !entries[0].IsDir || entries[0].Name != "sub" {
|
||||||
|
t.Fatalf("directories must be listed first, got %#v", entries[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
entries, err = read_dir(dir, true, "name")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(entries) != 3 {
|
||||||
|
t.Fatalf("wanted 3 entries with hidden files shown, got %d", len(entries))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadDirReportsErrors(t *testing.T) {
|
||||||
|
if _, err := read_dir(filepath.Join(t.TempDir(), "does-not-exist"), false, "name"); err == nil {
|
||||||
|
t.Fatal("reading a missing directory must fail")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidateEntryName(t *testing.T) {
|
||||||
|
for _, name := range []string{"", ".", "..", "a/b", "a\x00b"} {
|
||||||
|
if err := validate_entry_name(name); err == nil {
|
||||||
|
t.Fatalf("%q must be rejected", name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, name := range []string{"file.txt", "with space", "..hidden"} {
|
||||||
|
if err := validate_entry_name(name); err != nil {
|
||||||
|
t.Fatalf("%q must be accepted, got %v", name, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestParentOf(t *testing.T) {
|
||||||
|
cases := map[string]string{
|
||||||
|
"/": "/",
|
||||||
|
"/tmp": "/",
|
||||||
|
"/tmp/a/b": "/tmp/a",
|
||||||
|
"/tmp/a/b/": "/tmp/a/b",
|
||||||
|
}
|
||||||
|
for input, expected := range cases {
|
||||||
|
if got := parent_of(input); got != expected {
|
||||||
|
t.Fatalf("parent_of(%q) = %q, wanted %q", input, got, expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCreateRenameAndDelete(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
path, err := create_file(dir, "a.txt")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if _, err = os.Stat(path); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if _, err = create_file(dir, "a.txt"); err == nil {
|
||||||
|
t.Fatal("creating an existing file must fail")
|
||||||
|
}
|
||||||
|
if _, err = create_subdir(dir, "sub"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
renamed, err := rename_entry(dir, "a.txt", "b.txt")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if filepath.Base(renamed) != "b.txt" {
|
||||||
|
t.Fatalf("unexpected rename destination %q", renamed)
|
||||||
|
}
|
||||||
|
if _, err = os.Stat(filepath.Join(dir, "a.txt")); err == nil {
|
||||||
|
t.Fatal("the old name must no longer exist")
|
||||||
|
}
|
||||||
|
if _, err = rename_entry(dir, "b.txt", "sub"); err == nil {
|
||||||
|
t.Fatal("renaming over an existing entry must fail")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = delete_entry(dir, "b.txt"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if _, err = os.Stat(filepath.Join(dir, "b.txt")); err == nil {
|
||||||
|
t.Fatal("the deleted file must no longer exist")
|
||||||
|
}
|
||||||
|
if err = delete_entry(dir, ".."); err == nil {
|
||||||
|
t.Fatal("deleting the parent directory must be refused")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestResolveStartDirAcceptsFiles(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
file := filepath.Join(dir, "file.txt")
|
||||||
|
if err := os.WriteFile(file, nil, 0o644); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
got, err := resolve_start_dir(file)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if got != dir {
|
||||||
|
t.Fatalf("starting from a file must use its directory, got %q wanted %q", got, dir)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenWithSudoOption(t *testing.T) {
|
||||||
|
c := NewConfig()
|
||||||
|
if c.Open_with_sudo {
|
||||||
|
t.Fatal("files must not be opened with sudo by default")
|
||||||
|
}
|
||||||
|
if err := c.Parse("open_with_sudo", "yes"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if !c.Open_with_sudo {
|
||||||
|
t.Fatal("open_with_sudo = yes must enable sudo")
|
||||||
|
}
|
||||||
|
if err := c.Parse("open_with_sudo", "no"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if c.Open_with_sudo {
|
||||||
|
t.Fatal("open_with_sudo = no must disable sudo")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestEditArgs(t *testing.T) {
|
||||||
|
got := edit_args("/tmp/a.py")
|
||||||
|
want := []string{"edit-in-kitty", "--type=tab", "/tmp/a.py"}
|
||||||
|
if len(got) != len(want) {
|
||||||
|
t.Fatalf("expected %#v, got %#v", want, got)
|
||||||
|
}
|
||||||
|
for i := range want {
|
||||||
|
if got[i] != want[i] {
|
||||||
|
t.Fatalf("expected %#v, got %#v", want, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLoadConfigReadsOpenWithSudo(t *testing.T) {
|
||||||
|
// The option is ignored now, but old configuration files must keep loading.
|
||||||
|
dir := t.TempDir()
|
||||||
|
path := filepath.Join(dir, "file-manager.conf")
|
||||||
|
if err := os.WriteFile(path, []byte("open_with_sudo yes\neditor nano\n"), 0o644); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if _, err := load_config(&Options{Config: []string{path}}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestResultPayload(t *testing.T) {
|
||||||
|
h := &Handler{result_action: "cd", result_path: "/tmp"}
|
||||||
|
got := h.result_payload()
|
||||||
|
if len(got) != 2 || got["action"] != "cd" || got["path"] != "/tmp" {
|
||||||
|
t.Fatalf("unexpected payload: %#v", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTruncateToWidth(t *testing.T) {
|
||||||
|
if got := truncate_to_width("abcdef", 3); got != "ab\u2026" {
|
||||||
|
t.Fatalf("unexpected truncation %q", got)
|
||||||
|
}
|
||||||
|
if got := truncate_to_width("abc", 10); got != "abc" {
|
||||||
|
t.Fatalf("short text must not be truncated, got %q", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
+24
-11
@@ -2318,18 +2318,18 @@ The alignment of the tab bar, can be one of: :code:`start`, :code:`center`,
|
|||||||
|
|
||||||
opt(
|
opt(
|
||||||
'tab_bar_show_new_tab_button',
|
'tab_bar_show_new_tab_button',
|
||||||
'no',
|
'yes',
|
||||||
option_type='to_bool',
|
option_type='to_bool',
|
||||||
long_text="""
|
long_text="""
|
||||||
When set to :code:`yes`, a :code:`+` button is always shown at the end of the
|
When set to :code:`yes` (the default), a :code:`+` button is always shown at
|
||||||
tab bar as a clickable shortcut to open a new tab. When set to :code:`no`
|
the end of the tab bar as a clickable shortcut to open a new tab. When set to
|
||||||
(the default), the button is hidden at rest but still appears temporarily
|
:code:`no`, the button is hidden at rest but still appears temporarily while a
|
||||||
while a window is being dragged, so it can be used as a drop target to open
|
window is being dragged, so it can be used as a drop target to open the window
|
||||||
the window in a new tab.
|
in a new tab.
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
|
|
||||||
opt('tab_bar_min_tabs', '2', option_type='tab_bar_min_tabs', long_text='The minimum number of tabs that must exist before the tab bar is shown.')
|
opt('tab_bar_min_tabs', '1', option_type='tab_bar_min_tabs', long_text='The minimum number of tabs that must exist before the tab bar is shown.')
|
||||||
|
|
||||||
opt(
|
opt(
|
||||||
'tab_switch_strategy',
|
'tab_switch_strategy',
|
||||||
@@ -2450,7 +2450,7 @@ lines is wrapped independently.
|
|||||||
|
|
||||||
opt(
|
opt(
|
||||||
'tab_title_template',
|
'tab_title_template',
|
||||||
'"{fmt.fg.red}{bell_symbol}{activity_symbol}{secure_input_symbol}{fmt.fg.tab}{tab.last_focused_progress_percent}{title}"',
|
'"{fmt.fg.red}{bell_symbol}{activity_symbol}{exit_status_symbol}{secure_input_symbol}{fmt.fg.tab}{tab.last_focused_progress_percent}{title}"',
|
||||||
option_type='tab_title_template',
|
option_type='tab_title_template',
|
||||||
long_text="""
|
long_text="""
|
||||||
A template to render the tab title. The default just renders the title with
|
A template to render the tab title. The default just renders the title with
|
||||||
@@ -2473,12 +2473,25 @@ use :code:`{sup.index}`. All data available is:
|
|||||||
The number of windows in the tab.
|
The number of windows in the tab.
|
||||||
:code:`num_window_groups`
|
:code:`num_window_groups`
|
||||||
The number of window groups (a window group is a window and all of its overlay windows) in the tab.
|
The number of window groups (a window group is a window and all of its overlay windows) in the tab.
|
||||||
|
:code:`last_exit_code`
|
||||||
|
The exit status of the last command that finished in the active window of
|
||||||
|
the tab, or the empty string if it succeeded or no command has finished.
|
||||||
|
Requires :ref:`shell integration <shell_integration>`.
|
||||||
|
:code:`exit_status_symbol`
|
||||||
|
A cross followed by :code:`last_exit_code` when the last command failed,
|
||||||
|
empty otherwise. Requires :ref:`shell integration <shell_integration>`.
|
||||||
:code:`secure_input_symbol`
|
:code:`secure_input_symbol`
|
||||||
A key symbol when secure input is enabled on macOS and the tab is the active tab, empty otherwise.
|
A key symbol when secure input is enabled on macOS and the tab is the active tab, empty otherwise.
|
||||||
:code:`tab.active_wd`
|
:code:`tab.active_wd`
|
||||||
The working directory of the currently active window in the tab
|
The working directory of the currently active window in the tab
|
||||||
(expensive, requires syscall). Use :code:`tab.active_oldest_wd` to get
|
(expensive, requires syscall). Use :code:`tab.active_oldest_wd` to get
|
||||||
the directory of the oldest foreground process rather than the newest.
|
the directory of the oldest foreground process rather than the newest.
|
||||||
|
:code:`tab.active_wd_abbreviated`
|
||||||
|
A compact form of :code:`tab.active_wd` suited to a tab title: the home
|
||||||
|
directory is shown as ``~``, intermediate directories are reduced to
|
||||||
|
their first letter and, when the result is still too long, middle
|
||||||
|
directories are replaced by an ellipsis. For example
|
||||||
|
``~/p/fws-kitty``. Has the same cost as :code:`tab.active_wd`.
|
||||||
:code:`tab.active_exe`
|
:code:`tab.active_exe`
|
||||||
The name of the executable running in the foreground of the currently
|
The name of the executable running in the foreground of the currently
|
||||||
active window in the tab (expensive, requires syscall). Use
|
active window in the tab (expensive, requires syscall). Use
|
||||||
@@ -2518,9 +2531,9 @@ use styling directives, for example:
|
|||||||
Similarly, for bold and italic:
|
Similarly, for bold and italic:
|
||||||
``{fmt.bold}bold{fmt.nobold}normal{fmt.italic}italic{fmt.noitalic}``.
|
``{fmt.bold}bold{fmt.nobold}normal{fmt.italic}italic{fmt.noitalic}``.
|
||||||
The 256 eight terminal colors can be used as ``fmt.fg.color0`` through ``fmt.fg.color255``.
|
The 256 eight terminal colors can be used as ``fmt.fg.color0`` through ``fmt.fg.color255``.
|
||||||
Note that for backward compatibility, if :code:`{bell_symbol}` or
|
Note that for backward compatibility, if :code:`{bell_symbol}`,
|
||||||
:code:`{activity_symbol}` are not present in the template, they are prepended to
|
:code:`{activity_symbol}` or :code:`{exit_status_symbol}` are not present in
|
||||||
it.
|
the template, they are prepended to it.
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Generated
+3
-3
@@ -695,8 +695,8 @@ class Options:
|
|||||||
tab_bar_margin_color: kitty.fast_data_types.Color | None = None
|
tab_bar_margin_color: kitty.fast_data_types.Color | None = None
|
||||||
tab_bar_margin_height: TabBarMarginHeight = TabBarMarginHeight(outer=0, inner=0)
|
tab_bar_margin_height: TabBarMarginHeight = TabBarMarginHeight(outer=0, inner=0)
|
||||||
tab_bar_margin_width: float = 0
|
tab_bar_margin_width: float = 0
|
||||||
tab_bar_min_tabs: int = 2
|
tab_bar_min_tabs: int = 1
|
||||||
tab_bar_show_new_tab_button: bool = False
|
tab_bar_show_new_tab_button: bool = True
|
||||||
tab_bar_style: choices_for_tab_bar_style = 'fade'
|
tab_bar_style: choices_for_tab_bar_style = 'fade'
|
||||||
tab_fade: tuple[float, ...] = (0.25, 0.5, 0.75, 1.0)
|
tab_fade: tuple[float, ...] = (0.25, 0.5, 0.75, 1.0)
|
||||||
tab_powerline_style: choices_for_tab_powerline_style = 'angled'
|
tab_powerline_style: choices_for_tab_powerline_style = 'angled'
|
||||||
@@ -704,7 +704,7 @@ class Options:
|
|||||||
tab_switch_strategy: choices_for_tab_switch_strategy = 'previous'
|
tab_switch_strategy: choices_for_tab_switch_strategy = 'previous'
|
||||||
tab_title_max_length: int = 0
|
tab_title_max_length: int = 0
|
||||||
tab_title_max_lines: int = 1
|
tab_title_max_lines: int = 1
|
||||||
tab_title_template: str = '{fmt.fg.red}{bell_symbol}{activity_symbol}{secure_input_symbol}{fmt.fg.tab}{tab.last_focused_progress_percent}{title}'
|
tab_title_template: str = '{fmt.fg.red}{bell_symbol}{activity_symbol}{exit_status_symbol}{secure_input_symbol}{fmt.fg.tab}{tab.last_focused_progress_percent}{title}'
|
||||||
tab_title_wrap: int = 0
|
tab_title_wrap: int = 0
|
||||||
term: str = 'xterm-kitty'
|
term: str = 'xterm-kitty'
|
||||||
terminfo_type: choices_for_terminfo_type = 'path'
|
terminfo_type: choices_for_terminfo_type = 'path'
|
||||||
|
|||||||
+101
-3
@@ -260,6 +260,17 @@ class TabAccessor:
|
|||||||
tab = get_boss().tab_for_id(self.tab_id)
|
tab = get_boss().tab_for_id(self.tab_id)
|
||||||
return os.path.basename((tab.get_exe_of_active_window(oldest=True) if tab else '') or '')
|
return os.path.basename((tab.get_exe_of_active_window(oldest=True) if tab else '') or '')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def active_wd_abbreviated(self) -> str:
|
||||||
|
tab = get_boss().tab_for_id(self.tab_id)
|
||||||
|
return abbreviate_path((tab.get_cwd_of_active_window() if tab else '') or '')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def last_cmd_exit_status(self) -> int:
|
||||||
|
tab = get_boss().tab_for_id(self.tab_id)
|
||||||
|
w = tab.active_window if tab else None
|
||||||
|
return w.last_cmd_exit_status if w else 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def last_focused_progress_percent(self) -> str:
|
def last_focused_progress_percent(self) -> str:
|
||||||
tab = get_boss().tab_for_id(self.tab_id)
|
tab = get_boss().tab_for_id(self.tab_id)
|
||||||
@@ -337,6 +348,10 @@ def template_uses_max_title_length(template: str) -> bool:
|
|||||||
# Not across updates, as templates can use state not in TabBarData, such as
|
# Not across updates, as templates can use state not in TabBarData, such as
|
||||||
# the progress of the windows in the tab.
|
# the progress of the windows in the tab.
|
||||||
title_cache: dict[tuple[DrawData, TabBarData, int, int], str] | None = None
|
title_cache: dict[tuple[DrawData, TabBarData, int, int], str] | None = None
|
||||||
|
# Cells occupied by the close buttons drawn in the last layout pass, mapped to
|
||||||
|
# the id of the tab they close. None while titles are being measured, so that
|
||||||
|
# only the cells of the final drawing are kept.
|
||||||
|
close_button_cells: dict[tuple[int, int], int] | None = None
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
@@ -384,6 +399,7 @@ def evaluate_title_template(draw_data: DrawData, tab: TabBarData, index: int, ma
|
|||||||
ColorFormatter.draw_data = draw_data
|
ColorFormatter.draw_data = draw_data
|
||||||
ColorFormatter.tab_data = tab
|
ColorFormatter.tab_data = tab
|
||||||
boss = get_boss()
|
boss = get_boss()
|
||||||
|
last_cmd_exit_status = ta.last_cmd_exit_status
|
||||||
eval_locals = {
|
eval_locals = {
|
||||||
'index': index,
|
'index': index,
|
||||||
'layout_name': tab.layout_name,
|
'layout_name': tab.layout_name,
|
||||||
@@ -400,6 +416,8 @@ def evaluate_title_template(draw_data: DrawData, tab: TabBarData, index: int, ma
|
|||||||
'bell_symbol': draw_data.bell_on_tab if tab.needs_attention else '',
|
'bell_symbol': draw_data.bell_on_tab if tab.needs_attention else '',
|
||||||
'secure_input_symbol': si,
|
'secure_input_symbol': si,
|
||||||
'activity_symbol': draw_data.tab_activity_symbol if tab.has_activity_since_last_focus else '',
|
'activity_symbol': draw_data.tab_activity_symbol if tab.has_activity_since_last_focus else '',
|
||||||
|
'last_exit_code': str(last_cmd_exit_status) if last_cmd_exit_status else '',
|
||||||
|
'exit_status_symbol': exit_status_indicator(last_cmd_exit_status),
|
||||||
'max_title_length': max_title_length,
|
'max_title_length': max_title_length,
|
||||||
'keyboard_mode': boss.mappings.current_keyboard_mode_name,
|
'keyboard_mode': boss.mappings.current_keyboard_mode_name,
|
||||||
}
|
}
|
||||||
@@ -407,7 +425,7 @@ def evaluate_title_template(draw_data: DrawData, tab: TabBarData, index: int, ma
|
|||||||
if tab.is_active and draw_data.active_title_template is not None:
|
if tab.is_active and draw_data.active_title_template is not None:
|
||||||
template = draw_data.active_title_template
|
template = draw_data.active_title_template
|
||||||
prefix = ''
|
prefix = ''
|
||||||
for default_prefix in ('bell_symbol', 'activity_symbol', 'secure_input_symbol'):
|
for default_prefix in ('bell_symbol', 'activity_symbol', 'exit_status_symbol', 'secure_input_symbol'):
|
||||||
if eval_locals[default_prefix] and not template_has_field(template, default_prefix):
|
if eval_locals[default_prefix] and not template_has_field(template, default_prefix):
|
||||||
prefix += '{' + default_prefix + '}'
|
prefix += '{' + default_prefix + '}'
|
||||||
if prefix:
|
if prefix:
|
||||||
@@ -498,8 +516,65 @@ def truncate_line(line: str, width: int) -> str:
|
|||||||
return out + '…'
|
return out + '…'
|
||||||
|
|
||||||
|
|
||||||
|
def exit_status_indicator(exit_status: int) -> str:
|
||||||
|
"""A short indicator for the exit status of the last command, empty on success."""
|
||||||
|
return f'✘ {exit_status} ' if exit_status else ''
|
||||||
|
|
||||||
|
|
||||||
|
def abbreviate_path(path: str, home: str | None = None, max_length: int = 0) -> str:
|
||||||
|
"""Return a compact representation of path for use in a tab title.
|
||||||
|
|
||||||
|
The home directory is shown as ``~`` and the directories between it and
|
||||||
|
the last component are reduced to their first character, so
|
||||||
|
``~/projects/fws-kitty`` becomes ``~/p/fws-kitty``. When max_length is
|
||||||
|
positive and the result is wider, the middle directories are replaced by
|
||||||
|
an ellipsis, keeping the last component, which is the most informative
|
||||||
|
part. Widths are measured in terminal cells.
|
||||||
|
"""
|
||||||
|
if not path:
|
||||||
|
return ''
|
||||||
|
home = os.path.normpath(home or os.path.expanduser('~'))
|
||||||
|
p = os.path.normpath(path)
|
||||||
|
if home and (p == home or p.startswith(home + os.sep)):
|
||||||
|
prefix, rest = '~', p[len(home) :]
|
||||||
|
elif p.startswith(os.sep):
|
||||||
|
prefix, rest = os.sep, p
|
||||||
|
else:
|
||||||
|
prefix, rest = '', p
|
||||||
|
components = [c for c in rest.split(os.sep) if c]
|
||||||
|
if not components:
|
||||||
|
return prefix or os.sep
|
||||||
|
|
||||||
|
def join(parts: Sequence[str]) -> str:
|
||||||
|
if prefix == os.sep:
|
||||||
|
return os.sep + os.sep.join(parts)
|
||||||
|
if prefix == '~':
|
||||||
|
return '~' + (os.sep + os.sep.join(parts) if parts else '')
|
||||||
|
return os.sep.join(parts)
|
||||||
|
|
||||||
|
ans = join([c[0] for c in components[:-1]] + [components[-1]])
|
||||||
|
if max_length > 0 and wcswidth(ans) > max_length:
|
||||||
|
last = components[-1]
|
||||||
|
marker = prefix + os.sep + '…' if prefix else '…'
|
||||||
|
for candidate in (marker + os.sep + last, '…' + os.sep + last if prefix else last):
|
||||||
|
if wcswidth(candidate) <= max_length:
|
||||||
|
return candidate
|
||||||
|
# Even the last component alone is too wide, keep its end as that is
|
||||||
|
# the part that distinguishes it from its siblings.
|
||||||
|
available = max_length - wcswidth(marker) - 1
|
||||||
|
if available > 0:
|
||||||
|
return marker + os.sep + truncate_line(last, available)
|
||||||
|
return truncate_line(ans, max_length)
|
||||||
|
return ans
|
||||||
|
|
||||||
|
|
||||||
def draw_title(draw_data: DrawData, screen: Screen, tab: TabBarData, index: int, max_title_length: int = 0) -> None:
|
def draw_title(draw_data: DrawData, screen: Screen, tab: TabBarData, index: int, max_title_length: int = 0) -> None:
|
||||||
title = apply_title_template(draw_data, tab, index, max_title_length)
|
# Close buttons live in horizontal tab bars, where there is a spare cell at
|
||||||
|
# the start of each tab. Vertical tabs are already crowded and their titles
|
||||||
|
# wrap, so they keep closing with the middle mouse button.
|
||||||
|
show_close = tab.tab_id > 0 and draw_data.tab_bar_edge in ('top', 'bottom') and (max_title_length <= 0 or max_title_length >= 3)
|
||||||
|
title_width = max(1, max_title_length - 2) if show_close and max_title_length > 0 else max_title_length
|
||||||
|
title = apply_title_template(draw_data, tab, index, title_width)
|
||||||
if draw_data.max_tab_title_lines > 1 and draw_data.wrap_width:
|
if draw_data.max_tab_title_lines > 1 and draw_data.wrap_width:
|
||||||
title = wrap_title(title, draw_data.wrap_width)
|
title = wrap_title(title, draw_data.wrap_width)
|
||||||
if '\n' in title:
|
if '\n' in title:
|
||||||
@@ -511,9 +586,14 @@ def draw_title(draw_data: DrawData, screen: Screen, tab: TabBarData, index: int,
|
|||||||
# Mark the truncation, since the caller's ellipsis logic only fires
|
# Mark the truncation, since the caller's ellipsis logic only fires
|
||||||
# when the final line reaches the full width of the tab.
|
# when the final line reaches the full width of the tab.
|
||||||
del lines[limit:]
|
del lines[limit:]
|
||||||
lines[-1] = truncate_line(lines[-1], draw_data.wrap_width or max_title_length)
|
lines[-1] = truncate_line(lines[-1], draw_data.wrap_width or title_width)
|
||||||
title = '\n'.join(lines)
|
title = '\n'.join(lines)
|
||||||
before_draw = screen.cursor.x
|
before_draw = screen.cursor.x
|
||||||
|
if show_close:
|
||||||
|
if close_button_cells is not None:
|
||||||
|
close_button_cells[(before_draw, screen.cursor.y)] = tab.tab_id
|
||||||
|
close_button_cells[(before_draw + 1, screen.cursor.y)] = tab.tab_id
|
||||||
|
screen.draw('× ')
|
||||||
draw_attributed_string(title, screen)
|
draw_attributed_string(title, screen)
|
||||||
if draw_data.max_tab_title_length > 0:
|
if draw_data.max_tab_title_length > 0:
|
||||||
x_limit = before_draw + draw_data.max_tab_title_length
|
x_limit = before_draw + draw_data.max_tab_title_length
|
||||||
@@ -811,6 +891,7 @@ class TabBar:
|
|||||||
self.data_buffer_size = 0
|
self.data_buffer_size = 0
|
||||||
self.blank_rects: tuple[Border, ...] = ()
|
self.blank_rects: tuple[Border, ...] = ()
|
||||||
self.tab_extents: Sequence[TabExtent] = ()
|
self.tab_extents: Sequence[TabExtent] = ()
|
||||||
|
self.close_button_cells: dict[tuple[int, int], int] = {}
|
||||||
self.window_drop_insert_before: int | None = None
|
self.window_drop_insert_before: int | None = None
|
||||||
self.tab_drop_insert_before: int | None = None
|
self.tab_drop_insert_before: int | None = None
|
||||||
self.laid_out_once = False
|
self.laid_out_once = False
|
||||||
@@ -996,6 +1077,7 @@ class TabBar:
|
|||||||
self.blank_rects = tuple(blank_rects)
|
self.blank_rects = tuple(blank_rects)
|
||||||
|
|
||||||
def layout(self) -> None:
|
def layout(self) -> None:
|
||||||
|
self.close_button_cells = {}
|
||||||
central, tab_bar, vw, vh, cell_width, cell_height = viewport_for_window(self.os_window_id)
|
central, tab_bar, vw, vh, cell_width, cell_height = viewport_for_window(self.os_window_id)
|
||||||
if self.is_vertical:
|
if self.is_vertical:
|
||||||
if tab_bar.width < cell_width or tab_bar.height < cell_height:
|
if tab_bar.width < cell_width or tab_bar.height < cell_height:
|
||||||
@@ -1149,11 +1231,15 @@ class TabBar:
|
|||||||
s.erase_in_line(2, False)
|
s.erase_in_line(2, False)
|
||||||
cr: list[TabExtent] = []
|
cr: list[TabExtent] = []
|
||||||
ed.for_layout = False
|
ed.for_layout = False
|
||||||
|
global close_button_cells
|
||||||
|
close_button_cells = {}
|
||||||
for i, t in enumerate(data):
|
for i, t in enumerate(data):
|
||||||
try:
|
try:
|
||||||
draw_tab(i, t, cr, max_tab_lengths[i])
|
draw_tab(i, t, cr, max_tab_lengths[i])
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
break
|
break
|
||||||
|
self.close_button_cells = close_button_cells
|
||||||
|
close_button_cells = None
|
||||||
self.tab_extents = cr
|
self.tab_extents = cr
|
||||||
s.erase_in_line(0, False) # Ensure no long titles bleed after the last tab
|
s.erase_in_line(0, False) # Ensure no long titles bleed after the last tab
|
||||||
self.align()
|
self.align()
|
||||||
@@ -1164,6 +1250,7 @@ class TabBar:
|
|||||||
s = self.screen
|
s = self.screen
|
||||||
self.last_laid_out_tabs = data
|
self.last_laid_out_tabs = data
|
||||||
self.tab_extents = ()
|
self.tab_extents = ()
|
||||||
|
self.close_button_cells = {}
|
||||||
s.cursor.x = s.cursor.y = 0
|
s.cursor.x = s.cursor.y = 0
|
||||||
s.erase_in_display(2, False)
|
s.erase_in_display(2, False)
|
||||||
if not data:
|
if not data:
|
||||||
@@ -1312,6 +1399,17 @@ class TabBar:
|
|||||||
return te.tab_id
|
return te.tab_id
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def close_tab_id_at(self, x: int, y: int) -> int:
|
||||||
|
"The id of the tab whose close button is at the specified pixel, or zero."
|
||||||
|
if not self.laid_out_once or not self.close_button_cells:
|
||||||
|
return 0
|
||||||
|
g = self.window_geometry
|
||||||
|
if not (g.left <= x < g.right and g.top <= y < g.bottom):
|
||||||
|
return 0
|
||||||
|
x = (x - g.left) // self.cell_width
|
||||||
|
y = (y - g.top) // self.cell_height
|
||||||
|
return self.close_button_cells.get((x, y), 0)
|
||||||
|
|
||||||
def drag_axis_coordinate(self, x: int, y: int) -> int:
|
def drag_axis_coordinate(self, x: int, y: int) -> int:
|
||||||
return y if self.is_vertical else x
|
return y if self.is_vertical else x
|
||||||
|
|
||||||
|
|||||||
@@ -2093,9 +2093,19 @@ class TabManager: # {{{
|
|||||||
self.recent_tab_bar_mouse_events.clear()
|
self.recent_tab_bar_mouse_events.clear()
|
||||||
return
|
return
|
||||||
if button == GLFW_MOUSE_BUTTON_LEFT:
|
if button == GLFW_MOUSE_BUTTON_LEFT:
|
||||||
|
close_tab_id = self.tab_bar.close_tab_id_at(int(x), int(y))
|
||||||
if action == GLFW_PRESS:
|
if action == GLFW_PRESS:
|
||||||
|
if close_tab_id:
|
||||||
|
return # clicking the close button must not start a drag
|
||||||
set_tab_being_dragged(tab.id, False, x, y)
|
set_tab_being_dragged(tab.id, False, x, y)
|
||||||
return
|
return
|
||||||
|
if close_tab_id:
|
||||||
|
if self.recent_tab_bar_mouse_events.click_count(GLFW_MOUSE_BUTTON_LEFT) == 1:
|
||||||
|
set_tab_being_dragged()
|
||||||
|
self.recent_tab_bar_mouse_events.clear()
|
||||||
|
if (tab_to_close := self.tab_for_id(close_tab_id)) is not None:
|
||||||
|
get_boss().close_tab(tab_to_close)
|
||||||
|
return
|
||||||
match self.recent_tab_bar_mouse_events.click_count(GLFW_MOUSE_BUTTON_LEFT):
|
match self.recent_tab_bar_mouse_events.click_count(GLFW_MOUSE_BUTTON_LEFT):
|
||||||
case 2:
|
case 2:
|
||||||
self.set_active_tab(tab)
|
self.set_active_tab(tab)
|
||||||
|
|||||||
@@ -2056,6 +2056,8 @@ class Window:
|
|||||||
self.last_cmd_exit_status = int(exit_status)
|
self.last_cmd_exit_status = int(exit_status)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.last_cmd_exit_status = 0
|
self.last_cmd_exit_status = 0
|
||||||
|
if (tab := self.tabref()) is not None:
|
||||||
|
tab.mark_tab_bar_dirty()
|
||||||
end_time = monotonic()
|
end_time = monotonic()
|
||||||
last_cmd_output_duration = end_time - self.last_cmd_output_start_time
|
last_cmd_output_duration = end_time - self.last_cmd_output_start_time
|
||||||
self.last_cmd_output_start_time = 0.0
|
self.last_cmd_output_start_time = 0.0
|
||||||
|
|||||||
+90
-9
@@ -1,11 +1,27 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# License: GPL v3 Copyright: 2026, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2026, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
import os
|
||||||
|
from types import SimpleNamespace
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from kitty.fast_data_types import LEFT_EDGE, Color, Region, Screen
|
from kitty.fast_data_types import LEFT_EDGE, Color, Region, Screen
|
||||||
from kitty.options.utils import tab_title_wrap
|
from kitty.options.utils import tab_title_wrap
|
||||||
from kitty.tab_bar import CellRange, DrawData, ExtraData, TabBar, TabBarData, TabExtent, WindowDropTarget, as_rgb, powerline_symbols, truncate_line, wrap_title
|
from kitty.tab_bar import (
|
||||||
|
CellRange,
|
||||||
|
DrawData,
|
||||||
|
ExtraData,
|
||||||
|
TabBar,
|
||||||
|
TabBarData,
|
||||||
|
TabExtent,
|
||||||
|
WindowDropTarget,
|
||||||
|
abbreviate_path,
|
||||||
|
as_rgb,
|
||||||
|
exit_status_indicator,
|
||||||
|
powerline_symbols,
|
||||||
|
truncate_line,
|
||||||
|
wrap_title,
|
||||||
|
)
|
||||||
from kitty.utils import color_as_int
|
from kitty.utils import color_as_int
|
||||||
|
|
||||||
from .base import BaseTest
|
from .base import BaseTest
|
||||||
@@ -392,6 +408,47 @@ class TestTabBar(BaseTest):
|
|||||||
# empty line still gets ellipsis
|
# empty line still gets ellipsis
|
||||||
self.ae(truncate_line('', 4), '…')
|
self.ae(truncate_line('', 4), '…')
|
||||||
|
|
||||||
|
def test_abbreviate_path(self) -> None:
|
||||||
|
self.ae(abbreviate_path(''), '')
|
||||||
|
self.ae(abbreviate_path('/home/user/projects/fws-kitty', '/home/user'), '~/p/fws-kitty')
|
||||||
|
# the home directory itself has no component to abbreviate
|
||||||
|
self.ae(abbreviate_path('/home/user', '/home/user'), '~')
|
||||||
|
self.ae(abbreviate_path('/home/user/', '/home/user'), '~')
|
||||||
|
# a trailing slash does not add an empty component
|
||||||
|
self.ae(abbreviate_path('/usr/local/bin/'), '/u/l/bin')
|
||||||
|
self.ae(abbreviate_path('/'), '/')
|
||||||
|
self.ae(abbreviate_path('some/relative/dir'), 's/r/dir')
|
||||||
|
# the last component is never abbreviated, it is the most informative
|
||||||
|
self.ae(abbreviate_path('/home/user/a/very-long-project', '/home/user'), '~/a/very-long-project')
|
||||||
|
# when the result is too wide, middle directories are elided rather
|
||||||
|
# than cutting off the end of the title
|
||||||
|
self.ae(abbreviate_path('/home/user/one/two/three/project', '/home/user', 14), '~/…/project')
|
||||||
|
# when even that is too wide, the last component is truncated too
|
||||||
|
self.ae(abbreviate_path('/home/user/a/very-long-final-dir', '/home/user', 12), '~/…/very-lo…')
|
||||||
|
# widths are measured in terminal cells, so wide characters count double
|
||||||
|
self.ae(abbreviate_path('/日本語/東京'), '/日/東京')
|
||||||
|
|
||||||
|
def test_exit_status_indicator(self) -> None:
|
||||||
|
self.ae(exit_status_indicator(0), '')
|
||||||
|
self.ae(exit_status_indicator(1), '✘ 1 ')
|
||||||
|
self.ae(exit_status_indicator(130), '✘ 130 ')
|
||||||
|
|
||||||
|
def test_tab_title_indicators(self) -> None:
|
||||||
|
home = os.path.expanduser('~')
|
||||||
|
fake_tab = SimpleNamespace(
|
||||||
|
active_window=SimpleNamespace(last_cmd_exit_status=127),
|
||||||
|
get_cwd_of_active_window=lambda oldest=False: os.path.join(home, 'projects', 'fws-kitty'),
|
||||||
|
)
|
||||||
|
boss = SimpleNamespace(tab_for_id=lambda tab_id: fake_tab, mappings=SimpleNamespace(current_keyboard_mode_name=''))
|
||||||
|
line = self.horizontal_tab_bar_line(
|
||||||
|
['ignored'],
|
||||||
|
60,
|
||||||
|
boss=boss,
|
||||||
|
tab_bar_style='separator',
|
||||||
|
tab_title_template='{last_exit_code}:{exit_status_symbol}{tab.active_wd_abbreviated}',
|
||||||
|
)
|
||||||
|
self.assertIn('127:✘ 127 ~/p/fws-kitty', line)
|
||||||
|
|
||||||
def test_tab_title_wrap_option(self) -> None:
|
def test_tab_title_wrap_option(self) -> None:
|
||||||
for off in ('no', 'No', 'n', 'false', 'none', '0'):
|
for off in ('no', 'No', 'n', 'false', 'none', '0'):
|
||||||
self.ae(tab_title_wrap(off), 0)
|
self.ae(tab_title_wrap(off), 0)
|
||||||
@@ -601,7 +658,7 @@ class TestTabBar(BaseTest):
|
|||||||
[f' t0 {separator}', f'abcdefghijk{separator}', f'x {separator}'],
|
[f' t0 {separator}', f'abcdefghijk{separator}', f'x {separator}'],
|
||||||
)
|
)
|
||||||
|
|
||||||
def horizontal_tab_bar_line(self, titles: list[str], columns: int, **opts: object) -> str:
|
def horizontal_tab_bar(self, titles: list[str], columns: int, boss: object | None = None, **opts: object) -> TabBar:
|
||||||
self.set_options({'tab_title_template': '{title}', **opts})
|
self.set_options({'tab_title_template': '{title}', **opts})
|
||||||
central = region(0, 0, columns * 10, 180)
|
central = region(0, 0, columns * 10, 180)
|
||||||
tab_bar = region(0, 180, columns * 10, 200)
|
tab_bar = region(0, 180, columns * 10, 200)
|
||||||
@@ -610,24 +667,48 @@ class TestTabBar(BaseTest):
|
|||||||
patch('kitty.tab_bar.viewport_for_window', return_value=(central, tab_bar, columns * 10, 200, 10, 20)),
|
patch('kitty.tab_bar.viewport_for_window', return_value=(central, tab_bar, columns * 10, 200, 10, 20)),
|
||||||
patch('kitty.tab_bar.set_tab_bar_render_data'),
|
patch('kitty.tab_bar.set_tab_bar_render_data'),
|
||||||
patch('kitty.tab_bar.update_tab_bar_edge_colors', return_value=None),
|
patch('kitty.tab_bar.update_tab_bar_edge_colors', return_value=None),
|
||||||
patch('kitty.tab_bar.get_boss', return_value=DummyBoss()),
|
patch('kitty.tab_bar.get_boss', return_value=boss if boss is not None else DummyBoss()),
|
||||||
):
|
):
|
||||||
tb = TabBar(1)
|
tb = TabBar(1)
|
||||||
tb.layout()
|
tb.layout()
|
||||||
tb.update(tuple(TabBarData(title=t, tab_id=i + 1, is_active=i == 0) for i, t in enumerate(titles)))
|
tb.update(tuple(TabBarData(title=t, tab_id=i + 1, is_active=i == 0) for i, t in enumerate(titles)))
|
||||||
return str(tb.screen.line(0)).rstrip()
|
return tb
|
||||||
|
|
||||||
|
def horizontal_tab_bar_line(self, titles: list[str], columns: int, boss: object | None = None, **opts: object) -> str:
|
||||||
|
return str(self.horizontal_tab_bar(titles, columns, boss, **opts).screen.line(0)).rstrip()
|
||||||
|
|
||||||
|
def test_horizontal_tab_bar_close_buttons(self) -> None:
|
||||||
|
tb = self.horizontal_tab_bar(['one', 'two'], 40, tab_bar_style='separator')
|
||||||
|
line = str(tb.screen.line(0))
|
||||||
|
self.ae(line.count('×'), 2)
|
||||||
|
# each close button is two cells wide, at the start of its tab
|
||||||
|
self.ae(set(tb.close_button_cells.values()), {1, 2})
|
||||||
|
for (cell_x, row), tab_id in tb.close_button_cells.items():
|
||||||
|
px = tb.window_geometry.left + cell_x * tb.cell_width + 1
|
||||||
|
py = tb.window_geometry.top + row * tb.cell_height + 1
|
||||||
|
self.ae(tb.close_tab_id_at(px, py), tab_id)
|
||||||
|
# clicking the title itself does not close the tab
|
||||||
|
for te in tb.tab_extents:
|
||||||
|
px = tb.window_geometry.left + te.x.end * tb.cell_width
|
||||||
|
py = tb.window_geometry.top + 1
|
||||||
|
self.ae(tb.close_tab_id_at(px, py), 0)
|
||||||
|
self.ae(tb.close_tab_id_at(0, 0), 0)
|
||||||
|
|
||||||
|
# vertical tab bars keep closing with the middle mouse button
|
||||||
|
self.ae(self.vertical_tab_bar().close_button_cells, {})
|
||||||
|
|
||||||
def test_horizontal_tab_bar_uses_free_space(self) -> None:
|
def test_horizontal_tab_bar_uses_free_space(self) -> None:
|
||||||
line = self.horizontal_tab_bar_line
|
line = self.horizontal_tab_bar_line
|
||||||
# space not needed by short tabs goes to the long ones, instead of
|
# space not needed by short tabs goes to the long ones, instead of
|
||||||
# being left unused at the end of the tab bar
|
# being left unused at the end of the tab bar
|
||||||
long_title = 'abcdefghijklmn'
|
long_title = 'abcdefghijklmn'
|
||||||
|
# two extra cells per tab are needed for its close button
|
||||||
for style, columns, titles in (
|
for style, columns, titles in (
|
||||||
('fade', 25, ['1', long_title]),
|
('fade', 29, ['1', long_title]),
|
||||||
('fade', 35, ['1'] * 2 + [long_title]),
|
('fade', 41, ['1'] * 2 + [long_title]),
|
||||||
('separator', 60, ['1'] * 8 + [long_title] * 2),
|
('separator', 80, ['1'] * 8 + [long_title] * 2),
|
||||||
('powerline', 80, ['1'] * 5 + [long_title] * 3),
|
('powerline', 96, ['1'] * 5 + [long_title] * 3),
|
||||||
('slant', 126, ['1'] * 9 + [long_title] * 4),
|
('slant', 152, ['1'] * 9 + [long_title] * 4),
|
||||||
):
|
):
|
||||||
text = line(titles, columns, tab_bar_style=style)
|
text = line(titles, columns, tab_bar_style=style)
|
||||||
self.ae(text.count(long_title), titles.count(long_title), (style, text))
|
self.ae(text.count(long_title), titles.count(long_title), (style, text))
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
# Maintainer: FWS <maintainers@nocode-var.tech>
|
||||||
|
#
|
||||||
|
# Arch package for the FWS kitty fork. Built with makepkg from this directory:
|
||||||
|
#
|
||||||
|
# cd packaging && makepkg -f
|
||||||
|
#
|
||||||
|
# The resulting fws-kitty-<version>-<rel>-<arch>.pkg.tar.zst is ready to be
|
||||||
|
# added to a pacman repository (see README.md in this directory).
|
||||||
|
#
|
||||||
|
# kitty installs its own binary under /usr/bin and cannot coexist with the
|
||||||
|
# upstream package, hence provides/conflicts.
|
||||||
|
|
||||||
|
pkgname=fws-kitty
|
||||||
|
pkgver=0.50.0
|
||||||
|
pkgrel=1
|
||||||
|
pkgdesc='Fast, feature-rich, GPU based terminal (FWS fork with the file-manager kitten)'
|
||||||
|
arch=('x86_64' 'aarch64')
|
||||||
|
url='https://gitea.nocode-var.tech/FWS/FWS-Kitty'
|
||||||
|
license=('GPL-3.0-only')
|
||||||
|
|
||||||
|
# Replace main with the tag or commit to ship once the release is cut.
|
||||||
|
_branch=main
|
||||||
|
_repo='https://gitea.nocode-var.tech/FWS/FWS-Kitty.git'
|
||||||
|
|
||||||
|
depends=(
|
||||||
|
python harfbuzz zlib libpng lcms2 xxhash openssl
|
||||||
|
pixman cairo freetype2 fontconfig
|
||||||
|
libx11 libxcb libxrandr libxinerama libxcursor libxi libxrender
|
||||||
|
libxkbcommon libxkbcommon-x11 mesa wayland dbus
|
||||||
|
libcanberra systemd-libs
|
||||||
|
)
|
||||||
|
makedepends=(
|
||||||
|
git go python pkgconf ncurses rsync which file simde shader-slang
|
||||||
|
)
|
||||||
|
optdepends=(
|
||||||
|
'imagemagick: display uncommon image formats'
|
||||||
|
'shader-slang: custom shaders'
|
||||||
|
)
|
||||||
|
provides=('kitty')
|
||||||
|
conflicts=('kitty')
|
||||||
|
|
||||||
|
source=(
|
||||||
|
"$pkgname::git+$_repo#branch=$_branch"
|
||||||
|
"nerdfonts-symbols.tar.xz::https://github.com/ryanoasis/nerd-fonts/releases/download/v3.5.1/NerdFontsSymbolsOnly.tar.xz"
|
||||||
|
)
|
||||||
|
sha256sums=('SKIP' '01172f37db8543edb102e5cb5c64101c9f4686630804d49b419aa07b23a69996')
|
||||||
|
|
||||||
|
prepare() {
|
||||||
|
# kitty embeds the mono variant of the Nerd font at build time, but Arch
|
||||||
|
# only packages the proportional one, so ship the font with the build.
|
||||||
|
mkdir -p "$pkgname/fonts"
|
||||||
|
cp "$srcdir/SymbolsNerdFontMono-Regular.ttf" "$pkgname/fonts/"
|
||||||
|
|
||||||
|
cd "$pkgname"
|
||||||
|
# linux-package regenerates the man pages and the HTML docs, and some of
|
||||||
|
# their dependencies (furo, sphinx-design) are not packaged for Arch, so
|
||||||
|
# keep a local throwaway environment instead of requiring the system ones.
|
||||||
|
# Do not reuse the system packages: pip would then skip installing sphinx
|
||||||
|
# itself and the venv would have no sphinx-build entry point.
|
||||||
|
python -m venv .docs-venv
|
||||||
|
.docs-venv/bin/pip install --disable-pip-version-check -q -r docs/requirements.txt
|
||||||
|
}
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cd "$pkgname"
|
||||||
|
# kitty's linux-package target stages a full self-contained install, so
|
||||||
|
# pointing --prefix at the package root is enough; no manual file copying.
|
||||||
|
PATH="$srcdir/$pkgname/.docs-venv/bin:$PATH" python setup.py linux-package --prefix "$pkgdir/usr"
|
||||||
|
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
# Paquet Arch — FWS-Kitty
|
||||||
|
|
||||||
|
Ce dossier contient le `PKGBUILD` qui produit le paquet pacman de FWS-Kitty,
|
||||||
|
prêt à être publié dans le dépôt officiel FWS. Le paquet s'appelle
|
||||||
|
`fws-kitty` et remplace `kitty` (`provides`/`conflicts`) : les deux ne peuvent
|
||||||
|
pas cohabiter, ils installent les mêmes binaires dans `/usr/bin`.
|
||||||
|
|
||||||
|
## Construire
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd packaging
|
||||||
|
makepkg -f # ajouter -s pour installer les dépendances manquantes
|
||||||
|
```
|
||||||
|
|
||||||
|
Le résultat est `fws-kitty-<version>-<rel>-<arch>.pkg.tar.zst`.
|
||||||
|
`makepkg` construit depuis la branche indiquée par `_branch` en haut du
|
||||||
|
`PKGBUILD` (`main` par défaut). Pour publier une version précise, pointez-la
|
||||||
|
sur un tag ou un commit :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
_branch=v0.50.0
|
||||||
|
```
|
||||||
|
|
||||||
|
La police Symbols Nerd Font Mono n'est pas fournie par les dépôts Arch
|
||||||
|
(`ttf-nerd-fonts-symbols` n'installe que la variante proportionnelle) : le
|
||||||
|
`PKGBUILD` télécharge la release 3.5.1 de nerd-fonts et place le fichier dans
|
||||||
|
`fonts/` avant la compilation.
|
||||||
|
|
||||||
|
La cible `linux-package` de kitty reconstruit aussi les pages de manuel et la
|
||||||
|
documentation HTML : le `PKGBUILD` crée pour cela un environnement Python
|
||||||
|
isolé dans `prepare()` et installe `docs/requirements.txt` (Sphinx, thème
|
||||||
|
Furo…), car certaines de ces dépendances ne sont pas dans les dépôts Arch
|
||||||
|
(`sphinx-design`, `furo` au nom `python-sphinx-furo`).
|
||||||
|
|
||||||
|
## Tester localement
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo pacman -U fws-kitty-*.pkg.tar.zst
|
||||||
|
kitty --version
|
||||||
|
kitten --version
|
||||||
|
```
|
||||||
|
|
||||||
|
## Publier dans le dépôt pacman
|
||||||
|
|
||||||
|
Un dépôt pacman est un simple dossier HTTP contenant les paquets et une base
|
||||||
|
`repo-add` :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
repo-add fws-kitty.db.tar.gz fws-kitty-*.pkg.tar.zst
|
||||||
|
```
|
||||||
|
|
||||||
|
Puis, côté client, dans `/etc/pacman.conf` :
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[fws]
|
||||||
|
SigLevel = Optional TrustAll
|
||||||
|
Server = https://<hôte>/fws/$arch
|
||||||
|
```
|
||||||
|
|
||||||
|
Le dossier doit être servi en HTTP/HTTPS statique (nginx, Caddy, GitHub/Gitea
|
||||||
|
Pages…). Gitea n'a pas de registre pacman natif : le registre « Generic »
|
||||||
|
fonctionne pour héberger les fichiers, mais pacman a besoin d'URL stables pour
|
||||||
|
`fws-kitty.db.tar.gz` et les `.pkg.tar.zst`, ce qu'un simple dossier servi par
|
||||||
|
nginx (ou des assets de release) fournit directement.
|
||||||
|
|
||||||
|
Pour une publication automatique, il suffit d'enchaîner dans la CI :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
makepkg -f --nodeps # ou -s avec un utilisateur autorisé à pacman
|
||||||
|
repo-add repo/fws-kitty.db.tar.gz fws-kitty-*.pkg.tar.zst
|
||||||
|
# puis copier repo/ vers le serveur
|
||||||
|
```
|
||||||
|
|
||||||
|
Si le dépôt doit aussi fournir `kitty-terminfo` et l'intégration shell aux
|
||||||
|
serveurs SSH, ces fichiers peuvent être découpés en paquets séparés : la
|
||||||
|
documentation de kitty (`docs/build.rst`, section « Notes pour les
|
||||||
|
empaqueteurs ») décrit la répartition.
|
||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/kovidgoyal/kitty/kittens/desktop_ui"
|
"github.com/kovidgoyal/kitty/kittens/desktop_ui"
|
||||||
"github.com/kovidgoyal/kitty/kittens/diff"
|
"github.com/kovidgoyal/kitty/kittens/diff"
|
||||||
"github.com/kovidgoyal/kitty/kittens/dnd"
|
"github.com/kovidgoyal/kitty/kittens/dnd"
|
||||||
|
"github.com/kovidgoyal/kitty/kittens/file_manager"
|
||||||
"github.com/kovidgoyal/kitty/kittens/hints"
|
"github.com/kovidgoyal/kitty/kittens/hints"
|
||||||
"github.com/kovidgoyal/kitty/kittens/hyperlinked_grep"
|
"github.com/kovidgoyal/kitty/kittens/hyperlinked_grep"
|
||||||
"github.com/kovidgoyal/kitty/kittens/icat"
|
"github.com/kovidgoyal/kitty/kittens/icat"
|
||||||
@@ -59,6 +60,8 @@ func KittyToolEntryPoints(root *cli.Command) {
|
|||||||
clipboard.EntryPoint(root)
|
clipboard.EntryPoint(root)
|
||||||
// dnd
|
// dnd
|
||||||
dnd.EntryPoint(root)
|
dnd.EntryPoint(root)
|
||||||
|
// file-manager
|
||||||
|
file_manager.EntryPoint(root)
|
||||||
// icat
|
// icat
|
||||||
icat.EntryPoint(root)
|
icat.EntryPoint(root)
|
||||||
// ssh
|
// ssh
|
||||||
|
|||||||
Reference in new issue
Block a user