grmenu 4.0.3 → 4.1.0

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 +3 -3
  3. data/data/help.txt +1 -1
  4. data/grmenu.rb +207 -67
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2204001c5ee3dc5f6a037e839683035a655d73d98d74c667906f268ba84d0d07
4
- data.tar.gz: cc4d101354a88160890e4ebdb36073b5dd73cfb2ca5447aee609d6386aecb3d8
3
+ metadata.gz: 4cfab6080b581db0dddff8e9285cb831f70f259bb9da2965761702829c07292f
4
+ data.tar.gz: 172214b97293124225a3f6eef3f9b71842d3e49a7159e3cc27bacc407ec6db66
5
5
  SHA512:
6
- metadata.gz: 9c91666f2d8e9c9bb6094e50eca470029223425e0bf58e10adc83bfdc5d28062bb664f2a2569b78cf33a3cfb569c9873800cce7b1ec54c64c8ee383a310c6eb5
7
- data.tar.gz: 9da6c6d0543fc48c2f01cfdd4f64f6916698c433381504006cef981ab0b7974f785bff0c777b5e2ccc8092315658de5eaf45f42d340aed20c99abd9f9ab04f5c
6
+ metadata.gz: 2437295ff5176fc4ace40768e03e7cd25ecbfa0e1562ef625e348eac1f69c7e91c60b2cedf3d48c0f4a9285272978e8b0ae3ec8c1a81e3dbf2c47296b4ef7d0d
7
+ data.tar.gz: 021bf58afb13dce516963e7bb16b0fe5830498c2e88ab961a6dca0c4f7d5dc13e54fde83cf89b2b5a89a632f9a63a107539a462b82b65ec60f64e78f92eefee8
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # GRmenu (Ruby) v4.0.3
1
+ # GRmenu (Ruby) v4.1.0
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
 
@@ -73,7 +73,7 @@ gem install grmenu
73
73
  ### Vía Gemfile
74
74
 
75
75
  ```ruby
76
- gem 'grmenu', '~> 4.0'
76
+ gem 'grmenu', '~> 4.1'
77
77
  ```
78
78
 
79
79
  ### Requerimiento en scripts de Ruby
