GithubHelp home page GithubHelp logo

bazed-editor / bazed Goto Github PK

View Code? Open in Web Editor NEW
25.0 2.0 4.0 681 KB

The baz editor

License: Apache License 2.0

Rust 84.44% JavaScript 1.43% TypeScript 7.83% HTML 0.53% Svelte 5.23% Nix 0.55%
based crdt editor rope rust bazed

bazed's People

Contributors

canadahonk avatar druskus20 avatar elkowar avatar gwimm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bazed's Issues

Properly calculate and incorporate Viewport information in Rekuho

The communication with the backend implemented in #60 is very basic. We still need to implement viewport logic:

  • Line numbers need to be offset by the first_line value we get from core
  • viewport width and height need to be properly sent to the backend
  • We should set the required framework for scrolling to work

Implement some sort of User Styles / User Config

At the moment we have a Theme object that we pass around to our components. Its properties are then used as inline styles in the DOM elements. This clearly does not scale as the number of config options grows over time.

 <div
    style:position="absolute"
    style:height="{height}px"
    style:top="0"
    style:background={theme.editor_background}
    style:width="{theme.text_offset}px"
    style:left="{gutter_width}px"
  />

I think we could instead have a global styles.css file that is either exposed to the user or generated from its user settings, which would clean up the component code a lot.

Plan plugin manager

  • plugin version negotiation (plugin API changes)
  • plugin dependencies (DAG of deps? pain)

Decide on frontend frameworks to use

We need to do further evaluation if our current choice of tauri + Svelte is feasible, especially w.r.t. the performance and rendering issues we noticed in tauri.

Discuss registers / killring-style system

I'd think we want to have a vim-style concept of different registers, maybe a killring of deleted text. However, especially w.r.t. a kill-ring, I'd think that may already be the concern of a vim plugin rather than of core, although I'm not sure.
Having some concept of registers should most likely be part of core, however. The details of this need to be discussed

Implement undo and redo

Edit actions should be grouped into undo-groups in a sensible manner, and redo should be possible.
It may be worth thinking about approaches to have some sort of undo-tree or emacs-style undo, although for an initial POC regular undo/redo will do

Implement input-chains for vim-emulation

input chains are command mappings like gg, dw, etc that are composed of several, chained inputs. Some of these will have timeouts, i.e. mappings in insert mode (kj for escape is a typical example), whereas others are basically leader binds that shouldn't have a timeout. We should check if we can unify those or if they are conceptually different, and then implement both.

Implement persistent undo history

Undo history should be preserved across restarts of the editor, similar to how it works in vim. This requires specifying the location of the undo history file, specifying a format for that history, and loading the history from that file when opening a file.

Display selections in the frontend

Currently, rekuho does not carets with length > 0 into account, and still displays them as regular carets. These should be taken into account and displayed as selections.

Design / discuss event-system to inform plugins as well as internal modules of any activity

Plugins will need to react to events such as insertion, deletion, cursor movement, etc.
Similarly, things like a jumplist would need to remember cursor position after any jump and/or text insert action.
There are definitely a lot more of those things.
We should discuss a general event-system for these things, allowing us to modularize out any non-core components by having them simply register event-listeners and work in the background. Most, if not all things that rely on this can probably be expressed as plugins!

Properly support and test multiple cursors in core

While the datastructure in BufferRegions is currently already able to represent multiple carets, edits will frequently crash the editor as the carets will result in deltas being applied out of order.

We need to have some way to guarantee that carets are dealt with in order, and that caret regions never overlap. Once that abstraction exists, we need to have tests and actually a BufferOp to add and remove cursors

Implement selections

It should be possible to store selections in BufferMarks, and it should be possible to change selections by moving the cursor whilst a selection is active. We will probably need to distinguish between any region and user-initiated selections again, those details and plans for other uses of regions should be discussed prior to implementation.

Make undo remember cursor position and selection

This is a problem xi-editor had too (xi-editor/xi-editor#458): Undo is done as part of the CRDT engine, which does not know about cursors.
I see two viable implementation strategies:

  • wrap around the CRDT undo API and memorize cursor positions outside (this may need to interact with more of the CRDT for cursor offsets, idk)
  • Fork xi-rope
  • Don't do this (deliberately not counted towards the viable implementation strategies, as this would be garbage UX)

Additionally, any other marks also need to be aware of undo: Some, if not most, should just be recomputed (i.e. marks for inlay hints, or whatever we may use them for). Others (i.e. the carets of users other than the one that just did the undo) should apply a coordinate transform.

Another very viable idea

Instead of remembering where exactly the cursor was, just use a coordinate transformation to move the carets accordingly, and then (optionally, no reason not to make this configurable) ensure that the caret is moved within the range of text that was affected by the undo / redo action by moving it into that range if required. That way, we can ensure users are always aware of what changed. We'd simply need to ensure that in the simple case (inserting, then undoing) the cursor is where the user would expect it to be, i.e. at the start of the range that had been undone.

We could also just move the viewports to visualize the area that the undo happened in, without actually moving the cursor. That may actually be a preferred UX for many users.

implement undo-history garbage-collection and size limit

Currently, we're infinitely accumulating undo history events, which bloats both the undo history and our CRDT.
At a given max history length, we should discard older entries. Ever so often we should run garbage collection on the discarded entries.

Implement regex based search

Regex-based search should be supported at the Buffer level, and should be exposed through an EditOp.
This would most likely also be the first instance of using Marks for things other than carets, so some architecture around how we want to store that state should be discussed - should these be on the view level?

Design general abstraction for movements / semantic locations

Both for actual cursor-movement, as well as for things like "double-click-on-word", adding a new cursor etc it is required to describe positions in the document on a semantic level, often relative to the current cursor position.
We should design an abstraction that can define things such as "Next start of a word", "next end of a word", "end of line", "next occurrence of /foo/", "previous occurrence of character )", which would then allow us to use it in movement commands as well as any other abstractions (motion-based edit commands such as vim-style diw, cw, dt), etc)

Prototype bazed-rpc-protocol

DoD:
A basic protocol for rpc communication between backend and frontend is specified and implemented.
Supported features:

  • inserting characters
  • deleting characters
  • saving file
  • moving the cursor

Make Editor view fill the screen

As long as we don't have any other UI, the editor view should really fill the entire webpage.
This also means that we'll need to properly meaure the width and height to send accurate viewport information to the backend (see #67)

Setup rust-toolchain.toml file

Given that we're planning to be on nightly, we should add a rust-toolchain.toml file, decide on some recent version of nightly and then use that.

Define strategy for implementing folds

Plan how folds will be stored, on which layers they'll have to be considered (i.e. for things like movement, edit actions, etc), and how they'll be communicated to the frontend layer as well as to plugins.

Add high-level integration tests for RPC-API

We should write some integration tests based on the RPC api, that test actual end-to-end interaction with the editor core through RPC.
This should be relatively trivial to achieve, as the frontend shouldn't need to keep much state.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.