From 9c757c161d51aaec6167d3e41b77ff6908313f8c Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Thu, 4 Oct 2012 00:00:00 +0000 Subject: [PATCH] Version 1.2.1: forgot to add the pure vimscript version: so/fcitx.vim --- plugin/fcitx.py | 1 - so/fcitx.vim | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 so/fcitx.vim diff --git a/plugin/fcitx.py b/plugin/fcitx.py index 847ecbd..5de12bb 100644 --- a/plugin/fcitx.py +++ b/plugin/fcitx.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 # vim:fileencoding=utf-8 import os diff --git a/so/fcitx.vim b/so/fcitx.vim new file mode 100644 index 0000000..507fb4a --- /dev/null +++ b/so/fcitx.vim @@ -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