cani 0.5.0 → 0.5.1

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: c5da8f2224f0f5cbdc98b4e1d7a8a6a95575953b125cd2c3cf2c28655ed61108
4
- data.tar.gz: c6bb2e718e250eb2c404198e635ab4efb5559f1ff0f2afffc476158a94c04d7e
3
+ metadata.gz: d821ab62236b32025cd182c4c0196d1d8a4a707ea9a4308ef93347baba029c30
4
+ data.tar.gz: d12c12cb0bb5f6e91a40b7d9525642a5b5f4e78c7980b481ef03294061504b14
5
5
  SHA512:
6
- metadata.gz: bef86b81aae7fb02b08b5c977e00b73a79ee96e7e72671d72f62d4063c0ee6a19b5e109dd5180e2eb4975275739c61d8d797ca902b87b6a11dcc85b4d9bede19
7
- data.tar.gz: 5380aa3abf603f177676595e95bb04c0c9d641d96db4a5d4e3a03246513a66a9a7222bc17595d5add80c01b457003a7c98b97e1121028a035bb2f727d93e19b5
6
+ metadata.gz: edab77a93d813b073ebb9acc9de3b130a5f8f4768f94b4ebb85c58f2efa2313fda1a22c0aaf15c9d73ab2d0bc4de01a38fe57402c11836729795baa5434b64f1
7
+ data.tar.gz: c246b07a7a08d79e42c76c632c48286c32d9bfe5907da3360f93ed42888ee405def686fc4ece30ff00d04e2f0d8aaa56d04d752faf2a7ad2c9bbd23cdbbba613
data/bin/cani ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'cani'
6
+
7
+ Cani.exec! ARGV[0], *ARGV[1..-1]
@@ -173,18 +173,21 @@ module Cani
173
173
 
174
174
  # meaty part, loop through browsers to create
175
175
  # the final feature table
176
- browsers[0...viewable].each.with_index do |browser, x|
176
+ browsers.each.with_index do |browser, x|
177
177
  # some set up to find the current era for each browser
178
178
  # and creating a range around that to show past / coming support
179
179
  era_idx = browser.most_popular_era_idx
180
180
  era_range = (era_idx - (ERAS / 2.0).floor + 1)..(era_idx + (ERAS / 2.0).ceil)
181
181
  bx = offset_x + x * col_width + x
182
182
  by = offset_y + cy
183
+ do_draw = x < viewable
183
184
 
184
- # draw browser names
185
- Curses.setpos by, bx
186
- Curses.attron color(:header) do
187
- Curses.addstr browser.name.tr('_', '.').center(col_width)
185
+ if do_draw
186
+ # draw browser names
187
+ Curses.setpos by, bx
188
+ Curses.attron color(:header) do
189
+ Curses.addstr browser.name.tr('_', '.').center(col_width)
190
+ end
188
191
  end
189
192
 
190
193
  # accordingly increment current browser y for the table header (browser names)
@@ -204,7 +207,9 @@ module Cani
204
207
  note_nums = feature.browser_note_nums.fetch(browser.name, {})
205
208
  .fetch(era, [])
206
209
 
207
- if is_current
210
+ break if (ey + (is_current ? 1 : bot_pad) + 1) >= height
211
+
212
+ if do_draw && is_current
208
213
  Curses.setpos ey - top_pad - 1, bx - 1
209
214
  Curses.attron(color(:era_border)) { Curses.addstr ' ' * (col_width + 2) }
210
215
 
@@ -214,26 +219,30 @@ module Cani
214
219
 
215
220
  # only show visible / relevant browsers
216
221
  if browser.usage[era].to_i >= 0.5 || (!era.empty? && cur_era >= era_idx)
217
- ((ey - top_pad)..(ey + (is_current ? 1 : bot_pad))).each do |ry|
218
- txt = (bot_pad.zero? && !is_current) ? (ry >= ey + (is_current ? 1 : bot_pad) ? era.to_s : ' ')
219
- : (ry == ey ? era.to_s : ' ')
222
+ if do_draw
223
+ ((ey - top_pad)..(ey + (is_current ? 1 : bot_pad))).each do |ry|
224
+ txt = (bot_pad.zero? && !is_current) ? (ry >= ey + (is_current ? 1 : bot_pad) ? era.to_s : ' ')
225
+ : (ry == ey ? era.to_s : ' ')
220
226
 
221
- Curses.setpos ry, bx
222
- Curses.attron(colr) { Curses.addstr txt.center(col_width) }
227
+ Curses.setpos ry, bx
228
+ Curses.attron(colr) { Curses.addstr txt.center(col_width) }
223
229
 
224
- if is_current
225
- Curses.setpos ry, bx - 1
226
- Curses.attron(color(:era_border)) { Curses.addstr ' ' }
230
+ if is_current
231
+ Curses.setpos ry, bx - 1
232
+ Curses.attron(color(:era_border)) { Curses.addstr ' ' }
227
233
 
228
- Curses.setpos ry, offset_x + table_width + 2
229
- Curses.attron(color(:era_border)) { Curses.addstr ' ' }
234
+ Curses.setpos ry, offset_x + table_width + 2
235
+ Curses.attron(color(:era_border)) { Curses.addstr ' ' }
236
+ end
230
237
  end
231
238
  end
232
239
 
233
240
  if note_nums.any?
234
241
  notes_visible.concat(note_nums).uniq!
235
- Curses.setpos ey - top_pad, bx
236
- Curses.attron(note_color(supp_type)) { Curses.addstr ' ' + note_nums.join(' ') }
242
+ if do_draw
243
+ Curses.setpos ey - top_pad, bx
244
+ Curses.attron(note_color(supp_type)) { Curses.addstr ' ' + note_nums.join(' ') }
245
+ end
237
246
  end
238
247
  end
239
248
  end
data/lib/cani/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cani
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
data/lib/cani.rb CHANGED
@@ -55,6 +55,9 @@ module Cani
55
55
  puts 'cani is dependent on fzf (https://github.com/junegunn/fzf) for the interactive TUI to work.'.light_black
56
56
  puts 'without fzf, commands can still be piped to get the regular (colorless) output'.light_black
57
57
  puts ''
58
+ puts 'Cani requires at least 20 lines and 40 cols to work properly, this is not a hard limit but'
59
+ puts 'below this width, long lines could wrap a lot and reduce visible information.'
60
+ puts ''
58
61
  puts 'Usage:'.red
59
62
  puts ' cani'.yellow + ' [COMMAND [ARGUMENTS]]'
60
63
  puts ''
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cani
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sidney Liebrand
@@ -125,6 +125,7 @@ files:
125
125
  - LICENSE.txt
126
126
  - README.md
127
127
  - Rakefile
128
+ - bin/cani
128
129
  - bin/console
129
130
  - bin/setup
130
131
  - cani.gemspec