not finished
This commit is contained in:
6
packages/vscode/src/fill/css.js
Normal file
6
packages/vscode/src/fill/css.js
Normal file
@ -0,0 +1,6 @@
|
||||
module.exports = function(source) {
|
||||
if (this.resourcePath.endsWith(".ts")) {
|
||||
this.resourcePath = this.resourcePath.replace(".ts", ".css");
|
||||
}
|
||||
return `module.exports = require("${this.resourcePath}");`;
|
||||
};
|
8
packages/vscode/src/fill/native-keymap.ts
Normal file
8
packages/vscode/src/fill/native-keymap.ts
Normal file
@ -0,0 +1,8 @@
|
||||
module.exports = {
|
||||
getCurrentKeyboardLayout: (): null => {
|
||||
return null;
|
||||
},
|
||||
getKeyMap: (): undefined[] => {
|
||||
return [];
|
||||
},
|
||||
};
|
73
packages/vscode/src/fill/node-pty.ts
Normal file
73
packages/vscode/src/fill/node-pty.ts
Normal file
@ -0,0 +1,73 @@
|
||||
import * as cp from "child_process";
|
||||
import { EventEmitter } from "events";
|
||||
import * as nodePty from "node-pty";
|
||||
|
||||
type nodePtyType = typeof nodePty;
|
||||
|
||||
/**
|
||||
* Implementation of nodePty for the browser.
|
||||
*/
|
||||
class Pty implements nodePty.IPty {
|
||||
|
||||
private readonly emitter: EventEmitter;
|
||||
|
||||
public constructor(file: string, args: string[] | string, options: nodePty.IPtyForkOptions) {
|
||||
this.emitter = new EventEmitter();
|
||||
const session = wush.execute({
|
||||
command: `${file} ${Array.isArray(args) ? args.join(" ") : args}`,
|
||||
directory: options.cwd,
|
||||
environment: {
|
||||
...(options.env || {}),
|
||||
TERM: "xterm-color",
|
||||
},
|
||||
size: options && options.cols && options.rows ? {
|
||||
columns: options.cols,
|
||||
rows: options.rows,
|
||||
} : {
|
||||
columns: 100,
|
||||
rows: 100,
|
||||
},
|
||||
});
|
||||
this.on("write", (data) => session.sendStdin(data));
|
||||
this.on("kill", (exitCode) => session.close());
|
||||
this.on("resize", (columns, rows) => session.setSize({ columns, rows }));
|
||||
session.onStdout((data) => this.emitter.emit("data", data));
|
||||
session.onStderr((data) => this.emitter.emit("data", data));
|
||||
session.onDone((exitCode) => this.emitter.emit("exit", exitCode));
|
||||
}
|
||||
|
||||
public get pid(): number {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public get process(): string {
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
public on(event: string, listener: (...args) => void): void {
|
||||
this.emitter.on(event, listener);
|
||||
}
|
||||
|
||||
public resize(columns: number, rows: number): void {
|
||||
this.emitter.emit("resize", columns, rows);
|
||||
}
|
||||
|
||||
public write(data: string): void {
|
||||
this.emitter.emit("write", data);
|
||||
}
|
||||
|
||||
public kill(signal?: string): void {
|
||||
this.emitter.emit("kill", signal);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const ptyType: nodePtyType = {
|
||||
|
||||
spawn: (file: string, args: string[] | string, options: nodePty.IPtyForkOptions): nodePty.IPty => {
|
||||
return new Pty(file, args, options);
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
module.exports = ptyType;
|
Reference in New Issue
Block a user