C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
C-Menu

C-Menu is a fast, modular toolkit for building terminal-based user interfaces on Linux. Its components can be combined to create responsive menus, forms, pick lists, viewers, file-finding workflows, and administrative tools without the overhead of a heavyweight GUI stack.

Written in C and designed for speed, C-Menu works well for developer tools, system administration workflows, kiosk-style interfaces, and resource-constrained environments.

With C-Menu, you can leverage the raw speed and power of a terminal interface without the bloated dead weight of a full GUI framework. C-Menu is a toolkit that provides a framework for composing polished applications from small, focused components. Even previously unwieldy tools, such as awk, grep, sed, find, and shell scripts can be encapsulated in simple, menu-driven workflows that are easy to use and easy to maintain.

More sophisticated applications can be be built using the C-Menu API that is fully integrated with modern development environments like Vim and Neovim. As you type C-Menu API function names, the editor provides auto-completion and inline documentation, making it easy to learn and use. That's why C-Menu is an indispensable tool for skill levels ranging from shell script hobbyists to professional developers and system administrators.

The image below shows a screenshot of the C-Menu's UAL API in action, with auto-completion and inline documentation provided by the Neovim editor. The UAL API allows building with either NCurses or Notcurses. It is a powerful tool for developers who want to create terminal-based applications that are fast, user-friendly, and portable.

UAL API Screenshot

autotoc_md248

lf

Check out the lf file finder for more information on this powerful component of C-Menu.

Uniform Abstraction Layer User Interface

C-Menu has fully integrated the new Uniform Abstraction Layer (UAL) for UI Backends. Currently, NCurses and Notcurses are fully supported, and additional backends such as GTK and qt can be added in the future. The UAL allows C-Menu to provide a consistent interface across different terminal environments, while also enabling advanced features such as mouse support, color management, and improved performance. This makes C-Menu more versatile and adaptable to a wider range of use cases.

The core C-Menu components are visually and functionally identical across both NCurses and Notcurses backends, and the same code drives both backends through the UAL. This means that you can develop your application using the Notcurses backend, and then deploy it using the NCurses backend without any changes to your code. This is a powerful feature that allows you to take advantage of the advanced features of Notcurses during development, while still being able to deploy your application on systems that only support NCurses.

See UAL_UI Documentation for more information on the UAL and its features.


Uniform Abstraction Layer (UAL) API

The Uniform Abstraction Layer (UAL) API is a new feature in C-Menu that provides a consistent interface for terminal-based applications across different UI backends. The UAL allows developers to write applications that can run on multiple terminal environments without modification, while still taking advantage of advanced features such as mouse support, color management, and improved performance.

Currently, the UAL API supports two backends: NCurses and Notcurses. The NCurses backend provides a traditional terminal interface, while the Notcurses backend provides a more modern interface with advanced features such as true color support, high-performance rendering, and multimedia capabilities.

The UAL API is fully integrated with the C-Menu components, and developer tools such as Vim and Neovim provide auto-completion and inline documentation for the UAL functions. This makes it easy for developers to learn and use the UAL API, and to create terminal-based applications that are both powerful and user-friendly.

The following snippet is actually a complete program that opens a bordered window and displays some text. It shows just how easy it is to use the UAL_UI.

ui_hello.c

Below is a screenshot of the UAL view feature, which allows you to view not only text files, but multi-media files as well. We will be adding viewers for video and audio.

As you move the selector bar, you get a preview of the file. On the left, is the source code for lf, the C-Menu file finder. From the selector window, you can press F11 to move your focus to the text window. Then you can navigate with view, search the file, and even edit it with your favorite editor. On the right, view has detected an image file, and displays a preview. You can edit the image by pressing the spacebar.

UAL New View Feature - Photos

UAL View Feature - View Text Files in Pick

The program below displays the same image as Pick above in only 22 lines of code! That demonstrates how simple it is to use the UAL to create terminal-based applications with advanced features. The UAL provides a set of high-level functions that make it easy to create windows, menus, forms, and other UI elements, as well as handle input events and manage the terminal display.

NEW! Example Program Using UAL

Below is a screenshot of the UAL logging feature, which provides a detailed view of the internal workings of the UAL and can be used for debugging and performance analysis. The logging feature is available in both NCurses and Notcurses backends, and can be enabled or disabled at runtime.

NEW! UAL Logging

C-Menu Doxygen | C-Menu CHANGELOG | C-Menu Installation | Example Applications Menu Guided Tour


To Build C-Menu

Change to the source directory, C-Menu/src, and type:

./chkui

The script should respond with a message similar to the following:

menu linked with ncurses
CMake - NCURSES
Makefile - NCURSES

If these are the options you want, proceed with the build: To switch from NCURSES to NOTCURSES or vice versa, run the chkui script again with the "-s" option.

./chkui -s

The script should respond with a message similar to the following:

menu linked with ncurses
CMake - NCURSES
Makefile - NCURSES
CMake switching to NOTCURSES
Makefile switching to NOTCURSES

To build with CMake, remain in the source directory, C-Menu/src, and type:

./cmake.sh

This will create a build directory if it doesn't already exist. After the cmake.sh script finishes, change to the build directory and type:

make
make install

To build with GNU Makefile, remain in the source directory, C-Menu/src, and type:

make
make install

Troubleshooting

Cd to the C-Menu/src directory and type:

./chkinst

You should see a list of installed files similar to the following:

/home/bill/menuapp/lib64/libcm.so
/home/bill/menuapp/bin/view
/home/bill/menuapp/bin/menu
/home/bill/menuapp/bin/form
/home/bill/menuapp/bin/pick
/home/bill/menuapp/bin/whence
/home/bill/menuapp/bin/lf
/home/bill/menuapp/bin/stripansi

If the executables are not found, check your PATH environment variable and make sure it includes the directory where the C-Menu binaries were installed. You may also find that you have multiple copies of the executables installed, and the one that is being found first in your path is not the one you just built. You can check which executable is being found by typing:

which menu
which form
which pick
which view
which lf

Simply remove the unneeded copies of the executables from your path, or adjust your PATH environment variable to point to the correct directory.

One particularly pervasive problem is that programs like nvim and vim may be referenced by a symbolic link, /usr/bin/view. If that link occurs before the C-Menu binary directory in your PATH, then it will obscure the C-Menu executable from the shell. You can check for this by typing:

which view

If this command returns /usr/bin/view, then you have that problem. You can fix it by removing the /usr/bin/view link, or preferably, by adjusting your PATH environment variable to point to the C-Menu binary directory before /usr/bin.

A good solution to this kind of issue is to prepend your C-Menu binary path, normally ~/menuapp/bin, to your PATH environment variable. See C-Menu_bashrc.md for an example of how to do this in your .bashrc file.

Also confirm that libcm.so is in your library path as represented by /etc/ld.so.conf. Then, with root privileges, run the ldconfig command to update the shared library cache.

Modification

The user is free to modify the source code and build their own version of C-Menu. It is highly recommended that you use the CMake build system, as it is more flexible and easier to use than the GNU Makefile system. The CMake build system also provides better support for cross-compilation and building on different platforms.

Additionally, modification should be done in a separate branch or fork of the C-Menu source code, to avoid conflicts with the mainline development. This will also make it easier to merge changes from the mainline into your own version of C-Menu.

Valgrind and Helgrind are recommended for checking for memory leaks and threading issues. The C-Menu source code has been tested with Valgrind and Helgrind, and any issues found have been fixed. However, it is always a good idea to run these tools on your own modified version of C-Menu, to ensure that there are no new issues introduced.

Why C-Menu?

