Text Editing Hates You Too (2019)
lord.io
lord.io
Text editing hates you too (2019) - https://news.ycombinator.com/item?id=27236874 - May 2021 (182 comments)
Text Editing Hates You Too - https://news.ycombinator.com/item?id=21384158 - Oct 2019 (282 comments)
Text rendering hates you (2019) - https://news.ycombinator.com/item?id=36478892 - June 2023 (119 comments)
Text Rendering Hates You (2019) - https://news.ycombinator.com/item?id=30330144 - Feb 2022 (154 comments)
Text Rendering Hates You - https://news.ycombinator.com/item?id=21105625 - May 2019 (170 comments)
One of the more fun programming projects I ever worked on was a custom text editor. Mainly it supported rich annotations that could be applied to any chosen term or stretch of text. It used Mobiledoc[1] which already provided pretty well-developed primitives for rich text editing on the web, and it was still a complicated project, even with a solid framework.
I would expect it to go all the same direction across the text, regardless of which are rtl and ltr characters. If swiping left to right, ltrs would be selected forward, and rtls would be selected backwards (the same as if you just swiped ltrs from right to left).
Edit: video - https://we.tl/t-hAWomZ9DvT
A weird drawback however is that Backspace and Delete would not act on logical text order, but as "Delete Left" and "Delete Right". However, there should be a hotkey for swapping default text direction/justificiation globally that I think could make up for some of that.
I think that, if you are honest about the limitations of your program and convey those to your user as a consistent model, the user would be more willing to accept that model. Just don't claim to support Unicode according to spec if it is likely that only a subset will be supported correctly.
But what simpler format?
If it supports all of Unicode it's not simpler. If it doesn't, then it's missing necessary features entire languages rely on. And missing emoji.
I don't understand what benefit you're trying to provide.
This means questions (functions) like “how many characters do I have”, and indexing in general, are not as straight forward as they could be.
So storing each visual character’s character group together, as a single element, results in a simpler interface from a programming standpoint.
Not necessarily as efficient, since either indirection or larger character footprints (or both) are required, but simpler.
This is definitely the route I would go, while implementing other complexity. After that, possibly undoing this “simplicity optimization”, would be a small price to pay for the development convenience.
> If it supports all of Unicode it's not simpler.
The point is that it doesn't. The Unicode that it does not handle should get marked as "illegal character", rendered as boxes and not get mangled unless the user messes with it.
Support for more of Unicode could be added incrementally, and in a single subsystem instead of everywhere in the text editor.
>> If it supports all of Unicode it's not simpler.
> The point is that it doesn't.
But then it doesn't work. Why would you not want to support all of Unicode?
> The Unicode that it does not handle should get marked as "illegal character", rendered as boxes and not get mangled unless the user messes with it.
That's what already happens. We already show boxes when the codepoint is unknown or there's no glyph in the font. Their codepoints are preserved.
> Support for more of Unicode could be added incrementally, and in a single subsystem instead of everywhere in the text editor.
It already is. New OS's get upgraded to new Unicode versions. Text editors don't usually have to change a thing.
I don't know what problem you're trying to solve here.
> Byte-wise, this should be rendered as a single emoji.
It will be right after you've finished editing! No magic cursor movements.
And it should allow you to move "inside" emojis so you could edit the second modifier to something else (and worth some great UI that could guide you as to which options are available), which would be impossible in the "correct" TextEdit, where you'd have to recompose a new emoji from scratch
I've spent a few minutes staring at this section and still haven't figured it out. Anyone smarter than I care to shed some light?
If Arabic text editors don’t have the cursor behave the same as English ones, that’s fine. If I press backspace in a Hebrew text editor I probably want it to delete the character to the right. The behavior doesn’t need to be universal
Now add to that the fact that nobody wants to build a new editor for every single language, and there you go - all of that gets rolled into a common approach. It's hard to impossible to get right. (Because what you want also depends on context, not just language - URLs demand different behaviors with BiDi than text does)
Even if we wanted to build different editors, as soon as you start quoting things not from your preferred environment, guess what, you have mixed environments and need to start thinking about BiDi
It's a gargantuan mess. Nobody is really getting it right, we're just trying to get closer and closer. (And if you want to see folks in the field pulling out their hair, mention you'd like Boustrophedon writing ;)
Source: UAX 9 and UAX 29 were printouts on my desk for several years, for very good reasons. I still have unsolved problems with BiDi text, I've just given up.
And today the answer to that question means "maintain a very large and dynamic dataset of the world's written languages" which makes it unpalatable to "low level" software, like the standard libraries of every PL that I'm aware of.
I suspect you might be over-indexing on the specific example of emojis and skin tone modifiers that the article used, but on the Unicode implementation level that's just the same modifier characters that several real languages need to use to be encoded properly. It's not a useless frivolity.
Funnily, in the case of English, that would likely mean replacing the latin alphabet with a more complicated script. Because in contrast to e.g. German and Italian, that script really does not fit its phonetics very well. Hell, even Japanese romanization, "romaji", makes much better and more consistent use of the latin alphabet than English. Which is just all kinds of funny to me, English is so bad in that regard, that Japanese, a language which is very far away from English in multiple ways, can make so much better use of the to it foreign latin script. In fact, English is so extraordinarily bad in using the latin script, that the English-speaking world even has literal contests about how to spell pronounced words, called "spelling bees".
And yet I see no real efforts to simplify that gaining traction.
Most of the so-called complexity in English is just about scoring "style points", it's not necessary to communicate (other than the admittedly huge vocabulary - again a result of its formation from multiple influences).
The irony is English is simultaneously the best and worst option. It can incorporate things from almost any other language while making spelling them correctly impossible. Good luck memorizing adjective order and the nearly infinite number of idioms. A lot of them come from British sailors.
The whole point of Unicode is to encode languages. We already handle Arabic, which means we should be able to handle most languages. Even if we can’t convert a language into codepoints, we have the ability to record sound and images in resolutions beyond human acuity.
You’re right the technology dictates form. The computers represent English different than print. Due to the limitations of previous technology, indented paragraphs are less common than an empty line between paragraphs. Same with single-width or double spaces after periods.
In my experience, the complexity comes from the reality of how we write in different writing systems. I think this is inevitable.
Emoji don't introduce any edge cases of their own. If your software can't join a skin tone to a thumbs up, it also will fall apart on composing many scripts used by hundreds of millions of people.
So if you really want to get all kids-these-days about emoji, go ahead, but support Unicode properly. You'll get correct emoji handling as a consequence of that anyway, and you can still signal whatever message you're intending to send here about yourself in some other way.
That only works if you're dealing with a single line.
Once you're dealing with paragraphs (lines that wrap) your model won't work. Much less with entire documents.
Imagine if programmers were stenographers and computing wasn’t born/grew up in an age with slow teletypes. Maybe most computer code would be keyword/word-heavy (because that’s what stenography is good at) instead of symbol.. heavy.
But there's been a steady increase in the popularity of chorded keyboards with a small number of keys, which is kind of like stenography but probably more suitable to writing code. I don't really like them myself (I prefer a 60% keyboard with macros and layer modifiers over memorizing a bunch of chords), but some people swear by them. I assume there are projects to do it in software as well if you don't want a fancy new keyboard. I'd look in that direction if you want to check this out.
Relatively modern tools like vim and Perl inherited the syntax of the parsimonious, symbol-heavy teletype era.
My focus has been CL and clojure.
If you want something that is capable of both qwerty AND steno, consider the polyglot from https://stenokeyboards.com/ (not sponsored).
Just remember the line number you're on, rather than the byte. You already agreed for the cursor to operate in 2D space when storing the x-position. Also, you shouldn't operate on bytes, but on grapheme clusters, which solves the emoji problem.
> Emoji Modifiers
Come on, just don't allow a skin tone modifier to modify a newline, that's silly. Allow it to modify only what you can support it modifying, so emojis with alternate skin colors. The problem is what if you want to modify grapheme clusters, IMHO you should have a small (like with autocomplete suggestions) "magnifying" popup , where the cursor continues to move as it pauses in the main text, this however would be tricky to implement for a mouse - you can control and move the mouse but it may be annoying to many users; speaking of which...
> Bidirectional Text
"Proper" bidi behavior I find very confusing and annoying, with the selection splitting. IMHO there should be main text body with some direction, and within it *embeds*, and those embeds are selected in its entirety (you usually would select part of text body with the entire quote). Now you don't have surprising, unintuitive behavior of selection, and the implementation is easy. Of course embeds can have embeds within them, and if you start selection within the embed, you now treat it as full text body, allowing to select a fragment of it. The moment you leave the embed while dragging your mouse, the whole embed is selected (but just like with x-position, the selection anchor is remembered if you return to the embed), similarly to how the whole word is selected when you start selecting it but then move outside the word in Microsoft Office Word. And if you really need to select a fragment of the embed + something else, just select whole embed + something else, copy, paste, and delete the fragment you don't want and deal with it.