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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
|
require "base/file"
require "base/logger"
class String
# real dirty, but inspect does a pretty good escaping but
# unfortunately puts quotes around the string so we need
# to strip these
# def escaped
# self.inspect[1,self.inspect.size-2]
# end
def escaped
str = self.inspect ; str[1,str.size-2]
end
def splitdata
if self =~ /^\s*(.*?)\s*\{(.*)\}\s*$/o then
first, second = $1, $2
if first.empty? then
[second.split(/\} \{/o)].flatten
else
[first.split(/\s+/o)] + [second.split(/\} \{/o)]
end
else
[]
end
end
end
class Logger
def banner(str)
report(str)
return "%\n% #{str}\n%\n"
end
end
class TeXUtil
class Plugin
# we need to reset module data for each run; persistent data is
# possible, just don't reinitialize the data structures that need
# to be persistent; we reset afterwards becausethen we know what
# plugins are defined
def initialize(logger)
@plugins = Array.new
@logger = logger
end
def reset(name)
if @plugins.include?(name) then
begin
eval("#{name}").reset(@logger)
rescue Exception
@logger.report("fatal error in resetting plugin")
end
else
@logger.report("no plugin #{name}")
end
end
def resets
@plugins.each do |p|
reset(p)
end
end
def register(name, file=nil) # maybe also priority
if file then
begin
require("#{file.downcase.sub(/\.rb$/,'')}.rb")
rescue Exception
@logger.report("no plugin file #{file} for #{name}")
else
@plugins.push(name)
end
else
@plugins.push(name)
end
return self
end
def reader(name, data=[])
if @plugins.include?(name) then
begin
eval("#{name}").reader(@logger,data.flatten)
rescue Exception
@logger.report("fatal error in plugin reader #{name} (#{$!})")
end
else
@logger.report("no plugin #{name}")
end
end
def readers(data=[])
@plugins.each do |p|
reader(p,data.flatten)
end
end
def writers(handle)
@plugins.each do |p|
begin
eval("#{p}").writer(@logger,handle)
rescue Exception
@logger.report("fatal error in plugin writer #{p} (#{$!})")
end
end
end
def processors
@plugins.each do |p|
begin
eval("#{p}").processor(@logger)
rescue Exception
@logger.report("fatal error in plugin processor #{p} (#{$!})")
end
end
end
end
class Sorter
def initialize(max=12)
@rep, @map, @exp, @div = Hash.new, Hash.new, Hash.new, Hash.new
@max = max
@rexa, @rexb = nil, nil
end
def replacer(from,to='') # and expand
@max = [@max,to.length+1].max if to
@rep[from.escaped] = to || ''
end
# sorter.reducer('ch', 'c')
# sorter.reducer('ij', 'y')
def reducer(from,to='')
@max = [@max,to.length+1].max if to
@map[from] = to || ''
end
# sorter.expander('aeligature', 'ae')
# sorter.expander('ijligature', 'y')
def expander(from,to=nil)
from, to = converted(from), converted(to)
@max = [@max,to.length+1].max if to
@exp[from] = to || from || ''
end
def division(from,to=nil)
from, to = converted(from), converted(to)
@max = [@max,to.length+1].max if to
@div[from] = to || from || ''
end
# shortcut("\\ab\\cd\\e\\f", 'iacute')
# shortcut("\\\'\\i", 'iacute')
# shortcut("\\\'i", 'iacute')
# shortcut("\\\"e", 'ediaeresis')
# shortcut("\\\'o", 'oacute')
def shortcut(from,to)
replacer(from,to)
expander(to)
end
def prepare
if @rep.size > 0 then
@rexa = /(#{@rep.keys.join('|')})/ # o
else
@rexa = nil
end
if @map.size > 0 then
# watch out, order of match matters
@rexb = /(\\[a-zA-Z]+|#{@map.keys.join('|')}|.)\s*/ # o
else
@rexb = /(\\[a-zA-Z]+|.)\s*/o
end
end
def remap(str)
s = str.dup
s.gsub!(/(\d+)/o) do
$1.rjust(10,'a') # rest is b .. k
end
if @rexa then
s.gsub!(@rexa) do
@rep[$1.escaped]
end
end
if @rexb then
s.gsub!(@rexb) do
token = $1.sub(/\\/o, '')
if @exp.key?(token) then
@exp[token].ljust(@max,' ')
elsif @map.key?(token) then
@map[token].ljust(@max,' ')
else
''
end
end
end
s
end
def preset(shortcuts=[],expansions=[],reductions=[],divisions=[])
# maybe we should move this to sort-def.tex
'a'.upto('z') do |c| expander(c) ; division(c) end
expander('1','b') ; expander('2','c') ; expander('3','e') ; expander('4','f')
expander('5','g') ; expander('6','h') ; expander('7','i') ; expander('8','i')
expander('9','j') ; expander('0','a') ; expander('-','-') ;
# end potential move
shortcuts.each do |s| shortcut(s[0],s[1]) end
expansions.each do |e| expander(e[0],e[1]) end
reductions.each do |r| reducer(r[0],r[1]) end
divisions.each do |d| division(d[0],d[1]) end
end
def simplify(str)
s = str.dup
# ^^
# s.gsub!(/\^\^([a-f0-9][a-f0-9])/o, $1.hex.chr)
# \- ||
s.gsub!(/(\\\-|\|\|)/o) do '-' end
# {}
s.gsub!(/\{\}/o) do '' end
# <*..> (internal xml entity)
s.gsub!(/<\*(.*?)>/o) do $1 end
# entities
s.gsub!(/\\getXMLentity\s*\{(.*?)\}/o) do $1 end
# elements
s.gsub!(/\<.*?>/o) do '' end
# what to do with xml and utf-8
# \"e etc
# unknown \cs
s.gsub!(/\\[a-z][a-z]+\s*\{(.*?)\}/o) do $1 end
return s
end
def getdivision(str)
@div[str] || str
end
def division?(str)
@div.key?(str)
end
private
def converted(str)
if str then
str.gsub(/([\+\-]*\d+)/o) do
n = $1.to_i
if n > 0 then
'z'*n
elsif n < 0 then
'-'*(-n) # '-' precedes 'a'
else
''
end
end
else
nil
end
end
end
class Plugin
module MyFiles
@@files = Hash.new
def MyFiles::reset(logger)
@@files = Hash.new
end
def MyFiles::reader(logger,data)
case data[0]
when 'b', 'e' then
if @@files.key?(data[1]) then
@@files[data[1]] += 1
else
@@files[data[1]] = 1
end
end
end
def MyFiles::writer(logger,handle)
handle << logger.banner("loaded files: #{@@files.size}")
@@files.keys.sort.each do |k|
handle << "% > #{k} #{@@files[k]/2}\n"
end
end
def MyFiles::processor(logger)
@@files.keys.sort.each do |k|
unless (@@files[k] % 2) == 0 then
logger.report("check loading of file #{k}, begin/end problem")
end
end
end
end
end
class Plugin
module MyCommands
@@commands = []
def MyCommands::reset(logger)
@@commands = []
end
def MyCommands::reader(logger,data)
@@commands.push(data.shift+data.collect do |d| "\{#{d}\}" end.join)
end
def MyCommands::writer(logger,handle)
handle << logger.banner("commands: #{@@commands.size}")
@@commands.each do |c|
handle << "#{c}\n"
end
end
def MyCommands::processor(logger)
end
end
end
class Plugin
module MyExtras
@@programs = []
def MyExtras::reset(logger)
@@programs = []
end
def MyExtras::reader(logger,data)
case data[0]
when 'p' then
@@programs.push(data[1]) if data[0]
end
end
def MyExtras::writer(logger,handle)
handle << logger.banner("programs: #{@@programs.size}")
@@programs.each do |p|
handle << "% #{p} (#{@@programs[p.to_i]})\n"
end
end
def MyExtras::processor(logger)
@@programs.each do |p|
cmd = "texmfstart #{@@programs[p.to_i]}"
logger.report("running #{cmd}")
system(cmd)
end
end
end
end
class Plugin
module MySynonyms
class Synonym
@@debug = false
@@debug = true
def initialize(t, c, k, d)
@type, @command, @key, @sortkey, @data = t, c, k, k, d
end
attr_reader :type, :command, :key, :data
attr_reader :sortkey
attr_writer :sortkey
def build(sorter)
@sortkey = sorter.remap(sorter.simplify(@key.downcase))
if @sortkey.empty? then
@sortkey = sorter.remap(@command.downcase)
end
end
def <=> (other)
@sortkey <=> other.sortkey
end
def Synonym.flush(list,handle)
if @@debug then
list.each do |entry|
handle << "% [#{entry.sortkey}]\n"
end
end
list.each do |entry|
handle << "\\synonymentry{#{entry.type}}{#{entry.command}}{#{entry.key}}{#{entry.data}}\n"
end
end
end
@@synonyms = Hash.new
def MySynonyms::reset(logger)
@@synonyms = Hash.new
end
def MySynonyms::reader(logger,data)
if data[0] == 'e' then
@@synonyms[data[1]] = Array.new unless @@synonyms.key?(data[1])
@@synonyms[data[1]].push(Synonym.new(data[1],data[2],data[3],data[4]))
end
end
def MySynonyms::writer(logger,handle)
if @@synonyms.size > 0 then
@@synonyms.keys.sort.each do |s|
handle << logger.banner("synonyms: #{s} #{@@synonyms[s].size}")
Synonym.flush(@@synonyms[s],handle)
end
end
end
def MySynonyms::processor(logger)
sorter = Sorter.new
sorter.preset(eval("MyKeys").shortcuts,eval("MyKeys").expansions,eval("MyKeys").reductions,eval("MyKeys").divisions)
sorter.prepare
@@synonyms.keys.each do |s|
@@synonyms[s].each_index do |i|
@@synonyms[s][i].build(sorter)
end
@@synonyms[s] = @@synonyms[s].sort
end
end
end
end
class Plugin
module MyRegisters
class Register
@@debug = false
@@debug = true
@@howto = /^(.*?)\:\:(.*)$/o
@@split = ' && '
def initialize(state, t, l, k, e, s, p, r)
@state, @type, @location, @key, @entry, @seetoo, @page, @realpage = state, t, l, k, e, s, p, r
if @key =~ @@howto then @pagehowto, @key = $1, $2 else @pagehowto = '' end
if @entry =~ @@howto then @texthowto, @entry = $1, $2 else @texthowto = '' end
@key = @entry.dup if @key.empty?
@sortkey = @key.dup
@nofentries, @nofpages = 0, 0
end
attr_reader :state, :type, :location, :key, :entry, :seetoo, :page, :realpage, :texthowto, :pagehowto
attr_reader :sortkey
attr_writer :sortkey
def build(sorter)
@entry, @key = [@entry, @key].collect do |target|
# +a+b+c &a&b&c a+b+c a&b&c
case target[0,1]
when '&' then target = target.sub(/^./o,'').gsub(/([^\\])\&/o) do "#{$1}#{@@split}" end
when '+' then target = target.sub(/^./o,'').gsub(/([^\\])\+/o) do "#{$1}#{@@split}" end
else target = target .gsub(/([^\\])[\&\+]/o) do "#{$1}#{@@split}" end
end
# {a}{b}{c}
# if target =~ /^\{(.*)\}$/o then
# $1.split(/\} \{/o).join(@@split) # space between } { is mandate
# else
target
# end
end
@sortkey = sorter.simplify(@key)
@sortkey = @sortkey.split(@@split).collect do |c| sorter.remap(c) end.join(@@split)
# if ($Key eq "") { $Key = SanitizedString($Entry) }
# if ($ProcessHigh){ $Key = HighConverted($Key) }
@sortkey = [
@sortkey.downcase,
@sortkey,
@texthowto.ljust(10,' '),
@state,
@realpage.rjust(6,' '),
@pagehowto
].join(@@split)
end
def <=> (other)
@sortkey <=> other.sortkey
end
# more module like
@@savedhowto, @@savedfrom, @@savedto, @@savedentry = '', '', '', '', ''
@@collapse = false
def Register.flushsavedline(handle)
if @@collapse && ! @@savedfrom.empty? then
if ! @@savedto.empty? then
handle << "\\registerfrom#{@@savedfrom}"
handle << "\\registerto#{@@savedto}"
else
handle << "\\registerpage#{@@savedfrom}"
end
end
@@savedhowto, @@savedfrom, @@savedto, @@savedentry = '', '', '', ''
end
def Register.flush(list,handle,sorter)
# a bit messy, quite old mechanism, maybe some day ...
# alphaclass can go, now flushed per class
if list.size > 0 then
@nofentries, @nofpages = 0, 0
current, previous, howto = Array.new, Array.new, Array.new
lastpage, lastrealpage = '', ''
alphaclass, alpha = '', ''
@@savedhowto, @@savedfrom, @@savedto, @@savedentry = '', '', '', ''
if @@debug then
list.each do |entry|
handle << "% [#{entry.sortkey.gsub(/#{@@split}/o,'] [')}]\n"
end
end
list.each do |entry|
if entry.sortkey =~ /^(\S+)/o then
if sorter.division?($1) then
testalpha = sorter.getdivision($1)
else
testalpha = entry.sortkey[0,1].downcase
end
else
testalpha = entry.sortkey[0,1].downcase
end
if testalpha != alpha.downcase or alphaclass != entry.class then
alpha = testalpha
alphaclass = entry.class
if alpha != ' ' then
flushsavedline(handle)
if alpha =~ /^[a-zA-Z]$/o then
character = alpha.dup
elsif alpha.length > 1 then
# character = "\\getvalue\{#{alpha}\}"
character = "\\#{alpha}"
else
character = "\\#{alpha}"
end
handle << "\\registerentry{#{entry.type}}{#{character}}\n"
end
end
current = [entry.entry.split(@@split),'','',''].flatten
howto = current.collect do |e|
e + '::' + entry.texthowto
end
if howto[0] == previous[0] then
current[0] = ''
else
previous[0] = howto[0].dup
previous[1] = ''
previous[2] = ''
end
if howto[1] == previous[1] then
current[1] = ''
else
previous[1] = howto[1].dup
previous[2] = ''
end
if howto[2] == previous[2] then
current[2] = ''
else
previous[2] = howto[2].dup
end
copied = false
unless current[0].empty? then
Register.flushsavedline(handle)
handle << "\\registerentrya{#{entry.type}}{#{current[0]}}\n"
copied = true
end
unless current[1].empty? then
Register.flushsavedline(handle)
handle << "\\registerentryb{#{entry.type}}{#{current[1]}}\n"
copied = true
end
unless current[2].empty? then
Register.flushsavedline(handle)
handle << "\\registerentryc{#{entry.type}}{#{current[2]}}\n"
copied = true
end
@nofentries += 1 if copied
if entry.realpage.to_i == 0 then
Register.flushsavedline(handle)
handle << "\\registersee{#{entry.type}}{#{entry.pagehowto},#{entry.texthowto}}{#{entry.seetoo}}{#{entry.page}}\n" ;
lastpage, lastrealpage = entry.page, entry.realpage
elsif @@savedhowto != entry.pagehowto and ! entry.pagehowto.empty? then
@@savedhowto = entry.pagehowto
end
if copied || ! ((lastpage == entry.page) && (lastrealpage == entry.realpage)) then
nextentry = "{#{entry.type}}{#{previous[0]}}{#{previous[1]}}{#{previous[2]}}{#{entry.pagehowto},#{entry.texthowto}}"
savedline = "{#{entry.type}}{#{@@savedhowto},#{entry.texthowto}}{#{entry.location}}{#{entry.page}}{#{entry.realpage}}"
if entry.state == 1 then # from
Register.flushsavedline(handle)
handle << "\\registerfrom#{savedline}\n"
elsif entry.state == 3 then # to
Register.flushsavedline(handle)
handle << "\\registerto#{savedline}\n"
@@savedhowto = '' # test
elsif @@collapse then
if savedentry != nextentry then
savedFrom = savedline
else
savedTo, savedentry = savedline, nextentry
end
else
handle << "\\registerpage#{savedline}\n"
@@savedhowto = '' # test
end
@nofpages += 1
lastpage, lastrealpage = entry.page, entry.realpage
end
end
Register.flushsavedline(handle)
end
end
end
@@registers = Hash.new
@@sorter = Sorter.new
def MyRegisters::reset(logger)
@@registers = Hash.new
@@sorter = Sorter.new
end
def MyRegisters::reader(logger,data)
case data[0]
when 'f' then
@@registers[data[1]] = Array.new unless @@registers.key?(data[1])
@@registers[data[1]].push(Register.new(1,data[1],data[2],data[3],data[4],nil,data[5],data[6]))
when 'e' then
@@registers[data[1]] = Array.new unless @@registers.key?(data[1])
@@registers[data[1]].push(Register.new(2,data[1],data[2],data[3],data[4],nil,data[5],data[6]))
when 't' then
@@registers[data[1]] = Array.new unless @@registers.key?(data[1])
@@registers[data[1]].push(Register.new(3,data[1],data[2],data[3],data[4],nil,data[5],data[6]))
when 's' then
@@registers[data[1]] = Array.new unless @@registers.key?(data[1])
@@registers[data[1]].push(Register.new(4,data[1],data[2],data[3],data[4],data[5],data[6],nil))
end
end
def MyRegisters::writer(logger,handle)
if @@registers.size > 0 then
@@registers.keys.sort.each do |s|
handle << logger.banner("registers: #{s} #{@@registers[s].size}")
Register.flush(@@registers[s],handle,@@sorter)
# report("register #{@@registers[s].class}: #{@@registers[s].@nofentries} entries and #{@@registers[s].@nofpages} pages")
end
end
end
def MyRegisters::processor(logger)
@@sorter.preset(eval("MyKeys").shortcuts,eval("MyKeys").expansions,eval("MyKeys").reductions,eval("MyKeys").divisions)
@@sorter.prepare
@@registers.keys.each do |s|
@@registers[s].each_index do |i|
@@registers[s][i].build(@@sorter)
end
@@registers[s] = @@registers[s].sort
end
end
end
end
class Plugin
module MyPlugins
@@plugins = nil
def MyPlugins::reset(logger)
@@plugins = nil
end
def MyPlugins::reader(logger,data)
@@plugins = Plugin.new(logger) unless @@plugins
case data[0]
when 'r' then
logger.report("registering plugin #{data[1]}")
@@plugins.register(data[1],data[2])
when 'd' then
begin
@@plugins.reader(data[1],data[2,data.length-1])
rescue
@@plugins.reader(data[1],['error'])
end
end
end
def MyPlugins::writer(logger,handle)
@@plugins.writers(handle) if @@plugins
end
def MyPlugins::processor(logger)
@@plugins.processors if @@plugins
end
end
end
class Plugin
module MyKeys
@@shortcuts = Array.new
@@expansions = Array.new
@@reductions = Array.new
@@divisions = Array.new
def MyKeys::shortcuts
@@shortcuts
end
def MyKeys::expansions
@@expansions
end
def MyKeys::reductions
@@reductions
end
def MyKeys::divisions
@@divisions
end
def MyKeys::reset(logger)
@@shortcuts = Array.new
@@expansions = Array.new
@@reductions = Array.new
end
def MyKeys::reader(logger,data)
key = data.shift
grp = data.shift # language code, todo
case key
when 's' then @@shortcuts.push(data)
when 'e' then @@expansions.push(data)
when 'r' then @@reductions.push(data)
when 'd' then @@divisions.push(data)
end
end
def MyKeys::writer(logger,handle)
end
def MyKeys::processor(logger)
logger.report("shortcuts : #{@@shortcuts.size}") # logger.report(@@shortcuts.inspect)
logger.report("expansions: #{@@expansions.size}") # logger.report(@@expansions.inspect)
logger.report("reductions: #{@@reductions.size}") # logger.report(@@reductions.inspect)
logger.report("divisions : #{@@divisions.size}") # logger.report(@@divisions.inspect)
end
end
end
class Converter
def initialize(logger=nil)
if @logger = logger then
def report(str)
@logger.report(str)
end
def banner(str)
@logger.banner(str)
end
else
@logger = self
def report(str)
puts(str)
end
def banner(str)
puts(str)
end
end
@filename = 'texutil'
@fatalerror = false
@plugins = Plugin.new(@logger)
['MyFiles', 'MyCommands', 'MySynonyms', 'MyRegisters', 'MyExtras', 'MyPlugins', 'MyKeys'].each do |p|
@plugins.register(p)
end
end
def loaded(filename)
begin
report("parsing file #{filename}")
if f = open(File.suffixed(filename,'tui')) then
f.each do |line|
case line.chomp
when /^f (.*)$/o then @plugins.reader('MyFiles', $1.splitdata)
when /^c (.*)$/o then @plugins.reader('MyCommands', [$1])
when /^e (.*)$/o then @plugins.reader('MyExtras', $1.splitdata)
when /^s (.*)$/o then @plugins.reader('MySynonyms', $1.splitdata)
when /^r (.*)$/o then @plugins.reader('MyRegisters',$1.splitdata)
when /^p (.*)$/o then @plugins.reader('MyPlugins', $1.splitdata)
when /^x (.*)$/o then @plugins.reader('MyKeys', $1.splitdata)
else report("unknown entry #{line[0,1]} in line #{line.chomp}")
end
end
f.close
end
rescue
report("fatal error in parsing #{filename}")
@filename = 'texutil'
else
@filename = filename
end
end
def processed
@plugins.processors
return true # for the moment
end
def saved(filename=@filename)
if @fatalerror then
report("fatal error, no tuo file saved")
else
begin
if f = File.open(File.suffixed(filename,'tuo'),'w') then
@plugins.writers(f)
f.close
end
rescue
report("fatal error when saving file (#{$!})")
else
report("tuo file saved")
end
end
@plugins.resets
end
def reset
@plugins.resets
end
end
end
|