Skip to content

Commit

Permalink
Merge pull request #16 from FRACerqueira/NET7
Browse files Browse the repository at this point in the history
v3.3.2-PromptPlus-3.3.2-1.0.0.332
  • Loading branch information
FRACerqueira authored Feb 24, 2023
2 parents e40a3d0 + 1d4e2a0 commit 5f2052b
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 157 deletions.
42 changes: 0 additions & 42 deletions PromptPlus.Tests/Controls/InputControlTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,48 +115,6 @@ internal void Should_have_accept_with_InitialValue_and_enter()
Assert.Equal("teste", initialvalue);
}

[Fact]
internal void Should_have_show_tooltips()
{
var first = true;
string[] viewstart = null;
string[] viewAfterF1 = null;

_reader.WaitRender(); //PPLUS custom code for KeyAvailable = false => ConsoleKeyInfo((char)0, 0, true, true, true)
_reader.LoadInput(new ConsoleKeyInfo((char)0, ConsoleKey.F1, false, false, false));
_reader.WaitRender(); //PPLUS custom code for KeyAvailable = false => ConsoleKeyInfo((char)0, 0, true, true, true)
_reader.LoadInput(new ConsoleKeyInfo((char)0, ConsoleKey.Enter, false, false, false));
var result = PromptPlus.Input("Prompt teste", "teste description")
.Default("default")
.InitialValue("teste")
.Config((ctx) =>
{
ctx.AddExtraAction(PPlus.Objects.StageControl.OnInputRender, (object ctx, string value) =>
{
if (first)
{
first = false;
viewstart = _memoryconsole.GetScreen();
}
else
{
viewAfterF1 = _memoryconsole.GetScreen();
}

});
})
.Run();
Assert.Equal("teste description", viewstart[1]);
Assert.Equal(4, viewstart.Length);
Assert.Contains("F1", viewstart[2]);
Assert.Contains("F3", viewstart[2]);
Assert.Contains("Esc", viewstart[2]);
Assert.Contains("Enter", viewstart[3]);
Assert.Equal(2, viewAfterF1.Length);
Assert.Contains("Prompt teste", viewAfterF1[0]);
Assert.Equal("teste description", viewstart[1]);
}

[Fact]
internal void Should_have_hide_description()
{
Expand Down
11 changes: 4 additions & 7 deletions PromptPlus/Controls/AutoCompleteControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,12 @@ public override string InputTemplate(ScreenBuffer screenBuffer)
if (EnabledTooltip)
{
screenBuffer.WriteLineStandardHotKeys(OverPipeLine, _options.EnabledAbortKey, _options.EnabledAbortAllPipes, !HasDescription);
if (_options.EnabledTooltip)
screenBuffer.WriteLine();
if (_localpaginator.PageCount > 1)
{
screenBuffer.WriteLine();
if (_localpaginator.PageCount > 1)
{
screenBuffer.WriteHint(Messages.KeyNavPaging);
}
screenBuffer.WriteHint(Messages.AutoCompleteKeyNavigation);
screenBuffer.WriteHint(Messages.KeyNavPaging);
}
screenBuffer.WriteHint(Messages.AutoCompleteKeyNavigation);
}
if (!_autoCompleteRunning && _inputBuffer.ToString().Length >= _options.MinimumPrefixLength)
{
Expand Down
11 changes: 4 additions & 7 deletions PromptPlus/Controls/BrowserControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,12 @@ public override string InputTemplate(ScreenBuffer screenBuffer)
if (EnabledTooltip)
{
screenBuffer.WriteLineStandardHotKeys(OverPipeLine, _options.EnabledAbortKey, _options.EnabledAbortAllPipes, !HasDescription);
if (_options.EnabledTooltip)
screenBuffer.WriteLine();
if (_paginator.PageCount > 1)
{
screenBuffer.WriteLine();
if (_paginator.PageCount > 1)
{
screenBuffer.WriteHint(Messages.KeyNavPaging);
}
screenBuffer.WriteHint(Messages.FolderKeyNavigation);
screenBuffer.WriteHint(Messages.KeyNavPaging);
}
screenBuffer.WriteHint(Messages.FolderKeyNavigation);
}

if (_filterBuffer.Length > 0)
Expand Down
5 changes: 1 addition & 4 deletions PromptPlus/Controls/ConfirmControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,7 @@ public override string InputTemplate(ScreenBuffer screenBuffer)
if (EnabledTooltip)
{
screenBuffer.WriteLineStandardHotKeys(OverPipeLine, _options.EnabledAbortKey, _options.EnabledAbortAllPipes, !HasDescription);
if (_options.EnabledTooltip)
{
screenBuffer.WriteLineHint(Messages.EnterFininsh);
}
screenBuffer.WriteLineHint(Messages.EnterFininsh);
}
_initform = false;
return _inputBuffer.ToString();
Expand Down
26 changes: 3 additions & 23 deletions PromptPlus/Controls/ControlBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ public ResultPromptPlus<T> Run(CancellationToken? value)

public ResultPromptPlus<T> StartPipeline(Func<ScreenBuffer, string> summarypipeline, Paginator<ResultPromptPlus<ResultPipe>> pipePaginator, int currentStep, CancellationToken stoptoken)
{
if (PromptPlus.DisabledAllTooltips)
{
EnabledTooltip = false;
}
try
{
PromptPlus.ExclusiveMode = true;
Expand Down Expand Up @@ -302,10 +298,6 @@ public ResultPromptPlus<T> Start(CancellationToken stoptoken)
{
Thread.CurrentThread.CurrentCulture = PromptPlus.DefaultCulture;
Thread.CurrentThread.CurrentUICulture = PromptPlus.DefaultCulture;
if (PromptPlus.DisabledAllTooltips)
{
EnabledTooltip = false;
}

_screenrender.StopToken = stoptoken;
if (!_showcursor)
Expand Down Expand Up @@ -578,16 +570,12 @@ public static bool IskeyPageNavagator<Tkey>(ConsoleKeyInfo consoleKeyInfo, Pagin

public bool CheckDefaultWizardKey(ConsoleKeyInfo keyInfo)
{
if (PromptPlus.DisabledAllTooltips)
{
EnabledTooltip = false;
}
if (PromptPlus.ToggleVisibleDescription.Equals(keyInfo) && _options.HasDescription)
{
HideDescription = !HideDescription;
return true;
}
else if (PromptPlus.TooltipKeyPress.Equals(keyInfo) && !PromptPlus.DisabledAllTooltips)
else if (PromptPlus.TooltipKeyPress.Equals(keyInfo) && !PromptPlus.EnabledTooltip)
{
EnabledTooltip = !EnabledTooltip;
return true;
Expand All @@ -609,16 +597,12 @@ public bool CheckAbortKey(ConsoleKeyInfo keyInfo)
}
public bool CheckDefaultKeyStopWaitProcess(ConsoleKeyInfo keyInfo)
{
if (PromptPlus.DisabledAllTooltips)
{
EnabledTooltip = false;
}
if (PromptPlus.ToggleVisibleDescription.Equals(keyInfo) && _options.HasDescription)
{
HideDescription = !HideDescription;
return false;
}
else if (PromptPlus.TooltipKeyPress.Equals(keyInfo) && !PromptPlus.DisabledAllTooltips)
else if (PromptPlus.TooltipKeyPress.Equals(keyInfo) && !PromptPlus.EnabledTooltip)
{
EnabledTooltip = !EnabledTooltip;
return false;
Expand Down Expand Up @@ -649,16 +633,12 @@ public bool CheckDefaultKeyStopWaitProcess(ConsoleKeyInfo keyInfo)

public bool CheckDefaultKey(ConsoleKeyInfo keyInfo)
{
if (PromptPlus.DisabledAllTooltips)
{
EnabledTooltip = false;
}
if (PromptPlus.ToggleVisibleDescription.Equals(keyInfo) && _options.HasDescription)
{
HideDescription = !HideDescription;
return true;
}
else if (PromptPlus.TooltipKeyPress.Equals(keyInfo) && !PromptPlus.DisabledAllTooltips)
else if (PromptPlus.TooltipKeyPress.Equals(keyInfo) && !PromptPlus.EnabledTooltip)
{
EnabledTooltip = !EnabledTooltip;
return true;
Expand Down
10 changes: 1 addition & 9 deletions PromptPlus/Controls/InputControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,7 @@ public override string InputTemplate(ScreenBuffer screenBuffer)
else
{
var aux = ", ";
if (_options.EnabledTooltip)
{
screenBuffer.WriteLineInputHit(_options.SwithVisiblePassword && _options.IsPassword, Messages.EnterFininsh);
}
else
{
screenBuffer.WriteLine();
aux = string.Empty;
}
screenBuffer.WriteLineInputHit(_options.SwithVisiblePassword && _options.IsPassword, Messages.EnterFininsh);
if (_options.SuggestionHandler != null)
{
screenBuffer.WriteHint($"{aux}{Messages.ReadlineSugestionhit}");
Expand Down
16 changes: 4 additions & 12 deletions PromptPlus/Controls/ListControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,20 +272,12 @@ public override string InputTemplate(ScreenBuffer screenBuffer)
else
{
var aux = ", ";
if (_options.EnabledTooltip)
screenBuffer.WriteLine();
if (_localpaginator.PageCount > 1)
{
screenBuffer.WriteLine();
if (_localpaginator.PageCount > 1)
{
screenBuffer.WriteHint(Messages.KeyNavPaging);
}
screenBuffer.WriteHint(Messages.ListKeyNavigation);
}
else
{
screenBuffer.WriteLine();
aux = string.Empty;
screenBuffer.WriteHint(Messages.KeyNavPaging);
}
screenBuffer.WriteHint(Messages.ListKeyNavigation);
if (_options.SuggestionHandler != null)
{
screenBuffer.WriteHint($"{aux}{Messages.ReadlineSugestionhit}");
Expand Down
5 changes: 1 addition & 4 deletions PromptPlus/Controls/MaskedInputControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,7 @@ public override string InputTemplate(ScreenBuffer screenBuffer)
if (EnabledTooltip)
{
screenBuffer.WriteLineStandardHotKeys(OverPipeLine, _options.EnabledAbortKey, _options.EnabledAbortAllPipes, !HasDescription);
if (_options.EnabledTooltip)
{
screenBuffer.WriteLineHint($"{Messages.EnterFininsh}{Messages.MaskEditErase}");
}
screenBuffer.WriteLineHint($"{Messages.EnterFininsh}{Messages.MaskEditErase}");
}

if (_options.ValidateOnDemand && _options.Validators.Count > 0)
Expand Down
27 changes: 12 additions & 15 deletions PromptPlus/Controls/MaskedListControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,29 +388,26 @@ public override string InputTemplate(ScreenBuffer screenBuffer)
if (EnabledTooltip)
{
screenBuffer.WriteLineStandardHotKeys(OverPipeLine, _options.EnabledAbortKey, _options.EnabledAbortAllPipes, !HasDescription);
if (_options.EnabledTooltip)
screenBuffer.WriteLine();
if (_localpaginator.PageCount > 1)
{
screenBuffer.WriteLine();
if (_localpaginator.PageCount > 1)
screenBuffer.WriteHint(Messages.KeyNavPaging);
}
if (_options.MaskedOption.FillNumber == s_defaultfill)
{
if (_inputBuffer.Length > 0)
{
screenBuffer.WriteHint(Messages.KeyNavPaging);
}
if (_options.MaskedOption.FillNumber == s_defaultfill)
{
if (_inputBuffer.Length > 0)
{
screenBuffer.WriteHint(Messages.ListKeyNavigationFillZeros);
}
else
{
screenBuffer.WriteHint(Messages.ListKeyNavigation);
}
screenBuffer.WriteHint(Messages.ListKeyNavigationFillZeros);
}
else
{
screenBuffer.WriteHint(Messages.ListKeyNavigation);
}
}
else
{
screenBuffer.WriteHint(Messages.ListKeyNavigation);
}
}
var subset = _localpaginator.ToSubset();
var index = 0;
Expand Down
11 changes: 4 additions & 7 deletions PromptPlus/Controls/MultiSelectControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,12 @@ public override string InputTemplate(ScreenBuffer screenBuffer)
if (EnabledTooltip)
{
screenBuffer.WriteLineStandardHotKeys(OverPipeLine, _options.EnabledAbortKey, _options.EnabledAbortAllPipes, !HasDescription);
if (_options.EnabledTooltip)
screenBuffer.WriteLine();
if (_localpaginator.PageCount > 1)
{
screenBuffer.WriteLine();
if (_localpaginator.PageCount > 1)
{
screenBuffer.WriteHint(Messages.KeyNavPaging);
}
screenBuffer.WriteHint(string.Format(Messages.MultiSelectKeyNavigation));
screenBuffer.WriteHint(Messages.KeyNavPaging);
}
screenBuffer.WriteHint(string.Format(Messages.MultiSelectKeyNavigation));
}

if (_filterBuffer.Length > 0)
Expand Down
13 changes: 4 additions & 9 deletions PromptPlus/Controls/SelectControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,12 @@ public override string InputTemplate(ScreenBuffer screenBuffer)
if (EnabledTooltip)
{
screenBuffer.WriteLineStandardHotKeys(OverPipeLine, _options.EnabledAbortKey, _options.EnabledAbortAllPipes, !HasDescription);
if (_options.EnabledTooltip)
screenBuffer.WriteLine();
if (_localpaginator.PageCount > 1)
{
screenBuffer.WriteLine();
if (_localpaginator.PageCount > 1)
{
screenBuffer.WriteHint(Messages.KeyNavPaging);
}
screenBuffer.WriteHint(Messages.SelectKeyNavigation);

screenBuffer.WriteHint(Messages.KeyNavPaging);
}

screenBuffer.WriteHint(Messages.SelectKeyNavigation);
}

if (_filterBuffer.Length > 0)
Expand Down
15 changes: 6 additions & 9 deletions PromptPlus/Controls/SliderNumberControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,13 @@ public override string InputTemplate(ScreenBuffer screenBuffer)
if (EnabledTooltip)
{
screenBuffer.WriteLineStandardHotKeys(OverPipeLine, _options.EnabledAbortKey, _options.EnabledAbortAllPipes, !HasDescription);
if (_options.EnabledTooltip)
if (_options.Type == SliderNumberType.LeftRight)
{
if (_options.Type == SliderNumberType.LeftRight)
{
screenBuffer.WriteLineHint(Messages.SliderNumberKeyNavigator);
}
else if (_options.Type == SliderNumberType.UpDown)
{
screenBuffer.WriteLineHint(Messages.NumberUpDownKeyNavigator);
}
screenBuffer.WriteLineHint(Messages.SliderNumberKeyNavigator);
}
else if (_options.Type == SliderNumberType.UpDown)
{
screenBuffer.WriteLineHint(Messages.NumberUpDownKeyNavigator);
}
}
return ValueToString(_currentValue);
Expand Down
5 changes: 1 addition & 4 deletions PromptPlus/Controls/SliderSwitchControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,7 @@ public override string InputTemplate(ScreenBuffer screenBuffer)
if (EnabledTooltip)
{
screenBuffer.WriteLineStandardHotKeys(OverPipeLine, _options.EnabledAbortKey, _options.EnabledAbortAllPipes, !HasDescription);
if (_options.EnabledTooltip)
{
screenBuffer.WriteHint(Messages.SliderSwitcheKeyNavigator);
}
screenBuffer.WriteHint(Messages.SliderSwitcheKeyNavigator);
}
if (_currentValue)
{
Expand Down
2 changes: 0 additions & 2 deletions PromptPlus/PromptPlus.Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ private set

#endregion

public static bool DisabledAllTooltips { get; set; } = false;

public static HotKey AbortAllPipesKeyPress { get; set; } = new(UserHotKey.F7, true, false, false);

internal static HotKey AbortKeyPress { get; set; } = new(ConsoleKey.Escape, false, false, false);
Expand Down
2 changes: 1 addition & 1 deletion PromptPlus/PromptPlus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<PackageId>PromptPlus</PackageId>
<PackageReadmeFile>NugetREADME.md</PackageReadmeFile>
<PackageProjectUrl>https://fracerqueira.github.io/PromptPlus</PackageProjectUrl>
<Version>3.3.1</Version>
<Version>3.3.2</Version>
<PackageIcon>icon.png</PackageIcon>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<Copyright>© 2021 - Fernando Cerqueira </Copyright>
Expand Down
Loading

0 comments on commit 5f2052b

Please sign in to comment.