8 changed files with 31 additions and 18 deletions
@ -1,28 +1,26 @@ |
|||||
import type { Term } from '../../shared/type'; |
import type { Term } from '../../shared/type'; |
||||
// import { editor } from '../../../shared/elements';
|
import { editor } from '../../../shared/elements'; |
||||
|
|
||||
export const onInput = (term: Term, updated: any) => { |
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; |
||||
setOptions(term, updated); |
setOptions(term, updated); |
||||
requestAnimationFrame(() => { |
if (!updated.wetty_fit_terminal && updated.xterm.cols != null && updated.xterm.rows != null) term.resize(updated.xterm.cols, updated.xterm.rows); |
||||
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) { |
||||
|
console.error("Configuration Error"); |
||||
console.error(e); |
console.error(e); |
||||
// skip
|
editor.classList.add('error'); |
||||
// editor.classList.add('error');
|
|
||||
} |
} |
||||
}; |
}; |
||||
|
|
||||
export function setOptions(term: Term, options: any) { |
export function setOptions(term: Term, options: any) { |
||||
Object.keys(options.xterm).forEach(key => { |
Object.keys(options.xterm).forEach(key => { |
||||
if (key === "cols" || key === "rows") return; |
if (key === "cols" || key === "rows") return; |
||||
const value = options[key]; |
const value = options.xterm[key]; |
||||
term.setOption(key, value); |
term.setOption(key, value); |
||||
}); |
}); |
||||
} |
} |
||||
|
Loading…
Reference in new issue