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

rm5edbpk  于 2022-12-26  发布在  Linux
关注(0)|答案(7)|浏览(103)

在使用Eclipse时,我经常使用键盘箭头浏览包资源管理器树。
在Windows中,我可以通过按→键来展开一个折叠的节点。在Linux中,我需要按Shift + →。有没有办法重新配置它,这样就不需要Shift了?

yjghlzjz

yjghlzjz1#

把这个放到你的~/.gtkrc-2.0中,你就可以开始了。左行和右行做了所要求的修改,其余的只是我个人的添加,使树视图更像是虚拟的。

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以应用新的绑定

zynd9foi

zynd9foi2#

如果有人想知道如何在GTK 3中执行此操作-只需打开~/.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;
}
ylamdve6

ylamdve63#

我的GTK 3版本的行为方式更自然。添加以下内容到~/.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;
}
vltsax25

vltsax254#

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

r3i60tvu

r3i60tvu5#

我尝试使用the answer from @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之前的-以及重命名为treeviewGtkTreeView

khbbv19g

khbbv19g6#

Tree widget的导航是由底层widget工具包GTK控制的,SWT/Eclipse对此没有控制权,如果需要更改快捷方式,则必须从GTK端自己进行配置。

irlmq6kh

irlmq6kh7#

基于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;
}

相关问题