在 Linux 上的 Eclipse 中,是否可以单独使用箭头键来展开包资源管理器中的树节点?

发布于 2024-10-13 07:37:33 字数 171 浏览 3 评论 0原文

使用 Eclipse 时,我经常使用键盘箭头浏览包资源管理器树。

在 Windows 中,我可以通过按 键展开折叠的节点。在 Linux 中,我需要按 Shift + 。有没有办法重新配置它,以便不需要 Shift

When using Eclipse I browse through the package explorer tree using the keyboard arrows a lot.

In Windows I can expand a collapsed node by pressing the key. In Linux I need to press Shift + . Is there a way to reconfigure this so that Shift is not required?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

九歌凝 2024-10-20 07:37:33

将其放入您的 ~/.gtkrc-2.0 中,您就可以开始了。左行和右行进行了所要求的更改,其余的只是我个人的添加,以使树视图的行为更像 vim。

binding "gtk-binding-tree-view" {
    bind "j"        { "move-cursor" (display-lines, 1) }
    bind "k"        { "move-cursor" (display-lines, -1) }
    bind "h"        { "expand-collapse-cursor-row" (1,0,0) }
    bind "l"        { "expand-collapse-cursor-row" (1,1,0) }
    bind "o"        { "move-cursor" (pages, 1) }
    bind "u"        { "move-cursor" (pages, -1) }
    bind "g"        { "move-cursor" (buffer-ends, -1) }
    bind "y"        { "move-cursor" (buffer-ends, 1) }
    bind "p"        { "select-cursor-parent" () }
    bind "Left"     { "expand-collapse-cursor-row" (0,0,0) }
    bind "Right"    { "expand-collapse-cursor-row" (0,1,0) }
    bind "semicolon" { "expand-collapse-cursor-row" (0,1,1) }
    bind "slash"    { "start-interactive-search" () }
}
class "GtkTreeView" binding "gtk-binding-tree-view"

然后重新启动 Eclipse 以应用新的绑定

Put this into your ~/.gtkrc-2.0 and you should be good to go. The Left and Right lines make the requested change, the rest are just my personal additions to make the tree-view act more vim-like.

binding "gtk-binding-tree-view" {
    bind "j"        { "move-cursor" (display-lines, 1) }
    bind "k"        { "move-cursor" (display-lines, -1) }
    bind "h"        { "expand-collapse-cursor-row" (1,0,0) }
    bind "l"        { "expand-collapse-cursor-row" (1,1,0) }
    bind "o"        { "move-cursor" (pages, 1) }
    bind "u"        { "move-cursor" (pages, -1) }
    bind "g"        { "move-cursor" (buffer-ends, -1) }
    bind "y"        { "move-cursor" (buffer-ends, 1) }
    bind "p"        { "select-cursor-parent" () }
    bind "Left"     { "expand-collapse-cursor-row" (0,0,0) }
    bind "Right"    { "expand-collapse-cursor-row" (0,1,0) }
    bind "semicolon" { "expand-collapse-cursor-row" (0,1,1) }
    bind "slash"    { "start-interactive-search" () }
}
class "GtkTreeView" binding "gtk-binding-tree-view"

then restart your Eclipse to apply new bindings

度的依靠╰つ 2024-10-20 07:37:33

如果有人想知道如何使用 GTK3 执行此操作 - 只需打开 ~/.config/gtk-3.0/gtk.css 并添加以下内容:

@binding-set MyTreeViewBinding
{
    bind "Left"     { "expand-collapse-cursor-row" (0,0,0) };
    bind "Right"    { "expand-collapse-cursor-row" (0,1,0) };
}

GtkTreeView
{
  gtk-key-bindings: MyTreeViewBinding;
}

If anyone is wondering how to do this with GTK3 - simply open ~/.config/gtk-3.0/gtk.css and add the following:

@binding-set MyTreeViewBinding
{
    bind "Left"     { "expand-collapse-cursor-row" (0,0,0) };
    bind "Right"    { "expand-collapse-cursor-row" (0,1,0) };
}

GtkTreeView
{
  gtk-key-bindings: MyTreeViewBinding;
}
梦罢 2024-10-20 07:37:33

我的 GTK3 版本表现得更自然。
将以下内容添加到~/.config/gtk-3.0/gtk.css:

