OSX的默认kill(function fetch_array($result){
global $con;
return mysqli_fetch_array($result);
}
)和yank(ctrl + k
)功能不起作用。
光标移动的其他键绑定也被禁用。
因此,我正在尝试使用ctrl + y
模拟该功能。
但是我不知道如何从Hammerspoon调用Hammerspoon
和kill
函数。
我只能用此代码实现光标移动。
yank
我搜索了一些用于Emacs仿真的Hammerspoon脚本,但它们只是使用该功能的按键。
有没有办法直接从Hammerspoon脚本中调用kill和yank?
如果local EmacsKeyMap = hs.hotkey.modal.new()
local function sendKey(mods, key)
return function()
hs.eventtap.keyStroke(mods, key, 10000)
end
end
local function bindToEmacsKeyMap(mods, key, func)
EmacsKeyMap:bind(mods, key, func, nil, func)
end
bindToEmacsKeyMap({'ctrl'}, 0, sendKey({'command'}, 'left')) -- C-a
bindToEmacsKeyMap({'ctrl'}, 14, sendKey({'command'}, 'right')) -- C-e
bindToEmacsKeyMap({'ctrl'}, 11, sendKey({}, 'left')) -- C-b
bindToEmacsKeyMap({'ctrl'}, 3, sendKey({}, 'right')) -- C-f
bindToEmacsKeyMap({'ctrl'}, 45, sendKey({}, 'down')) -- C-n
bindToEmacsKeyMap({'ctrl'}, 35, sendKey({}, 'up')) -- C-p
bindToEmacsKeyMap({'ctrl'}, 4, sendKey({}, 'delete')) -- C-h
EmacsKeyMap:enter()
或其他应用程序可以完成相同的行为,那么我将使用它。
答案 0 :(得分:0)
我不知道如何使用Hammerspoon
来实现,但是按照对this website的解释,我编辑了~/Library/KeyBindings/DefaultKeyBinding.dict
。然后所有的文本键绑定都按我的预期工作。
{
"^ฟ" = "moveToBeginningOfParagraph:"; /* ctrl-a */
"^ฤ" = "moveToBeginningOfParagraphAndModifySelection:"; /* ctrl-A */
"^ิ" = "moveBackward:"; /* ctrl-b */
"^ฺ" = "moveBackwardAndModifySelection:"; /* ctrl-B */
"^ก" = "deleteForward:"; /* ctrl-d */
"^ำ" = "moveToEndOfParagraph:"; /* ctrl-e */
"^ฎ" = "moveToEndOfParagraphAndModifySelection:"; /* ctrl-E */
"^ด" = "moveForward:"; /* ctrl-f */
"^โ" = "moveForwardAndModifySelection:"; /* ctrl-F */
"^้" = "deleteBackward:"; /* ctrl-h */
"^า" = "deleteToEndOfParagraph:"; /* ctrl-k */
"^ส" = "centerSelectionInVisibleArea:"; /* ctrl-l */
"^ื" = "moveDown:"; /* ctrl-n */
"^์" = "moveDownAndModifySelection:"; /* ctrl-N */
"^น" = (
"insertNewlineIgnoringFieldEditor:",
"moveBackward:",
); /* ctrl-o */
"^ย" = "moveUp:"; /* ctrl-p */
"^ญ" = "moveUpAndModifySelection:"; /* ctrl-P */
"^ะ" = "transpose:"; /* ctrl-t */
"^ฮ" = "pageDownAndModifySelection:"; /* ctrl-V */
"^อ" = "pageDown:"; /* ctrl-v */
"^ั" = "yank:"; /* ctrl-y */
}