C-Menu is built for users who want terminal applications that are:

  • Fast - optimized C programs with a minimal footprint
  • Modular - combine small purpose-built components into larger workflows
  • Script-friendly - easy to integrate with shell scripts and external commands
  • Interactive - supports keyboard and mouse driven terminal interfaces
  • Practical - useful for both end-user tools and developer/admin utilities

Instead of treating menus, forms, selection lists, and viewers as separate one-off programs, C-Menu treats them as reusable building blocks that can be assembled into complete applications.

Components

Component Purpose Typical Use
menu Display menus and launch actions Application navigation, submenus, command dispatch
form Enter, edit, validate, and process structured data Data entry, calculations, query/update workflows
pick Select one or more items from a list File selection, multi-select actions, command dispatch
view Display text and command output efficiently Logs, reports, source code, highlighted output
lf Regular-expression-based file finder File discovery, filtering, pipelines
rsh Privileged shell helper Controlled administrative workflows
C-Keys Keyboard and mouse diagnostic utility Input testing and terminal diagnostics

Quick Start

See BUILD for full build and install instructions.

A typical workflow with C-Menu looks like this:

  1. Write a small menu description file
  2. Launch menu
  3. Dispatch actions to form, pick, view, shell commands, or other C-Menu components

Minimal example:

: APPLICATIONS
: Edit Current Project C Files
!pick -S "lf -d 5 '.*\.c$'" -T "Project Source" -c nvim %%
: Open Root Shell
!exec rsh

This example shows one of C-Menu’s core ideas: the menu itself is simple, and the power comes from composing components and external commands.

Core Concepts

C-Menu applications are usually built from plain text description files and command lines.

  • Menu description files define choices and the commands that run when a choice is selected.
  • Form description files define labels, input fields, and directives for processing.
  • Pick reads items from a file or command and lets the user select one or more of them.
  • View displays files or command output in a fast read-only interface.
  • lf can generate file lists that feed directly into pick, shell pipelines, or custom scripts.

This makes C-Menu especially effective when you want to combine:

  • shell commands
  • external utilities
  • custom scripts
  • terminal UI components
  • low-latency workflows

Examples

Menu

menu is the top-level dispatcher. It displays choices and runs the corresponding commands.

Example:

: APPLICATIONS
: Full Screen Shell
!exec rsh
: Workstation Configuration
!menu workstation_config.m
: Diagnostic Tools
!menu diag.m

Use menu when you want:

  • a text-based launcher
  • a hierarchy of submenus
  • a consistent front end for scripts and utilities
  • a terminal-native application shell

Form

form is used for entering, editing, validating, and processing structured data.

A form description file contains text lines and field definitions.

Text example:

T:5:14:Principal Amount

Field example:

F:5:33:14:Currency

Common workflow:

: Installment Loan Calculations
!form iloan.f -i iloan.dat -S iloan -R "view -S \"amort %%\"" -o iloan.dat

This demonstrates a powerful pattern:

  • load initial values
  • process them with an external executable
  • redisplay updated values
  • optionally hand off results to view

Use form when you need:

  • data entry
  • calculations
  • validation workflows
  • query/update cycles
  • integration with external programs

Pick

pick displays a list of items and lets the user select one or more of them.

General form:

!pick [ -n maximum_number_of_selections ][ -m ] \
[ -i input_file ][ -S executable_provider ] \
[ -o output_file ][ -c executable %% ]

Example:

: Rustlings Source
!pick -S rust_src -n 1 -T "Rustlings Source - Edit" -c nvim %%

You can also avoid helper scripts when a direct command is sufficient:

: Edit .c Files in Current Directory
!pick -S "lf -d 5 '.*\.c$'" -T "Project Tree - Select File to Edit" -c nvim %%

Use pick when you need:

  • interactive selection from generated lists
  • real-time filtering
  • single- or multi-select workflows
  • dispatching selected items to external commands

View

view is a fast read-only viewer for files and command output.

