mirror of
https://github.com/baairon/torlink.git
synced 2026-07-08 18:28:22 +02:00
123 lines
3.5 KiB
TypeScript
123 lines
3.5 KiB
TypeScript
import type { DownloadFocus, Region, Section, SeedFocus } from "./store";
|
|
|
|
export interface Hint {
|
|
keys: string;
|
|
label: string;
|
|
}
|
|
|
|
interface HelpGroup {
|
|
title: string;
|
|
hints: Hint[];
|
|
}
|
|
|
|
export const HELP_GROUPS: HelpGroup[] = [
|
|
{
|
|
title: "Navigate",
|
|
hints: [
|
|
{ keys: "↑ ↓ ← →, h j k l", label: "Navigate content and panes" },
|
|
{ keys: "↵", label: "Open" },
|
|
{ keys: "tab", label: "Switch pane" },
|
|
{ keys: "esc", label: "Back" },
|
|
{ keys: "o", label: "Download folder" },
|
|
{ keys: "t", label: "Extra trackers" },
|
|
{ keys: "q", label: "Quit" },
|
|
],
|
|
},
|
|
{
|
|
title: "Search",
|
|
hints: [
|
|
{ keys: "/", label: "Edit search" },
|
|
{ keys: "↵", label: "Run search" },
|
|
{ keys: "d", label: "Download" },
|
|
{ keys: "D", label: "Download to a folder…" },
|
|
{ keys: "s", label: "Sort results" },
|
|
{ keys: "z", label: "Hide dead torrents" },
|
|
{ keys: "y", label: "Copy magnet" },
|
|
{ keys: "m", label: "Paste magnet" },
|
|
],
|
|
},
|
|
{
|
|
title: "Downloads",
|
|
hints: [
|
|
{ keys: "p", label: "Pause/resume" },
|
|
{ keys: "c", label: "Cancel or remove from list" },
|
|
{ keys: "f", label: "Retry failed" },
|
|
{ keys: "d", label: "Download again" },
|
|
{ keys: "e", label: "Open folder" },
|
|
{ keys: "x", label: "Clear recent" },
|
|
],
|
|
},
|
|
{
|
|
title: "Seeding",
|
|
hints: [
|
|
{ keys: "p", label: "Pause/resume" },
|
|
{ keys: "c", label: "Remove from list" },
|
|
{ keys: "e", label: "Open folder" },
|
|
],
|
|
},
|
|
];
|
|
|
|
// Footer labels stay terse so the contextual hint row never wraps; the `?`
|
|
// overlay (HELP_GROUPS) carries the full, descriptive list.
|
|
const NAVIGATE: Hint = { keys: "↑↓←→", label: "Move" };
|
|
|
|
const ALWAYS: Hint = { keys: "?", label: "Keys" };
|
|
|
|
const SWITCH: Hint = { keys: "tab", label: "Switch" };
|
|
|
|
const FOLDER: Hint = { keys: "e", label: "Folder" };
|
|
|
|
export function footerHints(
|
|
region: Region,
|
|
section: Section,
|
|
downloadFocus?: DownloadFocus | null,
|
|
seedFocus?: SeedFocus | null,
|
|
): Hint[] {
|
|
if (region === "sidebar") {
|
|
return [
|
|
NAVIGATE,
|
|
{ keys: "↵", label: "Open" },
|
|
SWITCH,
|
|
ALWAYS,
|
|
{ keys: "q", label: "Quit" },
|
|
];
|
|
}
|
|
if (section === "seeding") {
|
|
const label =
|
|
seedFocus === "seeding" ? "Pause" : seedFocus === "missing" ? "Retry" : "Resume";
|
|
return [{ keys: "p", label }, { keys: "c", label: "Remove" }, FOLDER, SWITCH, ALWAYS];
|
|
}
|
|
if (section === "downloads") {
|
|
if (downloadFocus === "paused") {
|
|
return [{ keys: "p", label: "Resume" }, { keys: "c", label: "Cancel" }, FOLDER, SWITCH, ALWAYS];
|
|
}
|
|
if (downloadFocus === "failed") {
|
|
return [{ keys: "f", label: "Retry" }, { keys: "c", label: "Remove" }, FOLDER, SWITCH, ALWAYS];
|
|
}
|
|
if (downloadFocus === "recent") {
|
|
return [
|
|
NAVIGATE,
|
|
{ keys: "d", label: "Redownload" },
|
|
{ keys: "c", label: "Remove" },
|
|
{ keys: "x", label: "Clear" },
|
|
FOLDER,
|
|
SWITCH,
|
|
ALWAYS,
|
|
];
|
|
}
|
|
return [{ keys: "p", label: "Pause" }, { keys: "c", label: "Cancel" }, FOLDER, SWITCH, ALWAYS];
|
|
}
|
|
return [
|
|
NAVIGATE,
|
|
// d downloads to the default folder, D asks where; the `?` sheet spells
|
|
// out the difference, the footer just shows both keys exist.
|
|
{ keys: "d/D", label: "Download" },
|
|
{ keys: "y", label: "Copy" },
|
|
{ keys: "s", label: "Sort" },
|
|
{ keys: "z", label: "Alive" },
|
|
{ keys: "/", label: "Search" },
|
|
SWITCH,
|
|
ALWAYS,
|
|
];
|
|
}
|