gpt4 book ai didi

contextmenu - Atom 更改默认 TreeView 和编辑器上下文菜单

转载 作者:行者123 更新时间:2023-12-01 11:27:42 24 4
gpt4 key购买 nike

我在玩 Atom 文本编辑器。我在配置中环顾四周,但没有看到可以编辑文件树和编辑器的默认上下文菜单的任何地方。

我想去掉诸如剪切、复制、粘贴和全选等选项。他们让我的菜单变得臃肿,无论如何我总是使用键盘。

如何从 Atom 的上下文菜单中删除项目?

最佳答案

让我们破解 Atom!

Atom 将编辑器的上下文菜单选项存储在 atom.contextMenu.itemSets 中.我们需要做的就是在启动时遍历这个数组并删除我们不想要的元素。

将此添加到您的初始化脚本( Edit -> Open Your Init Script ):

# itemsToRemove contains commands to remove organized by menu selector
itemsToRemove = {
'atom-text-editor, .overlayer': [
'core:cut',
'core:copy',
'core:paste',
'core:select-all',
],
'.tree-view.full-menu': [
'tree-view:cut',
'tree-view:copy',
'tree-view:paste',
],
}

menus = atom.contextMenu.itemSets

for menu in menus
if !itemsToRemove[menu.selector]
# This is not the menu we're looking for
continue

items = menu.items
evilItems = itemsToRemove[menu.selector]
i = items.length

# Loop backwards because we're changing the array we're looping through
while i--
item = items[i]

# Is it an evil item?
if evilItems.indexOf(item.command) > -1
console.log 'Removing: ' + item.label + ' >> ' + item.command
# Die, evil item, DIE!
items.splice(i, 1)

关于contextmenu - Atom 更改默认 TreeView 和编辑器上下文菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36061392/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com