Class ConsoleMisc
Miscellaneous extensions for the console
Inheritance
Namespace: Terminaux.Base.Extensions
Assembly: Terminaux.dll
Syntax
public static class ConsoleMisc
Properties
| Edit this page View SourceIsOnAltBuffer
Checks to see whether we're in the alternative buffer or not
Declaration
public static bool IsOnAltBuffer { get; }
Property Value
Type | Description |
---|---|
bool |
TerminalReversesRtlText
Specifies whether your terminal emulator reverses the RTL text automatically or not
Declaration
public static bool TerminalReversesRtlText { get; set; }
Property Value
Type | Description |
---|---|
bool |
Methods
| Edit this page View SourceBell(ConsoleBell, int, int)
Emits the console bell using either audible or visible bell types
Declaration
public static void Bell(ConsoleBell bell = ConsoleBell.Audible, int delay = -1, int freq = -1)
Parameters
Type | Name | Description |
---|---|---|
ConsoleBell | bell | Type of console bell |
int | delay | Delay of the bell (audible and visual) |
int | freq | Frequency of the bell (audible) |
FilterVTSequences(string)
Filters the VT sequences that matches the regex
Declaration
public static string FilterVTSequences(string Text)
Parameters
Type | Name | Description |
---|---|---|
string | Text | The text that contains the VT sequences |
Returns
Type | Description |
---|---|
string | The text that doesn't contain the VT sequences |
Flash()
Flashes the screen
Declaration
public static void Flash()
Flash(int)
Flashes the screen
Declaration
public static void Flash(int delay)
Parameters
Type | Name | Description |
---|---|---|
int | delay | Delay as specified |
GetWrappedSentences(string, int)
Gets the wrapped sentences for text wrapping for console (with character wrapping)
Declaration
public static string[] GetWrappedSentences(string text, int maximumLength)
Parameters
Type | Name | Description |
---|---|---|
string | text | Text to be wrapped |
int | maximumLength | Maximum length of text before wrapping |
Returns
Type | Description |
---|---|
string[] |
GetWrappedSentences(string, int, int)
Gets the wrapped sentences for text wrapping for console (with character wrapping)
Declaration
public static string[] GetWrappedSentences(string text, int maximumLength, int indentLength)
Parameters
Type | Name | Description |
---|---|---|
string | text | Text to be wrapped |
int | maximumLength | Maximum length of text before wrapping |
int | indentLength | Indentation length |
Returns
Type | Description |
---|---|
string[] |
GetWrappedSentencesByWords(string, int)
Gets the wrapped sentences for text wrapping for console (with word wrapping)
Declaration
public static string[] GetWrappedSentencesByWords(string text, int maximumLength)
Parameters
Type | Name | Description |
---|---|---|
string | text | Text to be wrapped |
int | maximumLength | Maximum length of text before wrapping |
Returns
Type | Description |
---|---|
string[] |
Remarks
This function returns the same output as GetWrappedSentences(string, int, int) if there are any full-width characters.
GetWrappedSentencesByWords(string, int, int)
Gets the wrapped sentences for text wrapping for console (with word wrapping)
Declaration
public static string[] GetWrappedSentencesByWords(string text, int maximumLength, int indentLength)
Parameters
Type | Name | Description |
---|---|---|
string | text | Text to be wrapped |
int | maximumLength | Maximum length of text before wrapping |
int | indentLength | Indentation length |
Returns
Type | Description |
---|---|
string[] |
Remarks
This function returns the same output as GetWrappedSentences(string, int, int) if there are any full-width characters.
InitializeSequences()
Initializes the VT sequence handling for Windows systems.
Declaration
public static bool InitializeSequences()
Returns
Type | Description |
---|---|
bool | True if successful; false if not. Alays true on non-Windows systems. |
PercentRepeat(int, int, int)
Gets how many times to repeat the character to represent the appropriate percentage level for the specified number.
Declaration
public static int PercentRepeat(int CurrentNumber, int MaximumNumber, int WidthOffset)
Parameters
Type | Name | Description |
---|---|---|
int | CurrentNumber | The current number that is less than or equal to the maximum number. |
int | MaximumNumber | The maximum number. |
int | WidthOffset | The console window width offset. It's usually a multiple of 2. |
Returns
Type | Description |
---|---|
int | How many times to repeat the character |
PercentRepeatTargeted(int, int, int)
Gets how many times to repeat the character to represent the appropriate percentage level for the specified number.
Declaration
public static int PercentRepeatTargeted(int CurrentNumber, int MaximumNumber, int TargetWidth)
Parameters
Type | Name | Description |
---|---|---|
int | CurrentNumber | The current number that is less than or equal to the maximum number. |
int | MaximumNumber | The maximum number. |
int | TargetWidth | The target width |
Returns
Type | Description |
---|---|
int | How many times to repeat the character |
ReverseRtl(string)
Reverses the right-to-left characters in a string (for terminal printing)
Declaration
public static string ReverseRtl(string target)
Parameters
Type | Name | Description |
---|---|---|
string | target | Target string to reverse |
Returns
Type | Description |
---|---|
string | A string containing reversed RTL characters for usage with terminal writing. Returns the original string if either the terminal emulator is reversing the order of RTL characters or if there are no RTL characters |
SetTitle(string)
Sets the console title
Declaration
public static void SetTitle(string Text)
Parameters
Type | Name | Description |
---|---|---|
string | Text | The text to be set |
ShowAltBuffer()
Shows the alternate buffer
Declaration
public static void ShowAltBuffer()
ShowMainBuffer()
Shows the main buffer
Declaration
public static void ShowMainBuffer()
Truncate(string, int)
Truncates the string if the string is larger than the threshold, otherwise, returns an unchanged string
Declaration
public static string Truncate(this string target, int threshold)
Parameters
Type | Name | Description |
---|---|---|
string | target | Source string to truncate |
int | threshold | Max number of string characters |
Returns
Type | Description |
---|---|
string | Truncated string |