Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
guyutongxue committed Jan 31, 2024
1 parent 541de73 commit 87cf344
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
Run code
</button>
<div class="button-group" id="buildPanelTab">
<button>Input</button>
<button active>Output</button>
<button active>Input</button>
<button>Output</button>
<button>Compiler Diagnostics</button>
</div>
<div class="spacer"></div>
Expand All @@ -30,11 +30,11 @@
</button>
</div>
<textarea
class="io display-none"
class="io"
id="buildPanelInput"
placeholder="Type input here..."
></textarea>
<pre class="io" id="buildPanelOutput"></pre>
<pre class="io display-none" id="buildPanelOutput"></pre>
</div>
</div>
<div id="footer">
Expand Down
5 changes: 5 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ body {
font-family: var(--font-monospace);
overflow: auto;
user-select: text;

.hint {
user-select: none;
color: var(--c-text-light);
}
}

hr {
Expand Down
9 changes: 6 additions & 3 deletions src/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ function showInput() {
inputEl.classList.remove("display-none");
outputEl.classList.add("display-none");
}
const EMPTY_HINT_HTML = `<span style="user-select: none; color: var(--c-text-light)">No output.</span>`;
const EMPTY_HINT_HTML = `<span class="hint">No output.</span>`;
let hasRun = false;
const OUTPUT_HINT_HTML = `<span class="hint">Click "Run code" button to compile and run.</span>`;
const RESULT_COPY_HTML = `
<hr><span style="user-select: none; color: var(--c-text-light)">Compilation provided by <a href="https://godbolt.org" target="_blank">Compiler Explorer</a></span>`;
<hr><span class="hint">Compilation provided by <a href="https://godbolt.org" target="_blank">Compiler Explorer</a></span>`;
function showOutput(text: string) {
if (text === "") {
text = EMPTY_HINT_HTML;
text = hasRun ? EMPTY_HINT_HTML : OUTPUT_HINT_HTML;
}
outputEl.innerHTML = text + RESULT_COPY_HTML;
outputEl.classList.remove("display-none");
Expand Down Expand Up @@ -112,6 +114,7 @@ export async function compileAndRun() {
getEditorValue(),
{ stdin }
));
hasRun = true;
const outputContainer = document.createElement("pre");
const stdoutEl = document.createElement("span");
stdoutEl.innerText = stdout;
Expand Down
6 changes: 6 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ export default defineConfig({
build: {
target: "es2022"
},
server: {
headers: {
"Cross-Origin-Opener-Policy": "same-origin",
"Cross-Origin-Embedder-Policy": "require-corp",
}
},
// https://github.com/CodinGame/monaco-vscode-api?tab=readme-ov-file#if-you-use-vite
optimizeDeps: {
esbuildOptions: {
Expand Down

0 comments on commit 87cf344

Please sign in to comment.