[HN Gopher] Build Your Own Text Editor (2017)
___________________________________________________________________
Build Your Own Text Editor (2017)
Author : Tomte
Score : 174 points
Date : 2022-11-13 10:52 UTC (12 hours ago)
(HTM) web link (viewsourcecode.org)
(TXT) w3m dump (viewsourcecode.org)
| thomastjeffery wrote:
| Chapter 2 is an excellent dive into some of the more unfamiliar
| and confusing features emulated by terminal emulators.
|
| It would be neat to have an equivalent set-up using a GUI toolkit
| instead, but the terminal is good enough to work with.
|
| In a broader sense, it's pretty frustrating to know that we are
| still emulating features (like ctrl-[s,q]) that only really made
| sense in the context of a physical terminal. The amount of work
| and frustration we could save with a modern equivalent to
| terminal emulators (without historical baggage) would be really
| significant.
| heroku wrote:
| t-3 wrote:
| Everybody? It's been _the_ language for open source software
| since the beginning. "Who _likes_ C? " is a different
| question, but using it is often just plain practical. Almost
| all mainstream languages are syntactically close to C, so it's
| easy to read. Documentation for using C interfaces ships with
| every *nix, making it easy to write. Memory safety and footguns
| don't matter at all for the vast majority of programs,
| especially not the short and simple "do-one-thing"-type
| programs that are most non-commercial code.
| laerus wrote:
| teddyh wrote:
| Write your own Emacs: https://www.finseth.com/craft/
| jeadie wrote:
| I did this a few months ago in Golang and it was so much fun. Can
| 100% recommend.
|
| Shameless plug -> https://github.com/Jeadie/gram
| mrlonglong wrote:
| There's also a Rust version of this somewhere on the web. I'd dig
| out the URL but it's long forgotten.
| pflenker wrote:
| I wrote this a couple of years back - it's a bit out of date
| though: http://www.philippflenker.com/hecto/
| elashri wrote:
| Here we are https://github.com/rhysd/kiro-editor
| signaru wrote:
| Makes me wonder what was used to program the first text editor...
| vaylian wrote:
| I'm pretty sure it was punch cards
| peteforde wrote:
| Anyone reading this who might be on the fence... this project is
| 10/10 excellent.
|
| It's absolutely worth doing.
| unsafecast wrote:
| I _love_ this style of tutorial. It really does feel like a Lego
| book. Amazing.
| sys_64738 wrote:
| The memmove stuff suggests not using the unlimited undo
| technique. I only did a very brief scan but didn't see reference
| to undo.
| z3t4 wrote:
| > We can no longer just feed the substring of render that we want
| to print right into abAppend(). We'll have to do it character-by-
| character from now on.
|
| The more functionality you add to a program, the more complicated
| and slower it becomes. You can add optimizations and abstraction
| layers. But the best way to write a bug free and efficient
| program is to keep it small and simple.
|
| If you do need those functions though, you can make your life
| easier by writing tests before implementing a feature. For
| example before writing the code that colors numbers, write a test
| that checks if numbers has a color, and a test that measure the
| time it takes to render a line - and have it fail if it becomes
| significant slower.
|
| So as an exercise you could write a test for each step in the
| tutorial.
| BaculumMeumEst wrote:
| I'm really grateful people like author exist. This is awesome and
| I'm so excited to go through it.
| bediger4000 wrote:
| This is a lot of fun. I used this step by step tutorial to write
| the same editor in Go.
| bmitc wrote:
| Is your code available somewhere, like on GitHub?
| timsneath wrote:
| Me too. It started a whole chain of events for me:
|
| - I used the tutorial to write it in Dart (https://github.com/t
| imsneath/dart_console/blob/main/example/...)
|
| - I refactored the console pieces (raw mode, ANSI VT sequences)
| into a separate package (https://pub.dev/packages/dart_console)
|
| - I wrote Windows interop code for the previously Unix-only
| parts of the editor
|
| - I created a separate package for the Dart/Win32 interop
| pieces (https://pub.dev/packages/win32)
|
| - I wound up growing and expanding this package to the full
| Win32 surface area
|
| - Another OSS contributor took and extended my work to support
| the WinRT
|
| Now there are tens of Dart packages that use the Windows
| interop work that all started with this little tutorial on a
| completely unrelated area. So thank you to the author!
| bediger4000 wrote:
| Thank you for following up. I refactored my original Go
| version into somewhat more idiomatic Go. I'll compare with
| your Dart version to see if the packages I ended up with are
| "organic" or just determined by Go peculiarities.
| bmitc wrote:
| This is really cool! I'm definitely gonna try this out in one of
| my favorite languages. I love these types of project-based
| learning. You learn so much by going through them.
___________________________________________________________________
(page generated 2022-11-13 23:01 UTC)