Version 1.2.1: forgot to add the pure vimscript version: so/fcitx.vim

This commit is contained in:
lilydjwg 2012-10-04 00:00:00 +00:00 committed by Able Scraper
parent 6b07b1e728
commit 9c757c161d
2 changed files with 49 additions and 1 deletions

49
so/fcitx.vim Normal file
View file

@ -0,0 +1,49 @@
" fcitx.vim 记住插入模式小企鹅输入法的状态
" Author: lilydjwg
" Maintainer: lilydjwg
" Last Change: 2010-11-18
" Note: 另有使用 Python3 接口的新版本
" ---------------------------------------------------------------------
" Load Once:
if (has("win32") || has("win95") || has("win64") || has("win16"))
" Windows 下不要载入
finish
endif
if !exists('$DISPLAY')
" 没有 X不要载入
finish
endif
if &cp || exists("g:loaded_fcitx") || !executable("fcitx-remote")
finish
endif
let s:keepcpo = &cpo
let g:loaded_fcitx = 1
set cpo&vim
" ---------------------------------------------------------------------
" Functions:
function Fcitx2en()
let inputstatus = system("fcitx-remote")
if inputstatus == 2
let b:inputtoggle = 1
call system("fcitx-remote -c")
endif
endfunction
function Fcitx2zh()
try
if b:inputtoggle == 1
call system("fcitx-remote -o")
let b:inputtoggle = 0
endif
catch /inputtoggle/
let b:inputtoggle = 0
endtry
endfunction
" ---------------------------------------------------------------------
" Autocmds:
au InsertLeave * call Fcitx2en()
au InsertEnter * call Fcitx2zh()
" ---------------------------------------------------------------------
" Restoration And Modelines:
let &cpo=s:keepcpo
unlet s:keepcpo
" vim:fdm=expr:fde=getline(v\:lnum-1)=~'\\v"\\s*-{20,}'?'>1'\:1