Skip to content

Commit

Permalink
MML Editor: Disable soft tabs.
Browse files Browse the repository at this point in the history
MML Editor: Add `Show Invisibles` option to show spaces, tabs and CR/LF codes.
  • Loading branch information
okaxaki committed May 25, 2024
1 parent bfaab2d commit 953647e
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 16 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# 1.8.0 (2023/02/03)
# 1.9.0 (2024/05/25)
- MML Editor: Disable soft tabs.
- MML Editor: Add `Show Invisibles` option to show spaces, tabs and CR/LF codes.

# 1.8.0 (2024/02/03)
- Install ServiceWorker so that MSXplay works as a PWA.

# 1.7.5 (2023/12/25)
Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "msxplay-js",
"version": "1.8.0",
"version": "1.9.0",
"description": "",
"type": "module",
"engines": {
Expand Down
9 changes: 9 additions & 0 deletions public/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,15 @@
</select>
</td>
</tr>
<tr>
<td><label for="show-invisibles"><span lang="ja">空白や改行を表示</span><span lang="en">Show Invisibles</span></label></td>
<td>
<select name="show-invisibles" onchange="onShowInvisibleChange(event)">
<option value="true">On</option>
<option value="false">Off</option>
</select>
</td>
</tr>
</table>
</div>
<div class="button-area">
Expand Down
6 changes: 6 additions & 0 deletions public/js/ace-defines.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@
.ace_mgsc .ace_gutter-active-line {
background-color: rgba(0,0,0,0.071);
}
.ace_mgsc .ace_invisible {
color: #bcd;
}
.ace_mgsc .ace_comment {
color: #888;
}
Expand Down Expand Up @@ -379,6 +382,9 @@
.ace_mgsc_dark .ace_gutter-active-line {
background-color: rgba(255,255,255,0.14);
}
.ace_mgsc_dark .ace_invisible {
color: #678;
}
.ace_mgsc_dark .ace_comment {
color: #999;
}
Expand Down
13 changes: 13 additions & 0 deletions public/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ function loadEditorOptions() {
theme: LIGHT_THEME_PATH,
fontSize: 12,
wrap: "free", // "free" | "off"
showInvisibles: false,
};
const options = JSON.parse(window.localStorage.getItem(EDITOR_OPTIONS_KEY) || "{}");
return {
Expand All @@ -144,12 +145,14 @@ function loadEditorOptions() {

function saveEditorOptions() {
const options = editor.getOptions();
console.log(options);
window.localStorage.setItem(
EDITOR_OPTIONS_KEY,
JSON.stringify({
theme: options["theme"],
fontSize: options["fontSize"],
wrap: options["wrap"],
showInvisibles: options["showInvisibles"],
})
);
}
Expand All @@ -164,11 +167,13 @@ function createAceEditor() {
editor.$blockScrolling = Infinity;
editor.getSession().setUseWrapMode(true);
editor.setShowPrintMargin(false);
editor.setDisplayIndentGuides(true);
editor.resize(true);
editor.setOptions({
mode: "ace/mode/mgsc",
useWorker: false,
indentedSoftWrap: false,
useSoftTabs: false,
...loadEditorOptions(),
});
editor.on("change", function () {
Expand Down Expand Up @@ -791,6 +796,8 @@ function openSettings() {
fontSel.value = editor.getOption("fontSize");
const wrapSel = document.querySelector("#settings select[name='wrap']");
wrapSel.value = editor.getOption("wrap");
const showInvisiblesSel = document.querySelector("#settings select[name='show-invisibles']");
showInvisiblesSel.value = editor.getOption("showInvisibles").toString();

showDialog("settings", (value) => {
if (value == "reset") {
Expand Down Expand Up @@ -819,6 +826,12 @@ function onWrapChange(event) {
saveEditorOptions();
}

function onShowInvisibleChange(event) {
const showInvisibles = event.srcElement.value == "true";
editor.setOption("showInvisibles", showInvisibles);
saveEditorOptions();
}

function resetSettings() {
localStorage.removeItem(EDITOR_OPTIONS_KEY);
editor.setOptions(loadEditorOptions());
Expand Down

0 comments on commit 953647e

Please sign in to comment.