Class: VER::Text

Inherits:
Tk::Text
  • Object
show all
Defined in:
lib/ver/text.rb,
lib/ver/text/end.rb,
lib/ver/text/tag.rb,
lib/ver/text/mark.rb,
lib/ver/text/index.rb,
lib/ver/text/range.rb,
lib/ver/text/insert.rb,
lib/ver/text/position.rb,
lib/ver/text/selection/char.rb,
lib/ver/text/selection/line.rb

Overview

Common funcionality for Tk::Text widgets, mostly with shortcuts and helpers for VER.

Direct Known Subclasses

Buffer, MiniBuffer

Defined Under Namespace

Modules: Position Classes: End, Index, Insert, Mark, Range, Selection, Tag

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#lockObject (readonly)

Returns the value of attribute lock.



14
15
16
# File 'lib/ver/text.rb', line 14

def lock
  @lock
end

Instance Method Details

#execute(*args, &block) ⇒ Object



16
17
18
# File 'lib/ver/text.rb', line 16

def execute(*args, &block)
  super unless lock
end

#execute_only(*args, &block) ⇒ Object



20
21
22
# File 'lib/ver/text.rb', line 20

def execute_only(*args, &block)
  super unless lock
end

#focus(*args) ⇒ Object



24
25
26
# File 'lib/ver/text.rb', line 24

def focus(*args)
  super unless lock
end

#index(position) ⇒ Object



36
37
38
# File 'lib/ver/text.rb', line 36

def index(idx)
  Index.new(self, execute('index', idx).to_s)
end

#insert=(position) ⇒ Object



44
45
46
# File 'lib/ver/text.rb', line 44

def insert=(position)
  at_insert.index = position
end

#inspectObject



32
33
34
# File 'lib/ver/text.rb', line 32

def inspect
  "#<VER::Text %p>" % [tk_pathname]
end

#mark(name, index = nil, gravity = nil) ⇒ Object



70
71
72
73
74
# File 'lib/ver/text.rb', line 70

def mark(name, index = nil, gravity = nil)
  mark = Mark.new(self, name, index)
  mark.gravity = gravity if gravity
  mark
end

#mark_next(index) ⇒ Object



80
81
82
83
# File 'lib/ver/text.rb', line 80

def mark_next(index)
  name = super
  Mark.new(self, name) if name
end

#mark_previous(index) ⇒ Object



85
86
87
88
# File 'lib/ver/text.rb', line 85

def mark_previous(index)
  name = super
  Mark.new(self, name) if name
end

#marksObject



76
77
78
# File 'lib/ver/text.rb', line 76

def marks
  mark_names.map{|name| Mark.new(self, name) }
end

#place_forget(*args) ⇒ Object



28
29
30
# File 'lib/ver/text.rb', line 28

def place_forget(*args)
  super unless lock
end

#range(first, last) ⇒ Object



66
67
68
# File 'lib/ver/text.rb', line 66

def range(first, last)
  Range.new(self, Index.new(self, first), Index.new(self, last))
end

#tag(name, *indices) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/ver/text.rb', line 48

def tag(name, *indices)
  if indices.empty?
    Tag.new(self, name)
  else
    tag = Tag.new(self, name)
    tag.add(*indices)
    tag
  end
end

#tag_ranges(tag_name) ⇒ Object



62
63
64
# File 'lib/ver/text.rb', line 62

def tag_ranges(tag_name)
  super(tag_name).map{|first, last| range(first, last) }
end

#tags(index = Tk::None) ⇒ Object



58
59
60
# File 'lib/ver/text.rb', line 58

def tags(index = Tk::None)
  tag_names(index).map{|name| Tag.new(self, name) }
end