Browse Source

Added automatic saving. Bug wackamole. termResize being called with NaN RenderService values

pull/342/head
Christian7573 4 years ago
parent
commit
0ad56a0680
  1. 22
      src/assets/xterm_config/functionality.js
  2. 3
      src/assets/xterm_config/index.html
  3. 42
      src/assets/xterm_config/xterm_advanced_options.js
  4. 40
      src/assets/xterm_config/xterm_color_theme.js
  5. 2
      src/assets/xterm_config/xterm_defaults.js
  6. 30
      src/assets/xterm_config/xterm_general_options.js
  7. 11
      src/client/wetty/term/confiruragtion.ts
  8. 16
      src/client/wetty/term/confiruragtion/editor.ts
  9. 4
      src/client/wetty/term/confiruragtion/load.ts

22
src/assets/xterm_config/functionality.js

@ -2,6 +2,8 @@ function optionGenericGet() { return this.el.querySelector("input").value; }
function optionGenericSet(value) { this.el.querySelector("input").value = value; } function optionGenericSet(value) { this.el.querySelector("input").value = value; }
function optionEnumGet() { return this.el.querySelector("select").value; } function optionEnumGet() { return this.el.querySelector("select").value; }
function optionEnumSet(value) { this.el.querySelector("select").value = value; } function optionEnumSet(value) { this.el.querySelector("select").value = value; }
function optionBoolGet() { return this.el.querySelector("input").value === "true"; }
function optionBoolSet(value) { this.el.querySelector("input").value = value ? "true" : "false"; }
const allOptions = []; const allOptions = [];
function inflateOptions(optionsSchema) { function inflateOptions(optionsSchema) {
@ -23,6 +25,8 @@ function inflateOptions(optionsSchema) {
switch (option.type) { switch (option.type) {
case "boolean": case "boolean":
el = booleanOption.cloneNode(true); el = booleanOption.cloneNode(true);
option.get = optionBoolGet.bind(option);
option.set = optionBoolSet.bind(option);
break; break;
case "enum": case "enum":
@ -90,19 +94,21 @@ window.loadOptions = function(config) {
if (window.top === window) alert("Error: Page is top level. This page is supposed to be accessed from inside Wetty."); if (window.top === window) alert("Error: Page is top level. This page is supposed to be accessed from inside Wetty.");
document.querySelector("#save_button").addEventListener("click", () => { function saveConfig() {
const newConfig = {}; const newConfig = {};
allOptions.forEach(option => { allOptions.forEach(option => {
let newValue = option.get(); let newValue = option.get();
if (option.nullable === true && option.type === "text" && newValue === "") newValue = null; if (option.nullable === true && option.type === "text" && newValue === "") newValue = undefined;
else if (option.nullable === true && option.type === "number" && newValue < 0) newValue = null; else if (option.nullable === true && option.type === "number" && newValue < 0) newValue = undefined;
if (option.json === true && option.type === "text") newValue = JSON.parse(newValue); if (option.json === true && option.type === "text") newValue = JSON.parse(newValue);
setItem(newConfig, option.path, newValue); setItem(newConfig, option.path, newValue);
}); });
console.log(newConfig);
window.wetty_save_config(newConfig); window.wetty_save_config(newConfig);
window.wetty_close_config(); };
});
document.querySelector("#cancel_button").addEventListener("click", () => { window.addEventListener("load", () => {
window.wetty_close_config(); const els = document.querySelectorAll("input, select");
for (let i = 0; i < els.length; i++) {
els[i].addEventListener("input", saveConfig);
}
}); });

3
src/assets/xterm_config/index.html

@ -7,9 +7,6 @@
<body> <body>
<header> <header>
<h1>Configure</h1> <h1>Configure</h1>
<div style="flex-grow: 1000"></div>
<button id="save_button">Save</button>
<button id="cancel_button">Cancel</button>
</header> </header>
<div class="templ" id="boolean_option"> <div class="templ" id="boolean_option">

42
src/assets/xterm_config/xterm_advanced_options.js

@ -3,119 +3,113 @@ window.inflateOptions([
type: "boolean", type: "boolean",
name: "Allow Proposed XTerm APIs", name: "Allow Proposed XTerm APIs",
description: "When set to false, any experimental/proposed APIs will throw errors.", description: "When set to false, any experimental/proposed APIs will throw errors.",
path: ["allowProposedApi"], path: ["xterm", "allowProposedApi"],
}, },
{ {
type: "boolean", type: "boolean",
name: "Allow Transparent Background", name: "Allow Transparent Background",
description: "Whether the background is allowed to be a non-opaque color.", description: "Whether the background is allowed to be a non-opaque color.",
path: ["allowTransparentBackground"], path: ["xterm", "allowTransparency"],
},
{
type: "boolean",
name: "Alt-Click To Move Cursor",
description: "If enabled, alt + click will move the prompt cursor to the position underneath the mouse.",
path: ["altClickMovesCursor"],
}, },
{ {
type: "text", type: "text",
name: "Bell Sound URI", name: "Bell Sound URI",
description: "URI for a custom bell character sound.", description: "URI for a custom bell character sound.",
path: ["bellSound"], path: ["xterm", "bellSound"],
nullable: true, nullable: true,
}, },
{ {
type: "enum", type: "enum",
name: "Bell Style", name: "Bell Style",
description: "How the terminal will react to the bell character", description: "How the terminal will react to the bell character",
path: ["bellStyle"], path: ["xterm", "bellStyle"],
enum: ["none", "sound"], enum: ["none", "sound"],
}, },
{ {
type: "boolean", type: "boolean",
name: "Force End-Of-Line", name: "Force End-Of-Line",
description: "When enabled, any new-line characters (\\n) will be interpreted as carriage-return new-line. (\\r\\n) Typically this is done by the shell program.", description: "When enabled, any new-line characters (\\n) will be interpreted as carriage-return new-line. (\\r\\n) Typically this is done by the shell program.",
path: ["convertEol"], path: ["xterm", "convertEol"],
}, },
{ {
type: "boolean", type: "boolean",
name: "Disable Stdin", name: "Disable Stdin",
description: "Whether input should be disabled", description: "Whether input should be disabled",
path: ["disableStdin"], path: ["xterm", "disableStdin"],
}, },
{ {
type: "number", type: "number",
name: "Letter Spacing", name: "Letter Spacing",
description: "The spacing in whole pixels between characters.", description: "The spacing in whole pixels between characters.",
path: ["letterSpacing"], path: ["xterm", "letterSpacing"],
}, },
{ {
type: "number", type: "number",
name: "Line Height", name: "Line Height",
description: "Line height, multiplied by the font size to get the height of terminal rows.", description: "Line height, multiplied by the font size to get the height of terminal rows.",
path: ["lineHeight"], path: ["xterm", "lineHeight"],
}, },
{ {
type: "enum", type: "enum",
name: "XTerm Log Level", name: "XTerm Log Level",
description: "Log level for the XTerm library.", description: "Log level for the XTerm library.",
path: ["logLevel"], path: ["xterm", "logLevel"],
enum: ["debug", "info", "warn", "error", "off"], enum: ["debug", "info", "warn", "error", "off"],
}, },
{ {
type: "boolean", type: "boolean",
name: "Macintosh Option Key as Meta Key", name: "Macintosh Option Key as Meta Key",
description: "When enabled, the Option key on Macs will be interpreted as the Meta key.", description: "When enabled, the Option key on Macs will be interpreted as the Meta key.",
path: ["macOptionIsMeta"], path: ["xterm", "macOptionIsMeta"],
}, },
{ {
type: "boolean", type: "boolean",
name: "Macintosh Option Click Forces Selection", name: "Macintosh Option Click Forces Selection",
description: "Whether holding a modifier key will force normal selection behavior, regardless of whether the terminal is in mouse events mode. This will also prevent mouse events from being emitted by the terminal. For example, this allows you to use xterm.js' regular selection inside tmux with mouse mode enabled.", description: "Whether holding a modifier key will force normal selection behavior, regardless of whether the terminal is in mouse events mode. This will also prevent mouse events from being emitted by the terminal. For example, this allows you to use xterm.js' regular selection inside tmux with mouse mode enabled.",
path: ["macOptionClickForcesSelection"], path: ["xterm", "macOptionClickForcesSelection"],
}, },
{ {
type: "number", type: "number",
name: "Forced Contrast Ratio", name: "Forced Contrast Ratio",
description: "Miminum contrast ratio for terminal text. This will alter the foreground color dynamically to ensure the ratio is met. Goes from 1 (do nothing) to 21 (strict black and white).", description: "Miminum contrast ratio for terminal text. This will alter the foreground color dynamically to ensure the ratio is met. Goes from 1 (do nothing) to 21 (strict black and white).",
path: ["minimumContrastRatio"], path: ["xterm", "minimumContrastRatio"],
}, },
{ {
type: "enum", type: "enum",
name: "Renderer Type", name: "Renderer Type",
description: "The terminal renderer to use. Canvas is preferred, but a DOM renderer is also available. Note: Letter spacing and cursor blink do not work in the DOM renderer.", description: "The terminal renderer to use. Canvas is preferred, but a DOM renderer is also available. Note: Letter spacing and cursor blink do not work in the DOM renderer.",
path: ["rendererType"], path: ["xterm", "rendererType"],
enum: ["canvas", "dom"], enum: ["canvas", "dom"],
}, },
{ {
type: "boolean", type: "boolean",
name: "Right Click Selects Words", name: "Right Click Selects Words",
description: "Whether to select the word under the cursor on right click.", description: "Whether to select the word under the cursor on right click.",
path: ["rightClickSelectsWord"], path: ["xterm", "rightClickSelectsWord"],
}, },
{ {
type: "boolean", type: "boolean",
name: "Screen Reader Support", name: "Screen Reader Support",
description: "Whether screen reader support is enabled. When on this will expose supporting elements in the DOM to support NVDA on Windows and VoiceOver on macOS.", description: "Whether screen reader support is enabled. When on this will expose supporting elements in the DOM to support NVDA on Windows and VoiceOver on macOS.",
path: ["screenReaderMode"], path: ["xterm", "screenReaderMode"],
}, },
{ {
type: "number", type: "number",
name: "Tab Stop Width", name: "Tab Stop Width",
description: "The size of tab stops in the terminal.", description: "The size of tab stops in the terminal.",
path: ["tabStopWidth"], path: ["xterm", "tabStopWidth"],
}, },
{ {
type: "boolean", type: "boolean",
name: "Windows Mode", name: "Windows Mode",
description: "\"Whether 'Windows mode' is enabled. Because Windows backends winpty and conpty operate by doing line wrapping on their side, xterm.js does not have access to wrapped lines. When Windows mode is enabled the following changes will be in effect:\n- Reflow is disabled.\n- Lines are assumed to be wrapped if the last character of the line is not whitespace.", description: "\"Whether 'Windows mode' is enabled. Because Windows backends winpty and conpty operate by doing line wrapping on their side, xterm.js does not have access to wrapped lines. When Windows mode is enabled the following changes will be in effect:\n- Reflow is disabled.\n- Lines are assumed to be wrapped if the last character of the line is not whitespace.",
path: ["windowsMode"], path: ["xterm", "windowsMode"],
}, },
{ {
type: "text", type: "text",
name: "Word Separator", name: "Word Separator",
description: "All characters considered word separators. Used for double-click to select word logic. Encoded as JSON in this editor for editing convienience.", description: "All characters considered word separators. Used for double-click to select word logic. Encoded as JSON in this editor for editing convienience.",
path: ["wordSeparator"], path: ["xterm", "wordSeparator"],
json: true, json: true,
} }
]); ]);

40
src/assets/xterm_config/xterm_color_theme.js

@ -2,7 +2,7 @@ const selectionColorOption = {
type: "color", type: "color",
name: "Selection Color", name: "Selection Color",
description: "Background color for selected text. Can be transparent.", description: "Background color for selected text. Can be transparent.",
path: ["theme", "selection"], path: ["xterm", "theme", "selection"],
}; };
const selectionColorOpacityOption = { const selectionColorOpacityOption = {
type: "number", type: "number",
@ -16,25 +16,25 @@ window.inflateOptions([
type: "color", type: "color",
name: "Foreground Color", name: "Foreground Color",
description: "The default foreground (text) color.", description: "The default foreground (text) color.",
path: ["theme", "foreground"], path: ["xterm", "theme", "foreground"],
}, },
{ {
type: "color", type: "color",
name: "Background Color", name: "Background Color",
description: "The default background color.", description: "The default background color.",
path: ["theme", "background"], path: ["xterm", "theme", "background"],
}, },
{ {
type: "color", type: "color",
name: "Cursor Color", name: "Cursor Color",
description: "Color of the cursor.", description: "Color of the cursor.",
path: ["theme", "cursor"], path: ["xterm", "theme", "cursor"],
}, },
{ {
type: "color", type: "color",
name: "Block Cursor Accent Color", name: "Block Cursor Accent Color",
description: "The accent color of the cursor, used as the foreground color for block cursors.", description: "The accent color of the cursor, used as the foreground color for block cursors.",
path: ["theme", "cursorAccent"], path: ["xterm", "theme", "cursorAccent"],
}, },
selectionColorOption, selectionColorOption,
selectionColorOpacityOption, selectionColorOpacityOption,
@ -42,91 +42,91 @@ window.inflateOptions([
type: "color", type: "color",
name: "Black", name: "Black",
description: "Color for ANSI Black text.", description: "Color for ANSI Black text.",
path: ["theme", "black"], path: ["xterm", "theme", "black"],
}, },
{ {
type: "color", type: "color",
name: "Red", name: "Red",
description: "Color for ANSI Red text.", description: "Color for ANSI Red text.",
path: ["theme", "red"], path: ["xterm", "theme", "red"],
}, },
{ {
type: "color", type: "color",
name: "Green", name: "Green",
description: "Color for ANSI Green text.", description: "Color for ANSI Green text.",
path: ["theme", "green"], path: ["xterm", "theme", "green"],
}, },
{ {
type: "color", type: "color",
name: "Yellow", name: "Yellow",
description: "Color for ANSI Yellow text.", description: "Color for ANSI Yellow text.",
path: ["theme", "yellow"], path: ["xterm", "theme", "yellow"],
}, },
{ {
type: "color", type: "color",
name: "Blue", name: "Blue",
description: "Color for ANSI Blue text.", description: "Color for ANSI Blue text.",
path: ["theme", "blue"], path: ["xterm", "theme", "blue"],
}, },
{ {
type: "color", type: "color",
name: "Magenta", name: "Magenta",
description: "Color for ANSI Magenta text.", description: "Color for ANSI Magenta text.",
path: ["theme", "magenta"], path: ["xterm", "theme", "magenta"],
}, },
{ {
type: "color", type: "color",
name: "Cyan", name: "Cyan",
description: "Color for ANSI Cyan text.", description: "Color for ANSI Cyan text.",
path: ["theme", "cyan"], path: ["xterm", "theme", "cyan"],
}, },
{ {
type: "color", type: "color",
name: "White", name: "White",
description: "Color for ANSI White text.", description: "Color for ANSI White text.",
path: ["theme", "white"], path: ["xterm", "theme", "white"],
}, },
{ {
type: "color", type: "color",
name: "Bright Black", name: "Bright Black",
description: "Color for ANSI Bright Black text.", description: "Color for ANSI Bright Black text.",
path: ["theme", "brightBlack"], path: ["xterm", "theme", "brightBlack"],
}, },
{ {
type: "color", type: "color",
name: "Bright Red", name: "Bright Red",
description: "Color for ANSI Bright Red text.", description: "Color for ANSI Bright Red text.",
path: ["theme", "brightRed"], path: ["xterm", "theme", "brightRed"],
}, },
{ {
type: "color", type: "color",
name: "Bright Green", name: "Bright Green",
description: "Color for ANSI Bright Green text.", description: "Color for ANSI Bright Green text.",
path: ["theme", "brightGreen"], path: ["xterm", "theme", "brightGreen"],
}, },
{ {
type: "color", type: "color",
name: "Bright Yellow", name: "Bright Yellow",
description: "Color for ANSI Bright Yellow text.", description: "Color for ANSI Bright Yellow text.",
path: ["theme", "brightYellow"], path: ["xterm", "theme", "brightYellow"],
}, },
{ {
type: "color", type: "color",
name: "Bright Blue", name: "Bright Blue",
description: "Color for ANSI Bright Blue text.", description: "Color for ANSI Bright Blue text.",
path: ["theme", "brightBlue"], path: ["xterm", "theme", "brightBlue"],
}, },
{ {
type: "color", type: "color",
name: "Bright Magenta", name: "Bright Magenta",
description: "Color for ANSI Bright Magenta text.", description: "Color for ANSI Bright Magenta text.",
path: ["theme", "brightMagenta"], path: ["xterm", "theme", "brightMagenta"],
}, },
{ {
type: "color", type: "color",
name: "Bright White", name: "Bright White",
description: "Color for ANSI Bright White text.", description: "Color for ANSI Bright White text.",
path: ["theme", "brightWhite"], path: ["xterm", "theme", "brightWhite"],
} }
]); ]);

