|
@@ -323,7 +323,7 @@ internal class CharMap : View
|
|
|
CanFocus = true;
|
|
|
CursorVisibility = CursorVisibility.Default;
|
|
|
|
|
|
- SetContentSize (new (RowWidth, (MaxCodePoint / 16 + 2) * _rowHeight));
|
|
|
+ SetContentSize (new (RowWidth, (_maxCodePoint / 16 + 2) * _rowHeight));
|
|
|
|
|
|
AddCommand (
|
|
|
Command.ScrollUp,
|
|
@@ -344,7 +344,7 @@ internal class CharMap : View
|
|
|
Command.ScrollDown,
|
|
|
() =>
|
|
|
{
|
|
|
- if (SelectedCodePoint <= MaxCodePoint - 16)
|
|
|
+ if (SelectedCodePoint <= _maxCodePoint - 16)
|
|
|
{
|
|
|
SelectedCodePoint += 16;
|
|
|
}
|
|
@@ -380,7 +380,7 @@ internal class CharMap : View
|
|
|
Command.ScrollRight,
|
|
|
() =>
|
|
|
{
|
|
|
- if (SelectedCodePoint < MaxCodePoint)
|
|
|
+ if (SelectedCodePoint < _maxCodePoint)
|
|
|
{
|
|
|
SelectedCodePoint++;
|
|
|
}
|
|
@@ -411,7 +411,7 @@ internal class CharMap : View
|
|
|
() =>
|
|
|
{
|
|
|
int page = (Viewport.Height - 1 / _rowHeight) * 16;
|
|
|
- SelectedCodePoint += Math.Min (page, MaxCodePoint - SelectedCodePoint);
|
|
|
+ SelectedCodePoint += Math.Min (page, _maxCodePoint - SelectedCodePoint);
|
|
|
Viewport = Viewport with { Y = SelectedCodePoint / 16 * _rowHeight };
|
|
|
|
|
|
return true;
|
|
@@ -432,7 +432,7 @@ internal class CharMap : View
|
|
|
Command.BottomEnd,
|
|
|
() =>
|
|
|
{
|
|
|
- SelectedCodePoint = MaxCodePoint;
|
|
|
+ SelectedCodePoint = _maxCodePoint;
|
|
|
Viewport = Viewport with { Y = SelectedCodePoint / 16 * _rowHeight };
|
|
|
|
|
|
return true;
|
|
@@ -462,66 +462,42 @@ internal class CharMap : View
|
|
|
MouseClick += Handle_MouseClick;
|
|
|
MouseEvent += Handle_MouseEvent;
|
|
|
|
|
|
- // Prototype scrollbars
|
|
|
- Padding.Thickness = new (0, 0, 1, 1);
|
|
|
-
|
|
|
- var up = new Button
|
|
|
+ // Add scrollbars
|
|
|
+ Padding.Thickness = new (0, 0, 1, 0);
|
|
|
+ ScrollBar hScrollBar = new ()
|
|
|
{
|
|
|
- X = Pos.AnchorEnd (1),
|
|
|
- Y = 0,
|
|
|
- Height = 1,
|
|
|
- Width = 1,
|
|
|
- NoPadding = true,
|
|
|
- NoDecorations = true,
|
|
|
- Title = CM.Glyphs.UpArrow.ToString (),
|
|
|
- WantContinuousButtonPressed = true,
|
|
|
- CanFocus = false
|
|
|
+ X = 0,
|
|
|
+ Y = Pos.AnchorEnd (),
|
|
|
+ Width = Dim.Fill (1),
|
|
|
+ Size = GetContentSize ().Width,
|
|
|
+ Orientation = Orientation.Horizontal
|
|
|
};
|
|
|
- up.Accept += (sender, args) => { args.Handled = ScrollVertical (-1) == true; };
|
|
|
|
|
|
- var down = new Button
|
|
|
- {
|
|
|
- X = Pos.AnchorEnd (1),
|
|
|
- Y = Pos.AnchorEnd (2),
|
|
|
- Height = 1,
|
|
|
- Width = 1,
|
|
|
- NoPadding = true,
|
|
|
- NoDecorations = true,
|
|
|
- Title = CM.Glyphs.DownArrow.ToString (),
|
|
|
- WantContinuousButtonPressed = true,
|
|
|
- CanFocus = false
|
|
|
- };
|
|
|
- down.Accept += (sender, args) => { ScrollVertical (1); };
|
|
|
+ hScrollBar.VisibleChanged += (sender, args) =>
|
|
|
+ {
|
|
|
+ Padding.Thickness = Padding.Thickness with { Bottom = hScrollBar.Visible ? 1 : 0 };
|
|
|
+ };
|
|
|
|
|
|
- var left = new Button
|
|
|
+ ScrollBar vScrollBar = new ()
|
|
|
{
|
|
|
- X = 0,
|
|
|
- Y = Pos.AnchorEnd (1),
|
|
|
- Height = 1,
|
|
|
- Width = 1,
|
|
|
- NoPadding = true,
|
|
|
- NoDecorations = true,
|
|
|
- Title = CM.Glyphs.LeftArrow.ToString (),
|
|
|
- WantContinuousButtonPressed = true,
|
|
|
- CanFocus = false
|
|
|
+ X = Pos.AnchorEnd (),
|
|
|
+ Y = 0,
|
|
|
+ Height = Dim.Fill (Dim.Func (() => hScrollBar.Visible ? 1 : 0)),
|
|
|
+ Orientation = Orientation.Vertical,
|
|
|
+ Size = GetContentSize ().Height
|
|
|
};
|
|
|
- left.Accept += (sender, args) => { ScrollHorizontal (-1); };
|
|
|
+ vScrollBar.PositionChanged += (sender, args) => { Viewport = Viewport with { Y = args.CurrentValue }; };
|
|
|
|
|
|
- var right = new Button
|
|
|
- {
|
|
|
- X = Pos.AnchorEnd (2),
|
|
|
- Y = Pos.AnchorEnd (1),
|
|
|
- Height = 1,
|
|
|
- Width = 1,
|
|
|
- NoPadding = true,
|
|
|
- NoDecorations = true,
|
|
|
- Title = CM.Glyphs.RightArrow.ToString (),
|
|
|
- WantContinuousButtonPressed = true,
|
|
|
- CanFocus = false
|
|
|
- };
|
|
|
- right.Accept += (sender, args) => { ScrollHorizontal (1); };
|
|
|
+ Padding.Add (vScrollBar, hScrollBar);
|
|
|
+ hScrollBar.PositionChanged += (sender, args) => { Viewport = Viewport with { X = args.CurrentValue }; };
|
|
|
|
|
|
- Padding.Add (up, down, left, right);
|
|
|
+ ViewportChanged += UpdateVertialScrollBar;
|
|
|
+
|
|
|
+ void UpdateVertialScrollBar (object sender, DrawEventArgs e)
|
|
|
+ {
|
|
|
+ vScrollBar.Size = GetContentSize ().Height;
|
|
|
+ vScrollBar.Position = Viewport.Y;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void Handle_MouseEvent (object sender, MouseEventEventArgs e)
|
|
@@ -571,7 +547,7 @@ internal class CharMap : View
|
|
|
set => throw new NotImplementedException ();
|
|
|
}
|
|
|
|
|
|
- public static int MaxCodePoint = UnicodeRange.Ranges.Max (r => r.End);
|
|
|
+ public static int _maxCodePoint = UnicodeRange.Ranges.Max (r => r.End);
|
|
|
|
|
|
/// <summary>
|
|
|
/// Specifies the starting offset for the character map. The default is 0x2500 which is the Box Drawing
|
|
@@ -650,7 +626,7 @@ internal class CharMap : View
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static int RowLabelWidth => $"U+{MaxCodePoint:x5}".Length + 1;
|
|
|
+ private static int RowLabelWidth => $"U+{_maxCodePoint:x5}".Length + 1;
|
|
|
private static int RowWidth => RowLabelWidth + COLUMN_WIDTH * 16;
|
|
|
public event EventHandler<ListViewItemEventArgs> Hover;
|
|
|
|
|
@@ -698,7 +674,7 @@ internal class CharMap : View
|
|
|
|
|
|
int val = row * 16;
|
|
|
|
|
|
- if (val > MaxCodePoint)
|
|
|
+ if (val > _maxCodePoint)
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
@@ -865,7 +841,7 @@ internal class CharMap : View
|
|
|
|
|
|
int val = row * 16 + col;
|
|
|
|
|
|
- if (val > MaxCodePoint)
|
|
|
+ if (val > _maxCodePoint)
|
|
|
{
|
|
|
return;
|
|
|
}
|