fatty 0.99.3 → 0.99.5
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 +4 -4
- data/lib/fatty/ansi/renderer.rb +7 -0
- data/lib/fatty/api/output.rb +24 -4
- data/lib/fatty/progress.rb +5 -1
- data/lib/fatty/session/modal_session.rb +10 -1
- data/lib/fatty/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9bc94398dc11c48330c27d9a4e72197c0d0cbb402b426b248d1f0c3cc4d910fa
|
|
4
|
+
data.tar.gz: 112dbdaa9afb4e637dc405f2a8f69f73afea6375878604cc952598b498bf1ed9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f47fc3c3e387c39d761022f06fb8486a692ef7b20b81bd97aaa00e250d6f05b06f4f57f3a7a24963e007b6ec56aaf598db6d7ac0991909bf0995529170f2546f
|
|
7
|
+
data.tar.gz: 2debc225cd6ee1e2a3dc7f14e4f6951f0d1263b01db556fdac9a7f50101ef27a737a7f13495707bc656ac90baebbc57e53819c92f0735888e81ea3ef8c5b2749
|
data/lib/fatty/ansi/renderer.rb
CHANGED
|
@@ -9,6 +9,13 @@ module Fatty
|
|
|
9
9
|
@io = io
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
def style(text, role:, palette:)
|
|
13
|
+
spec = palette&.[](role.to_sym)
|
|
14
|
+
return text.to_s unless spec
|
|
15
|
+
|
|
16
|
+
"#{sgr_for_spec(spec)}#{text}#{reset}"
|
|
17
|
+
end
|
|
18
|
+
|
|
12
19
|
def render_line(row:, col:, width:, text:, role:, palette:)
|
|
13
20
|
spec = palette&.[](role)
|
|
14
21
|
return unless spec
|
data/lib/fatty/api/output.rb
CHANGED
|
@@ -2,13 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
module Fatty
|
|
4
4
|
module OutputApi
|
|
5
|
-
def append(text, follow: true)
|
|
6
|
-
|
|
5
|
+
def append(text, follow: true, role: nil)
|
|
6
|
+
payload = {
|
|
7
|
+
text: output_text(text, role: role),
|
|
8
|
+
follow: follow,
|
|
9
|
+
}
|
|
10
|
+
queue(Command.session(output_id, :append, **payload))
|
|
7
11
|
nil
|
|
8
12
|
end
|
|
9
13
|
|
|
10
|
-
def append_now(text, follow: true, mode: nil)
|
|
11
|
-
payload = {
|
|
14
|
+
def append_now(text, follow: true, mode: nil, role: nil)
|
|
15
|
+
payload = {
|
|
16
|
+
text: output_text(text, role: role),
|
|
17
|
+
follow: follow,
|
|
18
|
+
}
|
|
12
19
|
payload[:mode] = mode if mode
|
|
13
20
|
|
|
14
21
|
terminal.apply_command(Command.session(output_id, :append, **payload))
|
|
@@ -30,6 +37,19 @@ module Fatty
|
|
|
30
37
|
|
|
31
38
|
private
|
|
32
39
|
|
|
40
|
+
def output_text(text, role:)
|
|
41
|
+
text = text.to_s
|
|
42
|
+
if role
|
|
43
|
+
Fatty::Ansi::Renderer.new.style(
|
|
44
|
+
text,
|
|
45
|
+
role: role,
|
|
46
|
+
palette: markdown_palette,
|
|
47
|
+
)
|
|
48
|
+
else
|
|
49
|
+
text
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
33
53
|
def markdown_palette
|
|
34
54
|
terminal.renderer.palette if terminal.respond_to?(:renderer) && terminal.renderer
|
|
35
55
|
end
|
data/lib/fatty/progress.rb
CHANGED
|
@@ -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
|
-
|
|
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
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.
|
|
4
|
+
version: 0.99.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel E. Doherty
|
|
@@ -246,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
246
246
|
- !ruby/object:Gem::Version
|
|
247
247
|
version: '0'
|
|
248
248
|
requirements: []
|
|
249
|
-
rubygems_version: 4.0.
|
|
249
|
+
rubygems_version: 4.0.17
|
|
250
250
|
specification_version: 4
|
|
251
251
|
summary: Stateful terminal UI with editable input and scrollback
|
|
252
252
|
test_files: []
|