2
src/assets/xterm_config/xterm_defaults.js

@ -3,6 +3,7 @@ window.loadOptions({
wetty_fit_terminal: true, wetty_fit_terminal: true,
wetty_void: 0, wetty_void: 0,
xterm: {
cols: 80, cols: 80,
rows: 24, rows: 24,
cursorBlink: false, cursorBlink: false,
@ -65,4 +66,5 @@ window.loadOptions({
brightCyan: "#34e2e2", brightCyan: "#34e2e2",
brightWhite: "#eeeeec" brightWhite: "#eeeeec"
} }
}
}); });

30
src/assets/xterm_config/xterm_general_options.js

@ -3,26 +3,26 @@ window.inflateOptions([
type: "text", type: "text",
name: "Font Family", name: "Font Family",
description: "The font family for terminal text.", description: "The font family for terminal text.",
path: ["fontFamily"], path: ["xterm", "fontFamily"],
}, },
{ {
type: "number", type: "number",
name: "Font Size", name: "Font Size",
description: "The font size in CSS pixels for terminal text.", description: "The font size in CSS pixels for terminal text.",
path: ["fontSize"], path: ["xterm", "fontSize"],
}, },
{ {
type: "enum", type: "enum",
name: "Regular Font Weight", name: "Regular Font Weight",
description: "The font weight for non-bold text.", description: "The font weight for non-bold text.",
path: ["fontWeight"], path: ["xterm", "fontWeight"],
enum: ["normal", "bold", "100", "200", "300", "400", "500", "600", "700", "800", "900"], enum: ["normal", "bold", "100", "200", "300", "400", "500", "600", "700", "800", "900"],
}, },
{ {
type: "enum", type: "enum",
name: "Bold Font Weight", name: "Bold Font Weight",
description: "The font weight for bold text.", description: "The font weight for bold text.",
path: ["fontWeightBold"], path: ["xterm", "fontWeightBold"],
enum: ["normal", "bold", "100", "200", "300", "400", "500", "600", "700", "800", "900"], enum: ["normal", "bold", "100", "200", "300", "400", "500", "600", "700", "800", "900"],
}, },
{ {
@ -35,70 +35,70 @@ window.inflateOptions([
type: "number", type: "number",
name: "Terminal Columns", name: "Terminal Columns",
description: "The number of columns in the terminal. Overridden by the Fit Terminal option.", description: "The number of columns in the terminal. Overridden by the Fit Terminal option.",
path: ["cols"], path: ["xterm", "cols"],
nullable: true, nullable: true,
}, },
{ {
type: "number", type: "number",
name: "Terminal Rows", name: "Terminal Rows",
description: "The number of rows in the terminal. Overridden by the Fit Terminal option.", description: "The number of rows in the terminal. Overridden by the Fit Terminal option.",
path: ["rows"], path: ["xterm", "rows"],
nullable: true, nullable: true,
}, },
{ {
type: "enum", type: "enum",
name: "Cursor Style", name: "Cursor Style",
description: "The style of the cursor", description: "The style of the cursor",
path: ["cursorStyle"], path: ["xterm", "cursorStyle"],
enum: ["block", "underline", "bar"], enum: ["block", "underline", "bar"],
}, },
{ {
type: "boolean", type: "boolean",
name: "Blinking Cursor", name: "Blinking Cursor",
description: "Whether the cursor blinks", description: "Whether the cursor blinks",
path: ["cursorBlink"], path: ["xterm", "cursorBlink"],
}, },
{ {
type: "number", type: "number",
name: "Bar Cursor Width", name: "Bar Cursor Width",
description: "The width of the cursor in CSS pixels. Only applies when Cursor Style is set to 'bar'.", description: "The width of the cursor in CSS pixels. Only applies when Cursor Style is set to 'bar'.",
path: ["cursorWidth"], path: ["xterm", "cursorWidth"],
}, },
{ {
type: "boolean", type: "boolean",
name: "Draw Bold Text In Bright Colors", name: "Draw Bold Text In Bright Colors",
description: "Whether to draw bold text in bright colors", description: "Whether to draw bold text in bright colors",
path: ["drawBoldTextInBrightColors"], path: ["xterm", "drawBoldTextInBrightColors"],
}, },
{ {
type: "number", type: "number",
name: "Scroll Sensitivity", name: "Scroll Sensitivity",
description: "The scroll speed multiplier for regular scrolling.", description: "The scroll speed multiplier for regular scrolling.",
path: ["scrollSensitivity"], path: ["xterm", "scrollSensitivity"],
}, },
{ {
type: "enum", type: "enum",
name: "Fast Scroll Key", name: "Fast Scroll Key",
description: "The modifier key to hold to multiply scroll speed.", description: "The modifier key to hold to multiply scroll speed.",
path: ["fastScrollModifier"], path: ["xterm", "fastScrollModifier"],
enum: ["none", "alt", "shift", "ctrl"], enum: ["none", "alt", "shift", "ctrl"],
}, },
{ {
type: "number", type: "number",
name: "Fast Scroll Multiplier", name: "Fast Scroll Multiplier",
description: "The scroll speed multiplier used for fast scrolling.", description: "The scroll speed multiplier used for fast scrolling.",
path: ["fastScrollSensitivity"], path: ["xterm", "fastScrollSensitivity"],
}, },
{ {
type: "number", type: "number",
name: "Scrollback Rows", name: "Scrollback Rows",
description: "The amount of scrollback rows, rows you can scroll up to after they leave the viewport, to keep.", description: "The amount of scrollback rows, rows you can scroll up to after they leave the viewport, to keep.",
path: ["scrollback"], path: ["xterm", "scrollback"],
}, },
{ {
type: "number", type: "number",
name: "Tab Stop Width", name: "Tab Stop Width",
description: "The size of tab stops in the terminal.", description: "The size of tab stops in the terminal.",
path: ["tabStopWidth"], path: ["xterm", "tabStopWidth"],
}, },
]); ]);

