Module: Tk::Text::IndexModMethods

Included in:
IndexString, TkTextImage, TkTextMark, TkTextTag, TkTextWindow
Defined in:
lib/tk/text.rb

Instance Method Summary collapse

Instance Method Details

#+(mod) ⇒ Object



84
85
86
87
88
89
90
91
92
93
# File 'lib/tk/text.rb', line 84

def +(mod)
  return chars(mod) if mod.kind_of?(Numeric)

  mod = mod.to_s
  if mod =~ /^\s*[+-]?\d/
    Tk::Text::IndexString.new(String.new(id) << ' + ' << mod)
  else
    Tk::Text::IndexString.new(String.new(id) << ' ' << mod)
  end
end

#-(mod) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/tk/text.rb', line 95

def -(mod)
  return chars(-mod) if mod.kind_of?(Numeric)

  mod = mod.to_s
  if mod =~ /^\s*[+-]?\d/
    Tk::Text::IndexString.new(String.new(id) << ' - ' << mod)
  elsif mod =~ /^\s*[-]\s+(\d.*)$/
    Tk::Text::IndexString.new(String.new(id) << ' - -' << $1)
  else
    Tk::Text::IndexString.new(String.new(id) << ' ' << mod)
  end
end

#any_chars(mod) ⇒ Object Also known as: any_char



129
130
131
132
133
134
135
136
137
# File 'lib/tk/text.rb', line 129

def any_chars(mod)
  # Tk8.5 feature
  fail ArgumentError, 'expect Integer'  unless mod.kind_of?(Integer)
  if mod < 0
    Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' any chars')
  else
    Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' any chars')
  end
end

#any_indices(mod) ⇒ Object



160
161
162
163
164
165
166
167
168
# File 'lib/tk/text.rb', line 160

def any_indices(mod)
  # Tk8.5 feature
  fail ArgumentError, 'expect Integer'  unless mod.kind_of?(Integer)
  if mod < 0
    Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' any indices')
  else
    Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' any indices')
  end
end

#any_lines(mod) ⇒ Object Also known as: any_line



191
192
193
194
195
196
197
198
199
# File 'lib/tk/text.rb', line 191

def any_lines(mod)
  # Tk8.5 feature
  fail ArgumentError, 'expect Integer'  unless mod.kind_of?(Integer)
  if mod < 0
    Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' any_lines')
  else
    Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' any lines')
  end
end

#chars(mod) ⇒ Object Also known as: char



108
109
110
111
112
113
114
115
# File 'lib/tk/text.rb', line 108

def chars(mod)
  fail ArgumentError, 'expect Integer'  unless mod.kind_of?(Integer)
  if mod < 0
    Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' chars')
  else
    Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' chars')
  end
end

#display_chars(mod) ⇒ Object Also known as: display_char



118
119
120
121
122
123
124
125
126
# File 'lib/tk/text.rb', line 118

def display_chars(mod)
  # Tk8.5 feature
  fail ArgumentError, 'expect Integer'  unless mod.kind_of?(Integer)
  if mod < 0
    Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' display chars')
  else
    Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' display chars')
  end
end

#display_indices(mod) ⇒ Object



150
151
152
153
154
155
156
157
158
# File 'lib/tk/text.rb', line 150

def display_indices(mod)
  # Tk8.5 feature
  fail ArgumentError, 'expect Integer'  unless mod.kind_of?(Integer)
  if mod < 0
    Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' display indices')
  else
    Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' display indices')
  end
end

#display_lineendObject



213
214
215
216
# File 'lib/tk/text.rb', line 213

def display_lineend
  # Tk8.5 feature
  Tk::Text::IndexString.new(String.new(id) << ' display lineend')
end

#display_lines(mod) ⇒ Object Also known as: display_line



180
181
182
183
184
185
186
187
188
# File 'lib/tk/text.rb', line 180

def display_lines(mod)
  # Tk8.5 feature
  fail ArgumentError, 'expect Integer'  unless mod.kind_of?(Integer)
  if mod < 0
    Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' display_lines')
  else
    Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' display lines')
  end
end

#display_linestartObject



209
210
211
212
# File 'lib/tk/text.rb', line 209

def display_linestart
  # Tk8.5 feature
  Tk::Text::IndexString.new(String.new(id) << ' display linestart')
end

#display_wordendObject



229
230
231
232
# File 'lib/tk/text.rb', line 229

def display_wordend
  # Tk8.5 feature
  Tk::Text::IndexString.new(String.new(id) << ' display wordend')
end

#display_wordstartObject



225
226
227
228
# File 'lib/tk/text.rb', line 225

def display_wordstart
  # Tk8.5 feature
  Tk::Text::IndexString.new(String.new(id) << ' display wordstart')
end

#indices(mod) ⇒ Object



140
141
142
143
144
145
146
147
148
# File 'lib/tk/text.rb', line 140

def indices(mod)
  # Tk8.5 feature
  fail ArgumentError, 'expect Integer'  unless mod.kind_of?(Integer)
  if mod < 0
    Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' indices')
  else
    Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' indices')
  end
end

#lineendObject



205
206
207
# File 'lib/tk/text.rb', line 205

def lineend
  Tk::Text::IndexString.new(String.new(id) << ' lineend')
end

#lines(mod) ⇒ Object Also known as: line



170
171
172
173
174
175
176
177
# File 'lib/tk/text.rb', line 170

def lines(mod)
  fail ArgumentError, 'expect Integer'  unless mod.kind_of?(Integer)
  if mod < 0
    Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' lines')
  else
    Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' lines')
  end
end

#linestartObject



202
203
204
# File 'lib/tk/text.rb', line 202

def linestart
  Tk::Text::IndexString.new(String.new(id) << ' linestart')
end

#wordendObject



221
222
223
# File 'lib/tk/text.rb', line 221

def wordend
  Tk::Text::IndexString.new(String.new(id) << ' wordend')
end

#wordstartObject



218
219
220
# File 'lib/tk/text.rb', line 218

def wordstart
  Tk::Text::IndexString.new(String.new(id) << ' wordstart')
end