Aptivi - Manual
ProjectsWebsiteBlog
Terminaux - Manual
Terminaux - Manual
  • Welcome!
  • Breaking changes
    • API v1.0
    • API v2.0
    • API v3.0
    • API v4.0
    • API v5.0
    • API v6.0
    • API v7.0
  • Usage
    • Preface
    • Console Tools
      • Console Checker
        • Console Size Requirements
      • Image Rendering
        • Icons
      • Console Writers
        • Individual Writers
        • Cyclic Writers
          • Geometric Shapes
          • Charts
          • Text
          • Artistic
          • Progress Bars
          • Lists and Calendars
          • Miscellaneous
        • Informational Boxes
      • Textual UI
        • Interactive TUI
        • Console Screen
        • Console Resize Listener
        • VT Sequences
      • Console Wrapper
      • Console Colors
      • Color Templates
      • Presentation System
      • Console Extensions
      • Nerd Fonts
      • Terminal Info
      • Test Fixtures
      • Terminal Structures
      • Console Logging
    • Input Reader
      • Shells
        • Shell Structure
          • Help System
          • Command Parsing
          • Command Information
          • Command Switches
          • Shell Presets
          • Command Aliasing
      • Other Input
        • Keybindings
        • Choice-based inputs
        • Editors and Viewers
        • Figlet Font Selector
        • Color Wheel
        • Spinner Selector
      • Reader State
      • Reader Settings
      • Syntax Highlighting
      • Pointer Events
    • Color Sequences
      • Color Model Conversions
      • Color Model Parsing
      • Interop with System.Drawing.Color
  • Report an issue
  • Source code
  • API Reference
Powered by GitBook
On this page
Edit on GitHub
  1. Usage
  2. Console Tools

Console Wrapper

How do I wrap the console?

Terminaux provides you with a powerful console wrapper that allows you to customize how the console behaves in your .NET console applications that make use of this wrapper and/or built-in Terminaux features. This wrapper is easy to use, amidst the recent structural improvements to the console wrapper functionality compared to Terminaux 1.x.

One big advantage of using this console wrapper is that you're able to get the console cursor visibility, but only if you're using Terminaux's cursor visibility wrapper. This works on Windows, macOS, Android, and Linux.

To use this console wrapper, just replace all the calls to Console with our replacement ConsoleWrapper to take advantage of Terminaux's console wrapping feature. However, you can use this wrapper only for the following actions:

  • CursorLeft (get and set)

  • CursorTop (get and set)

  • WindowWidth (get and set)

  • WindowHeight (get and set)

  • BufferWidth (get and set)

  • BufferHeight (get and set)

  • CursorVisible (get and set)

  • KeyAvailable (get)

  • TreatCtrlCAsInput (get and set)

  • Clear() (with and without background)

  • GetCursorPosition()

  • SetCursorPosition()

  • SetWindowDimensions()

  • SetBufferDimensions()

  • Beep()

  • ReadKey()

  • Write()

  • WriteLine()

  • Error.Write()

  • Error.WriteLine()

Note that properties and functions that work only for Windows, such as MoveBufferArea, and have no good alternative alternatives for macOS and Linux are not going to be wrapped.

Setting the Wrappers

You can customize the console wrappers so that applications that call the Terminaux console wrapper can make use of your own custom wrapper function by setting the action properties found in ConsoleWrapperTools. You can make changes to the following wrappers (all prefixed by the Action word in all the properties):

  • IsDumb

  • CursorLeft

  • SetCursorLeft

  • CursorTop

  • SetCursorTop

  • WindowWidth

  • SetWindowWidth

  • WindowHeight

  • SetWindowHeight

  • BufferWidth

  • SetBufferWidth

  • BufferHeight

  • SetBufferHeight

  • CursorVisible

  • GetCursorVisible

  • TreatCtrlCAsInput

  • KeyAvailable

  • Clear() (without background)

  • ClearLoadBack() (with background)

  • GetCursorPosition()

  • SetCursorPosition()

  • SetWindowDimensions()

  • SetBufferDimensions()

  • Beep()

  • BeepSeq()

  • ReadKey()

  • WriteChar()

  • WriteString()

  • WriteParameterized()

  • WriteLine()

  • WriteLineStirng()

  • WriteLineParameterized()

  • WriteError()

  • WriteErrorLine()

In order for your console wrapper to be usable, all your custom wrapper functions must be fast, as interactive TUIs rely on performance.

Last updated 6 months ago