by klaussilveira on 5/19/25, 8:28 PM with 82 comments
by akkartik on 5/20/25, 2:03 AM
Here's the text editor I use all the time these days (and base lots of forks off of): https://git.sr.ht/~akkartik/text2.love. 1200 LoC, proportional font, word-wrap, scrolling, clipboard, unlimited undo. Can edit Moby Dick.
by lor_louis on 5/20/25, 2:45 AM
The core data structure (array of lines) just isn't that well suited to more complex operations.
Anyway here's what I built: https://github.com/lorlouis/cedit
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].
[1] https://en.m.wikipedia.org/wiki/Piece_table [2] https://code.visualstudio.com/blogs/2018/03/23/text-buffer-r...
by thomasdziedzic on 5/20/25, 12:24 AM
Would highly recommend the tutorial as it is really well done.
by 90s_dev on 5/20/25, 12:32 AM
by giancarlostoro on 5/20/25, 2:52 PM
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.
by nulld3v on 5/20/25, 12:43 AM
Although it does cheat a bit in an effort to better handle Unicode:
> 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.
by anonzzzies on 5/20/25, 2:13 PM
by lbj on 5/20/25, 12:10 PM
Why are all the commenters so eager to get out of terminals?
by JdeBP on 5/20/25, 2:12 PM
It duplicates the C library's cfmakeraw() function, for instance.
https://man.freebsd.org/cgi/man.cgi?query=cfmakeraw&sektion=...
by nodesocket on 5/20/25, 1:08 PM
by jonstewart on 5/20/25, 3:22 AM
by revskill on 5/20/25, 11:53 AM
by fuzztester on 5/20/25, 2:02 AM
go figure.
;)
by cies on 5/20/25, 3:17 PM