Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

@XVilka
Copy link
Author

XVilka commented Apr 13, 2015

@alihardan
Copy link

alihardan commented Oct 23, 2018

Now, qterminal supports bidi.

@XVilka
Copy link
Author

XVilka commented Oct 26, 2018

Thanks, @ali-hardan, added it.

@mintty
Copy link

mintty commented Oct 26, 2018

mintty also supports bidi

@XVilka
Copy link
Author

XVilka commented Oct 28, 2018

Thanks, @mintty, added it.

@faridcher
Copy link

faridcher commented Nov 6, 2018

Gnome terminal and xterm are supported as mentioned at https://github.com/behdad/bicon

@XVilka
Copy link
Author

XVilka commented Nov 8, 2018

@faridcher here I am speaking about native BiDi support, without the hacks like bicon.

@egmontkob
Copy link

egmontkob commented Jan 29, 2019

I do not understand the "How to test" section, really not sure how to interpret it, not sure what to do with that text in my terminals to test them.

Could you please provide something along the lines of "do this" (emphasis on the word "do") and "if it looks like this then it's good, if it looks like that then it's bad"?

@egmontkob
Copy link

egmontkob commented Jan 29, 2019

I've spent the last few months studying and evaluating the only document about BiDi in terminals that I could locate, as well as existing implementations. Unfortunately I have severe problems with all of them.

The most important problem with all the self-claimed BiDi-aware terminals is that they always apply the Unicode BiDi algorithm on the contents, giving no way for applications to switch it off. This way they literally, mathematically provably become a platform on top of which it's impossible to implement proper BiDi-aware text viewing/editing experience. (In most terminals you can disable BiDi in the settings, but it's an unacceptable user experience if people have to do so every time they start up or quit a text editor.)

They also work on lines of text rather than paragraphs, lack support for overall RTL direction, and suffer from various one-off problems as well.

Thus I'd make the bold claim that the terminals mentioned above as supporting BiDi actually don't. Supporting BiDi doesn't mean unconditionally doing it, since it does about as much harm as good. Supporting BiDi means (among plenty of other things) knowing when to do it and when not to.

I came up with a draft specification on how BiDi should be done in terminal emulators, it's at https://terminal-wg.pages.freedesktop.org/bidi/ . Feedback about this spec is welcome over there. I'm making a somewhat bold, but well supported claim that only terminals that implement BiDi according to this spec should be called BiDi-aware.

Recently Mintty did a couple of improvements, partially along the lines of the new specs. I haven't yet had a chance to evaluate what it supports now and what it still doesn't.

@DirectorX
Copy link

DirectorX commented Jan 29, 2019

Rxvt-unicode with fribidi (Perl) plugin supporting bidirectional text

@XVilka
Copy link
Author

XVilka commented Jul 2, 2019

Just an update - was recently implemented in libvte by @egmontkob: https://terminal-wg.pages.freedesktop.org/bidi/implementations.html#vte

@faridcher
Copy link

faridcher commented Jul 3, 2019

https://github.com/aligrudi/neatvi a fork of VI works great and may be included in the list of programs.

@zzgraph
Copy link

zzgraph commented Apr 4, 2020

I suppose Termite does not support bidirectional text rendering because their code is not compatible with vanilla libvte.

@nemya9066
Copy link

nemya9066 commented Jul 18, 2020

Please Remove Termite from the list it doesn't support bidirectional text they use a different vte library.
Tested on arch linux.

@XVilka
Copy link
Author

XVilka commented Sep 8, 2020

Removed Termite, thanks!

@foodornt
Copy link

foodornt commented Mar 29, 2021

How may someone contribute to one of these terminals to add BiDi support? if anybody can reference a starting point, may it be how to shape fonts, how to implement BiDi, or even the part of code of these libvte based terminals that makes it able to view BiDi text, that would be appreciated.

@SafwanLjd
Copy link

SafwanLjd commented May 18, 2021

Vim actually supports bidirectional text, all you have to do is use a terminal that supports it (or BiCon) and put :set arabicshape! in your .vimrc

@progandy
Copy link

progandy commented Jun 17, 2022

WezTerm has premliminary BiDi support in recent releases: wez/wezterm#784 (comment)

@AvidSeeker
Copy link

AvidSeeker commented Aug 31, 2022

Compiled programs support for Bidi in this ArchWiki article.

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