mirror of
https://github.com/zellij-org/zellij.git
synced 2026-10-02 16:02:10 +00:00
* phase 2+3 * initial mobile plugin (phases 4 + 5 + 6) * some bugfixes * implement stage 7 * mobile interface improvements * improve mobile pane/tab picker * more ui improvements and fixes * various mobile fixes * some mobile fixes * mobile keyboard triggering fix * some cleanups * initial plugin keyboard implementation * improve keyboard hit zones * improve keyboard * pinch resize * pinching fixes * implement scrolling + panning * initial keyboard resizing * fix: mobile first render issues * keyboard responsiveness * fix some issues with the keyboard * implement fit * fix mobile scrolling * add tilde cell to compact * improve mobile keyboard * fix starting mobile terminal font to natural keyboard size * fix mobile resize blank screen flash * shadow focus for mobile * more keyboard fixes * improve mobile status bar * fix: render plugins to mobile clients * allow opening new panes/tabs from the mobile plugin * allow configuring * fix dot slash * improve mobile native soft keyboard interaction * switch to native keyboard - initial implementation * dirty hacks, but phone keyboard works now * adjust keyboard help strip * fix cursor in mobile * fix keyboard and help line * rename keyboard to modifier bar * allow starting new session * make clicking session name bring us to new session menu * allow switching to desktop from the mobile ui * mobile welcome screen initial implementation * mobile welcome screen fixes * various welcome screen fixes * more mobile fixes * moar mobile fixes * mobile ui redesign * fix: swallowed backspace bug * switch session screen improvement * touch up some interfaces * refactor: move mobile state to own struct * refactor: move fit resizing to the server * remove dead flash code * some cleanups * refactor: clear fit on close * refactor: improve fit api * refactor: pane sync functions * refactor: mouse * refactor: break into modules * some cleanups for the sessions screen * fix scrolling and other stuff * refactor: sessions screen * refactor: panes screen * refactor: new session screen * refactor: menu screen * refactor: render * cleanups * refactor: plugin structure * remove unused welcome screen path * Rename api * refactor input.js * cleanup useless comments * fit/mobile refactoring * take out the garbage * remove more comments * remove mobile flash on startup/attach * fix: various mobile startup issues * fix space bugs * cleanup * rustfmt * fix windows build * adjust modifier bar ui * add pr
65 lines
2.2 KiB
JavaScript
65 lines
2.2 KiB
JavaScript
import { encode_kitty_key } from "./keyboard.js";
|
|
import { isMac } from "./utils.js";
|
|
|
|
export function installCustomKeyHandler(term, sendFunction) {
|
|
term.attachCustomKeyEventHandler((ev) => {
|
|
if (ev.type === "keydown") {
|
|
if (ev.key == "V" && ev.ctrlKey && ev.shiftKey) {
|
|
return;
|
|
}
|
|
if (isMac() && ev.key == "v" && ev.metaKey) {
|
|
return;
|
|
}
|
|
if (hasModifiersToHandle(ev)) {
|
|
ev.preventDefault();
|
|
encode_kitty_key(ev, sendFunction);
|
|
return false;
|
|
}
|
|
// xterm.js mishandles Alt+Arrow; send Alt-modified SGR sequences directly:
|
|
// https://github.com/xtermjs/xterm.js/blob/41e8ae395937011d6bf6c7cb618b851791aed395/src/common/input/Keyboard.ts#L158
|
|
if (ev.key == "ArrowLeft" && ev.altKey) {
|
|
ev.preventDefault();
|
|
sendFunction("\x1b[1;3D");
|
|
return false;
|
|
}
|
|
if (ev.key == "ArrowRight" && ev.altKey) {
|
|
ev.preventDefault();
|
|
sendFunction("\x1b[1;3C");
|
|
return false;
|
|
}
|
|
if (ev.key == "ArrowUp" && ev.altKey) {
|
|
ev.preventDefault();
|
|
sendFunction("\x1b[1;3A");
|
|
return false;
|
|
}
|
|
if (ev.key == "ArrowDown" && ev.altKey) {
|
|
ev.preventDefault();
|
|
sendFunction("\x1b[1;3B");
|
|
return false;
|
|
}
|
|
if (
|
|
(ev.key == "=" && ev.altKey) ||
|
|
(ev.key == "+" && ev.altKey) ||
|
|
(ev.key == "-" && ev.altKey)
|
|
) {
|
|
ev.preventDefault();
|
|
encode_kitty_key(ev, sendFunction);
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
});
|
|
}
|
|
|
|
function hasModifiersToHandle(ev) {
|
|
const MODIFIER_KEYS = ["Shift", "Control", "Alt", "Meta"];
|
|
const modifiers_count = [
|
|
ev.altKey,
|
|
ev.ctrlKey,
|
|
ev.shiftKey,
|
|
ev.metaKey,
|
|
].filter(Boolean).length;
|
|
const isModifierKey = MODIFIER_KEYS.includes(ev.key);
|
|
return (modifiers_count > 1 || ev.metaKey) && !isModifierKey;
|
|
}
|