textbringer 17 → 18

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: afebafd9a22024be2bc3c4c5c2140ac9ad3b7fa7a1efc25e0ae9bf4d38c3da10
4
- data.tar.gz: 53841ecd93d7b63e9d33a07d39721f90bf0d39e6803406287518601d67d4a59c
3
+ metadata.gz: 6880825c5cf726a2e49e28052cb09c0e8f0a15eadbf98b38e8806e6b486b9475
4
+ data.tar.gz: 79cef469e62da96630672057fda32b69ccdd349f76df36821f45a71be7e552d5
5
5
  SHA512:
6
- metadata.gz: 469ef80d72998003e1d5ca9e6c499b70debc5d1c2c09b43b9b79311e94ce15c22adbd766bf31cafaa20a5ac11a19c8b12d9c8392d166cec5a617305c4a50e43f
7
- data.tar.gz: 6908288f0debd4001c131327071962fda1392ff0310f26fc72b9f0391b01e281b22824c78e78d2be69cd89b5fc768c7239d116bd35699d1483c4fa944aae76be
6
+ metadata.gz: 868b9d1cce93bf0dc1dabdb4e59c0dd775210c700b794b7093bfedb82d95d7d9e82191fc1d05daa9342e282d151567aa4d0d85a93f489ced5165e7d537d1e102
7
+ data.tar.gz: afad73fc5062774e6aa9b4d7cfa175be24f2dc25c9345218359ddce61f0049dcd7059709fe72c52c71d15d5625393a46987d0df04a36dbdc19d3855df02a8dab
@@ -10,7 +10,7 @@ module Textbringer
10
10
 
11
11
  attr_accessor :mode, :keymap
12
12
  attr_reader :name, :file_name, :file_encoding, :file_format, :point, :marks
13
- attr_reader :current_line, :current_column, :visible_mark, :mark_active
13
+ attr_reader :current_line, :current_column, :visible_mark, :isearch_mark, :mark_active
14
14
  attr_reader :last_match
15
15
  attr_reader :input_method
16
16
 
@@ -254,6 +254,7 @@ module Textbringer
254
254
  @save_point_level = 0
255
255
  @match_offsets = []
256
256
  @visible_mark = nil
257
+ @isearch_mark = nil
257
258
  @mark_active = false
258
259
  @read_only = read_only
259
260
  @callbacks = {}
@@ -948,6 +949,18 @@ module Textbringer
948
949
  end
949
950
  end
950
951
 
952
+ def set_isearch_mark(pos = @point)
953
+ @isearch_mark ||= new_mark
954
+ @isearch_mark.location = pos
955
+ end
956
+
957
+ def delete_isearch_mark
958
+ if @isearch_mark
959
+ @isearch_mark.delete
960
+ @isearch_mark = nil
961
+ end
962
+ end
963
+
951
964
  def activate_mark
952
965
  @mark_active = true
953
966
  set_visible_mark(@mark.location) if @mark
@@ -96,7 +96,8 @@ module Textbringer
96
96
  buffer = Buffer.current
97
97
  buffer.exchange_point_and_mark
98
98
  # Activate mark if transient mark mode is enabled
99
- if TransientMarkMode.enabled?
99
+ if TransientMarkMode.enabled? &&
100
+ Controller.current.this_command == :exchange_point_and_mark
100
101
  buffer.activate_mark
101
102
  end
102
103
  end
@@ -153,7 +154,8 @@ module Textbringer
153
154
  else
154
155
  buffer.push_mark
155
156
  # Activate mark if transient mark mode is enabled
156
- if TransientMarkMode.enabled?
157
+ if TransientMarkMode.enabled? &&
158
+ Controller.current.this_command == :set_mark_command
157
159
  buffer.activate_mark
158
160
  end
159
161
  message("Mark set")
@@ -77,10 +77,7 @@ module Textbringer
77
77
  end
78
78
 
79
79
  def isearch_done
80
- # Don't delete visible_mark if mark is active (transient mark mode)
81
- unless Buffer.current.mark_active?
82
- Buffer.current.delete_visible_mark
83
- end
80
+ Buffer.current.delete_isearch_mark
84
81
  Controller.current.overriding_map = nil
85
82
  remove_hook(:pre_command_hook, :isearch_pre_command_hook)
86
83
  ISEARCH_STATUS[:last_string] = ISEARCH_STATUS[:string]
@@ -94,7 +91,7 @@ module Textbringer
94
91
  end
95
92
 
96
93
  define_command(:isearch_abort, doc: "Abort incremental search.") do
