Skip to content
/ te Public

A toy vim-like Text Editor for X in 500 lines of C.

Notifications You must be signed in to change notification settings

ChanderG/te

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

te

A toy text editor for X in around 500 lines of C.

Warning: This project is a toy meant for fun and has a lot of limitations. No guarantees to your input files.

Build

make
sudo make install

Use

Simplistic vim-like bindings.

  1. Normal, Insert and Command modes.
  2. Arrow and Page keys to navigate.
  3. Normal mode commands: "i", "a", "o", "dd".
  4. Command mode: "w" to write and "q" to quit.

Design choices

There are three primary/famous data structures to use for text-editing:

  1. Gap buffers, as used in Emacs.
  2. Ropes.
  3. Piece Tables.

Since, this is a toy and I wanted the simplest option, what I have done is the following:

  1. Model the file/buffer as a doubly linked list, where each entry is a single line.
  2. Model each line as single string.
  3. When switching to editing (normal -> insert), convert the current line into a line-scoped Gap buffer. This is used as long as you are in insert mode.
  4. When done editing the line (insert to normal), move back from the Gap buffer to a character array, a new allocation basically.

The selection of the doubly linked list is primarily to make adding and removing lines an easy operation.

License

MIT

About

A toy vim-like Text Editor for X in 500 lines of C.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published