html: add option to toggle sixel

This commit is contained in:
Shuanglei Tao
2022-10-30 11:14:19 +08:00
parent 8f754b153c
commit 5a4c210e7b
3 changed files with 1005 additions and 1000 deletions

View File

@@ -17,6 +17,7 @@ const clientOptions = {
disableLeaveAlert: false,
disableResizeOverlay: false,
enableZmodem: false,
enableSixel: false,
titleFixed: null,
} as ClientOptions;
const termOptions = {

View File

@@ -12,8 +12,6 @@ import { ZmodemAddon } from '../zmodem';
import 'xterm/css/xterm.css';
import worker from 'xterm-addon-image/lib/xterm-addon-image-worker';
const imageWorkerUrl = window.URL.createObjectURL(new Blob([worker], { type: 'text/javascript' }));
interface TtydTerminal extends Terminal {
fit(): void;
}
@@ -44,6 +42,7 @@ export interface ClientOptions {
disableLeaveAlert: boolean;
disableResizeOverlay: boolean;
enableZmodem: boolean;
enableSixel: boolean;
titleFixed: string;
}
@@ -204,7 +203,6 @@ export class Xterm extends Component<Props, State> {
terminal.loadAddon(fitAddon);
terminal.loadAddon(overlayAddon);
terminal.loadAddon(new WebLinksAddon());
terminal.loadAddon(new ImageAddon(imageWorkerUrl));
terminal.onTitleChange(data => {
if (data && data !== '' && !this.titleFixed) {
@@ -354,6 +352,15 @@ export class Xterm extends Component<Props, State> {
console.log(`[ttyd] Zmodem enabled`);
}
break;
case 'enableSixel':
if (value) {
const imageWorkerUrl = window.URL.createObjectURL(
new Blob([worker], { type: 'text/javascript' })
);
terminal.loadAddon(new ImageAddon(imageWorkerUrl));
console.log(`[ttyd] Sixel enabled`);
}
break;
case 'titleFixed':
if (!value || value === '') return;
console.log(`[ttyd] setting fixed title: ${value}`);

1991
src/html.h generated

File diff suppressed because it is too large Load Diff