Live data from Hacker News

Build Your Own Text Editor

viewsourcecode.org

41–50 of 164 posts

Re: Build Your Own Text Editor

#41

Earlier quoted context omitted.

It's in the parent's "redis style" link.

If you're so sensitive to superficial syntactic issues you're gonna miss out on a lot of reading/learning pleasure in this life. (It's one of my pet peeves: http://akkartik.name/post/readable-bad )

I was taking about the ability to debug code. Various IDEs/compilers have sometimes issues and bugs on multistatement lines in DWARF/etc. I've worked on a low level debugger, so it was a big problem, even few years back.

Re: Build Your Own Text Editor

#42

Nice guide, especially the terminal raw mode stuff. I haven't seen much on that before, I really appreciate that this guide goes over that. I've been messing around with a little text editor component myself in golang: https://github.com/briansteffens/tui/blob/master/editbox.go For a SQL editor project: https://github.com/briansteffens/prequel

If you are looking for an interesting project that uses terminal input modes try writing a command line utility that reads in a password correctly. (eg. Masks the password input so it does not appear on screen whilst it is being typed, prevents someone from scrolling up in terminal and copy/pasting the typed password and zeros out the password after use to prevent it being visible in process address space).

It is surprisingly tricky to get right. There used to be a POSIX function in the c standard library - "getpass" to handle this but the implementation was not thread safe and thus it was depreciated from posix spec - the only portable way I know to do this is to "roll your own code" using termios - not ideal.

see: http://man7.org/linux/man-pages/man3/getpass.3.html note the comment: "This function is obsolete. Do not use it" - there is a heap of potentially vulnerable code out in the wild that uses getpass.

Re: Build Your Own Text Editor

#43

Earlier quoted context omitted.

If you're so sensitive to superficial syntactic issues you're gonna miss out on a lot of reading/learning pleasure in this life. (It's one of my pet peeves: http://akkartik.name/post/readable-bad )

I was taking about the ability to debug code. Various IDEs/compilers have sometimes issues and bugs on multistatement lines in DWARF/etc. I've worked on a low level debugger, so it was a big problem, even few years back.

Fair enough. But where do you see multistatement lines in the link?

Re: Build Your Own Text Editor

#44

Reference implementations of medium sized applications are incredibly useful for leveling up as a programmer. While there are many large successful open source applications, many are overwhelming to read and learn from. Having something that outlines the key features and components and which ignores the important but complicated edge cases assists in keeping the attention focused. Now if there are annotation within t…

Do you have anything similar that you would recommend?

Minix (mini Unix) is a teaching operating system that goes with the well known os book "Operating Systems Design and Implementation". We used it at Cal. Very fun.

Re: Build Your Own Text Editor

#46
post #38

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…

Those features sound really nice. Any links/screenshots?

Ive put just a couple of snaps here: http://imgur.com/a/QMhpf

I really must get round to sharing the source but it needs a bit of preparation.

Re: Build Your Own Text Editor

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

Re: Build Your Own Text Editor

#48

Earlier quoted context omitted.

I was taking about the ability to debug code. Various IDEs/compilers have sometimes issues and bugs on multistatement lines in DWARF/etc. I've worked on a low level debugger, so it was a big problem, even few years back.

Fair enough. But where do you see multistatement lines in the link?

For example: https://github.com/martanne/vis/blob/master/buffer.c

bool buffer_prepend0(Buffer buf, const char data) { return buffer_prepend(buf, data, strlen(data) + (buf->len == 0)); }

Two function calls plus arithmetics plus step-return.

Depending on the debugger interface(eclipse with gdb, vs, etc), one will have to press some form of Step 1 to 4 times to advance the line. Depending on the complier that was supposed to provide correct debug info (GCC vs msvcc vs xlc) and bugs, these steps may or may not work.

It is short, but when you do multi platform code, a real pain to deal with.

Consider aix and Linux multiplatform code for one of my past projects. My choice would have been: 1. Step and maybe hit a bug, msg the complier team, proceed writing register values on paper. 2. Break up the line, recompile. Few minutes on Linux, over half an hour on aix.

Re: Build Your Own Text Editor

#49
post #35
post #29

Earlier quoted context omitted.

Do you have general programming experience?

Yep, lots of Ruby/PHP/Python/Javascript, some Java. So I can comfortably read syntax in most languages, but obviously none of the languages I've used are as low level as C.

If you understand pointers then from a cursory glance at this tutorial you should be fine.

Re: Build Your Own Text Editor

#50

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…

Lua is great for extensions, isn't it?

I forked antizez's editor to add Lua support, and posted it here in the past:

https://github.com/skx/kilua/

That works well for me, even with the minor omissions, and is well-paired with my console-based mail-client - again scripted by lua:

https://github.com/lumail/lumail2/

Post reply on HN