Eskil

Diff
Login

Differences From Artifact [26fe15cf73]:

To Artifact [b048b2471a]:


1
2
3
4

5
6
7
8
9
10
11
1
2
3

4
5
6
7
8
9
10
11



-
+







#----------------------------------------------------------------------
#  Eskil, Plugin handling
#
#  Copyright (c) 2008, Peter Spjuth  (peter.spjuth@gmail.com)
#  Copyright (c) 2008-2016, Peter Spjuth  (peter.spjuth@gmail.com)
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
78
79
80
81
82
83
84
85

86
87
88
89
90
91
92
78
79
80
81
82
83
84

85
86
87
88
89
90
91
92







-
+







    $pi eval [list set ::WhoAmI [file rootname [file tail $src]]]
    $pi eval [list set ::WhoAmIFull [file normalize $src]]
    $pi eval [list set ::Info $info]
    interp share {} stdout $pi

    # Expose needed commands
    if {!$allow} {
        interp expose $pi fconfigure ;# ??
        interp expose $pi fconfigure ;# needed??
        interp hide $pi close
    }

    set pinfo {file 0 dir 0}
    dict set pinfo "allow" $allow
    if {[$pi eval info proc PreProcess] ne ""} {
        dict set pinfo file 1
176
177
178
179
180
181
182

183
184
185
186
187
188
189
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190







+







    # Pass ::argv to plugin
    $::eskil($top,plugin) eval [list set ::argv $::eskil(argv)]
    # Pass ::Pref to plugin
    $::eskil($top,plugin) eval [list array set ::Pref [array get ::Pref]]
    # Pass File info to plugin
    $::eskil($top,plugin) eval [list set ::File(left)  $::eskil($top,leftFile)]
    $::eskil($top,plugin) eval [list set ::File(right) $::eskil($top,rightFile)]

    set out1 [tmpFile]
    set out2 [tmpFile]

    set chi [open $::eskil($top,leftFile) r]
    set cho [open $out1 w]
    set chi2 [open $::eskil($top,rightFile) r]
    set cho2 [open $out2 w]
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
237
238
239
240
241
242
243

244
245
246
247
248
249

250
251
252
253
254
255
256







-






-







    if {$usenew1} {
        # The file after processing should be used both
        # for comparison and for displaying.
        set ::eskil($top,leftFileBak) $::eskil($top,leftFile)
        set ::eskil($top,leftFile) $out1
    } else {
        set ::eskil($top,leftFileDiff) $out1
        #set ::eskil($top,leftLabel) "$::eskil($top,RevFile) $tag"
    }
    if {$usenew2} {
        set ::eskil($top,rightFileBak) $::eskil($top,rightFile)
        set ::eskil($top,rightFile) $out2
    } else {
        set ::eskil($top,rightFileDiff) $out2
        #set ::eskil($top,rightLabel) $::eskil($top,RevFile)
    }
}

proc cleanupPlugin {top} {
    if {[info exists ::eskil($top,leftFileBak)]} {
        set ::eskil($top,leftFile) $::eskil($top,leftFileBak)
    }
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
298
299
300
301
302
303
304

305
306
307
308
309
310
311







-







        ttk::label $wt.l$t -text $descr -anchor w
        grid $wt.rb$t $wt.l$t -sticky we -padx 3 -pady 3
        incr t
    }
    ttk::radiobutton $wt.rb$t -variable ::eskil($top,edit,pluginname) \
            -value "" -text "No Plugin"
    grid $wt.rb$t -sticky we -padx 3 -pady 3


    ttk::label $wt.li -text "Info" -anchor w
    addBalloon $wt.li "Info passed to plugin. Plugin specific."
    ttk::entry $wt.ei -textvariable ::eskil($top,edit,plugininfo)
    grid $wt.li $wt.ei -sticky we -padx 3 -pady 3

    ttk::checkbutton $wt.cb -text "Privilege" \
360
361
362
363
364
365
366

367
368
369
370
371
372
373
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372







+







            $t insert end $post\n comment
        } else {
            $t insert end $line\n
        }
    }
}

# Show plugin source
proc ShowPlugin {parent plugin} {
    set src [LocatePlugin $plugin]
    if {$src eq ""} return
    set ch [open $src]
    set data [read $ch]
    close $ch
    set wt $parent.plugin
383
384
385
386
387
388
389
390
382
383
384
385
386
387
388








-

    set t [Scroll both text $wt.t -width 80 -height 30 -font myfont -wrap none]
    pack $wt.t -fill both -expand 1
    bind $t <Control-a> "[list $t tag add sel 1.0 end];break"

    TextViewTcl $t $data
}