pi314 / ime.vim Goto Github PK
View Code? Open in Web Editor NEWA Vim input method engine
License: BSD 2-Clause "Simplified" License
A Vim input method engine
License: BSD 2-Clause "Simplified" License
目前遇到 apple_id
會轉換為 apple_誤
到時候再看 :help boshiamy
和 :help ime
是否要分成不同文件,如果 :help boshiamy
資訊不多的話,留在 :help ime
,用 tag reference 就好
最近開始工作,公司的電腦上沒有嘸蝦米
現在是用 http://boshiamy.com/hliu.php 網頁版
但每次打完字都需要手動複製文字,不是很方便
好在公司的電腦可以安裝 GVim 7.3,也還好這份 plugin 的核心功能都可以使用
目前在構思,GVim 能不能讓中文輸入更方便呢?
如果能在輸入文字以後自動複製,這樣雖然在打字時仍然需要切換到 GVim,但輸入以後就可以直接回到原本的視窗了
s:CharType()
有必要重新整理
from #8
因為 boshiamy#send_key()
已經不再是 public API
目前是 hardcode 產生嘸蝦米 cin 的邏輯,也許可以讓各輸入法自行定義輸出方式?
沒遇到什麼問題,只是突然想這樣改
這樣 ime.vim 就不用從字串產生 mapping,減少風險
g:ime_toggle_english
g:ime_select_mode
g:ime_select_mode
g:ime_switch_2nd
g:ime_cancel_input
g:ime_switch_submode
ime#export_cin_file()
例如不要把 [banana]
輸出成 [banana」
這對 [嘸蝦米]
可能無效,但針對英文做判斷應該就足夠了
在使用微軟內建的注音輸入法時,如果按下 Ctrl
+ Alt
+ ,
,
就會跳出一個小鍵盤,上面全是標點符號,
此時按下對應的按鍵就能輸入對應的符號。
現在內建的日文假名模式,如果要輸入片假名,一定要在字根後面加上一個 .
。
如果能讓輸入模式有自己的子模式,這些不方便可能都可以解決。
例如按下某個鍵,日文假名模式的 icon 就從 [あ]
變成 [ア]
,以後就都以片假名輸入。
例如按下某個鍵,注音模式的 icon 就從 [注]
變成 [,]
,
之後按下的第一個鍵會是標點符號,然後 icon 變回 [注]
。
現在好像是直接 unmap,但輸入法可能設定了很多 trigger key,要考慮到常用 key 例如 <tab>
有別的 plugin 在使用的狀況。
vim 本身沒有 socket interface,但這可以透過 language binding 解決。
如果系統輸入法有類似 client / server 的架構,也有 API,說不定可以讓 vim 去 query 它,回傳結果,再拿來用 menu 顯示。
ime-phonetic.vim had started using Vader.vim for testing
目前輸出:,o
→ お
官方字根表:o,
→ お
http://vim.1045645.n5.nabble.com/Funcref-and-script-local-functions-td1151686.html
這篇文章描述了和我一樣的問題,Vim 作者 Bram Moolenaar 表示「就是這樣設計的」
我不知道為什麼 Vim 7.4 開始能把 script local Funcref
傳出去,但總之 7.3 不行
:help boshiamy
放一般 user 會用得到的設定以及 public API:help boshiamy-dev
放詳細的文件,不用每行 code 解釋,但儘可能把設計的想法寫進去雖然說 fallback menu 是為了沒有 CompleteDone 的環境而做的,但好像有點好用。
考慮再次開放 g:ime_select_mode_style
。
∀
∃
Vim 的 replace mode 會把文字蓋掉,但這些蓋掉的字會保留一段時間,補完的時候會把不應該蓋掉的字填回原位。
我在畫 ASCII 流程圖的時候常用 replace mode 填字,但一個中文字兩格寬,一次只會蓋掉一個字元,有點不方便。
今天想到可以檢查補完的內容,如果長度都相同為 n
,且後方 n
個字元都是空白字元,這些字元可以被覆蓋掉。
而且這個邏輯和輸入模式無關,只和補完的行為有關。
Now they are 'menu'
/ 'fallback'
, I think 'popup'
/ 'interactive'
are more appropriate names.
function! s:set_title ()
for l:idx in [''] + map(range(2, bufnr('$') + 1), '"-". v:val')
try
" the ``file`` command expands ``#``, so it has to be escaped
let t:localtablabel = 'cim' . l:idx
execute 'file cim' . l:idx
break
catch /^Vim\%((\a\+)\)\=:E95/
endtry
endfor
endfunction
setlocal buftype=nofile
setlocal noswapfile
call s:set_title()
execute 'set guitablabel='. &guitablabel
inoremap <expr> <buffer> <CR> (pumvisible() ? "<C-Y>" : "") . (getline('.') == '' ? "<C-R>*" : "<ESC>0\"*C")
vnoremap <CR> "*d
Keep blinking due to redraw on every key stroke.
g:boshiamy_cancel_input
的原則就是,懶:想在一堆中文字之間嵌入英文單字,但又不想切回英文,若輸入了 id
, user
等常用單字,可以方便的把它們打回英文
但打字的速度稍微快一點的時候,常常在發現的時候已經打了下一個字,這時候才按下 cancel input 已經來不及了,所以 cancel input 的範圍需要加大才行
除了 complete()
以外,getchar()
和 echo
也可以做到互動式的選單
以下的 snippet 可以解掉這個問題
function! IMEStatusString ()
if exists('*ime#mode')
return ime#mode()
endif
return ''
endfunction
之後再來追一下 vim 的 patch history,看看是不是 vim 的 bug,然後把結論寫在 doc & README 裡。
doc/ime.twx
doc/ime.txt
README.rst
README.en.rst
用 getchar()
、echo
和 redraw
做出互動式選單,就不需要 input()
了
目前 plugin 宣告的 key 都會直接被拿來填給 inoremap
,但這樣很不方便。
例如對 <space>
的處理,plugin 需在 trigger
裡寫 '<space>'
,
handler
拿到的也會是 '<space>'
這個字串。
實際使用後發現其實 plugin 常常需要的是空白字元 ' '
同樣的問題還有 <bar>
打算改讓 plugin 直接寫 ' '
和 '|'
,ime.vim 建一張表做對應就好,也讓 handler
直接拿到原本的字串。
目前大小寫字母之間是沒有分隔的,所以 BANANAs.
只會變成 BANANAs。
而不會變成 BANANA?
這個 issue 只是記錄一下,在打字時遇到一點困擾
像是嘸蝦米本身,主要是實作了 fallback 的行為,讓 regex 很難寫
可能要考慮讓 pattern 可以是 function,或是回傳值可以選擇性的帶有長度
例如 runes、braille、全型字、Unicode
這些輸入模式如果能做成 plugin 的話,彈性會更大
例如注音模式,在核心抽象化以後可能會是 standalone plugin,但同時也是 embedded plugin。
雖然不換應該也不會怎樣,還是換吧,畢竟其他模式都用各自的符號做 icon 了
IME = Input Method Engine,目標是做更大的抽象化,儘可能讓各種輸入法都能接上來,不限中文。
改名以後,程式碼內的 boshiamy
也都要改成 ime
。
Error detected while processing function <SNR>51_CompSelectMode:
line 4:
E121: Undefined variable: v:completed_item
It is said that v:completed_item
is added in 7.4.774, I hit this problem on Vim 7.4.52
預定去除項目:
,poker*
🃑🃒🃓🃔🃕🃖🃗🃘🃙🃚🃛🃜🃝🃞
🃁🃂🃃🃄🃅🃆🃇🃈🃉🃊🃋🃌🃍🃎
🂱🂲🂳🂴🂵🂶🂷🂸🂹🂺🂻🂼🂽🂾
🂡🂢🂣🂤🂥🂦🂧🂨🂩🂪🂫🂬🂭🂮
☰
, ☱
, ☲
, ☳
, ☴
, ☵
, ☶
, ☷
目前是 hard code 成 <space>
,但如果要讓 core 繼續抽象化,需要考慮其他輸入法的習慣。
例如注音輸入法的送字可能會在 3
(ˇ
)、4
(ˋ
)、6
(ˊ
)、<space>
觸發,如果要做得更友善,可能會在每個 key 都觸發。
這個想法還在考慮中,如果要納入注音輸入法,就得考慮選字選詞的問題,
git
也沒有 Cygwin
,所以不管是 Vundle
、 vim-plug
還是其他 plugin manager 都不能用必要時把一些內容分到別的 readme 檔案,例如「其他安裝方式」
If plugin handler returns []
, ime.vim treat it as no result and inserts the key.
But sometimes the key is correctly handled in the other way, the key shouldn't be inserted into buffer.
Currently this can be hacked by returning ['']
: ime.vim think "it's a result" but it doesn't generate any strings.
I suggest providing ime#NOP
(= ['']
), which is more meaningful.
如題, 培
通常唸做 ㄆㄟˊ
,但之前整理字根表用的 script 沒有考慮到破音字,故 ㄆㄛˇ
的第一順位也被排成 培
,應將
let g:boshiamy#chewing#table[';q.3'] = ['培', '剖', '瓿', '掊', '勏', '婄', '棓', '犃', '篰']
修正為
let g:boshiamy#chewing#table[';q.3'] = ['剖', '培', '瓿', '掊', '勏', '婄', '棓', '犃', '篰']
boshiamy#add('liu', '嘸蝦米')
之類的,讓使用者不需修改 source code 也能自訂詞組
Every document should have English version
README.en.rst
README-install-manually.en.rst
doc/ime.txt
doc/ime-plugin.txt
目前 CompleteDone
事件被用來選擇不同的輸入模式,但 Vim 7.3 不支援
若要讓輸入模式能有彈性的增加,需要別的方式切換不同模式
例如在缺乏字型的環境中,應該要可以把 runes、braille 和 emoji 關閉
注音和拼音的邏輯有一部份類似,同一份 code 應該要能註冊成兩個 standalone plugin
發現 :help ime-plugins
裡面對 ime#{}#info()
的敘述要修正為 ime_{}#info()
。
plugin 的 handler()
說明也忘了加 trigger
資訊。
否則常常會輸入 emoji
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.