-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
draft - add support to .txt files, folder import, ignore in compile
- Loading branch information
1 parent
3c6a52e
commit e2d010b
Showing
9 changed files
with
128 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/components/code_editor/editor_extension/compileline_position.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { EditorView } from "codemirror"; | ||
import { Decoration, ViewPlugin } from "@codemirror/view"; | ||
|
||
|
||
|
||
function CompileLineHighlighter(lineNum: number) { | ||
const currExecLineDeco = Decoration.line({ class: "cm-compileLine-ok" }); | ||
return ViewPlugin.fromClass(class { | ||
public decorations; | ||
|
||
constructor(view: EditorView) { | ||
this.decorations = this.getDeco(view) | ||
} | ||
update(update: any) { | ||
this.decorations = this.getDeco(update.view) | ||
return; | ||
} | ||
getDeco(view: EditorView) { | ||
if (lineNum <= 0 || | ||
view.state.doc.lines < lineNum) { | ||
return Decoration.none; // When we are not running, no line to highlight | ||
} | ||
const execLineStart = view.state.doc.line(lineNum).from; | ||
return Decoration.set([currExecLineDeco.range(execLineStart)]); | ||
} | ||
}, { | ||
decorations: v => v.decorations | ||
} | ||
); | ||
} | ||
|
||
export default CompileLineHighlighter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from "react"; | ||
import ReactCodeMirror, { basicSetup } from "@uiw/react-codemirror"; | ||
|
||
import BC0LightTheme from "./editor_extension/bc0editor_theme"; | ||
import { LoadDocumentPlugin } from "./editor_extension/blank_load"; | ||
import CompileLineHighlighter from "./editor_extension/compileline_position"; | ||
|
||
|
||
// const cc0_compile_line_regex = ; | ||
|
||
|
||
export default class TextEditor extends React.Component<TextEditorProps> | ||
{ | ||
render() { | ||
return <ReactCodeMirror | ||
theme={BC0LightTheme} | ||
basicSetup={false} | ||
onUpdate={(v) => | ||
{ | ||
if (v.docChanged) { | ||
this.props.updateContent(v.state.doc.toString()); | ||
// for (let lineNum = 1; lineNum < v.state.doc.lines; lineNum ++) { | ||
// if (v.state.doc.line(lineNum).text.) | ||
// } | ||
} | ||
} | ||
} | ||
value = {this.props.editorValue} | ||
extensions={[ | ||
basicSetup(), | ||
CompileLineHighlighter(1), | ||
LoadDocumentPlugin(".txt", this.props.updateName) | ||
]} | ||
editable={true} | ||
/> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters