Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Handle multiple preprocess definitions that can be saved with preferences. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
823e77d9a824dbdc7e8dd5e303c5c845 |
User & Date: | peter 2017-02-05 18:59:52.955 |
Context
2017-02-05
| ||
19:02 | Bumped revision to 2.7.4 check-in: 7e3f1f0489 user: peter tags: trunk | |
18:59 | Handle multiple preprocess definitions that can be saved with preferences. check-in: 823e77d9a8 user: peter tags: trunk | |
17:07 | Make it safer ro recreate links check-in: 44ff79e29b user: peter tags: trunk | |
Changes
Changes to Changes.
1 2 3 4 5 6 7 | 2017-02-04 Support more areas for file drop. 2017-01-31 Made --query work again; lost in option reorganisation. 2017-01-12 | > > > | 1 2 3 4 5 6 7 8 9 10 | 2017-02-05 Handle multiple preprocess definitions that can be saved with preferences. 2017-02-04 Support more areas for file drop. 2017-01-31 Made --query work again; lost in option reorganisation. 2017-01-12 |
︙ | ︙ |
Changes to src/eskil.tcl.
︙ | ︙ | |||
3116 3117 3118 3119 3120 3121 3122 | -command {cleanupAndExit all} $top.m add cascade -label "Options" -underline 0 -menu $top.m.mo menu $top.m.mo $top.m.mo add cascade -label "Font" -underline 0 -menu $top.m.mo.f $top.m.mo add cascade -label "Ignore" -underline 0 -menu $top.m.mo.i $top.m.mo add command -label "Preprocess..." -underline 0 \ | | | 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 | -command {cleanupAndExit all} $top.m add cascade -label "Options" -underline 0 -menu $top.m.mo menu $top.m.mo $top.m.mo add cascade -label "Font" -underline 0 -menu $top.m.mo.f $top.m.mo add cascade -label "Ignore" -underline 0 -menu $top.m.mo.i $top.m.mo add command -label "Preprocess..." -underline 0 \ -command [list EditPrefPreprocess $top] $top.m.mo add command -label "Plugins..." -underline 1 \ -command [list EditPrefPlugins $top] $top.m.mo add cascade -label "Parse" -underline 1 -menu $top.m.mo.p $top.m.mo add command -label "Colours..." -underline 0 -command makePrefWin $top.m.mo add cascade -label "Context" -underline 1 -menu $top.m.mo.c $top.m.mo add cascade -label "Pivot" -underline 2 -menu $top.m.mo.piv $top.m.mo add separator |
︙ | ︙ |
Changes to src/preprocess.tcl.
︙ | ︙ | |||
15 16 17 18 19 20 21 | # # You should have received a copy of the GNU General Public License # along with this program; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # #---------------------------------------------------------------------- | | | | > > > > > > > | | > > > > > > | > > > > > > | | | 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 | # # You should have received a copy of the GNU General Public License # along with this program; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # #---------------------------------------------------------------------- # # The format of the ::Pref(preprocessn) is: # Flat list of stride 2, (name data) # Data dict elements: preprocess active save # Preprocess element is a flat list of stride 3 (RE sub side) # # There used to be a ::Pref(preprocess) with a different format, the new # was named a bit different for compatibilty with saved preferences. # Return active preprocess items as a flat list with stride 3 proc getActivePreprocess {top} { set res {} foreach {name data} $::Pref(preprocessn) { if {[dict get $data active]} { foreach {RE sub side} [dict get $data preprocess] { lappend res $RE $sub $side } } } return $res } # Entry for adding preprocess from command line proc addPreprocess {name RE sub side} { set data {} dict set data preprocess [list $RE $sub $side] dict set data active 1 dict set data save 0 lappend ::Pref(preprocessn) $name $data } # Get the value used when saving preferences proc getPreprocessSave {} { set res {} foreach {name data} $::Pref(preprocessn) { if {[dict get $data save]} { lappend res $name $data } } return $res } # This is called when Ok or Apply is pressed. # Update preference from dialog contents. proc EditPrefRegsubOk {top w item {keep 0}} { set exa $::eskil($top,prefregexa) set result {} for {set t 1} {[info exists ::eskil($top,prefregexp$t)]} {incr t} { set RE $::eskil($top,prefregexp$t) set Sub $::eskil($top,prefregsub$t) set l $::eskil($top,prefregleft$t) |
︙ | ︙ | |||
62 63 64 65 66 67 68 | if {[catch {regsub -all -- $RE $exa $Sub _} err]} { return } lappend result $RE $Sub $side } | | > | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | if {[catch {regsub -all -- $RE $exa $Sub _} err]} { return } lappend result $RE $Sub $side } set ::TmpPref(preprocess,re,$item) $result if {$keep} return destroy $w array unset ::eskil $top,prefregexp* array unset ::eskil $top,prefregsub* array unset ::eskil $top,prefregleft* array unset ::eskil $top,prefregright* |
︙ | ︙ | |||
173 174 175 176 177 178 179 | [list EditPrefRegsubUpdate $top] trace add variable ::eskil($top,prefregleft$t) write \ [list EditPrefRegsubUpdate $top] trace add variable ::eskil($top,prefregright$t) write \ [list EditPrefRegsubUpdate $top] } | | | < < < < < < | < | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | [list EditPrefRegsubUpdate $top] trace add variable ::eskil($top,prefregleft$t) write \ [list EditPrefRegsubUpdate $top] trace add variable ::eskil($top,prefregright$t) write \ [list EditPrefRegsubUpdate $top] } # Editor for one item in ::Pref(preprocessn) proc EditPrefRegsub {top item} { set w $top.prefregsub ToplevelForce $w "Preferences: Preprocess item" ttk::button $w.b -text "Add" -command [list AddPrefRegsub $top $w] # Result example part if {![info exists ::eskil($top,prefregexa)]} { set ::eskil($top,prefregexa) \ "An example TextString FOR_REGSUB /* Comment */" |
︙ | ︙ | |||
221 222 223 224 225 226 227 | grid $w.res.l5 $w.res.e5 -sticky we -padx 3 -pady 3 grid $w.res.l6 $w.res.e6l -sticky we -padx 3 -pady 3 grid x $w.res.e6r -sticky we -padx 3 -pady 3 grid columnconfigure $w.res 1 -weight 1 # Buttons ttk::frame $w.fb -padding 3 | | | > > | | | 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 | grid $w.res.l5 $w.res.e5 -sticky we -padx 3 -pady 3 grid $w.res.l6 $w.res.e6l -sticky we -padx 3 -pady 3 grid x $w.res.e6r -sticky we -padx 3 -pady 3 grid columnconfigure $w.res 1 -weight 1 # Buttons ttk::frame $w.fb -padding 3 ttk::button $w.fb.b1 -text "Ok" -command [list EditPrefRegsubOk $top $w $item] ttk::button $w.fb.b2 -text "Apply" -command [list EditPrefRegsubOk $top $w $item 1] ttk::button $w.fb.b3 -text "Cancel" -command [list destroy $w] set ::widgets($top,prefRegsubOk) $w.fb.b1 set ::widgets($top,prefRegsubApply) $w.fb.b2 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 # Top layout pack $w.b -side "top" -anchor "w" -padx 3 -pady 3 -ipadx 15 pack $w.fb $w.res -side bottom -fill x -padx 3 -pady 3 # Fill in existing or an empty line set preprocess $::TmpPref(preprocess,re,$item) if {[llength $preprocess] == 0} { AddPrefRegsub $top $w } else { set t 1 foreach {RE Sub side} $preprocess { set ::eskil($top,prefregexp$t) $RE set ::eskil($top,prefregsub$t) $Sub set ::eskil($top,prefregleft$t) 0 set ::eskil($top,prefregright$t) 0 if {$side eq "" || $side eq "left"} { set ::eskil($top,prefregleft$t) 1 } |
︙ | ︙ | |||
265 266 267 268 269 270 271 | trace add variable ::eskil($top,prefregexa2) write \ [list EditPrefRegsubUpdate $top] EditPrefRegsubUpdate $top } # This is called when Ok or Apply is pressed. | > | | < > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < | > | > > > > > > | > > > | | | | > > | | | | | | > | > > | > > > > > > > > > | | > > > > > | 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 | trace add variable ::eskil($top,prefregexa2) write \ [list EditPrefRegsubUpdate $top] EditPrefRegsubUpdate $top } # This is called when Ok or Apply is pressed. proc EditPrefPrepOk {top w {keep 0}} { # Update preference from dialog contents. set new {} for {set r 1} {$r <= $::TmpPref(preprocess,n)} {incr r} { set name $::TmpPref(preprocess,name,$r) set act $::TmpPref(preprocess,active,$r) set save $::TmpPref(preprocess,save,$r) set re $::TmpPref(preprocess,re,$r) lappend new $name lappend new [dict create active $act "save" $save preprocess $re] } set ::Pref(preprocessn) $new if {$keep} return destroy $w } # Create a toplevel, even if it exists proc ToplevelForce {w title} { destroy $w ttk::toplevel $w -padx 3 -pady 3 wm title $w $title } proc EditPrefPreprocessAddItem {w} { set r $::TmpPref(preprocess,n) incr r if {![info exists ::TmpPref(preprocess,name,$r)]} { set ::TmpPref(preprocess,name,$r) "" set ::TmpPref(preprocess,active,$r) 0 set ::TmpPref(preprocess,save,$r) 0 set ::TmpPref(preprocess,re,$r) "" } ttk::entry $w.fp.ne$r -textvariable ::TmpPref(preprocess,name,$r) ttk::checkbutton $w.fp.cba$r -text "Active" \ -variable ::TmpPref(preprocess,active,$r) ttk::checkbutton $w.fp.cbs$r -text "Save" \ -variable ::TmpPref(preprocess,save,$r) ttk::button $w.fp.be$r -text "Edit" \ -command [list EditPrefRegsub $w $r] grid $w.fp.ne$r $w.fp.cba$r $w.fp.cbs$r $w.fp.be$r -sticky we \ -padx 3 -pady 3 set ::TmpPref(preprocess,n) $r } proc EditPrefPreprocess {top} { set w $top.prefpreprocess # Make a working copy more suitable for GUI connection set r 0 foreach {name data} $::Pref(preprocessn) { incr r set ::TmpPref(preprocess,name,$r) $name set ::TmpPref(preprocess,active,$r) [dict get $data active] set ::TmpPref(preprocess,save,$r) [dict get $data save] set ::TmpPref(preprocess,re,$r) [dict get $data preprocess] } # Create one if there is none, to simplify GUI usage if {$r == 0} { incr r } set ::TmpPref(preprocess,n) 0 set nItems $r ToplevelForce $w "Preferences: Preprocess" # Frame for List of preprocessing ttk::frame $w.fp -padding 3 # Heading labels for columns ttk::label $w.fp.hl1 -text "Name" addBalloon $w.fp.hl1 "Name of preprocess item" ttk::label $w.fp.hl2 -text "Active" addBalloon $w.fp.hl2 "Is item active for this session?" ttk::label $w.fp.hl3 -text "Saved" addBalloon $w.fp.hl3 "Is item saved with preferences?" grid $w.fp.hl1 $w.fp.hl2 $w.fp.hl3 -sticky we -padx 3 -pady 3 for {set r 1} {$r <= $nItems} {incr r} { EditPrefPreprocessAddItem $w } # Frame for action buttons ttk::frame $w.fa -padding 3 ttk::button $w.fa.b1 -text "Add" -command [list EditPrefPreprocessAddItem $w] grid $w.fa.b1 -sticky we grid columnconfigure $w.fa {0 2 4} -uniform a grid columnconfigure $w.fa {1 3} -weight 1 # Frame for dialog Buttons ttk::frame $w.fb -padding 3 ttk::button $w.fb.b1 -text "Ok" -command [list EditPrefPrepOk $top $w] ttk::button $w.fb.b2 -text "Apply" -command [list EditPrefPrepOk $top $w 1] ttk::button $w.fb.b3 -text "Cancel" -command [list destroy $w] 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 # Top layout pack $w.fb -side bottom -fill x pack $w.fa -side bottom -fill x pack $w.fp -side "top" -fill both -expand 1 } |
Changes to src/startup.tcl.
︙ | ︙ | |||
36 37 38 39 40 41 42 43 44 45 46 47 48 49 | set ::argv {} set ::argc 0 set ::eskil(debug) 0 # Version string is loaded from version.txt set ::eskil(diffver) "Version Unknown" set ::eskil(thisScript) [file join [pwd] [info script]] namespace import tcl::mathop::+ namespace import tcl::mathop::- namespace import tcl::mathop::* namespace import tcl::mathop::/ # Do initalisations for needed packages and globals. | > | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | set ::argv {} set ::argc 0 set ::eskil(debug) 0 # Version string is loaded from version.txt set ::eskil(diffver) "Version Unknown" set ::eskil(thisScript) [file join [pwd] [info script]] set ::eskil(thisDir) [file dirname $::eskil(thisScript)] namespace import tcl::mathop::+ namespace import tcl::mathop::- namespace import tcl::mathop::* namespace import tcl::mathop::/ # Do initalisations for needed packages and globals. |
︙ | ︙ | |||
62 63 64 65 66 67 68 | if {[catch {package require psballoon}]} { # Add a dummy if it does not exist. proc addBalloon {args} {} } else { namespace import -force psballoon::addBalloon } | < < | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | if {[catch {package require psballoon}]} { # Add a dummy if it does not exist. proc addBalloon {args} {} } else { namespace import -force psballoon::addBalloon } # Follow any link set tmplink $::eskil(thisScript) while {[file type $tmplink] eq "link"} { set tmplink [file readlink $tmplink] set tmplink [file normalize [file join $::eskil(thisDir) $tmplink]] set ::eskil(thisDir) [file dirname $tmplink] } |
︙ | ︙ | |||
139 140 141 142 143 144 145 | } } } # Provide a ttk-friendly toplevel, fixing background and menubar if {[info commands ttk::toplevel] eq ""} { proc ttk::toplevel {w args} { tk::toplevel $w {*}$args | | > | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | } } } # Provide a ttk-friendly toplevel, fixing background and menubar if {[info commands ttk::toplevel] eq ""} { proc ttk::toplevel {w args} { tk::toplevel $w {*}$args place [ttk::frame $w.tilebg] -border outside \ -x 0 -y 0 -relwidth 1 -relheight 1 return $w } } ::snit::widgetadaptor ttk::entryX { delegate method * to hull delegate option * to hull |
︙ | ︙ | |||
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | set ih [image height $::img(up)] set iw [image width $::img(up)] set ::img(upup) [image create photo -height $ih -width [expr {2 * $iw}]] $::img(upup) copy $::img(up) -to 0 0 [expr {2 * $iw - 1}] [expr {$ih - 1}] EskilThemeInit } proc InitReSource {} { # Get all other source files source $::eskil(thisDir)/eskil.tcl source $::eskil(thisDir)/clip.tcl source $::eskil(thisDir)/compare.tcl source $::eskil(thisDir)/map.tcl source $::eskil(thisDir)/merge.tcl source $::eskil(thisDir)/registry.tcl source $::eskil(thisDir)/dirdiff.tcl source $::eskil(thisDir)/help.tcl | > > > > > > < | 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 | set ih [image height $::img(up)] set iw [image width $::img(up)] set ::img(upup) [image create photo -height $ih -width [expr {2 * $iw}]] $::img(upup) copy $::img(up) -to 0 0 [expr {2 * $iw - 1}] [expr {$ih - 1}] EskilThemeInit } # Load sources needed early, during command line handling proc InitSourceEarly {} { source $::eskil(thisDir)/preprocess.tcl } proc InitReSource {} { InitSourceEarly # Get all other source files source $::eskil(thisDir)/eskil.tcl source $::eskil(thisDir)/clip.tcl source $::eskil(thisDir)/compare.tcl source $::eskil(thisDir)/map.tcl source $::eskil(thisDir)/merge.tcl source $::eskil(thisDir)/registry.tcl source $::eskil(thisDir)/dirdiff.tcl source $::eskil(thisDir)/help.tcl source $::eskil(thisDir)/plugin.tcl source $::eskil(thisDir)/printobj.tcl source $::eskil(thisDir)/print.tcl source $::eskil(thisDir)/rev.tcl source $::eskil(thisDir)/debug.tcl # Only load vcsvfs if vfs is present |
︙ | ︙ | |||
1108 1109 1110 1111 1112 1113 1114 | "Error when trying to save preferences:\n$err" return } foreach i [array names ::Pref] { set value $::Pref($i) # Special handling for preprocess | | | 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 | "Error when trying to save preferences:\n$err" return } foreach i [array names ::Pref] { set value $::Pref($i) # Special handling for preprocess if {$i eq "preprocessn"} { set value [getPreprocessSave] } # Skip unchanged options. if {[info exists ::DefaultPref($i)]} { if {$::DefaultPref($i) eq $value} { continue } |
︙ | ︙ | |||
1155 1156 1157 1158 1159 1160 1161 | set ::DefaultPref(bgnew2) \#e0e0ff set ::DefaultPref(context) -1 set ::DefaultPref(finegrainchunks) 0 set ::DefaultPref(marklast) 1 set ::DefaultPref(linewidth) 80 set ::DefaultPref(lines) 60 set ::DefaultPref(editor) "" | | | 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 | set ::DefaultPref(bgnew2) \#e0e0ff set ::DefaultPref(context) -1 set ::DefaultPref(finegrainchunks) 0 set ::DefaultPref(marklast) 1 set ::DefaultPref(linewidth) 80 set ::DefaultPref(lines) 60 set ::DefaultPref(editor) "" set ::DefaultPref(preprocessn) {} set ::DefaultPref(toolbar) 0 set ::DefaultPref(wideMap) 0 ;# Not settable in GUI yet # Print options set ::DefaultPref(printHeaderSize) 10 set ::DefaultPref(printCharsPerLine) 80 set ::DefaultPref(printPaper) a4 |
︙ | ︙ | |||
1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 | set ::DefaultPref(dir,exdirs) "RCS CVS .git .svn .hg" set ::DefaultPref(dir,onlyrev) 0 set ::DefaultPref(dir,nice) 1 # Start with default preferences, before loading setup file array set ::Pref [array get ::DefaultPref] # TODO: implement filter option fully set ::eskil(filter) "" if {![info exists ::eskil_testsuite] && [file exists "~/.eskilrc"]} { safeLoad "~/.eskilrc" ::Pref } if {$::Pref(editor) ne ""} { set ::util(editor) $::Pref(editor) } # If the user's file has this old option, translate it to the new | > > > > > > > | > > | 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 | set ::DefaultPref(dir,exdirs) "RCS CVS .git .svn .hg" set ::DefaultPref(dir,onlyrev) 0 set ::DefaultPref(dir,nice) 1 # Start with default preferences, before loading setup file array set ::Pref [array get ::DefaultPref] # Handle old option set ::Pref(preprocess) {} # TODO: implement filter option fully set ::eskil(filter) "" if {![info exists ::eskil_testsuite] && [file exists "~/.eskilrc"]} { safeLoad "~/.eskilrc" ::Pref } if {$::Pref(editor) ne ""} { set ::util(editor) $::Pref(editor) } # If the user's file has this old option, translate it to the new if {$::Pref(preprocess) ne ""} { lappend ::Pref(preprocessn) "old" lappend ::Pref(preprocessn) \ [dict create preprocess $::Pref(preprocess) \ active 1 save 1] } array unset ::Pref preprocess # Set up reactions to some Pref settings if {![info exists ::widgets(toolbars)]} { set ::widgets(toolbars) {} } trace add variable ::Pref(toolbar) write TraceToolbar } |
︙ | ︙ | |||
1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 | if {![info exists ::eskil(gurkmeja)]} { set ::eskil(gurkmeja) 1 package require pstools namespace import -force pstools::* getOptions if {![info exists ::eskil_testsuite]} { parseCommandLine } } | > | 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 | if {![info exists ::eskil(gurkmeja)]} { set ::eskil(gurkmeja) 1 package require pstools namespace import -force pstools::* getOptions if {![info exists ::eskil_testsuite]} { InitSourceEarly parseCommandLine } } |