SelectableText_lib_namespace 1.0.0

dotnet add package SelectableText_lib_namespace --version 1.0.0
                    
NuGet\Install-Package SelectableText_lib_namespace -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SelectableText_lib_namespace" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SelectableText_lib_namespace" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SelectableText_lib_namespace" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SelectableText_lib_namespace --version 1.0.0
                    
#r "nuget: SelectableText_lib_namespace, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SelectableText_lib_namespace@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SelectableText_lib_namespace&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=SelectableText_lib_namespace&version=1.0.0
                    
Install as a Cake Tool

SelectableText_lib

A C# library for enabling selectable text that runs functions upon selection.

Overview

SelectableText_lib enables you to easily create interactive text menus. You define selectable (and optionally non-selectable) text segments, assign functions to them, and display them to the user—ideal for building menus and interactive console experiences.

Example: Using the Library (showcase_proj)

The showcase_proj directory contains a sample console project showcasing different usage scenarios, such as simple menus, keyword-driven menus, advanced multi-action menus, and a calendar picker.

Shorter menu's

Using the library you can make a 4 choice + exit menu which is around 53 lines (using a switch case to sort the input). To around 15 lines using the library. (The numbers where directly pulled from the showcase_proj comparing the main function to the SimpleMenu function).

Sample Code: Creating a Keyword Menu

using SelectableText_lib_namespace;

static void KeyWordMenu()
{
    // Initialize the menu with optional animation and color customization
    SelectableText_lib st = new SelectableText_lib(true, ConsoleColor.Black, ConsoleColor.White);

    // Add selectable and non-selectable text items
    st.AddText("test", "Test [yes]", myfunction);      // Selectable: runs myfunction
    st.AddText("test2", "Test 2 [no]", myfunction2);   // Selectable: runs myfunction2
    st.AddText("sometext", "some text");               // Non-selectable
    st.AddText("sometext2", "some text2");             // Non-selectable

    // Define the order in which menu items appear
    List<string> menu = new List<string> { "test", "empty", "test2", "sometext", "sometext2" };
    st.SetShownText(menu);

    // Display the menu and handle user interaction
    while (true)
    {
        st.DisplayText(); // Handles user input and selection
    }
}

// Example callback functions
public static void myfunction()
{
    Console.Clear();
    Console.WriteLine("Test function");
    Console.ReadLine();
}

public static void myfunction2()
{
    Console.Clear();
    Console.WriteLine("Test function 2");
    Console.ReadLine();
}
Other Examples in showcase_proj/Program.cs:
  • SimpleMenu – demonstrates basic menu creation.
  • AdvancedMenu – shows multi-action items.
  • CallenderExample – integrates a calendar/date picker UI.

To run these examples, open the solution in Visual Studio and set showcase_proj as the startup project.

Installation

Clone and add the library project or its files to your solution:

git clone https://github.com/Eborm/SelectableText_lib.git

Add a project reference to SelectableText_lib_namespace.

Summary

  • AddText(string key, string displayText, Action handler) — Add selectable item.
  • AddText(string key, string displayText) — Add non-selectable item.
  • SetShownText(List<string> keys) — Specify menu order and which items to display.
  • DisplayText() — Shows menu, handles navigation and selection.

(See library source for advanced features, such as multiple actions per item.)

License

MIT


For more advanced usage and additional scenarios, review the full example in showcase_proj/Program.cs.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 91 5/20/2026