Skip to content

Commit

Permalink
html: add titleFixed client option
Browse files Browse the repository at this point in the history
  • Loading branch information
tsl0922 committed Jul 25, 2020
1 parent 4ddf88b commit a841738
Show file tree
Hide file tree
Showing 3 changed files with 9,101 additions and 9,050 deletions.
18 changes: 12 additions & 6 deletions html/src/components/terminal/index.tsx
Expand Up @@ -50,6 +50,7 @@ export class Xterm extends Component<Props> {
private socket: WebSocket;
private token: string;
private title: string;
private titleFixed: string;
private resizeTimeout: number;
private backoff: backoff.Backoff;
private backoffLock = false;
Expand Down Expand Up @@ -160,7 +161,7 @@ export class Xterm extends Component<Props> {
terminal.loadAddon(this.zmodemAddon);

terminal.onTitleChange(data => {
if (data && data !== '') {
if (data && data !== '' && !this.titleFixed) {
document.title = data + ' | ' + this.title;
}
});
Expand Down Expand Up @@ -249,6 +250,7 @@ export class Xterm extends Component<Props> {
case Command.SET_PREFERENCES:
const preferences = JSON.parse(textDecoder.decode(data));
Object.keys(preferences).forEach(key => {
const value = preferences[key];
switch (key) {
case 'rendererType':
if (preferences[key] === 'webgl') {
Expand All @@ -263,14 +265,18 @@ export class Xterm extends Component<Props> {
}
break;
case 'fontSize':
console.log(`[ttyd] setting font size to ${preferences[key]}`);
terminal.setOption(key, preferences[key]);
console.log(`[ttyd] setting font size to ${value}`);
terminal.setOption(key, value);
fitAddon.fit();
break;

case 'titleFixed':
console.log(`[ttyd] setting fixed title: ${value}`);
this.titleFixed = value;
document.title = value;
break;
default:
console.log(`[ttyd] option: ${key}=${preferences[key]}`);
terminal.setOption(key, preferences[key]);
console.log(`[ttyd] option: ${key}=${value}`);
terminal.setOption(key, value);
break;
}
});
Expand Down
16 changes: 16 additions & 0 deletions html/yarn.lock
Expand Up @@ -1371,6 +1371,15 @@ clone-buffer@^1.0.0:
resolved "https://registry.yarnpkg.com/clone-buffer/-/clone-buffer-1.0.0.tgz#e3e25b207ac4e701af721e2cb5a16792cac3dc58"
integrity sha1-4+JbIHrE5wGvch4staFnksrD3Fg=

clone-deep@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387"
integrity sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==
dependencies:
is-plain-object "^2.0.4"
kind-of "^6.0.2"
shallow-clone "^3.0.0"

clone-response@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/clone-response/-/clone-response-1.0.2.tgz#d1dc973920314df67fbeb94223b4ee350239e96b"
Expand Down Expand Up @@ -7022,6 +7031,13 @@ sha.js@^2.4.0, sha.js@^2.4.8:
inherits "^2.0.1"
safe-buffer "^5.0.1"

shallow-clone@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/shallow-clone/-/shallow-clone-3.0.1.tgz#8f2981ad92531f55035b01fb230769a40e02efa3"
integrity sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==
dependencies:
kind-of "^6.0.2"

shebang-command@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
Expand Down

0 comments on commit a841738

Please sign in to comment.