textbringer 13 → 15

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.
@@ -0,0 +1,101 @@
1
+ require "set"
2
+
3
+ module Textbringer
4
+ # Transient Mark Mode is a global minor mode that highlights
5
+ # the region between mark and point when the mark is active.
6
+ class TransientMarkMode < GlobalMinorMode
7
+ # Commands that should NOT deactivate the mark
8
+ MARK_PRESERVING_COMMANDS = [
9
+ :set_mark_command,
10
+ :exchange_point_and_mark,
11
+ :transient_mark_mode,
12
+ # Navigation commands that should preserve mark
13
+ :beginning_of_line,
14
+ :end_of_line,
15
+ :next_line,
16
+ :previous_line,
17
+ :forward_char,
18
+ :backward_char,
19
+ :forward_word,
20
+ :backward_word,
21
+ :scroll_up_command,
22
+ :scroll_down_command,
23
+ :beginning_of_buffer,
24
+ :end_of_buffer,
25
+ # Search commands
26
+ :isearch_forward,
27
+ :isearch_backward,
28
+ :isearch_repeat_forward,
29
+ :isearch_repeat_backward,
30
+ :isearch_printing_char,
31
+ # Undo/redo
32
+ :undo,
33
+ :redo_command,
34
+ # Other navigation
35
+ :goto_line,
36
+ :goto_char,
37
+ :recenter,
38
+ :move_to_beginning_of_line,
39
+ :move_to_end_of_line
40
+ ].to_set.freeze
41
+
42
+ # Hook to deactivate mark before most commands
43
+ PRE_COMMAND_HOOK = -> {
44
+ buffer = Buffer.current
45
+ controller = Controller.current
46
+
47
+ return unless buffer.mark_active?
48
+
49
+ # Check if this command preserves the mark
50
+ command = controller.this_command
51
+ unless MARK_PRESERVING_COMMANDS.include?(command)
52
+ buffer.deactivate_mark
53
+ end
54
+ }
55
+
56
+ # Hook to update visible mark after commands
57
+ POST_COMMAND_HOOK = -> {
58
+ buffer = Buffer.current
59
+
60
+ # Skip if in isearch or ispell mode (they manage their own highlighting)
61
+ controller = Controller.current
62
+ if controller.overriding_map
63
+ return if Commands.const_defined?(:ISEARCH_MODE_MAP) &&
64
+ controller.overriding_map == Commands::ISEARCH_MODE_MAP
65
+ return if Commands.const_defined?(:ISPELL_MODE_MAP) &&
66
+ controller.overriding_map == Commands::ISPELL_MODE_MAP
67
+ end
68
+
69
+ # Update visible_mark to reflect mark_active state
70
+ if buffer.mark_active?
71
+ begin
72
+ mark = buffer.mark
73
+ buffer.set_visible_mark(mark.location) if mark
74
+ rescue EditorError
75
+ # Mark is not set, do nothing
76
+ end
77
+ elsif !buffer.mark_active? && buffer.visible_mark
78
+ buffer.delete_visible_mark
79
+ end
80
+ }
81
+
82
+ def self.enable
83
+ # Add global hooks (not buffer-local)
84
+ add_hook(:pre_command_hook, PRE_COMMAND_HOOK, local: false)
85
+ add_hook(:post_command_hook, POST_COMMAND_HOOK, local: false)
86
+ message("Transient Mark mode enabled")
87
+ end
88
+
89
+ def self.disable
90
+ # Remove global hooks
91
+ remove_hook(:pre_command_hook, PRE_COMMAND_HOOK, local: false)
92
+ remove_hook(:post_command_hook, POST_COMMAND_HOOK, local: false)
93
+
94
+ # Deactivate mark in all buffers
95
+ Buffer.list.each do |buffer|
96
+ buffer.deactivate_mark
97
+ end
98
+ message("Transient Mark mode disabled")
99
+ end
100
+ end
101
+ end
@@ -134,7 +134,6 @@ module Textbringer
134
134
  end
135
135
 
136
136
  COMPLETION = {
137
- original_buffer: nil,
138
137
  completions_window: nil
139
138
  }
140
139
 
@@ -186,11 +185,14 @@ module Textbringer
186
185
  Buffer.minibuffer.keymap = old_minibuffer_map
187
186
  Buffer.minibuffer.disable_input_method
188
187
  Controller.current.current_prefix_arg = old_current_prefix_arg
