Add IME support on OS X

Closes #1247, #1672, #1695.