A simple Ruby Gem to make input in Curses TUI's more User Friendly
Go to file
VetheonGames a27f41a601 feat: Introduce colored text windows and enhanced positioning
This commit introduces a significant enhancement to the DynamicCursesInput gem, enabling the creation of colored text windows within the terminal. The new `DynamicCursesInput::ColorWindow` class provides methods to add colored text to the window and handle user input.

Notable changes in this commit include:
- Implementation of colored windows with customizable color schemes and text content.
- Automatic centering of text within the window when 'x' is set to 'center.'
- Fine-tuning of centered positioning to shift back by 12 cells for improved visual layout.
- Removal of Fiber reliance and adoption of instance methods to resolve positioning issues.
- Compatibility fixes for different terminal environments to ensure consistent behavior.

Additionally, bug fixes have been made to resolve issues related to text misalignment and window positioning.

This feature-rich update aims to improve the user experience and offer better control over window positioning and color schemes. We hope these enhancements will be beneficial to our users. Feedback and suggestions are always welcome!
2023-07-26 16:31:20 -06:00
.github/workflows initial commit 2023-06-07 15:56:30 -06:00
bin initial commit 2023-06-07 15:56:30 -06:00
lib feat: Introduce colored text windows and enhanced positioning 2023-07-26 16:31:20 -06:00
sig initial commit 2023-06-07 15:56:30 -06:00
.gitignore feat: Introduce colored text windows and enhanced positioning 2023-07-26 16:31:20 -06:00
.rubocop.yml Refactor InputHandler, Add Enter Key Handling, Improve Input Redraw, Add Comments, Remove RSpec Tests, and Manual Testing 2023-06-08 11:05:38 -06:00
CHANGELOG.md feat: Introduce colored text windows and enhanced positioning 2023-07-26 16:31:20 -06:00
CODE_OF_CONDUCT.md initial commit 2023-06-07 15:56:30 -06:00
dynamic_curses_input.gemspec feat: Introduce colored text windows and enhanced positioning 2023-07-26 16:31:20 -06:00
Gemfile feat: Introduce colored text windows and enhanced positioning 2023-07-26 16:31:20 -06:00
Gemfile.lock feat: Introduce colored text windows and enhanced positioning 2023-07-26 16:31:20 -06:00
LICENSE.txt initial commit 2023-06-07 15:56:30 -06:00
Rakefile initial commit 2023-06-07 15:56:30 -06:00
README.md Update README.md 2023-06-08 12:02:05 -06:00

DynamicCursesInput

DynamicCursesInput is a Ruby gem that provides a simple and intuitive way to handle user input in a Curses-based terminal user interface (TUI). It allows for dynamic input handling, including cursor movement and inline character addition and deletion.

Table of Contents

Installation

To install DynamicCursesInput, add the following line to your application's Gemfile:

gem 'dynamic_curses_input'

Then execute:

$ bundle install

Or install it yourself as:

$ gem install dynamic_curses_input

Usage

Here's a simple example of how to use DynamicCursesInput:

require "curses"
require "dynamic_curses_input"

begin
  Curses.init_screen
  Curses.start_color
  Curses.addstr("You should be able to use the left and right arrow keys to switch between characters in the line, and selectively edit them.\n")
  Curses.addstr("Enter your name: ")
  name = DCI.catch_input(true)
  Curses.addstr("\nYou entered: #{name}")
  Curses.getch

  # Log the output
  logger.info("Name entered: #{name}")
ensure
  Curses.close_screen
end

In this example, DCI.catch_input(true) will capture user input until the Enter key is pressed, echoing the input to the screen.

Documentation

Detailed documentation for each function is available in the wiki.

Dependencies

DynamicCursesInput depends on the Curses gem.

FAQs

  • Q: How do I handle special keys like arrow keys?
    • A: Special keys like arrow keys are automatically handled by DynamicCursesInput.

Troubleshooting

If you encounter any issues while using DynamicCursesInput, please check the issues page. If your issue isn't listed, feel free to open a new issue.

Contribution Guidelines

We welcome contributions from the community! Please read our contribution guidelines before submitting a pull request.

License

DynamicCursesInput is available under the MIT License.


Note from the Developer:

There is a function in this gem that is not finished yet, it's for making asking questions in a Curses TUI easier from within the gem. This method shouldn't be used yet.