189
- if COMPLETION[:original_buffer]
190
- COMPLETION[:completions_window].buffer = COMPLETION[:original_buffer]
191
- COMPLETION[:completions_window] = nil
192
- COMPLETION[:original_buffer] = nil
193
- end
188
+ delete_completions_window
189
+ end
190
+ end
191
+
192
+ def delete_completions_window
193
+ if COMPLETION[:completions_window]
194
+ Window.delete_window(COMPLETION[:completions_window])
195
+ COMPLETION[:completions_window] = nil
194
196
  end
195
197
  end
196
198
 
@@ -1,3 +1,3 @@
1
1
  module Textbringer
2
- VERSION = "13"
2
+ VERSION = "15"
3
3
  end
data/lib/textbringer.rb CHANGED
@@ -14,7 +14,9 @@ require_relative "textbringer/commands/windows"
14
14
  require_relative "textbringer/commands/files"
15
15
  require_relative "textbringer/commands/misc"
16
16
  require_relative "textbringer/commands/isearch"
17
+ require_relative "textbringer/commands/ispell"
17
18
  require_relative "textbringer/commands/replace"
19
+ require_relative "textbringer/commands/rectangle"
18
20
  require_relative "textbringer/commands/dabbrev"
19
21
  require_relative "textbringer/commands/ctags"
20
22
  require_relative "textbringer/commands/clipboard"
@@ -35,7 +37,9 @@ require_relative "textbringer/modes/completion_list_mode"
35
37
  require_relative "textbringer/modes/buffer_list_mode"
36
38
  require_relative "textbringer/modes/help_mode"
37
39
  require_relative "textbringer/minor_mode"
40
+ require_relative "textbringer/global_minor_mode"
38
41
  require_relative "textbringer/modes/overwrite_mode"
42
+ require_relative "textbringer/modes/transient_mark_mode"
39
43
  require_relative "textbringer/input_method"
40
44
  require_relative "textbringer/input_methods/t_code_input_method"
41
45
  require_relative "textbringer/input_methods/hiragana_input_method"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: textbringer
3
3
  version: !ruby/object:Gem::Version
4
- version: '13'
4
+ version: '15'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugo Maeda
@@ -329,6 +329,7 @@ extensions: []
329
329
  extra_rdoc_files: []
330
330
  files:
331
331
  - CHANGES.md
332
+ - CLAUDE.md
332
333
  - Gemfile
333
334
  - LICENSE.txt
334
335
  - README.ja.md
@@ -352,8 +353,10 @@ files:
352
353
  - lib/textbringer/commands/help.rb
353
354
  - lib/textbringer/commands/input_method.rb
354
355
  - lib/textbringer/commands/isearch.rb
356
+ - lib/textbringer/commands/ispell.rb
355
357
  - lib/textbringer/commands/keyboard_macro.rb
356
358
  - lib/textbringer/commands/misc.rb
359
+ - lib/textbringer/commands/rectangle.rb
357
360
  - lib/textbringer/commands/register.rb
358
361
  - lib/textbringer/commands/replace.rb
359
362
  - lib/textbringer/commands/server.rb
@@ -366,6 +369,7 @@ files:
366
369
  - lib/textbringer/face.rb
367
370
  - lib/textbringer/faces/basic.rb
368
371
  - lib/textbringer/faces/programming.rb
372
+ - lib/textbringer/global_minor_mode.rb
369
373
  - lib/textbringer/input_method.rb
370
374
  - lib/textbringer/input_methods/hangul_input_method.rb
371
375
  - lib/textbringer/input_methods/hiragana_input_method.rb
@@ -383,6 +387,7 @@ files:
383
387
  - lib/textbringer/modes/overwrite_mode.rb
384
388
  - lib/textbringer/modes/programming_mode.rb
385
389
  - lib/textbringer/modes/ruby_mode.rb
390
+ - lib/textbringer/modes/transient_mark_mode.rb
386
391
  - lib/textbringer/plugin.rb
387
392
  - lib/textbringer/ring.rb
388
393
  - lib/textbringer/utils.rb
@@ -409,7 +414,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
409
414
  - !ruby/object:Gem::Version
410
415
  version: '0'
411
416
  requirements: []
412
- rubygems_version: 3.6.7
417
+ rubygems_version: 3.6.9
413
418
  specification_version: 4
414
419
  summary: An Emacs-like text editor
415
420
  test_files: []