3 ms·
I re-wrote ed in C once for fun: https://github.com/tylerneylon/ed2 https://github.com/tylerneylon/ed2 It uses the regex and readline libraries, as well as so
by tylerneylon 10y ago
I re-wrote ed in C once for fun:
https://github.com/tylerneylon/ed2 https://github.com/tylerneylon/ed2
It uses the regex and readline libraries, as well as some container data types (array/map) called cstructs. The main C files sum to around 1,000 lines. It was an interesting exercise in learning some of the pieces of building a text editor.
- kps 10y agoV6 ed (the first in C) was around 1300 lines. http://minnie.tuhs.org/cgi-bin/utree.pl?file=V6/usr/source/s1/ed.c http://minnie.tuhs.org/cgi-bin/utree.pl?file=V6/usr/source/s... It won't build with a modern compiler, of course.
- breadbox 10y ago> It uses the regex and readline libraries Given that readline is basically a line-oriented version of emacs (or vi, if you set the config), it sounds like you actually wrote a readline editor with an ed-inspired UI.
- mcguire 10y agoThe code for a simple ed-alike is one of the chapters of Software Tools by Kernighan and Plaugher. For entertainment value, here's a version in Haskell (using Parsec to parse regular expressions (!)): https://www.crsr.net/Programming_Languages/SoftwareTools/ch6.html https://www.crsr.net/Programming_Languages/SoftwareTools/ch6...