97
- goto_char(Buffer.current[:isearch_start])
94
+ goto_char(ISEARCH_STATUS[:start])
98
95
  isearch_done
99
96
  raise Quit
100
97
  end
@@ -157,11 +154,8 @@ module Textbringer
157
154
  if Buffer.current != Buffer.minibuffer
158
155
  message(isearch_prompt + ISEARCH_STATUS[:string], log: false)
159
156
  end
160
- # Don't update visible_mark if mark is already active (transient mark mode)
161
- unless Buffer.current.mark_active?
162
- Buffer.current.set_visible_mark(forward ? match_beginning(0) :
163
- match_end(0))
164
- end
157
+ Buffer.current.set_isearch_mark(forward ? match_beginning(0) :
158
+ match_end(0))
165
159
  goto_char(forward ? match_end(0) : match_beginning(0))
166
160
  else
167
161
  if Buffer.current != Buffer.minibuffer
@@ -2,5 +2,6 @@ module Textbringer
2
2
  Face.define :mode_line, reverse: true
3
3
  Face.define :link, foreground: "blue", bold: true
4
4
  Face.define :control
5
- Face.define :region, background: "blue"
5
+ Face.define :region, background: "blue", foreground: "white"
6
+ Face.define :isearch, background: "yellow", foreground: "black"
6
7
  end
@@ -28,6 +28,10 @@ module Textbringer
28
28
  :isearch_repeat_forward,
29
29
  :isearch_repeat_backward,
30
30
  :isearch_printing_char,
31
+ :isearch_delete_char,
32
+ :isearch_yank_word_or_char,
33
+ :isearch_quoted_insert,
34
+ :isearch_exit,
31
35
  # Undo/redo
32
36
  :undo,
33
37
  :redo_command,
@@ -1,3 +1,3 @@
1
1
  module Textbringer
2
- VERSION = "17"
2
+ VERSION = "18"
3
3
  end
@@ -237,6 +237,7 @@ module Textbringer
237
237
  @key_buffer = []
238
238
  @cursor = Cursor.new(0, 0)
239
239
  @in_region = false
240
+ @in_isearch = false
240
241
  @current_highlight_attrs = 0
241
242
  end
242
243
 
@@ -408,18 +409,28 @@ module Textbringer
408
409
  @window.setpos(0, 0)
409
410
  @window.attrset(0)
410
411
  @in_region = false
412
+ @in_isearch = false
411
413
  @current_highlight_attrs = 0
412
414
  if current? && @buffer.visible_mark &&
413
415
  @buffer.point_after_mark?(@buffer.visible_mark)
414
416
  @window.attron(region_attr)
415
417
  @in_region = true
416
418
  end
419
+ if current? && @buffer.isearch_mark &&
420
+ @buffer.point_after_mark?(@buffer.isearch_mark)
421
+ # If already in region, switch to isearch (priority)
422
+ if @in_region
423
+ @window.attroff(region_attr)
424
+ end
425
+ @window.attron(isearch_attr)
426
+ @in_isearch = true
427
+ end
417
428
  while !@buffer.end_of_buffer?
418
429
  cury = @window.cury
419
430
  curx = @window.curx
420
431
  update_cursor_and_attr(point, cury, curx)
421
432
  if attrs = @highlight_off[@buffer.point]
422
- if @in_region
433
+ if @in_region || @in_isearch
423
434
  # In region: only turn off non-color attributes (bold, underline, etc.)
424
435
  @window.attroff(attrs & ~Curses::A_COLOR)
425
436
  else
@@ -428,7 +439,7 @@ module Textbringer
428
439
  @current_highlight_attrs = 0
429
440
  end
430
441
  if attrs = @highlight_on[@buffer.point]
431
- if @in_region
442
+ if @in_region || @in_isearch
432
443
  # In region: only turn on non-color attributes (preserve region background)
433
444
  @window.attron(attrs & ~Curses::A_COLOR)
434
445
  else
@@ -479,6 +490,9 @@ module Textbringer
479
490
  break if newx == columns && cury == lines - 2
480
491
  @buffer.forward_char
481
492
  end
493
+ if current? && @buffer.isearch_mark
494
+ @window.attroff(isearch_attr)
495
+ end
482
496
  if current? && @buffer.visible_mark
483
497
  @window.attroff(region_attr)
484
498
  end
@@ -708,31 +722,82 @@ module Textbringer
708
722
  if @buffer.point_at_mark?(point)
709
723
  @cursor.y = cury
710
724
  @cursor.x = curx
725
+ # Handle visible mark transitions
711
726
  if current? && @buffer.visible_mark
712
727
  if @buffer.point_after_mark?(@buffer.visible_mark)
713
- @window.attroff(region_attr)
728
+ unless @in_isearch
729
+ @window.attroff(region_attr)
730
+ # Restore syntax highlighting colors after exiting region
731
+ if @current_highlight_attrs != 0
732
+ @window.attron(@current_highlight_attrs)
733
+ end
734
+ end
714
735
  @in_region = false
715
- # Restore syntax highlighting colors after exiting region
716
- if @current_highlight_attrs != 0
736
+ elsif @buffer.point_before_mark?(@buffer.visible_mark)
737
+ unless @in_isearch
738
+ @window.attron(region_attr)
739
+ end
740
+ @in_region = true
741
+ end
742
+ end
743
+ # Handle isearch mark transitions
744
+ if current? && @buffer.isearch_mark
745
+ if @buffer.point_after_mark?(@buffer.isearch_mark)
746
+ @window.attroff(isearch_attr)
747
+ @in_isearch = false
748
+ # If we were covering a region, restore it
749
+ if @in_region
750
+ @window.attron(region_attr)
751
+ elsif @current_highlight_attrs != 0
717
752
  @window.attron(@current_highlight_attrs)
718
753
  end
719
- elsif @buffer.point_before_mark?(@buffer.visible_mark)
754
+ elsif @buffer.point_before_mark?(@buffer.isearch_mark)
755
+ # Entering isearch - turn off region if active
756
+ if @in_region
757
+ @window.attroff(region_attr)
758
+ end
759
+ @window.attron(isearch_attr)
760
+ @in_isearch = true
761
+ end
762
+ end
763
+ end
764
+ # Handle transitions when point crosses isearch mark
765
+ if current? && @buffer.isearch_mark &&
766
+ @buffer.point_at_mark?(@buffer.isearch_mark)
767
+ if @buffer.point_after_mark?(point)
768
+ @window.attroff(isearch_attr)
769
+ @in_isearch = false
770
+ # If we have a region underneath, restore it
771
+ if @in_region
720
772
  @window.attron(region_attr)
721
- @in_region = true
773
+ elsif @current_highlight_attrs != 0
774
+ @window.attron(@current_highlight_attrs)
722
775
  end
776
+ elsif @buffer.point_before_mark?(point)
777
+ # Entering isearch - turn off region if active
778
+ if @in_region
779
+ @window.attroff(region_attr)
780
+ end
781
+ @window.attron(isearch_attr)
782
+ @in_isearch = true
723
783
  end
724
784
  end
785
+ # Handle transitions when point crosses visible mark
725
786
  if current? && @buffer.visible_mark &&
726
- @buffer.point_at_mark?(@buffer.visible_mark)
787
+ @buffer.point_at_mark?(@buffer.visible_mark)
727
788
  if @buffer.point_after_mark?(point)
728
- @window.attroff(region_attr)
729
- @in_region = false
730
- # Restore syntax highlighting colors after exiting region
731
- if @current_highlight_attrs != 0
732
- @window.attron(@current_highlight_attrs)
789
+ unless @in_isearch
790
+ @window.attroff(region_attr)
791
+ # Restore syntax highlighting colors after exiting region
792
+ if @current_highlight_attrs != 0
793
+ @window.attron(@current_highlight_attrs)
794
+ end
733
795
  end
796
+ @in_region = false
734
797
  elsif @buffer.point_before_mark?(point)
735
- @window.attron(region_attr)
798
+ unless @in_isearch
799
+ @window.attron(region_attr)
800
+ end
736
801
  @in_region = true
737
802
  end
738
803
  end
@@ -915,6 +980,10 @@ module Textbringer
915
980
  def region_attr
916
981
  @@has_colors ? Face[:region].attributes : Curses::A_REVERSE
917
982
  end
983
+
984
+ def isearch_attr
985
+ @@has_colors ? Face[:isearch].attributes : Curses::A_UNDERLINE
986
+ end
918
987
  end
919
988
 
920
989
  class EchoArea < Window
@@ -963,6 +1032,7 @@ module Textbringer
963
1032
  @window.setpos(0, 0)
964
1033
  @window.attrset(0)
965
1034
  @in_region = false
1035
+ @in_isearch = false
966
1036
  @current_highlight_attrs = 0
967
1037
  if @message
968
1038
  @window.addstr(escape(@message))
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: '17'
4
+ version: '18'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugo Maeda