Commit Graph

307 Commits

Author SHA1 Message Date
3dea412785 Add live display support
This commit also adds functionality to LiveRenderable that should
fix some problems related to vertical overflow.

Closes #316
Closes #415
2021-05-20 19:41:10 -04:00
315a52f3e9 Add support for hierarchical list prompts
Closes #412
2021-05-18 11:34:16 -04:00
c147929f16 Add color aliases 2021-05-12 23:44:11 +02:00
6549436356 Fix line break regression
In commit d1d94cd, we accidentally introduced a regression
since conhost requires all line breaks to be `\r\n`.
2021-05-10 17:42:49 -04:00
1dfc6bdadc Fix async race condition 2021-05-10 09:18:58 +02:00
2ba06577ef Improve CommandApp error message rendering
* Move line break to end of error message
* Move line break to start of each help section

Closes #392
2021-05-10 09:17:20 +02:00
ea5b7338ad renamed *`1.cs to *OfT.cs 2021-05-09 08:35:10 -05:00
4d88a6ab69 Play nice with type converters 2021-05-09 08:26:08 -05:00
1dd1945297 Add parameter value provider support
Adds support for parameter value providers which makes it
possible to set custom values for parameters.
2021-05-09 08:26:08 -05:00
d1d94cdebe Add Length and Lines properties to Paragraph
* Adds Length and Lines to `Paragraph`, `Markup` and `Text`.
* Do not use Environment.NewLine
2021-05-03 17:24:44 +02:00
cba02070f9 Add method to get VT/ANSI codes for renderables 2021-04-23 13:09:44 -04:00
01f707c78d Exposes Pretty property of CommandAppException
If a user is propagating the exceptions we aren't going to automatically display them. They might still want to get this exception message and use it, so we'll make it publicly available.
2021-04-23 16:44:41 +02:00
8d67c0a6b4 Removes printing of error messages when propagating 2021-04-23 16:44:41 +02:00
3463dde543 Add method to write VT/ANSI control codes
Adds a new extension method IAnsiConsole.WriteAnsi that writes
VT/ANSI control codes to the console. If VT/ANSI control codes are
not supported, nothing will be written.
2021-04-22 22:16:10 -04:00
91f910326c Fix maxWidth bug in Panel
Panel could pass a maxWidth to the child Render function that was greater than the maxWidth that was passed to the Panel render function.
I noticed this when trying to nest a table in a panel and the word wrapping was being disabled.

N.B It might be that Table.Measure ought to not return a measurment larger than maxWidth, but this Panel change seems defensivly sensible regardless.
2021-04-22 22:14:49 +02:00
f5a9c0ca26 Removes automatic registration of settings
Original intention was to register Settings automatically for DI. This ran into problem when the container verifies the configuration is valid for a settings using the constructor for initialization. It tries to resolve the parameters and fails.

This removes the automatic registration and falls back ActivatorCreateInstance when no Setting is registered.
2021-04-18 22:41:05 +02:00
23564612c1 Make AsyncCommand a little more discoverable (#375) 2021-04-18 09:35:37 +02:00
3e2eea730b Add output abstraction and reorganize profile
* Moves ColorSystem from Profile to Capabilities
* Renames Tty to IsTerminal
* Adds IAnsiConsoleOutput to make output more flexible

Closes #343
Closes #359
Closes #369
2021-04-13 21:39:54 -04:00
bc9f610258 Added "--hidden" param to explain feature
Probably shouldn't include the hidden commands by default. This lets the user show them if needed.
2021-04-13 17:40:55 +02:00
ae96606ab7 Adds default command to explain feature 2021-04-13 17:40:55 +02:00
41ccc0b464 Adds CLI explain command
Wanted a command to break down how Spectre views the command model. This outputs all the relevant settings in a tree. You can get a short explanation for all the commands, or a detailed explanation for all commands (there is a flag to go vice versa on the detailed view if you want)

app cli explain
app cli explain myappcommand
app cli explain -d
2021-04-12 17:40:31 +02:00
3545e0f6b5 Add example infrastructure
* Add "Shared" projects for all examples
* Update "Colors" example with better TrueColor demo
* Use same namespace for all examples
2021-04-11 22:03:13 -04:00
2fe2bb3c32 Add parameterless Clear method for IAnsiConsole
Closes #338
2021-04-11 22:01:14 -04:00
1fc6f22ea9 Remove Style.Clone method
Closes #362
2021-04-11 21:58:58 -04:00
13ac38ed04 Fix color system mapping bug
Closes #342
2021-04-08 12:18:54 -04:00
ca036f6543 Add demo example 2021-04-07 20:32:07 -04:00
36ec3d1fd3 Adds rune width caching for cell length calculations 2021-04-07 23:59:23 +02:00
fe5096dceb Fixes color system detection bug
If an application runs on Windows 10.0.15063 or above, on a
runtime prior to net5.0, the color system detection will fail
and fall back to 8-bit color support.

The reason for this is because the behavior of
Environment.OSVersion.Version differs between runtimes. Unless you're
running on net5.0, both the major and build version components will
not reflect those in the actual Windows version.
2021-04-07 11:15:45 -04:00
39b59c8d4a Cleanup AnsiSequences.cs
1. Update CSI constant to include the [ character.
See ECMA-48 Section 8.3.16
https://www.ecma-international.org/wp-content/uploads/ECMA-48_5th_edition_june_1991.pdf

2. Use string interpolation, because it's easier to read
(and internally uses a StringBuilder)

3. Add ESC constant, because the AnsiBuilder needs it to create links.

4. Remove unused SGR overload.
2021-04-06 22:51:42 +02:00
4edc647fdd Falls back to null for settings constructor 2021-04-06 22:48:51 +02:00
be45a0ff4e Fix AnsiConsoleBackend.Clear
1. Add an ED3 command to clear the scroll buffer.

This command is not in the original ANSI terminal control sequences but
was added later to XTerm to account for the fact that most modern
terminals have a scroll-buffer.

https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Functions-using-CSI-_-ordered-by-the-final-character-lparen-s-rparen:CSI-Ps-J.1C8A

This command is now awailable in basically
all terminals with scroll-buffers

2. Change CUP coordinates to 1, 1

The coordinates 0, 0 also worked, but strictly speaking they are outside
the available screen area and are capped to 1, 1 anyways.

This commit fixes #337
2021-04-06 22:42:03 +02:00
256fcdd27f Remove redundant Style constructor. 2021-04-06 07:30:31 -04:00
a690ce4955 Marks nullable bools as flags too 2021-04-05 16:14:13 +02:00
759b16aed9 Fix OS version detection 2021-04-04 09:28:20 -04:00
254880e93a Replaces emoji regex with ReadOnlySpan implementation
The RegEx runtime perf was never anything noticeable - it was the startup time that was eating over a third of time during initialization.

This shaves 200ms off the startup time.
2021-04-04 04:10:25 +02:00
6f16081f42 Add support for indeterminate progress
This commit also changes the behavior of ProgressContext.IsFinished.
Only tasks that have been started will be taken into consideration,
and not indeterminate tasks.

Closes #329
Closes #331
2021-04-03 09:42:49 -04:00
9204671b27 Uses Environment.TickCount for seed instead of DateTime.Now 2021-04-02 18:52:18 +02:00
c765bbd0dd Uses OSVersion instead of RegEx to detect Windows Build info
Perf improvement.
2021-04-02 18:51:30 +02:00
6bceac8a5e enable disposing ITypeResolver 2021-03-30 00:53:38 +02:00
1ed7e65fcb Make VT-100 sequences easier to understand 2021-03-28 12:51:19 -04:00
20650f1e7e Change IAnsiConsole to render IRenderable
This makes it possible for encoders to output better representation
of the actual objects instead of working with chopped up segments.

* IAnsiConsole.Write now takes an IRenderable instead of segments
* Calculating cell width does no longer require a render context
* Removed RenderContext.LegacyConsole
* Removed RenderContext.Encoding
* Added Capabilities.Unicode
2021-03-28 09:06:06 -04:00
2ba6da3514 Respect encoding of TextWriter provided to AnsiConsole.Create(...) 2021-03-25 21:19:49 +01:00
8830779875 Add params to ProgressExtensions.Columns(...)
This way you can omit `new ProgressColumn[] { ... }` and just list the columns separated by comma.
2021-03-25 21:11:51 +01:00
9c46c21e27 Fix argument order
Closes #319
2021-03-24 18:58:17 -04:00
c643ec735d Fix documentation for ProgressContext.AddTask 2021-03-24 07:34:56 -04:00
b17eabaa1f Adds helper overloads for Markup calls without args
Without specific overloads without the args string.format will get called even if it's not needed. 

This closes #309
2021-03-22 19:14:59 +01:00
7f6f2437b1 Add support for exclusive mode 2021-03-15 13:14:40 -04:00
c2bab0ebf8 Allow custom instructions for prompts
Closes #229
2021-03-14 21:27:44 -04:00
9502aaf2b9 Allow markup in selection prompts
Closes #221
2021-03-14 21:27:44 -04:00
57a8e6ccc1 Support Home, End, PgUp, and PgDown in prompts
Closes #296
2021-03-14 21:27:44 -04:00