Live data from Hacker News

Writing an editor in less than 1000 lines of code, just for fun

antirez.com

131–140 of 146 posts

Re: Writing an editor in less than 1000 lines of code, just for fun

#131
post #25

Earlier quoted context omitted.

Yeah but that is so much less usable. Quick, which one is up?

"k", as "k" glyph reaches higher from the two. And conversely, "j" reaches lower, so it moves down.

You're right, that is much more usable than having an up button in the up position with an up arrow on it...

Re: Writing an editor in less than 1000 lines of code, just for fun

#132

Awesome. When I saw all the things it could do in so little code, I assumed a higher level language would be used. But, nope...plain old C with the usual standard libraries. The parser for the syntax highlighting is super cool. Concise and declarative definition of the syntax (well, the keywords, anyway), in HL_keywords, and then maybe 150 lines of code for the parser. I doubt it would work well for a much more compl…

> I doubt it would work well for a much more complex language than C (say, JavaScript, or Perl), without a lot more smarts.

Perl can not be parsed, making accurate synthax highlighting impossible: http://www.perlmonks.org/?node_id=663393

Re: Writing an editor in less than 1000 lines of code, just for fun

#133
post #25

Earlier quoted context omitted.

"k", as "k" glyph reaches higher from the two. And conversely, "j" reaches lower, so it moves down.

You're right, that is much more usable than having an up button in the up position with an up arrow on it...

Erm... what? I didn't claim it's more usable (though it is for me). I just provided mnemonics I saw once which I liked, for a question "which k/j moves up and which moves down?".

Re: Writing an editor in less than 1000 lines of code, just for fun

#134
post #35

Earlier quoted context omitted.

The point is, they are no longer in symbolic memory. At this point they are muscle memory. Quick, which muscle do you use to move your right thumb in? Does it matter?

Exactly: muscle memory. In your car, do you move the turn signal lever up or down to indicate a right turn? It actually takes longer to answer this question than to do the action in real life. Another example: There are several passwords that I can type instantly, but I wouldn't be able to recite them.

Just have to imagine the motion. I remember left/right by literally right clicking & feeling my middle finger be to the right of my index. I got a little mixed up when I switched my mouse to my left hand

Re: Writing an editor in less than 1000 lines of code, just for fun

#135
post #10

Honestly, this is the most exciting and inspiring project I've seen on HN in years, by far. I love that it's a fully usable terminal-based text editor that has zero dependencies . Just perusing the source code has been extremely interesting and educational for me already, and it's only been 5 minutes. Definitely gonna bookmark this project and hack on it! The TODO list looks like a good start, especially the xterm-ba…

You can tell it's going to be good when, on a Mac, you download the source and compile it, and a) it compiles b) it doesn't give a single warning. It's nice when portability actually works.

Re: Writing an editor in less than 1000 lines of code, just for fun

#137

Earlier quoted context omitted.

Speaking HTTP is worse in almost every way to using CGI: harder to implement, loses meta information (suppose you put an application at /app/ on your server... CGI handles it well, HTTP doesn't unless you do some extension since your server will see GET / anyway) and is harder to centrally log too. I think app servers speak HTTP more because it is kinda convenient for developers to run the local server without settin…

Nah, it's not worse: as nostrademons mentioned, you have your gateway server be a reverse proxy server, e.g. HAProxy, and then you can do whatever you want in there. Serve an application under /app/? No problem. Centrally log? Of course. Harder to implement? Not really, every major language has well-supported HTTP libs. And since you only need to know how HTTP works, rather than needing to understand HTTP and CGI, it…

It is interesting to note that most those HTTP libraries end up looking like CGI to the programmer anyway, even sometimes using X-Whatever headers for additional information, because that's the relevant information to an app server.

Re: Writing an editor in less than 1000 lines of code, just for fun

#138

Earlier quoted context omitted.

First, switch it to alternative screen mode... printf("\033?1047h"); then clear and move and such with other similar prints. See the list here : http://invisible-island.net/xterm/ctlseqs/ctlseqs.html It really is pretty simple. The big benefit of ncurses is if you want to target terminals other than xterm compatible ones, and they are so rare nowadays that you can really just ignore them.... Input is quite a pain tho…

I wonder if these codes work in cmd.exe now that Windows 10 TH2 supports (some of) the features.

I haven't checked but I kinda doubt it... and I kinda hope not - the windows console API is so much nicer than the unix terminal system it would be a pity to make it an ugly hybrid.

Of course, you can run a terminal emulator inside the windows console and handle those sequences too! If I had to guess, I'd say that's what Microsoft would have implemented.

Re: Writing an editor in less than 1000 lines of code, just for fun

#139
post #116

> Let’s say this again, “email client”. The notion of email client itself is gone at this point. Really? Is it lame to be using an email clients these days? I still use an email client (Thunderbird) because I can't stand the thought of all my mail sitting forever on Goggle's or whoever's servers. Yes, I know that they could have secretly archived all of my email the moment it was sent or received, and that my privacy…

> Really? Is it lame to be using an email clients these days? I think he means that wether nano is derived from an email client or not is not important

You might be right; I may have misinterpreted. He might be saying, "The notion of email client itself is gone from Nano at this point, everything changed about Nano".

Re: Writing an editor in less than 1000 lines of code, just for fun

#140
post #124

Earlier quoted context omitted.

You are being needlessly pedantic. The point is that typing "vi" into a terminal runs some application that implements a "vi-ish" interface. Whether it is ported vi or vim or vim-tiny has some effect on how nice that interface is to work with, but I would argue that most vim users would be able to get their configuration fixed or whatever

> You are being needlessly pedantic. I assure you I am not pedantic needlessly . The claim was "vi has some issues with arrow keys". Now tell me: which vi clone was elsurudo talking about? Because those are different projects . And Vim doesn't have a smallest issue with arrow keys (unless with "compatible" option set, I think, but I didn't use it for years and I may remember wrong).

As a cranky old man, I'd argue all of them that support arrow keys have issues. Arrow keys are an abomination.
Post reply on HN