|
C-Menu 0.2.9
A User Interface Toolkit
|
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 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 image below shows a screenshot of the UAL API in action, with auto-completion and inline documentation provided by the Neovim editor. The UAL API is a powerful tool for developers who want to create terminal-based applications that are both fast and user-friendly, and it is an important part of the C-Menu toolkit.
lf is a high performance file finder that can be used to generate file lists for pick, shell pipelines, or custom scripts. lf is comparable to the popular find command, but it is designed to be more user-friendly and ridiculously fast.
To say that lf is fast is understated. It is easily ten times faster than find, and, even faster than fd. lf handles huge directories with ease. It can be used to find files based on name, type, date, size, and other attributes, making it a powerful tool for file discovery and filtering. It also has an option that only reports cyclic and broken links.
Above is a screenshot of an lf debugging log in view. Notice that it uses a "Coders Timestamp" instead of the usual ISO_8601 timestamp. The Coders Timestamp is a pair of 64-bit integers that represent the number of microseconds elapsed since the program was started as well as an interval timer to track time between log entries. It is used for high-resolution timing and logging in lf, and it provides a more precise measure of time than the standard ISO_8601 format. Most importantly, it contains meaningful information for developers who are debugging and profiling the performance of lf.
NOTE: Each thread has it's own interval timer, so the Coders Timestamp is not a global timer. It is a per-thread timer that is used to track the time between log entries for each thread. This allows developers to see how long each thread is taking to execute, and to identify any threads that are taking longer than expected. The Coders Timestamp is a valuable tool for debugging and profiling the performance of lf, and it can help developers optimize their code for maximum performance.
lf is already incredibly fast, but because a file finder is a core component of applications that deal with large numbers of files, it is reasonable that there will be developers who find ways to make it even faster. Hopefully they will make their improvements part of the lf project.
lf is designed to be modular and extensible, so that it can be easily integrated into larger workflows and applications. It is also designed to be user-friendly, with a simple and intuitive interface that makes it easy to use for both novice and experienced users. We know you will be impressed with its speed, and we hope you will be just as impressed with its ease of use and flexibility. lf is a powerful tool for file discovery and filtering, and it is an essential component of the C-Menu toolkit.
Report bugs to billx.nosp@m.wall.nosp@m.er@gm.nosp@m.ail..nosp@m.com.
| command | elapsed | CPU% | memory | pagefaults | files |
|---|---|---|---|---|---|
| find | 0.85 | 100 | 33288 | 11754 | 492537 |
| fd . -H -I | 0.13 | 1036 | 143096 | 5274 | 492536 |
| lf -H | 0.08 | 1068 | 10104 | 825 | 492536 |
Notice that lf is the fastest, and uses the least memory. It also has the fewest page faults. fd is faster than find, but uses more memory and has more page faults. find is the slowest, and uses the most memory and has the most page faults.
NOTE: find counts the root directory as a file, while fd and lf do not. This accounts for the one-file difference in the file counts. This is not necessarily an error. Just subtract 1 from the find count to get an accurate result.
Valgrind output for lf:
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.
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.
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.
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.
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.
C-Menu Doxygen | C-Menu CHANGELOG | C-Menu Installation | Example Applications Menu Guided Tour
Change to the source directory, C-Menu/src, and type:
The script should respond with a message similar to the following:
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.
The script should respond with a message similar to the following:
To build with CMake, remain in the source directory, C-Menu/src, and type:
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:
To build with GNU Makefile, remain in the source directory, C-Menu/src, and type:
C-Menu is built for users who want terminal applications that are:
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.
| 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 |
See BUILD for full build and install instructions.
A typical workflow with C-Menu looks like this:
Minimal example:
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.
C-Menu applications are usually built from plain text description files and command lines.
This makes C-Menu especially effective when you want to combine:
menu is the top-level dispatcher. It displays choices and runs the corresponding commands.
Example:
Use menu when you want:
form is used for entering, editing, validating, and processing structured data.
A form description file contains text lines and field definitions.
Text example:
Field example:
Common workflow:
This demonstrates a powerful pattern:
Use form when you need:
pick displays a list of items and lets the user select one or more of them.
General form:
Example:
You can also avoid helper scripts when a direct command is sufficient:
Use pick when you need:
view is a fast read-only viewer for files and command output.
It supports:
Example:
view is especially useful for:
lf is C-Menu’s regular expression file finder. The name can be read as either list files or lightweight find.
Example:
This makes it easy to generate file sets for:
Example integration with pick:
For performance notes and additional details, see PERFORMANCE.
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:
This can be useful in tightly controlled environments where short-lived privileged sessions are part of an established workflow.
Additional documentation is available in the docs directory:
Many C-Menu options can be set either:
Command-line options override configuration-file settings.
Examples:
Configuration can be used to control display behavior and tailor the interface to your workflow.
C-Menu is designed for Linux and terminal-based operation.
Typical requirements:
Optional integrations may depend on additional external tools such as:
Refer to INSTALLATION for the exact build and runtime details.
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:
Administrative tooling should be reviewed carefully before use in production or multi-user environments.
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:
That makes it a strong fit for:
If you are exploring C-Menu for the first time, a good path is:
If you contribute examples, documentation improvements, or fixes, keeping examples small and practical will help new users learn the system quickly.