Skip to content

Commit

Permalink
Smaller word-based fill with alt
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbilas committed May 12, 2024
1 parent c533f9c commit ac27ee6
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/Showkeys.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ async Task<CliExitCode> Drive(bool save)
[u]fills[/]:
f fill screen with a pattern (repeat to cycle patterns)
1-9 print this many lines with existing fill pattern
^1-9 print this many words with existing fill pattern
h ? print this help again

[u]moves[/]:
Expand Down Expand Up @@ -224,6 +225,8 @@ void Help()
};
// ReSharper restore StringLiteralTypo

string NextLoremIpsum() => loremIpsum[Random.Shared.Next(loremIpsum.Length)];

void PrintPatternLines(int count)
{
switch (pattern)
Expand All @@ -233,7 +236,7 @@ void PrintPatternLines(int count)
for (var y = 0; y < count; ++y)
{
while (sb.Length < size.Width)
sb.Append($"{loremIpsum[Random.Shared.Next(loremIpsum.Length)]} ");
sb.Append(NextLoremIpsum() + " ");
Out(sb.ToString()[..size.Width]);
if (y != size.Height-1)
OutLineRaw();
Expand All @@ -247,6 +250,22 @@ void PrintPatternLines(int count)
}
}

void PrintPatternWords(int count)
{
switch (pattern)
{
case 0:
var sb = new StringBuilder();
for (var i = 0; i < count; ++i)
sb.Append(NextLoremIpsum() + " ");
Out(sb.ToString());
break;

default:
throw new InvalidOperationException();
}
}

var (scrollTop, scrollBottom) = (0, size.Height-1);

void PrintStatus(string error)
Expand Down Expand Up @@ -307,6 +326,10 @@ void SetScrollMargin(int top, int bottom)
PrintPatternLines(c - '0');
break;

case { Char: var c and >= '1' and <= '9', Modifiers: ConsoleModifiers.Alt }:
PrintPatternWords(c - '0');
break;

case { Char: 'h' or '?', Modifiers: 0 }:
OutControl(c => c.MoveCursorTo(10000, 0));
OutLineRaw();
Expand Down

0 comments on commit ac27ee6

Please sign in to comment.