fatty 0.99.3 → 0.99.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16ab2485e0ddf5436af8c84cddf1e63abff8ec918bb30f4f364b318a8695676a
4
- data.tar.gz: 13f60ac107b8da8b610916e9a8e085db2bcc7ea1992f5dbab3922697fad46f4e
3
+ metadata.gz: 6ba7cbd31b6e1928863864a70182cd399e93382b779f48d1f8c7216ba4b39e1b
4
+ data.tar.gz: 33539e70de07caec28311895153471e83477f584656f89b2643636e0dbee33fc
5
5
  SHA512:
6
- metadata.gz: 6fa1efde1b8ae334344d604869ec8ffdbfc6abe843c0424f5dfdc22cd65b7073c1b09fee5769bc09d19e968fe7728c6b48ef80584bd64e65a1fa43f8633aaed4
7
- data.tar.gz: b38f20ea770d1cbc29474f574753c1b7909d34aa9a2eb7adf8610fc171bca18842d8b802c5c59d7be2881efa50288b3c25c8e68296ddafe2da33bb6745c352cc
6
+ metadata.gz: f3832c280838386b3e7a0ecccd6c527c1ec33edc1deaf8ec8e866f24963787e00e3dd6a2ba5083614da17e4875075d5b12fbfccc0dfad6f7efbf0759ab67fbf6
7
+ data.tar.gz: b540ef445b1c318f389adf4e72efdb3d95f4a0410531a74863812a122dcb79b6f02dbe63890ec4d6902ee96b5678055db84a20b4878ae4145d1d1aa6c4f4c9c0
@@ -104,10 +104,14 @@ module Fatty
104
104
  text.empty? ? DEFAULT_LABEL : text
105
105
  end
106
106
 
107
+ # Return the total but not less than 1 to avoid division-by-zero errors
108
+ # when calculating percentages.
107
109
  def normalize_total(value)
108
110
  return if value.nil?
109
111
 
110
- Integer(value, exception: false)
112
+ val = Integer(value, exception: false)
113
+ val = 1 unless val
114
+ [1, val].max
111
115
  end
112
116
 
113
117
  def normalize_style(value)
@@ -34,9 +34,18 @@ module Fatty
34
34
  cols = ::Curses.cols
35
35
  rows = ::Curses.lines
36
36
  width, height = geometry(cols: cols, rows: rows)
37
+
38
+ # Center the popup horizontally
37
39
  x = (cols - width) / 2
40
+
41
+ # Put the bottom of the popup window one row above the top of the status
42
+ # area.
38
43
  input_row = renderer.screen.input_rect.row
39
- y = [input_row - height - 1, 0].max
44
+ status_rows =
45
+ Fatty::Config.config.dig(:status, :max_rows)&.to_i ||
46
+ StatusSession::DEFAULT_MAX_ROWS
47
+ y = [input_row - status_rows - height - 1, 0].max
48
+
40
49
  self.win = ::Curses::Window.new(height, width, y, x)
41
50
  nil
42
51
  end
data/lib/fatty/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fatty
4
- VERSION = "0.99.3"
4
+ VERSION = "0.99.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fatty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.99.3
4
+ version: 0.99.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel E. Doherty