magic-tree icon indicating copy to clipboard operation
magic-tree copied to clipboard

Track cursor positions

Open mhuebert opened this issue 7 years ago • 0 comments

In addition to being 'whitespace-aware', a magic-tree AST should be 'cursor-aware' and 'selection-aware'. This would allow us to implement editing commands purely in terms of the AST, instead of having to interop with host environment/editor. This will make testing straightforward, and allow for more freedoms in the visual representation and manipulation of code. (CodeMirror can be just one of many possible 'views' on an AST, one which happens to use a string representation.)

Involves:

  • A way to represent cursors/selections in the AST
  • Cursors/selections should 'flow' along with edits made to the AST. After updates are made, we must be able to get the updated cursors/selections (with accurate positions)
  • A way to sync cursors/selections with a host environment/editor (ie. update the cursors/selections of an AST in response to user interactions in an editor like CodeMirror, and vice versa)
  • Errors can be handled/reported differently depending on whether they stem from a node being currently edited or not.

(the above items are purely speculative and subject to change, lots of cross-cutting concerns here)

mhuebert avatar Jun 06 '17 13:06 mhuebert