Skip to content

Commit 2a99d2c

Browse files
committed
Assume Tk 8.* code applies to Tk 9.* as well
Remove code for Tk 4.*. Tk 8.0 was released in 1997. Fixes #81
1 parent d7bd07d commit 2a99d2c

31 files changed

Lines changed: 378 additions & 918 deletions

lib/tk.rb

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2396,15 +2396,15 @@ def Tk.strictMotif(mode=None)
23962396

23972397
def Tk.show_kinsoku(mode='both')
23982398
begin
2399-
if /^8\.*/ === TK_VERSION && JAPANIZED_TK
2399+
if JAPANIZED_TK
24002400
tk_split_simplelist(tk_call('kinsoku', 'show', mode))
24012401
end
24022402
rescue
24032403
end
24042404
end
24052405
def Tk.add_kinsoku(chars, mode='both')
24062406
begin
2407-
if /^8\.*/ === TK_VERSION && JAPANIZED_TK
2407+
if JAPANIZED_TK
24082408
tk_split_simplelist(tk_call('kinsoku', 'add', mode,
24092409
*(chars.split(''))))
24102410
else
@@ -2416,7 +2416,7 @@ def Tk.add_kinsoku(chars, mode='both')
24162416
end
24172417
def Tk.delete_kinsoku(chars, mode='both')
24182418
begin
2419-
if /^8\.*/ === TK_VERSION && JAPANIZED_TK
2419+
if JAPANIZED_TK
24202420
tk_split_simplelist(tk_call('kinsoku', 'delete', mode,
24212421
*(chars.split(''))))
24222422
end
@@ -3813,12 +3813,7 @@ def __cget_core(slot)
38133813
unless fnt.kind_of?(TkFont)
38143814
fnt = fontobj(fontkey)
38153815
end
3816-
if fontcode == 'kanji' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
3817-
# obsolete; just for compatibility
3818-
fnt.kanji_font
3819-
else
3820-
fnt
3821-
end
3816+
fnt
38223817

38233818
when /^(#{__tkvariable_optkeys.join('|')})$/
38243819
v = tk_call_without_enc(*(__cget_cmd << "-#{slot}"))

lib/tk/canvas.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,7 @@ def itemcget(tagOrId, option)
301301
unless fnt.kind_of?(TkFont)
302302
fnt = tagfontobj(tagid(tagOrId), fnt)
303303
end
304-
if option.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
305-
# obsolete; just for compatibility
306-
fnt.kanji_font
307-
else
308-
fnt
309-
end
304+
fnt
310305
else
311306
tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', tagid(tagOrId),
312307
"-#{option}")))

lib/tk/font.rb

Lines changed: 33 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ def SYSTEM_FONT_NAMES.include?(name)
5252

5353
# set default font
5454
case Tk::TK_VERSION
55-
when /^4\..*/
56-
DEFAULT_LATIN_FONT_NAME = 'a14'.freeze
57-
DEFAULT_KANJI_FONT_NAME = 'k14'.freeze
58-
5955
when /^8\.[0-4]/
6056
if JAPANIZED_TK
6157
begin
@@ -122,19 +118,14 @@ def SYSTEM_FONT_NAMES.include?(name)
122118
DEFAULT_LATIN_FONT_NAME = ltn.freeze
123119
DEFAULT_KANJI_FONT_NAME = knj.freeze
124120

125-
when /^8\.[5-9]/, /^9\..*/
121+
else
126122
if tk_call('font', 'names') =~ /\bTkDefaultFont\b/
127123
DEFAULT_LATIN_FONT_NAME = 'TkDefaultFont'.freeze
128124
DEFAULT_KANJI_FONT_NAME = 'TkDefaultFont'.freeze
129125
else
130126
DEFAULT_LATIN_FONT_NAME = 'Helvetica'.freeze
131127
DEFAULT_KANJI_FONT_NAME = 'mincho'.freeze
132128
end
133-
134-
else # unknown version
135-
DEFAULT_LATIN_FONT_NAME = 'Helvetica'.freeze
136-
DEFAULT_KANJI_FONT_NAME = 'mincho'.freeze
137-
138129
end
139130

