-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Atom additions for editing #5
Comments
I was thinking about an alternate route we could discuss: maybe we could store the cursor position in the original text, and Atom could have some way of mapping between original text and its' internal contents? Consider that:
Our hypothetical Also this would solve the navigation problem: having a complex |
Having said all of this, I don't think that initial idea from the OP is bad. But I'm not sure if we want to add all the editor stuff to this library in such a way. Consider that every math rendering library will now need to support this I'd recommend to add an extendable mechanism that will be useful for everyone, no matter if they're editing math or rendering it or whatever. Probably let's add some "tags" to our atoms? E.g. type TaggedAtom<'a> = { atom : Atom; tag : 'a } Allow the user to add their own "tags" to atoms and add extension points to the renderer, so the user code is able to analyze the tags and instruct the renderer accordingly. Something like this: type MyAtomState = Rendered | InputSquare | Selected
type MyMathEditorAtom = TaggedAtom<MyState>
let myRenderer =
let baseRenderer = MathAtom.createRenderer<MyAtomState>()
{ baseRenderer with
getBackground = fun (a : TaggedAtom) -> match a.tag with
| Rendered -> baseRenderer.getBackground a
| InputSquare -> Color.Red
| Selected -> Color.Blue } (that's just a quick sample, I'm not sure what actual extension points would be) |
I don't think we should retain LaTeX because:
|
We are supporting 2 rendering libraries, which may become 1 in future. Options for differing feature support between wpf-math and csharpmath:
|
@charlesroddie Support 3. type MathListIndex =
member val AtomIndex = 0 with get, set
member val SubIndex : MathListIndex option with get, set
member val SubIndexType : MathListSubIndexType with get, set
type MathListSubIndexType =
| None
/// The position in the subindex is an index into the nucleus
| Nucleus
/// The subindex indexes into the superscript.
| Superscript
/// The subindex indexes into the subscript
| Subscript
/// The subindex indexes into the numerator (only valid for fractions)
| Numerator
/// The subindex indexes into the denominator (only valid for fractions)
| Denominator
/// The subindex indexes into the radicand (only valid for radicals)
| Radicand
/// The subindex indexes into the degree (only valid for radicals)
| Degree |
We could put extra cases inside the Atom type:
Alternatively we could make separate Atom from cursor position / selection:
@Happypig375 thoughts appreciated as you work on the MathEditor port.
I think the first approach will be much cleaner. In the simplest implementation it may not be the most performant as l/r/u/d moves would lead to laying out everything again, but as long as it takes << 1/60 s to process a change we don't need to worry.
The text was updated successfully, but these errors were encountered: