A minimal text editor written for fun in plain Ruby with no dependencies.
I wrote it from memory after watching the relevant screencast by Gary Bernhardt. It supports:
- Quitting
- Moving the cursor up/down/right/left
- Deleting the character before the cursor, like backspace
- Breaking a line (
Enter) - Undoing!
The following are also implemented (not covered in the screencast):
- Flicker-free screen
- Ignoring non-printable characters
- Creating a file if it doesn't exist (not just editing)
- Saving
- Redoing!
- Moving left at the beginning of a line causes the cursor to jump to the end of the previous line
- Moving right at the end of a line causes the cursor to jump to the beginning of the next line
- Moving the cursor to the beginning of the line
- Moving the cursor to the end of the line
- Deleting the character before the cursor at the beginning of a line joins lines
- Deleting the character at the cursor, like delete
- Deleting the character at the cursor when at the end of a line joins lines
- Deleting the line text before the cursor
- Deleting the line text after (and including) the cursor
- Support for arrow,
Backspace,Delete,HomeandEndkeys
./femto.rb myfile.txtCtrl-QquitsCtrl-SsavesCtrl-P(previous), or theUparrow key, moves the cursor upCtrl-N(next), or theDownarrow key, moves the cursor downCtrl-F(forward), or theRightarrow key, moves the cursor rightCtrl-B(backward), or theLeftarrow key, moves the cursor leftCtrl-AorHomemoves the cursor to the beginning of the lineCtrl-EorEndmoves the cursor to the end of the lineCtrl-HorBackspacedeletes the previous characterCtrl-DorDeletedeletes the current characterCtrl-Udeletes the line text before the cursorCtrl-Kdeletes the line text after (and including) the cursorCtrl--undoes the last changeCtrl-Rredoes the last change
- Tests
- Scroll-buffer
This is an experimental program. Do NOT use it to edit files that you don't want to lose/damage.
Angelos Orfanakos, https://agorf.gr/