11
src/client/wetty/term/confiruragtion.ts

@ -2,15 +2,16 @@ import _ from 'lodash';
import type { Term } from '../shared/type'; import type { Term } from '../shared/type';
import { copySelected, copyShortcut } from './confiruragtion/clipboard'; import { copySelected, copyShortcut } from './confiruragtion/clipboard';
import { onInput } from './confiruragtion/editor'; import { onInput, setOptions } from './confiruragtion/editor';
import { editor } from '../../shared/elements'; import { editor } from '../../shared/elements';
import { loadOptions } from './confiruragtion/load'; import { loadOptions } from './confiruragtion/load';
export function configureTerm(term: Term): void { export function configureTerm(term: Term): void {
const options = loadOptions(); let options = loadOptions();
Object.entries(options).forEach(([key, value]) => { //Convert old options to new options
term.setOption(key, value); if (!("xterm" in options)) options = { xterm: options };
}); try { setOptions(term, options); } catch {}
const toggle = document.querySelector('#options .toggler'); const toggle = document.querySelector('#options .toggler');
const optionsElem = document.getElementById('options'); const optionsElem = document.getElementById('options');
if (editor == null || toggle == null || optionsElem == null) throw new Error("Couldn't initialize configuration menu"); if (editor == null || toggle == null || optionsElem == null) throw new Error("Couldn't initialize configuration menu");

16
src/client/wetty/term/confiruragtion/editor.ts

@ -5,11 +5,11 @@ export const onInput = (term: Term, updated: any) => {
try { try {
const updatedConf = JSON.stringify(updated, null, 2); const updatedConf = JSON.stringify(updated, null, 2);
if (localStorage.options === updatedConf) return; if (localStorage.options === updatedConf) return;
Object.keys(updated).forEach(key => { setOptions(term, updated);
const value = updated[key]; requestAnimationFrame(() => {
term.setOption(key, value); if (!updated.wetty_fit_terminal && updated.xterm.cols != null && updated.xterm.rows != null) term.resize(updated.xterm.cols, updated.xterm.rows);
});
term.resizeTerm(); term.resizeTerm();
});
// editor.classList.remove('error'); // editor.classList.remove('error');
localStorage.options = updatedConf; localStorage.options = updatedConf;
} catch (e) { } catch (e) {
@ -18,3 +18,11 @@ export const onInput = (term: Term, updated: any) => {
// editor.classList.add('error'); // editor.classList.add('error');
} }
}; };
export function setOptions(term: Term, options: any) {
Object.keys(options.xterm).forEach(key => {
if (key === "cols" || key === "rows") return;
const value = options[key];
term.setOption(key, value);
});
}

4
src/client/wetty/term/confiruragtion/load.ts

@ -1,7 +1,7 @@
import _ from 'lodash'; import _ from 'lodash';
export function loadOptions(): object { export function loadOptions(): any {
const defaultOptions = { fontSize: 14 }; const defaultOptions = { xterm: { fontSize: 14 } };
try { try {
return _.isUndefined(localStorage.options) return _.isUndefined(localStorage.options)
? defaultOptions ? defaultOptions

Loading…
Cancel
Save