Search Results for

    Class ConsoleMisc

    Miscellaneous extensions for the console

    Inheritance
    object
    ConsoleMisc
    Namespace
    Terminaux.Base.Extensions @ Terminaux.dll
    Syntax
    public static class ConsoleMisc


    Properties

    IsOnAltBuffer

    Checks to see whether we're in the alternative buffer or not

    Property Value
    bool
    Declaration
    public static bool IsOnAltBuffer { get; }

    TabWidth

    Tab width to set

    Property Value
    int
    Declaration
    public static int TabWidth { get; set; }

    TerminalReversesRtlText

    Specifies whether your terminal emulator reverses the RTL text automatically or not

    Property Value
    bool
    Declaration
    public static bool TerminalReversesRtlText { get; set; }


    Methods

    Bell(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
    Name Type Description
    bell ConsoleBell

    Type of console bell

    delay int

    Delay of the bell (audible and visual)

    freq int

    Frequency of the bell (audible)

    FilterVTSequences(string)

    Filters the VT sequences that matches the regex

    Returns
    string

    The text that doesn't contain the VT sequences

    Declaration
    public static string FilterVTSequences(string Text)
    Parameters
    Name Type Description
    Text string

    The text that contains 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
    Name Type Description
    delay int

    Delay as specified

    GetWrappedSentences(string, int)

    Gets the wrapped sentences for text wrapping for console (with character wrapping)

    Returns
    string[]
    Declaration
    public static string[] GetWrappedSentences(string text, int maximumLength)
    Parameters
    Name Type Description
    text string

    Text to be wrapped

    maximumLength int

    Maximum length of text before wrapping

    GetWrappedSentences(string, int, int)

    Gets the wrapped sentences for text wrapping for console (with character wrapping)

    Returns
    string[]
    Declaration
    public static string[] GetWrappedSentences(string text, int maximumLength, int indentLength)
    Parameters
    Name Type Description
    text string

    Text to be wrapped

    maximumLength int

    Maximum length of text before wrapping

    indentLength int

    Indentation length

    GetWrappedSentencesByWords(string, int)

    Gets the wrapped sentences for text wrapping for console (with word wrapping)

    Remarks

    This function returns the same output as GetWrappedSentences(string, int, int) if there are any full-width characters.

    Returns
    string[]
    Declaration
    public static string[] GetWrappedSentencesByWords(string text, int maximumLength)
    Parameters
    Name Type Description
    text string

    Text to be wrapped

    maximumLength int

    Maximum length of text before wrapping

    GetWrappedSentencesByWords(string, int, int)

    Gets the wrapped sentences for text wrapping for console (with word wrapping)

    Remarks

    This function returns the same output as GetWrappedSentences(string, int, int) if there are any full-width characters.

    Returns
    string[]
    Declaration
    public static string[] GetWrappedSentencesByWords(string text, int maximumLength, int indentLength)
    Parameters
    Name Type Description
    text string

    Text to be wrapped

    maximumLength int

    Maximum length of text before wrapping

    indentLength int

    Indentation length

    InitializeSequences()

    Initializes the VT sequence handling for Windows systems.

    Returns
    bool

    True if successful; false if not. Alays true on non-Windows systems.

    Declaration
    public static bool InitializeSequences()

    Pad(string, int, TextAlignment)

    Pads the string to the specified alignment with spaces

    Returns
    string

    Padded string

    Declaration
    public static string Pad(string text, int totalLength, TextAlignment alignment)
    Parameters
    Name Type Description
    text string

    Text to pad to the specified alignment

    totalLength int

    Total length (total cells) of the padded string

    alignment TextAlignment

    Text alignment to pad the text

    Pad(string, int, WideChar, TextAlignment)

    Pads the string to the specified alignment with spaces

    Returns
    string

    Padded string

    Declaration
    public static string Pad(string text, int totalLength, WideChar padder, TextAlignment alignment)
    Parameters
    Name Type Description
    text string

    Text to pad to the specified alignment

    totalLength int

    Total length (total cells) of the padded string

    padder WideChar

    Pad character

    alignment TextAlignment

    Text alignment to pad the text

    PadLeft(string, int)

    Pads the string to the left with spaces

    Returns
    string

    Padded string

    Declaration
    public static string PadLeft(string text, int totalLength)
    Parameters
    Name Type Description
    text string

    Text to pad to the left

    totalLength int

    Total length (total cells) of the padded string

    PadLeft(string, int, WideChar)

    Pads the string to the left with spaces

    Returns
    string

    Padded string

    Declaration
    public static string PadLeft(string text, int totalLength, WideChar padder)
    Parameters
    Name Type Description
    text string

    Text to pad to the left

    totalLength int

    Total length (total cells) of the padded string

    padder WideChar

    Pad character

    PadMiddle(string, int)

    Pads the string to the middle with spaces

    Returns
    string

    Padded string

    Declaration
    public static string PadMiddle(string text, int totalLength)
    Parameters
    Name Type Description
    text string

    Text to pad to the middle

    totalLength int

    Total length (total cells) of the padded string

    PadMiddle(string, int, WideChar)

    Pads the string to the middle with spaces

    Returns
    string

    Padded string

    Declaration
    public static string PadMiddle(string text, int totalLength, WideChar padder)
    Parameters
    Name Type Description
    text string

    Text to pad to the middle

    totalLength int

    Total length (total cells) of the padded string

    padder WideChar

    Pad character

    PadRight(string, int)

    Pads the string to the right with spaces

    Returns
    string

    Padded string

    Declaration
    public static string PadRight(string text, int totalLength)
    Parameters
    Name Type Description
    text string

    Text to pad to the right

    totalLength int

    Total length (total cells) of the padded string

    PadRight(string, int, WideChar)

    Pads the string to the right with spaces

    Returns
    string

    Padded string

    Declaration
    public static string PadRight(string text, int totalLength, WideChar padder)
    Parameters
    Name Type Description
    text string

    Text to pad to the right

    totalLength int

    Total length (total cells) of the padded string

    padder WideChar

    Pad character

    Paragraphize(string, bool, int)

    Makes an array of strings that are processed for printing paragraphs from raw text

    Returns
    string[]

    An array of paragraph lines, with empty lines separating paragraphs

    Declaration
    public static string[] Paragraphize(this string text, bool wrapLines = true, int wrapWidth = 75)
    Parameters
    Name Type Description
    text string

    Text to process

    wrapLines bool

    Whether to wrap lines or not

    wrapWidth int

    Word wrap width for each line

    PercentRepeat(int, int, int)

    Gets how many times to repeat the character to represent the appropriate percentage level for the specified number.

    Returns
    int

    How many times to repeat the character

    Declaration
    public static int PercentRepeat(int CurrentNumber, int MaximumNumber, int WidthOffset)
    Parameters
    Name Type Description
    CurrentNumber int

    The current number that is less than or equal to the maximum number.

    MaximumNumber int

    The maximum number.

    WidthOffset int

    The console window width offset. It's usually a multiple of 2.

    PercentRepeatTargeted(int, int, int)

    Gets how many times to repeat the character to represent the appropriate percentage level for the specified number.

    Returns
    int

    How many times to repeat the character

    Declaration
    public static int PercentRepeatTargeted(int CurrentNumber, int MaximumNumber, int TargetWidth)
    Parameters
    Name Type Description
    CurrentNumber int

    The current number that is less than or equal to the maximum number.

    MaximumNumber int

    The maximum number.

    TargetWidth int

    The target width

    PreviewAltBuffer()

    Previews the alternative buffer (if the console is in the main buffer)

    Declaration
    public static void PreviewAltBuffer()

    PreviewMainBuffer()

    Previews the main buffer (if the console is in the alternative buffer)

    Declaration
    public static void PreviewMainBuffer()

    ReverseRtl(string)

    Reverses the right-to-left characters in a string (for terminal printing)

    Returns
    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

    Declaration
    public static string ReverseRtl(string target)
    Parameters
    Name Type Description
    target string

    Target string to reverse

    SetEncoding(ConsoleEncoding)

    Sets the Windows console encoding

    Declaration
    public static void SetEncoding(ConsoleEncoding encoding)
    Parameters
    Name Type Description
    encoding ConsoleEncoding

    SetTitle(string)

    Sets the console title

    Declaration
    public static void SetTitle(string Text)
    Parameters
    Name Type Description
    Text string

    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, bool)

    Truncates the string if the string is larger than the threshold, otherwise, returns an unchanged string

    Returns
    string

    Truncated string

    Declaration
    public static string Truncate(this string target, int threshold, bool ellipsis = true)
    Parameters
    Name Type Description
    target string

    Source string to truncate

    threshold int

    Max number of string characters

    ellipsis bool

    Whether to insert ellipsis or not

    Show / Hide Table of Contents

    Table of contents



      About

      Copyright © 2014-2026 Aptivi

      Find us

    •  
    •  
    •  
    •  
    •  
    •  
    • Social media

    •  
    •  
    •  
    •