Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
472 changes: 472 additions & 0 deletions Examples/UICatalog/Scenarios/WideGlyphs.DrawFlow.md

Large diffs are not rendered by default.

86 changes: 78 additions & 8 deletions Examples/UICatalog/Scenarios/WideGlyphs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public override void Main ()
};

// Build the array of codepoints once when subviews are laid out
appWindow.SubViewsLaidOut += (s, e) =>
appWindow.SubViewsLaidOut += (s, _) =>
{
View? view = s as View;
if (view is null)
Expand All @@ -34,8 +34,8 @@ public override void Main ()
}

// Only rebuild if size changed or array is null
if (_codepoints is null ||
_codepoints.GetLength (0) != view.Viewport.Height ||
if (_codepoints is null ||
_codepoints.GetLength (0) != view.Viewport.Height ||
_codepoints.GetLength (1) != view.Viewport.Width)
{
_codepoints = new Rune [view.Viewport.Height, view.Viewport.Width];
Expand All @@ -51,7 +51,9 @@ public override void Main ()
};

// Fill the window with the pre-built codepoints array
appWindow.DrawingContent += (s, e) =>
// For detailed documentation on the draw code flow from Application.Run to this event,
// see WideGlyphs.DrawFlow.md in this directory
appWindow.DrawingContent += (s, _) =>
{
View? view = s as View;
if (view is null || _codepoints is null)
Expand All @@ -73,15 +75,15 @@ public override void Main ()
}
};

Line verticalLineAtEven = new Line ()
Line verticalLineAtEven = new ()
{
X = 10,
Orientation = Orientation.Vertical,
Length = Dim.Fill ()
};
appWindow.Add (verticalLineAtEven);

Line verticalLineAtOdd = new Line ()
Line verticalLineAtOdd = new ()
{
X = 25,
Orientation = Orientation.Vertical,
Expand All @@ -97,8 +99,12 @@ public override void Main ()
Y = 5,
Width = 15,
Height = 5,
BorderStyle = LineStyle.Dashed,
//BorderStyle = LineStyle.Dashed,
};

// Proves it's not LineCanvas related
arrangeableViewAtEven!.Border!.Thickness = new (1);
arrangeableViewAtEven.Border.Add(new View () { Height = Dim.Auto(), Width = Dim.Auto(), Text = "Even" });
appWindow.Add (arrangeableViewAtEven);

View arrangeableViewAtOdd = new ()
Expand All @@ -112,6 +118,70 @@ public override void Main ()
BorderStyle = LineStyle.Dashed,
};
appWindow.Add (arrangeableViewAtOdd);

var superView = new View
{
CanFocus = true,
X = 30, // on an even column to start
Y = Pos.Center (),
Width = Dim.Auto () + 4,
Height = Dim.Auto () + 1,
BorderStyle = LineStyle.Single,
Arrangement = ViewArrangement.Movable | ViewArrangement.Resizable
};

Rune codepoint = Glyphs.Apple;

superView.DrawingContent += (s, e) =>
{
var view = s as View;
for (var r = 0; r < view!.Viewport.Height; r++)
{
for (var c = 0; c < view.Viewport.Width; c += 2)
{
if (codepoint != default (Rune))
{
view.AddRune (c, r, codepoint);
}
}
}
e.DrawContext?.AddDrawnRectangle (view.Viewport);
e.Cancel = true;
};
appWindow.Add (superView);

var viewWithBorderAtX0 = new View
{
Text = "viewWithBorderAtX0",
BorderStyle = LineStyle.Dashed,
X = 0,
Y = 1,
Width = Dim.Auto (),
Height = 3
};

var viewWithBorderAtX1 = new View
{
Text = "viewWithBorderAtX1",
BorderStyle = LineStyle.Dashed,
X = 1,
Y = Pos.Bottom (viewWithBorderAtX0) + 1,
Width = Dim.Auto (),
Height = 3
};

var viewWithBorderAtX2 = new View
{
Text = "viewWithBorderAtX2",
BorderStyle = LineStyle.Dashed,
X = 2,
Y = Pos.Bottom (viewWithBorderAtX1) + 1,
Width = Dim.Auto (),
Height = 3
};

superView.Add (viewWithBorderAtX0, viewWithBorderAtX1, viewWithBorderAtX2);

// Run - Start the application.
Application.Run (appWindow);
appWindow.Dispose ();
Expand All @@ -124,6 +194,6 @@ private Rune GetRandomWideCodepoint ()
{
Random random = new ();
int codepoint = random.Next (0x4E00, 0x9FFF);
return new Rune (codepoint);
return new (codepoint);
}
}
2 changes: 2 additions & 0 deletions Terminal.Gui/Drivers/DriverImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ public void Dispose ()

private readonly IOutput _output;

internal IOutput Output => _output;

/// <inheritdoc/>
public IInputProcessor InputProcessor { get; }

Expand Down
Loading
Loading