Build Your Own Text Editor
viewsourcecode.org
viewsourcecode.org
The original editor was introduced here:
https://news.ycombinator.com/item?id=12065217
I put together a fork of that editor, in C++, with support for buffers, scripting with Lua, and similar things. Nothing amazing, but still quite useful. That was posted here to some small interest:
I saw this on HN a couple of hours ago and figured I'd give it a whirl out of boredom and something to do while dinner was in the oven. I've never touched C before, and while I understand its historical significance and the fact that it's a very low-level language, I was always told to never start with C because I'd never understand it.
Now, I'm not claiming that I understand it to the point I can start writing my own programs, but I will say that the way the author presented this tutorial has built a confidence in me that if I keep pushing at it, I can actually learn to code in C over time. I got through the first chapter and I already have a fundamental understanding of how to manipulate characters and input/output on the command line. Thinking back to my dabbling with bash scripts in the past, I now more fully grasp what I was just guessing at with those.
Granted, it helps that I did start with an understanding of variables, conditional statements, and other basic programming building blocks, but I am no longer intimidated by learning C and I am eager to finish this tutorial. If I still have that eagerness once it's over I'm going to continue learning C, as one of my favorite OSes (OpenBSD) is written in it and I'd love to understand more about how it works under the hood.
I eventually got Linux installed (probably from a cd-rom included with a very thick book I bought in person at a book store) so I could use gcc.
If I can learn it under those conditions, you can totally do it! You've got Stack overflow!
I think all you need to really learn programming is a motivation. I was generating rendering instructions for some animation program at the time (ray tracing) and so it seemed like the best thing to do to get the job done. I feel in love.
Best of luck, and keep it up!
Here's yet another guide to building a text editor, using JavaFX, rather than C from scratch:
* https://bell-sw.com/announcements/2020/11/02/TeXnical-Writin...
* https://bell-sw.com/announcements/2020/12/10/TeXnical-Writin...
The second article depicts how the chain works. Using a chain makes combining different features much like snapping together lego blocks. Here's a video of the editor in action---albeit outdated---showing a variable processor, an R processor, and a Markdown processor chained together:
It includes lua 5.2 and SDL. On top of that, it's a few c files to handle input and rendering, and a set of neatly written lua modules for the logic.
Repo and author write-up:
https://github.com/arximboldi/ewig
It's design is covered in these talks:
- Postmodern immutable data structures: https://www.youtube.com/watch?v=sPhpelUfu8Q
- The most valuable values: https://www.youtube.com/watch?v=_oBx_NbLghY
I would love to hear about a "first line to last line" tutorial for a simple GTK app in C, python or preferable rust.
To me there seems to be a huge diffuse overhead to GUI programming, which is discouraging for my kind of brain. I thrive building tree houses, but despise puzzles.
Anyone got a link?
My initial implementation was based on this book and used one rich TextView with Spans to do the rendering. After that turned out way too slow I switched to drawing everything myself using the Android 2D drawing API's. It was a fun side project and I learned a lot from it.
The prototype is I think about 3000 lines of ClojureScript code. It does quite a bit already but there is more to be done. When it is somewhat done, Pavel will probably record a talk about it and put it on our YouTube channel.
This is useful at least as an example on how to manipulate the tty and use ncurse.
Zooming big blobs of text at 60fps without caching remains an open problem as it’s necessary to use a GPU shader and all of the approaches make one or another lacklustre trade-offs.
https://gankra.github.io/blah/text-hates-you/ has a decent description of many of the problems seen with rendering text in the browser setting (which is on the more complex side of text rendering).
That distance fields encoded in the texture are really freaky to capture sharp corners as median of three of them when texture gets interpolated:
https://github.com/copperspice/cs_paint/blob/master/demo/res...
https://css-tricks.com/techniques-for-rendering-text-with-we...
Kilo has also been ported to many other languages, including Go, Python, Java: https://github.com/search?q=kilo+text+editor