Class: Glimmer::Tk::TextProxy

Inherits:
WidgetProxy show all
Defined in:
lib/glimmer/tk/text_proxy.rb

Overview

Proxy for Tk::Text

Follows the Proxy Design Pattern

Constant Summary collapse

ALL_TAG =
'__all__'
FORMAT_DEFAULT_MAP =
{
  'justify' => 'left',
}

Constants inherited from WidgetProxy

WidgetProxy::FONTS_PREDEFINED, WidgetProxy::HEXADECIMAL_CHARACTERS

Instance Attribute Summary

Attributes inherited from WidgetProxy

#args, #bind_ids, #children, #destroyed, #keyword, #parent_proxy, #tk

Attributes included from DraggableAndDroppable

#on_drag_motion_block

Instance Method Summary collapse

Methods inherited from WidgetProxy

#add_observer, #ancestor_proxies, #apply_style, #attribute_argument_normalizers, #attribute_setter, #clear_children, #content, create, #destroy, #disabled, #disabled=, #enabled, #enabled=, #event_generate, #font=, #get_attribute, #grid, #has_attribute?, #has_attributes_attribute?, #has_state?, #hidden, #hidden=, #image_argument, #initialize, #inspect, #method_missing, #normalize_attribute_arguments, #on, #post_add_content, #post_initialize_child, #respond_to?, #root_parent_proxy, #set_attribute, #style=, tk_widget_class_for, #tk_widget_has_attribute_getter_setter?, #tk_widget_has_attribute_setter?, #toplevel_parent_proxy, #unbind_all, #visible, #visible=, #widget_attribute_listener_installers, #widget_custom_attribute_mapping, widget_exists?, widget_proxy_class, #window?

Methods included from DraggableAndDroppable

#drag_source=, #drop_target=, #make_draggable, #make_droppable, #make_non_draggable, #make_non_droppable, #on_drag_start_block=, #on_drop_block=, #textvariable_defined?

Constructor Details

This class inherits a constructor from Glimmer::Tk::WidgetProxy

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Glimmer::Tk::WidgetProxy

Instance Method Details

#add_font_format(region_start, region_end, font_option, value) ⇒ Object

[View source]

272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/glimmer/tk/text_proxy.rb', line 272

def add_font_format(region_start, region_end, font_option, value)
  applied_font_format_tags_and_regions(region_start, region_end).each do |tag, tag_region_start, tag_region_end|
    if tag
      bigger_region_tag = @tk.tag_ranges(tag).any? do |range_start, range_end|
        text_index_less_than_other_text_index?(range_start, tag_region_start) || text_index_greater_than_other_text_index?(range_end, tag_region_end)
      end
      if bigger_region_tag
        @tk.tag_ranges(tag).each do |range_start, range_end|
          if text_index_less_than_other_text_index?(range_start, tag_region_start) && text_index_less_than_or_equal_to_other_text_index?(range_end, tag_region_end) && text_index_greater_than_or_equal_to_other_text_index?(range_end, tag_region_start)
            font = @tk.tag_cget(tag, 'font')
            remove_format(range_start, range_end, 'font', font)
            add_format(range_start, tag_region_start, 'font', font)
            font_clone = clone_font(font)
            font_clone.send("#{font_option}=", value)
            add_format(tag_region_start, tag_region_end, 'font', font_clone)
          elsif text_index_greater_than_other_text_index?(range_end, tag_region_end) && text_index_greater_than_or_equal_to_other_text_index?(range_start, tag_region_start) && text_index_less_than_or_equal_to_other_text_index?(range_start, tag_region_end)
            font = @tk.tag_cget(tag, 'font')
            remove_format(range_start, range_end, 'font', font)
            add_format(tag_region_end, range_end, 'font', font)
            font_clone = clone_font(font)
            font_clone.send("#{font_option}=", value)
            add_format(tag_region_start, tag_region_end, 'font', font_clone)
          elsif text_index_less_than_other_text_index?(range_start, tag_region_start) && text_index_greater_than_other_text_index?(range_end, tag_region_end)
            font = @tk.tag_cget(tag, 'font')
            remove_format(range_start, range_end, 'font', font)
            add_format(range_start, tag_region_start, 'font', font)
            remove_format(range_start, range_end, 'font', font)
            add_format(tag_region_end, range_end, 'font', font)
            font_clone = clone_font(font)
            font_clone.send("#{font_option}=", value)
            add_format(tag_region_start, tag_region_end, 'font', font_clone)
          end
        end
      else
        current_font = @tk.tag_cget(tag, 'font')
        current_font.send("#{font_option}=", value)
      end
    else
      add_format(tag_region_start, tag_region_end, 'font', default_font_attributes.merge(font_option => value))
    end
  end
