Giter Site home page Giter Site logo

red's Introduction

🟥 RED 🟥 Text Editor written in Rust

This my built-from-scratch text editor, in Rust. I wanted to write a text editor since a long time, here is my trial. It supports vim-like modal edition, and many commands that are defined by VIM.

All the code is written in Rust. It contains a model, with an abstraction for different edition modes (insert mode, normal mode, command mode, visual selection, etc...), abstraction for selection (forward, backward, words, etc) and a view. The view is written using ncurses, using the bindings from this link which turned out to be very easy to use. There are also unit-tests to make sure that I do not break previous functionalities while writing new ones.

Why writing a text editor ? I wanted to test my software skills. It is surely not a very efficient text editor. But it remained a very challenging exercise and I am quite happy with the overall result, especially the architecture that I found.

To try it out, just run

cargo run -- test.txt

Technical Specification

Here is all of the features that I have implemented.

  • In Insert Mode, you can type text (like in any text editor)
  • In Normal Mode, you can navigate across your document, select part of your documents, yank, etc...
    • currently supported keybindings (same role as vim):
      • w, b to move the cursor 1 word forward or backward
      • o or O to go in insert mode at the line below / above
      • x to delete the current char
      • r to replace the current char
      • f, F, ; to look for a character forward or backward and repeat the same lookup
      • G to go to a line number, for instance "12G" to go to line 12
  • The editor supports copy/paste through vim's yank and put:
    • you can select a part of the document with the visual selection: 'v'
    • y will yank your visual selection
    • p will put you visual selection where your cursor is at
    • u to undo
      • This is limited to writing characters. All the framework is here to extend it to more actions. I just did not have time.
  • In Command Mode, you can execute commands
    • currently supported: :w (write), :q (quit), :wq or :x

About the visual display:

  • Line numbers are displayed with a status bar at the bottom
  • When the line is too long, line-wrapping is done to fit the screen
  • If the number of line is bigger than the screen, you can navigate vertically on your document using the arrows of the keyboard.

A word about the model

Let's write something here !

TODO

This is my personal todo list for features that I think are doable.

Two tasks that are remaining and that seem difficult to do.

  • Undo 'u' and redo 'C-r'
    • This will be a lot of work... Not sure if I can do it now.
  • Searching for a pattern: '/'.
    • The difficult part will be in the view, to highlight the words. However, it was already done for the visual mode, so maybe it's not too much work.

And some quick-wins that seem easy to do.

  • Yanking and pasting
    • Visual mode
      • Logic
      • Basic view
      • Advanced view (breakline)
    • yank and put
      • yank current selection
      • put the current yanking
      • special yanking action: 'yy'
    • Advanced selections: '()', '{}', '[]' with 'i' or 'a' words... to do
      • 'va('
      • 'ya('
  • Better motion and actions
    • Special motions: 'gg', 'G', '$', '^'
    • Line number moving: '155G': go to line 155
    • 'f' and 'F' motions
    • re-apply previous 'f' or 'F' pattern with ';'
    • 'x'
    • 'r'

red's People

Stargazers

Quentin LÉVÊQUE avatar

Watchers

Arthur Bricq avatar

red's Issues

Not compatible with a terminal in dark mode

First of all, good job, this is a nice editor ! Is red a reference to ed ?

My issue is that the default colors are not adapted for a terminal in dark mode, and there's no way to change the style.

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.