Improve text composite

- A `Text` object should not be able to justify itself.
  All justification needs to be done by a parent.
- Apply colors and styles to part of a `Text` object
- Markup parser should return a `Text` object
This commit is contained in:
Patrik Svensson
2020-07-30 23:26:22 +02:00
committed by Patrik Svensson
parent 8e4f33bba4
commit f19202b427
33 changed files with 728 additions and 434 deletions

View File

@@ -53,9 +53,10 @@ namespace Sample
AnsiConsole.Foreground = Color.Maroon;
AnsiConsole.Render(new Panel(new Panel(new Panel(new Panel(
Text.New(
"I heard you like 📦\n\n\n\nSo I put a 📦 in a 📦",
foreground: Color.White,
justify: Justify.Center))))));
"[underline]I[/] heard [underline on blue]you[/] like 📦\n\n\n\n" +
"So I put a 📦 in a 📦\nin a 📦 in a 📦\n\n" +
"😅",
foreground: Color.White), content: Justify.Center)))));
// Reset colors
AnsiConsole.ResetColors();
@@ -69,16 +70,14 @@ namespace Sample
// Centered panel with text
AnsiConsole.Render(new Panel(
Text.New("Centered\nCenter",
foreground: Color.White,
justify: Justify.Center),
fit: true));
foreground: Color.White),
fit: true, content: Justify.Center));
// Right adjusted panel with text
AnsiConsole.Render(new Panel(
Text.New("Right adjusted\nRight",
foreground: Color.White,
justify: Justify.Right),
fit: true));
foreground: Color.White),
fit: true, content: Justify.Right));
}
}
}