import * as vscode from 'vscode'; import * as child_process from 'child_process'; import documentclass_symbols from '../dictionary/documentclass_symbols'; import { window } from 'vscode'; export default { // pdflatex -synctex=1 -interaction=nonstopmode -output-directory="$FILEDIRNAME" "$FILE" > ~/.vscode/.pdflatex_log latex_pdflatex: function latex_pdflatex(textEditor: vscode.TextEditor, textEditorEdit: vscode.TextEditorEdit): void { var document: vscode.TextDocument = textEditor.document; var fileDir: string = document.fileName.substring(0, document.fileName.lastIndexOf('/')); document.save(); // save the document before compile child_process.exec( "pdflatex -synctex=1 -interaction=nonstopmode -output-directory=" + fileDir + " " + document.fileName, { cwd: fileDir }, // set the working directory (error: Error, stdout: string, stderr: string) => { if (error) { vscode.window.showErrorMessage("pdflatex Failed: " + error.message + ", " + stdout); } else { vscode.window.setStatusBarMessage("Created File: " + document.fileName.replace('.tex', '.pdf'), 5000); } } ); }, latex_makeindex: function latex_makeindex(textEditor: vscode.TextEditor, textEditorEdit: vscode.TextEditorEdit): void { var document: vscode.TextDocument = textEditor.document; var fileDir: string = document.fileName.substring(0, document.fileName.lastIndexOf('/')); textEditor.document.save(); // save the document before makeindex child_process.exec( "makeindex " + document.fileName.substring(0, document.fileName.lastIndexOf('.')) + ".idx", { cwd: fileDir }, // set the working directory (error: Error, stdout: string, stderr: string) => { if (error) { vscode.window.showErrorMessage("makeindex Failed: " + error.stack + ", " + stdout); } else { vscode.window.setStatusBarMessage("Index Created:", 5000); } } ); }, latex_cleanup: function latex_cleanup(textEditor: vscode.TextEditor, textEditorEdit: vscode.TextEditorEdit): void { var document: vscode.TextDocument = textEditor.document; var fileDir: string = document.fileName.substring(0, document.fileName.lastIndexOf('/')); child_process.execFile( "./scripts/cleanup.sh", [ fileDir ], { cwd: this.extensionPath }, // set the working directory (error: Error, stdout: string, stderr: string) => { if (error) { vscode.window.showErrorMessage("cleanup Failed: " + error.message + ", " + stdout); } else { vscode.window.showInformationMessage(stdout); } } ); } }