summaryrefslogtreecommitdiff
path: root/ext/tk
diff options
context:
space:
mode:
Diffstat (limited to 'ext/tk')
-rw-r--r--ext/tk/lib/tk.rb51
-rw-r--r--ext/tk/lib/tkfont.rb35
2 files changed, 38 insertions, 48 deletions
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb
index 8fc57f307e..2aa49879fd 100644
--- a/ext/tk/lib/tk.rb
+++ b/ext/tk/lib/tk.rb
@@ -228,7 +228,7 @@ module TkComm
return '' if cmd == ''
id = _next_cmd_id
Tk_CMDTBL[id] = cmd
- @cmdtbl = [] if not @cmdtbl
+ @cmdtbl = [] unless @cmdtbl
@cmdtbl.push id
return format("rb_out %s", id);
end
@@ -711,14 +711,14 @@ class TkVariable
elsif val.kind_of?(Array)
a = []
val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e))}
- s = '"' + a.join(" ").gsub(/[][$"]/, '\\\\\&') + '"' #'
+ s = '"' + a.join(" ").gsub(/[][$"]/, '\\\\\&') + '"'
INTERP._eval(format('global %s; array set %s %s', @id, @id, s))
elsif val.kind_of?(Hash)
s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
- .gsub(/[][$"]/, '\\\\\&') + '"' #'
+ .gsub(/[][$"]/, '\\\\\&') + '"'
INTERP._eval(format('global %s; array set %s %s', @id, @id, s))
else
- s = '"' + _get_eval_string(val).gsub(/[][$"]/, '\\\\\&') + '"' #'
+ s = '"' + _get_eval_string(val).gsub(/[][$"]/, '\\\\\&') + '"'
INTERP._eval(format('global %s; set %s %s', @id, @id, s))
end
end
@@ -738,16 +738,15 @@ class TkVariable
if INTERP._eval(format('global %s; array exists %s', @id, @id)) != "1"
raise
else
- Hash[*tk_split_simplelist(INTERP\
- ._eval(format('global %s; array get %s',
- @id, @id)))]
+ Hash[*tk_split_simplelist(INTERP._eval(format('global %s; array get %s',
+ @id, @id)))]
end
end
end
def value=(val)
begin
- s = '"' + _get_eval_string(val).gsub(/[][$"]/, '\\\\\&') + '"' #'
+ s = '"' + _get_eval_string(val).gsub(/[][$"]/, '\\\\\&') + '"'
INTERP._eval(format('global %s; set %s %s', @id, @id, s))
rescue
if INTERP._eval(format('global %s; array exists %s', @id, @id)) != "1"
@@ -760,12 +759,12 @@ class TkVariable
elsif val.kind_of?(Array)
a = []
val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e))}
- s = '"' + a.join(" ").gsub(/[][$"]/, '\\\\\&') + '"' #'
+ s = '"' + a.join(" ").gsub(/[][$"]/, '\\\\\&') + '"'
INTERP._eval(format('global %s; unset %s; array set %s %s',
@id, @id, @id, s))
elsif val.kind_of?(Hash)
s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
- .gsub(/[][$"]/, '\\\\\&') + '"' #'
+ .gsub(/[][$"]/, '\\\\\&') + '"'
INTERP._eval(format('global %s; unset %s; array set %s %s',
@id, @id, @id, s))
else
@@ -972,7 +971,7 @@ class TkVarAccess<TkVariable
def initialize(varname, val=nil)
@id = varname
if val
- s = '"' + _get_eval_string(val).gsub(/[][$"]/, '\\\\\&') + '"' #'
+ s = '"' + _get_eval_string(val).gsub(/[][$"]/, '\\\\\&') + '"'
INTERP._eval(format('global %s; set %s %s', @id, @id, s))
end
end
@@ -1600,17 +1599,21 @@ class TkObject<TkKernel
def configure(slot, value=None)
if slot.kind_of? Hash
- if ( slot['font'] || slot['kanjifont'] \
- || slot['latinfont'] || slot['asciifont'] )
+ if (slot['font'] || slot['kanjifont'] ||
+ slot['latinfont'] || slot['asciifont'] )
font_configure(slot.dup)
else
tk_call path, 'configure', *hash_kv(slot)
end
else
- if ( slot == 'font' || slot == 'kanjifont' \
- || slot == 'latinfont' || slot == 'asciifont' )
- font_configure({slot=>value})
+ if (slot == 'font' || slot == 'kanjifont' ||
+ slot == 'latinfont' || slot == 'asciifont')
+ if value == None
+ fontobj
+ else
+ font_configure({slot=>value})
+ end
else
tk_call path, 'configure', "-#{slot}", value
end
@@ -1624,13 +1627,11 @@ class TkObject<TkKernel
def configinfo(slot = nil)
if slot == 'font' || slot == 'kanjifont'
fontobj
-
else
if slot
conf = tk_split_list(tk_send('configure', "-#{slot}") )
conf[0] = conf[0][1..-1]
conf
-
else
ret = tk_split_list(tk_send('configure') ).collect{|conf|
conf[0] = conf[0][1..-1]
@@ -2360,27 +2361,21 @@ class TkMenu<TkWindow
def yposition(index)
number(tk_send('yposition', index))
end
- def entryconfigure(index, keys=nil)
- tk_send 'entryconfigure', index, *hash_kv(keys)
- end
-# def entryconfigure(index, keys=nil)
-# tk_send 'entryconfigure', index, *hash_kv(keys)
-# end
def entrycget(index, key)
tk_tcl2ruby tk_send 'entrycget', index, "-#{key}"
end
def entryconfigure(index, key, val=None)
if key.kind_of? Hash
- if ( key['font'] || key['kanjifont'] \
- || key['latinfont'] || key['asciifont'] )
+ if (key['font'] || key['kanjifont'] ||
+ key['latinfont'] || key['asciifont'])
tagfont_configure(index, key.dup)
else
tk_send 'entryconfigure', index, *hash_kv(key)
end
else
- if ( key == 'font' || key == 'kanjifont' \
- || key == 'latinfont' || key == 'asciifont' )
+ if (key == 'font' || key == 'kanjifont' ||
+ key == 'latinfont' || key == 'asciifont' )
tagfont_configure({key=>val})
else
tk_call 'entryconfigure', index, "-#{key}", val
diff --git a/ext/tk/lib/tkfont.rb b/ext/tk/lib/tkfont.rb
index 421988aeca..1526f68d88 100644
--- a/ext/tk/lib/tkfont.rb
+++ b/ext/tk/lib/tkfont.rb
@@ -153,8 +153,8 @@ class TkFont
charset = (info = font['charset'] .to_s)? info: '*'
encoding = (info = font['encoding'].to_s)? info: '*'
- Array([foundry, family, weight, slant, swidth, adstyle,
- pixels, points, resx, resy, space, avgWidth, charset, encoding])
+ [foundry, family, weight, slant, swidth, adstyle,
+ pixels, points, resx, resy, space, avgWidth, charset, encoding]
end
def create_latinfont_tk4x(font)
@@ -238,13 +238,10 @@ class TkFont
}
@kanjifont = '-' + _get_font_info_from_hash(finfo).join('-') + '-'
-
elsif font.kind_of? TkFont
@kanjifont = font.kanji_font
-
else
@kanjifont = font
-
end
end
@@ -309,11 +306,9 @@ class TkFont
elsif font.kind_of? TkFont
tk_call('font', 'create', @kanjifont, '-copy', font.kanji_font)
-
else
tk_call('font', 'create', @kanjifont, '-copy', font,
'-charset', 'jisx0208.1983')
-
end
end
@@ -397,9 +392,9 @@ class TkFont
if option
""
else
- Array([ ['family',[]], ['size',[]], ['weight',[]], ['slant',[]],
- ['underline',[]], ['overstrike',[]], ['charset',[]],
- ['pointadjust',[]] ])
+ [['family',[]], ['size',[]], ['weight',[]], ['slant',[]],
+ ['underline',[]], ['overstrike',[]], ['charset',[]],
+ ['pointadjust',[]]]
end
end
@@ -440,9 +435,9 @@ class TkFont
if option
""
else
- Array([ ['family',[]], ['size',[]], ['weight',[]], ['slant',[]],
- ['underline',[]], ['overstrike',[]], ['charset',[]],
- ['pointadjust',[]] ])
+ [['family',[]], ['size',[]], ['weight',[]], ['slant',[]],
+ ['underline',[]], ['overstrike',[]], ['charset',[]],
+ ['pointadjust',[]]]
end
end
@@ -583,15 +578,15 @@ class TkFont
def kanji_replace_core_tk81(knj)
if font.kind_of? Hash
- tk_call('font', 'configure', @compoundfont, *hash_kv(font))
+ tk_call('font', 'configure', @compoundfont, *hash_kv(knj))
else
keys = {}
- if font.kind_of? Array
- actual_core(array2tk_list(font)).each{|key,val| keys[key] = val}
- elsif font.kind_of? TkFont
- actual_core(font.latin_font).each{|key,val| keys[key] = val}
+ if knj.kind_of? Array
+ actual_core(array2tk_list(knj)).each{|key,val| keys[key] = val}
+ elsif knj.kind_of? TkFont
+ actual_core(knj.latin_font).each{|key,val| keys[key] = val}
else
- actual_core(font).each{|key,val| keys[key] = val}
+ actual_core(knj).each{|key,val| keys[key] = val}
end
tk_call('font', 'configure', @compoundfont, *hash_kv(keys))
end
@@ -616,7 +611,7 @@ class TkFont
if option
""
else
- Array([ ['ascent',[]], ['descent',[]], ['linespace',[]], ['fixed',[]] ])
+ [['ascent',[]], ['descent',[]], ['linespace',[]], ['fixed',[]]]
end
end