140131
if $DEBUG
@@ -346,34 +337,15 @@ def TkFont.metrics_hash_displayof(fnt, win, option=nil)
346337
end
347338

348339
def TkFont.families(win=nil)
349-
case (Tk::TK_VERSION)
350-
when /^4\..*/
351-
['fixed']
352-
353-
when /^8\..*/
354-
if win
355-
tk_split_simplelist(tk_call('font', 'families', '-displayof', win))
356-
else
357-
tk_split_simplelist(tk_call('font', 'families'))
358-
end
340+
if win
341+
tk_split_simplelist(tk_call('font', 'families', '-displayof', win))
342+
else
343+
tk_split_simplelist(tk_call('font', 'families'))
359344
end
360345
end
361346

362347
def TkFont.names
363-
case (Tk::TK_VERSION)
364-
when /^4\..*/
365-
r = ['fixed']
366-
r += ['a14', 'k14'] if JAPANIZED_TK
367-
Tk_FontNameTBL.mutex.synchronize{
368-
Tk_FontNameTBL.each_value{|obj| r.push(obj)}
369-
}
370-
#r | []
371-
r.uniq
372-
373-
when /^8\..*/
374-
tk_split_simplelist(tk_call('font', 'names'))
375-
376-
end
348+
tk_split_simplelist(tk_call('font', 'names'))
377349
end
378350

379351
def TkFont.create_copy(font)
@@ -406,32 +378,6 @@ def TkFont.init_widget_font(pathname, *args)
406378
path = [win, tag, key].join(';')
407379

408380
case (Tk::TK_VERSION)
409-
when /^4\..*/
410-
regexp = /^-(|kanji)#{key} /
411-
412-
conf_list = tk_split_simplelist(tk_call(*args)).
413-
find_all{|prop| prop =~ regexp}.
414-
collect{|prop| tk_split_simplelist(prop)}
415-
416-
if conf_list.size == 0
417-
raise RuntimeError, "the widget may not support 'font' option"
418-
end
419-
420-
args << {}
421-
422-
ltn_key = "-#{key}"
423-
knj_key = "-kanji#{key}"
424-
425-
ltn_info = conf_list.find{|conf| conf[0] == ltn_key}
426-
ltn = ltn_info[-1]
427-
ltn = nil if ltn == [] || ltn == ""
428-
429-
knj_info = conf_list.find{|conf| conf[0] == knj_key}
430-
knj = knj_info[-1]
431-
knj = nil if knj == [] || knj == ""
432-
433-
TkFont.new(ltn, knj).call_font_configure([path, key], *args)
434-
435381
when /^8\.[0-4]/
436382
regexp = /^-#{key} /
437383

@@ -479,7 +425,7 @@ def TkFont.init_widget_font(pathname, *args)
479425
end
480426
end
481427

482-
when /^8\.[5-9]/, /^9\..*/
428+
else
483429
regexp = /^-#{key} /
484430

485431
conf_list = tk_split_simplelist(tk_call(*args)).
@@ -527,7 +473,7 @@ def TkFont.used_on(path=nil)
527473

528474
def TkFont.failsafe(font)
529475
begin
530-
if /^8\..*/ === Tk::TK_VERSION && JAPANIZED_TK
476+
if JAPANIZED_TK
531477
tk_call('font', 'failsafe', font)
532478
end
533479
rescue
@@ -552,36 +498,23 @@ def init_dummy_fontobj
552498
# @kanji_desscendant = nil
553499
@descendant = [nil, nil] # [latin, kanji]
554500

555-
case (Tk::TK_VERSION)
556-
when /^4\..*/
557-
@latinfont = ""
558-
@kanjifont = ""
559-
if JAPANIZED_TK
560-
@compoundfont = [[@latinfont], [@kanjifont]]
561-
@fontslot = {'font'=>@latinfont, 'kanjifont'=>@kanjifont}
562-
else
563-
@compoundfont = @latinfont
564-
@fontslot = {'font'=>@latinfont}
565-
end
566-
else
567-
@latinfont = @id + 'l'
568-
@kanjifont = @id + 'k'
569-
@compoundfont = @id + 'c'
570-
571-
if JAPANIZED_TK
572-
tk_call('font', 'create', @latinfont, '-charset', 'iso8859')
573-
tk_call('font', 'create', @kanjifont, '-charset', 'jisx0208.1983')
574-
tk_call('font', 'create', @compoundfont,
575-
'-compound', [@latinfont, @kanjifont])
576-
else
577-
tk_call('font', 'create', @latinfont)
578-
tk_call('font', 'create', @kanjifont)
579-
tk_call('font', 'create', @compoundfont)
580-
end
501+
@latinfont = @id + 'l'
502+
@kanjifont = @id + 'k'
503+
@compoundfont = @id + 'c'
581504