@binding-set MyTreeViewBinding
{
    bind "Left"     { "select-cursor-parent" ()
                      "expand-collapse-cursor-row" (0,0,0) };
    bind "Right"    { "expand-collapse-cursor-row" (0,1,0) };
}

GtkTreeView
{
    gtk-key-bindings: MyTreeViewBinding;
}

My version for GTK3 that behaves in more natural way.
Add the following to ~/.config/gtk-3.0/gtk.css:

@binding-set MyTreeViewBinding
{
    bind "Left"     { "select-cursor-parent" ()
                      "expand-collapse-cursor-row" (0,0,0) };
    bind "Right"    { "expand-collapse-cursor-row" (0,1,0) };
}

GtkTreeView
{
    gtk-key-bindings: MyTreeViewBinding;
}
转角预定愛 2024-10-20 07:37:33

安德鲁提供的答案是正确的。请注意,在较新版本的 Ubuntu 中没有 ~/.gtkrc-2.0 文件,因此您可以创建它,也可以编辑当前主题的 gtkrc,该文件存储在

/usr/share/themes/your_theme/gtk 中-2.0/gtkrc

The answer provided by Andrew is correct. Please note that in newer versions of Ubuntu there is no ~/.gtkrc-2.0 file, so you can either create it or you can edit the gtkrc of your current theme, which is stored in

/usr/share/themes/your_theme/gtk-2.0/gtkrc

千秋岁 2024-10-20 07:37:33

我尝试使用@Andrew Lazarev的答案。然而,由于 GTK3.20 上的非向后兼容更改 (https://bugzilla.gnome。 org/show_bug.cgi?id=766166)绑定必须稍作调整:

@binding-set MyTreeViewBinding
{
   bind "Left"     { "select-cursor-parent" ()
                  "expand-collapse-cursor-row" (0,0,0) };
   bind "Right"    { "expand-collapse-cursor-row" (0,1,0) };
}

treeview
{
   -gtk-key-bindings: MyTreeViewBinding;
}

请注意 gtk-key-bindings 之前的 -GtkTreeView 重命名为 treeview

I tried to use the answer from @Andrew Lazarev. However due to a non backward compatible change on GTK3.20 (https://bugzilla.gnome.org/show_bug.cgi?id=766166) the bindings have to be slightly adapted:

@binding-set MyTreeViewBinding
{
   bind "Left"     { "select-cursor-parent" ()
                  "expand-collapse-cursor-row" (0,0,0) };
   bind "Right"    { "expand-collapse-cursor-row" (0,1,0) };
}

treeview
{
   -gtk-key-bindings: MyTreeViewBinding;
}

Note the - before gtk-key-bindings and the GtkTreeView renamed to treeview.

倾城°AllureLove 2024-10-20 07:37:33

Tree widget 的导航由底层 widget 工具包 GTK 控制。 SWT/Eclipse 无法控制它。
如果需要任何此类配置来更改快捷方式,则必须从 GTK 端本身进行。

The navigation of Tree widget is controlled by underlaying widget toolkit - GTK. SWT/Eclipse has no control over it.
If any such configuration is required for changing the short-cut, then it has to be made from the GTK side itself.

执手闯天涯 2024-10-20 07:37:33

根据 YMomb 答案,我最终得到了以下配置(~/.config/gtk-3.0/gtk.css )。与 Eclipse 2021-09 配合良好。

@binding-set MyTreeViewBinding
{
    bind "<Ctrl>Left" { "select-cursor-parent" ()
                   "expand-collapse-cursor-row" (0,0,0) };
    bind "Left"     { "expand-collapse-cursor-row" (0,0,0) };
    bind "Right"    { "expand-collapse-cursor-row" (0,1,0) };
}

treeview
{
  -gtk-key-bindings: MyTreeViewBinding;
}

Basing on YMomb answer I ended up with config bellow (~/.config/gtk-3.0/gtk.css). Works well with Eclipse 2021-09.

@binding-set MyTreeViewBinding
{
    bind "<Ctrl>Left" { "select-cursor-parent" ()
                   "expand-collapse-cursor-row" (0,0,0) };
    bind "Left"     { "expand-collapse-cursor-row" (0,0,0) };
    bind "Right"    { "expand-collapse-cursor-row" (0,1,0) };
}

treeview
{
  -gtk-key-bindings: MyTreeViewBinding;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文