grmenu 4.0.2 → 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/data/help.txt +1 -1
  4. data/grmenu.rb +57 -61
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c028e16af097dddc8e61b7cc766cc6a7f1870616e3c5169c832fe6edcf79fb55
4
- data.tar.gz: 1c0070cb22cebd71fa4b235c0cea7bd51c1af58c7b662fbe5bd2d9976709e774
3
+ metadata.gz: 2204001c5ee3dc5f6a037e839683035a655d73d98d74c667906f268ba84d0d07
4
+ data.tar.gz: cc4d101354a88160890e4ebdb36073b5dd73cfb2ca5447aee609d6386aecb3d8
5
5
  SHA512:
6
- metadata.gz: ba425e3a5e0a2d4692f9bc79e249a8303a245e0aeca137bd343fee489020d6b3f1b4c37147751ca4d5c05ab119b97848f6f7470803984550c69b93c0ae77a8cc
7
- data.tar.gz: 90959c3c3c4ae76ec8bca759faea2ecdb801ee8fbc977bfae15618ad3af603202c95b2192e0296193cee5a933a0aa93e2ac559db84e0a967380c3e4737839c50
6
+ metadata.gz: 9c91666f2d8e9c9bb6094e50eca470029223425e0bf58e10adc83bfdc5d28062bb664f2a2569b78cf33a3cfb569c9873800cce7b1ec54c64c8ee383a310c6eb5
7
+ data.tar.gz: 9da6c6d0543fc48c2f01cfdd4f64f6916698c433381504006cef981ab0b7974f785bff0c777b5e2ccc8092315658de5eaf45f42d340aed20c99abd9f9ab04f5c
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # GRmenu (Ruby) v4.0.2
1
+ # GRmenu (Ruby) v4.0.3
2
2
 
3
3
  **Suite TUI Profesional y Ligera para la Creación de Interfaces de Línea de Comandos en Terminales TTY.**
4
4
 
@@ -95,7 +95,7 @@ require 'grmenu'
95
95
  GRmenu.theme(:neon_red)
96
96
 
97
97
  def saludar
98
- GRmenu.alert(:success, "Bienvenido a GRmenu v4.0.2!")
98
+ GRmenu.alert(:success, "Bienvenido a GRmenu v4.0.3!")
99
99
  end
100
100
 
101
101
  def ver_tabla
data/data/help.txt CHANGED
@@ -8,7 +8,7 @@
8
8
  {bright_cyan}╚═══════════════════════════════════════════════════════════════════════════════════╝{reset}
9
9
 
10
10
  {bright_cyan}╔═══════════════════════════════════════════════════════════════════════════════════╗{reset}
11
- {bright_cyan}║{bright_yellow} DOCUMENTACION Y GUIA COMPLETA DE PARAMETROS (v4.0.2) {bright_cyan}║{reset}
11
+ {bright_cyan}║{bright_yellow} DOCUMENTACION Y GUIA COMPLETA DE PARAMETROS (v4.0.3) {bright_cyan}║{reset}
12
12
  {bright_cyan}║{gray} Soporte Raton SGR 1006, Submenus en Cascada 3 Niveles, Pestanas y CSS .gr {bright_cyan}║{reset}
13
13
  {bright_cyan}╚═══════════════════════════════════════════════════════════════════════════════════╝{reset}
14
14
 
data/grmenu.rb CHANGED
@@ -6,7 +6,7 @@ require 'zlib'
6
6
  require 'open3'
7
7
 
8
8
  class GRmenu
9
- VERSION = "4.0.2"
9
+ VERSION = "4.0.3"
10
10
  CLEAR_SCREEN_SEQUENCE = "\e[H\e[2J\e[3J"
11
11
  HIDE_CURSOR = "\e[?25l"
12
12
  SHOW_CURSOR = "\e[?25h"
@@ -2771,8 +2771,7 @@ class GRmenu
2771
2771
  brightness_level = parts[1].to_i if parts[1] && !parts[1].empty?
