gdb で VisualStudio キーバインド
VisualStudio キーバインド
http://msdn.microsoft.com/library/ja/default.asp?url=/library/ja/vsintro7/html/vxurfvisualstudio70defaultshortcutkeys.asp
kterm + screen + vim + gdb でデバッグするとき VisualStudio のキーバインドを使いたい。
まずは Start(F5)、StepOver(F10) と StepInTo(F11)。.inputrc にこう書いた。
$if Gdb # F5 : continue "\e[15~": "c \C-m" # F10 : next "\e[21~": "n \C-m" # F11 : step "\e[23~": "s \C-m" $endif
しかし実際やってみると、これらのキーの後にさらに何かを押さないと next が実行されない。
このキーシーケンスで始まるエスケープシーケンスが他にもある??
次は StepOut(S-F11)と RunToCursor(C-F10)。
端末ではファンクションキーと Shift, Ctrl の組合せは認識できないので、.Xdefaults に kterm の translations を書いて対処。
KTerm*VT100.translations: #override \ Shift<Key>F11: string("finish") string(0x0d)\n\ Ctrl<Key>F10: string(":Advance") string(0x0d)\n\
advance と break はファイル名と行番号を指定するため、vim から使うことにする。しかたがない。
http://d.hatena.ne.jp/parasporospa/20060827/1156679053
ついでに Breakpoint をブレークポイントトグルするように改良。
" カレントファイルのカレント行にブレークポイント設定/解除 command! Breakpoint call Breakpoint() command! ListBreakpoints sign place sign define br text=>> texthl=Search let g:bpmap = {} let g:bpsignplace = 0 function! Breakpoint() let pos = expand("%") . ":" . line(".") if !has_key(g:bpmap, pos) let g:bpsignplace += 1 let g:bpmap[pos] = g:bpsignplace exe ":sign place " . g:bpsignplace . " line=" . line(".") . " name=br file=" .expand("%") call system("screen -X eval focus 'stuff \"b " . pos . "\"\\015' focus") else exe ":sign unplace " . g:bpmap[pos] unlet g:bpmap[pos] call system("screen -X eval focus 'stuff \"clear " . pos . "\"\\015' focus") endif endfunction
sign は ID を自分で管理しなければならないのがとても不便だ。
コマンドの構文も他の vim コマンドと少し毛色が違う気がする。
Kterm ではまったこと
KTerm*VT100.translations: #override \
のところを
KTerm*translations: #override \
と書くと "Warning: Actions not found: string" などと出てしまう。
これについて調べていたらこんなものを見つけた。
http://www.sic.med.tohoku.ac.jp/~mladmin/w3m-dev/200103.month/1749.html
xterm/kterm は -name オプションにより、リソース名を取得するときのアプリケーション名を指定できるらしい。
これと translations を使えば、コンソールアプリを1枚のウィンドウで開いてさらに独自のキーバインドを定義できるわけだ。
すばらしい。