dynamic_curses_input 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0dc424a4c850c6b23c7c3f3d03e742ac8df2358bf8e27b23f1687f420e5bca9e
4
- data.tar.gz: 5f7ac980e9cee53d31dd38952055069e68f86f1f5a0392739546e1f7d50ae7e8
3
+ metadata.gz: 9c428601614e3ac70ef3fcbf32e47f08c630e41fee379ac070042615d22247a2
4
+ data.tar.gz: 6cb43128ee6336bbf5f8b86aa870b9ac106c0a965f684c4e55c2f3cf3ee1679c
5
5
  SHA512:
6
- metadata.gz: f043944848d3e36e99e4a4430e9fd7bfea0e2ca045c1466d87e47fadb2ed9a24d32ef406cb8ef00073427b14ef5df3a86b458cd88560fbfb63020227682c998e
7
- data.tar.gz: 44a37ec7a25d1df68a325023fc2e7e5b7a563225fd4fae2835d5bd3499df3064181f8c22ea090d12f3d1d55f7e8543542a414abc521157db4a59ad2dcc1f882e
6
+ metadata.gz: 9cc2ecdbac0dd45a134b373e74f10dddfed6dd906cd61e53ea706886e47a2fe02323a4a8f95667e8a03863f5c1d74b3887cf95a346609db83880b659ca86769a
7
+ data.tar.gz: f6df58e040695ae079a1d231ccf85ce01b080e06644c398e31946f50b691c4e841bed51af4252392af855b173aba709ed49612b15b7c4a9716d14924d7c3fa0f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
- ## [Unreleased]
1
+ ## [Release]
2
2
 
3
- ## [0.1.0] - 2023-06-07
3
+ ## [1.0.0] - 2023-06-07
4
4
 
5
5
  - Initial release
6
+
7
+ ## [Release]
8
+
9
+ ## [1.1.0] - 2023-07-26
10
+
11
+ - Features and Enhancements:
12
+
13
+ - Added support for printing colored windows with customized positions and color schemes.
14
+ - Introduced the DynamicCursesInput::ColorWindow class, which allows creating colored text windows within the terminal.
15
+ - The ColorWindow class provides methods to add colored text to the window and handle user input.
16
+ - Implemented automatic centering of text within the window when x is set to 'center'.
17
+ - Adjusted the centered position to shift back by 12 cells for better visual layout when necessary.
18
+ - Removed reliance on Fibers and replaced it with instance methods to resolve issues with positioning.
19
+ - Handled compatibility issues with different terminal environments to ensure consistent behavior.
20
+ - Refactored the code to eliminate unnecessary checks for IRB, enabling smooth execution in various contexts.
21
+ - Improved the debug log functionality for easier debugging and troubleshooting.
22
+
23
+ - Bug Fixes:
24
+
25
+ - Fixed the issue causing text to be misaligned or misplaced in certain terminal environments.
26
+ - Resolved a bug where the window position was not being updated correctly in some cases.
27
+
28
+ - Other Changes:
29
+
30
+ - Removed redundant and unused code snippets to improve code cleanliness and maintainability.
data/Gemfile CHANGED
@@ -1,12 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in dynamic_curses_input.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake"
8
+ gem 'rake'
9
9
 
10
- gem "rubocop"
10
+ gem 'rubocop'
11
11
 
12
- gem "curses"
12
+ gem 'curses'
13
+
14
+ gem 'reline'
data/Gemfile.lock CHANGED
@@ -1,44 +1,38 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dynamic_curses_input (1.0.0)
4
+ dynamic_curses_input (1.0.1.1)
5
5
  curses
6
+ reline
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
10
11
  ast (2.4.2)
11
12
  curses (1.4.4)
12
- diff-lcs (1.5.0)
13
+ io-console (0.6.0)
13
14
  json (2.6.3)
15
+ language_server-protocol (3.17.0.3)
14
16
  parallel (1.23.0)
15
- parser (3.2.2.1)
17
+ parser (3.2.2.3)
16
18
  ast (~> 2.4.1)
19
+ racc
20
+ racc (1.7.1)
17
21
  rainbow (3.1.1)
18
22
  rake (13.0.6)
19
- regexp_parser (2.8.0)
23
+ regexp_parser (2.8.1)
24
+ reline (0.3.6)
25
+ io-console (~> 0.5)
20
26
  rexml (3.2.5)
