Skip to content

Commit

Permalink
Added clean+restore behaviour
Browse files Browse the repository at this point in the history
Signed-off-by: paulober <[email protected]>
  • Loading branch information
paulober committed Nov 17, 2024
1 parent df9b294 commit 1fdaebe
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 100 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,10 @@
"vscode:uninstall": "node ./dist/vscodeUninstall.mjs",
"vscode:prepublish": "npm run package",
"postinstall": "patch-package && python3 -m pip install -U micropython-rp2-rpi_pico_w-stubs==1.23.* --target ./mpy_stubs --no-user",
"cp-prebuilds": "cp -r node_modules/@serialport/bindings-cpp/prebuilds ./prebuilds",
"compile-uninstaller": "rollup -c uninstall.rollup.config.mjs --environment BUILD:production",
"compile": "rollup -c && npm run compile-uninstaller",
"watch": "rollup -cw",
"watch": "npm run cp-prebuilds && rollup -cw",
"package-local": "rimraf dist && rollup -c --environment BUILD:production --sourcemap hidden && npm run compile-uninstaller",
"package": "rollup -c --environment BUILD:production && npm run compile-uninstaller",
"compile-tests": "tsc -p . --outDir out",
Expand Down
30 changes: 11 additions & 19 deletions src/activator.mts
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,7 @@ export default class Activator {
}

commandExecuting = true;
this.terminal?.clean(true);
this.terminal?.write("\r\n");
this.terminal?.cleanAndStore();
this.ui?.userOperationStarted();
},
(data: Buffer) => {
Expand All @@ -506,9 +505,7 @@ export default class Activator {
this.logger.warn("Failed to execute script on Pico.");
}
commandExecuting = false;
this.terminal?.melt();
this.terminal?.write("\r\n");
this.terminal?.prompt();
this.terminal?.restore();
}
);
context.subscriptions.push(disposable);
Expand Down Expand Up @@ -559,8 +556,7 @@ export default class Activator {
// tells the terminal that it should
// emit input events to relay user input
commandExecuting = true;
this.terminal?.clean(true);
this.terminal?.write("\r\n");
this.terminal?.cleanAndStore();
this.ui?.userOperationStarted();
},
(data: Buffer) => {
Expand All @@ -574,9 +570,7 @@ export default class Activator {
}
this.ui?.userOperationStopped();
commandExecuting = false;
this.terminal?.melt();
this.terminal?.write("\r\n");
this.terminal?.prompt();
this.terminal?.restore();
}
);
context.subscriptions.push(disposable);
Expand Down Expand Up @@ -616,8 +610,7 @@ export default class Activator {
}

commandExecuting = true;
this.terminal?.clean(true);
this.terminal?.write("\r\n");
this.terminal?.cleanAndStore();
this.ui?.userOperationStarted();
},
(data: Buffer) => {
Expand All @@ -634,8 +627,7 @@ export default class Activator {
// const result = data as PyOutCommandResult;
// TODO: reflect result.result in status bar
}
this.terminal?.melt();
this.terminal?.prompt();
this.terminal?.restore();
}
}
);
Expand Down Expand Up @@ -1339,24 +1331,24 @@ export default class Activator {
}

await focusTerminal(this.terminalOptions);
// performing hard reset in orange
this.terminal?.write("\x1b[33mPerforming hard reset...\x1b[0m\r\n");

const result = await PicoMpyCom.getInstance().hardReset(
(open: boolean) => {
if (!open) {
return;
}

commandExecuting = true;
this.terminal?.clean(true);
this.terminal?.write("\r\n");
this.terminal?.cleanAndStore();
this.ui?.userOperationStarted();

// inform user about ongoing operation
this.terminal?.write("\x1b[33mPerforming hard reset...\x1b[0m\r\n");
},
(data: Buffer) => {
this.terminal?.write(data.toString("utf-8"));
}
);
this.terminal?.restore();
commandExecuting = false;
this.ui?.userOperationStopped();
if (result.type === OperationResultType.commandResult) {
Expand Down
Loading

0 comments on commit 1fdaebe

Please sign in to comment.