Skip to content

Commit fa1bdae

Browse files
committed
Add Command.Up and Command.Down.
1 parent 9724625 commit fa1bdae

File tree

2 files changed

+44
-5
lines changed

2 files changed

+44
-5
lines changed

Terminal.Gui/Views/TabView/TabRow.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public TabRow (TabView host)
1313
Id = "tabRow";
1414

1515
CanFocus = true;
16+
// Because TabRow has focusable subviews, it must be a TabGroup
1617
TabStop = TabBehavior.TabGroup;
1718
Width = Dim.Fill ();
1819

Terminal.Gui/Views/TabView/TabView.cs

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,54 @@ public class TabView : View
2727
public TabView ()
2828
{
2929
CanFocus = true;
30-
TabStop = TabBehavior.TabStop; // Because TabView has focusable subviews, it must be a TabGroup
31-
_tabsBar = new TabRow (this);
30+
TabStop = TabBehavior.TabStop;
31+
_tabsBar = new (this);
3232
_containerView = new ();
3333
ApplyStyleChanges ();
3434

3535
base.Add (_tabsBar);
3636
base.Add (_containerView);
3737

3838
// Things this view knows how to do
39-
AddCommand (Command.Left, () => SwitchTabBy (-1));
40-
41-
AddCommand (Command.Right, () => SwitchTabBy (1));
39+
AddCommand (Command.Left, () =>
40+
{
41+
if (Style.TabsSide is TabSide.Top or TabSide.Bottom)
42+
{
43+
return SwitchTabBy (-1);
44+
}
45+
46+
return false;
47+
});
48+
49+
AddCommand (Command.Right, () =>
50+
{
51+
if (Style.TabsSide is TabSide.Top or TabSide.Bottom)
52+
{
53+
return SwitchTabBy (1);
54+
}
55+
56+
return false;
57+
});
58+
59+
AddCommand (Command.Up, () =>
60+
{
61+
if (Style.TabsSide is TabSide.Left or TabSide.Right)
62+
{
63+
return SwitchTabBy (-1);
64+
}
65+
66+
return false;
67+
});
68+
69+
AddCommand (Command.Down, () =>
70+
{
71+
if (Style.TabsSide is TabSide.Left or TabSide.Right)
72+
{
73+
return SwitchTabBy (1);
74+
}
75+
76+
return false;
77+
});
4278

4379
AddCommand (
4480
Command.LeftStart,
@@ -87,6 +123,8 @@ public TabView ()
87123
// Default keybindings for this view
88124
KeyBindings.Add (Key.CursorLeft, Command.Left);
89125
KeyBindings.Add (Key.CursorRight, Command.Right);
126+
KeyBindings.Add (Key.CursorUp, Command.Up);
127+
KeyBindings.Add (Key.CursorDown, Command.Down);
90128
KeyBindings.Add (Key.Home, Command.LeftStart);
91129
KeyBindings.Add (Key.End, Command.RightEnd);
92130
KeyBindings.Add (Key.PageDown, Command.PageDown);

0 commit comments

Comments
 (0)