Eskil

Diff
Login

Differences From Artifact [765ee32e31]:

To Artifact [a27d09c31d]:


377
378
379
380
381
382
383




384
385
386
387
388
389
390
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394







+
+
+
+







                set chunk [string range $d 0 $ci-1]
                set d [string trim [string range $d $ci end]]
            }
            puts "$outName$chunk"
            set outName [format %*s $indent ""]
        }
    }
    if {$::eskil(opts,src) ne ""} {
        puts ""
        printPlugin $::eskil(opts,src) 1
    }
}

#####################################
# Option/flag handling helpers
#####################################
# Validators
proc optValidatePdfColor {opt arg} {
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
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







-
+
+






-
+
-
-
-
-
+
+
+


-
-
-
+
+
+
-
-




+
+










+










-
+







        puts [join [lsort -dictionary [pdf4tcl::getPaperSizeList]] \n]
        exit
    }
}
proc optValidatePlugin {opt arg} {
    # We must start up completely to check a plugin
    Init
    set src [LocatePlugin $arg]
    set res [LocatePlugin $arg]
    set src [dict get $res src]
    if {$src eq ""} {
        puts "Bad plugin: $arg"
        printPlugins
        exit
    }
    # Look for declarations of command line options
    set ch [open $src r]
    foreach {name flag doc} [dict get $res opts] {
    while {[gets $ch line] >= 0} {
        # Only look until empty line
        if {[string trim $line] eq ""} break
        if {[regexp {^\#\# Option\s+(\S+)} $line -> name]} {
        if {$flag} {
            addFlags $name
        } else {
            addOpt $name
        }
        if {[regexp {^\#\# Flag\s+(\S+)} $line -> name]} {
            addFlags $name
        }
        docFlag $name "Plugin $arg : $doc"
        addSource $name $arg
    }
    }
    close $ch
}
# Option database setup
proc initOpts {} {
    set ::eskil(opts) {}
    set ::eskil(opts,info) {}
    set ::eskil(opts,src) ""
    set ::eskil(defoptinfo) {
        flag 0
        given 0
        multi 0
        type ""
        validator ""
        filter ""
        sideeffect ""
        shortdescr ""
        longdescr ""
        source ""
    } 
}
# Add a command line flag that do not take a value
proc addFlags {args} {
    foreach name $args {
        dict set ::eskil(opts) $name 0
        dict set ::eskil(opts,info) $name $::eskil(defoptinfo)
        dict set ::eskil(opts,info) $name flag  1
    }
}
# Document a flag
# Document a flag or option
proc docFlag {name short {long {}}} {
    dict set ::eskil(opts,info) $name shortdescr $short
    dict set ::eskil(opts,info) $name longdescr $long
}

# Flag that affects Pref
proc addPrefFlag {name elem {value 1}} {
511
512
513
514
515
516
517





518
519
520
521
522
523
524
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534







+
+
+
+
+







proc addValidator {name cmd} {
    dict set ::eskil(opts,info) $name validator $cmd
}
# Add a filter command prefix to an Opt
proc addFilter {name cmd} {
    dict set ::eskil(opts,info) $name filter $cmd
}
# Add a source reference to an Opt
proc addSource {name src} {
    set ::eskil(opts,src) $src
    dict set ::eskil(opts,info) $name source $src
}
# Add a sideeffect to an Opt
##nagelfar syntax addSideEffect x c
proc addSideEffect {name script} {
    dict set ::eskil(opts,info) $name sideeffect $script
}
# Add a command line option that takes a value and stores in local opts
proc addOptsOpt {name elem {validator ""}} {