582-
@fontslot = {'font'=>@compoundfont}
505+
if JAPANIZED_TK
506+
tk_call('font', 'create', @latinfont, '-charset', 'iso8859')
507+
tk_call('font', 'create', @kanjifont, '-charset', 'jisx0208.1983')
508+
tk_call('font', 'create', @compoundfont,
509+
'-compound', [@latinfont, @kanjifont])
510+
else
511+
tk_call('font', 'create', @latinfont)
512+
tk_call('font', 'create', @kanjifont)
513+
tk_call('font', 'create', @compoundfont)
583514
end
584515

516+
@fontslot = {'font'=>@compoundfont}
517+
585518
self
586519
end
587520

@@ -637,11 +570,7 @@ def initialize(ltn=nil, knj=nil, keys=nil)
637570

638571
if ltn
639572
if JAPANIZED_TK && !knj
640-
if Tk::TK_VERSION =~ /^4..*/
641-
knj = DEFAULT_KANJI_FONT_NAME
642-
else
643-
knj = ltn
644-
end
573+
knj = ltn
645574
end
646575
else
647576
ltn = DEFAULT_LATIN_FONT_NAME
@@ -1586,7 +1515,7 @@ def kanji_metrics_hash_displayof(win, option=nil)
15861515

15871516
def reset_pointadjust
15881517
begin
1589-
if /^8\..*/ === Tk::TK_VERSION && JAPANIZED_TK
1518+
if JAPANIZED_TK
15901519
configure('pointadjust' => latin_actual.assoc('size')[1].to_f /
15911520
kanji_actual.assoc('size')[1].to_f )
15921521
end
@@ -1599,11 +1528,6 @@ def reset_pointadjust
15991528
# private alias
16001529
###################################
16011530
case (Tk::TK_VERSION)
1602-
when /^4\..*/
1603-
alias create_latinfont create_latinfont_tk4x
1604-
alias create_kanjifont create_kanjifont_tk4x
1605-
alias create_compoundfont create_compoundfont_tk4x
1606-
16071531
when /^8\.[0-5]/
16081532
alias create_latinfont create_latinfont_tk8x
16091533
alias create_kanjifont create_kanjifont_tk8x
@@ -2188,41 +2112,15 @@ def metrics_core_tk8x(font, win, option=nil)
21882112
###################################
21892113
# private alias
21902114
###################################
2191-
case (Tk::TK_VERSION)
2192-
when /^4\..*/
2193-
alias actual_core actual_core_tk4x
2194-
alias configure_core configure_core_tk4x
2195-
alias configinfo_core configinfo_core_tk4x
2196-
alias current_configinfo_core current_configinfo_core_tk4x
2197-
alias delete_core delete_core_tk4x
2198-
alias latin_replace_core latin_replace_core_tk4x
2199-
alias kanji_replace_core kanji_replace_core_tk4x
2200-
alias measure_core measure_core_tk4x
2201-
alias metrics_core metrics_core_tk4x
2202-
2203-
when /^8\.[0-9]/
2204-
alias actual_core actual_core_tk8x
2205-
alias configure_core configure_core_tk8x
2206-
alias configinfo_core configinfo_core_tk8x
2207-
alias current_configinfo_core current_configinfo_core_tk8x
2208-
alias delete_core delete_core_tk8x
2209-
alias latin_replace_core latin_replace_core_tk8x
2210-
alias kanji_replace_core kanji_replace_core_tk8x
2211-
alias measure_core measure_core_tk8x
2212-
alias metrics_core metrics_core_tk8x
2213-
2214-
else
2215-
alias actual_core actual_core_tk8x
2216-
alias configure_core configure_core_tk8x
2217-
alias configinfo_core configinfo_core_tk8x
2218-
alias current_configinfo_core current_configinfo_core_tk8x
2219-
alias delete_core delete_core_tk8x
2220-
alias latin_replace_core latin_replace_core_tk8x
2221-
alias kanji_replace_core kanji_replace_core_tk8x
2222-
alias measure_core measure_core_tk8x
2223-
alias metrics_core metrics_core_tk8x
2224-
2225-
end
2115+
alias actual_core actual_core_tk8x
2116+
alias configure_core configure_core_tk8x
2117+
alias configinfo_core configinfo_core_tk8x
2118+
alias current_configinfo_core current_configinfo_core_tk8x
2119+
alias delete_core delete_core_tk8x
2120+
alias latin_replace_core latin_replace_core_tk8x
2121+
alias kanji_replace_core kanji_replace_core_tk8x
2122+
alias measure_core measure_core_tk8x
2123+
alias metrics_core metrics_core_tk8x
22262124
end
22272125

