本文整理匯總了TypeScript中xterm.Terminal.focus方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Terminal.focus方法的具體用法?TypeScript Terminal.focus怎麽用?TypeScript Terminal.focus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類xterm.Terminal
的用法示例。
在下文中一共展示了Terminal.focus方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: Terminal
namespace static_methods {
{
Terminal.applyAddon({});
Terminal.applyAddon({});
Terminal.applyAddon({});
Terminal.applyAddon({});
Terminal.applyAddon({});
Terminal.applyAddon({});
}
}
namespace methods_core {
{
const t: Terminal = new Terminal();
t.blur();
t.focus();
t.destroy();
t.clear();
t.refresh(0, 1);
t.reset();
t.resize(1, 1);
t.write('foo');
t.writeln('foo');
}
{
const t: Terminal = new Terminal();
// no arg
t.on('blur', () => {});
t.on('focus', () => {});
t.on('linefeed', () => {});
t.on('selection', () => {});
示例2: Terminal
socket.on('connect', () => {
const term = new Terminal();
term.open(document.getElementById('terminal'));
const defaultOptions = { fontSize: 14 };
let options: any;
try {
if (localStorage.options === undefined) {
options = defaultOptions;
} else {
options = JSON.parse(localStorage.options);
}
} catch {
options = defaultOptions;
}
Object.keys(options).forEach(key => {
const value = options[key];
term.setOption(key, value);
});
const code = JSON.stringify(options, null, 2);
const editor = document.querySelector('#options .editor');
editor.value = code;
editor.addEventListener('keyup', e => {
try {
const updated = JSON.parse(editor.value);
const updatedCode = JSON.stringify(updated, null, 2);
editor.value = updatedCode;
editor.classList.remove('error');
localStorage.options = updatedCode;
Object.keys(updated).forEach(key => {
const value = updated[key];
term.setOption(key, value);
});
resize();
} catch {
// skip
editor.classList.add('error');
}
});
document.getElementById('overlay').style.display = 'none';
document.querySelector('#options .toggler').addEventListener('click', e => {
document.getElementById('options').classList.toggle('opened');
e.preventDefault();
});
window.addEventListener('beforeunload', handler, false);
/*
term.scrollPort_.screen_.setAttribute('contenteditable', 'false');
*/
term.attachCustomKeyEventHandler(e => {
// Ctrl + Shift + C
if (e.ctrlKey && e.shiftKey && e.keyCode === 67) {
e.preventDefault();
document.execCommand('copy');
return false;
}
return true;
});
function resize(): void {
fit(term);
socket.emit('resize', { cols: term.cols, rows: term.rows });
}
window.onresize = resize;
resize();
term.focus();
function kill(data: string): void {
disconnect(data);
}
term.on('data', data => {
socket.emit('input', data);
});
term.on('resize', size => {
socket.emit('resize', size);
});
socket
.on('data', (data: string) => {
term.write(data);
})
.on('login', () => {
term.writeln('');
resize();
})
.on('logout', kill)
.on('disconnect', kill)
.on('error', (err: string | null) => {
if (err) disconnect(err);
});
});