Live data from Hacker News

Build Your Own Text Editor

viewsourcecode.org

151–160 of 164 posts

Re: Build Your Own Text Editor

#151
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.

A long time ago I put some components together and built ProgEdit using Delphi, with resources that reminded me of SideKick Plus.

I've used that editor daily to write source code, mainly in Clipper, and I think some of my coworkers used that too.

But then I moved on and knew vi, and now I can't take my hands from the center row :)

ProgEdit: https://sourceforge.net/projects/cpstools/

SynEdit, the base of the editor: https://github.com/SynEdit/SynEdit (confession: I was only a user of SynEdit, not a developer).

Re: Build Your Own Text Editor

#152
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 wrote one back in 1984-85 that I called QEdit, and have been using and updating it ever since.

QEdit's configurability was amazing. Back in the early 90s I had a completely hand built config, a feat I have never dared to repeat with subsequent editors. I wrote a lot of code in it at home, and nagged my employer into buying some licenses for the sophisticated programmers among the staff (it was a bank, so not many, but a few!). I would edit locally and FTP to the server rather than use vi directly there!

When my computer illiterate aunt decided to write a book back in the early 90s, I set her up with a minimalistic QEdit, a few bat files to perform backups, versioning, etc automatically and a floppy disk for each day of the week plus a daily backup one. Simple instructions and process, simple editing setup, and two years later the 670-page book was finished and published, and she was ready to actually learn how to use a computer.

So a big thank you for creating such an excellent tool!

Re: Build Your Own Text Editor

#153
post #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?

Simplest I can think of: $ echo 'cat > "$@"' >editor $ chmod +x editor $ GIT_EDITOR=./editor git commit -a stuff [master b2d3915] stuff 1 file changed, 1 insertion(+) You'll need to hit enter before ^D. You can add simple Emacs-like keybindings by changing that into $ echo 'rlwrap cat > "$@"' >editor Or just learn ed: $ GIT_EDITOR=ed git commit --amend -a 256 1c stuff and more stuff . w 271 [master c5092a6] stuff and…

If anyone is having trouble getting the first one working, you need a shebang at the top of the file!

    $ printf '#!/usr/bin/env sh\ncat > "$@"\n' > editor
But the second point is more valid. Ed is the standard editor.

Re: Build Your Own Text Editor

#155
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…

Ropes are pretty sweet. I still prefer a piece table, just because of the sheer simplicity.

Re: Build Your Own Text Editor

#156
post #47

The next fun experiment is to handle gigabyte files without undue performance troubles with a lively ui thread! This is where scintilla et al run into limits.

If that sounds fun to you, do it!

I suppose that would be more along the lines of a hex editor, which is probably interesting to implement too.

Re: Build Your Own Text Editor

#157
post #108

I'm working on an editor in JavaScript. You would be surprised how fast string operations, like concatenation, are in JavaScript! You can hold the entire buffer in a String! While browsers renders text very well, the DOM is relative slow to interact with, but there are other ways to render in JavaScript, for example the Canvas, or into a terminal, or even stream a video, or talk directly to a display.

That's really what JavaScript was made for: editing HTML (strings) on-the-fly. It has been optimized well, indeed.

What kind of data structure are you using for edits?

Re: Build Your Own Text Editor

#158

I got fed up with the standard offerings back in '07 or so and hammered out my idea of a code editor that's perfect for me over a long weekend. It mmaps files initially for instant response, it has a small sensible command set that I can remember completely, it depends on nothing more than the standard C library and a terminal emulator, and it's not many more lines of code than some Emacs configuration files that I'v…

Cool. Is it public? What data structure do you use for the modifications?

Re: Build Your Own Text Editor

#159
post #68
post #66

Earlier quoted context omitted.

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.

Running a regex each time you type a character seems a little heavy to me...

Regex'ing languages like HTML or C++ can be quite mind breaking... I think.

Re: Build Your Own Text Editor

#160

Earlier quoted context omitted.

Simplest I can think of: $ echo 'cat > "$@"' >editor $ chmod +x editor $ GIT_EDITOR=./editor git commit -a stuff [master b2d3915] stuff 1 file changed, 1 insertion(+) You'll need to hit enter before ^D. You can add simple Emacs-like keybindings by changing that into $ echo 'rlwrap cat > "$@"' >editor Or just learn ed: $ GIT_EDITOR=ed git commit --amend -a 256 1c stuff and more stuff . w 271 [master c5092a6] stuff and…

If anyone is having trouble getting the first one working, you need a shebang at the top of the file! $ printf '#!/usr/bin/env sh\ncat > "$@"\n' > editor But the second point is more valid. Ed is the standard editor.

What system are you on that needs the shebang? bash 4 on Ubuntu seems to just run it in bash, though I guess it probably shouldn't :-)
Post reply on HN