It supports:

  • Unicode
  • line numbering
  • regular-expression searching
  • horizontal scrolling with a large virtual pad
  • highlighted output from tools such as Tree-sitter, bat, pygments, and source-highlight

Example:

: View C-Menu Source with Tree-Sitter
!pick -S project_src -n 1 -T "Select Project Source to Highlight" -c "view -L 60 -C 85 -S \"tree-sitter highlight %%\""

view is especially useful for:

  • source browsing
  • log inspection
  • highlighted output
  • large text files
  • command output that should remain read-only

lf

lf is C-Menu’s regular expression file finder. The name can be read as either list files or lightweight find.

Example:

lf -d 5 -t f -a 2024-01-01 -b 2024-06-01 | xargs ls -l

This makes it easy to generate file sets for:

  • pick
  • shell pipelines
  • batch processing
  • date-based searches
  • source filtering

Example integration with pick:

!pick -S "lf -d 5 '.*\.c$'" -T "Project Tree - Select File to Edit" -c nvim %%

For performance notes and additional details, see PERFORMANCE.

rsh

rsh provides a root-shell-oriented administrative workflow intended as an alternative approach to repeatedly invoking su or sudo for certain tasks.

Example use case:

  • elevate for an administrative operation
  • run the required command
  • exit immediately when finished

This can be useful in tightly controlled environments where short-lived privileged sessions are part of an established workflow.

Documentation

Additional documentation is available in the docs directory:

Configuration

Many C-Menu options can be set either:

  • on the command line, or
  • in the configuration file ~/.minitrc

Command-line options override configuration-file settings.

Examples:

# .minitrc
fill_character=_
brackets=[]

Configuration can be used to control display behavior and tailor the interface to your workflow.

Platform and Requirements

C-Menu is designed for Linux and terminal-based operation.

Typical requirements:

  • Linux
  • a standard C library
  • a terminal with the capabilities needed for the desired interface features

Optional integrations may depend on additional external tools such as:

  • nvim
  • bat
  • Tree-sitter tools
  • source-highlight
  • pygments

Refer to INSTALLATION for the exact build and runtime details.

Security Notes

Some C-Menu components can be used in privileged or security-sensitive workflows, especially rsh.

Before using rsh or integrating C-Menu into elevated workflows, make sure you clearly define:

  • who is allowed to authenticate
  • how authentication is performed
  • what level of privilege is granted
  • what auditing or logging is required
  • whether the environment is appropriate for passwordless or key-based elevation

Administrative tooling should be reviewed carefully before use in production or multi-user environments.

Why the Design Works

C-Menu’s design is effective because it keeps the UI layer simple and composable.

Rather than forcing a single monolithic framework, it lets you connect:

  • plain text configuration
  • terminal-native interaction
  • Unix pipelines
  • external executables
  • lightweight focused tools

That makes it a strong fit for:

  • custom internal tools
  • developer utilities
  • interactive scripts
  • operations workflows
  • systems with limited resources

Contributing

If you are exploring C-Menu for the first time, a good path is:

  1. Read BUILD
  2. Read the USER GUIDE
  3. Try a small menu + pick workflow
  4. Expand into form, view, and lf integrations

If you contribute examples, documentation improvements, or fixes, keeping examples small and practical will help new users learn the system quickly.

See also

  • Build - build instructions and requirements
  • API - developer-facing API documentation
  • CHANGELOG - project history and notable changes
  • User Guide - end-user documentation
  • Augmentation - additional examples and supporting material
  • FAQ - frequently asked questions
  • Performance - benchmarks and performance notes
  • Menu - detailed documentation for the menu component
  • Form - detailed documentation for the form component
  • Pick - detailed documentation for the pick component
  • View - detailed documentation for the view component
  • Exercises - exercises to practice using C-Menu components
  • Valgrind - memory-checking notes and best practices
  • Roadmap - planned features and future directions'
  • Contributing - guidelines for contributing to the project