如何在Sublime Text 3中配置5个按钮鼠标 [英] How to configure 5 buttons mouse in Sublime Text 3

查看:153
本文介绍了如何在Sublime Text 3中配置5个按钮鼠标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有5个按钮的鼠标,我该如何配置这些按钮来执行Sublime Text 3中的特定任务.就像button4执行Buildbutton5执行Build With...

I have a mouse with 5 buttons, how can I configure these buttons to do specific tasks in Sublime Text 3. Like when button4 does Build and button5 does Build With...

推荐答案

对于Sublime Text,鼠标动作由称为mousemap的文件(扩展名为.sublime-mousemap)进行配置.这些文件通常可以有2种变体:-

In case of Sublime Text, the mouse actions are configured by what are known as mousemap files (that have an extension .sublime-mousemap). You can have generally 2 variants of these files :-

  • Default.sublime-mousemap:这将为任何平台定义鼠标操作.
  • Default ($platform).sublime-mousemap:这将定义特定平台的鼠标操作,其中$platformWindowsLinuxOSX中的任何一个,具体取决于您的操作系统.
  • Default.sublime-mousemap: This will define mouse actions for any platform.
  • Default ($platform).sublime-mousemap: This will define mouse actions for a specific platform, where $platform is any one of Windows, Linux or OSX depending on your operating system.

您可以通过使用命令面板中的View Package File并搜索mousemap来查看默认附带的鼠标映射文件.

You can view the default shipped mousemap files by using View Package File from the command palette and searching for mousemap.

为了定义自己的鼠标动作(或覆盖任何现有动作),必须在User目录中创建一个名称为Default.sublime-mousemap的文件(要访问此目录,请从以下位置选择Preferences -> Browse Packages ...主菜单),以实现与平台无关的替代(或Default ($platform).sublime-mousemap:取决于平台的替代,具体取决于您的操作系统).

In order to define your own mouse actions (or override any existing actions), you have to create a file by the name of Default.sublime-mousemap in the User directory (to get to this directory, select Preferences -> Browse Packages ... from the main menu) for platform independent override (or Default ($platform).sublime-mousemap for platform dependent overrides depending on your OS).

完成后,这里是有关鼠标映射文件的一些基本知识(请注意,没有关于鼠标映射文件的官方或社区文档,因此所有内容都是基于实验以及开发人员对此类文件的评价).

Once that's done, here is some basic knowledge about mousemap files (Note that there is no official or community documentation about mousemap files so everything is based on experimentation and what the dev's have said about such files).

这是mousemap文件中某些键的含义:-

Here are the meaning of some keys in mousemap files :-

  • 按钮:这定义了按钮的名称.例如, button1 是指鼠标左键& button2 定义鼠标右键.同样,您可以具有 button3 button4 . button5 等.我不确定实际上有多少这样的按钮名称.另外,对于滚轮,您还具有 scroll_up 用于向上滚动和 scroll_down 表示相反的行为.

  • button: This defines the name of the button. For example, button1 refers to the left mouse button & button2 defines the right mouse button. Similarly, you can have button3, button4. button5 etc. I am not sure how many such button names actually exist. Also for the scroll wheel, you have scroll_up for upward scroll movement & scroll_down for the opposite behavior.

修饰符:这是修饰键的列表,例如 ctrl alt 等.例如,["alt"]["ctrl", "alt"].定义修改器列表时,应同时按下列出的所有修改器键,然后按下/释放相应的按钮将触发某些操作.

modifiers: This is a list of modifier keys like ctrl, alt etc. For example, ["alt"], ["ctrl", "alt"]. When you define a modifier list, all the modifier keys listed should be pressed simultaneously and then pressing/releasing the corresponding button triggers some action.

命令:这定义了在按下相应按钮后释放要执行的命令.如果此命令带有任何参数,则可以为其提供一个 args 键.

command: This defines the command to be executed when the corresponding button is released after being pressed. If this command takes any arguments, you can have an args key for it.

press_command :这定义了按下按钮时要执行的命令.如果此命令带有任何参数,则可以为其提供 press_args 键.

press_command: This defines the command to be executed when the corresponding button is pressed. If this command takes any arguments, you can have a press_args key for it.

计数:您必须按下相应按钮才能触发操作的次数(按操作,我的意思是执行相应的命令/ press_command )

count: The number of times you have to press the corresponding button to trigger the action (by action, I mean execute the corresponding command/press_command)

注意: 如果需要,可以定义命令 press_command .

NOTE: You can define both command and press_command if you wanted to.

让我们看一些示例:-

文件名:-User/Default.sublime-mousemap

[
    {
        "button": "button2",
        "modifiers": [],
        "press_command": "echo",
        "press_args": {
            "message": "I am pressed"
        },
        "command": "echo",
        "args": {
            "message": "I am released"
        },
    }
]

在此,右键( button2 )绑定到内置的 echo 命令.如果现在单击鼠标右键,默认行为实际上是打开上下文菜单,但是现在我们覆盖该行为,现在您可以在其中看到相应的消息{'message': 'I am pressed'}{'message': 'I am released'}控制台是根据您是按下还是按下后释放.

Here, the right button (button2) is bound to the built in echo command. If you now right click, the default behavior would have been actually the opening of the context menu, but now we have overriden that behavior and now you can see the corresponding messages {'message': 'I am pressed'} or {'message': 'I am released'} in the console based on whether you have pressed or released after pressing.

对于您的情况,您可以使用以下内容:-

For your case, you can have something like the following :-

[
    {
        "button": "button1", // replace button1 with button4/5 because I don't have that many mouse buttons.
        "modifiers": ["alt", "ctrl", "shift"],
        "press_command": "undo",
    }   
]

现在,当您现在按下 button1 (同时按住 alt ctrl shift 时), 撤消命令应被执行.您可以将修饰符设置为空白列表.

Now, when you now press button1 (while holding down alt, ctrl, shift simultaneously), the undo command should be executed. You can set modifiers to an empty list if you don't want that.

对于构建,如果要执行最新的构建系统,则将撤消替换为构建.

As for build, if you mean executing the most recent build system, replace undo, with build.

作为分手红利提示,如果要禁用任何按钮操作,只需使用命令 noop .

As a parting bonus tip, if you want to disable any button actions, just use the command noop.

示例:-

[
    {
        "button": "button1",
        "modifiers": [],
        "press_command": "noop",
    }   
]

这将禁用 button1 ,现在您不能再拖动选择了;-)所以要小心.

This will disable button1 and now you can't drag select anymore ;-) So be careful.

希望这会有所帮助.

这篇关于如何在Sublime Text 3中配置5个按钮鼠标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