fatty 0.99.8.2 → 0.99.8.3

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: 7587a39968cfcfad6e8f4d1c0cd61be2a471c5a0946830108315f5b6eeec9cba
4
- data.tar.gz: a5c84ea5819e495d554ffc5cfcd1570a0547795c7cd09967f7768a552e6b6379
3
+ metadata.gz: f79cba23bcf8b408c343c3c732d0af6e93bdf677f3492838f3e1a16473bc05fd
4
+ data.tar.gz: f3c72c60150347df09d4f8f17238566c78c4ade01bd33b73dffe3db48f462f24
5
5
  SHA512:
6
- metadata.gz: b3e988c6ca1404032644fb8de4c606b072ffe59aa1324ebae3fb58212fab46272e3d52a51bfd660a8f0a7e45606a3c4362ffecde98cad375a06c1786cc2c2a89
7
- data.tar.gz: 607be99da8e0fd128ceebb55b666e7f17c0d6c33318b4ce2d339439cef1155cb0c887c2f1896e0fc5cb6156720f92f0d5e489ba9a09ef2814e2d8b468350b3a1
6
+ metadata.gz: a181c65be329a3e0ba0e4084538cee20f25f8250c98e764c9f60ededa9c95af7bda619f28a7ed54d747bbb46efb78ec5460a84263fb5ce4efdf2ba0f2b496e20
7
+ data.tar.gz: abafce8dfdfa7446f229b2742b2de1cf9adcfae99e41fb66348e766153efa971bcf13de6239eef5ef2843258381bb6da268f806b2c389fa729a62a5b1703db94
data/lib/fatty/config.rb CHANGED
@@ -148,6 +148,35 @@ module Fatty
148
148
  File.join(app_user_config_dir, "#{name}.yml")
149
149
  end
150
150
 
151
+ # Persist a user-adjustable preference in the current application's config
152
+ # file. Preferences are kept in the app layer so applications using Fatty
153
+ # do not overwrite one another's selections. When no app layer is
154
+ # configured, use Fatty's global user config.
155
+ def self.set_preference(name, value)
156
+ path = app_config_path || File.join(user_config_dir, "config.yml")
157
+
158
+ config = if app_config_path
159
+ read_app("config")
160
+ elsif File.exist?(path)
161
+ YAML.safe_load_file(
162
+ path,
163
+ aliases: true,
164
+ permitted_classes: [Date, DateTime, Time],
165
+ symbolize_names: true,
166
+ ) || {}
167
+ else
168
+ {}
169
+ end
170
+ config[name.to_sym] = value
171
+ FileUtils.mkdir_p(File.dirname(path))
172
+ File.write(path, YAML.dump(yaml_safe_value(config)))
173
+ reset_reader!
174
+ true
175
+ rescue StandardError => e
176
+ Fatty.warn("Could not save preference #{name.inspect}: #{e.class}: #{e.message}", tag: :config)
177
+ false
178
+ end
179
+
151
180
  # The per-app themes directory, either under
152
181
  # ~/.config/fatty/apps/<app_name>/themes (by default) or under the themes
153
182
  # directory in the config directory the library consumer sets in
@@ -216,7 +245,12 @@ module Fatty
216
245
  return {} unless path
217
246
  return {} unless File.exist?(path)
218
247
 
219
- YAML.load_file(path, symbolize_names: true) || {}
248
+ YAML.safe_load_file(
249
+ path,
250
+ aliases: true,
251
+ permitted_classes: [Date, DateTime, Time],
252
+ symbolize_names: true,
253
+ ) || {}
220
254
  end
221
255
 
222
256
  def self.merge_config(base, overlay)
@@ -256,6 +290,19 @@ module Fatty
256
290
  value || {}
257
291
  end
258
292
 
293
+ def self.yaml_safe_value(value)
294
+ case value
295
+ when Hash
296
+ value.to_h { |key, item| [key.to_s, yaml_safe_value(item)] }
297
+ when Array
298
+ value.map { |item| yaml_safe_value(item) }
299
+ when Symbol
300
+ value.to_s
301
+ else
302
+ value
303
+ end
304
+ end
305
+
259
306
  def self.normalize_app_name(name)
260
307
  text = name.to_s.strip
261
308
  text.empty? ? nil : text
@@ -269,6 +316,7 @@ module Fatty
269
316
  private_class_method :merge_config
270
317
  private_class_method :blank_config?
271
318
  private_class_method :normalize_config_value
319
+ private_class_method :yaml_safe_value
272
320
  private_class_method :normalize_app_name
273
321
  end
274
322
  end
@@ -153,6 +153,7 @@ module Fatty
153
153
  def resume
154
154
  return unless @started
155
155
 
156
+ ::Curses.reset_prog_mode
156
157
  ::Curses.refresh
157
158
  enable_bracketed_paste!
158
159
  nil
@@ -346,6 +346,12 @@ module Fatty
346
346
  stage_window(win)
347
347
  end
348
348
 
349
+ def clear_physical_screen!
350
+ ::Curses.clear
351
+ invalidate!
352
+ self
353
+ end
354
+
349
355
  def begin_frame
350
356
  end
351
357
 
@@ -101,6 +101,10 @@ module Fatty
101
101
  raise NotImplementedError, "#{self.class} must implement #render_alert"
102
102
  end
103
103
 
104
+ def clear_physical_screen!
105
+ self
106
+ end
107
+
104
108
  def invalidate!
105
109
  @last_output_state = nil
106
110
  @last_input_state = nil
@@ -80,6 +80,7 @@ module Fatty
80
80
  []
81
81
  when :clear
82
82
  reset_output!
83
+ renderer.clear_physical_screen!
83
84
  []
84
85
  when :resize
85
86
  resize_output!
@@ -53,6 +53,8 @@ module Fatty
53
53
  if theme_names.include?(t)
54
54
  @warning = nil
55
55
  @current = t
56
+ Fatty::Config.set_preference(:theme, t)
57
+ @current
56
58
  else
57
59
  @warning = "Unknown theme in config: '#{theme}'; using '#{FALLBACK_THEME}'"
58
60
  Fatty.warn(@warning, tag: :theme)
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.8.2"
4
+ VERSION = "0.99.8.3"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fatty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.99.8.2
4
+ version: 0.99.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel E. Doherty
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
10
+ date: 2026-09-08 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: curses
@@ -263,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
263
263
  - !ruby/object:Gem::Version
264
264
  version: '0'
265
265
  requirements: []
266
- rubygems_version: 4.0.17
266
+ rubygems_version: 3.6.2
267
267
  specification_version: 4
268
268
  summary: Stateful terminal UI with editable input and scrollback
269
269
  test_files: []