diff options
| author | _Tradam <[email protected]> | 2021-12-16 19:22:26 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-12-16 19:22:26 -0500 |
| commit | 5954b9beb4d4a3b4f248d72d1851195f030558a8 (patch) | |
| tree | fecd8aa840a25afdb502915b0fdb4d03b7ed339a /dragon/console_prompt.rb | |
| parent | 2f845281f133849256b57bb08fd3e9ae57600784 (diff) | |
| parent | eaa29e72939f5edf61735ccbb73c36ee89369f65 (diff) | |
| download | dragonruby-game-toolkit-contrib-5954b9beb4d4a3b4f248d72d1851195f030558a8.tar.gz dragonruby-game-toolkit-contrib-5954b9beb4d4a3b4f248d72d1851195f030558a8.zip | |
Diffstat (limited to 'dragon/console_prompt.rb')
| -rw-r--r-- | dragon/console_prompt.rb | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/dragon/console_prompt.rb b/dragon/console_prompt.rb index b97bdba..8c02de0 100644 --- a/dragon/console_prompt.rb +++ b/dragon/console_prompt.rb @@ -1,3 +1,4 @@ +# coding: utf-8 # Copyright 2019 DragonRuby LLC # MIT License # console_prompt.rb has been released under MIT (*only this file*). @@ -71,14 +72,14 @@ module GTK return if @cursor_position.zero? new_pos = @cursor_position - 1 - (is_word_boundary? @current_input_str[new_pos]) ? + (is_word_boundary? @current_input_str[new_pos]) ? (new_pos -= 1 until !(is_word_boundary? @current_input_str[new_pos - 1]) || new_pos.zero?): (new_pos -= 1 until (is_word_boundary? @current_input_str[new_pos - 1]) || new_pos.zero?) @cursor_position = new_pos update_cursor_position_px end - + def move_cursor_right @cursor_position += 1 if @cursor_position < current_input_str.length update_cursor_position_px @@ -91,7 +92,7 @@ module GTK (is_word_boundary? @current_input_str[new_pos]) ? (new_pos += 1 until !(is_word_boundary? @current_input_str[new_pos]) || (new_pos.equal? str_len)): (new_pos += 1 until (is_word_boundary? @current_input_str[new_pos]) || (new_pos.equal? str_len)) - + @cursor_position = new_pos update_cursor_position_px end @@ -157,11 +158,11 @@ S # partition the original list of items into a string to be printed items.each_slice(columns).each_with_index do |cells, i| - pretty_print_row_seperator string_width, cell_width, column_width, columns + pretty_print_row_separator string_width, cell_width, column_width, columns pretty_print_row cells, string_width, cell_width, column_width, columns end - pretty_print_row_seperator string_width, cell_width, column_width, columns + pretty_print_row_separator string_width, cell_width, column_width, columns end end @@ -174,17 +175,17 @@ S "#{" " * (string_width.length - c.length) } #{c} |" end.join - # remove seperators between empty values + # remove separators between empty values formated_row = formated_row.gsub(" | ", " ") puts formated_row end - def pretty_print_row_seperator string_width, cell_width, column_width, columns + def pretty_print_row_separator string_width, cell_width, column_width, columns # this is a joint: +-------- column_joint = "+#{"-" * cell_width}" - # multiple joints create a row seperator: +----+----+ + # multiple joints create a row separator: +----+----+ puts (column_joint * columns) + "+" end @@ -193,12 +194,12 @@ S args.outputs.reserved << (@cursor_color.to_h.merge x: x + @cursor_position_px + 0.5, y: y + 5, x2: x + @cursor_position_px + 0.5, - y2: y + @font_style.letter_size.y + 5) + y2: y + @font_style.letter_size.y + 4) args.outputs.reserved << (@cursor_color.to_h.merge x: x + @cursor_position_px + 1, y: y + 5, x2: x + @cursor_position_px + 1, - y2: y + @font_style.letter_size.y + 5) + y2: y + @font_style.letter_size.y + 4) # debugging rectangle for string # args.outputs.reserved << (@cursor_color.to_h.merge x: x, |