2772
2772
  end
2773
2773
 
2774
- is_neon_color = color_name.start_with?("neon")
2775
- is_anim_active = is_neon_color || (@animate && ["diagonal", "linear", "fade", "rgb", "rainbow", "chroma", "neon"].include?(@animate.to_s.downcase))
2774
+ is_anim_active = @animate && ["neon", "fade"].include?(@animate.to_s.downcase)
2776
2775
  is_chroma = color_name == "rgb" || color_name == "rainbow" || color_name == "chroma" || @animate.to_s.downcase == "rgb"
2777
2776
 
2778
2777
  if is_chroma
@@ -2822,53 +2821,13 @@ class GRmenu
2822
2821
  BASE_RGB[color_name] || [255, 255, 255]
2823
2822
  end
2824
2823
 
2825
- if @animate.to_s.downcase == "fade"
2826
- factor = (Math.sin(tick + phase_offset) + 1.0) / 2.0
2827
- f = 0.35 + 0.65 * factor
2828
- r = (base[0] * f).clamp(0, 255).to_i
2829
- g = (base[1] * f).clamp(0, 255).to_i
2830
- b = (base[2] * f).clamp(0, 255).to_i
2831
- glow = (factor > 0.85) ? ";1" : ""
2832
- return "\e[38;2;#{r};#{g};#{b}#{glow}m#{text}#{self.class.ansi_reset}"
2833
- else
2834
- out = String.new("")
2835
- char_count = 0
2836
- in_escape = false
2837
- escape_buf = String.new("")
2838
-
2839
- text.to_s.each_char do |ch|
2840
- if ch == "\e"
2841
- in_escape = true
2842
- escape_buf << ch
2843
- next
2844
- end
2845
- if in_escape
2846
- escape_buf << ch
2847
- if ch =~ /[a-zA-Z]/
2848
- in_escape = false
2849
- out << escape_buf
2850
- escape_buf.clear
2851
- end
2852
- next
2853
- end
2854
-
2855
- if ch == " " || ch == "\t" || ch == "\r" || ch == "\n"
2856
- out << ch
2857
- else
2858
- phase = char_count * 0.22 + phase_offset
2859
- factor = (Math.sin(tick + phase) + 1.0) / 2.0
2860
- f = 0.35 + 0.65 * factor
2861
- r = (base[0] * f).clamp(0, 255).to_i
2862
- g = (base[1] * f).clamp(0, 255).to_i
2863
- b = (base[2] * f).clamp(0, 255).to_i
2864
- glow = (factor > 0.85) ? ";1" : ""
2865
- out << "\e[38;2;#{r};#{g};#{b}#{glow}m#{ch}"
2866
- char_count += 1
2867
- end
2868
- end
2869
- out << self.class.ansi_reset
2870
- return out
2871
- end
2824
+ factor = (Math.sin(tick + phase_offset) + 1.0) / 2.0
2825
+ f = 0.35 + 0.65 * factor
2826
+ r = (base[0] * f).clamp(0, 255).to_i
2827
+ g = (base[1] * f).clamp(0, 255).to_i
2828
+ b = (base[2] * f).clamp(0, 255).to_i
2829
+ glow = (factor > 0.85) ? ";1" : ""
2830
+ return "\e[38;2;#{r};#{g};#{b}#{glow}m#{text}#{self.class.ansi_reset}"
2872
2831
  end
2873
2832
 
2874
2833
  color_code = self.class.ansi_color(color_name, brightness_level)
@@ -3091,7 +3050,8 @@ class GRmenu
3091
3050
  if @banner && !@banner.empty?
3092
3051
  banner_lines, banner_box_w = render_banner_lines(term_cols)
3093
3052
  unless banner_lines.empty?
