/usr/lib/ruby/1.9.1/tk/textwindow.rb is in libtcltk-ruby1.9.1 1.9.3.0-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 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 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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | #
# tk/textwindow.rb - treat Tk text window object
#
require 'tk'
require 'tk/text'
class TkTextWindow<TkObject
include Tk::Text::IndexModMethods
def initialize(parent, index, keys = {})
#unless parent.kind_of?(Tk::Text)
# fail ArgumentError, "expect Tk::Text for 1st argument"
#end
@t = parent
if index == 'end' || index == :end
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
'end - 1 chars'))
elsif index.kind_of?(TkTextMark)
if tk_call_without_enc(@t.path,'index',index.path) == tk_call_without_enc(@t.path,'index','end')
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
'end - 1 chars'))
else
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
index.path))
end
else
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index', _get_eval_enc_str(index)))
end
@path.gravity = 'left'
@index = @path.path
keys = _symbolkey2str(keys)
@id = keys['window']
# keys['window'] = @id.epath if @id.kind_of?(TkWindow)
keys['window'] = _epath(@id) if @id
if keys['create']
@p_create = keys['create']
# if @p_create.kind_of?(Proc)
if TkComm._callback_entry?(@p_create)
=begin
keys['create'] = install_cmd(proc{
@id = @p_create.call
if @id.kind_of?(TkWindow)
@id.epath
else
@id
end
})
=end
keys['create'] = install_cmd(proc{@id = @p_create.call; _epath(@id)})
end
end
tk_call_without_enc(@t.path, 'window', 'create', @index,
*hash_kv(keys, true))
@path.gravity = 'right'
end
def id
Tk::Text::IndexString.new(_epath(@id))
end
def mark
@path
end
def [](slot)
cget(slot)
end
def []=(slot, value)
configure(slot, value)
value
end
def cget(slot)
@t.window_cget(@index, slot)
end
def cget_strict(slot)
@t.window_cget_strict(@index, slot)
end
def configure(slot, value=None)
if slot.kind_of?(Hash)
slot = _symbolkey2str(slot)
if slot['window']
@id = slot['window']
# slot['window'] = @id.epath if @id.kind_of?(TkWindow)
slot['window'] = _epath(@id) if @id
end
if slot['create']
self.create=slot.delete('create')
end
if slot.size > 0
tk_call_without_enc(@t.path, 'window', 'configure', @index,
*hash_kv(slot, true))
end
else
if slot == 'window' || slot == :window
@id = value
# value = @id.epath if @id.kind_of?(TkWindow)
value = _epath(@id) if @id
end
if slot == 'create' || slot == :create
self.create=value
else
tk_call_without_enc(@t.path, 'window', 'configure', @index,
"-#{slot}", _get_eval_enc_str(value))
end
end
self
end
def configinfo(slot = nil)
@t.window_configinfo(@index, slot)
end
def current_configinfo(slot = nil)
@t.current_window_configinfo(@index, slot)
end
def window
@id
end
def window=(value)
@id = value
# value = @id.epath if @id.kind_of?(TkWindow)
value = _epath(@id) if @id
tk_call_without_enc(@t.path, 'window', 'configure', @index,
'-window', _get_eval_enc_str(value))
value
end
def create
@p_create
end
def create=(value)
@p_create = value
# if @p_create.kind_of?(Proc)
if TkComm._callback_entry?(@p_create)
value = install_cmd(proc{
@id = @p_create.call
if @id.kind_of?(TkWindow)
@id.epath
else
@id
end
})
end
tk_call_without_enc(@t.path, 'window', 'configure', @index,
'-create', _get_eval_enc_str(value))
value
end
end
TktWindow = TkTextWindow
|