Skip to content

Commit

Permalink
Just some little stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbilas committed Aug 19, 2024
1 parent c060b44 commit 56580f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/Stale.Cli/Playback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading.Channels;
using Vezel.Cathode;
using Vezel.Cathode.Text.Control;

readonly record struct LineCapture(bool IsStdErr, DateTime When, string Line)
Expand Down
15 changes: 9 additions & 6 deletions src/Stale.Cli/StaleApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ async Task<CliExitCode> RunInternal()
static readonly Style k_stdErrStyle = new(background: Color.DarkRed);
static readonly Style k_statusStyle = new(decoration: Decoration.Italic);
static readonly Style k_userAlertStyle = new(foreground: Color.Yellow);
static readonly Style k_endOfTextStyle = new(foreground: Color.Grey);

void ControlFinishLogLine(bool newline)
{
Expand All @@ -218,6 +219,9 @@ void ControlPrintLogLine(OutLineType lineType, ReadOnlyMemory<char> chars, bool
case OutLineType.Status:
_cb.Print(chars.ToString(), k_statusStyle);
break;
case OutLineType.EndOfText:
_cb.Print(chars.ToString(), k_endOfTextStyle);
break;
default:
throw new ArgumentOutOfRangeException(nameof(lineType));
}
Expand All @@ -228,16 +232,13 @@ void ControlPrintLogLine(OutLineType lineType, string text, bool newline) =>
ControlPrintLogLine(lineType, text.AsMemory(), newline);

// TODO: spinner + timer while child process still running
void ControlPrintEndOfText(bool newline) => ControlPrintLogLine(OutLineType.Status, "‡", newline);
void ControlPrintEndOfText(bool newline) =>
ControlPrintLogLine(OutLineType.EndOfText, _options.PauseEveryLine ? "‡ " + k_pauseText : "‡", newline);

enum OutLineType { CapturedStdout, CapturedStderr, Status }
enum OutLineType { CapturedStdout, CapturedStderr, Status, EndOfText }

ValueTask OutLineAsync(bool stdErrOrOut, ReadOnlyMemory<char> chars) =>
OutLineAsync(stdErrOrOut ? OutLineType.CapturedStderr : OutLineType.CapturedStdout, chars);
ValueTask OutLineAsync(bool stdErrOrOut, string text) =>
OutLineAsync(stdErrOrOut, text.AsMemory());
ValueTask OutLineAsync(OutLineType lineType, string text) =>
OutLineAsync(lineType, text.AsMemory());

async ValueTask OutLineAsync(OutLineType lineType, ReadOnlyMemory<char> chars)
{
Expand Down Expand Up @@ -325,6 +326,8 @@ async Task LogCapturesAsync(ArraySegment<LineCapture> captures)
}
}

const string k_pauseText = "(paused: enter/space to advance 1/10; q to quit)";

async Task LinePauseAsync()
{
if (_pauseSkip != 0)
Expand Down

0 comments on commit 56580f1

Please sign in to comment.