end

#add_format(region_start, region_end, option, value) ⇒ Object

[View source]

174
175
176
177
178
179
180
# File 'lib/glimmer/tk/text_proxy.rb', line 174

def add_format(region_start, region_end, option, value)
  @@tag_number = 0 unless defined?(@@tag_number)
  tag = "tag_#{option}_#{@@tag_number += 1}"
  @tk.tag_configure(tag, {option => value})
  @tk.tag_add(tag, region_start, region_end)
  tag
end

#add_selection_font_format(option, value, no_selection_default: :insert_word, focus: true) ⇒ Object

[View source]

107
108
109
# File 'lib/glimmer/tk/text_proxy.rb', line 107

def add_selection_font_format(option, value, no_selection_default: :insert_word, focus: true)
  process_selection_ranges(no_selection_default: no_selection_default, focus: focus) { |range_start, range_end| add_font_format(range_start, range_end, option, value) }
end

#add_selection_format(option, value, no_selection_default: :insert_word, focus: true) ⇒ Object

[View source]

95
96
97
# File 'lib/glimmer/tk/text_proxy.rb', line 95

def add_selection_format(option, value, no_selection_default: :insert_word, focus: true)
  process_selection_ranges(no_selection_default: no_selection_default, focus: focus) { |range_start, range_end| add_format(range_start, range_end, option, value) }
end

#add_to_text_index(text_index, addition) ⇒ Object

[View source]

375
376
377
378
379
380
381
# File 'lib/glimmer/tk/text_proxy.rb', line 375

def add_to_text_index(text_index, addition)
  text_index_parts = text_index.split('.')
  line = text_index_parts.first
  char_index = text_index_parts.last
  char_index = char_index.to_i + addition
  "#{line}.#{char_index}"
end

#applied_font_format?(region_start, region_end, font_option, value) ⇒ Boolean

TODO Algorithm for font option formatting for a region, grab all the latest tags for each subregion as well as the widget font for subregions without a tag for each part of the region covered by a tag, augment its font with new font option (or remove if that is what is needed) Once add and remove are implemented, implement toggle Also, there is a need for a method that checks if a font option value applies to an entire region (to decide which way to toggle with toggle method)

Returns:

  • (Boolean)
[View source]

214
215
216
217
218
219
220
221
222
# File 'lib/glimmer/tk/text_proxy.rb', line 214

def applied_font_format?(region_start, region_end, font_option, value)
  applied_font_format_tags_and_regions(region_start, region_end).all? do |tag, region_start, region_end|
    if tag.nil?
      @tk.font.send(font_option) == value
    else
      @tk.tag_cget(tag, 'font').send(font_option) == value
    end
  end
end

#applied_font_format_tags_and_regions(region_start, region_end) ⇒ Object

[View source]

224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/glimmer/tk/text_proxy.rb', line 224

def applied_font_format_tags_and_regions(region_start, region_end)
  lines = value.split("\n")
  tags_and_regions = []
  all_tag_names = (@tk.tag_names - ['sel', ALL_TAG]).select {|tag_name| tag_name.include?('_font_')}
  (region_start.to_i..region_end.to_i).each do |line_number|
    start_character_index = 0
    start_character_index = region_start.to_s.split('.').last.to_i if line_number == region_start.to_i
    end_character_index = lines[line_number - 1].to_s.size
    end_character_index = region_end.to_s.split('.').last.to_i if line_number == region_end.to_i
    (start_character_index...end_character_index).each do |character_index|
      text_index = "#{line_number}.#{character_index}"
      region_tag = all_tag_names.reverse.find do |tag|
        @tk.tag_cget(tag, 'font') && @tk.tag_ranges(tag).any? do |range_start, range_end|
          text_index_less_than_or_equal_to_other_text_index?(range_start, text_index) && text_index_greater_than_or_equal_to_other_text_index?(range_end, text_index)
        end
      end
      end_text_index = add_to_text_index(text_index, 1)
      if tags_and_regions&.last && region_tag == tags_and_regions.last.first
        tags_and_regions.last[2] = end_text_index
      else
        tags_and_regions << [region_tag, text_index, end_text_index]
      end
    end
  end
  tags_and_regions
