mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-21 00:32:51 +02:00
EDITOR: changed editor tabs to have their own editor mode (#1372)
This commit is contained in:
@@ -12,16 +12,25 @@ export class OpenScript {
|
||||
hostname: string;
|
||||
lastPosition: Position;
|
||||
model: ITextModel;
|
||||
vimMode: boolean;
|
||||
isTxt: boolean;
|
||||
// TODO: Adding actual external update notifications for the OpenScript class
|
||||
// hasExternalUpdate = false;
|
||||
|
||||
constructor(path: ContentFilePath, code: string, hostname: string, lastPosition: Position, model: ITextModel) {
|
||||
constructor(
|
||||
path: ContentFilePath,
|
||||
code: string,
|
||||
hostname: string,
|
||||
lastPosition: Position,
|
||||
model: ITextModel,
|
||||
vimMode: boolean,
|
||||
) {
|
||||
this.path = path;
|
||||
this.code = code;
|
||||
this.hostname = hostname;
|
||||
this.lastPosition = lastPosition;
|
||||
this.model = model;
|
||||
this.vimMode = vimMode;
|
||||
this.isTxt = hasTextExtension(path);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ export interface Options {
|
||||
fontSize: number;
|
||||
fontLigatures: boolean;
|
||||
wordWrap: WordWrapOptions;
|
||||
vim: boolean;
|
||||
cursorStyle: CursorStyle;
|
||||
cursorBlinking: CursorBlinking;
|
||||
}
|
||||
|
||||
@@ -93,11 +93,6 @@ export function OptionsModal(props: OptionsModalProps): ReactElement {
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div style={{ display: "flex", alignItems: "center" }}>
|
||||
<Typography marginRight={"auto"}>Enable vim mode: </Typography>
|
||||
<Switch onChange={(e) => props.onOptionChange("vim", e.target.checked)} checked={props.options.vim} />
|
||||
</div>
|
||||
|
||||
<div style={{ display: "flex", alignItems: "center" }}>
|
||||
<Typography marginRight={"auto"}>Font family: </Typography>
|
||||
<TextField
|
||||
|
||||
@@ -26,7 +26,7 @@ export interface ScriptEditorContextShape {
|
||||
|
||||
const ScriptEditorContext = React.createContext({} as ScriptEditorContextShape);
|
||||
|
||||
export function ScriptEditorContextProvider({ children, vim }: { children: React.ReactNode; vim: boolean }) {
|
||||
export function ScriptEditorContextProvider({ children }: { children: React.ReactNode }) {
|
||||
const [ram, setRAM] = useState("RAM: ???");
|
||||
const [ramEntries, setRamEntries] = useState<string[][]>([["???", ""]]);
|
||||
|
||||
@@ -76,7 +76,6 @@ export function ScriptEditorContextProvider({ children, vim }: { children: React
|
||||
fontSize: Settings.MonacoFontSize,
|
||||
fontLigatures: Settings.MonacoFontLigatures,
|
||||
wordWrap: Settings.MonacoWordWrap,
|
||||
vim: vim || Settings.MonacoVim,
|
||||
cursorStyle: Settings.MonacoCursorStyle,
|
||||
cursorBlinking: Settings.MonacoCursorBlinking,
|
||||
});
|
||||
@@ -93,7 +92,6 @@ export function ScriptEditorContextProvider({ children, vim }: { children: React
|
||||
Settings.MonacoCursorStyle = options.cursorStyle;
|
||||
Settings.MonacoCursorBlinking = options.cursorBlinking;
|
||||
Settings.MonacoWordWrap = options.wordWrap;
|
||||
Settings.MonacoVim = options.vim;
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -44,7 +44,7 @@ function Root(props: IProps): React.ReactElement {
|
||||
const rerender = useRerender();
|
||||
const editorRef = useRef<IStandaloneCodeEditor | null>(null);
|
||||
|
||||
const { options, updateRAM, startUpdatingRAM, finishUpdatingRAM } = useScriptEditorContext();
|
||||
const { updateRAM, startUpdatingRAM, finishUpdatingRAM } = useScriptEditorContext();
|
||||
|
||||
let decorations: monaco.editor.IEditorDecorationsCollection | undefined;
|
||||
|
||||
@@ -194,6 +194,7 @@ function Root(props: IProps): React.ReactElement {
|
||||
props.hostname,
|
||||
new monaco.Position(0, 0),
|
||||
makeModel(props.hostname, filename, code),
|
||||
props.vim,
|
||||
);
|
||||
openScripts.push(newScript);
|
||||
currentScript = newScript;
|
||||
@@ -375,7 +376,7 @@ function Root(props: IProps): React.ReactElement {
|
||||
|
||||
const { statusBarRef } = useVimEditor({
|
||||
editor: editorRef.current,
|
||||
vim: options.vim,
|
||||
vim: currentScript !== null ? currentScript.vimMode : props.vim,
|
||||
onSave: save,
|
||||
onOpenNextTab,
|
||||
onOpenPreviousTab,
|
||||
@@ -423,7 +424,7 @@ function Root(props: IProps): React.ReactElement {
|
||||
// Called every time script editor is opened
|
||||
export function ScriptEditorRoot(props: IProps) {
|
||||
return (
|
||||
<ScriptEditorContextProvider vim={props.vim}>
|
||||
<ScriptEditorContextProvider>
|
||||
<Root {...props} />
|
||||
</ScriptEditorContextProvider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user