What is it?

hexen running from st
hexen running in st and viewing some of its own source code.
Those colors look familiar...

hexen is my project to create a simple text editor that runs from the terminal. It uses the X and the ncurses library for display.

The current version of hexen is 0.00 because it is missing "features" that are core to a text editor, as I haven't implemented them yet. Backspace behaves strangely, tabs have been a bit of a pain. The window cannot be resized yet. Saving files is not fully realized. The big one is the lack of scrolling! Occasionally the cursor gets stuck out of bounds and can move around where the line numbers are printed (thankfully characters can't be typed here).

My intention is first to complete the core features and fix the odd behavior, in the order of fixing any weird key issues, having the text scroll properly, and implementing a proper saving system.

hexen is currently hosted on my GitHub (privately). I will be making the repository public once the program is functioning to my minimal goals.

The compiled binary comes in at around 37K on my system. The project spans a few files and is about 1295 lines of "code". I am unsure how many of these lines are whitespace/comments and I haven't bothered to count through them or write a script to do it.

Dependencies, as far as I can tell, are X and ncurses. I have only tested its use in st (the screenshot on the right is hexen running in st. Those colors look a bit familiar...)


My goal is to build a lightweight text editor that is configurable but also fairly simple. I like using nano and Visual Studio Code for a lot of stuff, but I want something more in the middle (run inside the terminal, shortcuts that I would find more predictable). I find that sometimes nano feels a bit sticky and awkward to use (although that might just be my impression), so I wanted to make something more compact but with the functionality I would expect from an editor.

The first version is set to just be the basic things that an editor would have: editing, saving, the required stuff. Ideally I'll figure out a better way to save a file (instead of just writing over the whole thing). Other stuff on the table is text wrapping, window resizing, text searching/regex stuff.

Cut and pasting, file renaming and retyping are longer term goals. I also want to improve the way the document is displayed to avoid redrawing lines that don't need to be redrawn. Possibly light file browsing but I don't want to push it and end up writing something that grows to read mail.

My other large goals are keeping LOC low, keeping the binary size down, and avoiding a large memory overhead (putting an entire file into a linked list will produce some overhead for larger files obviously).

Oddities and Bugs

I define oddities as features or odd behavior that are my fault intentional and just kind of weird. Bugs on the other hand are not always features and I intend to fix them. At this point in development, while hexen is currently still a prototype essentially, maybe it wouldn't be best to call them bugs - but the idea is that something is not working as intended.


  • Lines are limited to 140 characters. This was sort of arbitrary but it made stuff easier for me (string manipulation is a lot easier if array size is constant. I'll try to find some way to justify it retroactively. The standard maximum CPL for C seems to be considered around 80 or so anyways.
  • There is no code for mouse input. Maybe once I get the core stuff done I'll try and implement mouse based selection, other than that I don't want to pile on a ton of features or mouse integration. hexen is designed around the keyboard and I wouldn't want to de-emphasize the keyboard just to add unnecessary mouse functions.
  • Key behavior is weird.
    • Backspace will essentially snip a line at the position of the cursor, deleting all characters after the cursor as well as the one preceeding it. The line also fails to render the text appropriately and the deleted characters show until they are written over. Fixed as of 12/19/2019
    • Tabs work within lines, but there is no automatic indentation for lines that follow an indented line. This is more of an unrealized feature because I haven't written any code for it yet.
    • Enter behaves as though the cursor was at the end of a line regardless of its position, adding a new empty line below the line with the cursor, instead of breaking text into two line, or pushing the current line down one. Fixed as of 12/19/2019
    • Deleting the last line in a file with backspace will not properly update the deletion in the display and the line will always show unless it has been written over. Moving the cursor shows that the line is gone in spite of this. The line number for the last line will persist if it is deleted. Fixed as of 12/19/2019
  • Editing the end of a line will remove its newline and saving the buffer will show that the next line has been joined when the lines are printed. The solution to this is most likely to strip newlines after fgets and insert them again when saving, since they aren't necessary for the display code anyways (lines are already broken up into linked list nodes). Fixed as of 12/19/2019

To do (for version 0.1)
  • Fix enter key function so it properly breaks the line Done
  • Implement the delete key Done
  • Implement text selection with the shift key
  • Implement proper auto indentation for lines after tabbed lines
  • Fix scrolling
  • Implement control+key shortcuts Done (saving, quitting)
  • Implement window resizing

Copyright and License

The license has not yet been determined, but the plan is to release hexen under the LUUL license once the license is finished.