textbringer 18 → 19
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/exe/txtb +1 -1
- data/lib/textbringer/buffer.rb +23 -2
- data/lib/textbringer/commands/clipboard.rb +21 -6
- data/lib/textbringer/commands/completion.rb +133 -0
- data/lib/textbringer/commands/ctags.rb +1 -1
- data/lib/textbringer/commands/files.rb +11 -1
- data/lib/textbringer/commands/help.rb +1 -1
- data/lib/textbringer/commands/ispell.rb +0 -2
- data/lib/textbringer/commands/lsp.rb +389 -0
- data/lib/textbringer/commands/misc.rb +2 -1
- data/lib/textbringer/commands.rb +7 -3
- data/lib/textbringer/completion_popup.rb +188 -0
- data/lib/textbringer/faces/basic.rb +1 -0
- data/lib/textbringer/faces/completion.rb +4 -0
- data/lib/textbringer/floating_window.rb +327 -0
- data/lib/textbringer/input_methods/skk_input_method.rb +751 -0
- data/lib/textbringer/lsp/client.rb +568 -0
- data/lib/textbringer/lsp/server_registry.rb +138 -0
- data/lib/textbringer/mode.rb +3 -1
- data/lib/textbringer/modes/programming_mode.rb +17 -8
- data/lib/textbringer/modes/transient_mark_mode.rb +5 -2
- data/lib/textbringer/utils.rb +14 -10
- data/lib/textbringer/version.rb +1 -1
- data/lib/textbringer/window.rb +36 -9
- data/lib/textbringer.rb +7 -0
- data/sig/lib/textbringer/buffer.rbs +483 -0
- data/sig/lib/textbringer/color.rbs +9 -0
- data/sig/lib/textbringer/commands/buffers.rbs +93 -0
- data/sig/lib/textbringer/commands/clipboard.rbs +17 -0
- data/sig/lib/textbringer/commands/completion.rbs +20 -0
- data/sig/lib/textbringer/commands/ctags.rbs +11 -0
- data/sig/lib/textbringer/commands/dabbrev.rbs +4 -0
- data/sig/lib/textbringer/commands/files.rbs +29 -0
- data/sig/lib/textbringer/commands/fill.rbs +5 -0
- data/sig/lib/textbringer/commands/help.rbs +28 -0
- data/sig/lib/textbringer/commands/input_method.rbs +6 -0
- data/sig/lib/textbringer/commands/isearch.rbs +38 -0
- data/sig/lib/textbringer/commands/ispell.rbs +39 -0
- data/sig/lib/textbringer/commands/keyboard_macro.rbs +25 -0
- data/sig/lib/textbringer/commands/lsp.rbs +8 -0
- data/sig/lib/textbringer/commands/misc.rbs +74 -0
- data/sig/lib/textbringer/commands/rectangle.rbs +19 -0
- data/sig/lib/textbringer/commands/register.rbs +31 -0
- data/sig/lib/textbringer/commands/replace.rbs +17 -0
- data/sig/lib/textbringer/commands/server.rbs +31 -0
- data/sig/lib/textbringer/commands/ucs_normalize.rbs +9 -0
- data/sig/lib/textbringer/commands/windows.rbs +45 -0
- data/sig/lib/textbringer/commands.rbs +21 -0
- data/sig/lib/textbringer/completion_popup.rbs +40 -0
- data/sig/lib/textbringer/controller.rbs +58 -0
- data/sig/lib/textbringer/default_output.rbs +7 -0
- data/sig/lib/textbringer/errors.rbs +3 -0
- data/sig/lib/textbringer/face.rbs +19 -0
- data/sig/lib/textbringer/floating_window.rbs +42 -0
- data/sig/lib/textbringer/global_minor_mode.rbs +7 -0
- data/sig/lib/textbringer/input_method.rbs +28 -0
- data/sig/lib/textbringer/input_methods/hangul_input_method.rbs +12 -0
- data/sig/lib/textbringer/input_methods/hiragana_input_method.rbs +12 -0
- data/sig/lib/textbringer/input_methods/t_code_input_method.rbs +49 -0
- data/sig/lib/textbringer/keymap.rbs +33 -0
- data/sig/lib/textbringer/lsp/client.rbs +21 -0
- data/sig/lib/textbringer/lsp/server_registry.rbs +23 -0
- data/sig/lib/textbringer/minor_mode.rbs +12 -0
- data/sig/lib/textbringer/mode.rbs +70 -0
- data/sig/lib/textbringer/modes/backtrace_mode.rbs +8 -0
- data/sig/lib/textbringer/modes/buffer_list_mode.rbs +5 -0
- data/sig/lib/textbringer/modes/c_mode.rbs +21 -0
- data/sig/lib/textbringer/modes/completion_list_mode.rbs +5 -0
- data/sig/lib/textbringer/modes/fundamental_mode.rbs +3 -0
- data/sig/lib/textbringer/modes/help_mode.rbs +7 -0
- data/sig/lib/textbringer/modes/overwrite_mode.rbs +15 -0
- data/sig/lib/textbringer/modes/programming_mode.rbs +14 -0
- data/sig/lib/textbringer/modes/ruby_mode.rbs +57 -0
- data/sig/lib/textbringer/plugin.rbs +3 -0
- data/sig/lib/textbringer/ring.rbs +36 -0
- data/sig/lib/textbringer/utils.rbs +95 -0
- data/sig/lib/textbringer/window.rbs +183 -0
- data/textbringer.gemspec +1 -0
- metadata +76 -2
|
@@ -3,14 +3,23 @@ module Textbringer
|
|
|
3
3
|
# abstract mode
|
|
4
4
|
undefine_command(:programming_mode)
|
|
5
5
|
|
|
6
|
-
define_generic_command :indent_line
|
|
7
|
-
|
|
8
|
-
define_generic_command :
|
|
9
|
-
|
|
10
|
-
define_generic_command :
|
|
11
|
-
|
|
12
|
-
define_generic_command :
|
|
13
|
-
|
|
6
|
+
define_generic_command :indent_line,
|
|
7
|
+
doc: "Indent the current line."
|
|
8
|
+
define_generic_command :reindent_then_newline_and_indent,
|
|
9
|
+
doc: "Reindent the current line, insert a new line, then indent the new line."
|
|
10
|
+
define_generic_command :indent_region,
|
|
11
|
+
doc: "Indent the region."
|
|
12
|
+
define_generic_command :forward_definition,
|
|
13
|
+
doc: "Go to the next definition of a class, method etc."
|
|
14
|
+
define_generic_command :backward_definition,
|
|
15
|
+
doc: "Go to the preivous definition of a class, method etc."
|
|
16
|
+
define_generic_command :compile,
|
|
17
|
+
doc: "Compile the program including the current buffer."
|
|
18
|
+
define_generic_command :toggle_test,
|
|
19
|
+
doc: "Open the test file corresponding to the current buffer. " \
|
|
20
|
+
"If the current buffer is a test file, open the file of the code under test."
|
|
21
|
+
define_generic_command :indent_new_comment_line,
|
|
22
|
+
doc: "Break line at point and indent, continuing comment if within one."
|
|
14
23
|
|
|
15
24
|
define_keymap :PROGRAMMING_MODE_MAP
|
|
16
25
|
PROGRAMMING_MODE_MAP.define_key("\t", :indent_line_command)
|
|
@@ -40,8 +40,11 @@ module Textbringer
|
|
|
40
40
|
:goto_char,
|
|
41
41
|
:recenter,
|
|
42
42
|
:move_to_beginning_of_line,
|
|
43
|
-
:move_to_end_of_line
|
|
44
|
-
|
|
43
|
+
:move_to_end_of_line,
|
|
44
|
+
# Other commands
|
|
45
|
+
:execute_command,
|
|
46
|
+
:eval_expression
|
|
47
|
+
].to_set
|
|
45
48
|
|
|
46
49
|
# Hook to deactivate mark before most commands
|
|
47
50
|
PRE_COMMAND_HOOK = -> {
|
data/lib/textbringer/utils.rb
CHANGED
|
@@ -145,7 +145,8 @@ module Textbringer
|
|
|
145
145
|
"Command attempted to use minibuffer while in minibuffer"
|
|
146
146
|
end
|
|
147
147
|
old_buffer = Buffer.current
|
|
148
|
-
|
|
148
|
+
old_minibuffer_selected = Window.minibuffer_selected
|
|
149
|
+
Window.minibuffer_selected = Window.current
|
|
149
150
|
old_completion_proc = Buffer.minibuffer[:completion_proc]
|
|
150
151
|
old_completion_ignore_case = Buffer.minibuffer[:completion_ignore_case]
|
|
151
152
|
old_current_prefix_arg = Controller.current.current_prefix_arg
|
|
@@ -176,10 +177,11 @@ module Textbringer
|
|
|
176
177
|
Window.echo_area.redisplay
|
|
177
178
|
Window.update
|
|
178
179
|
Window.echo_area.active = false
|
|
179
|
-
Window.current =
|
|
180
|
-
# Just in case
|
|
180
|
+
Window.current = Window.minibuffer_selected
|
|
181
|
+
# Just in case Window.minibuffer_selected has been deleted by resize,
|
|
181
182
|
# in which case Window.current is set to the first window.
|
|
182
183
|
Window.current.buffer = Buffer.current = old_buffer
|
|
184
|
+
Window.minibuffer_selected = old_minibuffer_selected
|
|
183
185
|
Buffer.minibuffer[:completion_ignore_case] = old_completion_ignore_case
|
|
184
186
|
Buffer.minibuffer[:completion_proc] = old_completion_proc
|
|
185
187
|
Buffer.minibuffer.keymap = old_minibuffer_map
|
|
@@ -373,20 +375,22 @@ module Textbringer
|
|
|
373
375
|
end
|
|
374
376
|
end
|
|
375
377
|
|
|
376
|
-
def run_hooks(name, remove_on_error: false)
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
378
|
+
def run_hooks(name, *args, remove_on_error: false)
|
|
379
|
+
if Buffer.current
|
|
380
|
+
hooks = Buffer.current[:hooks]
|
|
381
|
+
run_hooks_in(hooks, name, *args, remove_on_error:) if hooks
|
|
382
|
+
end
|
|
383
|
+
run_hooks_in(HOOKS, name, *args, remove_on_error:)
|
|
380
384
|
end
|
|
381
385
|
|
|
382
|
-
def run_hooks_in(hooks, name, remove_on_error: false)
|
|
386
|
+
def run_hooks_in(hooks, name, *args, remove_on_error: false)
|
|
383
387
|
hooks[name].delete_if do |func|
|
|
384
388
|
begin
|
|
385
389
|
case func
|
|
386
390
|
when Symbol
|
|
387
|
-
send(func)
|
|
391
|
+
send(func, *args)
|
|
388
392
|
else
|
|
389
|
-
func.call
|
|
393
|
+
func.call(*args)
|
|
390
394
|
end
|
|
391
395
|
false
|
|
392
396
|
rescue Exception => e
|
data/lib/textbringer/version.rb
CHANGED
data/lib/textbringer/window.rb
CHANGED
|
@@ -20,6 +20,7 @@ module Textbringer
|
|
|
20
20
|
@@started = false
|
|
21
21
|
@@list = []
|
|
22
22
|
@@current = nil
|
|
23
|
+
@@minibuffer_selected = nil
|
|
23
24
|
@@echo_area = nil
|
|
24
25
|
@@has_colors = false
|
|
25
26
|
|
|
@@ -45,6 +46,18 @@ module Textbringer
|
|
|
45
46
|
Buffer.current = window.buffer
|
|
46
47
|
end
|
|
47
48
|
|
|
49
|
+
class << self
|
|
50
|
+
alias selected current
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def self.minibuffer_selected
|
|
54
|
+
@@minibuffer_selected
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def self.minibuffer_selected=(window)
|
|
58
|
+
@@minibuffer_selected = window
|
|
59
|
+
end
|
|
60
|
+
|
|
48
61
|
def self.delete_window(target = @@current)
|
|
49
62
|
if target.echo_area?
|
|
50
63
|
raise EditorError, "Can't delete the echo area"
|
|
@@ -117,6 +130,7 @@ module Textbringer
|
|
|
117
130
|
def self.load_faces
|
|
118
131
|
require_relative "faces/basic"
|
|
119
132
|
require_relative "faces/programming"
|
|
133
|
+
require_relative "faces/completion"
|
|
120
134
|
end
|
|
121
135
|
|
|
122
136
|
def self.start
|
|
@@ -166,6 +180,15 @@ module Textbringer
|
|
|
166
180
|
window.redisplay unless window.current?
|
|
167
181
|
end
|
|
168
182
|
current.redisplay
|
|
183
|
+
if defined?(FloatingWindow)
|
|
184
|
+
# Render floating windows on top
|
|
185
|
+
FloatingWindow.redisplay_all_floating
|
|
186
|
+
# Ensure cursor position is from the current window, not floating windows
|
|
187
|
+
# Refresh current window's cursor position after floating windows
|
|
188
|
+
if !FloatingWindow.floating_windows.empty?
|
|
189
|
+
current&.window&.noutrefresh
|
|
190
|
+
end
|
|
191
|
+
end
|
|
169
192
|
update
|
|
170
193
|
end
|
|
171
194
|
|
|
@@ -217,7 +240,7 @@ module Textbringer
|
|
|
217
240
|
end
|
|
218
241
|
|
|
219
242
|
attr_reader :buffer, :lines, :columns, :y, :x, :window, :mode_line
|
|
220
|
-
attr_reader :top_of_window, :bottom_of_window
|
|
243
|
+
attr_reader :top_of_window, :bottom_of_window, :cursor
|
|
221
244
|
|
|
222
245
|
def initialize(lines, columns, y, x)
|
|
223
246
|
@lines = lines
|
|
@@ -298,6 +321,10 @@ module Textbringer
|
|
|
298
321
|
self == @@current
|
|
299
322
|
end
|
|
300
323
|
|
|
324
|
+
def current_or_minibuffer_selected?
|
|
325
|
+
self == @@current || self == @@minibuffer_selected
|
|
326
|
+
end
|
|
327
|
+
|
|
301
328
|
def read_event
|
|
302
329
|
key = get_char
|
|
303
330
|
if key.is_a?(Integer)
|
|
@@ -411,12 +438,12 @@ module Textbringer
|
|
|
411
438
|
@in_region = false
|
|
412
439
|
@in_isearch = false
|
|
413
440
|
@current_highlight_attrs = 0
|
|
414
|
-
if
|
|
441
|
+
if current_or_minibuffer_selected? && @buffer.visible_mark &&
|
|
415
442
|
@buffer.point_after_mark?(@buffer.visible_mark)
|
|
416
443
|
@window.attron(region_attr)
|
|
417
444
|
@in_region = true
|
|
418
445
|
end
|
|
419
|
-
if
|
|
446
|
+
if current_or_minibuffer_selected? && @buffer.isearch_mark &&
|
|
420
447
|
@buffer.point_after_mark?(@buffer.isearch_mark)
|
|
421
448
|
# If already in region, switch to isearch (priority)
|
|
422
449
|
if @in_region
|
|
@@ -490,10 +517,10 @@ module Textbringer
|
|
|
490
517
|
break if newx == columns && cury == lines - 2
|
|
491
518
|
@buffer.forward_char
|
|
492
519
|
end
|
|
493
|
-
if
|
|
520
|
+
if current_or_minibuffer_selected? && @buffer.isearch_mark
|
|
494
521
|
@window.attroff(isearch_attr)
|
|
495
522
|
end
|
|
496
|
-
if
|
|
523
|
+
if current_or_minibuffer_selected? && @buffer.visible_mark
|
|
497
524
|
@window.attroff(region_attr)
|
|
498
525
|
end
|
|
499
526
|
@buffer.mark_to_point(@bottom_of_window)
|
|
@@ -723,7 +750,7 @@ module Textbringer
|
|
|
723
750
|
@cursor.y = cury
|
|
724
751
|
@cursor.x = curx
|
|
725
752
|
# Handle visible mark transitions
|
|
726
|
-
if
|
|
753
|
+
if current_or_minibuffer_selected? && @buffer.visible_mark
|
|
727
754
|
if @buffer.point_after_mark?(@buffer.visible_mark)
|
|
728
755
|
unless @in_isearch
|
|
729
756
|
@window.attroff(region_attr)
|
|
@@ -741,7 +768,7 @@ module Textbringer
|
|
|
741
768
|
end
|
|
742
769
|
end
|
|
743
770
|
# Handle isearch mark transitions
|
|
744
|
-
if
|
|
771
|
+
if current_or_minibuffer_selected? && @buffer.isearch_mark
|
|
745
772
|
if @buffer.point_after_mark?(@buffer.isearch_mark)
|
|
746
773
|
@window.attroff(isearch_attr)
|
|
747
774
|
@in_isearch = false
|
|
@@ -762,7 +789,7 @@ module Textbringer
|
|
|
762
789
|
end
|
|
763
790
|
end
|
|
764
791
|
# Handle transitions when point crosses isearch mark
|
|
765
|
-
if
|
|
792
|
+
if current_or_minibuffer_selected? && @buffer.isearch_mark &&
|
|
766
793
|
@buffer.point_at_mark?(@buffer.isearch_mark)
|
|
767
794
|
if @buffer.point_after_mark?(point)
|
|
768
795
|
@window.attroff(isearch_attr)
|
|
@@ -783,7 +810,7 @@ module Textbringer
|
|
|
783
810
|
end
|
|
784
811
|
end
|
|
785
812
|
# Handle transitions when point crosses visible mark
|
|
786
|
-
if
|
|
813
|
+
if current_or_minibuffer_selected? && @buffer.visible_mark &&
|
|
787
814
|
@buffer.point_at_mark?(@buffer.visible_mark)
|
|
788
815
|
if @buffer.point_after_mark?(point)
|
|
789
816
|
unless @in_isearch
|
data/lib/textbringer.rb
CHANGED
|
@@ -4,10 +4,14 @@ require_relative "textbringer/errors"
|
|
|
4
4
|
require_relative "textbringer/ring"
|
|
5
5
|
require_relative "textbringer/buffer"
|
|
6
6
|
require_relative "textbringer/window"
|
|
7
|
+
require_relative "textbringer/floating_window"
|
|
7
8
|
require_relative "textbringer/keymap"
|
|
8
9
|
require_relative "textbringer/utils"
|
|
9
10
|
require_relative "textbringer/color"
|
|
10
11
|
require_relative "textbringer/face"
|
|
12
|
+
require_relative "textbringer/completion_popup"
|
|
13
|
+
require_relative "textbringer/lsp/client"
|
|
14
|
+
require_relative "textbringer/lsp/server_registry"
|
|
11
15
|
require_relative "textbringer/commands"
|
|
12
16
|
require_relative "textbringer/commands/buffers"
|
|
13
17
|
require_relative "textbringer/commands/windows"
|
|
@@ -27,6 +31,8 @@ require_relative "textbringer/commands/server"
|
|
|
27
31
|
require_relative "textbringer/commands/input_method"
|
|
28
32
|
require_relative "textbringer/commands/ucs_normalize"
|
|
29
33
|
require_relative "textbringer/commands/help"
|
|
34
|
+
require_relative "textbringer/commands/completion"
|
|
35
|
+
require_relative "textbringer/commands/lsp"
|
|
30
36
|
require_relative "textbringer/mode"
|
|
31
37
|
require_relative "textbringer/modes/fundamental_mode"
|
|
32
38
|
require_relative "textbringer/modes/programming_mode"
|
|
@@ -44,6 +50,7 @@ require_relative "textbringer/input_method"
|
|
|
44
50
|
require_relative "textbringer/input_methods/t_code_input_method"
|
|
45
51
|
require_relative "textbringer/input_methods/hiragana_input_method"
|
|
46
52
|
require_relative "textbringer/input_methods/hangul_input_method"
|
|
53
|
+
require_relative "textbringer/input_methods/skk_input_method"
|
|
47
54
|
require_relative "textbringer/plugin"
|
|
48
55
|
require_relative "textbringer/controller"
|
|
49
56
|
require_relative "textbringer/default_output"
|