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
95 changes: 78 additions & 17 deletions Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ public enum DiagnosticFlags : uint {
/// Set flags to enable/disable <see cref="ConsoleDriver"/> diagnostics.
/// </summary>
public static DiagnosticFlags Diagnostics { get; set; }

/// <summary>
/// Suspend the application, typically needs to save the state, suspend the app and upon return, reset the console driver.
/// </summary>
Expand Down Expand Up @@ -1118,42 +1118,32 @@ public Rect Clip {
/// <summary>
/// Horizontal double line character.
/// </summary>
public Rune HDLine = '\u2550';
public Rune HDbLine = '\u2550';

/// <summary>
/// Vertical double line character.
/// </summary>
public Rune VDLine = '\u2551';
public Rune VDbLine = '\u2551';

/// <summary>
/// Upper left double corner
/// </summary>
public Rune ULDCorner = '\u2554';
public Rune ULDbCorner = '\u2554';

/// <summary>
/// Lower left double corner
/// </summary>
public Rune LLDCorner = '\u255a';
public Rune LLDbCorner = '\u255a';

/// <summary>
/// Upper right double corner
/// </summary>
public Rune URDCorner = '\u2557';
public Rune URDbCorner = '\u2557';

/// <summary>
/// Lower right double corner
/// </summary>
public Rune LRDCorner = '\u255d';

/// <summary>
/// Horizontal line character for rounded corners.
/// </summary>
public Rune HRLine = '\u2500';

/// <summary>
/// Vertical line character for rounded corners.
/// </summary>
public Rune VRLine = '\u2502';
public Rune LRDbCorner = '\u255d';

/// <summary>
/// Upper left rounded corner
Expand All @@ -1174,6 +1164,77 @@ public Rect Clip {
/// Lower right rounded corner
/// </summary>
public Rune LRRCorner = '\u256f';

/// <summary>
/// Horizontal double dashed line character.
/// </summary>
public Rune HDsLine = '\u254c';

/// <summary>
/// Vertical triple dashed line character.
/// </summary>
public Rune VDsLine = '\u2506';

/// <summary>
/// Horizontal triple dashed line character.
/// </summary>
public Rune HDtLine = '\u2504';

/// <summary>
/// Vertical quadruple dashed line character.
/// </summary>
public Rune VDtLine = '\u250a';

/// <summary>
/// Horizontal heavy line character.
/// </summary>
public Rune HThLine = '\u2501';

/// <summary>
/// Vertical heavy line character.
/// </summary>
public Rune VThLine = '\u2503';

/// <summary>
/// Upper left heavy corner
/// </summary>
public Rune ULThCorner = '\u250f';

/// <summary>
/// Lower left heavy corner
/// </summary>
public Rune LLThCorner = '\u2517';

/// <summary>
/// Upper right heavy corner
/// </summary>
public Rune URThCorner = '\u2513';

/// <summary>
/// Lower right heavy corner
/// </summary>
public Rune LRThCorner = '\u251b';

/// <summary>
/// Horizontal heavy double dashed line character.
/// </summary>
public Rune HThDsLine = '\u254d';

/// <summary>
/// Vertical heavy triple dashed line character.
/// </summary>
public Rune VThDsLine = '\u2507';

/// <summary>
/// Horizontal heavy triple dashed line character.
/// </summary>
public Rune HThDtLine = '\u2505';

/// <summary>
/// Vertical heavy quadruple dashed line character.
/// </summary>
public Rune VThDtLine = '\u250b';

private Attribute currentAttribute;

/// <summary>
Expand Down
110 changes: 90 additions & 20 deletions Terminal.Gui/Drawing/LineCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,45 @@ public enum LineStyle {
/// </summary>
None,
/// <summary>
/// The border is drawn using single-width line glyphs.
/// The border is drawn using thin line glyphs.
/// </summary>
Single,
/// <summary>
/// The border is drawn using double-width line glyphs.
/// The border is drawn using thin line glyphs with dashed (double and triple) straight lines.
/// </summary>
Dashed,
/// <summary>
/// The border is drawn using thin line glyphs with short dashed (triple and quadruple) straight lines.
/// </summary>
Dotted,
/// <summary>
/// The border is drawn using thin double line glyphs.
/// </summary>
Double,
/// <summary>
/// The border is drawn using heavy line glyphs.
/// </summary>
Thick,
/// <summary>
/// The border is drawn using heavy line glyphs with dashed (double and triple) straight lines.
/// </summary>
ThickDashed,
/// <summary>
/// The border is drawn using heavy line glyphs with short dashed (triple and quadruple) straight lines.
/// </summary>
ThickDotted,
/// <summary>
/// The border is drawn using single-width line glyphs with rounded corners.
/// </summary>
Rounded,
/// <summary>
/// The border is drawn using single-width line glyphs with rounded corners and dashed (double and triple) straight lines.
/// </summary>
RoundedDashed,
/// <summary>
/// The border is drawn using single-width line glyphs with rounded corners and short dashed (triple and quadruple) straight lines.
/// </summary>
RoundedDotted,
// TODO: Support Ruler
///// <summary>
///// The border is drawn as a diagnostic ruler ("|123456789...").
Expand Down Expand Up @@ -249,99 +277,118 @@ private abstract class IntersectionRuneResolver {
readonly Rune doubleH;
readonly Rune doubleV;
readonly Rune doubleBoth;
readonly Rune thickH;
readonly Rune thickV;
readonly Rune thickBoth;
readonly Rune normal;

public IntersectionRuneResolver (Rune round, Rune doubleH, Rune doubleV, Rune doubleBoth, Rune normal)
public IntersectionRuneResolver (Rune round, Rune doubleH, Rune doubleV, Rune doubleBoth, Rune thickH, Rune thickV, Rune thickBoth, Rune normal)
{
this.round = round;
this.doubleH = doubleH;
this.doubleV = doubleV;
this.doubleBoth = doubleBoth;
this.thickH = thickH;
this.thickV = thickV;
this.thickBoth = thickBoth;
this.normal = normal;
}

public Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects)
{
var useRounded = intersects.Any (i => i.Line.Style == LineStyle.Rounded && i.Line.Length != 0);
var useRounded = intersects.Any (i => i.Line.Length != 0 && (
i.Line.Style == LineStyle.Rounded || i.Line.Style == LineStyle.RoundedDashed || i.Line.Style == LineStyle.RoundedDotted));

// Note that there aren't any glyphs for intersections of double lines with thick lines

bool doubleHorizontal = intersects.Any (l => l.Line.Orientation == Orientation.Horizontal && l.Line.Style == LineStyle.Double);
bool doubleVertical = intersects.Any (l => l.Line.Orientation == Orientation.Vertical && l.Line.Style == LineStyle.Double);

bool thickHorizontal = intersects.Any (l => l.Line.Orientation == Orientation.Horizontal && (
l.Line.Style == LineStyle.Thick || l.Line.Style == LineStyle.ThickDashed || l.Line.Style == LineStyle.ThickDotted));
bool thickVertical = intersects.Any (l => l.Line.Orientation == Orientation.Vertical && (
l.Line.Style == LineStyle.Thick || l.Line.Style == LineStyle.ThickDashed || l.Line.Style == LineStyle.ThickDotted));

if (doubleHorizontal) {
return doubleVertical ? doubleBoth : doubleH;
}

if (doubleVertical) {
return doubleV;
}

if (thickHorizontal) {
Comment thread
tig marked this conversation as resolved.
return thickVertical ? thickBoth : thickH;
}
if (thickVertical) {
return thickV;
}

return useRounded ? round : normal;
}
}

private class ULIntersectionRuneResolver : IntersectionRuneResolver {
public ULIntersectionRuneResolver () :
base ('╭', '╒', '╓', '╔', '┌')
base ('╭', '╒', '╓', '╔', '┍', '┎', '┏', '┌')
{

}
}
private class URIntersectionRuneResolver : IntersectionRuneResolver {

public URIntersectionRuneResolver () :
base ('╮', '╕', '╖', '╗', '┐')
base ('╮', '╕', '╖', '╗', '┑', '┒', '┓', '┐')
{

}
}
private class LLIntersectionRuneResolver : IntersectionRuneResolver {

public LLIntersectionRuneResolver () :
base ('╰', '╘', '╙', '╚', '└')
base ('╰', '╘', '╙', '╚', '┕', '┖', '┗', '└')
{

}
}
private class LRIntersectionRuneResolver : IntersectionRuneResolver {
public LRIntersectionRuneResolver () :
base ('╯', '╛', '╜', '╝', '┘')
base ('╯', '╛', '╜', '╝', '┙', '┚', '┛', '┘')
{

}
}

private class TopTeeIntersectionRuneResolver : IntersectionRuneResolver {
public TopTeeIntersectionRuneResolver () :
base ('┬', '╤', '╥', '╦', '┬')
base ('┬', '╤', '╥', '╦', '┯', '┰', '┳', '┬')
{

}
}
private class LeftTeeIntersectionRuneResolver : IntersectionRuneResolver {
public LeftTeeIntersectionRuneResolver () :
base ('├', '╞', '╟', '╠', '├')
base ('├', '╞', '╟', '╠', '┝', '┠', '┣', '├')
{

}
}
private class RightTeeIntersectionRuneResolver : IntersectionRuneResolver {
public RightTeeIntersectionRuneResolver () :
base ('┤', '╡', '╢', '╣', '┤')
base ('┤', '╡', '╢', '╣', '┥', '┨', '┫', '┤')
{

}
}
private class BottomTeeIntersectionRuneResolver : IntersectionRuneResolver {
public BottomTeeIntersectionRuneResolver () :
base ('┴', '╧', '╨', '╩', '┴')
base ('┴', '╧', '╨', '╩', '┷', '┸', '┻', '┴')
{

}
}
private class CrosshairIntersectionRuneResolver : IntersectionRuneResolver {
public CrosshairIntersectionRuneResolver () :
base ('┼', '╪', '╫', '╬', '┼')
base ('┼', '╪', '╫', '╬', '┿', '╂', '╋', '┼')
{

}
Expand All @@ -359,23 +406,46 @@ public CrosshairIntersectionRuneResolver () :
return runeResolvers [runeType].GetRuneForIntersects (driver, intersects);
}

// TODO: Remove these two once we have all of the below ported to IntersectionRuneResolvers
// TODO: Remove these once we have all of the below ported to IntersectionRuneResolvers
var useDouble = intersects.Any (i => i.Line.Style == LineStyle.Double);
var useRounded = intersects.Any (i => i.Line.Style == LineStyle.Rounded);
var useDashed = intersects.Any (i => i.Line.Style == LineStyle.Dashed || i.Line.Style == LineStyle.RoundedDashed);
var useDotted = intersects.Any (i => i.Line.Style == LineStyle.Dotted || i.Line.Style == LineStyle.RoundedDotted);
// horiz and vert lines same as Single for Rounded
var useThick = intersects.Any (i => i.Line.Style == LineStyle.Thick);
var useThickDashed = intersects.Any (i => i.Line.Style == LineStyle.ThickDashed);
var useThickDotted = intersects.Any (i => i.Line.Style == LineStyle.ThickDotted);
// TODO: Support ruler
//var useRuler = intersects.Any (i => i.Line.Style == LineStyle.Ruler && i.Line.Length != 0);

// TODO: maybe make these resolvers to for simplicity?
// or for dotted lines later on or that kind of thing?
// TODO: maybe make these resolvers too for simplicity?
switch (runeType) {
case IntersectionRuneType.None:
return null;
case IntersectionRuneType.Dot:
return (Rune)'.';
case IntersectionRuneType.HLine:
return useDouble ? driver.HDLine : driver.HLine;
if (useDouble) {
return driver.HDbLine;
}
if (useDashed) {
return driver.HDsLine;
}
if (useDotted) {
return driver.HDtLine;
}
return useThick ? driver.HThLine : (useThickDashed ? driver.HThDsLine : (useThickDotted ? driver.HThDtLine : driver.HLine));
case IntersectionRuneType.VLine:
return useDouble ? driver.VDLine : driver.VLine;
if (useDouble) {
return driver.VDbLine;
}
if (useDashed) {
return driver.VDsLine;
}
if (useDotted) {
return driver.VDtLine;
}
return useThick ? driver.VThLine : (useThickDashed ? driver.VThDsLine : (useThickDotted ? driver.VThDtLine : driver.VLine));

default: throw new Exception ("Could not find resolver or switch case for " + nameof (runeType) + ":" + runeType);
}
}
Expand Down
4 changes: 2 additions & 2 deletions UICatalog/Scenarios/BordersOnContainers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@ public BordersOnContainers (NStack.ustring title, string typeName, View smartVie
};

Add (new Label ("Background:") {
Y = 5
Y = 12
});

var colorEnum = Enum.GetValues (typeof (Color)).Cast<Color> ().ToList ();
var rbBackground = new RadioGroup (colorEnum.Select (
e => NStack.ustring.Make (e.ToString ())).ToArray ()) {

X = 2,
Y = 6,
Y = 13,
//SelectedItem = (int)smartView.BorderFrame.BackgroundColor
};
rbBackground.SelectedItemChanged += (s, e) => {
Expand Down
Loading