Fossil SCM
Minor UI enhancements in the --tk diff display.
Commit
3d7468454bf38914c8427dba78efd219ffc7bff1
Parent
2a5de7ea2e119a6…
1 file changed
+23
-11
+23
-11
| --- src/diff.tcl | ||
| +++ src/diff.tcl | ||
| @@ -228,15 +228,20 @@ | ||
| 228 | 228 | |
| 229 | 229 | wm withdraw . |
| 230 | 230 | wm title . $CFG(TITLE) |
| 231 | 231 | wm iconname . $CFG(TITLE) |
| 232 | 232 | bind . <q> exit |
| 233 | +bind . <Escape><Escape> exit | |
| 233 | 234 | bind . <Destroy> {after 0 exit} |
| 234 | 235 | bind . <Tab> {cycleDiffs; break} |
| 235 | 236 | bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 237 | +bind . <Control-f> {searchOnOff; break} | |
| 238 | +bind . <n> {catch searchNext; break} | |
| 239 | +bind . <Control-g> {catch searchNext; break} | |
| 240 | +bind . <p> {catch searchPrev; break} | |
| 236 | 241 | bind . <Return> { |
| 237 | - event generate .bb.files <1> | |
| 242 | + event generate bb.files <1> | |
| 238 | 243 | event generate .bb.files <ButtonRelease-1> |
| 239 | 244 | break |
| 240 | 245 | } |
| 241 | 246 | foreach {key axis args} { |
| 242 | 247 | Up y {scroll -5 units} |
| @@ -259,10 +264,14 @@ | ||
| 259 | 264 | bind . <Shift-$key> continue |
| 260 | 265 | } |
| 261 | 266 | |
| 262 | 267 | frame .bb |
| 263 | 268 | ::ttk::menubutton .bb.files -text "Files" |
| 269 | +if {[tk windowingsystem] eq "win32"} { | |
| 270 | + ::ttk::style theme use winnative | |
| 271 | + .bb.files configure -padding {20 1 10 2} | |
| 272 | +} | |
| 264 | 273 | toplevel .wfiles |
| 265 | 274 | wm withdraw .wfiles |
| 266 | 275 | update idletasks |
| 267 | 276 | wm transient .wfiles . |
| 268 | 277 | wm overrideredirect .wfiles 1 |
| @@ -358,17 +367,19 @@ | ||
| 358 | 367 | grid config .txtB -column 1 |
| 359 | 368 | .txtB tag config add -background $CFG(RM_BG) |
| 360 | 369 | grid config .lnA -column 3 |
| 361 | 370 | grid config .txtA -column 4 |
| 362 | 371 | .txtA tag config rm -background $CFG(ADD_BG) |
| 372 | + .bb.invert config -text Uninvert | |
| 363 | 373 | } else { |
| 364 | 374 | grid config .lnA -column 0 |
| 365 | 375 | grid config .txtA -column 1 |
| 366 | 376 | .txtA tag config rm -background $CFG(RM_BG) |
| 367 | 377 | grid config .lnB -column 3 |
| 368 | 378 | grid config .txtB -column 4 |
| 369 | 379 | .txtB tag config add -background $CFG(ADD_BG) |
| 380 | + .bb.invert config -text Invert | |
| 370 | 381 | } |
| 371 | 382 | .mkr config -state normal |
| 372 | 383 | set clt [.mkr search -all < 1.0 end] |
| 373 | 384 | set cgt [.mkr search -all > 1.0 end] |
| 374 | 385 | foreach c $clt {.mkr replace $c "$c +1 chars" >} |
| @@ -385,25 +396,28 @@ | ||
| 385 | 396 | set ::search .txtA |
| 386 | 397 | if {![winfo exists .bb.sframe]} { |
| 387 | 398 | frame .bb.sframe |
| 388 | 399 | ::ttk::entry .bb.sframe.e -width 10 |
| 389 | 400 | pack .bb.sframe.e -side left -fill y -expand 1 |
| 390 | - ::ttk::button .bb.sframe.nx -text \u2193 -width 1 \ | |
| 391 | - -command {searchNext -forwards +1 1.0 end} | |
| 392 | - ::ttk::button .bb.sframe.pv -text \u2191 -width 1 \ | |
| 393 | - -command {searchNext -backwards -1 end 1.0} | |
| 401 | + bind .bb.sframe.e <Return> {searchNext; break} | |
| 402 | + ::ttk::button .bb.sframe.nx -text \u2193 -width 1 -command searchNext | |
| 403 | + ::ttk::button .bb.sframe.pv -text \u2191 -width 1 -command searchPrev | |
| 394 | 404 | tk_optionMenu .bb.sframe.typ ::search_type \ |
| 395 | 405 | Exact {No Case} {RegExp} {Whole Word} |
| 396 | 406 | .bb.sframe.typ config -width 10 |
| 397 | 407 | set ::search_type Exact |
| 398 | 408 | pack .bb.sframe.nx .bb.sframe.pv .bb.sframe.typ -side left |
| 399 | 409 | } |
| 400 | 410 | pack .bb.sframe -side left |
| 411 | + after idle {focus .bb.sframe.e} | |
| 401 | 412 | } |
| 402 | 413 | } |
| 403 | -proc searchNext {direction incr start stop} { | |
| 414 | +proc searchNext {} {searchStep -forwards +1 1.0 end} | |
| 415 | +proc searchPrev {} {searchStep -backwards -1 end 1.0} | |
| 416 | +proc searchStep {direction incr start stop} { | |
| 404 | 417 | set pattern [.bb.sframe.e get] |
| 418 | + if {$pattern==""} return | |
| 405 | 419 | set count 0 |
| 406 | 420 | set w $::search |
| 407 | 421 | if {"$w"==".txtA"} {set other .txtB} {set other .txtA} |
| 408 | 422 | if {[lsearch [$w mark names] search]<0} { |
| 409 | 423 | $w mark set search $start |
| @@ -415,18 +429,16 @@ | ||
| 415 | 429 | {Whole Word} {set st -regexp; set pattern \\y$pattern\\y} |
| 416 | 430 | } |
| 417 | 431 | set idx [$w search -count count $direction $st -- \ |
| 418 | 432 | $pattern "search $incr chars" $stop] |
| 419 | 433 | if {"$idx"==""} { |
| 420 | - set this $w | |
| 421 | - set w $other | |
| 422 | - set other $this | |
| 423 | - set idx [$w search -count count $direction $st -- $pattern $start $stop] | |
| 424 | - if {"$idx"==""} { | |
| 434 | + set idx [$other search -count count $direction $st -- $pattern $start $stop] | |
| 435 | + if {"$idx"!=""} { | |
| 425 | 436 | set this $w |
| 426 | 437 | set w $other |
| 427 | 438 | set other $this |
| 439 | + } else { | |
| 428 | 440 | set idx [$w search -count count $direction $st -- $pattern $start $stop] |
| 429 | 441 | } |
| 430 | 442 | } |
| 431 | 443 | $w tag remove search 1.0 end |
| 432 | 444 | $w mark unset search |
| 433 | 445 |
| --- src/diff.tcl | |
| +++ src/diff.tcl | |
| @@ -228,15 +228,20 @@ | |
| 228 | |
| 229 | wm withdraw . |
| 230 | wm title . $CFG(TITLE) |
| 231 | wm iconname . $CFG(TITLE) |
| 232 | bind . <q> exit |
| 233 | bind . <Destroy> {after 0 exit} |
| 234 | bind . <Tab> {cycleDiffs; break} |
| 235 | bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 236 | bind . <Return> { |
| 237 | event generate .bb.files <1> |
| 238 | event generate .bb.files <ButtonRelease-1> |
| 239 | break |
| 240 | } |
| 241 | foreach {key axis args} { |
| 242 | Up y {scroll -5 units} |
| @@ -259,10 +264,14 @@ | |
| 259 | bind . <Shift-$key> continue |
| 260 | } |
| 261 | |
| 262 | frame .bb |
| 263 | ::ttk::menubutton .bb.files -text "Files" |
| 264 | toplevel .wfiles |
| 265 | wm withdraw .wfiles |
| 266 | update idletasks |
| 267 | wm transient .wfiles . |
| 268 | wm overrideredirect .wfiles 1 |
| @@ -358,17 +367,19 @@ | |
| 358 | grid config .txtB -column 1 |
| 359 | .txtB tag config add -background $CFG(RM_BG) |
| 360 | grid config .lnA -column 3 |
| 361 | grid config .txtA -column 4 |
| 362 | .txtA tag config rm -background $CFG(ADD_BG) |
| 363 | } else { |
| 364 | grid config .lnA -column 0 |
| 365 | grid config .txtA -column 1 |
| 366 | .txtA tag config rm -background $CFG(RM_BG) |
| 367 | grid config .lnB -column 3 |
| 368 | grid config .txtB -column 4 |
| 369 | .txtB tag config add -background $CFG(ADD_BG) |
| 370 | } |
| 371 | .mkr config -state normal |
| 372 | set clt [.mkr search -all < 1.0 end] |
| 373 | set cgt [.mkr search -all > 1.0 end] |
| 374 | foreach c $clt {.mkr replace $c "$c +1 chars" >} |
| @@ -385,25 +396,28 @@ | |
| 385 | set ::search .txtA |
| 386 | if {![winfo exists .bb.sframe]} { |
| 387 | frame .bb.sframe |
| 388 | ::ttk::entry .bb.sframe.e -width 10 |
| 389 | pack .bb.sframe.e -side left -fill y -expand 1 |
| 390 | ::ttk::button .bb.sframe.nx -text \u2193 -width 1 \ |
| 391 | -command {searchNext -forwards +1 1.0 end} |
| 392 | ::ttk::button .bb.sframe.pv -text \u2191 -width 1 \ |
| 393 | -command {searchNext -backwards -1 end 1.0} |
| 394 | tk_optionMenu .bb.sframe.typ ::search_type \ |
| 395 | Exact {No Case} {RegExp} {Whole Word} |
| 396 | .bb.sframe.typ config -width 10 |
| 397 | set ::search_type Exact |
| 398 | pack .bb.sframe.nx .bb.sframe.pv .bb.sframe.typ -side left |
| 399 | } |
| 400 | pack .bb.sframe -side left |
| 401 | } |
| 402 | } |
| 403 | proc searchNext {direction incr start stop} { |
| 404 | set pattern [.bb.sframe.e get] |
| 405 | set count 0 |
| 406 | set w $::search |
| 407 | if {"$w"==".txtA"} {set other .txtB} {set other .txtA} |
| 408 | if {[lsearch [$w mark names] search]<0} { |
| 409 | $w mark set search $start |
| @@ -415,18 +429,16 @@ | |
| 415 | {Whole Word} {set st -regexp; set pattern \\y$pattern\\y} |
| 416 | } |
| 417 | set idx [$w search -count count $direction $st -- \ |
| 418 | $pattern "search $incr chars" $stop] |
| 419 | if {"$idx"==""} { |
| 420 | set this $w |
| 421 | set w $other |
| 422 | set other $this |
| 423 | set idx [$w search -count count $direction $st -- $pattern $start $stop] |
| 424 | if {"$idx"==""} { |
| 425 | set this $w |
| 426 | set w $other |
| 427 | set other $this |
| 428 | set idx [$w search -count count $direction $st -- $pattern $start $stop] |
| 429 | } |
| 430 | } |
| 431 | $w tag remove search 1.0 end |
| 432 | $w mark unset search |
| 433 |
| --- src/diff.tcl | |
| +++ src/diff.tcl | |
| @@ -228,15 +228,20 @@ | |
| 228 | |
| 229 | wm withdraw . |
| 230 | wm title . $CFG(TITLE) |
| 231 | wm iconname . $CFG(TITLE) |
| 232 | bind . <q> exit |
| 233 | bind . <Escape><Escape> exit |
| 234 | bind . <Destroy> {after 0 exit} |
| 235 | bind . <Tab> {cycleDiffs; break} |
| 236 | bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 237 | bind . <Control-f> {searchOnOff; break} |
| 238 | bind . <n> {catch searchNext; break} |
| 239 | bind . <Control-g> {catch searchNext; break} |
| 240 | bind . <p> {catch searchPrev; break} |
| 241 | bind . <Return> { |
| 242 | event generate bb.files <1> |
| 243 | event generate .bb.files <ButtonRelease-1> |
| 244 | break |
| 245 | } |
| 246 | foreach {key axis args} { |
| 247 | Up y {scroll -5 units} |
| @@ -259,10 +264,14 @@ | |
| 264 | bind . <Shift-$key> continue |
| 265 | } |
| 266 | |
| 267 | frame .bb |
| 268 | ::ttk::menubutton .bb.files -text "Files" |
| 269 | if {[tk windowingsystem] eq "win32"} { |
| 270 | ::ttk::style theme use winnative |
| 271 | .bb.files configure -padding {20 1 10 2} |
| 272 | } |
| 273 | toplevel .wfiles |
| 274 | wm withdraw .wfiles |
| 275 | update idletasks |
| 276 | wm transient .wfiles . |
| 277 | wm overrideredirect .wfiles 1 |
| @@ -358,17 +367,19 @@ | |
| 367 | grid config .txtB -column 1 |
| 368 | .txtB tag config add -background $CFG(RM_BG) |
| 369 | grid config .lnA -column 3 |
| 370 | grid config .txtA -column 4 |
| 371 | .txtA tag config rm -background $CFG(ADD_BG) |
| 372 | .bb.invert config -text Uninvert |
| 373 | } else { |
| 374 | grid config .lnA -column 0 |
| 375 | grid config .txtA -column 1 |
| 376 | .txtA tag config rm -background $CFG(RM_BG) |
| 377 | grid config .lnB -column 3 |
| 378 | grid config .txtB -column 4 |
| 379 | .txtB tag config add -background $CFG(ADD_BG) |
| 380 | .bb.invert config -text Invert |
| 381 | } |
| 382 | .mkr config -state normal |
| 383 | set clt [.mkr search -all < 1.0 end] |
| 384 | set cgt [.mkr search -all > 1.0 end] |
| 385 | foreach c $clt {.mkr replace $c "$c +1 chars" >} |
| @@ -385,25 +396,28 @@ | |
| 396 | set ::search .txtA |
| 397 | if {![winfo exists .bb.sframe]} { |
| 398 | frame .bb.sframe |
| 399 | ::ttk::entry .bb.sframe.e -width 10 |
| 400 | pack .bb.sframe.e -side left -fill y -expand 1 |
| 401 | bind .bb.sframe.e <Return> {searchNext; break} |
| 402 | ::ttk::button .bb.sframe.nx -text \u2193 -width 1 -command searchNext |
| 403 | ::ttk::button .bb.sframe.pv -text \u2191 -width 1 -command searchPrev |
| 404 | tk_optionMenu .bb.sframe.typ ::search_type \ |
| 405 | Exact {No Case} {RegExp} {Whole Word} |
| 406 | .bb.sframe.typ config -width 10 |
| 407 | set ::search_type Exact |
| 408 | pack .bb.sframe.nx .bb.sframe.pv .bb.sframe.typ -side left |
| 409 | } |
| 410 | pack .bb.sframe -side left |
| 411 | after idle {focus .bb.sframe.e} |
| 412 | } |
| 413 | } |
| 414 | proc searchNext {} {searchStep -forwards +1 1.0 end} |
| 415 | proc searchPrev {} {searchStep -backwards -1 end 1.0} |
| 416 | proc searchStep {direction incr start stop} { |
| 417 | set pattern [.bb.sframe.e get] |
| 418 | if {$pattern==""} return |
| 419 | set count 0 |
| 420 | set w $::search |
| 421 | if {"$w"==".txtA"} {set other .txtB} {set other .txtA} |
| 422 | if {[lsearch [$w mark names] search]<0} { |
| 423 | $w mark set search $start |
| @@ -415,18 +429,16 @@ | |
| 429 | {Whole Word} {set st -regexp; set pattern \\y$pattern\\y} |
| 430 | } |
| 431 | set idx [$w search -count count $direction $st -- \ |
| 432 | $pattern "search $incr chars" $stop] |
| 433 | if {"$idx"==""} { |
| 434 | set idx [$other search -count count $direction $st -- $pattern $start $stop] |
| 435 | if {"$idx"!=""} { |
| 436 | set this $w |
| 437 | set w $other |
| 438 | set other $this |
| 439 | } else { |
| 440 | set idx [$w search -count count $direction $st -- $pattern $start $stop] |
| 441 | } |
| 442 | } |
| 443 | $w tag remove search 1.0 end |
| 444 | $w mark unset search |
| 445 |