@defasm/codemirror
v1.4.4
Published
CodeMirror 6 extension utilizing DefAssembler
Downloads
469
Readme
DefAssembler - CodeMirror Extension
A CodeMirror 6 extension that highlights Assembly code and assembles it incrementally.
This package uses the DefAssembler core package to generate binary dumps from Assembly code. For a demonstration of the plugin in action, I recommend checking out the GitHub Pages site, or alternatively, the Code Golf editor, where you can also run your programs and submit them to the site.
Usage
The package exports the assembly()
function, which returns an extension that can be added to the editor. The configuration object passed to the function may include the following boolean fields:
byteDumps
- whether to display the results of the assembly on the side of the editordebug
- whether to enable toggling debug mode when pressing F3errorMarking
- whether to draw a red underline beneath segments of code that cause errorserrorTooltips
- whether to show a tooltip on these segments explaining the cause of the errorhighlighting
- whether to enable syntax highlighting using aLanguageSupport
object
By default, all of these fields, except for debug
, are set to true
. Additionally, an assemblyConfig
field may be provided to be passed into the AssemblyState
constructor.
The AssemblyState
object associated with the editor may be accessed through the ASMStateField
state field, as such:
import { assembly, ASMStateField } from "@defasm/codemirror";
new EditorView({
dispatch: tr => {
const result = editor.update([tr]);
const state = editor.state.field(ASMStateField);
byteCount = state.head.length();
return result;
},
state: EditorState.create({ extensions: [assembly()] })
});