3094
- rendered_lines.concat(banner_lines)
3053
+ b_pad = (@center && term_cols > banner_box_w) ? " " * ((term_cols - banner_box_w) / 2) : ""
3054
+ rendered_lines.concat(banner_lines.map { |l| "#{b_pad}#{l}" })
3095
3055
  rendered_lines << ""
3096
3056
  header_lines_count += banner_lines.length + 1
3097
3057
  header_box_width = [header_box_width, banner_box_w].max
@@ -3113,28 +3073,63 @@ class GRmenu
3113
3073
  calculated_width = ([calculated_width, GRmenu.display_width(@query) + 16].max) if @search
3114
3074
  total_width = [calculated_width, term_cols - 2].min
3115
3075
 
3116
- reference_width = header_box_width > 0 ? header_box_width : total_width
3117
- margin_left = (@center && reference_width > total_width) ? " " * ((reference_width - total_width) / 2) : ""
3076
+ sub_1_preview_w = 0
3077
+ sub_2_preview_w = 0
3078
+ if @open_level >= 1 && is_submenu_item?(@functions[@index])
3079
+ s1_acts = get_submenu_actions(@functions[@index])
3080
+ if s1_acts && !s1_acts.empty?
3081
+ s1_names = s1_acts.map { |a| extract_name_from_action(a) }
3082
+ s1_max = s1_names.empty? ? 10 : s1_names.map { |n| GRmenu.display_width(n) }.max
3083
+ s1_title = all_names[@index] || ""
3084
+ sub_1_preview_w = [s1_max + 8, GRmenu.display_width(s1_title) + 6, 20].max
3085
+ sub_1_preview_w = [sub_1_preview_w, 36].min
3086
+
3087
+ if @open_level >= 2 && is_submenu_item?(s1_acts[@sub_index_1])
3088
+ s2_acts = get_submenu_actions(s1_acts[@sub_index_1])
3089
+ if s2_acts && !s2_acts.empty?
3090
+ s2_names = s2_acts.map { |a| extract_name_from_action(a) }
3091
+ s2_max = s2_names.empty? ? 10 : s2_names.map { |n| GRmenu.display_width(n) }.max
3092
+ s2_title = extract_name_from_action(s1_acts[@sub_index_1]) || ""
3093
+ sub_2_preview_w = [s2_max + 8, GRmenu.display_width(s2_title) + 6, 20].max
3094
+ sub_2_preview_w = [sub_2_preview_w, 36].min
3095
+ end
3096
+ end
3097
+ end
3098
+ end
3099
+
3100
+ total_chain_w = total_width
3101
+ total_chain_w += 2 + sub_1_preview_w if sub_1_preview_w > 0
3102
+ total_chain_w += 2 + sub_2_preview_w if sub_2_preview_w > 0
3103
+
3104
+ margin_left = if @center && term_cols > total_chain_w
3105
+ " " * ((term_cols - total_chain_w) / 2)
3106
+ elsif @center && term_cols > total_width
3107
+ " " * ((term_cols - total_width) / 2)
3108
+ else
3109
+ ""
3110
+ end
3118
3111
 
3119
3112
  subtitle_lines_count = 0
3120
3113
  if @subtitle && !@subtitle.empty?
3121
3114
  subtitle_lines = @subtitle.lines.map(&:chomp)
3122
- div_w = @divider.is_a?(Numeric) ? @divider.to_i : [reference_width, term_cols - 2].min
3115
+ ref_sub_w = header_box_width > 0 ? header_box_width : total_chain_w
3116
+ div_w = @divider.is_a?(Numeric) ? @divider.to_i : [ref_sub_w, term_cols - 2].min
3117
+ sub_pad = (@center && term_cols > div_w) ? " " * ((term_cols - div_w) / 2) : ""
3123
3118
 
3124
3119
  if @divider
3125
- rendered_lines << colorize("─" * div_w, @style_config.divider, 0.0)
3120
+ rendered_lines << "#{sub_pad}#{colorize("─" * div_w, @style_config.divider, 0.0)}"
3126
3121
  subtitle_lines_count += 1
