Skip to content

Commit

Permalink
Merge pull request #2439 from BetterThanTomorrow/2436-show-output-cha…
Browse files Browse the repository at this point in the history
…nnel

2436 show output channel
  • Loading branch information
PEZ authored Mar 17, 2024
2 parents a153b16 + e29f67c commit 9d0ed09
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changes to Calva.

## [Unreleased]

- [Add command for revealing the **Calva says** output channel](https://github.com/BetterThanTomorrow/calva/issues/2436)
- Fix: [Results not shown inline when output-channel configured is configured as for results output](https://github.com/BetterThanTomorrow/calva/issues/2437)
- [Make the results hover aware of where the results output goes](https://github.com/BetterThanTomorrow/calva/issues/2438)

## [2.0.423] - 2024-03-17

- [Add Output Destinations configuration](https://github.com/BetterThanTomorrow/calva/issues/1104)
Expand Down
7 changes: 7 additions & 0 deletions docs/site/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ When Calva is connected to the REPL, the Output window will by default print not
3. Anything printed to `stdout` and `stderr` by the REPL process

You can control the default via the `calva.redirectServerOutputToRepl` setting. It defaults to `true`. Setting it to `false` before connecting the REPL will result in that **2.** and **3.** will not get printed in the Output window. It will then instead be printed wherever the REPL process is printing its messages, usually the terminal from where it was started (the **Jack-in terminal** if Calva started the REPL).

## Commands for showing output destinations

These are the commands and their default keyboard shortcuts for revealing output destinations

* **Calva: Show/Open the result output destination** - `ctrl+alt+o ctrl+o`
* **Calva: Show/Open the Calva says Output Channel** - `ctrl+alt+o o`
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1908,6 +1908,16 @@
"title": "Open Source File for Current Fiddle File",
"enablement": "calva:activeEditorIsFiddle"
},
{
"category": "Calva",
"command": "calva.showOutputChannel",
"title": "Show/Open the Calva says Output Channel"
},
{
"category": "Calva",
"command": "calva.showResultOutputDestination",
"title": "Show/Open the result output destination"
},
{
"category": "Calva",
"command": "calva.showOutputWindow",
Expand Down Expand Up @@ -2613,6 +2623,16 @@
"key": "ctrl+alt+c f",
"when": "calva:keybindingsEnabled && calva:activeEditorIsFiddle"
},
{
"command": "calva.showResultOutputDestination",
"key": "ctrl+alt+o ctrl+o",
"when": "calva:keybindingsEnabled"
},
{
"command": "calva.showOutputChannel",
"key": "ctrl+alt+o o",
"when": "calva:keybindingsEnabled"
},
{
"command": "calva.showOutputWindow",
"key": "ctrl+alt+o r",
Expand Down
2 changes: 2 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ async function activate(context: vscode.ExtensionContext) {
},
showNextReplHistoryEntry: replHistory.showNextReplHistoryEntry,
showOutputWindow: () => outputWindow.revealResultsDoc(false),
showOutputChannel: output.showOutputChannel,
showResultOutputDestination: output.showResultOutputDestination,
showPreviousReplHistoryEntry: replHistory.showPreviousReplHistoryEntry,
startJoyrideReplAndConnect: async () => {
const projectDir: string = await joyride.prepareForJackingOrConnect();
Expand Down
4 changes: 2 additions & 2 deletions src/providers/annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ function decorateSelection(
JSON.stringify([{ text: resultString }])
)}`,
copyCommandMd = `[Copy](${copyCommandUri} "Copy results to the clipboard")`;
const openWindowCommandUri = `command:calva.showOutputWindow`,
openWindowCommandMd = `[Open Output Window](${openWindowCommandUri} "Open the output window")`;
const openWindowCommandUri = `command:calva.showResultOutputDestination`,
openWindowCommandMd = `[Show Output](${openWindowCommandUri} "Reveal the output destination")`;
const hoverMessage = new vscode.MarkdownString(
`${copyCommandMd} | ${openWindowCommandMd}\n` + '```clojure\n' + resultString + '\n```'
);
Expand Down
14 changes: 13 additions & 1 deletion src/results-output/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ export function initOutputChannel(channel: vscode.OutputChannel) {
outputChannel = channel;
}

export function showOutputChannel() {
outputChannel.show(true);
}

export function showResultOutputDestination() {
if (getDestinationConfiguration().evalResults === 'output-channel') {
return showOutputChannel();
} else {
return outputWindow.revealResultsDoc(true);
}
}

export type OutputDestination = 'repl-window' | 'output-channel';

export type OutputDestinationConfiguration = {
Expand Down Expand Up @@ -56,7 +68,7 @@ function appendClojure(
outputChannel.appendLine(
(didLastTerminateLine ? '' : '\n') + '```clojure\n' + message + '\n```'
);
// TODO: Deal with `after`
after(undefined, undefined);
return;
}
}
Expand Down

0 comments on commit 9d0ed09

Please sign in to comment.