--Boundary_(ID_2y+L2IzElmGKkqvFnkScKQ)
Content-type: text/plain; charset=ISO-8859-1; format=flowed
Content-transfer-encoding: 7BIT

Tzafrir Cohen wrote:

>bidi formatting characters.
>
>  
>
Agree that bidi chars is the way it SHOULD be done, however in current 
state of affairs, there's two problems with these:

1) There's no general way of typing them. Some apps might have them, but 
it really should be done by an xkb keyboard layout (the standard hebrew 
one does not include bidi stuff).

For that specific issue - I've prepared an xkb symbols file. It's 
included in the attached bash-script, which acts as an 
installer/uninstaller/activate/deactivate tool (just put it in 
/usr/local/bin and your'e fine).
To access the new keys: *in hebrew mode only* press 
SHIFT+F{1,2,3,4,5,6,7} (instructions are also printed by the installer.
 Pls let me know of any comments or suggestions (esp: which keys you 
think they should be on).

2) Applications don't always handle them right. For example, OpenOffice 
handles them correctly, but makes them visible - depending on the font, 
you usually see an annoying blank square in their place (they should be 
invisible - at least if you call yourself WYSIWIG). gedit behaves quite 
well with these chars - but there's some annoying issues concerning 
cursor movement with arrow keys.



--Boundary_(ID_2y+L2IzElmGKkqvFnkScKQ)
Content-type: text/plain; name=bidisetup
Content-transfer-encoding: 7BIT
Content-disposition: inline; filename=bidisetup

#!/bin/bash
#
# Depends:
#  XFree86 4.3.x or matching (for xkb & multi-layout support)
#  bash (script's language)
#  ssh (for the scp. Maybe we should use su instead somehow?)
#  awk (for the installation thingy)
#

VERSION="0.5"

XSERVER="localhost"
CHKDIRS="/etc/X11/xkb/symbols /usr/X11R6/lib/X11/xkb/symbols 
/usr/local/X11R6/lib/X11/xkb/symbols /usr/local/etc/X11/xkb/symbols"
TMPFILE="/tmp/xkbaddbidi_symbols_bidi"
BIDIFILENAME="bidi"

function frstdir {
  for cdir in $*; do
    if [ -d $cdir ]; then
      echo $cdir
      break
    fi
  done
}

function putbidifile {
  cat >$1 <<-EOF
        // \$XConsortium: \$
        //
        // \$XFree86: \$
        //
EOF
  if [ $? != 0 ]; then return 1; fi
  echo "// This is BidiSymbols. Version: $VERSION" >>$1
  cat >>$1 <<-EOF
        //
        // To use add +bidi:2 to symbols e.g.:
        //   setxkbmap -symbols \`setxkbmap -v | awk '/^symbols:/ {print \$2 
"+bidi:2"}'\`
        
        partial default function_keys xkb_symbols "bidi" {
            name[Group1]= "bidi";
            // Begin "Function" section
            key <FK01> { type[Group1]="TWO_LEVEL", 
                         symbols[Group1]=[ F1 , U202A ]}; //LRE
            key <FK02> { type[Group1]="TWO_LEVEL", 
                         symbols[Group1]=[ F2 , U202B ]}; //RLE
            key <FK03> { type[Group1]="TWO_LEVEL", 
                         symbols[Group1]=[ F3 , U202C ]}; //PDF
            key <FK04> { type[Group1]="TWO_LEVEL", 
                         symbols[Group1]=[ F4 , U202D ]}; //LRO
            key <FK05> { type[Group1]="TWO_LEVEL", 
                         symbols[Group1]=[ F5 , U202E ]}; //RLO
            key <FK06> { type[Group1]="TWO_LEVEL", 
                         symbols[Group1]=[ F6 , U200E ]}; //LRM
            key <FK07> { type[Group1]="TWO_LEVEL", 
                         symbols[Group1]=[ F7 , U200F ]}; //RLM
        };
        
EOF
}

function get_bidi_version {
  cat ${SYMBDIR}/${BIDIFILENAME} | awk '/This is BidiSymbols/ {print $NF}'
}

function install_bidifile {
  putbidifile $TMPFILE
  if [ $? != 0 ]; then return $?; fi
  echo "Installing bidi file (version=${VERSION}) in ${SYMBDIR}/${BIDIFILENAME}"
  echo "You'll need to supply root password"
  scp $TMPFILE [EMAIL PROTECTED]:${SYMBDIR}/${BIDIFILENAME}
}

function uninstall_bidifile {
  setxkbmap
  echo "Uninstalling bidi file (version=${VERSION}) from ${SYMBDIR}/${BIDIFILENAME}"
  echo "You'll need to supply root password"
  ssh [EMAIL PROTECTED] rm ${SYMBDIR}/${BIDIFILENAME}
  echo "bidi character keys support uninstalled"
}

function is_activated {
  if ( xmodmap -pk | grep U202A >/dev/null ); then echo 1
  else echo 0
  fi
}

function activate_bidi {
  setxkbmap -symbols `setxkbmap -v | awk '/^symbols:/ {print $2 "+bidi:2"}'`
  if [ $? != 0 ]; then return 1; fi
  
  echo "Unicode bidi keys were successfuly added"
  echo "The new keys (work only in hebrew mode) are:"
  echo "  SHIFT+F1 : LRE"
  echo "  SHIFT+F2 : RLE"
  echo "  SHIFT+F3 : PDF"
  echo "  SHIFT+F4 : LRO"
  echo "  SHIFT+F5 : RLO"
  echo "  SHIFT+F6 : LRM"
  echo "  SHIFT+F7 : RLM"
}

function deactivate_bidi {
# check: does setxkbmap with no options set as specified in XF86Config?
  setxkbmap
  if [ $? != 0 ]; then return 1; fi
  echo "bidi character keys deactivated"
}

echo "Bidi Character Support Setup (version $VERSION)"
echo "--------------------------------------------"

SYMBDIR=$(frstdir $CHKDIRS)

if [ "$SYMBDIR" = "" ]; then
  echo could not find a valid xkb installation 1>&2
  exit 1
fi

OPTS=""

if [ -f ${SYMBDIR}/${BIDIFILENAME} ]; then
  if [[ $(get_bidi_version) < $VERSION ]]; then
    echo ... Found older version $(get_bidi_version) in ${SYMBDIR}/${BIDIFILENAME}
    OPTS="$OPTS Upgrade"
  else
    echo ... bidi charset file already installed : ${SYMBDIR}/${BIDIFILENAME}

    if (( $(is_activated) )); then
      OPTS="$OPTS Deactivate"
    else 
      OPTS="$OPTS Activate"
    fi
    OPTS="$OPTS Uninstall"
  fi
else
  OPTS="$OPTS Install"
fi


#echo "<$OPTS>"
#for i in $OPTS; do echo "<${i}>"; done

NOPTS=$(echo $OPTS | wc -w)

# if single option - do it
if (( ${NOPTS} == 1 )); then
  opt=$(echo $OPTS) #get rid of leading ws
  case $opt in
     Install|Upgrade)
       if (( $(is_activated) )); then deactivate_bidi; fi
       install_bidifile
       if [ $? != 0 ]; then exit $?; fi
       activate_bidi
       if [ $? != 0 ]; then exit $?; fi
       ;;
     *)
       echo "Bug? Illegal option <$OPTS>" 2>&1
       exit 1
       ;;
  esac

#several possibilities - ask user
else

  echo "select option (or press ^D to quit)"
  select opt in $OPTS; do
    case $opt in
       Uninstall)
         if (( $(is_activated) )); then deactivate_bidi; fi
         uninstall_bidifile
         if [ $? != 0 ]; then exit $?; fi
         ;;
       Activate)
         activate_bidi
         if [ $? != 0 ]; then exit $?; fi
         ;;
       Deactivate)
         deactivate_bidi
         if [ $? != 0 ]; then exit $?; fi
         ;;
       *)
         echo "Illegal option <$OPTS>" 2>&1
         exit 1
         ;;
    esac
    exit 0
  done
fi

--Boundary_(ID_2y+L2IzElmGKkqvFnkScKQ)--

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to