3127
3122
  end
3128
3123
 
3129
3124
  subtitle_lines.each_with_index do |sub_line, s_i|
3130
3125
  pad_sub = [div_w - GRmenu.display_width(sub_line), 0].max
3131
3126
  formatted_sub = @center ? (" " * (pad_sub / 2) + sub_line + " " * (pad_sub - (pad_sub / 2))) : sub_line
3132
- rendered_lines << colorize(formatted_sub, @style_config.subtitle, s_i * 0.3)
3127
+ rendered_lines << "#{sub_pad}#{colorize(formatted_sub, @style_config.subtitle, s_i * 0.3)}"
3133
3128
  subtitle_lines_count += 1
3134
3129
  end
3135
3130
 
3136
3131
  if @divider
3137
- rendered_lines << colorize("─" * div_w, @style_config.divider, 0.6)
3132
+ rendered_lines << "#{sub_pad}#{colorize("─" * div_w, @style_config.divider, 0.6)}"
3138
3133
  subtitle_lines_count += 1
3139
3134
  end
3140
3135
  rendered_lines << ""
@@ -3227,6 +3222,7 @@ class GRmenu
3227
3222
  v_left = colorize(v_l_raw, border_color_cfg, 0.2)
3228
3223
  v_right = colorize(v_r_raw, border_color_cfg, 0.8)
3229
3224
 
3225
+ main_box_start = rendered_lines.length
3230
3226
  top_border_line = box_border[:tl] + top_fill + box_border[:tr]
3231
3227
  rendered_lines << "#{margin_left}#{colorize(top_border_line, border_color_cfg, 0.0)}"
3232
3228
 
@@ -3449,9 +3445,9 @@ class GRmenu
3449
3445
  if sub_2_lines
3450
3446
  total_3_w = margin_left.length + total_width + 2 + sub_1_w + 2 + sub_2_w
3451
3447
  if total_3_w <= term_cols
3452
- sub_1_start = [[parent_row_idx - 1, 0].max, [rendered_lines.length - sub_1_lines.length, 0].max].min
3448
+ sub_1_start = main_box_start
3453
3449
  p1_abs_row = sub_1_start + (p_row_1 || 1)
3454
- sub_2_start = [[p1_abs_row - 1, 0].max, [rendered_lines.length - sub_2_lines.length, 0].max].min
3450
+ sub_2_start = main_box_start
3455
3451
  max_3_lines = [rendered_lines.length, sub_1_start + sub_1_lines.length, sub_2_start + sub_2_lines.length].max
3456
3452
 
3457
3453
  x1_start = margin_left.length + total_width + 2
@@ -3498,7 +3494,7 @@ class GRmenu
3498
3494
  rendered_lines = stitched_lines
3499
3495
  elsif (sub_1_w + 2 + sub_2_w) <= term_cols
3500
3496
  p1_abs_row = (p_row_1 || 1)
3501
- sub_2_start = [[p1_abs_row - 1, 0].max, [sub_1_lines.length - sub_2_lines.length, 0].max].min
3497
+ sub_2_start = main_box_start
3502
3498
  max_2_lines = [sub_1_lines.length, sub_2_start + sub_2_lines.length].max
3503
3499
 
3504
3500
  x1_start = margin_left.length
@@ -3538,7 +3534,7 @@ class GRmenu
3538
3534
  else
3539
3535
  total_2_w = margin_left.length + total_width + 2 + sub_1_w
3540
3536
  if total_2_w <= term_cols
3541
- sub_start_line = [[parent_row_idx - 1, 0].max, [rendered_lines.length - sub_1_lines.length, 0].max].min
3537
+ sub_start_line = main_box_start
3542
3538
  max_total_lines = [rendered_lines.length, sub_start_line + sub_1_lines.length].max
3543
3539
 
3544
3540
  x1_start = margin_left.length + total_width + 2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grmenu
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.2
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - grcode