From 55b2cbb549e29fddd10fb2bfd87463b85e82b865 Mon Sep 17 00:00:00 2001
From: quacksouls <66396308+quacksouls@users.noreply.github.com>
Date: Fri, 4 Nov 2022 22:23:33 +1100
Subject: [PATCH] UI: `cat`: proper line breaks when showing .js, .script, or
.txt files (#192)
Currently, the HTML line break sequence `
` is hardcoded into the dialog box message when showing the content of these file types: ".js", ".script", and ".txt". By default, the function `dialogBoxCreate()` currently assumes that its first parameter is not HTML, but a text string, so whatever is in the string will appear in the dialog box. Use the newline character instead for line break.
---
src/Terminal/commands/cat.ts | 2 +-
src/TextFile.ts | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Terminal/commands/cat.ts b/src/Terminal/commands/cat.ts
index 0807e8a84..a108662f0 100644
--- a/src/Terminal/commands/cat.ts
+++ b/src/Terminal/commands/cat.ts
@@ -49,7 +49,7 @@ export function cat(args: (string | number | boolean)[], server: BaseServer): vo
} else if (filename.endsWith(".script") || filename.endsWith(".js")) {
const script = Terminal.getScript(relative_filename);
if (script != null) {
- dialogBoxCreate(`${script.filename}
${script.code}`);
+ dialogBoxCreate(`${script.filename}\n\n${script.code}`);
return;
}
}
diff --git a/src/TextFile.ts b/src/TextFile.ts
index 673c9e35c..5ce2a9adc 100644
--- a/src/TextFile.ts
+++ b/src/TextFile.ts
@@ -54,7 +54,7 @@ export class TextFile {
/** Shows the content to the user via the game's dialog box. */
show(): void {
- dialogBoxCreate(`${this.fn}
${this.text}`);
+ dialogBoxCreate(`${this.fn}\n\n${this.text}`);
}
/** Serialize the current file to a JSON save state. */