daf5b7be92
- Changes panel: a working file opens in a CodeMirror editor with its diff inline (DiffEditor.tsx, @codemirror/merge, lazy-loaded); Changes folds the unchanged lines, Whole file shows them; side by side at 50/50 and full width; a Revert per block; original from HEAD or the branch's merge base (`mergeBase` on GET /git/changes?range=branch) - Every diff: green = line added whole, red = removed whole, blue = edited in place (--diff-mod) - History drawn as a commit graph (#58: `parents` on GET /git/log, --date-order; lib/commitGraph.ts) - Per-workspace never-stage list, drawn orange in the Files tree (--kept); closed Terminal rows past three deleted - Status bar plan quota for Claude (per account) and Codex (GET /api/pricing/quota, server/lib/quota.js); compact hover panel that stays open, Refresh button with a spinner - Settings → Appearance holds language, theme and pet; Ctrl+Shift+C copies; compact sidebar navigation and short session times
29 lines
1.3 KiB
TypeScript
29 lines
1.3 KiB
TypeScript
/**
|
|
* @file keys.ts
|
|
* @description Keyboard helpers shared by every single-line submit field.
|
|
* `isSubmitEnter` ignores the Enter that confirms an IME candidate (Vietnamese
|
|
* Telex, CJK): without it a rename or commit message is committed half-typed.
|
|
* `copyOnCtrlShiftC` makes Ctrl+Shift+C a copy, as in a Linux terminal, instead
|
|
* of the browser's inspect-element shortcut (App.tsx installs it, capture phase).
|
|
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
|
*/
|
|
|
|
import type { KeyboardEvent as ReactKeyboardEvent } from "react";
|
|
|
|
/** True for a plain Enter that should submit — not Shift+Enter, not mid-IME. */
|
|
export function isSubmitEnter(e: ReactKeyboardEvent | KeyboardEvent): boolean {
|
|
const native = "nativeEvent" in e ? e.nativeEvent : e;
|
|
return e.key === "Enter" && !e.shiftKey && !native.isComposing && native.keyCode !== 229;
|
|
}
|
|
|
|
/**
|
|
* Ctrl+Shift+C copies the selection — a field's, the page's or a terminal's
|
|
* (xterm answers the `copy` event) — instead of opening DevTools. F12 and
|
|
* Ctrl+Shift+I still open them. With nothing selected it does nothing.
|
|
*/
|
|
export function copyOnCtrlShiftC(e: KeyboardEvent): void {
|
|
if (e.code !== "KeyC" || !e.ctrlKey || !e.shiftKey || e.altKey || e.metaKey) return;
|
|
e.preventDefault();
|
|
document.execCommand("copy");
|
|
}
|