Skip to content

Instantly share code, notes, and snippets.

@XVilka
Last active August 9, 2024 06:36
Show Gist options
  • Save XVilka/a0e49e1c65370ba11c17 to your computer and use it in GitHub Desktop.
Save XVilka/a0e49e1c65370ba11c17 to your computer and use it in GitHub Desktop.
BiDirectional Text

This gist will show the support of BiDirectional text in the terminal emulators and console programs. You can read more about the standardization efforts at the dedicated page of FreeDesktop Terminal BiDi working group.

How to test

Logical Order ◀ ◀ ◀ RTL LTR ▶ ▶ ▶
WHAT IS UNICODE؟ in arabic in arabic ؟EDOCINU SI TAHW ؟EDOCINU SI TAHW in arabic
ما هو الترميز الموحد يونيكود؟ in Arabic ما هو الترميز الموحد يونيكود؟ in Arabic

Supporting BiDirectional text

According to a new standard

Please note, that specification is preliminary yet, and VTE implementation is still work in progress:

Incompatible and incomplete implementations

Supporting BiDirectional text programs, but incompatible

Not supporting BiDirectional text

Terminal multiplexers

Not supporting BiDirectional text programs

@ctrlcctrlv
Copy link

@wez Sure!

Do:

ssh [email protected]

No password. That's not how I ssh to デブ.狸.agency and is there as a joke against would-be crackers and skiddies, but it's useful for this too! (As that message is just my MOTD.)

@anonimo0-0
Copy link

So is there a terminal that supports bidi yet? Gnome terminal isn't that good. I've tried to run Neovim inside it, and got the wrong behavior. mlterm seems to be the one with the best behavior out of all the ones that I've tried, but its documentation is lacking and it doesn't look very nice out of the box.

@ctrlcctrlv
Copy link

that is the state of the art. mlterm does the best job.

@cben
Copy link

cben commented Aug 21, 2023 via email

@ctrlcctrlv
Copy link

perhaps bidi better on win32 but i see dotted circles

fails both deva and hebr

image

@mmstick
Copy link

mmstick commented Dec 20, 2023

cosmic-term supports bidirectional text and ligatures via cosmic-text: https://fosstodon.org/@soller/111602927867586005

@wolandark
Copy link

wolandark commented Jul 24, 2024

Konsole is actually doing a great job at bidi, in fact it is the only terminal that renders the RTL text from the right edge of the terminal window.

See this screenshot from Konsole displaying English and Persian bible text in one window.

I'm not sure if others can render LTR and RTL text in such fashion.

The settings window

@mintty
Copy link

mintty commented Jul 24, 2024

I'd say all terminals I've seen to do bidi do it that way - how else? To check, however, please upload your test file.

The konsole feature "Table characters BiDi mode override" might be interesting but unfortunately it is not really specified (which characters? examples?); maybe I'll submit them an issue.

@MoSal
Copy link

MoSal commented Jul 24, 2024

@wolandark

In any VTE-based terminal, echo '\e[?2501h' to enable auto-direction, and you should get the same behavior.

This comes from terminal-wg's BiDI draft proposal.

@wolandark
Copy link

@MoSal Neat! I didn't know that. After running the escape sequence, XFCE terminal also behaves the same as Konsole does.

@wolandark
Copy link

@mintty here is a sample of the text (though what I shared in the screenshot was being fetched from an API).

As mentioned above, doing as MoSal suggested, makes XFCE terminal (which is VTE) behave the same way as Konsole, so I guess my defense of Konsole is relevant, though in my defense there is no need to run any escape sequence in Konsole to get this behavior.

@MoSal
Copy link

MoSal commented Jul 24, 2024

though in my defense there is no need to run any escape sequence in Konsole to get this behavior.

FWIW, LTR instead of AUTO as a default paragraph direction was a design choice which I, as a native speaker of an RTL language, tend to agree with.

@mintty
Copy link

mintty commented Jul 26, 2024

The konsole feature "Table characters BiDi mode override" might be interesting

It appears that mintty already has a mode that seems to render table layout like konsole: echo -e "\e[?2501l".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment