diff --git a/Terminal.Gui/Views/ComboBox.cs b/Terminal.Gui/Views/ComboBox.cs
index be7c5c3ea..a4dcb1a6a 100644
--- a/Terminal.Gui/Views/ComboBox.cs
+++ b/Terminal.Gui/Views/ComboBox.cs
@@ -6,9 +6,6 @@
//
using System.Collections.ObjectModel;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Threading.Channels;
namespace Terminal.Gui;
@@ -388,7 +385,7 @@ public class ComboBox : View, IDesignable
{
Selected ();
- return true;
+ return RaiseAccepted () == true;
}
return false;
diff --git a/Terminal.Gui/Views/HexView.cs b/Terminal.Gui/Views/HexView.cs
index 062ae1cd9..bafe10bca 100644
--- a/Terminal.Gui/Views/HexView.cs
+++ b/Terminal.Gui/Views/HexView.cs
@@ -25,7 +25,7 @@ namespace Terminal.Gui;
///
/// Control the first byte shown by setting the property to an offset in the stream.
///
-public class HexView : View
+public class HexView : View, IDesignable
{
private const int bsize = 4;
private const int displayWidth = 9;
@@ -33,7 +33,8 @@ public class HexView : View
private int bpl;
private long displayStart, pos;
private SortedDictionary edits = [];
- private bool firstNibble, leftSide;
+ private bool firstNibble;
+ private bool leftSide;
private Stream source;
private static readonly Rune SpaceCharRune = new (' ');
private static readonly Rune PeriodCharRune = new ('.');
@@ -46,8 +47,7 @@ public class HexView : View
public HexView (Stream source)
{
Source = source;
- // BUG: This will always call the most-derived definition of CanFocus.
- // Either seal it or don't set it here.
+
CanFocus = true;
CursorVisibility = CursorVisibility.Default;
leftSide = true;
@@ -61,7 +61,8 @@ public class HexView : View
AddCommand (Command.Right, () => MoveRight ());
AddCommand (Command.Down, () => MoveDown (bytesPerLine));
AddCommand (Command.Up, () => MoveUp (bytesPerLine));
- AddCommand (Command.Accept, () => ToggleSide ());
+ AddCommand (Command.Tab, () => Navigate (NavigationDirection.Forward));
+ AddCommand (Command.BackTab, () => Navigate (NavigationDirection.Backward));
AddCommand (Command.PageUp, () => MoveUp (bytesPerLine * Frame.Height));
AddCommand (Command.PageDown, () => MoveDown (bytesPerLine * Frame.Height));
AddCommand (Command.Start, () => MoveHome ());
@@ -94,6 +95,9 @@ public class HexView : View
KeyBindings.Add (Key.CursorUp.WithCtrl, Command.StartOfPage);
KeyBindings.Add (Key.CursorDown.WithCtrl, Command.EndOfPage);
+ KeyBindings.Add (Key.Tab, Command.Tab);
+ KeyBindings.Add (Key.Tab.WithShift, Command.BackTab);
+
LayoutComplete += HexView_LayoutComplete;
}
@@ -246,7 +250,7 @@ public class HexView : View
public event EventHandler Edited;
///
- protected internal override bool OnMouseEvent (MouseEvent me)
+ protected internal override bool OnMouseEvent (MouseEvent me)
{
if (!me.Flags.HasFlag (MouseFlags.Button1Clicked)
&& !me.Flags.HasFlag (MouseFlags.Button1DoubleClicked)
@@ -528,12 +532,14 @@ public class HexView : View
int x = displayWidth + block * 14 + column + (firstNibble ? 0 : 1);
int y = line;
+
if (!leftSide)
{
x = displayWidth + bytesPerLine / bsize * 14 + item - 1;
}
Move (x, y);
+
return new (x, y);
}
@@ -763,17 +769,49 @@ public class HexView : View
{
return;
}
+
var delta = (int)(pos - DisplayStart);
int line = delta / bytesPerLine;
SetNeedsDisplay (new (0, line, Viewport.Width, 1));
}
- private bool ToggleSide ()
+ private bool Navigate (NavigationDirection direction)
{
- leftSide = !leftSide;
- RedisplayLine (position);
- firstNibble = true;
+ switch (direction)
+ {
+ case NavigationDirection.Forward:
+ if (leftSide)
+ {
+ leftSide = false;
+ RedisplayLine (position);
+ firstNibble = true;
+
+ return true;
+ }
+
+ break;
+
+ case NavigationDirection.Backward:
+ if (!leftSide)
+ {
+ leftSide = true;
+ RedisplayLine (position);
+ firstNibble = true;
+ return true;
+ }
+
+ break;
+ }
+
+ return false;
+ }
+
+
+ ///
+ bool IDesignable.EnableForDesign ()
+ {
+ Source = new MemoryStream (Encoding.UTF8.GetBytes ("HexEditor Unicode that shouldn't đšAâđ˝!"));
return true;
}