5 ms·
It's nice to see another editor that uses straight ansi escapes instead of the bloated legacy database of glass terminal incompatibility & its associated clumsy
by clarry 9y ago
It's nice to see another editor that uses straight ansi escapes instead of the bloated legacy database of glass terminal incompatibility & its associated clumsy library. :-)
I did a similar thing, but it's more or less vi with some subtle differences that would make any vi user mad.
- hellerve 9y agoI was actually scolded—by a friend—for not using curses, but I honestly prefer working with escape sequences. Is your editor available on Github?
- clarry 9y agoI really think curses causes more problems than it solves, today. It made sense back when terminals were hardware, and communications with them were really slow. Today? Explain to your friend what he needs to do when he connects to the solaris server on his campus, using rxvt-unicode, and all curses-using applications are completely broken. How to compile & install the terminfo file, where to get it, where to put it, and what to do because "rxvt-unicode" is too long a name for the implementation. Then explain to him why software won't use ansi standard codes that would just work. Nah my editor is not on github. I figured that I'm only writing it for myself anyway; any rational people should be happy with nvi or vim or one of a few dozen other editors. And the few stubborn ones like me will want to write their own editor anyway. :-)
- msla 9y agoIt's bad to see someone ignoring previous work done and assuming that doing things by hand necessarily means doing it better or more efficiently. ncurses has optimization routines in it, and replicating them in your own project is bloat and, frankly, not something you're likely to do better.
- jlg23 9y ago"Frankly", I'm always willing to learn: Any facts to back up your claims?
- msla 9y agohttps://softwareengineering.stackexchange.com/questions/311015/how-is-curses-a-pun-for-cursor-optimization https://softwareengineering.stackexchange.com/questions/3110... > Part of what curses does is optimize cursor control sequences so (for example) to backspace all the way to the beginning of a line, instead of writing out a bunch of back-space characters, it can issue one command to move the cursor to the beginning of the line, and one more to erase to the end of the line. For more detail, there's the source code. http://invisible-island.net/ncurses/ http://invisible-island.net/ncurses/
- hellerve 9y agoANSI can do it in one escape sequence: "CSI2K". https://en.wikipedia.org/wiki/ANSI_escape_code https://en.wikipedia.org/wiki/ANSI_escape_code
- clarry 9y agoIndeed. There really is not much screen update "optimization" to do in implementing an editor. It's really quite a no-brainer to keep track of updates to a line, and only update the tail that changed. And that's pretty much all it takes to keep it running smoothly over serial. I don't have my code handy right now but all the screen handling amounts to maybe a couple hundred lines of code, out of many thousand.
- jlg23 9y agoI asked for a point, not for a pointer to source code. I can RTFS myself, but after 20+ years of reading and writing code relevant to the question: again, do you have an actual point?
- zeveb 9y agoWithout looking at the source code, I wonder to what extent it succeeds at that goal. Does it actually contain a platform-independent state machine, and diff the current state against the last-known state in order to issue updates, or does it use heuristics to figure out how to reduce control sequences?
- hellerve 9y agoI neither ignore it or assume I can do it better. I just did it because it was fun and satisfying. I don’t believe I could do better than curses/ncurses. What I do believe, however, is that replicating the work isn’t always bloat. If you’re only going to use a small subset of the library anyway, replicating a bit of it might actually be less bloaty than including the whole thing. That said, when in doubt using pre-made solutions surely is better _if_ you’re working in a professional/production-grade environment. I on the other hand am just playing around and seeing how far I can take this.
- samoright 9y ago+1 Projects like these are always welcome on Hacker News. I am saddened to see comments like the parent's (that are too eager to discourage any technical decision that does not conform to their opinion) popping up in this community often. The very purpose of the "Show HN" prefix is to show off fun projects like these to the HN community and the more such projects we have (regardless of what technical decisions were taken to create the project), the better it serves that purpose.
- alphaalpha101 9y agoBut the escapes aren't actually standardised to particular values, as far as I remember. The terminfo database exists for a reason. Assuming every terminal is 'xterm' is an awful idea.
- clarry 9y agoI said ansi because there is an ansi standard. Deprecated, admittedly. Practically all terminals you're going to come across do support a reasonable subset of that standard. Assuming the terminal supports these is more likely to work than some random implementation of curses that might or might not have your terminal in the database. If people really insist on using some weirdo terminal that doesn't support ansi, they are free to run a terminal emulator such as screen between the application and their terminal. Worrying about every legacy glass terminal from the 70s is an awful idea.