Skip to content

Commit

Permalink
put output channel button in cell toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Donham committed Jun 21, 2024
1 parent debbe42 commit 6e918c6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ tried it.

Standard output and error streams are captured when running cells and sent to a
per-cell output channel. Press the ![output](./assets/CodiconOutput.svg) button
in the cell status bar to view the channel.
in the cell toolbar to view the channel.

## Environment variables

Expand Down
14 changes: 13 additions & 1 deletion packages/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
"category": "Vitale",
"icon": "$(open-preview)",
"enablement": "notebookType == 'vitale-notebook' && notebookCellHasOutputs"
},
{
"title": "Show cell output channel",
"command": "vitale.showCellOutputChannel",
"category": "Vitale",
"icon": "$(output)",
"enablement": "notebookType == 'vitale-notebook'"
}
],
"menus": {
Expand All @@ -54,8 +61,13 @@
"notebook/cell/title": [
{
"command": "vitale.viewCellOutputInPane",
"group": "inline/cell",
"group": "inline/cell@1",
"when": "notebookType == 'vitale-notebook' && notebookCellHasOutputs"
},
{
"command": "vitale.showCellOutputChannel",
"group": "inline/cell@2",
"when": "notebookType == 'vitale-notebook'"
}
]
},
Expand Down
14 changes: 0 additions & 14 deletions packages/vscode/src/cellStatusBarItemProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,6 @@ export class NotebookCellStatusBarItemProvider
};
items.push(pauseItem);

// TODO(jaked)
// it would be nice to show this only if there is any output
const stdoutItem = new vscode.NotebookCellStatusBarItem(
"$(output)",
vscode.NotebookCellStatusBarAlignment.Right
);
stdoutItem.tooltip = "Stdout";
stdoutItem.command = {
title: "Show stdout",
command: "vitale.showStdout",
arguments: [cell],
};
items.push(stdoutItem);

return items;
}
}
7 changes: 5 additions & 2 deletions packages/vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { makeHandleDidChangeNotebookDocument } from "./handleDidChangeNotebookDo
import { makeHandleDidChangeNotebookEditorSelection } from "./handleDidChangeNotebookEditorSelection";
import { handleDidChangeTextDocument } from "./handleDidChangeTextDocument";
import { pauseCell } from "./pauseCell";
import { showStdout } from "./showStdout";
import { showCellOutputChannel } from "./showCellOutputChannel";
import { NotebookSerializer } from "./serializer";
import { CellOutputPanes } from "./cellOutputPanes";

Expand Down Expand Up @@ -34,7 +34,10 @@ export function activate(context: vscode.ExtensionContext) {
vscode.env.clipboard.writeText(s);
}),
vscode.commands.registerCommand("vitale.pauseCell", pauseCell),
vscode.commands.registerCommand("vitale.showStdout", showStdout),
vscode.commands.registerCommand(
"vitale.showCellOutputChannel",
showCellOutputChannel
),
vscode.commands.registerCommand(
"vitale.viewCellOutputInPane",
cellOutputPanes.makeViewCellOutputInPane()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as vscode from "vscode";

export const showStdout = async (cell: vscode.NotebookCell) => {
export const showCellOutputChannel = async (cell?: vscode.NotebookCell) => {
if (!cell) {
return;
}
const name = `${cell.notebook.uri.fsPath}-${cell.metadata.id}-stdout`;
const channel = vscode.window.createOutputChannel(name, { log: true });
channel.show(/* preserveFocus: */ true);
Expand Down

0 comments on commit 6e918c6

Please sign in to comment.