end

#applied_font_format_value(text_index = nil, font_option) ⇒ Object

[View source]

251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/glimmer/tk/text_proxy.rb', line 251

def applied_font_format_value(text_index = nil, font_option)
  text_index ||= @tk.index('insert')
  region_start = text_index
  region_end = @tk.index("#{text_index} + 1 chars")
  tag_names = applied_font_format_tags_and_regions(region_start, region_end).map(&:first)
  
  values = tag_names.map do |tag_name|
    @tk.tag_ranges(tag_name).map do |range|
      if text_index_less_than_or_equal_to_other_text_index?(range.first, region_start) && text_index_greater_than_or_equal_to_other_text_index?(range.last, region_end)
        @tk.tag_cget(tag_name, 'font')
      end
    end
  end.flatten.reject {|value| value.to_s.empty?}
  
  font = values.last
  
  value = font && font.send(font_option)
  
  value || Hash[@tk.font.actual][font_option]
end

#applied_format?(region_start, region_end, option, value) ⇒ Boolean

Returns:

  • (Boolean)
[View source]

141
142
143
# File 'lib/glimmer/tk/text_proxy.rb', line 141

def applied_format?(region_start, region_end, option, value)
  !applied_format_tags(region_start, region_end, option, value).empty?
end

#applied_format_tags(region_start, region_end, option, value) ⇒ Object

[View source]

145
146
147
148
149
150
151
152
153
154
155
# File 'lib/glimmer/tk/text_proxy.rb', line 145

def applied_format_tags(region_start, region_end, option, value)
  tag_names = @tk.tag_names - ['sel', ALL_TAG]
  
  tag_names.select do |tag_name|
    @tk.tag_ranges(tag_name).any? do |range|
      if text_index_less_than_or_equal_to_other_text_index?(range.first, region_start) && text_index_greater_than_or_equal_to_other_text_index?(range.last, region_end)
        @tk.tag_cget(tag_name, option) == value
      end
    end
  end
end

#applied_format_value(text_index = nil, option) ⇒ Object

[View source]

157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/glimmer/tk/text_proxy.rb', line 157

def applied_format_value(text_index = nil, option)
  text_index ||= @tk.index('insert')
  region_start = text_index
  region_end = text_index
  tag_names = @tk.tag_names - ['sel', ALL_TAG]
  
  values = tag_names.map do |tag_name|
    @tk.tag_ranges(tag_name).map do |range|
      if text_index_less_than_or_equal_to_other_text_index?(range.first, region_start) && text_index_greater_than_or_equal_to_other_text_index?(range.last, region_end)
        @tk.tag_cget(tag_name, option)
      end
    end
  end.flatten.reject {|value| value.to_s.empty?}
  
  values.last || (@tk.send(option) rescue FORMAT_DEFAULT_MAP[option])
end

#default_font_attributesObject

[View source]

371
372
373
# File 'lib/glimmer/tk/text_proxy.rb', line 371

def default_font_attributes
  Hash[@tk.font.actual]
end

#default_for_font_option(font_option) ⇒ Object

[View source]

367
368
369
# File 'lib/glimmer/tk/text_proxy.rb', line 367

def default_for_font_option(font_option)
  @tk.font.send(font_option)
end

#edit_redoObject

[View source]

87
88
89
90
91
92
93
# File 'lib/glimmer/tk/text_proxy.rb', line 87

def edit_redo
  begin
    @tk.edit_redo
  rescue => e
    # No Op
  end
end

#edit_undoObject

[View source]

78
79
80
81
82
83
84
85
# File 'lib/glimmer/tk/text_proxy.rb', line 78

def edit_undo
  # <Modified> fires twice the first time, which is equivalent to one change.
  if @modified_count.to_i > 2
    # must count the extra 2 modified count that will occur upon undo too
    @modified_count -= 4
    @tk.edit_undo
  end
end

#get_open_file_to_insert_image(text_index = 'insert') ⇒ Object

[View source]

423
424
425
426
427
428
429
430
# File 'lib/glimmer/tk/text_proxy.rb', line 423

def get_open_file_to_insert_image(text_index = 'insert')
  image_filename = Glimmer::DSL::Tk::BuiltInDialogExpression.new.interpret(nil, 'get_open_file', filetypes: {
    'PNG Images' => '.png',
    'Gif Images' => '.gif',
    'PPM Images' => '.ppm'
  })
  insert_image('insert', image_filename) unless image_filename.nil? || image_filename.to_s.empty?
end

#handle_listener(listener_name, &listener) ⇒ Object

[View source]

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/glimmer/tk/text_proxy.rb', line 35

def handle_listener(listener_name, &listener)
  case listener_name.to_s.downcase
  when '<<modified>>', '<modified>', 'modified'
    modified_listener = Proc.new do |*args|
      @modified_count ||= 0
      @modified_count += 1
      listener.call(*args)
      @insert_mark_moved_proc&.call
      @tk.modified = false
    end
    @tk.bind('<Modified>', modified_listener)
  when '<<selection>>', '<selection>', 'selection'
    @tk.bind('<Selection>', listener)
  when 'destroy'
    super
  when 'insertmarkmove', 'insertmarkmoved', 'insert_mark_move', 'insert_mark_moved'
    if @insert_mark_moved_proc.nil?
      handle_listener('KeyPress') do |event|
        @insert_mark_moved_proc&.call
      end
      handle_listener('KeyRelease') do |event|
        @insert_mark_moved_proc&.call
      end
      handle_listener('ButtonPress') do |event|
        @insert_mark_moved_proc&.call
      end
      handle_listener('ButtonRelease') do |event|
        @insert_mark_moved_proc&.call
      end
    end
    @insert_mark = @tk.index('insert')
    @insert_mark_moved_proc = Proc.new do
      new_insert_mark = @tk.index('insert')
      if new_insert_mark != @insert_mark
        @insert_mark = new_insert_mark
        listener.call(new_insert_mark)
      end
    end
  else
    super
  end
end

#insert_image(text_index, *image_args) ⇒ Object

[View source]

419
420
421
# File 'lib/glimmer/tk/text_proxy.rb', line 419

def insert_image(text_index, *image_args)
  TkTextImage.new(@tk, 'insert', :image => image_argument(image_args))
end

#process_selection_ranges(no_selection_default: :insert_word, focus: true, &processor) ⇒ Object

[View source]

119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/glimmer/tk/text_proxy.rb', line 119

def process_selection_ranges(no_selection_default: :insert_word, focus: true, &processor)
  regions = @tk.tag_ranges('sel')
  if regions.empty?
    case no_selection_default
    when :insert_word
      regions = [[@tk.index('insert wordstart'), @tk.index('insert wordend + 1 char')]]
    when :insert_letter
      regions = [[@tk.index('insert'), @tk.index('insert + 1 char')]]
    end
  end
  regions.each do |region|
    range_start = region.first
    range_end = region.last
    processor.call(range_start, range_end)
  end
  if focus == true
    @tk.focus
  elsif focus.is_a?(Integer)
    ::Tk.after(focus) { @tk.focus }
  end
end

#remove_font_format(region_start, region_end, font_option, value) ⇒ Object

[View source]

315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/glimmer/tk/text_proxy.rb', line 315

def remove_font_format(region_start, region_end, font_option, value)
  applied_font_format_tags_and_regions(region_start, region_end).each do |tag, tag_region_start, tag_region_end|
    if tag
      bigger_region_tag = @tk.tag_ranges(tag).any? do |range_start, range_end|
        text_index_less_than_other_text_index?(range_start, tag_region_start) || text_index_greater_than_other_text_index?(range_end, tag_region_end)
      end
      if bigger_region_tag
        @tk.tag_ranges(tag).each do |range_start, range_end|
          if text_index_less_than_other_text_index?(range_start, tag_region_start) && text_index_less_than_or_equal_to_other_text_index?(range_end, tag_region_end) && text_index_greater_than_or_equal_to_other_text_index?(range_end, tag_region_start)
            font = @tk.tag_cget(tag, 'font')
            remove_format(range_start, range_end, 'font', font)
            add_format(range_start, subtract_from_text_index(tag_region_start, 1), 'font', font)
            font_clone = clone_font(font)
            font_clone.send("#{font_option}=", default_for_font_option(font_option))
            add_format(tag_region_start, tag_region_end, 'font', font_clone)
          elsif text_index_greater_than_other_text_index?(range_end, tag_region_end) && text_index_greater_than_or_equal_to_other_text_index?(range_start, tag_region_start) && text_index_less_than_or_equal_to_other_text_index?(range_start, tag_region_end)
            font = @tk.tag_cget(tag, 'font')
            remove_format(range_start, range_end, 'font', font)
            add_format(add_to_text_index(tag_region_end, 1), range_end, 'font', font)
            font_clone = clone_font(font)
            font_clone.send("#{font_option}=", default_for_font_option(font_option))
            add_format(tag_region_start, tag_region_end, 'font', font_clone)
          elsif text_index_less_than_other_text_index?(range_start, tag_region_start) && text_index_greater_than_other_text_index?(range_end, tag_region_end)
            font = @tk.tag_cget(tag, 'font')
            remove_format(range_start, range_end, 'font', font)
            add_format(range_start, subtract_from_text_index(tag_region_start, 1), 'font', font)
            remove_format(range_start, range_end, 'font', font)
            add_format(add_to_text_index(tag_region_end, 1), range_end, 'font', font)
            font_clone = clone_font(font)
            font_clone.send("#{font_option}=", default_for_font_option(font_option))
            add_format(tag_region_start, tag_region_end, 'font', font_clone)
          end
        end
      else
        current_font = @tk.tag_cget(tag, 'font')
        current_font.send("#{font_option}=", default_for_font_option(font_option))
      end
    else
      add_format(tag_region_start, tag_region_end, 'font', default_font_attributes.merge(font_option => default_for_font_option(font_option)))
    end
  end
end

#remove_format(region_start, region_end, option, value) ⇒ Object

[View source]

182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/glimmer/tk/text_proxy.rb', line 182

def remove_format(region_start, region_end, option, value)
  partial_intersection_option_applied_tags = tag_names.select do |tag_name|
    @tk.tag_ranges(tag_name).any? do |range|
      if range.first.to_f.between?(region_start.to_f, region_end.to_f) or
         range.last.to_f.between?(region_start.to_f, region_end.to_f) or
         (text_index_less_than_or_equal_to_other_text_index?(range.first, region_start) && text_index_greater_than_or_equal_to_other_text_index?(range.last, region_end))
        @tk.tag_cget(tag_name, option) == value
      end
    end
  end
  
  partial_intersection_option_applied_tags.each do |tag_name|
    @tk.tag_remove(tag_name, region_start, region_end)
  end
  
  nil
end

#remove_selection_font_format(option, value, no_selection_default: :insert_word, focus: true) ⇒ Object

[View source]

111
112
113
# File 'lib/glimmer/tk/text_proxy.rb', line 111

def remove_selection_font_format(option, value, no_selection_default: :insert_word, focus: true)
  process_selection_ranges(no_selection_default: no_selection_default, focus: focus) { |range_start, range_end| remove_font_format(range_start, range_end, option, value) }
end

#remove_selection_format(option, value, no_selection_default: :insert_word, focus: true) ⇒ Object

[View source]

99
100
101
# File 'lib/glimmer/tk/text_proxy.rb', line 99

def remove_selection_format(option, value, no_selection_default: :insert_word, focus: true)
  process_selection_ranges(no_selection_default: no_selection_default, focus: focus) { |range_start, range_end| remove_format(range_start, range_end, option, value) }
end

#subtract_from_text_index(text_index, subtraction) ⇒ Object

[View source]

383
384
385
# File 'lib/glimmer/tk/text_proxy.rb', line 383

def subtract_from_text_index(text_index, subtraction)
  add_to_text_index(text_index, -1 * subtraction)
end

#text_index_greater_than_or_equal_to_other_text_index?(region1, region2) ⇒ Boolean

Returns:

  • (Boolean)
[View source]

411
412
413
414
415
416
417
# File 'lib/glimmer/tk/text_proxy.rb', line 411

def text_index_greater_than_or_equal_to_other_text_index?(region1, region2)
  region1_parts = region1.to_s.split('.')
  region2_parts = region2.to_s.split('.')
  return true if region1_parts.first.to_i > region2_parts.first.to_i
  return false if region1_parts.first.to_i < region2_parts.first.to_i
  region1_parts.last.to_i >= region2_parts.last.to_i
end

#text_index_greater_than_other_text_index?(region1, region2) ⇒ Boolean

Returns:

  • (Boolean)
[View source]

403
404
405
406
407
408
409
# File 'lib/glimmer/tk/text_proxy.rb', line 403

def text_index_greater_than_other_text_index?(region1, region2)
  region1_parts = region1.to_s.split('.')
  region2_parts = region2.to_s.split('.')
  return true if region1_parts.first.to_i > region2_parts.first.to_i
  return false if region1_parts.first.to_i < region2_parts.first.to_i
  region1_parts.last.to_i > region2_parts.last.to_i
end

#text_index_less_than_or_equal_to_other_text_index?(region1, region2) ⇒ Boolean

Returns:

  • (Boolean)
[View source]

395
396
397
398
399
400
401
# File 'lib/glimmer/tk/text_proxy.rb', line 395

def text_index_less_than_or_equal_to_other_text_index?(region1, region2)
  region1_parts = region1.to_s.split('.')
  region2_parts = region2.to_s.split('.')
  return true if region1_parts.first.to_i < region2_parts.first.to_i
  return false if region1_parts.first.to_i > region2_parts.first.to_i
  region1_parts.last.to_i <= region2_parts.last.to_i
end

#text_index_less_than_other_text_index?(region1, region2) ⇒ Boolean

Returns:

  • (Boolean)
[View source]

387
388
389
390
391
392
393
# File 'lib/glimmer/tk/text_proxy.rb', line 387

def text_index_less_than_other_text_index?(region1, region2)
  region1_parts = region1.to_s.split('.')
  region2_parts = region2.to_s.split('.')
  return true if region1_parts.first.to_i < region2_parts.first.to_i
  return false if region1_parts.first.to_i > region2_parts.first.to_i
  region1_parts.last.to_i < region2_parts.last.to_i
end

#toggle_font_format(region_start, region_end, option, value) ⇒ Object

toggles option/value tag (removes if already applied)

[View source]

359
360
361
362
363
364
365
# File 'lib/glimmer/tk/text_proxy.rb', line 359

def toggle_font_format(region_start, region_end, option, value)
  if applied_font_format?(region_start, region_end, option, value)
    remove_font_format(region_start, region_end, option, value)
  else
    add_font_format(region_start, region_end, option, value)
  end
end

#toggle_format(region_start, region_end, option, value) ⇒ Object

toggles option/value tag (removes if already applied)

[View source]

201
202
203
204
205
206
207
# File 'lib/glimmer/tk/text_proxy.rb', line 201

def toggle_format(region_start, region_end, option, value)
  if applied_format?(region_start, region_end, option, value)
    remove_format(region_start, region_end, option, value)
  else
    add_format(region_start, region_end, option, value)
  end
end

#toggle_selection_font_format(option, value, no_selection_default: :insert_word, focus: true) ⇒ Object

[View source]

115
116
117
# File 'lib/glimmer/tk/text_proxy.rb', line 115

def toggle_selection_font_format(option, value, no_selection_default: :insert_word, focus: true)
  process_selection_ranges(no_selection_default: no_selection_default, focus: focus) { |range_start, range_end| toggle_font_format(range_start, range_end, option, value) }
end

#toggle_selection_format(option, value, no_selection_default: :insert_word, focus: true) ⇒ Object

[View source]

103
104
105
# File 'lib/glimmer/tk/text_proxy.rb', line 103

def toggle_selection_format(option, value, no_selection_default: :insert_word, focus: true)
  process_selection_ranges(no_selection_default: no_selection_default, focus: focus) { |range_start, range_end| toggle_format(range_start, range_end, option, value) }
end