Live data from Hacker News

Build Your Own Text Editor

viewsourcecode.org

61–70 of 164 posts

Re: Build Your Own Text Editor

#61
Thanks for making this! It is obviously a labor of love. This kind of incremental building is a lot of work, but adds a revealing dimension not seen in a flat annotated source.

Great work.

Re: Build Your Own Text Editor

#62
post #33

I'm curious if anyone here regularly codes in a text editor they wrote themselves? I've often thought of coding one for fun, with no intention to share it, just for the purpose of having a long-term project that evolves along with my skills. I've never made time for it, but I still consider it once in a while.

I do, sort of. I bought a text editor a number of years ago that was very popular. I still maintain it and use it daily and have often thought about putting out a new version. I have it running on many OS's and devices now. I have also added a lot of features specific to what I wanted. I'm not really sure if they are useful to others or not.

Example: I have an iPad version where I can use an Apple Pencil and handwrite my code on the screen. To me it is very useful when my wife is driving me someplace and I still want to work. Recline in the passenger seat and code.

Re: Build Your Own Text Editor

#63
I think Kilo is a great little project, well-structured and very educational.

Another useful resource I've relied upon in the past, dates back to the 1990s: Freyja, which is Craig Finseth's emacs-like editor written in C.

Here is a list of features:

  * deletions are automatically saved into a "kill buffer" 
  * ability to edit up to 11 files at once 
  * ability to view two independent windows at once 
  * integrated help facility 
  * integrated menu facility, with help on all commands 
  * can record and play back keyboard macros 
  * supports file completion and limited directory operations 
  * includes a fully-integrated RPN type calculator 
 
It was designed for MS-DOS with the Cygwin terminal library.

I found the architecture to be very clean, and it is well explained in Finseth's classic book ("The Craft of Text Editing"). The book is worth reading even if you never touch the code: http://www.finseth.com/craft/

It uses a multi-buffer architecture roughly similar to Walter Bright's text editor (see sibling posting). (I knew about Finseth's editor years ago, but was not aware of Bright's work until now, thanks Walter!)

The Freyja source can be downloaded from: http://www.finseth.com/parts/freyja.php

Look for the link to "freyja30.exe" which turns out to be freyja30.zip (not an executable).

Re: Build Your Own Text Editor

#64
post #33

I'm curious if anyone here regularly codes in a text editor they wrote themselves? I've often thought of coding one for fun, with no intention to share it, just for the purpose of having a long-term project that evolves along with my skills. I've never made time for it, but I still consider it once in a while.

I would not say that I use it regularly, but I have a somewhat working version of what I remember to be the Norton Editor in C++ / ncurses. It was 100% motivated by seeing antirez's artistic triumph, and my effort is sadly lacking in comparison. Still, I look at it every few weeks and add a new feature, and now I am mostly editing the code in the editor itself, which is gratifying. I actually need to get off my duff…

Norton Editor.

Interesting that you mention this. I loved the Norton Editor. I have wanted to for years add a more Norton feel to the text editor that I write.

I wonder if I can still get a copy to play around with and run in a virtual machine. Any idea?

Re: Build Your Own Text Editor

#66

Scite is a barebone open source text editor created by Neil Hodgson to exercise his "Scintilla" text-editor c++ library which is used in others like notepad++. In hindsight, I would have a bit more caution programming text editors. I started tweaking and modifying Scite years ago, it was very interesting but it was no small undertaking and I came to understand why Neil advised in the support forum, to customise it us…

I also tried to make an editor 5 years ago, because I was not satisfied by either notepad++ or sublime text. I was checking out notepad++'s code, and I was quite amazed by the fact that making a text editor was not some simple task.

The syntax highlighting functionality alone is a combination of something as complex as what a compiler/parser does, and you have to do it almost in real time.

So if you want to color every different part like operators, symbols, braces, with a different color, and you try to do this on C++, it is not going to be a small task...

Also something you learn about text editors is the rope data structure. https://en.wikipedia.org/wiki/Rope_(data_structure)

Re: Build Your Own Text Editor

#68
post #66

Scite is a barebone open source text editor created by Neil Hodgson to exercise his "Scintilla" text-editor c++ library which is used in others like notepad++. In hindsight, I would have a bit more caution programming text editors. I started tweaking and modifying Scite years ago, it was very interesting but it was no small undertaking and I came to understand why Neil advised in the support forum, to customise it us…

I also tried to make an editor 5 years ago, because I was not satisfied by either notepad++ or sublime text. I was checking out notepad++'s code, and I was quite amazed by the fact that making a text editor was not some simple task. The syntax highlighting functionality alone is a combination of something as complex as what a compiler/parser does, and you have to do it almost in real time. So if you want to color eve…

> So if you want to color every different part like operators, symbols, braces, with a different color, and you try to do this on C++, it is not going to be a small task...

For a lot of modes, Emacs does this using regex.

Re: Build Your Own Text Editor

#69
marginally relevant: I was looking for a terminal text editor for git commits and other similarly simple tasks: my only requirement is that I can save&leave with ^D. Any suggestions?

Re: Build Your Own Text Editor

#70
post #25

Would something like this be a way for a beginner to C (barely any experience) to get their feet wet? Or is there an expectation of basic familiarity with C already?

If you can write C at the level of K&R, you'll probably be fine.

Hanson's C Interfaces and Implementations is another great book that would better prepare you for this.

Post reply on HN