Fossil SCM

Minor UI enhancements in the --tk diff display.

drh 2016-08-01 11:01 trunk
Commit 3d7468454bf38914c8427dba78efd219ffc7bff1
1 file changed +23 -11
+23 -11
--- src/diff.tcl
+++ src/diff.tcl
@@ -228,15 +228,20 @@
228228
229229
wm withdraw .
230230
wm title . $CFG(TITLE)
231231
wm iconname . $CFG(TITLE)
232232
bind . <q> exit
233
+bind . <Escape><Escape> exit
233234
bind . <Destroy> {after 0 exit}
234235
bind . <Tab> {cycleDiffs; break}
235236
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}
236241
bind . <Return> {
237
- event generate .bb.files <1>
242
+ event generate bb.files <1>
238243
event generate .bb.files <ButtonRelease-1>
239244
break
240245
}
241246
foreach {key axis args} {
242247
Up y {scroll -5 units}
@@ -259,10 +264,14 @@
259264
bind . <Shift-$key> continue
260265
}
261266
262267
frame .bb
263268
::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
+}
264273
toplevel .wfiles
265274
wm withdraw .wfiles
266275
update idletasks
267276
wm transient .wfiles .
268277
wm overrideredirect .wfiles 1
@@ -358,17 +367,19 @@
358367
grid config .txtB -column 1
359368
.txtB tag config add -background $CFG(RM_BG)
360369
grid config .lnA -column 3
361370
grid config .txtA -column 4
362371
.txtA tag config rm -background $CFG(ADD_BG)
372
+ .bb.invert config -text Uninvert
363373
} else {
364374
grid config .lnA -column 0
365375
grid config .txtA -column 1
366376
.txtA tag config rm -background $CFG(RM_BG)
367377
grid config .lnB -column 3
368378
grid config .txtB -column 4
369379
.txtB tag config add -background $CFG(ADD_BG)
380
+ .bb.invert config -text Invert
370381
}
371382
.mkr config -state normal
372383
set clt [.mkr search -all < 1.0 end]
373384
set cgt [.mkr search -all > 1.0 end]
374385
foreach c $clt {.mkr replace $c "$c +1 chars" >}
@@ -385,25 +396,28 @@
385396
set ::search .txtA
386397
if {![winfo exists .bb.sframe]} {
387398
frame .bb.sframe
388399
::ttk::entry .bb.sframe.e -width 10
389400
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
394404
tk_optionMenu .bb.sframe.typ ::search_type \
395405
Exact {No Case} {RegExp} {Whole Word}
396406
.bb.sframe.typ config -width 10
397407
set ::search_type Exact
398408
pack .bb.sframe.nx .bb.sframe.pv .bb.sframe.typ -side left
399409
}
400410
pack .bb.sframe -side left
411
+ after idle {focus .bb.sframe.e}
401412
}
402413
}
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} {
404417
set pattern [.bb.sframe.e get]
418
+ if {$pattern==""} return
405419
set count 0
406420
set w $::search
407421
if {"$w"==".txtA"} {set other .txtB} {set other .txtA}
408422
if {[lsearch [$w mark names] search]<0} {
409423
$w mark set search $start
@@ -415,18 +429,16 @@
415429
{Whole Word} {set st -regexp; set pattern \\y$pattern\\y}
416430
}
417431
set idx [$w search -count count $direction $st -- \
418432
$pattern "search $incr chars" $stop]
419433
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"!=""} {
425436
set this $w
426437
set w $other
427438
set other $this
439
+ } else {
428440
set idx [$w search -count count $direction $st -- $pattern $start $stop]
429441
}
430442
}
431443
$w tag remove search 1.0 end
432444
$w mark unset search
433445
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button