Skip to content

Commit

Permalink
PDF Generation: feature parity with the toolbox
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Ponzi <me@fponzi.me>
  • Loading branch information
FedericoPonzi committed Oct 31, 2024
1 parent 220a265 commit f7b181d
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,31 @@
"maxLength": 1000,
"description": "Command to produce PDFs from .tex files."
},
"tlaplus.pdf.commentsShade": {
"default": true,
"type": "boolean",
"scope": "application",
"description": "If enabled, comments will have a gray background."
},
"tlaplus.pdf.commentsShadeColor": {
"default": 0.85,
"type": "number",
"scope": "application",
"maxLength": 10,
"description": "If comments are shaded in gray, this config changes the darkness of the shading. This must be a number between 0.0 (completely black) and 1.0 (no shading)."
},
"tlaplus.pdf.numberLines": {
"default": false,
"type": "boolean",
"scope": "application",
"description": "Show line numbers in PDFs."
},
"tlaplus.pdf.noPcalShade": {
"default": false,
"type": "boolean",
"scope": "application",
"description": "Causes a PlusCal algorithm (which appear in a comment) not to be shaded. (The algorithm's comments will be shaded.)"
},
"tlaplus.tlaps.enabled": {
"type": "boolean",
"default": false,
Expand Down Expand Up @@ -504,6 +529,7 @@
"vscode:prepublish": "npm run compile -- --production",
"compile": "node ./esbuild.js",
"lint": "eslint --ext .ts,.tsx src/ tests/",
"lint:fix": "eslint --fix --ext .ts,.tsx src/ tests/",
"watch": "npm run compile -- --watch",
"pretest": "tsc -p ./",
"test": "node ./out/tests/runTest.js",
Expand Down
32 changes: 31 additions & 1 deletion src/tla2tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ const CFG_JAVA_OPTIONS = 'tlaplus.java.options';
const CFG_TLC_OPTIONS = 'tlaplus.tlc.modelChecker.options';
const CFG_PLUSCAL_OPTIONS = 'tlaplus.pluscal.options';
const CFG_TLC_OPTIONS_PROMPT = 'tlaplus.tlc.modelChecker.optionsPrompt';
const CFG_TLA_PDF_NUMBER_LINES = 'tlaplus.pdf.numberLines';
const CFG_TLA_PDF_NO_PCAL_SHADE = 'tlaplus.pdf.noPcalShade';
const CFG_TLA_PDF_COMMENTS_SHADE = 'tlaplus.pdf.commentsShade';
const CFG_TLA_PDF_COMMENTS_SHADE_COLOR = 'tlaplus.pdf.commentsShadeColor';

const VAR_TLC_SPEC_NAME = /\$\{specName\}/g;
const VAR_TLC_MODEL_NAME = /\$\{modelName\}/g;
Expand Down Expand Up @@ -102,10 +106,34 @@ export async function runSany(tlaFilePath: string): Promise<ToolProcessInfo> {
}

export async function runTex(tlaFilePath: string): Promise<ToolProcessInfo> {
const shadeComments = vscode.workspace.getConfiguration().get<boolean>(CFG_TLA_PDF_COMMENTS_SHADE, true);
const commentColor = vscode.workspace.getConfiguration().get<number>(CFG_TLA_PDF_COMMENTS_SHADE_COLOR, 0.85);
const numberLines = vscode.workspace.getConfiguration().get<boolean>(CFG_TLA_PDF_NUMBER_LINES, false);
const noPcalShade = vscode.workspace.getConfiguration().get<boolean>(CFG_TLA_PDF_NO_PCAL_SHADE, false);

const toolArgs = ['-metadir',
path.dirname(tlaFilePath),
path.basename(tlaFilePath)];

if (shadeComments) {
toolArgs.unshift('-nops',
'-shade',
'-grayLevel',
commentColor.toString());
}

if (numberLines) {
toolArgs.unshift('-number');
}

if (noPcalShade) {
toolArgs.unshift('-noPcalShade');
}

return runTool(
TlaTool.TEX,
tlaFilePath,
[ path.basename(tlaFilePath) ],
toolArgs,
[]
);
}
Expand Down Expand Up @@ -148,6 +176,8 @@ async function runTool(
toolOptions: string[],
javaOptions: string[]
): Promise<ToolProcessInfo> {
// log the arugments:
//console.log(toolName + ': ' + filePath + ' ' + toolOptions.join(' ') + ' ' + javaOptions.join(' '));
const javaPath = await obtainJavaPath();
// TODO: Merge cfgOptions with javaOptions to avoid complete overrides.
const cfgOptions = getConfigOptions(CFG_JAVA_OPTIONS);
Expand Down
3 changes: 2 additions & 1 deletion src/webview/checkResultView/headerSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export const HeaderSection = React.memo(({checkResult}: HeaderSectionI) => {
<span hidden={checkResult.state !== 'R'}>
(<VSCodeLink onClick={vscode.stopProcess} href="#"> stop </VSCodeLink>)
</span>
<span hidden={ checkResult.statusDetails === undefined || checkResult.statusDetails === null}>: {' ' + checkResult.statusDetails} </span>
<span hidden={ checkResult.statusDetails === undefined

Check warning on line 37 in src/webview/checkResultView/headerSection/index.tsx

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04)

Trailing spaces not allowed

Check warning on line 37 in src/webview/checkResultView/headerSection/index.tsx

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Trailing spaces not allowed
|| checkResult.statusDetails === null}>: {' ' + checkResult.statusDetails} </span>
</div>

<div className="timeInfo"> Start: {checkResult.startDateTimeStr}, end: {checkResult.endDateTimeStr} </div>
Expand Down

0 comments on commit f7b181d

Please sign in to comment.