ParagraphEditor >> prettyPrintCommand を定義する。(editing keys プロトコルに追加)
prettyPrintCommand: characterStream
sensor keyboard.
self prettyPrint.
^ true
ParagraphEditor class >> initializeCmdKeyShortcuts を書き換える。
initializeCmdKeyShortcuts
| cmdMap cmds |
cmdMap := Array new: 256 withAll: #noop:. "use temp in case of a crash"
cmdMap at: (1 + 1) put: #cursorHome:. "home key"
・
・(中略)
・
$t tempCommand:
$u align:
$v paste:
$w prettyPrintCommand:
$w backWord:
$x cut:
$y swapChars:
$z undo:
).
1 to: cmds size by: 2 do: [ :i |
cmdMap at: ((cmds at: i) asciiValue + 1) put: (cmds at: i + 1).
].
CmdActions := cmdMap
最後に以下を"do it"。
ParagraphEditor initialize
以後、command-key(or alt-key) + w でフォーマットが実行される。