Skip to content

Commit bdd9912

Browse files
committed
Add Command.Up and Command.Down.
1 parent 5f526b2 commit bdd9912

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
@@ -14,6 +14,7 @@ public TabRow (TabView host)
1414
Id = "tabRow";
1515

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

Terminal.Gui/Views/TabView/TabView.cs

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

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

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

4480
AddCommand (
4581
Command.LeftStart,
@@ -174,6 +210,8 @@ public TabView ()
174210
// Default keybindings for this view
175211
KeyBindings.Add (Key.CursorLeft, Command.Left);
176212
KeyBindings.Add (Key.CursorRight, Command.Right);
213+
KeyBindings.Add (Key.CursorUp, Command.Up);
214+
KeyBindings.Add (Key.CursorDown, Command.Down);
177215
KeyBindings.Add (Key.Home, Command.LeftStart);
178216
KeyBindings.Add (Key.End, Command.RightEnd);
179217
KeyBindings.Add (Key.PageDown, Command.PageDown);

0 commit comments

Comments
 (0)