From 567fcf8fb63bc469ae61013cca511a76eb6f9086 Mon Sep 17 00:00:00 2001
From: nickofolas <60761231+nickofolas@users.noreply.github.com>
Date: Wed, 13 Apr 2022 14:42:07 -0500
Subject: [PATCH] prettier
---
src/ScriptEditor/ui/OptionsModal.tsx | 13 ++--
src/ScriptEditor/ui/ThemeEditorModal.tsx | 38 ++++++----
src/ScriptEditor/ui/themes.ts | 94 ++++++++++++------------
src/Settings/Settings.ts | 2 +-
4 files changed, 79 insertions(+), 68 deletions(-)
diff --git a/src/ScriptEditor/ui/OptionsModal.tsx b/src/ScriptEditor/ui/OptionsModal.tsx
index 65e12db1f..1e0d622f4 100644
--- a/src/ScriptEditor/ui/OptionsModal.tsx
+++ b/src/ScriptEditor/ui/OptionsModal.tsx
@@ -9,8 +9,8 @@ import Select from "@mui/material/Select";
import Switch from "@mui/material/Switch";
import MenuItem from "@mui/material/MenuItem";
import TextField from "@mui/material/TextField";
-import EditIcon from '@mui/icons-material/Edit';
-import SaveIcon from '@mui/icons-material/Save';
+import EditIcon from "@mui/icons-material/Edit";
+import SaveIcon from "@mui/icons-material/Save";
import { ThemeEditorModal } from "./ThemeEditorModal";
@@ -48,10 +48,7 @@ export function OptionsModal(props: IProps): React.ReactElement {
return (
- setThemeEditorOpen(false)}
- />
+ setThemeEditorOpen(false)} />
Theme:
- }>Save
+ }>
+ Save
+
);
}
diff --git a/src/ScriptEditor/ui/ThemeEditorModal.tsx b/src/ScriptEditor/ui/ThemeEditorModal.tsx
index 0bf75ed03..67d2f18d0 100644
--- a/src/ScriptEditor/ui/ThemeEditorModal.tsx
+++ b/src/ScriptEditor/ui/ThemeEditorModal.tsx
@@ -10,8 +10,8 @@ import TextField from "@mui/material/TextField";
import Paper from "@mui/material/Paper";
import IconButton from "@mui/material/IconButton";
import ReplyIcon from "@mui/icons-material/Reply";
-import HistoryIcon from '@mui/icons-material/History';
-import SaveIcon from '@mui/icons-material/Save';
+import HistoryIcon from "@mui/icons-material/History";
+import SaveIcon from "@mui/icons-material/Save";
import { Settings } from "../../Settings/Settings";
import { OptionSwitch } from "../../ui/React/OptionSwitch";
@@ -99,10 +99,13 @@ export function ThemeEditorModal(props: IProps): React.ReactElement {
}
return (
- {
- setThemeCopy(Settings.EditorTheme);
- props.onClose();
- }}>
+ {
+ setThemeCopy(Settings.EditorTheme);
+ props.onClose();
+ }}
+ >
Customize Editor theme
Hover over input boxes for more information
@@ -115,8 +118,8 @@ export function ThemeEditorModal(props: IProps): React.ReactElement {
text="Use light theme as base"
tooltip={
<>
- If enabled, the vs
light theme will be used as the
- theme base, otherwise, vs-dark
will be used.
+ If enabled, the vs
light theme will be used as the theme base, otherwise,{" "}
+ vs-dark
will be used.
>
}
/>
@@ -258,19 +261,26 @@ export function ThemeEditorModal(props: IProps): React.ReactElement {
onChange={onThemeChange}
/>
-
+
+ >
+ Reset to default
+
- )
+ );
}
diff --git a/src/ScriptEditor/ui/themes.ts b/src/ScriptEditor/ui/themes.ts
index f1eceed3b..7b9f63973 100644
--- a/src/ScriptEditor/ui/themes.ts
+++ b/src/ScriptEditor/ui/themes.ts
@@ -53,20 +53,20 @@ export const defaultMonacoTheme: IScriptEditorTheme = {
keyword: "569CD6",
comment: "6A9955",
constant: "569CD6",
- error: "F44747"
+ error: "F44747",
},
ui: {
line: "1E1E1E",
panel: {
bg: "252526",
selected: "252526",
- border: "1E1E1E"
+ border: "1E1E1E",
},
selection: {
- bg: "ADD6FF26"
- }
- }
-}
+ bg: "ADD6FF26",
+ },
+ },
+};
// Regex used for token color validation
// https://github.com/microsoft/vscode/blob/973684056e67153952f495fce93bf50d0ec0b892/src/vs/editor/common/languages/supports/tokenization.ts#L153
@@ -93,122 +93,124 @@ export const sanitizeTheme = (theme: IScriptEditorTheme): void => {
if (!v.match(colorRegExp)) block[k] = "FF0000";
}
}
- }
+ };
repairBlock(v);
}
-}
+};
export function makeTheme(theme: IScriptEditorTheme): any {
const themeRules = [
{
token: "",
background: theme.ui.line,
- foreground: theme.common.fg
+ foreground: theme.common.fg,
},
{
token: "identifier",
- foreground: theme.common.accent
+ foreground: theme.common.accent,
},
{
token: "keyword",
- foreground: theme.syntax.keyword
+ foreground: theme.syntax.keyword,
},
{
token: "string",
- foreground: theme.syntax.string
+ foreground: theme.syntax.string,
},
{
token: "string.escape",
- foreground: theme.syntax.regexp
+ foreground: theme.syntax.regexp,
},
{
token: "comment",
- foreground: theme.syntax.comment
+ foreground: theme.syntax.comment,
},
{
token: "constant",
- foreground: theme.syntax.constant
+ foreground: theme.syntax.constant,
},
{
token: "entity",
- foreground: theme.syntax.entity
+ foreground: theme.syntax.entity,
},
{
token: "type",
- foreground: theme.syntax.tag
+ foreground: theme.syntax.tag,
},
{
token: "tag",
- foreground: theme.syntax.tag
+ foreground: theme.syntax.tag,
},
{
token: "regexp",
- foreground: theme.syntax.regexp
+ foreground: theme.syntax.regexp,
},
{
token: "attribute",
- foreground: theme.syntax.tag
+ foreground: theme.syntax.tag,
},
{
token: "constructor",
- foreground: theme.syntax.markup
+ foreground: theme.syntax.markup,
},
{
token: "invalid",
- foreground: theme.syntax.error
+ foreground: theme.syntax.error,
},
{
token: "number",
- foreground: theme.common.accent
+ foreground: theme.common.accent,
},
{
token: "delimiter",
- foreground: theme.common.fg
+ foreground: theme.common.fg,
},
// Custom tokens
{
token: "ns",
- foreground: theme.syntax.tag
+ foreground: theme.syntax.tag,
},
{
token: "netscriptfunction",
- foreground: theme.syntax.markup
+ foreground: theme.syntax.markup,
},
{
token: "otherkeywords",
- foreground: theme.syntax.keyword
+ foreground: theme.syntax.keyword,
},
{
token: "otherkeyvars",
- foreground: theme.common.accent
+ foreground: theme.common.accent,
},
{
token: "this",
- foreground: theme.syntax.tag
- }
+ foreground: theme.syntax.tag,
+ },
];
- const themeColors = Object.fromEntries([
- ["editor.background", theme.common.bg],
- ["editor.foreground", theme.common.fg],
- ["editor.lineHighlightBackground", theme.ui.line],
- ["editor.selectionBackground", theme.ui.selection.bg],
+ const themeColors = Object.fromEntries(
+ [
+ ["editor.background", theme.common.bg],
+ ["editor.foreground", theme.common.fg],
+ ["editor.lineHighlightBackground", theme.ui.line],
+ ["editor.selectionBackground", theme.ui.selection.bg],
- ["editorSuggestWidget.background", theme.ui.panel.bg],
- ["editorSuggestWidget.border", theme.ui.panel.border],
- ["editorSuggestWidget.selectedBackground", theme.ui.panel.selected],
+ ["editorSuggestWidget.background", theme.ui.panel.bg],
+ ["editorSuggestWidget.border", theme.ui.panel.border],
+ ["editorSuggestWidget.selectedBackground", theme.ui.panel.selected],
- ["editorHoverWidget.background", theme.ui.panel.bg],
- ["editorHoverWidget.border", theme.ui.panel.border],
+ ["editorHoverWidget.background", theme.ui.panel.bg],
+ ["editorHoverWidget.border", theme.ui.panel.border],
- ["editorWidget.background", theme.ui.panel.bg],
- ["editorWidget.border", theme.ui.panel.border],
+ ["editorWidget.background", theme.ui.panel.bg],
+ ["editorWidget.border", theme.ui.panel.border],
- ["input.background", theme.ui.panel.bg],
- ["input.border", theme.ui.panel.border]
- ].map(([k, v]) => [k, "#" + v]));
+ ["input.background", theme.ui.panel.bg],
+ ["input.border", theme.ui.panel.border],
+ ].map(([k, v]) => [k, "#" + v]),
+ );
- return { base: theme.base, inherit: theme.inherit, rules: themeRules, colors: themeColors }
+ return { base: theme.base, inherit: theme.inherit, rules: themeRules, colors: themeColors };
}
export async function loadThemes(monaco: { editor: any }): Promise {
diff --git a/src/Settings/Settings.ts b/src/Settings/Settings.ts
index 202f49fcd..c8d1cfd0c 100644
--- a/src/Settings/Settings.ts
+++ b/src/Settings/Settings.ts
@@ -266,7 +266,7 @@ export const Settings: ISettings & ISelfInitializer & ISelfLoading = {
MonacoFontSize: 20,
MonacoVim: false,
MonacoWordWrap: "off",
-
+
theme: { ...defaultTheme },
styles: { ...defaultStyles },
overview: defaultSettings.overview,