fatty 0.99.4 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ba7cbd31b6e1928863864a70182cd399e93382b779f48d1f8c7216ba4b39e1b
4
- data.tar.gz: 33539e70de07caec28311895153471e83477f584656f89b2643636e0dbee33fc
3
+ metadata.gz: 9bc94398dc11c48330c27d9a4e72197c0d0cbb402b426b248d1f0c3cc4d910fa
4
+ data.tar.gz: 112dbdaa9afb4e637dc405f2a8f69f73afea6375878604cc952598b498bf1ed9
5
5
  SHA512:
6
- metadata.gz: f3832c280838386b3e7a0ecccd6c527c1ec33edc1deaf8ec8e866f24963787e00e3dd6a2ba5083614da17e4875075d5b12fbfccc0dfad6f7efbf0759ab67fbf6
7
- data.tar.gz: b540ef445b1c318f389adf4e72efdb3d95f4a0410531a74863812a122dcb79b6f02dbe63890ec4d6902ee96b5678055db84a20b4878ae4145d1d1aa6c4f4c9c0
6
+ metadata.gz: f47fc3c3e387c39d761022f06fb8486a692ef7b20b81bd97aaa00e250d6f05b06f4f57f3a7a24963e007b6ec56aaf598db6d7ac0991909bf0995529170f2546f
7
+ data.tar.gz: 2debc225cd6ee1e2a3dc7f14e4f6951f0d1263b01db556fdac9a7f50101ef27a737a7f13495707bc656ac90baebbc57e53819c92f0735888e81ea3ef8c5b2749
@@ -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
@@ -2,13 +2,20 @@
2
2
 
3
3
  module Fatty
4
4
  module OutputApi
5
- def append(text, follow: true)
6
- queue(Command.session(output_id, :append, text: text.to_s, follow: follow))
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 = { text: text.to_s, follow: follow }
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/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fatty
4
- VERSION = "0.99.4"
4
+ VERSION = "0.99.5"
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.4
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.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: []