PitchHut logo
Isocline
A modern C library for enhanced line editing and terminal formatting.
Pitch

Isocline offers a powerful yet accessible drop-in alternative to GNU readline, designed for modern command-line applications. With features like multiline editing, customizable prompts, and advanced key binding profiles, it enhances user experience without added dependencies, making it an ideal choice for language REPLs and custom CLIs.

Description

Isocline: A Modern Line-Editing Library

Isocline is a pure C library designed for line editing and terminal formatting, tailored as a seamless drop-in alternative to GNU readline. This project is actively maintained by Caden Finley as part of CJ's Shell, ensuring a lightweight solution with no external dependencies while enhancing functionality for interactive applications such as REPLs and custom command-line interfaces.

Key Features

  • Multiline Editor Enhancements: Offers advanced features such as relative/absolute line numbers, customizable prompt-gutter replacements, and support for visible whitespace markers, improving the user experience for complex inputs.
  • Prompt Management: The prompt cleanup pipeline allows developers to manage prompts effectively by rewriting or clearing them post-input. This functionality is designed to make REPL transcripts cleaner and more manageable.
  • Abbreviations and Widgets: Supports Fish-style abbreviations that expand without disrupting the undo history, alongside utility functions for key-driven workflows to streamline the interaction process.
  • Enhanced Completion Features: A comprehensive completion API offers user-friendly enhancements including inline hints, spell correction, and the ability to manage completion sources dynamically.
  • Versatile Key Binding Support: Ships with both Emacs and Vi key profiles, providing users with familiar command line experiences and full control over key mappings.
  • Structured Output and Formatting: Implements a BBCode-inspired markup language for styled outputs and prompts, allowing for rich terminal interactions and visually organized information presentation.
  • Portability: Designed to ensure compatibility across various terminal environments, including smarter detection and improved support for Windows terminals.
  • Asynchronous Operation: Supports cooperative interruption and typeahead buffers to enable smooth integration into event-driven applications.

Quick Example

Integrating Isocline into a project is straightforward:

#include "isocline.h"

static void configure_editor(void) {
    ic_enable_multiline(true);
    ic_enable_line_numbers(true);
}

int main(void) {
    configure_editor();
    char* line = NULL;
    while ((line = ic_readline("cjsh> ", NULL, NULL)) != NULL) {
        if (strcmp(line, "exit") == 0) {
            free(line);
            break;
        }
        ic_println("[ic-info]You typed:[/]");
        ic_println(line);
        free(line);
    }
    return 0;
}

In this example, the configuration function sets up the editor with multiline support and line number display, enabling an interactive experience.

Documentation and Resources

Complete documentation is available in the docs directory, offering a thorough walkthrough of features, editing techniques, and completion authoring guidelines.

Isocline is continually evolving, with contributions welcome from the community to enhance its capabilities further. Interested developers can find more information and access the code at the Isocline GitHub Repository.

By leveraging Isocline, developers can create rich, user-friendly command-line applications that maximize the interactive capabilities and enhance overall usability.

0 comments

No comments yet.

Sign in to be the first to comment.