21
- rspec (3.12.0)
22
- rspec-core (~> 3.12.0)
23
- rspec-expectations (~> 3.12.0)
24
- rspec-mocks (~> 3.12.0)
25
- rspec-core (3.12.2)
26
- rspec-support (~> 3.12.0)
27
- rspec-expectations (3.12.3)
28
- diff-lcs (>= 1.2.0, < 2.0)
29
- rspec-support (~> 3.12.0)
30
- rspec-mocks (3.12.5)
31
- diff-lcs (>= 1.2.0, < 2.0)
32
- rspec-support (~> 3.12.0)
33
- rspec-support (3.12.0)
34
- rubocop (1.52.0)
27
+ rubocop (1.55.0)
35
28
  json (~> 2.3)
29
+ language_server-protocol (>= 3.17.0)
36
30
  parallel (~> 1.10)
37
- parser (>= 3.2.0.0)
31
+ parser (>= 3.2.2.3)
38
32
  rainbow (>= 2.2.2, < 4.0)
39
33
  regexp_parser (>= 1.8, < 3.0)
40
34
  rexml (>= 3.2.5, < 4.0)
41
- rubocop-ast (>= 1.28.0, < 2.0)
35
+ rubocop-ast (>= 1.28.1, < 2.0)
42
36
  ruby-progressbar (~> 1.7)
43
37
  unicode-display_width (>= 2.4.0, < 3.0)
44
38
  rubocop-ast (1.29.0)
@@ -53,8 +47,8 @@ DEPENDENCIES
53
47
  curses
54
48
  dynamic_curses_input!
55
49
  rake
56
- rspec
50
+ reline
57
51
  rubocop
58
52
 
59
53
  BUNDLED WITH
