Skip to content

Commit

Permalink
Merge pull request #50 from FRACerqueira/v4.0.4
Browse files Browse the repository at this point in the history
V4.0.4
  • Loading branch information
FRACerqueira authored Aug 7, 2023
2 parents c38e0aa + 0b27aaa commit bbe72ad
Show file tree
Hide file tree
Showing 170 changed files with 2,409 additions and 2,926 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
- [License](#license)
- [API Reference](https://fracerqueira.github.io/PromptPlus/apis/apis.html)

## Whats news in V4.0.4
- Fixed bug PromptPlus not restore terminal original setting when shutdown application
- Fixed bug Autocomplete does not change result when backspace is pressed during search
- Added Property CurrentBuffer in console drive to return Current Buffer running (Primary/Secondary)
- Added SwapBuffer command to swith Primary/Secondar buffer (Valid only When console 'ansi' suported)
- Renamed 'AlternateScreen' to 'RunOnBuffer'. Now executes a custom action on TargetBuffer and returns to CurrentBuffer
- Refactored console drivers initialization, control options initialization
- Added auto create Environment 'PromptPlusConvertCodePage' to custom automate convert codepage to unicode-codepage
- Default value is = '850;65001'

## Whats news in V4.0.3
- New control to switch Alternate screen
- Fixed bug Console does not change foreground/background color correctly
Expand Down Expand Up @@ -462,6 +472,7 @@ PromptPlus.WriteLine($"Your input: {name.Value}!");
- FIGlet was inspired by the work of [FIGlet.Net](https://github.com/WenceyWang/FIGlet.Net).
- The colors and some of its dependencies were inspired by the work of [spectreconsole](https://spectreconsole.net/).
- The API Reference was inspired by the work of [xmldoc2md (Fork with improvements)](https://github.com/FRACerqueira/xmldoc2md).
- The EastAsianWidth and base-control was inspired by the work of [Sharprompt](https://github.com/shibayan/Sharprompt)

## Code of Conduct
[**Top**](#table-of-contents)
Expand Down
16 changes: 8 additions & 8 deletions Samples/AlternateScreenSamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@ static void Main(string[] args)
})
.Run();

PromptPlus.AlternateScreen()
.ForegroundColor(ConsoleColor.White)
.BackgroundColor(ConsoleColor.Red)
.CustomAction((cts) =>

PromptPlus.RunOnBuffer(TargetBuffer.Secondary,
(cts) =>
{
PromptPlus.WriteLine("This text run in secondary screen");
PromptPlus.WriteLines(2);
PromptPlus.KeyPress("Press any key to Swith primary screen", cfg =>
{
cfg.ShowTooltip(false);
})
.Run();
})
.Run();
.Run(cts);
},
ConsoleColor.White,
ConsoleColor.Red);

PromptPlus.WriteLines(2);
PromptPlus.KeyPress("End Sample!, Press any key", cfg =>
{
cfg.ShowTooltip(false);
cfg.ApplyStyle(StyleControls.Tooltips, Style.Plain.Foreground(Style.Plain.Background.GetInvertedColor()));
cfg.ApplyStyle(StyleControls.Tooltips, Style.Default.Foreground(Style.Default.Background.GetInvertedColor()));
})
.Run();

Expand Down
6 changes: 3 additions & 3 deletions Samples/BrowserMultSelectSamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ static void Main(string[] args)
PromptPlus.DoubleDash("Control:BrowserMultiSelect - Change Style");
PromptPlus.BrowserMultiSelect("Browser", "Folder Color.Blue / Color.Yellow ")
.Root(root, true)
.Styles(StyleBrowser.UnselectedFolder, Style.Plain.Foreground(Color.Blue))
.Styles(StyleBrowser.SelectedFolder, Style.Plain.Foreground(Color.Yellow))
.Styles(StyleBrowser.Lines, Style.Plain.Foreground(Color.Red))
.Styles(StyleBrowser.UnselectedFolder, Style.Default.Foreground(Color.Blue))
.Styles(StyleBrowser.SelectedFolder, Style.Default.Foreground(Color.Yellow))
.Styles(StyleBrowser.Lines, Style.Default.Foreground(Color.Red))
.Run();

PromptPlus.WriteLines(2);
Expand Down
6 changes: 3 additions & 3 deletions Samples/BrowserSamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ static void Main(string[] args)
PromptPlus.DoubleDash("Control:Browser - Change Style");
PromptPlus.Browser("Browser", "Folder Color.Blue / Color.Yellow ")
.Root(root, true)
.Styles(StyleBrowser.UnselectedFolder, Style.Plain.Foreground(Color.Blue))
.Styles(StyleBrowser.SelectedFolder, Style.Plain.Foreground(Color.Yellow))
.Styles(StyleBrowser.Lines, Style.Plain.Foreground(Color.Red))
.Styles(StyleBrowser.UnselectedFolder, Style.Default.Foreground(Color.Blue))
.Styles(StyleBrowser.SelectedFolder, Style.Default.Foreground(Color.Yellow))
.Styles(StyleBrowser.Lines, Style.Default.Foreground(Color.Red))
.Run();

PromptPlus.WriteLines(2);
Expand Down
16 changes: 8 additions & 8 deletions Samples/CalendarSamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

PromptPlus.Clear();

PromptPlus.DoubleDash($"Your default Culture is {cult.Name}", DashOptions.HeavyBorder, style: Style.Plain.Foreground(Color.Yellow));
PromptPlus.DoubleDash($"Your default Culture is {cult.Name}", DashOptions.HeavyBorder, style: Style.Default.Foreground(Color.Yellow));

PromptPlus.DoubleDash($"Control:Calendar ({cult.Name}) - minimal usage");

Expand Down Expand Up @@ -108,13 +108,13 @@

PromptPlus
.Calendar("Date", "Select date")
.Styles(StyleCalendar.Line, Style.Plain.Foreground(Color.Red))
.Styles(StyleCalendar.Day, Style.Plain.Foreground(Color.Yellow))
.Styles(StyleCalendar.Highlight, Style.Plain.Foreground(Color.Blue))
.Styles(StyleCalendar.Month, Style.Plain.Foreground(Color.Green))
.Styles(StyleCalendar.Selected, Style.Plain.Foreground(Color.Maroon))
.Styles(StyleCalendar.WeekDay, Style.Plain.Foreground(Color.Aqua))
.Styles(StyleCalendar.Year, Style.Plain.Foreground(Color.Violet))
.Styles(StyleCalendar.Line, Style.Default.Foreground(Color.Red))
.Styles(StyleCalendar.Day, Style.Default.Foreground(Color.Yellow))
.Styles(StyleCalendar.Highlight, Style.Default.Foreground(Color.Blue))
.Styles(StyleCalendar.Month, Style.Default.Foreground(Color.Green))
.Styles(StyleCalendar.Selected, Style.Default.Foreground(Color.Maroon))
.Styles(StyleCalendar.WeekDay, Style.Default.Foreground(Color.Aqua))
.Styles(StyleCalendar.Year, Style.Default.Foreground(Color.Violet))
.AddItems(CalendarScope.Highlight,
new ItemCalendar(DateTime.Now.AddDays(1), "Note1"),
new ItemCalendar(DateTime.Now.AddDays(2)))
Expand Down
14 changes: 7 additions & 7 deletions Samples/ChartSamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@
.PadLeft(2)
.HideValue()
.ShowLegends(true,false)
.Styles(StyleChart.Title, Style.Plain.Foreground(Color.Turquoise4))
.Styles(StyleChart.Label, Style.Plain.Foreground(Color.Yellow))
.Styles(StyleChart.Percent, Style.Plain.Foreground(Color.IndianRed))
.Styles(StyleChart.Value, Style.Plain.Foreground(Color.Aqua))
.Styles(StyleChart.Title, Style.Default.Foreground(Color.Turquoise4))
.Styles(StyleChart.Label, Style.Default.Foreground(Color.Yellow))
.Styles(StyleChart.Percent, Style.Default.Foreground(Color.IndianRed))
.Styles(StyleChart.Value, Style.Default.Foreground(Color.Aqua))
.Run();

PromptPlus
Expand Down Expand Up @@ -134,9 +134,9 @@
.HideOrdination()
.HideValue()
.ShowLegends(true, false)
.Styles(StyleChart.Label, Style.Plain.Foreground(Color.Yellow))
.Styles(StyleChart.Percent, Style.Plain.Foreground(Color.IndianRed))
.Styles(StyleChart.Value, Style.Plain.Foreground(Color.Aqua))
.Styles(StyleChart.Label, Style.Default.Foreground(Color.Yellow))
.Styles(StyleChart.Percent, Style.Default.Foreground(Color.IndianRed))
.Styles(StyleChart.Value, Style.Default.Foreground(Color.Aqua))
.Run();
PromptPlus
.KeyPress()
Expand Down
13 changes: 6 additions & 7 deletions Samples/ConsoleFeaturesSamples/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// See https://aka.ms/new-console-template for more information

using System.Globalization;
using PPlus;
using PPlus.Controls;

Expand All @@ -13,7 +12,6 @@ static void Main()
PromptPlus.Reset();
PromptPlus.Clear();


PromptPlus.WriteLine("[RGB(255,0,0) ON WHITE]Test[YELLOW] COLOR [/] BACK COLOR [/] other text");
PromptPlus.WriteLine("[#ff0000 ON WHITE]Test [YELLOW] COLOR [/] BACK COLOR [/] other text");
PromptPlus.WriteLine("[RED ON WHITE]Test[YELLOW] COLOR [/] BACK COLOR [/] other text");
Expand All @@ -36,20 +34,21 @@ static void Main()
PromptPlus
.KeyPress()
.Config(cfg => cfg.HideAfterFinish(true))
.Spinner(SpinnersType.DotsScrolling)
.Run();

PromptPlus.Setup((cfg) =>
{
cfg.PadLeft = 2;
cfg.PadRight = 2;
cfg.BackgroundColor = ConsoleColor.Blue;
cfg.Culture = new CultureInfo("en-us");
});

PromptPlus.BackgroundColor = ConsoleColor.Blue;
PromptPlus.Clear();

PromptPlus.SingleDash($"[yellow]Console Information[/]", DashOptions.DoubleBorder, 1 /*extra lines*/);
PromptPlus.WriteLine($"Current Buffer: {PromptPlus.CurrentTargetBuffer}");
PromptPlus.WriteLine($"IsTerminal: {PromptPlus.IsTerminal}");
PromptPlus.WriteLine($"CodePage : {PromptPlus.CodePage}");
PromptPlus.WriteLine($"IsUnicodeSupported: {PromptPlus.IsUnicodeSupported}");
PromptPlus.WriteLine($"OutputEncoding: {PromptPlus.OutputEncoding.EncodingName}");
PromptPlus.WriteLine($"ColorDepth: {PromptPlus.ColorDepth}");
Expand All @@ -65,7 +64,7 @@ static void Main()
{
cfg.HideAfterFinish(true)
.ShowTooltip(false)
.ApplyStyle(StyleControls.Tooltips, Style.Plain.Foreground(Color.Grey100));
.ApplyStyle(StyleControls.Tooltips, Style.Default.Foreground(Color.Grey100));
})
.Spinner(SpinnersType.Balloon)
.Run();
Expand Down Expand Up @@ -149,7 +148,7 @@ static void Main()
PromptPlus.KeyPress("End Sample!, Press any key", cfg =>
{
cfg.ShowTooltip(false);
cfg.ApplyStyle(StyleControls.Tooltips, Style.Plain.Foreground(Style.Plain.Background.GetInvertedColor()));
cfg.ApplyStyle(StyleControls.Tooltips, Style.Default.Foreground(Style.Default.Background.GetInvertedColor()));
})
.Run();

Expand Down
6 changes: 3 additions & 3 deletions Samples/MaskEditCurrencyTypeSamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static void Main(string[] args)
var cult = Thread.CurrentThread.CurrentCulture;
PromptPlus.Config.DefaultCulture = cult;

PromptPlus.DoubleDash($"Your default Culture is {cult.Name}", DashOptions.HeavyBorder, style: Style.Plain.Foreground(Color.Yellow));
PromptPlus.DoubleDash($"Your default Culture is {cult.Name}", DashOptions.HeavyBorder, style: Style.Default.Foreground(Color.Yellow));

PromptPlus.DoubleDash($"Control:MaskEdit Currency ({cult.Name}) - minimal usage");

Expand All @@ -34,8 +34,8 @@ static void Main(string[] args)
PromptPlus.MaskEdit("input", "MaskEdit Currency input")
.Mask(MaskedType.Currency)
.AmmoutPositions(10, 2, true)
.PositiveStyle(Style.Plain.Foreground(Color.Green))
.NegativeStyle(Style.Plain.Foreground(Color.IndianRed))
.PositiveStyle(Style.Default.Foreground(Color.Green))
.NegativeStyle(Style.Default.Foreground(Color.IndianRed))
.Run();

PromptPlus.DoubleDash($"Control:Currency - with overwrite culture:pt-br.");
Expand Down
4 changes: 2 additions & 2 deletions Samples/MaskEditDateTimeTypeSamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static void Main(string[] args)
var cult = Thread.CurrentThread.CurrentCulture;
PromptPlus.Config.DefaultCulture = cult;

PromptPlus.DoubleDash($"Your default Culture is {cult.Name}", DashOptions.HeavyBorder, style: Style.Plain.Foreground(Color.Yellow));
PromptPlus.DoubleDash($"Your default Culture is {cult.Name}", DashOptions.HeavyBorder, style: Style.Default.Foreground(Color.Yellow));


PromptPlus.DoubleDash($"Control:MaskEdit DateTime ({cult.Name}) - minimal usage");
Expand Down Expand Up @@ -42,7 +42,7 @@ static void Main(string[] args)
.Mask(MaskedType.DateTime)
.AcceptEmptyValue()
.DescriptionWithInputType(FormatWeek.Long)
.TypeTipStyle(Style.Plain.Foreground(Color.Aqua))
.TypeTipStyle(Style.Default.Foreground(Color.Aqua))
.Run();

PromptPlus.DoubleDash($"Control:MaskEdit DateTime - with overwrite culture:pt-br.");
Expand Down
4 changes: 2 additions & 2 deletions Samples/MaskEditDateTypeSamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static void Main(string[] args)
var cult = Thread.CurrentThread.CurrentCulture;
PromptPlus.Config.DefaultCulture = cult;

PromptPlus.DoubleDash($"Your default Culture is {cult.Name}", DashOptions.HeavyBorder, style: Style.Plain.Foreground(Color.Yellow));
PromptPlus.DoubleDash($"Your default Culture is {cult.Name}", DashOptions.HeavyBorder, style: Style.Default.Foreground(Color.Yellow));


PromptPlus.DoubleDash($"Control:MaskEdit DateOnly ({cult.Name}) - minimal usage");
Expand Down Expand Up @@ -41,7 +41,7 @@ static void Main(string[] args)
.Mask(MaskedType.DateOnly)
.AcceptEmptyValue()
.DescriptionWithInputType(FormatWeek.Long)
.TypeTipStyle(Style.Plain.Foreground(Color.IndianRed))
.TypeTipStyle(Style.Default.Foreground(Color.IndianRed))
.Run();

PromptPlus.DoubleDash($"Control:MaskEdit DateOnly - with overwrite culture:pt-br.");
Expand Down
2 changes: 1 addition & 1 deletion Samples/MaskEditGenericSamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static void Main(string[] args)
PromptPlus.MaskEdit("input", "MaskEdit Generic input")
.Mask(@"\XYZ 9{3}-L{3}-C[ABC]N{1}[XYZ]-A{3}")
.DescriptionWithInputType()
.TypeTipStyle(Style.Plain.Foreground(Color.Aqua))
.TypeTipStyle(Style.Default.Foreground(Color.Aqua))
.Run();

PromptPlus.DoubleDash("For other features below see - input samples (same behaviour)");
Expand Down
6 changes: 3 additions & 3 deletions Samples/MaskEditNumberTypeSamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static void Main(string[] args)
var cult = Thread.CurrentThread.CurrentCulture;
PromptPlus.Config.DefaultCulture = cult;

PromptPlus.DoubleDash($"Your default Culture is {cult.Name}", DashOptions.HeavyBorder, style: Style.Plain.Foreground(Color.Yellow));
PromptPlus.DoubleDash($"Your default Culture is {cult.Name}", DashOptions.HeavyBorder, style: Style.Default.Foreground(Color.Yellow));

PromptPlus.DoubleDash($"Control:MaskEdit Number ({cult.Name}) - minimal usage");

Expand All @@ -34,8 +34,8 @@ static void Main(string[] args)
PromptPlus.MaskEdit("input", "MaskEdit Number input")
.Mask(MaskedType.Number)
.AmmoutPositions(10, 2, true)
.PositiveStyle(Style.Plain.Foreground(Color.Green))
.NegativeStyle(Style.Plain.Foreground(Color.IndianRed))
.PositiveStyle(Style.Default.Foreground(Color.Green))
.NegativeStyle(Style.Default.Foreground(Color.IndianRed))
.Run();

PromptPlus.DoubleDash($"Control:Number - with overwrite culture:pt-br.");
Expand Down
4 changes: 2 additions & 2 deletions Samples/MaskEditTimeTypeSamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static void Main(string[] args)
var cult = Thread.CurrentThread.CurrentCulture;
PromptPlus.Config.DefaultCulture = cult;

PromptPlus.DoubleDash($"Your default Culture is {cult.Name}", DashOptions.HeavyBorder, style: Style.Plain.Foreground(Color.Yellow));
PromptPlus.DoubleDash($"Your default Culture is {cult.Name}", DashOptions.HeavyBorder, style: Style.Default.Foreground(Color.Yellow));


PromptPlus.DoubleDash($"Control:MaskEdit TimeOnly ({cult.Name}) - minimal usage");
Expand Down Expand Up @@ -42,7 +42,7 @@ static void Main(string[] args)
.Mask(MaskedType.TimeOnly)
.AcceptEmptyValue()
.DescriptionWithInputType()
.TypeTipStyle(Style.Plain.Foreground(Color.IndianRed))
.TypeTipStyle(Style.Default.Foreground(Color.IndianRed))
.Run();

PromptPlus.DoubleDash($"Control:MaskEdit TimeOnly - with overwrite culture:pt-br.");
Expand Down
9 changes: 5 additions & 4 deletions Samples/ProgressBarSamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ private static void MyPrgBarHandler(UpdateProgressBar<object> prgbar, Cancellati

static void Main(string[] args)
{

PromptPlus.WriteLine("Hello, World!");

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
Expand Down Expand Up @@ -86,17 +87,17 @@ static void Main(string[] args)
{
if (value <= 20)
{
return Style.Plain.Foreground(Color.Violet);
return Style.Default.Foreground(Color.Violet);
}
else if (value <= 60)
{
return Style.Plain.Foreground(PromptPlus.StyleSchema.Slider().Foreground);
return Style.Default.Foreground(PromptPlus.StyleSchema.Slider().Foreground);
}
else if (value <= 80)
{
return Style.Plain.Foreground(Color.Yellow);
return Style.Default.Foreground(Color.Yellow);
}
return Style.Plain.Foreground(Color.Red);
return Style.Default.Foreground(Color.Red);
})
.Run();

Expand Down
2 changes: 1 addition & 1 deletion Samples/SliderNumberLeftRightModeSamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static void Main(string[] args)
var cult = Thread.CurrentThread.CurrentCulture;
PromptPlus.Config.DefaultCulture = cult;

PromptPlus.DoubleDash($"Your default Culture is {cult.Name}", DashOptions.HeavyBorder, style: Style.Plain.Foreground(Color.Yellow));
PromptPlus.DoubleDash($"Your default Culture is {cult.Name}", DashOptions.HeavyBorder, style: Style.Default.Foreground(Color.Yellow));

PromptPlus.DoubleDash($"Control:SliderNumber {cult} - auto larger/shot step usage");
var sdl = PromptPlus
Expand Down
2 changes: 1 addition & 1 deletion Samples/SliderNumberUpDownModeSamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static void Main(string[] args)
var cult = Thread.CurrentThread.CurrentCulture;
PromptPlus.Config.DefaultCulture = cult;

PromptPlus.DoubleDash($"Your default Culture is {cult.Name}", DashOptions.HeavyBorder, style: Style.Plain.Foreground(Color.Yellow));
PromptPlus.DoubleDash($"Your default Culture is {cult.Name}", DashOptions.HeavyBorder, style: Style.Default.Foreground(Color.Yellow));

PromptPlus.DoubleDash($"Control:SliderNumber {cult} - auto larger/shot step usage");
var sdl = PromptPlus
Expand Down
2 changes: 1 addition & 1 deletion Samples/TreeViewMultiSelectSamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static void Main(string[] args)
separatePath: '|',
uniquenode: (item) => item.Id,
validselect: (item) => item.TypeInfo == TypeMyOrg.Funcionario)
.Styles(StyleTreeView.SelectedRoot, Style.Plain.Foreground(Color.Yellow))
.Styles(StyleTreeView.SelectedRoot, Style.Default.Foreground(Color.Yellow))
.PageSize(20)
.Interaction(MyOrg.LoadAreas(), (ctrl, item) =>
{
Expand Down
2 changes: 1 addition & 1 deletion Samples/TreeViewSamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static void Main(string[] args)
validselect: (item) => item.TypeInfo == TypeMyOrg.Funcionario,
setdisabled: (item) => item.TypeInfo != TypeMyOrg.Funcionario,
uniquenode: (item) => item.Id)
.Styles(StyleTreeView.SelectedRoot, Style.Plain.Foreground(Color.Yellow))
.Styles(StyleTreeView.SelectedRoot, Style.Default.Foreground(Color.Yellow))
.Interaction(MyOrg.LoadAreas(), (ctrl, item) =>
{
ctrl.AddNode(item);
Expand Down
Loading

0 comments on commit bbe72ad

Please sign in to comment.