Eskil

Diff
Login

Differences From Artifact [e6e820f881]:

To Artifact [3701de5a23]:


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
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







-
+


-
-
-
-
-
+
+
+
+
+



-
+

















-
+

-
-
+
+


-
+

-
+


-
-
-
-
+
+
+
+

-
+

-
-
+
+

-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+

-
-
-
+
+
+

-
-
+
+


-
-
+
+







    unset -nocomplain \
            ::eskil($top,leftFileBak) ::eskil($top,rightFileBak) \
            ::eskil($top,leftFileDiff) ::eskil($top,rightFileDiff)
}

# GUI for plugin selection
proc EditPrefPlugins {top {dirdiff 0}} {
    set w $top.prefplugin
    set wt $top.prefplugin

    # Create window
    destroy $w
    toplevel $w -padx 3 -pady 3
    ttk::frame $w._bg
    place $w._bg -x 0 -y 0 -relwidth 1.0 -relheight 1.0 -border outside
    wm title $w "Preferences: Plugins"
    destroy $wt
    toplevel $wt -padx 3 -pady 3
    ttk::frame $wt._bg
    place $wt._bg -x 0 -y 0 -relwidth 1.0 -relheight 1.0 -border outside
    wm title $wt "Preferences: Plugins"

    set plugins [listPlugins]
    if {[llength $plugins] == 0} {
        grid [ttk::label $w.l -text "No plugins found."] - -padx 3 -pady 3
        grid [ttk::label $wt.l -text "No plugins found."] - -padx 3 -pady 3
    }
    if {![info exists ::eskil($top,pluginname)]} {
        set ::eskil($top,pluginname) ""
    }
    if {![info exists ::eskil($top,plugininfo)]} {
        set ::eskil($top,plugininfo) ""
    }
    if {![info exists ::eskil($top,pluginallow)]} {
        set ::eskil($top,pluginallow) 0
    }
    set ::eskil($top,edit,pluginname) $::eskil($top,pluginname)
    set ::eskil($top,edit,plugininfo) $::eskil($top,plugininfo)
    set ::eskil($top,edit,pluginallow) $::eskil($top,pluginallow)
    set t 0
    foreach {plugin info} $plugins {
        set descr [dict get $info descr]
        if {$dirdiff && ![dict get $info dir]} continue
        ttk::radiobutton $w.rb$t -variable ::eskil($top,edit,pluginname) \
        ttk::radiobutton $wt.rb$t -variable ::eskil($top,edit,pluginname) \
                -value $plugin -text $plugin
        ttk::label $w.l$t -text $descr -anchor "w"
        grid $w.rb$t $w.l$t -sticky we -padx 3 -pady 3
        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 $w.rb$t -variable ::eskil($top,edit,pluginname) \
    ttk::radiobutton $wt.rb$t -variable ::eskil($top,edit,pluginname) \
            -value "" -text "No Plugin"
    grid $w.rb$t -sticky we -padx 3 -pady 3
    grid $wt.rb$t -sticky we -padx 3 -pady 3


    ttk::label $w.li -text "Info" -anchor "w"
    addBalloon $w.li "Info passed to plugin. Plugin specific."
    ttk::entry $w.ei -textvariable ::eskil($top,edit,plugininfo)
    grid $w.li $w.ei -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 $w.cb -text "Privilege" \
    ttk::checkbutton $wt.cb -text "Privilege" \
            -variable ::eskil($top,edit,pluginallow)
    addBalloon $w.cb "Run plugin with raised privileges"
    grid $w.cb - -sticky w -padx 3 -pady 3
    addBalloon $wt.cb "Run plugin with raised privileges"
    grid $wt.cb - -sticky w -padx 3 -pady 3

    ttk::frame $w.fb -padding 3
    ttk::button $w.fb.b1 -text "Ok"   \
            -command [list EditPrefPluginsOk $top $w]
    ttk::button $w.fb.b2 -text "Show" \
            -command "ShowPlugin $w \$::eskil($top,edit,pluginname)"
    addBalloon $w.fb.b2 "Show plugin source code."
    ttk::button $w.fb.b3 -text "Cancel" -command [list destroy $w]
    set ::widgets($top,prefPluginsOk) $w.fb.b1
    ttk::frame $wt.fb -padding 3
    ttk::button $wt.fb.b1 -text "Ok"   \
            -command [list EditPrefPluginsOk $top $wt]
    ttk::button $wt.fb.b2 -text "Show" \
            -command "ShowPlugin $wt \$::eskil($top,edit,pluginname)"
    addBalloon $wt.fb.b2 "Show plugin source code."
    ttk::button $wt.fb.b3 -text "Cancel" -command [list destroy $wt]
    set ::widgets($top,prefPluginsOk) $wt.fb.b1

    grid $w.fb.b1 x $w.fb.b2 x $w.fb.b3 -sticky we
    grid columnconfigure $w.fb {0 2 4} -uniform a
    grid columnconfigure $w.fb {1 3} -weight 1
    grid $wt.fb.b1 x $wt.fb.b2 x $wt.fb.b3 -sticky we
    grid columnconfigure $wt.fb {0 2 4} -uniform a
    grid columnconfigure $wt.fb {1 3} -weight 1

    grid $w.fb - -sticky we
    grid columnconfigure $w 1 -weight 1
    grid $wt.fb - -sticky we
    grid columnconfigure $wt 1 -weight 1
}

proc EditPrefPluginsOk {top w} {
    destroy $w
proc EditPrefPluginsOk {top wt} {
    destroy $wt
    set ::eskil($top,pluginname) $::eskil($top,edit,pluginname)
    set ::eskil($top,plugininfo) $::eskil($top,edit,plugininfo)
    set ::eskil($top,pluginallow) $::eskil($top,edit,pluginallow)
    if {$::eskil($top,pluginname) ne ""} {
        set pinterp [createPluginInterp $::eskil($top,pluginname) \
                             $::eskil($top,plugininfo) \
                             $::eskil($top,pluginallow) pinfo]
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
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







-
-
-
+
+
+

-
+

-
-
-
-
+
+
+
+

-
-
+
+






proc ShowPlugin {parent plugin} {
    set src [LocatePlugin $plugin]
    if {$src eq ""} return
    set ch [open $src]
    set data [read $ch]
    close $ch
    set w $parent.plugin
    if {[winfo exists $w]} {
        wm deiconify $w
    set wt $parent.plugin
    if {[winfo exists $wt]} {
        wm deiconify $wt
    } else {
        toplevel $w -padx 3 -pady 3
        toplevel $wt -padx 3 -pady 3
    }
    destroy {*}[winfo children $w]
    ttk::frame $w._bg
    place $w._bg -x 0 -y 0 -relwidth 1.0 -relheight 1.0 -border outside
    wm title $w "Plugin: $plugin"
    destroy {*}[winfo children $wt]
    ttk::frame $wt._bg
    place $wt._bg -x 0 -y 0 -relwidth 1.0 -relheight 1.0 -border outside
    wm title $wt "Plugin: $plugin"

    set t [Scroll both text $w.t -width 80 -height 30 -font myfont -wrap none]
    pack $w.t -fill both -expand 1
    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
}