60
- 2.4.13
54
+ 2.4.16
data/README.md CHANGED
@@ -1,39 +1,91 @@
1
1
  # DynamicCursesInput
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ 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.
4
4
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/dynamic_curses_input`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+ ## Table of Contents
6
+
7
+ - [Installation](#installation)
8
+ - [Usage](#usage)
9
+ - [Documentation](#documentation)
10
+ - [Dependencies](#dependencies)
11
+ - [FAQs](#faqs)
12
+ - [Troubleshooting](#troubleshooting)
13
+ - [Contribution Guidelines](#contribution-guidelines)
14
+ - [License](#license)
6
15
 
7
16
  ## Installation
8
17
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
18
+ To install DynamicCursesInput, add the following line to your application's Gemfile:
19
+
20
+ ```ruby
21
+ gem 'dynamic_curses_input'
22
+ ```
10
23
 
11
- Install the gem and add to the application's Gemfile by executing:
24
+ Then execute:
12
25
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
26
+ ```bash
27
+ $ bundle install
28
+ ```
14
29
 
15
- If bundler is not being used to manage dependencies, install the gem by executing:
30
+ Or install it yourself as:
16
31
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
32
+ ```bash
33
+ $ gem install dynamic_curses_input
34
+ ```
18
35
 
19
36
  ## Usage
20
37
 
21
- TODO: Write usage instructions here
38
+ Here's a simple example of how to use DynamicCursesInput:
39
+
40
+ ```ruby
41
+ require "curses"
42
+ require "dynamic_curses_input"
43
+
44
+ begin
45
+ Curses.init_screen
46
+ Curses.start_color
47
+ 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")
48
+ Curses.addstr("Enter your name: ")
49
+ name = DCI.catch_input(true)
50
+ Curses.addstr("\nYou entered: #{name}")
51
+ Curses.getch
52
+
53
+ # Log the output
54
+ logger.info("Name entered: #{name}")
55
+ ensure
56
+ Curses.close_screen
57
+ end
58
+ ```
59
+
60
+ In this example, `DCI.catch_input(true)` will capture user input until the Enter key is pressed, echoing the input to the screen.
22
61
 
23
- ## Development
62
+ ## Documentation
24
63
 
25
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
64
+ Detailed documentation for each function is available in the [wiki](https://github.com/Pixelated-Studios/dynamic_curses_input/wiki).
26
65
 
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
66
+ ## Dependencies
28
67
 
29
- ## Contributing
68
+ DynamicCursesInput depends on the [Curses](https://github.com/ruby/curses) gem.
30
69
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dynamic_curses_input. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/dynamic_curses_input/blob/master/CODE_OF_CONDUCT.md).
70
+ ## FAQs
71
+
72
+ - **Q: How do I handle special keys like arrow keys?**
73
+ - A: Special keys like arrow keys are automatically handled by DynamicCursesInput.
74
+
75
+ ## Troubleshooting
76
+
77
+ If you encounter any issues while using DynamicCursesInput, please check the [issues](https://github.com/yourusername/dynamic_curses_input/issues) page. If your issue isn't listed, feel free to open a new issue.
78
+
79
+ ## Contribution Guidelines
80
+
81
+ We welcome contributions from the community! Please read our [contribution guidelines](CONTRIBUTING.md) before submitting a pull request.
32
82
 
33
83
  ## License
34
84
 
35
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
85
+ DynamicCursesInput is available under the [MIT License](LICENSE.txt).
86
+
87
+ ---
36
88
 
37
- ## Code of Conduct
89
+ ### Note from the Developer:
38
90
 
39
- Everyone interacting in the DynamicCursesInput project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/dynamic_curses_input/blob/master/CODE_OF_CONDUCT.md).
91
+ 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.
data/buildgem.sh ADDED
@@ -0,0 +1,22 @@
1
+ #/bin/bash
2
+ echo "rebuilding dynamic_curses_input..."
3
+ sleep 1
4
+ echo "Uninstalling existing version..."
5
+ sleep 1
6
+ gem uninstall dynamic_curses_input
7
+ sleep 1
8
+ echo "Cleaning up old files..."
9
+ sleep 1
10
+ gem cleanup dynamic_curses_input
11
+ sleep 1
12
+ echo "Building DCI..."
13
+ sleep 1
14
+ gem build dynamic_curses_input.gemspec
15
+ echo "built!"
16
+ sleep 1
17
+ echo "Installing new version of DCI..."
18
+ sleep 1
19
+ gem install dynamic_curses_input-1.0.1.1.gem
20
+ echo "Installed!"
21
+ echo "press any key to exit..."
22
+ read -p ""
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "lib/dynamic_curses_input/version"
3
+ require_relative 'lib/dynamic_curses_input/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "dynamic_curses_input"
6
+ spec.name = 'dynamic_curses_input'
7
7
  spec.version = DynamicCursesInput::VERSION
8
- spec.authors = ["VetheonGames"]
9
- spec.email = ["vetheon@pixelatedstudios.net"]
8
+ spec.authors = ['VetheonGames']
9
+ spec.email = ['vetheon@pixelatedstudios.net']
10
10
 
11
- spec.summary = "A simple library for making Curses TUI input more dynamic and user-friendly"
11
+ spec.summary = 'A simple library for making Curses TUI input more dynamic and user-friendly'
12
12
  spec.description = "Dynamic Curses Input is a highly simple, yet powerful gem that allows simple implementation of
13
13
  dynamic typing in curses TUI menus built in Ruby. For example, one can't simply use their arrow
14
14
  keys to navigate and edit inputs in Cursese TUI menus without adding a bunch of extra code to your
@@ -17,23 +17,23 @@ Gem::Specification.new do |spec|
17
17
  allowing the special keys to work as the average user would expect.
18
18
  IE: When you press the left arrow key, the cursor moves to the left and allows you to delete a
19
19
  character you entered that isn't the last character you entered."
20
- spec.homepage = "https://github.com/Pixelated-Studios/dynamic_curses_input"
21
- spec.license = "MIT"
22
- spec.required_ruby_version = "3.2.2"
20
+ spec.homepage = 'https://github.com/Pixelated-Studios/dynamic_curses_input'
21
+ spec.license = 'MIT'
22
+ spec.required_ruby_version = '3.2.2'
23
23
 
24
- spec.metadata["homepage_uri"] = spec.homepage
25
- spec.metadata["source_code_uri"] = "https://github.com/Pixelated-Studios/dynamic_curses_input"
26
- spec.metadata["changelog_uri"] = "https://github.com/Pixelated-Studios/dynamic_curses_input/blob/main/CHANGELOG.md"
24
+ spec.metadata['homepage_uri'] = spec.homepage
25
+ spec.metadata['source_code_uri'] = 'https://github.com/Pixelated-Studios/dynamic_curses_input'
26
+ spec.metadata['changelog_uri'] = 'https://github.com/Pixelated-Studios/dynamic_curses_input/blob/main/CHANGELOG.md'
27
27
 
28
28
  # Specify which files should be added to the gem when it is released.
29
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
30
- spec.files = Dir.chdir(__dir__) do
31
- `git ls-files -z`.split("\x0").reject do |f|
32
- f.start_with?("spec", ".rspec") || (File.expand_path(f) == __FILE__)
33
- end
34
- end
35
- spec.require_paths = ["lib"]
29
+ spec.files = Dir.glob('{bin,lib,sig}/**/*') + Dir.glob('*').reject { |f| f.start_with?('spec', '.rspec', 'dynamic_curses_input.gemspec') }
30
+ spec.files << 'LICENSE.txt'
31
+ spec.files << 'README.md'
32
+ spec.files << 'dynamic_curses_input.gemspec'
36
33
 
37
- spec.add_dependency "curses"
38
- spec.add_development_dependency "rubocop"
34
+ spec.require_paths = ['lib']
35
+
36
+ spec.add_dependency 'curses'
37
+ spec.add_dependency 'reline'
38
+ spec.add_development_dependency 'rubocop'
39
39
  end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ # lib/dynamic_curses_input/color_window.rb
4
+
5
+ require 'curses'
6
+ require_relative 'input_handler'
7
+
8
+ module DynamicCursesInput
9
+ # Class for creating a colored window
10
+ class ColorWindow
11
+ # Initialize instance variables and setup curses
12
+ def initialize(echo, x, y)
13
+ @echo = echo # Determines whether input should be echoed to the screen
14
+ setup_curses_color # Setup curses
15
+ @x = x
16
+ @y = y
17
+ # Define color pairs
18
+ Curses.init_pair(1, Curses::COLOR_BLACK, Curses::COLOR_BLACK)
19
+ Curses.init_pair(2, Curses::COLOR_BLUE, Curses::COLOR_BLACK)
20
+ Curses.init_pair(3, Curses::COLOR_GREEN, Curses::COLOR_BLACK)
21
+ Curses.init_pair(4, Curses::COLOR_CYAN, Curses::COLOR_BLACK)
22
+ Curses.init_pair(5, Curses::COLOR_RED, Curses::COLOR_BLACK)
23
+ Curses.init_pair(6, Curses::COLOR_MAGENTA, Curses::COLOR_BLACK)
24
+ Curses.init_pair(7, Curses::COLOR_YELLOW, Curses::COLOR_BLACK) # Brown is usually represented as yellow
25
+ Curses.init_pair(8, Curses::COLOR_WHITE, Curses::COLOR_BLACK)
26
+ end
27
+
28
+ # Method that adds colored text to the window
29
+ def add_color_window(color, text, x, y, input: nil, echo: true)
30
+ # Map color names to color pair numbers
31
+ color_map = {
32
+ 'black' => 1,
33
+ 'blue' => 2,
34
+ 'green' => 3,
35
+ 'cyan' => 4,
36
+ 'red' => 5,
37
+ 'magenta' => 6,
38
+ 'brown' => 7, # Brown is usually represented as yellow in terminal colors
39
+ 'white' => 8
40
+ }
41
+
42
+ # Get the color pair number for the specified color
43
+ color_pair = color_map[color.downcase]
44
+
45
+ # Set the cursor position if both x and y are specified
46
+ if x && y
47
+ set_position(y, x)
48
+ elsif x.nil? && y.nil?
49
+ # If both x and y are not specified, raise an ArgumentError
50
+ raise ArgumentError, 'Both x and y coordinates must be specified for printing the color window.'
51
+ end
52
+
53
+ # Print the text in the specified color
54
+ Curses.attron(Curses.color_pair(color_pair))
55
+ Curses.addstr(text)
56
+ Curses.attroff(Curses.color_pair(color_pair))
57
+
58
+ # If an input is specified, take input from the user
59
+ InputHandler.catch_input(echo) if input
60
+
61
+ Curses.refresh
62
+ end
63
+
64
+ private
65
+
66
+ # Setup curses
67
+ def setup_curses_color
68
+ Curses.init_screen
69
+ Curses.start_color
70
+ end
71
+
72
+ # Set cursor position manually on the X and Y axis
73
+ def set_position(y, x)
74
+ Curses.setpos(y, x)
75
+ end
76
+ end
77
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # lib/dynamic_curses_input/input_handler.rb
4
4
 
5
- require "curses"
5
+ require 'curses'
6
6
 
7
7
  module DynamicCursesInput
8
8
  # our main class for handling input
@@ -15,7 +15,7 @@ module DynamicCursesInput
15
15
  # Initialize instance variables and setup curses
16
16
  def initialize(echo)
17
17
  @echo = echo # Determines whether input should be echoed to the screen
18
- @input = "" # Stores the input string
18
+ @input = '' # Stores the input string
19
19
  @cursor_pos = 0 # Stores the current cursor position
20
20
  @initial_y = Curses.stdscr.cury # Stores the initial y-coordinate of the cursor
21
21
  @initial_x = Curses.stdscr.curx # Stores the initial x-coordinate of the cursor
@@ -84,7 +84,7 @@ module DynamicCursesInput
84
84
  # Redraw the input string
85
85
  def redraw_input
86
86
  Curses.setpos(@initial_y, @initial_x) # Move cursor to initial position
87
- Curses.addstr(" " * (Curses.cols - @initial_x)) # Clear line
87
+ Curses.addstr(' ' * (Curses.cols - @initial_x)) # Clear line
88
88
  Curses.setpos(@initial_y, @initial_x) # Move cursor to initial position
89
89
  Curses.addstr(@input) if @echo # Draw input string if @echo is true
90
90
  Curses.setpos(@initial_y, @initial_x + @cursor_pos) # Move cursor to current position
@@ -102,6 +102,11 @@ module DynamicCursesInput
102
102
  def self.right(cursor_pos, length)
103
103
  cursor_pos == length ? cursor_pos : cursor_pos + 1
104
104
  end
105
+
106
+ # Set cursor position
107
+ def self.set_position(y, x)
108
+ Curses.setpos(y, x)
109
+ end
105
110
  end
106
111
 
107
112
  # Class for deleting characters
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DynamicCursesInput
4
- VERSION = "1.0.0"
4
+ VERSION = '1.1.0'
5
5
  end
@@ -2,8 +2,10 @@
2
2
 
3
3
  # lib/dynamic_curses_input.rb
4
4
 
5
- require_relative "dynamic_curses_input/version"
6
- require_relative "dynamic_curses_input/input_handler"
5
+ require 'readline' # Add the Readline module
6
+ require_relative 'dynamic_curses_input/version'
7
+ require_relative 'dynamic_curses_input/input_handler'
8
+ require_relative 'dynamic_curses_input/color_window'
7
9
 
8
10
  # The module entrypoint for our Gem
9
11
  module DynamicCursesInput
@@ -13,12 +15,74 @@ module DynamicCursesInput
13
15
  InputHandler.catch_input(echo)
14
16
  end
15
17
 
16
- def self.ask_question(question, echo)
18
+ def self.ask_question(color = 'white', question, x: 'center', input: true, echo: nil)
17
19
  Curses.clear
18
- Curses.setpos(1, 0)
19
- Curses.addstr(question)
20
+ ColorWindow.add_color_window(color, question, y:, x:, input:, echo:)
21
+ end
22
+
23
+ def self.print_color_window(color, text, y_value: nil, x: 'center', input: nil, echo: true)
24
+ case x
25
+ when 'center'
26
+ terminal_size = `stty size`.split.map(&:to_i)
27
+ y_value = terminal_size[0] / 2
28
+ x_value = terminal_size[1] / 2 - text.length / 2 # Adjust x-coordinate to center the window
29
+ x_value -= 12 if x_value > 1
30
+ # the above line shifts the X value of the cell coords back by 12 cells if we are trying to center the window
31
+ # we have to do this because math gets kind of approximate when we convert pixel ratios to character cell coords
32
+ when 'left'
33
+ y_value = Curses.lines / 2
34
+ x_value = 0
35
+ when 'right'
36
+ y_value = Curses.lines / 2
37
+ x_value = Curses.cols - text.length
38
+ when 'left_center'
39
+ y_value = Curses.lines / 4
40
+ x_value = 0
41
+ when 'right_center'
42
+ y_value = Curses.lines / 4
43
+ x_value = Curses.cols - text.length
44
+ else
45
+ y_value, x_value = x.split('px').map(&:to_i)
46
+ end
47
+
48
+ # Initialize curses and get the terminal size
49
+ Curses.init_screen
50
+ Curses.start_color
20
51
  Curses.refresh
21
- catch_input(echo)
52
+
53
+ # Set up Readline for proper terminal settings
54
+ setup_readline
55
+
56
+ ColorWindow.new(echo, x_value, y_value).add_color_window(color, text, x_value, y_value, input:, echo:)
57
+ end
58
+
59
+ class << self
60
+ private
61
+
62
+ def process_print_color_window_args(args)
63
+ case args.size
64
+ when 2
65
+ ['white', args[0], args[1], 'center', nil, true]
66
+ when 3
67
+ ['white', args[0], args[1], args[2], nil, true]
68
+ when 4
69
+ ['white', args[0], args[1], args[2], args[3], true]
70
+ when 5
71
+ [args[0], args[1], args[2], args[3], args[4]]
72
+ else
73
+ raise ArgumentError, 'print_color_window accepts 2 to 5 arguments: color, text, [position], [input], [echo]'
74
+ end
75
+ end
76
+ end
77
+
78
+ def self.setup_readline
79
+ # Set up Readline for proper terminal settings
80
+ Readline.emacs_editing_mode
81
+ # the above line sets Readline to emacs_editing_mode so that terminals behave like they're supposed to
82
+ Readline.completion_append_character = ' '
83
+ # we remove Readlines thing where it adds a space to the end of tab completes because it breaks the Curses cursor
84
+ Readline.completion_proc = proc { |_s| [] }
85
+ # here we basically are disabling tab completion all together. That's because for some reason it breaks the cursor
22
86
  end
23
87
  end
24
88
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_curses_input
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - VetheonGames
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-08 00:00:00.000000000 Z
11
+ date: 2023-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: reline
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rubocop
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -53,9 +67,6 @@ executables: []
53
67
  extensions: []
54
68
  extra_rdoc_files: []
55
69
  files:
56
- - ".github/workflows/main.yml"
57
- - ".gitignore"
58
- - ".rubocop.yml"
59
70
  - CHANGELOG.md
60
71
  - CODE_OF_CONDUCT.md
61
72
  - Gemfile
@@ -65,8 +76,10 @@ files:
65
76
  - Rakefile
66
77
  - bin/console
67
78
  - bin/setup
79
+ - buildgem.sh
68
80
  - dynamic_curses_input.gemspec
69
81
  - lib/dynamic_curses_input.rb
82
+ - lib/dynamic_curses_input/color_window.rb
70
83
  - lib/dynamic_curses_input/input_handler.rb
71
84
  - lib/dynamic_curses_input/version.rb
72
85
  - sig/dynamic_curses_input.rbs
@@ -92,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
105
  - !ruby/object:Gem::Version
93
106
  version: '0'
94
107
  requirements: []
95
- rubygems_version: 3.4.13
108
+ rubygems_version: 3.4.16
96
109
  signing_key:
97
110
  specification_version: 4
98
111
  summary: A simple library for making Curses TUI input more dynamic and user-friendly
@@ -1,27 +0,0 @@
1
- name: Ruby
2
-
3
- on:
4
- push:
5
- branches:
6
- - master
7
-
8
- pull_request:
9
-
10
- jobs:
11
- build:
12
- runs-on: ubuntu-latest
13
- name: Ruby ${{ matrix.ruby }}
14
- strategy:
15
- matrix:
16
- ruby:
17
- - '3.2.2'
18
-
19
- steps:
20
- - uses: actions/checkout@v3
21
- - name: Set up Ruby
22
- uses: ruby/setup-ruby@v1
23
- with:
24
- ruby-version: ${{ matrix.ruby }}
25
- bundler-cache: true
26
- - name: Run the default task
27
- run: bundle exec rake
data/.gitignore DELETED
@@ -1,11 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
data/.rubocop.yml DELETED
@@ -1,13 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 3.2.2
3
-
4
- Style/StringLiterals:
5
- Enabled: true
6
- EnforcedStyle: double_quotes
7
-
8
- Style/StringLiteralsInInterpolation:
9
- Enabled: true
10
- EnforcedStyle: double_quotes
11
-
12
- Layout/LineLength:
13
- Max: 120