本文整理汇总了TypeScript中electron.remote.app.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript remote.app.on方法的具体用法?TypeScript remote.app.on怎么用?TypeScript remote.app.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electron.remote.app
的用法示例。
在下文中一共展示了remote.app.on方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: prepareIpc
editor.on('process-attached', () => {
const client = editor.getClient();
client.listRuntimePaths()
.then((rtp: string[]) => {
component_loader.loadFromRTP(rtp);
component_loader.initially_loaded = true;
});
runtime_api.subscribe(client);
element.addEventListener('drop', e => {
e.preventDefault();
const f = e.dataTransfer.files[0];
if (f) {
client.command('edit! ' + f.path);
}
});
remote.app.on('open-file', (e: Event, p: string) => {
e.preventDefault();
client.command('edit! ' + p);
});
prepareIpc(client);
});
示例2: char2nr
editor.on('process-attached', () => {
const client = editor.getClient();
client.listRuntimePaths()
.then((rtp: string[]) => {
component_loader.loadFromRTP(rtp);
component_loader.initially_loaded = true;
});
runtime_api.subscribe(client);
element.addEventListener('drop', e => {
e.preventDefault();
const f = e.dataTransfer.files[0];
if (f) {
client.command('edit! ' + f.path);
}
});
remote.app.on('open-file', (e: Event, p: string) => {
e.preventDefault();
client.command('edit! ' + p);
});
ipc.on('nyaovim:exec-commands', (_: Electron.IpcRendererEvent, cmds: string[]) => {
console.log('ipc: nyaovim:exec-commands', cmds);
for (const c of cmds) {
client.command(c);
}
});
ipc.on('nyaovim:copy', () => {
// get current vim mode
let m = client.eval('mode()');
m.then(obj => {
const value = obj.toString();
if (value.length === 0) {
return;
}
const ch = value[0];
const num = value.charCodeAt(0);
if (ch === 'v' // visual mode
|| ch === 'V' // visual line mode
|| num === 22 // visual block mode. 22 is returned by ':echo char2nr("\<C-v>")'
) {
const command = '"+y';
client.input(command);
}
});
});
ipc.on('nyaovim:select-all', () => {
// get current vim mode.
let m = client.eval('mode()');
m.then(obj => {
const value = obj.toString();
if (value.length === 0) {
return;
}
const command = value[0] === 'n' ? 'ggVG' : '<Esc>ggVG';
client.input(command);
});
});
ipc.on('nyaovim:cut', () => {
// get current vim mode
let m = client.eval('mode()');
m.then(obj => {
const value = obj.toString();
if (value.length === 0) {
return;
}
const ch = value[0];
const num = value.charCodeAt(0);
if (ch === 'v' // visual mode
|| ch === 'V' // visual line mode
|| num === 22 // visual block mode
) {
const command = '"+x';
client.input(command);
}
});
});
ipc.on('nyaovim:paste', () => {
// get current vim mode
let m = client.eval('mode()');
m.then(obj => {
const value = obj.toString();
if (value.length === 0) {
return;
}
let command: string;
const ch = value[0];
const num = value.charCodeAt(0);
if (ch === 'v') {
//.........这里部分代码省略.........