Skip to content
wirenuxPublic

About

A code editor in the terminal (in 1400 lines of code)

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

 

History

86 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rilo


A code editor in the terminal (in 1600 lines of code)

Why does rilo even exist ( °ヮ° ) ?

I created rilo because i've seen this guide : kilo but it was in C and with some little functionality i didn't really like (like the PageUp/PageDown thing), so i recreated it in rust with a lot of new functionality.

Images


C code (rilo)

C code (vim)

Home screen (rilo)

Home screen (vim)

Message

Core Features ( ദ്ദി ˙ᗜ˙ )

Editing

  • Auto-indent
  • Auto-close: ( [ { " ' insert their closing character, typing the closing character steps over it and Backspace between a pair deletes both
  • Toggle comment (Ctrl-K): adds/removes the single-line comment of the current language (// or #)
  • Go to line (Ctrl-G)
  • Search with match highlighting
  • Save and Save as
  • Command prompt (Ctrl-P): see Commands

Display

  • Line numbers: the current line is brighter, can be removed with ~/.rilorc
  • Highlight syntax with the same colors as vim
    • Supported languages: C/C++ (.c .h .cpp), Rust (.rs) and Python (.py)
    • Hexadecimal number support
    • #define and #include support (in C)
  • Message bar: can show Warning, Error, Help and Info (with color !)
    • Every message is gone after 3 sec
  • Status bar: show the filename, the total number of lines, the filetype (for highlighting) and the current line
    • (modified) flag when there are unsaved changes + warning when quitting with unsaved changes
  • Welcome screen: with the version, GitHub link and keybinds
  • Uses queue!() (from crossterm) for less/no flicker

Extras

  • ~/.rilorc: you can change different settings like TAB_STOP, QUIT_TIMES, AUTO_INDENT and SHOW_LINES_NUMBER
  • Read from stdin: cat file | rilo -
  • Open at a line: rilo file.rs +42
  • New files: rilo newfile.txt opens an empty buffer and you can save it with that name with Ctrl-S

~/.rilorc

In it you can change different settings of the editor. I built a custom parser to get those settings into the editor.

Here is an example (these are the default values):

TAB_STOP=4
QUIT_TIMES=1
SHOW_LINES_NUMBER=true
AUTO_INDENT=true
Option Values Description
TAB_STOP number Width of a tab
QUIT_TIMES number How many extra Ctrl-C presses are needed to quit with unsaved changes (default 1, so two presses in total)
SHOW_LINES_NUMBER true / false Show the line numbers on the left
AUTO_INDENT true / false Keep the indentation on a new line

# at the start of a line comments the option out

You can re-read the file without restarting with the reload command.

Keybinds

Key Action
Arrow Move around
Ctrl-A / Ctrl-D Go to start / end of line
Ctrl-W / Ctrl-X Page up / page down
Ctrl-S Save
Ctrl-Shift-S* (or Ctrl-O) Save as...
Ctrl-F Search
Down/Right (when search) Go to the next occurrence
Up/Left (when search) Go to the previous occurrence
Ctrl-G Go to line
Ctrl-K Toggle comment on the current line
Ctrl-P Open the command prompt
Esc Quit prompt / clear search
Ctrl-C Quit

Commands

You can press Ctrl-P to access the command prompt and enter a command

Command Action
save (or w) Save
saveas Save as... (asks for the name)
goto N Go to line N
set number on / set number off Show / hide the line numbers
set syntax NAME Force the highlighting: c, rust, python or none (useful for piped text)
reload Re-read ~/.rilorc
version Show the version

Built with...

  • Rust: for the whole app! ദ്ദി(˵ •̀ ᴗ - ˵ ) ✧
  • crossterm: for the cross-platform UI

Installation & Quick Start

The easiest way to get rilo is to run :

cargo install rilo

to get the latest version ( ദ്ദി ˙ᗜ˙ ). (Otherwise you can build the project from source on your own here: Development)

ദ്ദി(˵ •̀ ᴗ - ˵ ) ✧

Usage

rilo file.c          # open a file (or start a new one if it doesn't exist)
rilo file.c +42      # open a file at line 42
rilo                 # empty buffer
cat file | rilo -    # read the text from stdin
rilo --help          # show the usage
rilo --version       # show the version

Development

Important

You must have Rust and Cargo installed on your computer

Building rilo from source

  • Clone the repository with
git clone https://github.com/wirenux/rilo.git
cd rilo
  • Then install the dependencies and run the program with:
cargo run
# or open a file
cargo run -- file.rs

Boring Stuff (¬⤙¬ )

Use of AI

I used AI only to generate test code in C, Python and Rust, to test the highlighting of the syntax. All generated code are in the test/ folder.

And when i was stuck on understanding complex C code.

Everything else is built on my own.

Credits ₍^. .^₎⟆

This project is created by @wirenux in Rust, using crossterm.

Logo created by @wirenux (using Photopea)

License

This project is released under the MIT License

Other

Idea came from: kilo

Ctrl-Shift-S might not work in some terminal. If so, you can use Ctrl-O

About

A code editor in the terminal (in 1400 lines of code)

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages