Input CJK

samuraicoder.net – My WordPress Blog

# open CocoaDialog's textbox
res=$(CocoaDialog textbox ?
       --title "Input CJK" ?
       --informative-text "Write up here..." ?
       --selected ?
       --scroll-top top ?
       --editable ?
       --no-newline ?
       --button1 "Insert" ?
       --button2 "Cancel")
# If user canceled exit.
[[ $( (tail -r <<<"$res") | tail -n1)  == "2" ]] && ?
         exit_discard
# delete first line
res=$(sed '1,1d' <<<"$res")
# print the content of the textbox
echo -n "$res"

IM=`defaults -currentHost read com.apple.HIToolbox AppleKeyboardScript`

if [ $IM != 'smRoman' ]; then
osascript << EOF
tell application "System Events"
  keystroke " " using command down
end tell
EOF
fi