Funny story: using kilo was the final straw [1] in getting me to give up on terminals. These days I try to do all my programming atop a simple canvas I can draw pixels on.<p>Here's the text editor I use all the time these days (and base lots of forks off of): <a href="https://git.sr.ht/~akkartik/text2.love" rel="nofollow">https://git.sr.ht/~akkartik/text2.love</a>. 1200 LoC, proportional font, word-wrap, scrolling, clipboard, unlimited undo. Can edit Moby Dick.<p>[1] <a href="https://git.sr.ht/~akkartik/teliva" rel="nofollow">https://git.sr.ht/~akkartik/teliva</a>
Kilo is a fun weekend project, but I learned the hard way that it's not a good base uppon which you should build your own text editor.<p>The core data structure (array of lines) just isn't that well suited to more complex operations.<p>Anyway here's what I built:
<a href="https://github.com/lorlouis/cedit">https://github.com/lorlouis/cedit</a><p>If I were to do it again I'd use a piece table[1]. The VS code folks wrote a fantastic blog post about it some time ago[2].<p>[1] <a href="https://en.m.wikipedia.org/wiki/Piece_table" rel="nofollow">https://en.m.wikipedia.org/wiki/Piece_table</a>
[2] <a href="https://code.visualstudio.com/blogs/2018/03/23/text-buffer-reimplementation" rel="nofollow">https://code.visualstudio.com/blogs/2018/03/23/text-buffer-r...</a>
How timely, I just finished going through a tutorial that builds a text editor like kilo from scratch: <a href="https://viewsourcecode.org/snaptoken/kilo/index.html" rel="nofollow">https://viewsourcecode.org/snaptoken/kilo/index.html</a><p>Would highly recommend the tutorial as it is really well done.
Reading through this code is a veritable rite of passage. You learn how C works, how text editors work, how VT codes work, how syntax highlighting works, how find works, and how little code it really takes to make <i>anything</i> when you strip away almost all conveniences, edge cases, and error handling.
I made a similar editor using Lazarus... since it has syntax highlighting components... I guess that's cheating. The more I think about it though, I wonder if Freepascal could produce a nice GUI for Neovim.<p>I did try to build one in Qt in C++ years ago, stopped at trying to figure out how to add Syntax Highlighting since I'm not really that much into C++. Pivoted it to work like Notepad so I was still happy with how it wound up.<p><a href="https://github.com/Giancarlos/qNotePad">https://github.com/Giancarlos/qNotePad</a>
It also inspired this similar Rust project: <a href="https://github.com/ilai-deutel/kibi#comparison-with-kilo">https://github.com/ilai-deutel/kibi#comparison-with-kilo</a><p>Although it does cheat a bit in an effort to better handle Unicode:<p>> unicode-width is used to determine the displayed width of Unicode characters. Unfortunately, there is no way around it: the unicode character width table is 230 lines long.
Ah darn. Closing in on retirement (will never happen, coding is too much fun for profit or charity) age, I resistent building an editor but I want to. Need to. I hacked so much vim, emacs, eclipse, vs code and its all crap (the newer, the worse: all these useless gimmicks you won't use past grade school aaarrr while lacking power user features). Can I do better? This seems a good start.
Funny. These days when I see a headline like that, I assume it's some type of web component.<p>Why are all the commenters so eager to get out of terminals?
One interesting thing is that even some of those 1000 lines could have been eliminated.<p>It duplicates the C library's cfmakeraw() function, for instance.<p><a href="https://man.freebsd.org/cgi/man.cgi?query=cfmakeraw&sektion=3" rel="nofollow">https://man.freebsd.org/cgi/man.cgi?query=cfmakeraw&sektion=...</a>