22282126
class TkFont

lib/tk/itemconfig.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,7 @@ def __itemcget_core(tagOrId, option)
239239
unless fnt.kind_of?(TkFont)
240240
fnt = tagfontobj(tagid(tagOrId), fontkey)
241241
end
242-
if fontcode == 'kanji' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
243-
# obsolete; just for compatibility
244-
fnt.kanji_font
245-
else
246-
fnt
247-
end
242+
fnt
248243
else
249244
tk_tcl2ruby(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")), true)
250245
end

lib/tk/listbox.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,7 @@ def itemcget(index, key)
116116
unless fnt.kind_of?(TkFont)
117117
fnt = tagfontobj(index, fnt)
118118
end
119-
if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
120-
# obsolete; just for compatibility
121-
fnt.kanji_font
122-
else
123-
fnt
124-
end
119+
fnt
125120
else
126121
tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', index, "-#{key}")))
127122
end

lib/tk/menu.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,7 @@ def entrycget(index, key)
224224
unless fnt.kind_of?(TkFont)
225225
fnt = tagfontobj(index, fnt)
226226
end
227-
if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
228-
# obsolete; just for compatibility
229-
fnt.kanji_font
230-
else
231-
fnt
232-
end
227+
fnt
233228
else
234229
tk_tcl2ruby(_fromUTF8(tk_send_without_enc('entrycget', _get_eval_enc_str(index), "-#{key}")))
235230
end

lib/tk/text.rb

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -814,12 +814,7 @@ def tag_cget(tag, key)
814814
unless fnt.kind_of?(TkFont)
815815
fnt = tagfontobj(tag, fnt)
816816
end
817-
if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
818-
# obsolete; just for compatibility
819-
fnt.kanji_font
820-
else
821-
fnt
822-
end
817+
fnt
823818
else
824819
tk_tcl2ruby(_fromUTF8(tk_call_without_enc(@path,'tag','cget',_get_eval_enc_str(tag),"-#{key}")))
825820
end
@@ -1039,12 +1034,7 @@ def window_cget(index, slot)
10391034
unless fnt.kind_of?(TkFont)
10401035
fnt = tagfontobj(index, fnt)
10411036
end
1042-
if slot.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
1043-
# obsolete; just for compatibility
1044-
fnt.kanji_font
1045-
else
1046-
fnt
1047-
end
1037+
fnt
10481038
else
10491039
tk_tcl2ruby(_fromUTF8(tk_send_without_enc('window', 'cget', _get_eval_enc_str(index), "-#{slot}")))
10501040
end

lib/tk/texttag.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,7 @@ def cget(key)
151151
unless fnt.kind_of?(TkFont)
152152
fnt = tagfontobj(@id, fnt)
153153
end
154-
if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
155-
# obsolete; just for compatibility
156-
fnt.kanji_font
157-
else
158-
fnt
159-
end
154+
fnt
160155
else
161156
tk_tcl2ruby(_fromUTF8(tk_call_without_enc(@t.path, 'tag', 'cget',
162157
@id, "-#{key}")))

0 commit comments

Comments
 (0)