From 2e33b94bf4e4a7df504b2f8f01ba841c0e3ba648 Mon Sep 17 00:00:00 2001 From: Fernando Cerqueira Date: Mon, 7 Aug 2023 09:22:47 -0300 Subject: [PATCH] fixed #48 , Updated docs and codeQL --- Src/Controls/Input/AutoCompleteControl.cs | 9 +- Src/Controls/StyleSchema.cs | 2 +- Src/Drivers/ConsoleDriveMemory.cs | 2 +- Src/Drivers/DriveExtensions.cs | 4 +- Src/Drivers/Style.cs | 4 +- docs/apis/apis.md | 2 +- docs/apis/pplus.controls.configcontrols.md | 389 +++++++++++++++++++++ docs/apis/pplus.iconsolebase.md | 36 ++ docs/apis/pplus.iprofiledrive.md | 46 --- docs/apis/pplus.profilesetup.md | 37 -- docs/apis/pplus.promptplus.md | 5 +- docs/apis/pplus.style.md | 2 +- 12 files changed, 438 insertions(+), 100 deletions(-) create mode 100644 docs/apis/pplus.controls.configcontrols.md diff --git a/Src/Controls/Input/AutoCompleteControl.cs b/Src/Controls/Input/AutoCompleteControl.cs index 0e73b696..6a38b668 100644 --- a/Src/Controls/Input/AutoCompleteControl.cs +++ b/Src/Controls/Input/AutoCompleteControl.cs @@ -447,13 +447,10 @@ public override ResultPrompt TryResult(CancellationToken cancellationTok } else { - if (!skipstartComplete) + if (!skipstartComplete && oldinput != _inputBuffer.ToString() && oldinput != null) { - if (oldinput != _inputBuffer.ToString() && oldinput != null) - { - _autoCompleteRunning = true; - _autoCompleteSendStart = true; - } + _autoCompleteRunning = true; + _autoCompleteSendStart = true; } } var clear = !_autoCompleteRunning; diff --git a/Src/Controls/StyleSchema.cs b/Src/Controls/StyleSchema.cs index d76ff47f..842a496c 100644 --- a/Src/Controls/StyleSchema.cs +++ b/Src/Controls/StyleSchema.cs @@ -14,7 +14,7 @@ namespace PPlus.Controls /// public class StyleSchema { - private Dictionary _Styles; + private readonly Dictionary _Styles; internal StyleSchema() { diff --git a/Src/Drivers/ConsoleDriveMemory.cs b/Src/Drivers/ConsoleDriveMemory.cs index 77a7dca4..55171378 100644 --- a/Src/Drivers/ConsoleDriveMemory.cs +++ b/Src/Drivers/ConsoleDriveMemory.cs @@ -475,7 +475,7 @@ public bool OnBuffer(TargetBuffer target, Action value, Conso try { - ForegroundColor = defaultforecolor??curforecolor; + ForegroundColor = defaultforecolor ?? curforecolor; BackgroundColor = defaultbackcolor ?? curbackcolor; IsControlText = true; diff --git a/Src/Drivers/DriveExtensions.cs b/Src/Drivers/DriveExtensions.cs index 70676caa..a586a994 100644 --- a/Src/Drivers/DriveExtensions.cs +++ b/Src/Drivers/DriveExtensions.cs @@ -23,7 +23,7 @@ public static partial class PromptPlus { private static readonly bool RunningConsoleMemory = false; private static readonly CultureInfo AppConsoleCulture; - internal static IConsoleControl _consoledrive; + internal static readonly IConsoleControl _consoledrive; private static ConfigControls _configcontrols; private static readonly StyleSchema _styleschema; private static readonly object lockrecord = new(); @@ -606,7 +606,7 @@ private static void Profile(Action config) var param = new ProfileSetup { - IsLegacy = RunningConsoleMemory ? false: _consoledrive.IsLegacy, + IsLegacy = !RunningConsoleMemory && _consoledrive.IsLegacy, ColorDepth = RunningConsoleMemory ? ColorSystem.TrueColor : _consoledrive.ColorDepth, IsTerminal = RunningConsoleMemory || _consoledrive.IsTerminal, IsUnicodeSupported = RunningConsoleMemory || _consoledrive.IsUnicodeSupported, diff --git a/Src/Drivers/Style.cs b/Src/Drivers/Style.cs index a63d48da..0249ec5b 100644 --- a/Src/Drivers/Style.cs +++ b/Src/Drivers/Style.cs @@ -40,9 +40,9 @@ public Style(Color foreground, Color background, Overflow overflowStrategy = Ove } /// - /// Gets a with the default colors and default overflow. + /// Gets a with the default colors and overflow.None /// - public static Style Default => new(PromptPlus._consoledrive.ForegroundColor, PromptPlus._consoledrive.BackgroundColor, PromptPlus._consoledrive.OverflowStrategy); + public static Style Default => new(Color.DefaultForecolor, Color.DefaultBackcolor, Overflow.None); /// /// Gets a with the default colors and overflow Crop. diff --git a/docs/apis/apis.md b/docs/apis/apis.md index 3ab52581..a2203290 100644 --- a/docs/apis/apis.md +++ b/docs/apis/apis.md @@ -72,7 +72,7 @@ - [ChartOrder](./pplus.controls.chartorder.md) -- [Config](./pplus.controls.config.md) +- [ConfigControls](./pplus.controls.configcontrols.md) - [EventPipe<T>](./pplus.controls.eventpipe-1.md) diff --git a/docs/apis/pplus.controls.configcontrols.md b/docs/apis/pplus.controls.configcontrols.md new file mode 100644 index 00000000..b6892479 --- /dev/null +++ b/docs/apis/pplus.controls.configcontrols.md @@ -0,0 +1,389 @@ +# PromptPlus API:ConfigControls + +[![Build](https://github.com/FRACerqueira/PromptPlus/workflows/Build/badge.svg)](https://github.com/FRACerqueira/PromptPlus/actions/workflows/build.yml) +[![Publish](https://github.com/FRACerqueira/PromptPlus/actions/workflows/publish.yml/badge.svg)](https://github.com/FRACerqueira/PromptPlus/actions/workflows/publish.yml) +[![License](https://img.shields.io/github/license/FRACerqueira/PromptPlus)](https://github.com/FRACerqueira/PromptPlus/blob/master/LICENSE) +[![NuGet](https://img.shields.io/nuget/v/PromptPlus)](https://www.nuget.org/packages/PromptPlus/) +[![Downloads](https://img.shields.io/nuget/dt/PromptPlus)](https://www.nuget.org/packages/PromptPlus/) + +[**Back to List Api**](./apis.md) + +# ConfigControls + +Namespace: PPlus.Controls + +Represents the common config properties for all controls. + +```csharp +public class ConfigControls +``` + +Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ConfigControls](./pplus.controls.configcontrols.md) + +## Properties + +### **CalendarSwitchNotesPress** + +Get/Set [HotKey](./pplus.controls.hotkey.md) to toggle view notes in calendar. +
Default value : '[F2]' + +```csharp +public HotKey CalendarSwitchNotesPress { get; set; } +``` + +#### Property Value + +[HotKey](./pplus.controls.hotkey.md)
+ +###
**ChartBarSwitchLegendPress** + +Get/Set [HotKey](./pplus.controls.hotkey.md) to toggle ChartBar Legend view. +
Default value : '[F3]' + +```csharp +public HotKey ChartBarSwitchLegendPress { get; set; } +``` + +#### Property Value + +[HotKey](./pplus.controls.hotkey.md)
+ +###
**ChartBarSwitchOrderPress** + +Get/Set [HotKey](./pplus.controls.hotkey.md) to toggle ChartBar Order view. +
Default value : '[F4]' + +```csharp +public HotKey ChartBarSwitchOrderPress { get; set; } +``` + +#### Property Value + +[HotKey](./pplus.controls.hotkey.md)
+ +###
**ChartBarSwitchTypePress** + +Get/Set [HotKey](./pplus.controls.hotkey.md) to toggle ChartBar Layout view. +
Default value : '[F2]' + +```csharp +public HotKey ChartBarSwitchTypePress { get; set; } +``` + +#### Property Value + +[HotKey](./pplus.controls.hotkey.md)
+ +###
**CompletionMaxCount** + +Get/Set Completion Max Items to return. +
Default value : 1000. If value less than 1 internal sette to 1. + +```csharp +public int CompletionMaxCount { get; set; } +``` + +#### Property Value + +[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+ +###
**CompletionMinimumPrefixLength** + +Get/Set Minimum Prefix Length. +
Default value : 3.If value less than 0 internal sette to 0. + +```csharp +public int CompletionMinimumPrefixLength { get; set; } +``` + +#### Property Value + +[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+ +###
**CompletionWaitToStart** + +Get/Set Interval in mileseconds to wait start Completion funcion. +
Default value : 1000. If value less than 10 internal sette to 10. + +```csharp +public int CompletionWaitToStart { get; set; } +``` + +#### Property Value + +[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+ +###
**DefaultCulture** + +Get/Set default Culture([CultureInfo](https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo)) for all controls. + +```csharp +public CultureInfo DefaultCulture { get; set; } +``` + +#### Property Value + +[CultureInfo](https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo)
+ +###
**EditItemPress** + +Get/Set [HotKey](./pplus.controls.hotkey.md) to Edit item. +
Default value : '[F2]' + +```csharp +public HotKey EditItemPress { get; set; } +``` + +#### Property Value + +[HotKey](./pplus.controls.hotkey.md)
+ +###
**EnabledAbortKey** + +Get/Set enabled abortKey(ESC) for all controls. +
Default value : true + +```csharp +public bool EnabledAbortKey { get; set; } +``` + +#### Property Value + +[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+ +###
**FullPathPress** + +Get/Set [HotKey](./pplus.controls.hotkey.md) toggle current path to full path. +
Default value : '[F2]' + +```csharp +public HotKey FullPathPress { get; set; } +``` + +#### Property Value + +[HotKey](./pplus.controls.hotkey.md)
+ +###
**HideAfterFinish** + +Get/Set hide controls after finish for all controls. +
Default value : false + +```csharp +public bool HideAfterFinish { get; set; } +``` + +#### Property Value + +[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+ +###
**HideOnAbort** + +Get/Set hide controls On Abort for all controls. +
Default value : false + +```csharp +public bool HideOnAbort { get; set; } +``` + +#### Property Value + +[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+ +###
**HistoryTimeout** + +Get/Set History Timeout. +
Default value : 365 days + +```csharp +public TimeSpan HistoryTimeout { get; set; } +``` + +#### Property Value + +[TimeSpan](https://docs.microsoft.com/en-us/dotnet/api/system.timespan)
+ +###
**InvertSelectedPress** + +Get/Set [HotKey](./pplus.controls.hotkey.md) to Invert Selected item. +
Default value : '[F3]' + +```csharp +public HotKey InvertSelectedPress { get; set; } +``` + +#### Property Value + +[HotKey](./pplus.controls.hotkey.md)
+ +###
**NoChar** + +Get/Set value for NO answer +
Default value : NoChar in built-in resources. Fall-back when null : N + +```csharp +public Nullable NoChar { get; set; } +``` + +#### Property Value + +[Nullable<Char>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +###
**PageSize** + +Get/Set Page Size from colletions. +
Default value : 10. If value less than 1 internal sette to 1. + +```csharp +public int PageSize { get; set; } +``` + +#### Property Value + +[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+ +###
**PasswordViewPress** + +Get/Set [HotKey](./pplus.controls.hotkey.md) to toggle password view. +
Default value : '[F2]' + +```csharp +public HotKey PasswordViewPress { get; set; } +``` + +#### Property Value + +[HotKey](./pplus.controls.hotkey.md)
+ +###
**RemoveItemPress** + +Get/Set [HotKey](./pplus.controls.hotkey.md) to Remove item. +
Default value : '[F3]' + +```csharp +public HotKey RemoveItemPress { get; set; } +``` + +#### Property Value + +[HotKey](./pplus.controls.hotkey.md)
+ +###
**SecretChar** + +Get/Set value char for secret input +
Default value : '#'. Fall-back when null : '#' + +```csharp +public Nullable SecretChar { get; set; } +``` + +#### Property Value + +[Nullable<Char>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +###
**SelectAllPress** + +Get/Set [HotKey](./pplus.controls.hotkey.md) to Select all item. +
Default value : '[F2]' + +```csharp +public HotKey SelectAllPress { get; set; } +``` + +#### Property Value + +[HotKey](./pplus.controls.hotkey.md)
+ +###
**ShowTooltip** + +Get/Set enabled show Tooltip for all controls. +
Default value : true + +```csharp +public bool ShowTooltip { get; set; } +``` + +#### Property Value + +[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+ +###
**ToggleExpandAllPress** + +Get/Set [HotKey](./pplus.controls.hotkey.md) Toggle Expand /Collapse All node. +
Default value : '[F4]' + +```csharp +public HotKey ToggleExpandAllPress { get; set; } +``` + +#### Property Value + +[HotKey](./pplus.controls.hotkey.md)
+ +###
**ToggleExpandPress** + +Get/Set [HotKey](./pplus.controls.hotkey.md) Toggle Expand/Collapse node. +
Default value : '[F3]' + +```csharp +public HotKey ToggleExpandPress { get; set; } +``` + +#### Property Value + +[HotKey](./pplus.controls.hotkey.md)
+ +###
**TooltipKeyPress** + +Get/Set [HotKey](./pplus.controls.hotkey.md) to show/hide Tooltip. +
Default value : '[F1]' + +```csharp +public HotKey TooltipKeyPress { get; } +``` + +#### Property Value + +[HotKey](./pplus.controls.hotkey.md)
+ +###
**YesChar** + +Get/Set value for YES answer +
Default value : YesChar in built-in resources. Fall-back when null : Y + +```csharp +public Nullable YesChar { get; set; } +``` + +#### Property Value + +[Nullable<Char>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +## Methods + +###
**Symbols(SymbolType, String, String)** + +Get/Set the Symbols for all controls.If empty params return current set. + +```csharp +public ValueTuple Symbols(SymbolType schema, string value, string unicode) +``` + +#### Parameters + +`schema` [SymbolType](./pplus.controls.symboltype.md)
+[SymbolType](./pplus.controls.symboltype.md) to set + +`value` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+Text symbol when not unicode support + +`unicode` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+Text symbol when has unicode support + +#### Returns + +(string value, string unicode) value + + +- - - +[**Back to List Api**](./apis.md) diff --git a/docs/apis/pplus.iconsolebase.md b/docs/apis/pplus.iconsolebase.md index 8d5e88d4..263fd832 100644 --- a/docs/apis/pplus.iconsolebase.md +++ b/docs/apis/pplus.iconsolebase.md @@ -20,6 +20,42 @@ public interface IConsoleBase : ICursorDrive, IInputDrive, IOutputDrive, IBacken Implements [ICursorDrive](./pplus.icursordrive.md), [IInputDrive](./pplus.iinputdrive.md), [IOutputDrive](./pplus.ioutputdrive.md), [IBackendTextWrite](./pplus.ibackendtextwrite.md), [IProfileDrive](./pplus.iprofiledrive.md), [IConsoleExtendDrive](./pplus.iconsoleextenddrive.md) +## Properties + +###
**BackgroundColor** + +Get/set console BackgroundColor + +```csharp +public abstract ConsoleColor BackgroundColor { get; set; } +``` + +#### Property Value + +ConsoleColor
+ +###
**ForegroundColor** + +Get/set console ForegroundColor + +```csharp +public abstract ConsoleColor ForegroundColor { get; set; } +``` + +#### Property Value + +ConsoleColor
+ +## Methods + +###
**ResetColor()** + +Reset colors to default values. + +```csharp +void ResetColor() +``` + - - - [**Back to List Api**](./apis.md) diff --git a/docs/apis/pplus.iprofiledrive.md b/docs/apis/pplus.iprofiledrive.md index eda23c39..ddb75401 100644 --- a/docs/apis/pplus.iprofiledrive.md +++ b/docs/apis/pplus.iprofiledrive.md @@ -20,18 +20,6 @@ public interface IProfileDrive ## Properties -### **BackgroundColor** - -Get/set BackgroundColor console with color. - -```csharp -public abstract ConsoleColor BackgroundColor { get; set; } -``` - -#### Property Value - -ConsoleColor
- ###
**BufferHeight** Gets the height of the buffer area. @@ -68,30 +56,6 @@ public abstract ColorSystem ColorDepth { get; } [ColorSystem](./pplus.colorsystem.md)
-###
**DefaultStyle** - -Get default [Style](./pplus.style.md) console. - -```csharp -public abstract Style DefaultStyle { get; internal set; } -``` - -#### Property Value - -[Style](./pplus.style.md)
- -###
**ForegroundColor** - -Get/Set Foreground console with color. - -```csharp -public abstract ConsoleColor ForegroundColor { get; set; } -``` - -#### Property Value - -ConsoleColor
- ###
**IsLegacy** Get Terminal is legacy. @@ -188,16 +152,6 @@ public abstract bool SupportsAnsi { get; } [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
-## Methods - -###
**ResetColor()** - -Reset colors to default values. - -```csharp -void ResetColor() -``` - - - - [**Back to List Api**](./apis.md) diff --git a/docs/apis/pplus.profilesetup.md b/docs/apis/pplus.profilesetup.md index f2c3191c..54f0b41b 100644 --- a/docs/apis/pplus.profilesetup.md +++ b/docs/apis/pplus.profilesetup.md @@ -22,18 +22,6 @@ Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) ## Properties -### **BackgroundColor** - -Get/Set BackgroundColor console with color. - -```csharp -public ConsoleColor BackgroundColor { get; set; } -``` - -#### Property Value - -ConsoleColor
- ###
**ColorDepth** Get/Set Color capacity.[ColorSystem](./pplus.colorsystem.md) @@ -46,31 +34,6 @@ public ColorSystem ColorDepth { get; set; } [ColorSystem](./pplus.colorsystem.md)
-###
**Culture** - -Get/Set Default Culture for console -
Culture is global set fro threads - -```csharp -public CultureInfo Culture { get; set; } -``` - -#### Property Value - -[CultureInfo](https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo)
- -###
**ForegroundColor** - -Get/Set Foreground console with color. - -```csharp -public ConsoleColor ForegroundColor { get; set; } -``` - -#### Property Value - -ConsoleColor
- ###
**IsLegacy** Get/Set Terminal is legacy. diff --git a/docs/apis/pplus.promptplus.md b/docs/apis/pplus.promptplus.md index e570bcfd..fdcc1185 100644 --- a/docs/apis/pplus.promptplus.md +++ b/docs/apis/pplus.promptplus.md @@ -87,12 +87,12 @@ public static ColorSystem ColorDepth { get; } Get global properties for all controls. ```csharp -public static Config Config { get; } +public static ConfigControls Config { get; } ``` #### Property Value -[Config](./pplus.controls.config.md)
+[ConfigControls](./pplus.controls.configcontrols.md)
###
**CurrentTargetBuffer** @@ -1577,7 +1577,6 @@ A stream that is the new standard output. ### **Setup(Action<ProfileSetup>)** Overwrite current console with new console profile. -
After overwrite the new console the screeen is clear
and all Style-Schema are updated with backgoundcolor console ```csharp public static void Setup(Action config) diff --git a/docs/apis/pplus.style.md b/docs/apis/pplus.style.md index af0799f7..b37a1449 100644 --- a/docs/apis/pplus.style.md +++ b/docs/apis/pplus.style.md @@ -37,7 +37,7 @@ public Color Background { get; } ###
**Default** -Gets a [Style](./pplus.style.md) with the default colors and default overflow. +Gets a [Style](./pplus.style.md) with the default colors and overflow.None ```csharp public static Style Default { get; }