Closed gchp closed 9 years ago
The first thing I see is changing Editor::handle_command to work with command::Command rather than the command enum.
As a transitional step, we can create a shim Editor::Command::TextObjectCommand(command::Command)
variant to work with a Editor::handle_textobject_command
function. Modes can then be gradually converted to the new system while still working through the Editor::Command
interface.
Central to moving to the new system is being able to turn TextObject
instances into buffer indexes. This should be slightly easier now that we have the Buffer::chars
, Buffer::chars_from(Mark)
iterators.
I've been considering making TextObject::Kind
a trait, rather than an enum. Doing so would mean we'd have different structs for each kind;
struct Char;
struct Word(Anchor);
struct Line(Anchor);
trait Kind {
pub fn with_anchor(&self, anchor: Anchor) -> Self;
pub fn get_anchor(&self) -> Anchor;
pub fn find_first_index(&self, iter: &mut Iterator<Item=char>) -> usize;
}
Doing this would help to separate matching logic for each kind, as opposed to having something like:
enum Kind { ... }
impl Kind {
...
pub fn find_first_index(&self, iter:&mut Iterator<Item=char>) -> usize {
match *self {
Char => ...
Word(anchor) => ...
Line(anchor) => ...
...
}
}
}
I'd hoped to make some progress in this area, but frequent build breakage and a severe lack of spare time has kept me moving a good deal slower than I'd hoped.
See also #95 and the cmd-builder branch for a rough proof of concept.
I merged @Crespyl's command builder stuff into a branch on this repo. There's still some work in getting it fully integrated, so I'm opening this ticket to track progress in doing that.
The first thing I see is changing
Editor::handle_command
to work withcommand::Command
rather than the command enum.After that,
standardmode
will need to be updated to use theCommand
struct rather than enum.There's a good bit more than that, but I think doing those two things will get us to the place where it is functional. Any improvements & optimisations can be working in then.