xaml-math icon indicating copy to clipboard operation
xaml-math copied to clipboard

Refactor C#-defined command system

Open ForNeVeR opened this issue 5 years ago • 3 comments

For now, when defining a command in C# code, I need to add it to two places:

  1. TexFormulaParser.commands hash set.
  2. TexFormulaParser.ProcessCommand method.

It looks like a lot of duplication comes from this, and also this system is not user-extendable.

What I imagine is the following:

  1. We need to declare one command dictionary, no name duplication should ever be used.
  2. Create a TexCommand class and allow the implementation to deal with parsed arguments etc.
  3. Add an external RegisterCommand API for our users to define their own commands in C#.

ForNeVeR avatar Sep 16 '18 06:09 ForNeVeR

We could create a Command delegate that returns an Atom, store the namesof supported commands and their methods in a dictionary and invoke the command in the "ProcessCommand" method. However, if we want users to create their own commands, use the atoms we create and manipulate other aspects of the library, we have to make them go public.

B3zaleel avatar Sep 17 '18 20:09 B3zaleel

Well, yep, you're right about the public Atoms, I haven't thought about that yet. That'll be little stressful, I'll need to think more. I don't wanna to publicize all our internal stuff, because that means that any changes to that stuff will be API-breaking.

ForNeVeR avatar Sep 18 '18 15:09 ForNeVeR

@Polina7 let's begin with simpler commands: everything except \left, \right, and \color*.

ForNeVeR avatar Oct 11 '19 13:10 ForNeVeR