@@ -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.3!")
98
+ GRmenu.alert(:success, "Bienvenido a GRmenu v4.1.0!")
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.3) {bright_cyan}║{reset}
11
+ {bright_cyan}║{bright_yellow} DOCUMENTACION Y GUIA COMPLETA DE PARAMETROS (v4.1.0) {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.3"
9
+ VERSION = "4.1.0"
10
10
  CLEAR_SCREEN_SEQUENCE = "\e[H\e[2J\e[3J"
11
11
  HIDE_CURSOR = "\e[?25l"
12
12
  SHOW_CURSOR = "\e[?25h"
@@ -1531,10 +1531,24 @@ class GRmenu
1531
1531
  @divider = divider.dup
1532
1532
  @font = font.to_i
1533
1533
  @desc_prefix = desc_prefix.to_s
1534
+ @explicitly_set = {}
1534
1535
  end
1535
1536
 
1536
- def desc_prefix(prefix_str = nil)
1537
+ def explicitly_set?(key)
1538
+ @explicitly_set ||= {}
1539
+ @explicitly_set[key.to_sym] == true || self.class.explicitly_set?(key)
1540
+ end
1541
+
1542
+ def mark_explicit(key)
1543
+ @explicitly_set ||= {}
1544
+ @explicitly_set[key.to_sym] = true
1545
+ end
1546
+
1547
+ def desc_prefix(prefix_str = nil, from_css: false)
1537
1548
  return @desc_prefix if prefix_str.nil?
1549
+ return self if from_css && explicitly_set?(:desc_prefix)
1550
+ @explicitly_set ||= {}
1551
+ @explicitly_set[:desc_prefix] = true unless from_css
1538
1552
  @desc_prefix = prefix_str.to_s
1539
1553
  self
1540
1554
  end
@@ -1542,8 +1556,11 @@ class GRmenu
1542
1556
  alias_method :desc_prefix=, :desc_prefix
1543
1557
  alias_method :description_prefix=, :desc_prefix
1544
1558
 
1545
- def border(color_name = nil, brightness_level = 1)
1559
+ def border(color_name = nil, brightness_level = 1, from_css: false)
1546
1560
  return @border if color_name.nil?
1561
+ return self if from_css && explicitly_set?(:border)
1562
+ @explicitly_set ||= {}
1563
+ @explicitly_set[:border] = true unless from_css
1547
1564
  @border = parse_color(color_name, brightness_level)
1548
1565
  self
1549
1566
  end
@@ -1551,8 +1568,11 @@ class GRmenu
1551
1568
  alias_method :set_border, :border
1552
1569
  alias_method :border=, :border
1553
1570
 
1554
- def options(color_name = nil, brightness_level = 1)
1571
+ def options(color_name = nil, brightness_level = 1, from_css: false)
1555
1572
  return @options if color_name.nil?
1573
+ return self if from_css && explicitly_set?(:options)
1574
+ @explicitly_set ||= {}
1575
+ @explicitly_set[:options] = true unless from_css
1556
1576
  @options = parse_color(color_name, brightness_level)
1557
1577
  self
1558
1578
  end
@@ -1560,8 +1580,11 @@ class GRmenu
1560
1580
  alias_method :set_options, :options
1561
1581
  alias_method :options=, :options
1562
1582
 
1563
- def focus(color_name = nil, brightness_level = 2)
1583
+ def focus(color_name = nil, brightness_level = 2, from_css: false)
1564
1584
  return @focus if color_name.nil?
1585
+ return self if from_css && explicitly_set?(:focus)
1586
+ @explicitly_set ||= {}
1587
+ @explicitly_set[:focus] = true unless from_css
1565
1588
  @focus = parse_color(color_name, brightness_level)
1566
1589
  self
1567
1590
  end
@@ -1569,8 +1592,11 @@ class GRmenu
1569
1592
  alias_method :set_focus, :focus
1570
1593
  alias_method :focus=, :focus
1571
1594
 
1572
- def title(color_name = nil, brightness_level = 2)
1595
+ def title(color_name = nil, brightness_level = 2, from_css: false)
1573
1596
  return @title if color_name.nil?
1597
+ return self if from_css && explicitly_set?(:title)
1598
+ @explicitly_set ||= {}
1599
+ @explicitly_set[:title] = true unless from_css
1574
1600
  @title = parse_color(color_name, brightness_level)
1575
1601
  self
1576
1602
  end
@@ -1578,8 +1604,11 @@ class GRmenu
1578
1604
  alias_method :set_title, :title
1579
1605
  alias_method :title=, :title
1580
1606
 
1581
- def banner(color_name = nil, brightness_level = 2)
1607
+ def banner(color_name = nil, brightness_level = 2, from_css: false)
1582
1608
  return @banner if color_name.nil?
1609
+ return self if from_css && explicitly_set?(:banner)
1610
+ @explicitly_set ||= {}
1611
+ @explicitly_set[:banner] = true unless from_css
1583
1612
  @banner = parse_color(color_name, brightness_level)
1584
1613
  self
1585
1614
  end
@@ -1587,8 +1616,11 @@ class GRmenu
1587
1616
  alias_method :set_banner, :banner
1588
1617
  alias_method :banner=, :banner
1589
1618
 
1590
- def subtitle(color_name = nil, brightness_level = 2)
1619
+ def subtitle(color_name = nil, brightness_level = 2, from_css: false)
1591
1620
  return @subtitle if color_name.nil?
1621
+ return self if from_css && explicitly_set?(:subtitle)
1622
+ @explicitly_set ||= {}
1623
+ @explicitly_set[:subtitle] = true unless from_css
1592
1624
  @subtitle = parse_color(color_name, brightness_level)
1593
1625
  self
1594
1626
  end
@@ -1596,8 +1628,11 @@ class GRmenu
1596
1628
  alias_method :set_subtitle, :subtitle
1597
1629
  alias_method :subtitle=, :subtitle
1598
1630
 
1599
- def divider(color_name = nil, brightness_level = 1)
1631
+ def divider(color_name = nil, brightness_level = 1, from_css: false)
1600
1632
  return @divider if color_name.nil?
1633
+ return self if from_css && explicitly_set?(:divider)
1634
+ @explicitly_set ||= {}
1635
+ @explicitly_set[:divider] = true unless from_css
1601
1636
  @divider = parse_color(color_name, brightness_level)
1602
1637
  self
1603
1638
  end
@@ -1605,8 +1640,11 @@ class GRmenu
1605
1640
  alias_method :set_divider, :divider
1606
1641
  alias_method :divider=, :divider
1607
1642
 
1608
- def font(font_id = nil)
1643
+ def font(font_id = nil, from_css: false)
1609
1644
  return @font if font_id.nil?
1645
+ return self if from_css && explicitly_set?(:font)
1646
+ @explicitly_set ||= {}
1647
+ @explicitly_set[:font] = true unless from_css
1610
1648
  @font = font_id.to_i
1611
1649
  self
1612
1650
  end
@@ -1625,74 +1663,111 @@ class GRmenu
1625
1663
  end
1626
1664
 
1627
1665
  class << self
1628
- def border(color_name = nil, brightness_level = 1)
1666
+ def explicitly_set?(key)
1667
+ @explicitly_set ||= {}
1668
+ @explicitly_set[key.to_sym] == true
1669
+ end
1670
+
1671
+ def mark_explicit(key)
1672
+ @explicitly_set ||= {}
1673
+ @explicitly_set[key.to_sym] = true
1674
+ end
1675
+
1676
+ def border(color_name = nil, brightness_level = 1, from_css: false)
1629
1677
  @default_border ||= { color: "cyan", level: 1 }
1630
1678
  return @default_border if color_name.nil?
1679
+ return @default_border if from_css && explicitly_set?(:border)
1680
+ @explicitly_set ||= {}
1681
+ @explicitly_set[:border] = true unless from_css
1631
1682
  @default_border = { color: color_name.to_s, level: brightness_level.to_i }
1632
1683
  end
1633
1684
  alias_method :Border, :border
1634
1685
  alias_method :border=, :border
1635
1686
 
1636
- def options(color_name = nil, brightness_level = 1)
1687
+ def options(color_name = nil, brightness_level = 1, from_css: false)
1637
1688
  @default_options ||= { color: "white", level: 1 }
1638
1689
  return @default_options if color_name.nil?
1690
+ return @default_options if from_css && explicitly_set?(:options)
1691
+ @explicitly_set ||= {}
1692
+ @explicitly_set[:options] = true unless from_css
1639
1693
  @default_options = { color: color_name.to_s, level: brightness_level.to_i }
1640
1694
  end
1641
1695
  alias_method :Options, :options
1642
1696
  alias_method :options=, :options
1643
1697
 
1644
- def focus(color_name = nil, brightness_level = 2)
1698
+ def focus(color_name = nil, brightness_level = 2, from_css: false)
1645
1699
  @default_focus ||= { color: "green", level: 2 }
1646
1700
  return @default_focus if color_name.nil?
1701
+ return @default_focus if from_css && explicitly_set?(:focus)
1702
+ @explicitly_set ||= {}
1703
+ @explicitly_set[:focus] = true unless from_css
1647
1704
  @default_focus = { color: color_name.to_s, level: brightness_level.to_i }
1648
1705
  end
1649
1706
  alias_method :Focus, :focus
1650
1707
  alias_method :focus=, :focus
1651
1708
 
1652
- def title(color_name = nil, brightness_level = 2)
1709
+ def title(color_name = nil, brightness_level = 2, from_css: false)
1653
1710
  @default_title ||= { color: "yellow", level: 2 }
1654
1711
  return @default_title if color_name.nil?
1712
+ return @default_title if from_css && explicitly_set?(:title)
1713
+ @explicitly_set ||= {}
1714
+ @explicitly_set[:title] = true unless from_css
1655
1715
  @default_title = { color: color_name.to_s, level: brightness_level.to_i }
1656
1716
  end
1657
1717
  alias_method :Title, :title
1658
1718
  alias_method :title=, :title
1659
1719
 
1660
- def banner(color_name = nil, brightness_level = 2)
1720
+ def banner(color_name = nil, brightness_level = 2, from_css: false)
1661
1721
  @default_banner ||= { color: "magenta", level: 2 }
1662
1722
  return @default_banner if color_name.nil?
1723
+ return @default_banner if from_css && explicitly_set?(:banner)
1724
+ @explicitly_set ||= {}
1725
+ @explicitly_set[:banner] = true unless from_css
1663
1726
  @default_banner = { color: color_name.to_s, level: brightness_level.to_i }
1664
1727
  end
1665
1728
  alias_method :Banner, :banner
1666
1729
  alias_method :banner=, :banner
1667
1730
 
1668
- def subtitle(color_name = nil, brightness_level = 2)
1731
+ def subtitle(color_name = nil, brightness_level = 2, from_css: false)
1669
1732
  @default_subtitle ||= { color: "cyan", level: 2 }
1670
1733
  return @default_subtitle if color_name.nil?
1734
+ return @default_subtitle if from_css && explicitly_set?(:subtitle)
1735
+ @explicitly_set ||= {}
1736
+ @explicitly_set[:subtitle] = true unless from_css
1671
1737
  @default_subtitle = { color: color_name.to_s, level: brightness_level.to_i }
1672
1738
  end
1673
1739
  alias_method :Subtitle, :subtitle
1674
1740
  alias_method :subtitle=, :subtitle
1675
1741
 
1676
- def divider(color_name = nil, brightness_level = 1)
1742
+ def divider(color_name = nil, brightness_level = 1, from_css: false)
1677
1743
  @default_divider ||= { color: "blue", level: 1 }
1678
1744
  return @default_divider if color_name.nil?
1745
+ return @default_divider if from_css && explicitly_set?(:divider)
1746
+ @explicitly_set ||= {}
1747
+ @explicitly_set[:divider] = true unless from_css
1679
1748
  @default_divider = { color: color_name.to_s, level: brightness_level.to_i }
1680
1749
  end
1681
1750
  alias_method :Divider, :divider
1682
1751
  alias_method :divider=, :divider
1683
1752
 
1684
- def font(font_id = nil)
1753
+ def font(font_id = nil, from_css: false)
1685
1754
  @default_font ||= 1
1686
1755
  return @default_font if font_id.nil?
1756
+ return @default_font if from_css && explicitly_set?(:font)
1757
+ @explicitly_set ||= {}
1758
+ @explicitly_set[:font] = true unless from_css
1687
1759
  @default_font = font_id.to_i
1688
1760
  end
1689
1761
  alias_method :Font, :font
1690
1762
  alias_method :set_font, :font
1691
1763
  alias_method :font=, :font
1692
1764
 
1693
- def desc_prefix(prefix_str = nil)
1765
+ def desc_prefix(prefix_str = nil, from_css: false)
1694
1766
  @default_desc_prefix ||= "[i]"
1695
1767
  return @default_desc_prefix if prefix_str.nil?
1768
+ return @default_desc_prefix if from_css && explicitly_set?(:desc_prefix)
1769
+ @explicitly_set ||= {}
1770
+ @explicitly_set[:desc_prefix] = true unless from_css
1696
1771
  @default_desc_prefix = prefix_str.to_s
1697
1772
  end
1698
1773
  alias_method :description_prefix, :desc_prefix
@@ -1709,7 +1784,7 @@ class GRmenu
1709
1784
  end
1710
1785
  end
1711
1786
 
1712
- attr_accessor :functions, :title, :subtitle, :banner, :banner_style, :divider, :style, :index, :style_config, :center, :page_size, :search, :columns, :query, :image, :image_width
1787
+ attr_accessor :functions, :title, :subtitle, :banner, :banner_style, :divider, :index, :style_config, :center, :page_size, :search, :columns, :query, :image, :image_width
1713
1788
 
1714
1789
  alias_method :options, :functions
1715
1790
  alias_method :options=, :functions=
@@ -1720,6 +1795,19 @@ class GRmenu
1720
1795
  alias_method :description, :subtitle
1721
1796
  alias_method :description=, :subtitle=
1722
1797
 
1798
+ def desc_prefix
1799
+ @desc_prefix || @style_config&.desc_prefix || SetStyle.desc_prefix
1800
+ end
1801
+
1802
+ def desc_prefix=(val)
1803
+ @desc_prefix = val.to_s
1804
+ @style_config&.desc_prefix(val)
1805
+ end
1806
+ alias_method :prefix, :desc_prefix
1807
+ alias_method :prefix=, :desc_prefix=
1808
+ alias_method :description_prefix, :desc_prefix
1809
+ alias_method :description_prefix=, :desc_prefix=
1810
+
1723
1811
  def self.STYLES; STYLES; end
1724
1812
  def self.COLORS; COLORS; end
1725
1813
  def self.BORDERS; BORDERS; end
@@ -1831,38 +1919,40 @@ class GRmenu
1831
1919
  m = (sec["menu"] || {}).merge(glob)
1832
1920
 
1833
1921
  if m && !m.empty?
1834
- if m["border"] || m["border_color"]
1922
+ if (m["border"] || m["border_color"]) && !SetStyle.explicitly_set?(:border)
1835
1923
  c, l = extract_color_and_level(m["border"] || m["border_color"], 1)
1836
- SetStyle.border(c, l)
1924
+ SetStyle.border(c, l, from_css: true)
1837
1925
  end
1838
- if m["title"] || m["title_color"]
1926
+ if (m["title"] || m["title_color"]) && !SetStyle.explicitly_set?(:title)
1839
1927
  c, l = extract_color_and_level(m["title"] || m["title_color"], 2)
1840
- SetStyle.title(c, l)
1928
+ SetStyle.title(c, l, from_css: true)
1841
1929
  end
1842
- if m["focus"] || m["focus_color"]
1930
+ if (m["focus"] || m["focus_color"]) && !SetStyle.explicitly_set?(:focus)
1843
1931
  c, l = extract_color_and_level(m["focus"] || m["focus_color"], 2)
1844
- SetStyle.focus(c, l)
1932
+ SetStyle.focus(c, l, from_css: true)
1845
1933
  end
1846
- if m["options"] || m["options_color"]
1934
+ if (m["options"] || m["options_color"]) && !SetStyle.explicitly_set?(:options)
1847
1935
  c, l = extract_color_and_level(m["options"] || m["options_color"], 1)
1848
- SetStyle.options(c, l)
1936
+ SetStyle.options(c, l, from_css: true)
1849
1937
  end
1850
- if m["banner"] || m["banner_color"]
1938
+ if (m["banner"] || m["banner_color"]) && !SetStyle.explicitly_set?(:banner)
1851
1939
  c, l = extract_color_and_level(m["banner"] || m["banner_color"], 2)
1852
- SetStyle.banner(c, l)
1940
+ SetStyle.banner(c, l, from_css: true)
1853
1941
  end
1854
- if m["subtitle"] || m["subtitle_color"]
1942
+ if (m["subtitle"] || m["subtitle_color"]) && !SetStyle.explicitly_set?(:subtitle)
1855
1943
  c, l = extract_color_and_level(m["subtitle"] || m["subtitle_color"], 1)
1856
- SetStyle.subtitle(c, l)
1944
+ SetStyle.subtitle(c, l, from_css: true)
1857
1945
  end
1858
- if m["divider"] || m["divider_color"]
1946
+ if (m["divider"] || m["divider_color"]) && !SetStyle.explicitly_set?(:divider)
1859
1947
  c, l = extract_color_and_level(m["divider"] || m["divider_color"], 1)
1860
- SetStyle.divider(c, l)
1948
+ SetStyle.divider(c, l, from_css: true)
1861
1949
  end
1862
- if m["desc_prefix"] || m["description_prefix"] || m["prefix"]
1863
- SetStyle.desc_prefix(m["desc_prefix"] || m["description_prefix"] || m["prefix"])
1950
+ if (m["desc_prefix"] || m["description_prefix"] || m["prefix"]) && !SetStyle.explicitly_set?(:desc_prefix)
1951
+ SetStyle.desc_prefix(m["desc_prefix"] || m["description_prefix"] || m["prefix"], from_css: true)
1952
+ end
1953
+ if m["font"] && !SetStyle.explicitly_set?(:font)
1954
+ SetStyle.font(m["font"].to_i, from_css: true)
1864
1955
  end
1865
- SetStyle.font(m["font"].to_i) if m["font"]
1866
1956
  end
1867
1957
 
1868
1958
  sec.each do |k, v|
@@ -1871,22 +1961,22 @@ class GRmenu
1871
1961
  c, l = extract_color_and_level(c_val, (v["level"] || 1).to_i)
1872
1962
  case k
1873
1963
  when "border"
1874
- SetStyle.border(c, l)
1964
+ SetStyle.border(c, l, from_css: true) unless SetStyle.explicitly_set?(:border)
1875
1965
  when "options"
1876
- SetStyle.options(c, l)
1966
+ SetStyle.options(c, l, from_css: true) unless SetStyle.explicitly_set?(:options)
1877
1967
  when "focus"
1878
- SetStyle.focus(c, l)
1968
+ SetStyle.focus(c, l, from_css: true) unless SetStyle.explicitly_set?(:focus)
1879
1969
  when "title"
1880
- SetStyle.title(c, l)
1970
+ SetStyle.title(c, l, from_css: true) unless SetStyle.explicitly_set?(:title)
1881
1971
  when "banner"
1882
- SetStyle.banner(c, l)
1972
+ SetStyle.banner(c, l, from_css: true) unless SetStyle.explicitly_set?(:banner)
1883
1973
  when "subtitle"
1884
- SetStyle.subtitle(c, l)
1974
+ SetStyle.subtitle(c, l, from_css: true) unless SetStyle.explicitly_set?(:subtitle)
1885
1975
  when "divider"
1886
- SetStyle.divider(c, l)
1976
+ SetStyle.divider(c, l, from_css: true) unless SetStyle.explicitly_set?(:divider)
1887
1977
  end
1888
1978
  end
1889
- SetStyle.font(glob["font"].to_i) if glob["font"]
1979
+ SetStyle.font(glob["font"].to_i, from_css: true) if glob["font"] && !SetStyle.explicitly_set?(:font)
1890
1980
  end
1891
1981
 
1892
1982
  def self.style(css_content)
@@ -2586,7 +2676,7 @@ class GRmenu
2586
2676
  end
2587
2677
  end
2588
2678
 
2589
- def initialize(functions = [], *positional_arguments, title: nil, banner: nil, subtitle: nil, description: nil, divider: nil, style: nil, banner_style: nil, center: true, font: nil, page_size: nil, search: false, columns: 1, image: nil, image_width: nil, mouse: nil, tabs: nil, active_tab_color: nil, tab_color: nil, **keyword_arguments)
2679
+ def initialize(functions = [], *positional_arguments, title: nil, banner: nil, subtitle: nil, description: nil, divider: nil, style: nil, banner_style: nil, center: true, font: nil, page_size: nil, search: false, columns: 1, image: nil, image_width: nil, mouse: nil, tabs: nil, active_tab_color: nil, tab_color: nil, desc_prefix: nil, prefix: nil, border: nil, border_color: nil, options_color: nil, focus_color: nil, title_color: nil, banner_color: nil, subtitle_color: nil, divider_color: nil, **keyword_arguments)
2590
2680
  tabs_data = tabs || keyword_arguments[:tabs] || (functions.is_a?(Hash) ? functions : nil)
2591
2681
  if tabs_data.is_a?(Hash) && !tabs_data.empty?
2592
2682
  @tabs = tabs_data.keys.map(&:to_s)
@@ -2659,7 +2749,9 @@ class GRmenu
2659
2749
  @cached_image_lines = nil
2660
2750
  @cached_image_cols = nil
2661
2751
 
2662
- init_font = font || keyword_arguments[:font_style] || SetStyle.font || 1
2752
+ init_font = font || keyword_arguments[:font] || keyword_arguments[:font_style] || SetStyle.font || 1
2753
+ raw_pfx = desc_prefix || prefix || keyword_arguments[:desc_prefix] || keyword_arguments[:prefix] || keyword_arguments[:description_prefix]
2754
+ @desc_prefix = raw_pfx.to_s unless raw_pfx.nil?
2663
2755
  init_pfx = @desc_prefix || (@@global_theme.is_a?(Hash) && (@@global_theme.dig(:sections, 'menu', 'desc_prefix') || @@global_theme.dig(:sections, 'menu', 'prefix'))) || SetStyle.desc_prefix || "[i]"
2664
2756
 
2665
2757
  @style_config = SetStyle.new(
@@ -2673,6 +2765,37 @@ class GRmenu
2673
2765
  font: init_font,
2674
2766
  desc_prefix: init_pfx
2675
2767
  )
2768
+ @style_config.mark_explicit(:font) if font || keyword_arguments[:font] || keyword_arguments[:font_style]
2769
+ @style_config.mark_explicit(:desc_prefix) unless raw_pfx.nil?
2770
+
2771
+ if border || border_color || keyword_arguments[:border] || keyword_arguments[:border_color]
2772
+ b_c, b_l = self.class.extract_color_and_level(border || border_color || keyword_arguments[:border] || keyword_arguments[:border_color], 1)
2773
+ @style_config.border(b_c, b_l)
2774
+ end
2775
+ if options_color || keyword_arguments[:options_color] || keyword_arguments[:options]
2776
+ o_c, o_l = self.class.extract_color_and_level(options_color || keyword_arguments[:options_color] || keyword_arguments[:options], 1)
2777
+ @style_config.options(o_c, o_l)
2778
+ end
2779
+ if focus_color || keyword_arguments[:focus_color] || keyword_arguments[:focus]
2780
+ f_c, f_l = self.class.extract_color_and_level(focus_color || keyword_arguments[:focus_color] || keyword_arguments[:focus], 2)
2781
+ @style_config.focus(f_c, f_l)
2782
+ end
2783
+ if title_color || keyword_arguments[:title_color]
2784
+ t_c, t_l = self.class.extract_color_and_level(title_color || keyword_arguments[:title_color], 2)
2785
+ @style_config.title(t_c, t_l)
2786
+ end
2787
+ if banner_color || keyword_arguments[:banner_color]
2788
+ bn_c, bn_l = self.class.extract_color_and_level(banner_color || keyword_arguments[:banner_color], 2)
2789
+ @style_config.banner(bn_c, bn_l)
2790
+ end
2791
+ if subtitle_color || keyword_arguments[:subtitle_color]
2792
+ s_c, s_l = self.class.extract_color_and_level(subtitle_color || keyword_arguments[:subtitle_color], 1)
2793
+ @style_config.subtitle(s_c, s_l)
2794
+ end
2795
+ if divider_color || keyword_arguments[:divider_color]
2796
+ d_c, d_l = self.class.extract_color_and_level(divider_color || keyword_arguments[:divider_color], 1)
2797
+ @style_config.divider(d_c, d_l)
2798
+ end
2676
2799
  end
2677
2800
 
2678
2801
  def current_matching_indices
@@ -2771,8 +2894,9 @@ class GRmenu
2771
2894
  brightness_level = parts[1].to_i if parts[1] && !parts[1].empty?
2772
2895
  end
2773
2896
 
2774
- is_anim_active = @animate && ["neon", "fade"].include?(@animate.to_s.downcase)
2775
- is_chroma = color_name == "rgb" || color_name == "rainbow" || color_name == "chroma" || @animate.to_s.downcase == "rgb"
2897
+ is_neon_color = color_name.start_with?("neon")
2898
+ is_anim_active = is_neon_color || (@animate && ["neon", "fade"].include?(@animate.to_s.downcase))
2899
+ is_chroma = color_name == "rgb" || color_name == "rainbow" || color_name == "chroma" || (@animate && ["rgb", "rainbow", "chroma"].include?(@animate.to_s.downcase))
2776
2900
 
2777
2901
  if is_chroma
2778
2902
  tick = @rgb_tick || 0.0
@@ -3071,6 +3195,10 @@ class GRmenu
3071
3195
  calculated_width = [size_max, GRmenu.display_width(@title) + 4, grid_suggested_w].max
3072
3196
  calculated_width = ([calculated_width, GRmenu.display_width(active_desc) + 8].max) unless active_desc.empty?
3073
3197
  calculated_width = ([calculated_width, GRmenu.display_width(@query) + 16].max) if @search
3198
+ if @tabs && !@tabs.empty?
3199
+ tabs_min_w = @tabs.map { |t| GRmenu.display_width(t) + 4 }.sum + (@tabs.length - 1) * 3
3200
+ calculated_width = [calculated_width, tabs_min_w + 4].max
3201
+ end
3074
3202
  total_width = [calculated_width, term_cols - 2].min
3075
3203
 
3076
3204
  sub_1_preview_w = 0
@@ -3616,7 +3744,8 @@ class GRmenu
3616
3744
  end
3617
3745
  end
3618
3746
 
3619
- def style(css_content)
3747
+ def style(css_content = nil)
3748
+ return @style if css_content.nil?
3620
3749
  parsed = self.class.parse_config_text(css_content)
3621
3750
  m = ((parsed[:sections] && parsed[:sections]["menu"]) || {}).merge(parsed[:global] || {})
3622
3751
  if m["style"]
@@ -3626,38 +3755,40 @@ class GRmenu
3626
3755
  @banner_style = m["banner_style"].to_i if m["banner_style"]
3627
3756
  @animate = m["animate"].to_s if m["animate"]
3628
3757
  @center = (m["center"].to_s != "false") if m.key?("center")
3629
- if m["border"] || m["border_color"]
3758
+ if (m["border"] || m["border_color"]) && !@style_config.explicitly_set?(:border)
3630
3759
  c, l = self.class.extract_color_and_level(m["border"] || m["border_color"], 1)
3631
- @style_config.border(c, l)
3760
+ @style_config.border(c, l, from_css: true)
3632
3761
  end
3633
- if m["options"] || m["options_color"]
3762
+ if (m["options"] || m["options_color"]) && !@style_config.explicitly_set?(:options)
3634
3763
  c, l = self.class.extract_color_and_level(m["options"] || m["options_color"], 1)
3635
- @style_config.options(c, l)
3764
+ @style_config.options(c, l, from_css: true)
3636
3765
  end
3637
- if m["focus"] || m["focus_color"]
3766
+ if (m["focus"] || m["focus_color"]) && !@style_config.explicitly_set?(:focus)
3638
3767
  c, l = self.class.extract_color_and_level(m["focus"] || m["focus_color"], 2)
3639
- @style_config.focus(c, l)
3768
+ @style_config.focus(c, l, from_css: true)
3640
3769
  end
3641
- if m["title"] || m["title_color"]
3770
+ if (m["title"] || m["title_color"]) && !@style_config.explicitly_set?(:title)
3642
3771
  c, l = self.class.extract_color_and_level(m["title"] || m["title_color"], 2)
3643
- @style_config.title(c, l)
3772
+ @style_config.title(c, l, from_css: true)
3644
3773
  end
3645
- if m["banner"] || m["banner_color"]
3774
+ if (m["banner"] || m["banner_color"]) && !@style_config.explicitly_set?(:banner)
3646
3775
  c, l = self.class.extract_color_and_level(m["banner"] || m["banner_color"], 2)
3647
- @style_config.banner(c, l)
3776
+ @style_config.banner(c, l, from_css: true)
3648
3777
  end
3649
- if m["subtitle"] || m["subtitle_color"]
3778
+ if (m["subtitle"] || m["subtitle_color"]) && !@style_config.explicitly_set?(:subtitle)
3650
3779
  c, l = self.class.extract_color_and_level(m["subtitle"] || m["subtitle_color"], 1)
3651
- @style_config.subtitle(c, l)
3780
+ @style_config.subtitle(c, l, from_css: true)
3652
3781
  end
3653
- if m["divider"] || m["divider_color"]
3782
+ if (m["divider"] || m["divider_color"]) && !@style_config.explicitly_set?(:divider)
3654
3783
  c, l = self.class.extract_color_and_level(m["divider"] || m["divider_color"], 1)
3655
- @style_config.divider(c, l)
3784
+ @style_config.divider(c, l, from_css: true)
3785
+ end
3786
+ if (m["desc_prefix"] || m["description_prefix"] || m["prefix"]) && !@style_config.explicitly_set?(:desc_prefix)
3787
+ @style_config.desc_prefix(m["desc_prefix"] || m["description_prefix"] || m["prefix"], from_css: true)
3656
3788
  end
3657
- if m["desc_prefix"] || m["description_prefix"] || m["prefix"]
3658
- @style_config.desc_prefix(m["desc_prefix"] || m["description_prefix"] || m["prefix"])
3789
+ if m["font"] && !@style_config.explicitly_set?(:font)
3790
+ @style_config.font(m["font"].to_i, from_css: true)
3659
3791
  end
3660
- @style_config.font(m["font"].to_i) if m["font"]
3661
3792
  @mouse = (m["mouse"].to_s == "true") if m.key?("mouse")
3662
3793
  if parsed[:sections] && parsed[:sections]["tabs"]
3663
3794
  t_sec = parsed[:sections]["tabs"]
@@ -3667,6 +3798,15 @@ class GRmenu
3667
3798
  self
3668
3799
  end
3669
3800
 
3801
+ def style=(val)
3802
+ if val.is_a?(String) && (val.include?("::") || val.include?("<<") || val.include?("@theme"))
3803
+ style(val)
3804
+ else
3805
+ @style = val.to_i
3806
+ @border_config = BORDERS[@style] || BORDERS[3]
3807
+ end
3808
+ end
3809
+
3670
3810
  def export_config(path = nil)
3671
3811
  if path.nil?
3672
3812
  caller_loc = caller_locations.find { |c| !c.path.include?(__FILE__) }
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.3
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - grcode