summaryrefslogtreecommitdiff
path: root/extension/src/terminal/terminalEmulator.ts
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-05-23 23:45:12 -0400
committerNate Sesti <sestinj@gmail.com>2023-05-23 23:45:12 -0400
commitf53768612b1e2268697b5444e502032ef9f3fb3c (patch)
tree4ed49b73e6bd3c2f8fceffa9643973033f87af95 /extension/src/terminal/terminalEmulator.ts
downloadsncontinue-f53768612b1e2268697b5444e502032ef9f3fb3c.tar.gz
sncontinue-f53768612b1e2268697b5444e502032ef9f3fb3c.tar.bz2
sncontinue-f53768612b1e2268697b5444e502032ef9f3fb3c.zip
copying from old repo
Diffstat (limited to 'extension/src/terminal/terminalEmulator.ts')
-rw-r--r--extension/src/terminal/terminalEmulator.ts140
1 files changed, 140 insertions, 0 deletions
diff --git a/extension/src/terminal/terminalEmulator.ts b/extension/src/terminal/terminalEmulator.ts
new file mode 100644
index 00000000..ba860b24
--- /dev/null
+++ b/extension/src/terminal/terminalEmulator.ts
@@ -0,0 +1,140 @@
+// /* Terminal emulator - commented because node-pty is causing problems. */
+
+// import * as vscode from "vscode";
+// import pty = require("node-pty");
+// import os = require("os");
+// import { extensionContext } from "../activation/activate";
+// import { debugPanelWebview } from "../debugPanel"; // Need to consider having multiple panels, where to store this state.
+// import {
+// CommandCaptureSnooper,
+// PythonTracebackSnooper,
+// TerminalSnooper,
+// } from "./snoopers";
+
+// export function tracebackToWebviewAction(traceback: string) {
+// if (debugPanelWebview) {
+// debugPanelWebview.postMessage({
+// type: "traceback",
+// value: traceback,
+// });
+// } else {
+// vscode.commands
+// .executeCommand("continue.openDebugPanel", extensionContext)
+// .then(() => {
+// // TODO: Waiting for the webview to load, but should add a hook to the onLoad message event. Same thing in autodebugTest command in commands.ts
+// setTimeout(() => {
+// debugPanelWebview?.postMessage({
+// type: "traceback",
+// value: traceback,
+// });
+// }, 500);
+// });
+// }
+// }
+
+// const DEFAULT_SNOOPERS = [
+// new PythonTracebackSnooper(tracebackToWebviewAction),
+// new CommandCaptureSnooper((data: string) => {
+// if (data.trim().startsWith("pytest ")) {
+// let fileAndFunctionSpecifier = data.split(" ")[1];
+// vscode.commands.executeCommand(
+// "continue.debugTest",
+// fileAndFunctionSpecifier
+// );
+// }
+// }),
+// ];
+
+// // Whenever a user opens a terminal, replace it with ours
+// vscode.window.onDidOpenTerminal((terminal) => {
+// if (terminal.name != "Continue") {
+// terminal.dispose();
+// openCapturedTerminal();
+// }
+// });
+
+// function getDefaultShell(): string {
+// if (process.platform !== "win32") {
+// return os.userInfo().shell;
+// }
+// switch (process.platform) {
+// case "win32":
+// return process.env.COMSPEC || "cmd.exe";
+// // case "darwin":
+// // return process.env.SHELL || "/bin/zsh";
+// // default:
+// // return process.env.SHELL || "/bin/sh";
+// }
+// }
+
+// function getRootDir(): string | undefined {
+// var isWindows = os.platform() === "win32";
+// let cwd = isWindows ? process.env.USERPROFILE : process.env.HOME;
+// if (
+// vscode.workspace.workspaceFolders &&
+// vscode.workspace.workspaceFolders.length > 0
+// ) {
+// cwd = vscode.workspace.workspaceFolders[0].uri.fsPath;
+// }
+// return cwd;
+// }
+
+// export function openCapturedTerminal(
+// snoopers: TerminalSnooper<string>[] = DEFAULT_SNOOPERS
+// ) {
+// // If there is another existing, non-Continue terminal, delete it
+// let terminals = vscode.window.terminals;
+// for (let i = 0; i < terminals.length; i++) {
+// if (terminals[i].name != "Continue") {
+// terminals[i].dispose();
+// }
+// }
+
+// let env = { ...(process.env as any) };
+// if (os.platform() !== "win32") {
+// env["PATH"] += ":" + ["/opt/homebrew/bin", "/opt/homebrew/sbin"].join(":");
+// }
+
+// var ptyProcess = pty.spawn(getDefaultShell(), [], {
+// name: "xterm-256color",
+// cols: 160, // TODO: Get size of vscode terminal, and change with resize
+// rows: 26,
+// cwd: getRootDir(),
+// env,
+// useConpty: true,
+// });
+
+// const writeEmitter = new vscode.EventEmitter<string>();
+
+// ptyProcess.onData((data: any) => {
+// // Let each of the snoopers see the new data
+// for (let snooper of snoopers) {
+// snooper.onData(data);
+// }
+
+// // Pass data through to terminal
+// writeEmitter.fire(data);
+// });
+// process.on("exit", () => ptyProcess.kill());
+
+// const newPty: vscode.Pseudoterminal = {
+// onDidWrite: writeEmitter.event,
+// open: () => {},
+// close: () => {},
+// handleInput: (data) => {
+// for (let snooper of snoopers) {
+// snooper.onWrite(data);
+// }
+// ptyProcess.write(data);
+// },
+// };
+// const terminal = vscode.window.createTerminal({
+// name: "Continue",
+// pty: newPty,
+// });
+// terminal.show();
+
+// setTimeout(() => {
+// ptyProcess.write("clear\r");
+// }, 500);
+// }