Skip to content

Commit c159f33

Browse files
Merge pull request #49 from CaptainUnbrauchbar/release
QoL changes and small bug fixes
2 parents 5ca7d07 + 618e747 commit c159f33

File tree

6 files changed

+33
-10
lines changed

6 files changed

+33
-10
lines changed

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ We added multi-file support with v0.4.0!
1515

1616
## Usage
1717

18-
![](https://github.com/CaptainUnbrauchbar/asp-language-support/blob/release/media/usage-demo.gif)
18+
<img src="https://github.com/CaptainUnbrauchbar/asp-language-support/blob/release/media/usage-demo.gif" height="500" alt="demo-gif"/>
1919

2020
Just right click anywhere on a logic program (.lp) file and select `Compute all Answer Sets`, `Compute the first Answer Set` or `Compute Answer Sets (config.json)`.
2121
This will display Clingo's results in a seperate ASP tab located in the panel. You can also use the buttons in the top right of this tab to run bundled or PATH clingo depending on your `ASPLanguage: Use PATH Clingo` setting.
@@ -32,6 +32,13 @@ See the Clingo [Documentation](https://github.com/potassco/guide/releases/downlo
3232

3333
If you want to use your own Version of Clingo from PATH with this extension, please enable `ASPLanguage: Use PATH Clingo` option in your settings.
3434

35+
## Customization
36+
37+
<img src="https://github.com/CaptainUnbrauchbar/asp-language-support/blob/release/media/customization-demo.gif" height="500" alt="customization-gif"/>
38+
39+
When using the bundled WASM Clingo (Choose in configuration `ASPLanguage: Use PATH Clingo`), you can easily move the panel to the sidebars or change the panel position depending on your preferences.
40+
The layout will adjust accordingly!
41+
3542
## Requirements
3643

3744
For the extension to work properly, please install the Answer Set Programming syntax highlighter by abelcour (abelcour.asp-syntax-highlight)

media/customization-demo.gif

850 KB
Loading

media/main.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ body {
5151
}
5252

5353
.answer-label-box {
54-
width: 30em;
54+
width: 100%;
5555
background-color: var(--vscode-input-border);
5656
color: var(--vscode-input-foreground);
5757
padding: 0.1em 0.1em;

media/main.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
const result = message.answers;
1717
const cfgFile = message.cfgFile;
18+
const useConfig = message.useConfig;
1819

1920
// Create a container for metadata and config boxes
2021
const infoContainer = document.createElement("div");
@@ -36,7 +37,7 @@ Result: ${result.result}
3637
// Append the metadata box to the info container
3738
infoContainer.appendChild(metadataBox);
3839

39-
if (cfgFile) {
40+
if (useConfig) {
4041
// Create a config file output box
4142
const configBox = document.createElement("textarea");
4243
configBox.className = "info-box"; // Reuse the same styling

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "answer-set-programming-language-support",
33
"displayName": "Answer Set Programming Language Support",
4-
"version": "1.0.1",
4+
"version": "1.0.2",
55
"description": "Language Support for Clingo ASP (developed by University of Potsdam).",
66
"publisher": "ffrankreiter",
77
"jest": {

src/extension.js

+21-6
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@ function activate(context) {
121121
*/
122122
async function runBundledClingo(models, useConfig = false) {
123123
let additionalArgs = [];
124+
let cfgFile = [];
124125
// Process config information
125126
if (useConfig) {
126-
const cfgFile = readConfig(setConfig, turnMessagesOff, context.asAbsolutePath(""));
127+
cfgFile = readConfig(setConfig, turnMessagesOff, context.asAbsolutePath(""));
127128
models = cfgFile.find((arg) => arg.startsWith("--models")).split(" ")[1];
128129
additionalArgs = cfgFile.filter((arg) => !arg.startsWith("--models"));
129130
}
@@ -135,6 +136,8 @@ function activate(context) {
135136
provider._view?.webview.postMessage({
136137
type: "updateOutput",
137138
answers,
139+
useConfig,
140+
cfgFile,
138141
});
139142
}
140143

@@ -168,6 +171,7 @@ function activate(context) {
168171
/**
169172
* Function to run Clingo with the given models. It checks if the user has selected a valid file and runs Clingo with the given models.
170173
* @param {Number} models The number of models to run.
174+
* @param {Boolean} useConfig If true, it uses the config file to run Clingo.
171175
* @returns
172176
*/
173177
async function runClingoCommand(models, useConfig = false) {
@@ -187,15 +191,22 @@ function activate(context) {
187191
////////////////////////////////////////////////////////////////////////////////
188192

189193
// Register computeAllSetsCommand command for the extension
190-
const computeAllSetsCommand = vscode.commands.registerCommand(
191-
"answer-set-programming-language-support.runinterminalall",
192-
async () => await runClingoCommand(0, false)
193-
);
194+
const computeAllSetsCommand = vscode.commands.registerCommand("answer-set-programming-language-support.runinterminalall", async () => {
195+
// Focus ASP Tab for easier access to output
196+
vscode.commands.executeCommand("workbench.view.extension.aspContainer");
197+
// Run WASM Clingo
198+
await runClingoCommand(0, false);
199+
});
194200

195201
// Register computeSingleSetCommand command for the extension
196202
const computeSingleSetCommand = vscode.commands.registerCommand(
197203
"answer-set-programming-language-support.runinterminalsingle",
198-
async () => await runClingoCommand(1, false)
204+
async () => {
205+
// Focus ASP Tab for easier access to output
206+
vscode.commands.executeCommand("workbench.view.extension.aspContainer");
207+
// Run WASM Clingo
208+
await runClingoCommand(1, false);
209+
}
199210
);
200211

201212
// Register computeConfigCommand command for the extension
@@ -207,11 +218,15 @@ function activate(context) {
207218
return;
208219
}
209220

221+
// Focus ASP Tab for easier access to output
222+
vscode.commands.executeCommand("workbench.view.extension.aspContainer");
223+
210224
// Create configPath and sanitize it
211225
const configPath = join(dirname(vscode.window.activeTextEditor.document.fileName), setConfig.replace(/^(..(\/|\|$))+/, ""));
212226

213227
// Check if config exists, otherwise ask user if they wants to create a new one
214228
if (fs.existsSync(configPath)) {
229+
// Run WASM Clingo with config file (bool operator)
215230
runClingoCommand(0, true);
216231
} else {
217232
const chosenOption = Promise.resolve(

0 commit comments

Comments
 (0)