Skip to content

Latest commit

 

History

History
51 lines (40 loc) · 2.11 KB

README.md

File metadata and controls

51 lines (40 loc) · 2.11 KB

CSLHelper

Description

Makes creating, destroying, and and printing to a console window easier, with support for virtual terminal sequences and basic text colors.

How To Use

using System.Windows.Forms;
using CSLHelper;

using Icon = System.Drawing.Icon;

namespace MyProgram
{
    public partial class MyForm : Form
    {
        InitializeComponent();

        // the 'IsVirtual' parameter defaults to 'false', so only put 'true' here if you want it enabled
        Console.Inst.CreateConsole("My Console Window", true);
        FormClosing += (_, __) => Console.Inst.DestroyConsole();

        Console.Inst.SetIcon(Icon); // sets the window caption icon and the taskbar icon of the console window
        Console.Inst.SetIconBig(Icon); // sets the taskbar icon of the console window
        Console.Inst.SetIconSmall(Icon); // sets the window caption icon of the console window

        // have following printed text be bright red and bright black (aka gray)
        Console.Inst.SetTextColor(TextColor.BrightRed, BackColor.BrightBlack);
        Console.Inst.WriteLine("Hello World!");
        Console.Inst.WriteLine("Look at my cool text!");

        // if you have 'IsVirtual' set to 'true' when calling 'Console.Inst.CreateConsole',
        // you can use ANSI escape codes to format the text and do other manipulations with the console window
        Console.Inst.Write("\x1b[H\x1b[2J"); // clear the console window

        // the following command is similar to calling:
        // Console.Inst.SetTextColor(TextColor.Red);
        // Console.Inst.Write("This is red text");
        Console.Inst.Write("\x1b[31mThis is red text"); // print red text
    }
}

Example

FYI

In the release, there is a file called cslpp.dll, which you only need to download if it is not automatically being written to in the same directory as CSLHelper.dll.

Download

CSLHelper.dll
cslpp.dll — if not in the same directory as CSLHelper.dll when program is run