-
Notifications
You must be signed in to change notification settings - Fork 44
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
Leaf Projectors #1218
Draft
disconcision
wants to merge
68
commits into
dev
Choose a base branch
from
projectors
base: dev
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Leaf Projectors #1218
Conversation
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
…rily disabled scroll to caret
… disabled for now
…was used only by backpark targets. new 'segment' is now what was previously called 'unselected'
…ind of nasty though may need an alternate approach
Draft
…rojector statics sync
…individual projector cores and views to their own files
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First stage of projectors. Implements a simple atomic code projection framework intended to be used for:
This PR implements two kind of leaf projector:
How to add a new projector:
The meat of adding a new projector consists of:
Roadmap for adding a new projector:
ZipperBase.re
alongsidefold
andinfer
ZipperBase.projector
FoldProjectorCore.re
Projector.to_module
Action.project
ProjectorPerform.go
FoldProjectorView.re
ProjectorsView.to_module
Projector model types and persistence of projector state
The model type represents the persistent state of a projector which is serialized alongside the program zipper. If your model type involves heavy state making user of substructural sharing, or stores functions, you'll need to implement custom serialization. The model state is stored in the projector map, which is a map of IDs to zippers. Hazel UUIDs form the link between the syntax and projectors, so any action which disrupts IDs, for example, modifying a token or cutting or copying syntax will not (currently) retain projectors; all projector state will be lost in such cases. Note that it's possible to destroy a projector on an atomic literal/variable by causing that atom to merge with another, e.g. if {} denotes projector then given 1+{2}, backspacing the + results in an unprojected 12. This is somewhat artifactual of the implementation decision to use a new id in such cases, rather than the id of one of the initial tiles. This also applies to projectors on holes.
Projector core logic module
The type t should be your model type. The data field is the projector state, and the projector field is an implementation detail; follow the pattern of existing projector modules.
The
placeholder_length
method must return an integer corresponding to the number of characters your projector's view will occupy in the syntax. Currently only single-line projectors are supported. This must be kept in sync with your projector's view logic.The
can_project
method is a predicate to determine what kinds of syntax your projector can apply to. Currently only single pieces can be projected, not segments or slots. This means that projection is currently limited to terms which form convex tiles, like atoms, parentheses, and case expressions. This predicate is not currently automatically enforced; you must include it in your action logic manually.The
update
method is automatically called whenever the syntax is edited to supply your projector with semantic information. Currentlyprojector_info
contains only static cursor info. If you want to more information here, you'll need to add the relevant type(s) toZipperBase.projector_info
, and make sure this information gets populated inUpdate.re
.Projector view module
The type t and data field should be exactly as in the corresponding core logic module.
The
normal
andindicated
methods represent how your projector is rendered when not indicated / indicated by the caret respectively. The currently means precisely when the caret is directly adjacent to a projector. Projector actions are currently globally scoped actions but this will likely be limited before merge to only be able to effect either the projector's own model, or the syntax under the projector.The
key_handler
method allows overriding keyboard input precisely when the caret is directly adjacent to a projector. When this function returns None, keyboard input is escaped to the parent editor.The
ci_string
method provides a single-character indication on the right side of the cursor inspector bottom bar that a projector is currently indicated. This is a stub for a more general UI for overloading the CI to show more or modified information when a projector is indicated.Progress
Features:
Bugs:
Todo: