Class: Gtk::TextBuffer
- Inherits:
-
Object
- Object
- Gtk::TextBuffer
- Extended by:
- GLib::Deprecatable
- Defined in:
- lib/gtk3/deprecated.rb,
lib/gtk3/text-buffer.rb
Instance Method Summary collapse
- #apply_tag(tag, start, last) ⇒ Object
- #apply_tag_raw ⇒ Object
- #create_tag(tag_name = nil, properties = {}) ⇒ Object
- #deserialize_formats ⇒ Object
- #deserialize_formats_raw ⇒ Object
- #get_iter_at(arguments) ⇒ Object
- #insert(iter, target, *args) ⇒ Object
- #insert_at_cursor(text, options = {}) ⇒ Object
- #insert_at_cursor_raw ⇒ Object
- #insert_raw ⇒ Object
- #selection_bounds ⇒ Object
- #selection_bounds_raw ⇒ Object
- #serialize(*arguments) ⇒ Object
- #serialize_formats ⇒ Object
- #serialize_formats_raw ⇒ Object
- #serialize_raw ⇒ Object
- #set_text(text) ⇒ Object (also: #text=)
- #set_text_raw ⇒ Object
Instance Method Details
#apply_tag(tag, start, last) ⇒ Object
143 144 145 146 147 148 149 |
# File 'lib/gtk3/text-buffer.rb', line 143 def apply_tag(tag, start, last) if tag.is_a?(String) apply_tag_by_name(tag, start, last) else apply_tag_raw(tag, start, last) end end |
#apply_tag_raw ⇒ Object
142 |
# File 'lib/gtk3/text-buffer.rb', line 142 alias_method :apply_tag_raw, :apply_tag |
#create_tag(tag_name = nil, properties = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gtk3/text-buffer.rb', line 19 def create_tag(tag_name=nil, properties={}) tag = TextTag.new(tag_name) succeeded = tag_table.add(tag) return nil unless succeeded properties.each do |property| key, value = property tag.set_property(key, value) end tag end |
#deserialize_formats ⇒ Object
157 158 159 |
# File 'lib/gtk3/text-buffer.rb', line 157 def deserialize_formats deserialize_formats_raw[0] end |
#deserialize_formats_raw ⇒ Object
156 |
# File 'lib/gtk3/text-buffer.rb', line 156 alias_method :deserialize_formats_raw, :deserialize_formats |
#get_iter_at(arguments) ⇒ Object
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 |
# File 'lib/gtk3/text-buffer.rb', line 39 def get_iter_at(arguments) line = arguments[:line] offset = arguments[:offset] index = arguments[:index] mark = arguments[:mark] anchor = arguments[:anchor] if line if offset get_iter_at_line_offset_raw(line, offset) elsif index get_iter_at_line_index_raw(line, index) else get_iter_at_line_raw(line) end elsif offset get_iter_at_offset_raw(offset) elsif mark get_iter_at_mark_raw(mark) elsif anchor get_iter_at_child_anchor_raw(anchor) else = "Must specify one of :line, :offset, :mark or :anchor: #{arguments.inspect}" raise ArgumentError, end end |
#insert(iter, target, *args) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/gtk3/text-buffer.rb', line 69 def insert(iter, target, *args) = nil = nil case args.size when 0 = {} when 1 case args.first when Hash = args.first else = args end else = args end if .nil? signature_prefix = "#{self.class}\##{__method__}(iter, target" warn("#{signature_prefix}, *tags) style has been deprecated. " + "Use #{signature_prefix}, options={:tags => tags}) style instead.") = {:tags => } end interactive = [:interactive] default_editable = [:default_editable] = [:tags] start_offset = iter.offset if interactive default_editable = true if default_editable.nil? insert_interactive(iter, target, default_editable) else case target when Gdk::Pixbuf insert_pixbuf_raw(iter, target) when TextChildAnchor insert_text_child_anchor_raw(iter, target) else insert_raw(iter, target, target.bytesize) end end if start_iter = get_iter_at(:offset => start_offset) .each do |tag| tag = tag_table.lookup(tag) if tag.is_a?(String) apply_tag(tag, start_iter, iter) end end self end |
#insert_at_cursor(text, options = {}) ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/gtk3/text-buffer.rb', line 123 def insert_at_cursor(text, ={}) interactive = [:interactive] default_editable = [:default_editable] if interactive default_editable = true if default_editable.nil? insert_interactive_at_cursor(text, default_editable) else insert_at_cursor_raw(text, text.bytesize) end end |
#insert_at_cursor_raw ⇒ Object
122 |
# File 'lib/gtk3/text-buffer.rb', line 122 alias_method :insert_at_cursor_raw, :insert_at_cursor |
#insert_raw ⇒ Object
66 |
# File 'lib/gtk3/text-buffer.rb', line 66 alias_method :insert_raw, :insert |
#selection_bounds ⇒ Object
167 168 169 170 171 172 173 174 |
# File 'lib/gtk3/text-buffer.rb', line 167 def selection_bounds selected, start_iter, end_iter = selection_bounds_raw if selected [start_iter, end_iter] else nil end end |
#selection_bounds_raw ⇒ Object
166 |
# File 'lib/gtk3/text-buffer.rb', line 166 alias_method :selection_bounds_raw, :selection_bounds |
#serialize(*arguments) ⇒ Object
162 163 164 |
# File 'lib/gtk3/text-buffer.rb', line 162 def serialize(*arguments) serialize_raw(*arguments)[0].pack("C*") end |
#serialize_formats ⇒ Object
152 153 154 |
# File 'lib/gtk3/text-buffer.rb', line 152 def serialize_formats serialize_formats_raw[0] end |
#serialize_formats_raw ⇒ Object
151 |
# File 'lib/gtk3/text-buffer.rb', line 151 alias_method :serialize_formats_raw, :serialize_formats |
#serialize_raw ⇒ Object
161 |
# File 'lib/gtk3/text-buffer.rb', line 161 alias_method :serialize_raw, :serialize |
#set_text(text) ⇒ Object Also known as: text=
136 137 138 |
# File 'lib/gtk3/text-buffer.rb', line 136 def set_text(text) set_text_raw(text, text.bytesize) end |
#set_text_raw ⇒ Object
135 |
# File 'lib/gtk3/text-buffer.rb', line 135 alias_method :set_text_raw, :set_text |