Writing a text editor using C and ncurses - Part 1
I have had a bit of a hardware-software project marinating in my mind lately. Part of that project requires a terminal/console based text editor.
I’ve written a few text editors over the years, simply for the sake of playing around with a new language, but this one is the first that has a real purpose. Ironically, even though we are in 2016 and fancy 3D desktop environments are all the rage, this project called for an old school terminal application.
In my search for how to write console or terminal applications, I came across NCurses. With a little help from the internet (mostly here and here) I managed to get a working text editor running within my terminal (currently LXTerminal, but I also tested it in Gnome-Terminal and urxvt).
Current features include:
- Vim-like “Normal” and “Insert” modes
- Open any text file from disk
- Edit the file in the application
- Save the changes to disk
- Status bar (mostly for debugging at the moment)
- Outline panel (purpose to be explained in Part 2)
- Editor panel
- Panels can be given focus by tabbing between them
- Current line highlighted in a different colour
- Cursor highlighted in a different colour (currently yellow)
- Suitably gaudy colours for a WIP!
This is where I am currently up to. The text editor will now go on hold for a while as I research various hardware requirements for the physical device.