Gutenberg

Class Alignment

How to behave when composing two Box<T>es with mismatched sizes.

Inheritance
Declaration
public sealed class Alignment : Enum

Fields

CenterEnd

Align the smaller box with the centre of the larger one. If the box can't be exactly centred (because the width difference is an odd number), align it one character closer to the end.

Declaration
public const Alignment CenterEnd
Field Value
Type Description

Alignment

Examples

When boxes are being composed vertically, the start of the alignment axis is the left-hand side of the box.

var box = Box.FromString("abcdefgh")
    .Above("ijk", Alignment.CenterEnd)
    .WithBorder();
Console.Write(box.ToString());
// Output:
// ┌────────┐
// │abcdefgh│
// │   ijk  │
// └────────┘

When boxes are being composed horiztonally, the start of the alignment axis is the top of the box.

var box = Box.FromString(string.Join('\n', "abcdefgh".AsEnumerable()))
    .LeftOf(string.Join('\n', "ijk".AsEnumerable()), Alignment.CenterEnd)
    .WithBorder();
Console.Write(box.ToString());
// Output:
// ┌──┐
// │a │
// │b │
// │c │
// │di│
// │ej│
// │fk│
// │g │
// │h │
// └──┘

CenterStart

Align the smaller box with the centre of the larger one. If the box can't be exactly centred (because the width difference is an odd number), align it one character closer to the start.

Declaration
public const Alignment CenterStart
Field Value
Type Description

Alignment

Examples

When boxes are being composed vertically, the start of the alignment axis is the left-hand side of the box.

var box = Box.FromString("abcdefgh")
    .Above("ijk", Alignment.CenterStart)
    .WithBorder();
Console.Write(box.ToString());
// Output:
// ┌────────┐
// │abcdefgh│
// │  ijk   │
// └────────┘

When boxes are being composed horiztonally, the start of the alignment axis is the top of the box.

var box = Box.FromString(string.Join('\n', "abcdefgh".AsEnumerable()))
    .LeftOf(string.Join('\n', "ijk".AsEnumerable()), Alignment.CenterStart)
    .WithBorder();
Console.Write(box.ToString());
// Output:
// ┌──┐
// │a │
// │b │
// │ci│
// │dj│
// │ek│
// │f │
// │g │
// │h │
// └──┘

End

Align the smaller box with the end (the bottom or right) of the larger one.

Declaration
public const Alignment End
Field Value
Type Description

Alignment

Examples

When boxes are being composed vertically, the start of the alignment axis is the left-hand side of the box.

var box = Box.FromString("abcdefgh")
    .Above("ijk", Alignment.End)
    .WithBorder();
Console.Write(box.ToString());
// Output:
// ┌────────┐
// │abcdefgh│
// │     ijk│
// └────────┘

When boxes are being composed horiztonally, the start of the alignment axis is the top of the box.

var box = Box.FromString(string.Join('\n', "abcdefgh".AsEnumerable()))
    .LeftOf(string.Join('\n', "ijk".AsEnumerable()), Alignment.End)
    .WithBorder();
Console.Write(box.ToString());
// Output:
// ┌──┐
// │a │
// │b │
// │c │
// │d │
// │e │
// │fi│
// │gj│
// │hk│
// └──┘

Start

Align the smaller box with the start (the top or left) of the larger one.

Declaration
public const Alignment Start
Field Value
Type Description

Alignment

Examples

When boxes are being composed vertically, the start of the alignment axis is the left-hand side of the box.

var box = Box.FromString("abcdefgh")
    .Above("ijk", Alignment.Start)
    .WithBorder();
Console.Write(box.ToString());
// Output:
// ┌────────┐
// │abcdefgh│
// │ijk     │
// └────────┘

When boxes are being composed horiztonally, the start of the alignment axis is the top of the box.

var box = Box.FromString(string.Join('\n', "abcdefgh".AsEnumerable()))
    .LeftOf(string.Join('\n', "ijk".AsEnumerable()), Alignment.Start)
    .WithBorder();
Console.Write(box.ToString());
// Output:
// ┌──┐
// │ai│
// │bj│
// │ck│
// │d │
// │e │
// │f │
// │g │
// │h │
// └──┘

value__

Declaration
public int value__
Field Value
Type Description

Int32