Upgrade mobile keyboard with more keys.
This commit is contained in:
@@ -405,7 +405,7 @@ style.innerHTML = `
|
|||||||
font-feature-settings: "liga" 1, "calt" 1;
|
font-feature-settings: "liga" 1, "calt" 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.xterm .xterm-screen .xterm-char[data-char-code^="\\uE"] {
|
.xterm .xterm-screen .xterm-char[data-char-code^="\uE000"] {
|
||||||
font-family: 'JetBrains Mono Nerd Font', 'MesloLGS NF', 'FiraCode Nerd Font' !important;
|
font-family: 'JetBrains Mono Nerd Font', 'MesloLGS NF', 'FiraCode Nerd Font' !important;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -9,59 +9,137 @@ interface TerminalKeyboardProps {
|
|||||||
|
|
||||||
export function TerminalKeyboard({onSendInput}: TerminalKeyboardProps) {
|
export function TerminalKeyboard({onSendInput}: TerminalKeyboardProps) {
|
||||||
const [layoutName, setLayoutName] = useState("default");
|
const [layoutName, setLayoutName] = useState("default");
|
||||||
|
const [isCtrl, setIsCtrl] = useState(false);
|
||||||
|
const [isAlt, setIsAlt] = useState(false);
|
||||||
|
|
||||||
const onKeyPress = (button: string) => {
|
const onKeyPress = async (button: string) => {
|
||||||
if (button === "{shift}") {
|
if (button === "{shift}") {
|
||||||
setLayoutName("shift");
|
setLayoutName("shift");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (button === "{unshift}") {
|
if (button === "{unshift}") {
|
||||||
setLayoutName("default");
|
setLayoutName("default");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (button === "{more}") {
|
if (button === "{more}") {
|
||||||
setLayoutName("more")
|
setLayoutName("more");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (button === "{less}") {
|
if (button === "{less}") {
|
||||||
setLayoutName("default");
|
setLayoutName("default");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (button === "{hide}") {
|
if (button === "{hide}") {
|
||||||
setLayoutName("hide");
|
setLayoutName("hide");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (button === "{unhide}") {
|
if (button === "{unhide}") {
|
||||||
setLayoutName("default");
|
setLayoutName("default");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSendInput(button);
|
if (button === "{ctrl}") {
|
||||||
|
setIsCtrl(prev => !prev);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (button === "{alt}") {
|
||||||
|
setIsAlt(prev => !prev);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (button === "{paste}") {
|
||||||
|
if (navigator.clipboard?.readText) {
|
||||||
|
try {
|
||||||
|
const text = await navigator.clipboard.readText();
|
||||||
|
if (text) {
|
||||||
|
onSendInput(text);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let input = button;
|
||||||
|
|
||||||
|
const specialKeyMap: { [key: string]: string } = {
|
||||||
|
"{esc}": "\x1b", "{enter}": "\r", "{tab}": "\t", "{backspace}": "\x7f",
|
||||||
|
"{arrowUp}": "\x1b[A", "{arrowDown}": "\x1b[B", "{arrowRight}": "\x1b[C", "{arrowLeft}": "\x1b[D",
|
||||||
|
"{home}": "\x1b[H", "{end}": "\x1b[F", "{pgUp}": "\x1b[5~", "{pgDn}": "\x1b[6~",
|
||||||
|
"F1": "\x1bOP", "F2": "\x1bOQ", "F3": "\x1bOR", "F4": "\x1bOS",
|
||||||
|
"F5": "\x1b[15~", "F6": "\x1b[17~", "F7": "\x1b[18~", "F8": "\x1b[19~",
|
||||||
|
"F9": "\x1b[20~", "F10": "\x1b[21~", "F11": "\x1b[23~", "F12": "\x1b[24~",
|
||||||
|
"{space}": " "
|
||||||
|
};
|
||||||
|
|
||||||
|
if (specialKeyMap[input]) {
|
||||||
|
input = specialKeyMap[input];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isCtrl) {
|
||||||
|
if (input.length === 1) {
|
||||||
|
const charCode = input.toUpperCase().charCodeAt(0);
|
||||||
|
if (charCode >= 64 && charCode <= 95) {
|
||||||
|
input = String.fromCharCode(charCode - 64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isAlt) {
|
||||||
|
input = `\x1b${input}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSendInput(input);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const buttonTheme = [
|
||||||
|
{
|
||||||
|
class: "hg-space-big",
|
||||||
|
buttons: "{space}",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
class: "hg-space-medium",
|
||||||
|
buttons: "{enter} {backspace}",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
class: "hg-space-small",
|
||||||
|
buttons: "{hide} {less} {more}",
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
if (isCtrl) {
|
||||||
|
buttonTheme.push({class: "key-active", buttons: "{ctrl}"});
|
||||||
|
}
|
||||||
|
if (isAlt) {
|
||||||
|
buttonTheme.push({class: "key-active", buttons: "{alt}"});
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="">
|
<div className="">
|
||||||
<Keyboard
|
<Keyboard
|
||||||
layout={{
|
layout={{
|
||||||
default: [
|
default: [
|
||||||
|
"{esc} {tab} {ctrl} {alt} {arrowLeft} {arrowRight} {arrowUp} {arrowDown}",
|
||||||
"q w e r t y u i o p",
|
"q w e r t y u i o p",
|
||||||
"a s d f g h j k l",
|
"a s d f g h j k l",
|
||||||
"{shift} z x c v b n m {backspace}",
|
"{shift} z x c v b n m {backspace}",
|
||||||
"{hide} {more} {space} {enter}",
|
"{hide} {more} {space} {enter}",
|
||||||
],
|
],
|
||||||
shift: [
|
shift: [
|
||||||
|
"{esc} {tab} {ctrl} {alt} {arrowLeft} {arrowRight} {arrowUp} {arrowDown}",
|
||||||
"Q W E R T Y U I O P",
|
"Q W E R T Y U I O P",
|
||||||
"A S D F G H J K L",
|
"A S D F G H J K L",
|
||||||
"{unshift} Z X C V B N M {backspace}",
|
"{unshift} Z X C V B N M {backspace}",
|
||||||
"{hide} {more} {space} {enter}",
|
"{hide} {more} {space} {enter}",
|
||||||
],
|
],
|
||||||
more: [
|
more: [
|
||||||
"{arrowLeft} {arrowRight} {arrowUp} {arrowDown} {backspace}",
|
"{esc} {tab} {ctrl} {alt} {end} {home} {pgUp} {pgDn}",
|
||||||
|
"1 2 3 4 5 6 7 8 9 0",
|
||||||
|
"! @ # $ % ^ & * ( ) _ +",
|
||||||
|
"[ ] { } | \\ ; : ' \" , . / < >",
|
||||||
|
"F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12",
|
||||||
|
"{arrowLeft} {arrowRight} {arrowUp} {arrowDown} {paste} {backspace}",
|
||||||
"{hide} {less} {space} {enter}",
|
"{hide} {less} {space} {enter}",
|
||||||
],
|
],
|
||||||
hide: [
|
hide: [
|
||||||
@@ -73,7 +151,7 @@ export function TerminalKeyboard({onSendInput}: TerminalKeyboardProps) {
|
|||||||
display={{
|
display={{
|
||||||
"{shift}": "up",
|
"{shift}": "up",
|
||||||
"{unshift}": "dn",
|
"{unshift}": "dn",
|
||||||
"{backspace}": "del",
|
"{backspace}": "back",
|
||||||
"{more}": "more",
|
"{more}": "more",
|
||||||
"{less}": "less",
|
"{less}": "less",
|
||||||
"{space}": "space",
|
"{space}": "space",
|
||||||
@@ -84,23 +162,19 @@ export function TerminalKeyboard({onSendInput}: TerminalKeyboardProps) {
|
|||||||
"{arrowDown}": "↓",
|
"{arrowDown}": "↓",
|
||||||
"{hide}": "hide",
|
"{hide}": "hide",
|
||||||
"{unhide}": "unhide",
|
"{unhide}": "unhide",
|
||||||
|
"{esc}": "esc",
|
||||||
|
"{tab}": "tab",
|
||||||
|
"{ctrl}": "ctrl",
|
||||||
|
"{alt}": "alt",
|
||||||
|
"{paste}": "paste",
|
||||||
|
"{end}": "end",
|
||||||
|
"{home}": "home",
|
||||||
|
"{pgUp}": "pgUp",
|
||||||
|
"{pgDn}": "pgDn",
|
||||||
}}
|
}}
|
||||||
theme={"hg-theme-default dark-theme"}
|
theme={"hg-theme-default dark-theme"}
|
||||||
useTouchEvents={true}
|
useTouchEvents={true}
|
||||||
buttonTheme={[
|
buttonTheme={buttonTheme}
|
||||||
{
|
|
||||||
class: "hg-space-big",
|
|
||||||
buttons: "{space}",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
class: "hg-space-medium",
|
|
||||||
buttons: "{enter} {backspace}",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
class: "hg-space-small",
|
|
||||||
buttons: "{hide} {less} {more}",
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -22,6 +22,11 @@
|
|||||||
background: rgba(83, 83, 83, 0.5);
|
background: rgba(83, 83, 83, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dark-theme .hg-button.key-active {
|
||||||
|
background: rgba(126, 126, 126, 0.5);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
.hg-space-big {
|
.hg-space-big {
|
||||||
width: 100px;
|
width: 100px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import {useRef} from "react";
|
import {useRef, FC} from "react";
|
||||||
import {Terminal} from "@/ui/Mobile/Apps/Terminal/Terminal.tsx";
|
import {Terminal} from "@/ui/Mobile/Apps/Terminal/Terminal.tsx";
|
||||||
import {TerminalKeyboard} from "@/ui/Mobile/Apps/Terminal/TerminalKeyboard.tsx";
|
import {TerminalKeyboard} from "@/ui/Mobile/Apps/Terminal/TerminalKeyboard.tsx";
|
||||||
|
|
||||||
export function MobileApp() {
|
export const MobileApp: FC = () => {
|
||||||
const terminalRef = useRef<any>(null);
|
const terminalRef = useRef<any>(null);
|
||||||
|
|
||||||
function handleKeyboardInput(input: string) {
|
function handleKeyboardInput(input: string) {
|
||||||
@@ -34,16 +34,18 @@ export function MobileApp() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-screen w-screen flex flex-col bg-[#09090b] overflow-y-hidden overflow-x-hidden">
|
<div className="h-screen w-screen flex flex-col bg-[#09090b] overflow-y-hidden overflow-x-hidden">
|
||||||
<Terminal
|
<div className="flex-1 min-h-0">
|
||||||
ref={terminalRef}
|
<Terminal
|
||||||
hostConfig={{
|
ref={terminalRef}
|
||||||
ip: "192.210.197.55",
|
hostConfig={{
|
||||||
port: 22,
|
ip: "192.210.197.55",
|
||||||
username: "bugattiguy527",
|
port: 22,
|
||||||
password: "bugatti$123"
|
username: "bugattiguy527",
|
||||||
}}
|
password: "bugatti$123"
|
||||||
isVisible={true}
|
}}
|
||||||
/>
|
isVisible={true}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<TerminalKeyboard
|
<TerminalKeyboard
|
||||||
onSendInput={handleKeyboardInput}
|
onSendInput={handleKeyboardInput}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user