fatty 0.99.10.0 → 0.99.12.0
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/CHANGELOG.org +30 -0
- data/README.md +263 -230
- data/README.org +49 -5
- data/examples/markdown/native-markdown.md +370 -0
- data/examples/markdown/ox-gfm-markdown.md +373 -0
- data/exe/fatty +43 -41
- data/exe/themer +10 -10
- data/help/help.md +1 -0
- data/lib/fatty/alert.rb +1 -1
- data/lib/fatty/ansi/renderer.rb +8 -4
- data/lib/fatty/ansi/windows_console.rb +40 -0
- data/lib/fatty/ansi.rb +0 -5
- data/lib/fatty/api/choose.rb +2 -2
- data/lib/fatty/api/menu.rb +3 -0
- data/lib/fatty/api/output.rb +13 -5
- data/lib/fatty/api/progress.rb +6 -6
- data/lib/fatty/api/prompt.rb +3 -1
- data/lib/fatty/api/status.rb +1 -1
- data/lib/fatty/api.rb +12 -10
- data/lib/fatty/callback_environment.rb +1 -0
- data/lib/fatty/colors/color.rb +7 -30
- data/lib/fatty/config.rb +11 -11
- data/lib/fatty/curses/context.rb +41 -11
- data/lib/fatty/curses/event_source.rb +85 -26
- data/lib/fatty/curses/key_decoder.rb +54 -22
- data/lib/fatty/curses/patch.rb +2 -0
- data/lib/fatty/curses/pdcurses_keys.rb +154 -0
- data/lib/fatty/curses/windows_keyboard.rb +35 -0
- data/lib/fatty/env.rb +14 -12
- data/lib/fatty/help.rb +26 -18
- data/lib/fatty/input_field.rb +55 -17
- data/lib/fatty/key_event.rb +1 -4
- data/lib/fatty/keymaps/emacs.rb +12 -2
- data/lib/fatty/markdown/ansi_renderer.rb +1 -1
- data/lib/fatty/markdown/render.rb +10 -3
- data/lib/fatty/mouse_event.rb +3 -3
- data/lib/fatty/output_buffer.rb +1 -2
- data/lib/fatty/pager.rb +7 -7
- data/lib/fatty/progress.rb +2 -2
- data/lib/fatty/renderer/curses.rb +28 -27
- data/lib/fatty/renderer/truecolor.rb +8 -1
- data/lib/fatty/renderer.rb +6 -6
- data/lib/fatty/session/keytest_session.rb +2 -1
- data/lib/fatty/session/output_session.rb +3 -5
- data/lib/fatty/session/popup_session.rb +24 -24
- data/lib/fatty/session/prompt_session.rb +1 -1
- data/lib/fatty/session/shell_session.rb +11 -5
- data/lib/fatty/session/status_session.rb +2 -2
- data/lib/fatty/shell.rb +60 -0
- data/lib/fatty/terminal.rb +24 -19
- data/lib/fatty/version.rb +1 -1
- data/lib/fatty.rb +9 -10
- metadata +24 -18
data/lib/fatty/progress.rb
CHANGED
|
@@ -21,7 +21,7 @@ module Fatty
|
|
|
21
21
|
unicode_bar
|
|
22
22
|
braille_bar
|
|
23
23
|
spinner
|
|
24
|
-
|
|
24
|
+
].freeze
|
|
25
25
|
|
|
26
26
|
DEFAULT_LABEL = "Progress"
|
|
27
27
|
DEFAULT_ROLE = :info
|
|
@@ -170,7 +170,7 @@ module Fatty
|
|
|
170
170
|
:show,
|
|
171
171
|
text: render_text,
|
|
172
172
|
role: role,
|
|
173
|
-
)
|
|
173
|
+
),
|
|
174
174
|
)
|
|
175
175
|
terminal.render_frame if render
|
|
176
176
|
end
|
|
@@ -634,9 +634,10 @@ module Fatty
|
|
|
634
634
|
stage_window(win)
|
|
635
635
|
end
|
|
636
636
|
|
|
637
|
-
def draw_output_row(win, line:, fragments: nil, y:, abs_line:, highlights:, line_number: nil,
|
|
637
|
+
def draw_output_row(win, line:, fragments: nil, y:, abs_line:, highlights:, line_number: nil,
|
|
638
|
+
line_number_width: nil)
|
|
638
639
|
base_attr = pair_attr(:output, fallback: ::Curses::A_NORMAL)
|
|
639
|
-
|
|
640
|
+
base_attr | ::Curses::A_DIM
|
|
640
641
|
hi_attr = pair_attr(:match_current, fallback: ::Curses::A_REVERSE)
|
|
641
642
|
hi2_attr = pair_attr(:match_other, fallback: hi_attr)
|
|
642
643
|
|
|
@@ -654,13 +655,13 @@ module Fatty
|
|
|
654
655
|
|
|
655
656
|
curses_ranges =
|
|
656
657
|
Array(semantic_ranges).map do |from, to, role|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
658
|
+
attr =
|
|
659
|
+
case role
|
|
660
|
+
when :secondary then hi2_attr
|
|
661
|
+
else hi_attr
|
|
662
|
+
end
|
|
663
|
+
[from.to_i, to.to_i, attr]
|
|
664
|
+
end
|
|
664
665
|
|
|
665
666
|
slices = output_slices(line, fragments: fragments, ranges: curses_ranges, base_attr: base_attr)
|
|
666
667
|
render_slices(win, slices)
|
|
@@ -735,9 +736,9 @@ module Fatty
|
|
|
735
736
|
|
|
736
737
|
def output_slices(line, fragments:, ranges:, base_attr:)
|
|
737
738
|
fragments = Array(fragments)
|
|
738
|
-
return build_line_slices(line.to_s, ranges: ranges)
|
|
739
|
+
return build_line_slices(line.to_s, ranges: ranges) do |style|
|
|
739
740
|
ansi_style_attr(style, fallback: base_attr)
|
|
740
|
-
|
|
741
|
+
end if fragments.empty?
|
|
741
742
|
|
|
742
743
|
slices = []
|
|
743
744
|
offset = 0
|
|
@@ -752,25 +753,25 @@ module Fatty
|
|
|
752
753
|
|
|
753
754
|
fragment_ranges =
|
|
754
755
|
Array(ranges).filter_map do |from, to, attr|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
756
|
+
clipped_from = [from, offset].max
|
|
757
|
+
clipped_to = [to, fragment_end].min
|
|
758
|
+
next if clipped_from >= clipped_to
|
|
759
|
+
|
|
760
|
+
[
|
|
761
|
+
clipped_from - offset,
|
|
762
|
+
clipped_to - offset,
|
|
763
|
+
attr,
|
|
764
|
+
]
|
|
765
|
+
end
|
|
765
766
|
|
|
766
767
|
fragment_slices =
|
|
767
768
|
build_line_slices(text, ranges: fragment_ranges) do |style|
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
769
|
+
ansi_style_attr(
|
|
770
|
+
style,
|
|
771
|
+
fallback: fragment_attr,
|
|
772
|
+
fallback_role: role,
|
|
773
|
+
)
|
|
774
|
+
end
|
|
774
775
|
|
|
775
776
|
fragment_slices.each do |attr, slice_text|
|
|
776
777
|
emit_slice(slices, attr, slice_text)
|
|
@@ -209,6 +209,9 @@ module Fatty
|
|
|
209
209
|
end
|
|
210
210
|
|
|
211
211
|
def begin_frame
|
|
212
|
+
# getch refreshes a touched curses input window. Do that before ANSI
|
|
213
|
+
# painting, otherwise the first read erases the freshly drawn prompt.
|
|
214
|
+
context.input_win&.refresh
|
|
212
215
|
@pending_ansi_draws = []
|
|
213
216
|
end
|
|
214
217
|
|
|
@@ -510,7 +513,11 @@ module Fatty
|
|
|
510
513
|
|
|
511
514
|
rect.rows.times do |y|
|
|
512
515
|
visible_line = lines[y]
|
|
513
|
-
text =
|
|
516
|
+
text = if visible_line
|
|
517
|
+
visible_line.text
|
|
518
|
+
else
|
|
519
|
+
(y < viewport.height ? "~" : "")
|
|
520
|
+
end
|
|
514
521
|
abs_line = visible_line ? visible_line.number - 1 : nil
|
|
515
522
|
ranges = highlight_ranges_for_line(highlights, abs_line)
|
|
516
523
|
segments = []
|
data/lib/fatty/renderer.rb
CHANGED
|
@@ -401,12 +401,12 @@ module Fatty
|
|
|
401
401
|
text = buf.text.to_s
|
|
402
402
|
segments =
|
|
403
403
|
Fatty::Ansi.segment(field.prompt_text.to_s).map do |prompt_text, style|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
404
|
+
{
|
|
405
|
+
text: prompt_text,
|
|
406
|
+
role: base_role,
|
|
407
|
+
style: style,
|
|
408
|
+
}
|
|
409
|
+
end
|
|
410
410
|
|
|
411
411
|
region =
|
|
412
412
|
if buf.respond_to?(:region_range)
|
|
@@ -287,9 +287,7 @@ module Fatty
|
|
|
287
287
|
Fatty::Ansi.segment(text.to_s).map(&:first).join
|
|
288
288
|
end
|
|
289
289
|
|
|
290
|
-
|
|
291
|
-
@narrow_query
|
|
292
|
-
end
|
|
290
|
+
attr_reader :narrow_query
|
|
293
291
|
|
|
294
292
|
def narrowed?
|
|
295
293
|
!@narrow_query.nil?
|
|
@@ -331,8 +329,8 @@ module Fatty
|
|
|
331
329
|
overlap = prev_lines.length - delta
|
|
332
330
|
|
|
333
331
|
delta.positive? &&
|
|
334
|
-
|
|
335
|
-
|
|
332
|
+
delta < curr_viewport[1] &&
|
|
333
|
+
overlap.positive? &&
|
|
336
334
|
prev_lines.drop(delta) == curr_lines.take(overlap)
|
|
337
335
|
end
|
|
338
336
|
|
|
@@ -21,31 +21,31 @@ module Fatty
|
|
|
21
21
|
# - order: :as_given (default) or :reverse (presentation order).
|
|
22
22
|
# - current: :preserve (default), :top, :bottom (how the current behaves after refresh).
|
|
23
23
|
def initialize(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
source:,
|
|
25
|
+
title: nil,
|
|
26
|
+
message: nil,
|
|
27
|
+
prompt: "Narrow: ",
|
|
28
|
+
keymap: Keymaps.emacs,
|
|
29
|
+
matcher: nil,
|
|
30
|
+
order: :as_given,
|
|
31
|
+
kind: nil,
|
|
32
|
+
current: :preserve,
|
|
33
|
+
initial_query: nil,
|
|
34
|
+
show_counts: true,
|
|
35
|
+
show_filter: true,
|
|
36
|
+
selection_mode: :single,
|
|
37
|
+
history: nil,
|
|
38
|
+
history_kind: :popup_filter,
|
|
39
|
+
history_ctx: nil,
|
|
40
|
+
save_history: true,
|
|
41
|
+
validate_unique_labels: false
|
|
42
|
+
)
|
|
43
43
|
super(keymap: keymap)
|
|
44
44
|
@source = source
|
|
45
45
|
@title = title&.to_s
|
|
46
46
|
@message = message&.to_s
|
|
47
47
|
@prompt = Prompt.ensure(prompt)
|
|
48
|
-
@matcher = matcher || method(:default_matcher)
|
|
48
|
+
@matcher = matcher || method(:default_matcher?)
|
|
49
49
|
@order = order.to_sym
|
|
50
50
|
@kind = kind&.to_sym
|
|
51
51
|
@current_policy = current.to_sym
|
|
@@ -402,7 +402,7 @@ module Fatty
|
|
|
402
402
|
apply_order!
|
|
403
403
|
validate_unique_labels!(@items) if @validate_unique_labels
|
|
404
404
|
|
|
405
|
-
matcher = @matcher || method(:default_matcher)
|
|
405
|
+
matcher = @matcher || method(:default_matcher?)
|
|
406
406
|
@filtered =
|
|
407
407
|
if q.empty?
|
|
408
408
|
@items
|
|
@@ -610,7 +610,7 @@ module Fatty
|
|
|
610
610
|
end
|
|
611
611
|
end
|
|
612
612
|
|
|
613
|
-
def default_matcher(item, query)
|
|
613
|
+
def default_matcher?(item, query)
|
|
614
614
|
Fatty::Search.match_all_terms?(item, query)
|
|
615
615
|
end
|
|
616
616
|
|
|
@@ -649,8 +649,8 @@ module Fatty
|
|
|
649
649
|
end
|
|
650
650
|
|
|
651
651
|
def selected_result_hash
|
|
652
|
-
selected_items_in_source_order.
|
|
653
|
-
|
|
652
|
+
selected_items_in_source_order.to_h do |item|
|
|
653
|
+
[item_label(item), item_value(item)]
|
|
654
654
|
end
|
|
655
655
|
end
|
|
656
656
|
end
|
|
@@ -11,7 +11,7 @@ module Fatty
|
|
|
11
11
|
def id = :prompt
|
|
12
12
|
|
|
13
13
|
def initialize(initial: "", prompt: "> ", title: "Prompt", message: nil, kind: nil,
|
|
14
|
-
|
|
14
|
+
history_ctx: nil, history_path: :default, history: nil, save_history: true)
|
|
15
15
|
super(keymap: Keymaps.emacs)
|
|
16
16
|
@title = title&.to_s
|
|
17
17
|
@message = message&.to_s
|
|
@@ -8,7 +8,8 @@ module Fatty
|
|
|
8
8
|
|
|
9
9
|
attr_reader :field, :history, :output_session, :on_accept
|
|
10
10
|
|
|
11
|
-
def initialize(id: nil, prompt: "sh> ", on_accept: nil, completion_proc: nil, history_ctx: nil,
|
|
11
|
+
def initialize(id: nil, prompt: "sh> ", on_accept: nil, completion_proc: nil, history_ctx: nil,
|
|
12
|
+
history_path: :default)
|
|
12
13
|
keymap = Keymaps.emacs
|
|
13
14
|
super(
|
|
14
15
|
id: :shell,
|
|
@@ -389,7 +390,8 @@ module Fatty
|
|
|
389
390
|
|
|
390
391
|
def run_default_command(line)
|
|
391
392
|
commands = [Command.session(output_session.id, :append, text: "$ #{line}\n", follow: true)]
|
|
392
|
-
out
|
|
393
|
+
out = status = nil
|
|
394
|
+
terminal.suspend { out, status = Fatty::Shell.capture(line) }
|
|
393
395
|
if status&.exitstatus && status.exitstatus != 0
|
|
394
396
|
out << "\n[exit #{status.exitstatus}]\n"
|
|
395
397
|
end
|
|
@@ -403,14 +405,14 @@ module Fatty
|
|
|
403
405
|
alert_cmd(
|
|
404
406
|
:error,
|
|
405
407
|
"Undefined key: #{ev.key} " \
|
|
406
|
-
|
|
408
|
+
"(edit config in 'keydefs.yml' to name)",
|
|
407
409
|
ev: ev,
|
|
408
410
|
)
|
|
409
411
|
else
|
|
410
412
|
alert_cmd(
|
|
411
413
|
:warn,
|
|
412
414
|
"Unbound key: #{ev} " \
|
|
413
|
-
|
|
415
|
+
"(edit config in 'keybindings.yml' to bind)",
|
|
414
416
|
ev: ev,
|
|
415
417
|
)
|
|
416
418
|
end
|
|
@@ -488,11 +490,14 @@ module Fatty
|
|
|
488
490
|
end
|
|
489
491
|
|
|
490
492
|
def completion_path_item?(item)
|
|
491
|
-
item.to_s
|
|
493
|
+
s = item.to_s
|
|
494
|
+
s = s.delete_prefix('"').delete_suffix('"').tr("\\", "/") if Gem.win_platform?
|
|
495
|
+
s.end_with?("/")
|
|
492
496
|
end
|
|
493
497
|
|
|
494
498
|
def parent_completion_path(path)
|
|
495
499
|
s = path.to_s
|
|
500
|
+
s = s.delete_prefix('"').delete_suffix('"').tr("\\", "/") if Gem.win_platform?
|
|
496
501
|
return if s.empty?
|
|
497
502
|
|
|
498
503
|
s = s[0...-1] if s.end_with?("/") && s.length > 1
|
|
@@ -500,6 +505,7 @@ module Fatty
|
|
|
500
505
|
return unless slash
|
|
501
506
|
|
|
502
507
|
parent = s[0..slash]
|
|
508
|
+
parent = parent.tr("/", "\\") if Gem.win_platform?
|
|
503
509
|
return if parent == path
|
|
504
510
|
|
|
505
511
|
parent
|
|
@@ -87,13 +87,13 @@ module Fatty
|
|
|
87
87
|
def renderable_text(value)
|
|
88
88
|
parts = value.is_a?(Array) ? value : [value]
|
|
89
89
|
|
|
90
|
-
parts.map
|
|
90
|
+
parts.map { |part|
|
|
91
91
|
if part.is_a?(Hash) && part.key?(:text)
|
|
92
92
|
part[:text].to_s
|
|
93
93
|
else
|
|
94
94
|
part.to_s
|
|
95
95
|
end
|
|
96
|
-
|
|
96
|
+
}.join
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
def visible?
|
data/lib/fatty/shell.rb
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "fiddle"
|
|
4
|
+
require "open3"
|
|
5
|
+
require "shellwords"
|
|
6
|
+
require "tempfile"
|
|
7
|
+
|
|
8
|
+
module Fatty
|
|
9
|
+
# Capture noninteractive shell output. On native Windows, avoid the threaded
|
|
10
|
+
# pipe reader that can stall after PDCurses console input.
|
|
11
|
+
module Shell
|
|
12
|
+
# Demo command arguments are shell-like, but Windows backslashes are
|
|
13
|
+
# path separators, not Unix escapes. External commands keep the original line.
|
|
14
|
+
def self.split_arguments(line)
|
|
15
|
+
line = line.gsub("\\") { "\\\\" } if Gem.win_platform?
|
|
16
|
+
Shellwords.split(line)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.capture(line)
|
|
20
|
+
return Open3.capture2e(line) unless Gem.win_platform?
|
|
21
|
+
|
|
22
|
+
Tempfile.create("fatty-command") do |output|
|
|
23
|
+
pid = Process.spawn(line, in: File::NULL, out: output, err: [:child, :out])
|
|
24
|
+
_, status = Process.wait2(pid)
|
|
25
|
+
output.binmode
|
|
26
|
+
output.rewind
|
|
27
|
+
[decode_windows_output(output.read).gsub("\r\n", "\n"), status]
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Some external programs emit UTF-8 even when cmd.exe uses a legacy page.
|
|
32
|
+
def self.decode_windows_output(bytes)
|
|
33
|
+
text = bytes.dup.force_encoding(Encoding::UTF_8)
|
|
34
|
+
return text if text.valid_encoding?
|
|
35
|
+
|
|
36
|
+
text.force_encoding(windows_output_encoding).encode(Encoding::UTF_8, invalid: :replace, undef: :replace)
|
|
37
|
+
end
|
|
38
|
+
private_class_method :decode_windows_output
|
|
39
|
+
|
|
40
|
+
def self.windows_output_encoding
|
|
41
|
+
@code_page_functions ||= begin
|
|
42
|
+
library = Fiddle.dlopen("kernel32.dll")
|
|
43
|
+
abi = if Fiddle::Function.const_defined?(:STDCALL)
|
|
44
|
+
Fiddle::Function::STDCALL
|
|
45
|
+
else
|
|
46
|
+
Fiddle::Function::DEFAULT
|
|
47
|
+
end
|
|
48
|
+
["GetConsoleOutputCP", "GetOEMCP"].map do |name|
|
|
49
|
+
Fiddle::Function.new(library[name], [], Fiddle::TYPE_INT, abi)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
page = @code_page_functions[0].call
|
|
53
|
+
page = @code_page_functions[1].call if page.zero?
|
|
54
|
+
Encoding.find(page == 65001 ? "UTF-8" : "CP#{page}")
|
|
55
|
+
rescue ArgumentError, Fiddle::DLError
|
|
56
|
+
Encoding::UTF_8
|
|
57
|
+
end
|
|
58
|
+
private_class_method :windows_output_encoding
|
|
59
|
+
end
|
|
60
|
+
end
|
data/lib/fatty/terminal.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "io/console"
|
|
4
|
+
|
|
3
5
|
require_relative 'terminal/popup_owner'
|
|
4
6
|
|
|
5
7
|
module Fatty
|
|
@@ -67,13 +69,13 @@ module Fatty
|
|
|
67
69
|
attr_reader :shell_session, :status_session, :alert_session, :focused_session
|
|
68
70
|
|
|
69
71
|
def initialize(prompt: "> ",
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
on_accept: nil,
|
|
73
|
+
app_name: nil,
|
|
74
|
+
app_config_dir: nil,
|
|
75
|
+
completion_proc: nil,
|
|
76
|
+
history_path: :default,
|
|
77
|
+
history_ctx: nil,
|
|
78
|
+
env: nil)
|
|
77
79
|
@prompt = Prompt.ensure(prompt)
|
|
78
80
|
@on_accept = on_accept
|
|
79
81
|
@app_name = app_name
|
|
@@ -102,7 +104,8 @@ module Fatty
|
|
|
102
104
|
end
|
|
103
105
|
|
|
104
106
|
def inspect
|
|
105
|
-
"Terminal: prompt: #{@prompt}; history: #{@history_path};
|
|
107
|
+
"Terminal: prompt: #{@prompt}; history: #{@history_path}; " \
|
|
108
|
+
"sessions size: #{@sessions.size} active: #{active_session.id}"
|
|
106
109
|
end
|
|
107
110
|
|
|
108
111
|
def to_s
|
|
@@ -355,13 +358,13 @@ module Fatty
|
|
|
355
358
|
@status_session = Fatty::StatusSession.new(id: :status)
|
|
356
359
|
install_session(@status_session)
|
|
357
360
|
@shell_session = ShellSession.new(
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
361
|
+
id: :shell,
|
|
362
|
+
prompt: @prompt,
|
|
363
|
+
on_accept: @on_accept,
|
|
364
|
+
completion_proc: @completion_proc,
|
|
365
|
+
history_path: @history_path,
|
|
366
|
+
history_ctx: @history_ctx,
|
|
367
|
+
)
|
|
365
368
|
install_session(@shell_session, focus: true)
|
|
366
369
|
end
|
|
367
370
|
|
|
@@ -510,7 +513,7 @@ module Fatty
|
|
|
510
513
|
screen.resize(rows: rows, cols: cols, status_rows: @status_rows)
|
|
511
514
|
Fatty.info(
|
|
512
515
|
"handle_resize after=#{screen.rows}x#{screen.cols} " \
|
|
513
|
-
|
|
516
|
+
"output_after=#{screen.output_rect.inspect}",
|
|
514
517
|
tag: :resize,
|
|
515
518
|
)
|
|
516
519
|
|
|
@@ -537,7 +540,7 @@ module Fatty
|
|
|
537
540
|
def reconcile_terminal_size!
|
|
538
541
|
return unless @screen && @ctx
|
|
539
542
|
|
|
540
|
-
rows, cols =
|
|
543
|
+
rows, cols = $stdout.winsize
|
|
541
544
|
return if rows.to_i <= 0 || cols.to_i <= 0
|
|
542
545
|
|
|
543
546
|
if [rows, cols] == [@screen.rows, @screen.cols]
|
|
@@ -731,7 +734,8 @@ module Fatty
|
|
|
731
734
|
:show,
|
|
732
735
|
role: :info,
|
|
733
736
|
text: "Theme: #{new_theme}",
|
|
734
|
-
)
|
|
737
|
+
),
|
|
738
|
+
)
|
|
735
739
|
when :set_theme
|
|
736
740
|
theme = command.payload.fetch(:theme)
|
|
737
741
|
Fatty::Themes::Manager.set(theme)
|
|
@@ -742,7 +746,8 @@ module Fatty
|
|
|
742
746
|
:show,
|
|
743
747
|
role: :info,
|
|
744
748
|
text: "Theme: #{theme}",
|
|
745
|
-
)
|
|
749
|
+
),
|
|
750
|
+
)
|
|
746
751
|
when :resize
|
|
747
752
|
handle_resize
|
|
748
753
|
else
|
data/lib/fatty/version.rb
CHANGED
data/lib/fatty.rb
CHANGED
|
@@ -9,14 +9,12 @@ require "rainbow"
|
|
|
9
9
|
require "redcarpet"
|
|
10
10
|
require "strscan"
|
|
11
11
|
|
|
12
|
-
require 'debug'
|
|
13
|
-
|
|
14
12
|
# Gem Overview (extracted from README.org by gem_docs)
|
|
15
13
|
#
|
|
16
14
|
# * Introduction
|
|
17
|
-
# ~Fatty~ aims to provide a full-featured command-line
|
|
15
|
+
# ~Fatty~ aims to provide a full-featured command-line environment that provides:
|
|
18
16
|
#
|
|
19
|
-
# 1. an editing command-line input,
|
|
17
|
+
# 1. an emacs-like editing command-line input, including undo/redo and kill/yank
|
|
20
18
|
# 2. a history facility,
|
|
21
19
|
# 3. command completion,
|
|
22
20
|
# 4. completion of partially-typed file path names,
|
|
@@ -27,24 +25,25 @@ require 'debug'
|
|
|
27
25
|
# 9. defining unrecognized key-codes as named keys,
|
|
28
26
|
# 10. color themes that can be selected in real time,
|
|
29
27
|
# 11. a way to define new themes,
|
|
30
|
-
# 12.
|
|
28
|
+
# 12. processing completed command lines with a callback procedure of your
|
|
31
29
|
# choosing,
|
|
32
|
-
# 13. several user-interface widgets such
|
|
33
|
-
#
|
|
34
|
-
#
|
|
30
|
+
# 13. several user-interface widgets such as selection popups, text prompts,
|
|
31
|
+
# menus, and progress indicators,
|
|
32
|
+
# 14. a way to render markdown to the output pane,
|
|
35
33
|
#
|
|
36
34
|
# In other words, fatty allows you to write a terminal-based REPL of your choosing but takes
|
|
37
35
|
# care of all the difficult parts.
|
|
38
36
|
#
|
|
39
37
|
# ~Fatty~ is written entirely in Ruby and was born from my frustrations at the
|
|
40
|
-
# limitations of libraries like ~readline~ and ~reline~. It
|
|
41
|
-
#
|
|
38
|
+
# limitations of libraries like ~readline~ and ~reline~. It uses ~curses~ and
|
|
39
|
+
# ~truecolor~ sequences for low-level rendering and is surprisingly snappy.
|
|
42
40
|
#
|
|
43
41
|
# ~Fatty~ is /not/ a terminal emulator but runs on top of one.
|
|
44
42
|
module Fatty
|
|
45
43
|
require_relative "fatty/version"
|
|
46
44
|
require_relative "fatty/core_ext"
|
|
47
45
|
require_relative "fatty/env"
|
|
46
|
+
require_relative "fatty/shell"
|
|
48
47
|
require_relative "fatty/config"
|
|
49
48
|
require_relative "fatty/logger"
|
|
50
49
|
require_relative "fatty/counter"
|