Giter Club home page Giter Club logo

consoleselect's Introduction

ConsoleSelect

Usage

The following example:

var consoleSelect = new ConsoleSelect();

var options = new[]
{
    new ConsoleSelect.Option<string> { Key = "option1", Text = "Option 1" },
    new ConsoleSelect.Option<string> { Key = "option2", Text = "Option 2" },
    new ConsoleSelect.Option<string> { Key = "option3", Text = "Option 3", Selected = true },
    new ConsoleSelect.Option<string> { Key = "option4", Text = "Option 4" },
    new ConsoleSelect.Option<string> { Key = "option5", Text = "Option 5" }
};

var selectedOption = consoleSelect.PropmtSelection("Select an option:", options);

Would render:


Select an option:

[ ] Option 1
[ ] Option 2
[X] Option 3
[ ] Option 4
[ ] Option 5

By default, UpArrow and DownArrow is used to move selection up and down. Enter is used to confirm the selection.

Customization

The ConsoleSelect(ConsoleSelect.Settings settings) constructor can be used to customize the following:

Property Default Description
OptionRenderFormat "[{Selected}] {Text}" The render format of each option ({Selected} and {Text} are required placeholders)
OptionNotSelectedIndicator " " The string indicating that an option is not selected
OptionSelectedIndicator "X" The string indicating that an option is selected
IsTitleEnabled true Whether or not the title should be drawn
MoveSelectionUpKey ConsoleKey.UpArrow The key used to move the selection up
MoveSelectionDownKey ConsoleKey.DownArrow The key used to move the selection down
ConfirmSelectionKey ConsoleKey.Enter The key used to confirm the selection
TextWriter Console.Out The writer used to output the title and options
InputKeyReader intercept => Console.ReadKey(intercept) A function to read a key from user input
CursorVisibilitySetter visible => Console.CursorVisible = visible A function to set the console cursor visibility
CursorPositionSetter (left, top) => Console.SetCursorPosition(left, top) A function to set the console cursor position
CursorLeftGetter () => Console.CursorLeft A function to get the console cursor left position
CursorTopGetter () => Console.CursorTop A function to get the console cursor top position

consoleselect's People

Contributors

katostoelen avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.