Skip to content
forked from behdad/bicon

BiCon—The Bidirectional Console

License

Notifications You must be signed in to change notification settings

NightMachinery/bicon

 
 

Repository files navigation

BiCon - The Bidirectional Console

Dependencies

  • FriBiDi >= 0.10.4 (library AND headers)

Installation

You need the FriBidi library to compile this program. Probably you have it in your distribution. If not, get it from http://fribidi.org/ . You can install it via Homebrew as well (works on both Linux and macOS):

brew install fribidi

Installation is simple, the usual steps:

./autogen.sh
./configure
make
make install

macOS

Things seem to somewhat work, but:

  • The build fails its last step because there is no psfaddtable on macOS. This doesn't seem to matter.
    • The built binary can be found at ./bicon/bicon.bin.
  • Sometimes programs exit abnormally: [1] 15104 abort bicon.bin ls. This also doesn't seem to matter, but you do need to do a reset on the terminal after it.
    • I have added a test file that triggers this: bicon.bin cat ./macOS/test.txt
  • Opening a shell with bicon seems to work without problems.

Usage

This program currently can be used under Linux console, or terminal emulators with basic Unicode rendering support, like gnome-terminal, xterm, or PuTTY.

Simply run "bicon" to get a console supporting Arabic or Persian. The language used is chosen according to the LANG environment variable.

You can also choose the language country by specifying the country on the country on the command line, e.g ::

bicon sa          # enables Arabic (Saudi Arabia) support
bicon ir          # for Persian (Iran)

You can use the alt+shift combination to switch keyboard language.

Of course, you have a man page bicon(1) to check.

Emacs

This works for me:

function bicon-emc() {
  bicon.bin --reshape-only emacsclient -t "$@"
  reset
}

Take care not to run this from a shell that is itself running under bicon. You need to use this function if you want to do so (you also need the wrappers defined in the known issues section):

bicon-emc () {
    if isBicon
    then
        {
            (
                emacsclient -t -e "(progn (setq-default bidi-display-reordering nil) (redraw-display))" "$@"
            )
        } always {
            emacsclient -e "(setq-default bidi-display-reordering t)"
        }
        return $?
    fi
    biconm --reshape-only emacsclient -t "$@"
    reset
}

And it will still not be good for editing RTL text, as Emacs is confused by the bidi reversal that bicon does.

Known Issues

  • Text that is soft-wrapped, is vertically inverted. You can wrap the text yourself using, e.g., command ggrep -Eo ".{1,100}", to avoid this problem.
  • tmux is somewhat buggy, but still usable. (See the screenshots.)
  • As the RTL text is changed in order to be displayed correctly, copying it will probably not work as you intend it.
  • Some zsh plugins are somewhat incompatible with running under bicon:
    • zsh-syntax-highlighting
    • zdharma/fast-syntax-highlighting
    • zsh-users/zsh-autosuggestions

One workaround is to wrap your invocations of bicon in:

biconm () {
    BICON_MODE=y bicon.bin "$@"
}
bicon-zsh () {
    biconm zsh
    reset
}

Then check if zsh is running under bicon:

isBicon () {
    test -n "$BICON_MODE"
}
if ! isBicon ; then
  antibody bundle zdharma/fast-syntax-highlighting # etc
fi

Screenshots

All the screenshots have been taken on iTerm 3.4.4 (macOS).

Reporting Bugs

Please report all bugs to http://github.com/behdad/bicon

About

BiCon—The Bidirectional Console

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 44.6%
  • Makefile 21.1%
  • SWIG 11.0%
  • Perl 10.9%
  • Shell 10.2%
  • M4 2.2%