fatty 0.99.0 → 0.99.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 +4 -4
- data/CHANGELOG.org +11 -29
- data/README.md +2207 -18
- data/README.org +2066 -104
- data/exe/fatty +236 -93
- data/help/help.md +233 -0
- data/lib/fatty/action.rb +3 -7
- data/lib/fatty/actionable.rb +2 -0
- data/lib/fatty/alert.rb +65 -39
- data/lib/fatty/ansi/renderer.rb +26 -6
- data/lib/fatty/ansi.rb +1 -0
- data/lib/fatty/api/alert.rb +15 -0
- data/lib/fatty/api/choose.rb +145 -0
- data/lib/fatty/api/environment.rb +12 -0
- data/lib/fatty/api/keytest.rb +11 -0
- data/lib/fatty/api/menu.rb +104 -0
- data/lib/fatty/api/output.rb +55 -0
- data/lib/fatty/api/progress.rb +24 -0
- data/lib/fatty/api/prompt.rb +77 -0
- data/lib/fatty/api/status.rb +55 -0
- data/lib/fatty/api.rb +38 -0
- data/lib/fatty/callback_environment.rb +74 -0
- data/lib/fatty/colors/color.rb +366 -232
- data/lib/fatty/colors/pairs.rb +2 -0
- data/lib/fatty/command.rb +78 -0
- data/lib/fatty/config.rb +227 -39
- data/lib/fatty/config_files/config.yml +4 -12
- data/lib/fatty/config_files/keydefs.yml +13 -23
- data/lib/fatty/config_files/themes/capuchin_monk.yml +140 -0
- data/lib/fatty/config_files/themes/catppuccin_latte.yml +140 -0
- data/lib/fatty/config_files/themes/catppuccin_mocha.yml +140 -0
- data/lib/fatty/config_files/themes/cyberpunk.yml +141 -0
- data/lib/fatty/config_files/themes/dracula.yml +140 -0
- data/lib/fatty/config_files/themes/everforest_dark.yml +140 -0
- data/lib/fatty/config_files/themes/gruvbox_dark.yml +140 -0
- data/lib/fatty/config_files/themes/gruvbox_light.yml +140 -0
- data/lib/fatty/config_files/themes/mono.yml +119 -47
- data/lib/fatty/config_files/themes/monokai.yml +140 -0
- data/lib/fatty/config_files/themes/nordic.yml +1 -0
- data/lib/fatty/config_files/themes/onedark.yml +140 -0
- data/lib/fatty/config_files/themes/solarized_dark.yml +1 -0
- data/lib/fatty/config_files/themes/solarized_light.yml +140 -0
- data/lib/fatty/config_files/themes/terminal.yml +67 -0
- data/lib/fatty/config_files/themes/tokyo_night.yml +140 -0
- data/lib/fatty/config_files/themes/wordperfect.yml +80 -9
- data/lib/fatty/core_ext/hash.rb +19 -0
- data/lib/fatty/core_ext/string.rb +19 -12
- data/lib/fatty/core_ext.rb +1 -0
- data/lib/fatty/curses/context.rb +86 -84
- data/lib/fatty/curses/event_source.rb +128 -40
- data/lib/fatty/curses/key_decoder.rb +77 -11
- data/lib/fatty/env.rb +21 -20
- data/lib/fatty/help.rb +1 -29
- data/lib/fatty/history/entry.rb +2 -0
- data/lib/fatty/history.rb +17 -14
- data/lib/fatty/input_buffer.rb +71 -47
- data/lib/fatty/input_field.rb +216 -149
- data/lib/fatty/key_event.rb +67 -66
- data/lib/fatty/key_map.rb +54 -16
- data/lib/fatty/keymaps/emacs.rb +40 -6
- data/lib/fatty/log_formats/json.rb +2 -0
- data/lib/fatty/log_formats/text.rb +2 -0
- data/lib/fatty/logger.rb +7 -2
- data/lib/fatty/markdown/ansi_renderer.rb +75 -6
- data/lib/fatty/markdown/render.rb +2 -3
- data/lib/fatty/mouse_event.rb +142 -2
- data/lib/fatty/output_buffer.rb +2 -0
- data/lib/fatty/pager.rb +158 -47
- data/lib/fatty/progress.rb +417 -0
- data/lib/fatty/renderer/curses.rb +340 -184
- data/lib/fatty/renderer/truecolor.rb +266 -163
- data/lib/fatty/renderer.rb +115 -97
- data/lib/fatty/screen.rb +2 -0
- data/lib/fatty/session/alert_session.rb +39 -21
- data/lib/fatty/session/isearch_session.rb +92 -38
- data/lib/fatty/session/keytest_session.rb +105 -85
- data/lib/fatty/session/modal_session.rb +38 -1
- data/lib/fatty/session/output_session.rb +472 -21
- data/lib/fatty/session/popup_session.rb +251 -134
- data/lib/fatty/session/prompt_session.rb +68 -26
- data/lib/fatty/session/search_session.rb +79 -31
- data/lib/fatty/session/shell_session.rb +383 -368
- data/lib/fatty/session/status_session.rb +167 -0
- data/lib/fatty/session.rb +95 -95
- data/lib/fatty/terminal/popup_owner.rb +14 -11
- data/lib/fatty/terminal.rb +515 -813
- data/lib/fatty/themes/loader.rb +4 -2
- data/lib/fatty/themes/manager.rb +4 -0
- data/lib/fatty/themes/registry.rb +2 -0
- data/lib/fatty/themes/resolver.rb +175 -162
- data/lib/fatty/version.rb +1 -1
- data/lib/fatty/viewport.rb +8 -1
- data/lib/fatty.rb +35 -7
- metadata +42 -40
- data/.envrc +0 -2
- data/.simplecov +0 -23
- data/.yardopts +0 -4
- data/CHANGELOG.md +0 -34
- data/Rakefile +0 -15
- data/TODO.org +0 -163
- data/examples/markdown/native-markdown.md +0 -370
- data/examples/markdown/ox-gfm-markdown.md +0 -373
- data/examples/markdown/ox-gfm-markdown.org +0 -376
- data/fatty.gemspec +0 -42
- data/lib/fatty/accept_env.rb +0 -32
- data/lib/fatty/config_files/help.md +0 -120
- data/lib/fatty/config_files/help.org +0 -124
- data/lib/fatty/config_files/themes/wordperfect_light.yml +0 -77
- data/lib/fatty/menu_env.rb +0 -22
- data/lib/fatty/session/input_session.rb +0 -99
- data/lib/fatty/sessions.rb +0 -14
- data/lib/fatty/terminal/progress.rb +0 -374
- data/lib/fatty/view/alert_view.rb +0 -14
- data/lib/fatty/view/cursor_view.rb +0 -18
- data/lib/fatty/view/input_view.rb +0 -9
- data/lib/fatty/view/output_view.rb +0 -9
- data/lib/fatty/view/status_view.rb +0 -14
- data/lib/fatty/view.rb +0 -33
- data/lib/fatty/views.rb +0 -9
- data/sig/fatty.rbs +0 -4
data/lib/fatty/help.rb
CHANGED
|
@@ -1,37 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# require "redcarpet"
|
|
4
|
-
# require_relative "ansi_renderer"
|
|
5
|
-
|
|
6
|
-
# module Fatty
|
|
7
|
-
# module Help
|
|
8
|
-
# def self.path
|
|
9
|
-
# File.expand_path("config_files/help.md", __dir__)
|
|
10
|
-
# end
|
|
11
|
-
|
|
12
|
-
# def self.render(width: 80)
|
|
13
|
-
# renderer = Fatty::AnsiRenderer.new(width: width)
|
|
14
|
-
# markdown = Redcarpet::Markdown.new(
|
|
15
|
-
# renderer,
|
|
16
|
-
# tables: true,
|
|
17
|
-
# fenced_code_blocks: true,
|
|
18
|
-
# autolink: true,
|
|
19
|
-
# )
|
|
20
|
-
# markdown.render(text)
|
|
21
|
-
# end
|
|
22
|
-
|
|
23
|
-
# def self.text
|
|
24
|
-
# File.read(path)
|
|
25
|
-
# end
|
|
26
|
-
# end
|
|
27
|
-
# end
|
|
28
|
-
|
|
29
|
-
# frozen_string_literal: true
|
|
30
|
-
|
|
31
3
|
module Fatty
|
|
32
4
|
module Help
|
|
33
5
|
def self.path
|
|
34
|
-
File.expand_path("
|
|
6
|
+
File.expand_path("../../help/help.md", __dir__)
|
|
35
7
|
end
|
|
36
8
|
|
|
37
9
|
def self.text
|
data/lib/fatty/history/entry.rb
CHANGED
data/lib/fatty/history.rb
CHANGED
|
@@ -25,10 +25,10 @@ module Fatty
|
|
|
25
25
|
@cursors = {}
|
|
26
26
|
|
|
27
27
|
if @path
|
|
28
|
-
Fatty.info("History loaded from #{@path}")
|
|
28
|
+
Fatty.info("History loaded from #{@path}", tag: :config)
|
|
29
29
|
load
|
|
30
30
|
else
|
|
31
|
-
Fatty.info("In-memory History only: no path")
|
|
31
|
+
Fatty.info("In-memory History only: no path", tag: :config)
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
@@ -47,10 +47,6 @@ module Fatty
|
|
|
47
47
|
@instances = {}
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
def self.default
|
|
51
|
-
for_path(:default)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
50
|
###################################################################################
|
|
55
51
|
# Accessing History items from a consuming application
|
|
56
52
|
###################################################################################
|
|
@@ -164,19 +160,24 @@ module Fatty
|
|
|
164
160
|
cursor[:scratch] = nil
|
|
165
161
|
end
|
|
166
162
|
|
|
167
|
-
def
|
|
163
|
+
def suggestions_for(*kinds, prefix:, ctx: nil, limit: nil)
|
|
168
164
|
text = prefix.to_s
|
|
169
|
-
return if text.empty?
|
|
165
|
+
return [] if text.empty?
|
|
170
166
|
|
|
171
167
|
wanted_ctx = normalize_ctx(ctx)
|
|
172
168
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
169
|
+
rows =
|
|
170
|
+
if wanted_ctx.empty?
|
|
171
|
+
entries_for(*kinds, prefix: text)
|
|
172
|
+
else
|
|
173
|
+
local = entries_for(*kinds, ctx: wanted_ctx, prefix: text)
|
|
174
|
+
global = entries_for(*kinds, prefix: text)
|
|
175
|
+
local + global
|
|
176
|
+
end
|
|
177
177
|
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
rows = rows.reverse.map(&:text).uniq
|
|
179
|
+
rows = rows.first(limit) if limit
|
|
180
|
+
rows
|
|
180
181
|
end
|
|
181
182
|
|
|
182
183
|
def self.normalize_ctx(ctx)
|
|
@@ -189,6 +190,8 @@ module Fatty
|
|
|
189
190
|
|
|
190
191
|
private
|
|
191
192
|
|
|
193
|
+
# simplecov:disable
|
|
194
|
+
|
|
192
195
|
def normalize_kinds(*kinds)
|
|
193
196
|
kinds.flatten.map(&:to_sym).uniq.sort
|
|
194
197
|
end
|
data/lib/fatty/input_buffer.rb
CHANGED
|
@@ -35,22 +35,19 @@ module Fatty
|
|
|
35
35
|
include Actionable
|
|
36
36
|
|
|
37
37
|
attr_reader :mark, :kill_ring, :undo_stack
|
|
38
|
-
attr_accessor :text, :cursor, :
|
|
38
|
+
attr_accessor :text, :cursor, :word_char_re, :virtual_suffix
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
DEFAULT_WORD_CHAR_RE = "[[:alnum:]_]"
|
|
41
41
|
|
|
42
|
-
def initialize(
|
|
42
|
+
def initialize(word_char_re: DEFAULT_WORD_CHAR_RE, undo_limit: 1_000, kill_ring_max: 60)
|
|
43
43
|
@text = +""
|
|
44
44
|
@virtual_suffix = +""
|
|
45
45
|
@cursor = 0
|
|
46
46
|
@mark = nil
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
# word_chars is a fragment like "[[:alnum:]_]" or "[[:alnum:]_-]"
|
|
52
|
-
Regexp.new(word_chars)
|
|
53
|
-
end
|
|
47
|
+
# word_char_re is a fragment like "[[:alnum:]_]" or "[[:alnum:]_-]"
|
|
48
|
+
# meant to match a single charachter that should be considered a part of
|
|
49
|
+
# a word for purposes of cursor movement.
|
|
50
|
+
@word_char_re = normalize_word_char_re(word_char_re)
|
|
54
51
|
@undo_limit = undo_limit
|
|
55
52
|
@undo_stack = []
|
|
56
53
|
@redo_stack = []
|
|
@@ -289,7 +286,7 @@ module Fatty
|
|
|
289
286
|
desc "Delete the character before the cursor"
|
|
290
287
|
action :delete_char_backward do |count: 1|
|
|
291
288
|
if region_active?
|
|
292
|
-
|
|
289
|
+
kill_region
|
|
293
290
|
else
|
|
294
291
|
n = normalize_count(count)
|
|
295
292
|
return if @cursor.zero?
|
|
@@ -309,7 +306,7 @@ module Fatty
|
|
|
309
306
|
desc "Delete count characters after the cursor"
|
|
310
307
|
action :delete_char_forward do |count: 1|
|
|
311
308
|
if region_active?
|
|
312
|
-
|
|
309
|
+
kill_region
|
|
313
310
|
else
|
|
314
311
|
n = normalize_count(count)
|
|
315
312
|
return if @cursor == text.length
|
|
@@ -352,56 +349,66 @@ module Fatty
|
|
|
352
349
|
killed
|
|
353
350
|
end
|
|
354
351
|
|
|
355
|
-
desc "Kill count words after the cursor
|
|
352
|
+
desc "Kill count words after the cursor, or kill the active region"
|
|
356
353
|
action :kill_word_forward do |count: 1|
|
|
357
|
-
|
|
358
|
-
|
|
354
|
+
if region_active?
|
|
355
|
+
kill_region
|
|
356
|
+
else
|
|
357
|
+
n = normalize_count(count)
|
|
358
|
+
return "" if eol?
|
|
359
359
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
360
|
+
deleted = ""
|
|
361
|
+
with_undo do
|
|
362
|
+
start = cursor
|
|
363
|
+
finish = start
|
|
364
|
+
|
|
365
|
+
repeat(n) do
|
|
366
|
+
break if finish >= text.length
|
|
366
367
|
|
|
367
|
-
|
|
368
|
-
|
|
368
|
+
span = word_span_forward(finish)
|
|
369
|
+
break if span.begin == span.end
|
|
370
|
+
|
|
371
|
+
finish = span.end
|
|
372
|
+
end
|
|
369
373
|
|
|
370
|
-
|
|
374
|
+
deleted = delete_range(start...finish)
|
|
375
|
+
@cursor = start
|
|
376
|
+
push_kill(deleted)
|
|
377
|
+
@last_action = :kill
|
|
371
378
|
end
|
|
372
379
|
|
|
373
|
-
deleted
|
|
374
|
-
@cursor = start
|
|
375
|
-
push_kill(deleted)
|
|
376
|
-
@last_action = :kill
|
|
380
|
+
deleted
|
|
377
381
|
end
|
|
378
|
-
deleted
|
|
379
382
|
end
|
|
380
383
|
|
|
381
384
|
desc "Kill count words before the cursor and return the deleted string"
|
|
382
385
|
action :kill_word_backward do |count: 1|
|
|
383
|
-
|
|
384
|
-
|
|
386
|
+
if region_active?
|
|
387
|
+
kill_region
|
|
388
|
+
else
|
|
389
|
+
n = normalize_count(count)
|
|
390
|
+
return "" if bol?
|
|
385
391
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
+
deleted = ""
|
|
393
|
+
with_undo do
|
|
394
|
+
finish = cursor
|
|
395
|
+
start = finish
|
|
396
|
+
repeat(n) do
|
|
397
|
+
break if start <= 0
|
|
392
398
|
|
|
393
|
-
|
|
394
|
-
|
|
399
|
+
span = word_span_backward(start)
|
|
400
|
+
break if span.begin == span.end
|
|
395
401
|
|
|
396
|
-
|
|
397
|
-
|
|
402
|
+
start = span.begin
|
|
403
|
+
end
|
|
398
404
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
405
|
+
deleted = delete_range(start...finish)
|
|
406
|
+
@cursor = start
|
|
407
|
+
push_kill(deleted)
|
|
408
|
+
@last_action = :kill
|
|
409
|
+
end
|
|
410
|
+
deleted
|
|
403
411
|
end
|
|
404
|
-
deleted
|
|
405
412
|
end
|
|
406
413
|
|
|
407
414
|
desc "Transpose the two characters around point."
|
|
@@ -707,6 +714,23 @@ module Fatty
|
|
|
707
714
|
|
|
708
715
|
private
|
|
709
716
|
|
|
717
|
+
# simplecov:disable
|
|
718
|
+
|
|
719
|
+
def normalize_word_char_re(value)
|
|
720
|
+
case value
|
|
721
|
+
when Regexp
|
|
722
|
+
value
|
|
723
|
+
when String
|
|
724
|
+
value = value.strip
|
|
725
|
+
if value.start_with?("/") && value.end_with?("/") && value.length >= 2
|
|
726
|
+
value[1...-1]
|
|
727
|
+
else
|
|
728
|
+
value
|
|
729
|
+
end
|
|
730
|
+
Regexp.new(value)
|
|
731
|
+
end
|
|
732
|
+
end
|
|
733
|
+
|
|
710
734
|
def move_word_right_once
|
|
711
735
|
break_undo_chain!
|
|
712
736
|
chars = virtual_text.chars
|
|
@@ -992,7 +1016,7 @@ module Fatty
|
|
|
992
1016
|
end
|
|
993
1017
|
|
|
994
1018
|
def word_char?(ch)
|
|
995
|
-
@
|
|
1019
|
+
@word_char_re.match?(ch)
|
|
996
1020
|
end
|
|
997
1021
|
end
|
|
998
1022
|
end
|