Fossil

Check-in [132340e6]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:In diff -tk window, add a button which toggles the line wrap mode, as discussed in forum post c5e018e78a8e9d26. (My very first tk code, so it might be significantly improved upon by someone who knows Tk Fu.) (Edit: it turns out that wrapping doesn't work with the line numbers.)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | mistake
Files: files | file ages | folders
SHA3-256: 132340e6f77a38e316b26320913703a26f5df2108ea143b811b5ea4cd3579102
User & Date: stephan 2021-07-08 08:51:25
Original Comment: In diff -tk window, add a button which toggles the line wrap mode, as discussed in forum post c5e018e78a8e9d26. (My very first tk code, so it might be significantly improved upon by someone who knows Tk Fu.)
Context
2021-07-08
11:54
diff -tk: simplified wrap toggle implementation a bit using a ttk::checkbutton. ... (Closed-Leaf check-in: 57a2cab3 user: stephan tags: mistake)
08:51
In diff -tk window, add a button which toggles the line wrap mode, as discussed in forum post c5e018e78a8e9d26. (My very first tk code, so it might be significantly improved upon by someone who knows Tk Fu.) (Edit: it turns out that wrapping doesn't work with the line numbers.) ... (check-in: 132340e6 user: stephan tags: mistake)
2021-07-07
18:14
Fix the unversioned_content_hash() function so that it returns the SHA1 of a zero-length buffer if the "unversioned" table does not exist. ... (check-in: ccce70fb user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/diff.tcl.

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
  }
}
bind .wfiles.lb <Motion> {
  %W selection clear 0 end
  %W selection set @%x,%y
}





foreach {side syncCol} {A .txtB B .txtA} {
  set ln .ln$side
  text $ln
  $ln tag config - -justify right

  set txt .txt$side


  text $txt -width $CFG(WIDTH) -height $CFG(HEIGHT) -wrap none \
    -xscroll "sync-x $syncCol"
  catch {$txt config -tabstyle wordprocessor} ;# Required for Tk>=8.5
  foreach tag {add rm chng} {
    $txt tag config $tag -background $CFG([string toupper $tag]_BG)
    $txt tag lower $tag
  }
  $txt tag config fn -background $CFG(FN_BG) -foreground $CFG(FN_FG) \
    -justify center
  $txt tag config err -foreground $CFG(ERR_FG)
}
text .mkr


foreach c [cols] {
  set keyPrefix [string toupper [colType $c]]_COL_
  if {[tk windowingsystem] eq "win32"} {$c config -font {courier 9}}
  $c config -bg $CFG(${keyPrefix}BG) -fg $CFG(${keyPrefix}FG) -borderwidth 0 \
    -padx $CFG(PADX) -yscroll sync-y
  $c tag config hr -spacing1 $CFG(HR_PAD_TOP) -spacing3 $CFG(HR_PAD_BTM) \







>
>
>
>






>
>
|











>







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
  }
}
bind .wfiles.lb <Motion> {
  %W selection clear 0 end
  %W selection set @%x,%y
}

set wrapMode none
set txtCol0 ""
set txtCol1 ""
set i 0
foreach {side syncCol} {A .txtB B .txtA} {
  set ln .ln$side
  text $ln
  $ln tag config - -justify right

  set txt .txt$side
  set txtCol$i $txt
  set i [expr $i + 1]
  text $txt -width $CFG(WIDTH) -height $CFG(HEIGHT) -wrap $wrapMode \
    -xscroll "sync-x $syncCol"
  catch {$txt config -tabstyle wordprocessor} ;# Required for Tk>=8.5
  foreach tag {add rm chng} {
    $txt tag config $tag -background $CFG([string toupper $tag]_BG)
    $txt tag lower $tag
  }
  $txt tag config fn -background $CFG(FN_BG) -foreground $CFG(FN_FG) \
    -justify center
  $txt tag config err -foreground $CFG(ERR_FG)
}
text .mkr
unset i

foreach c [cols] {
  set keyPrefix [string toupper [colType $c]]_COL_
  if {[tk windowingsystem] eq "win32"} {$c config -font {courier 9}}
  $c config -bg $CFG(${keyPrefix}BG) -fg $CFG(${keyPrefix}FG) -borderwidth 0 \
    -padx $CFG(PADX) -yscroll sync-y
  $c tag config hr -spacing1 $CFG(HR_PAD_TOP) -spacing3 $CFG(HR_PAD_BTM) \
454
455
456
457
458
459
460













461
462
463
464

465
466
467
468
469
470
471
472
473
474
    $w mark set search $idx
    $w yview -pickplace $idx
    $w tag add search search "$idx +$count chars"
    $w tag config search -background {#fcc000}
  }
  set ::search $w
}













::ttk::button .bb.quit -text {Quit} -command exit
::ttk::button .bb.invert -text {Invert} -command invertDiff
::ttk::button .bb.save -text {Save As...} -command saveDiff
::ttk::button .bb.search -text {Search} -command searchOnOff

pack .bb.quit .bb.invert -side left
if {$fossilcmd!=""} {pack .bb.save -side left}
pack .bb.files .bb.search -side left
grid rowconfigure . 1 -weight 1
grid columnconfigure . 1 -weight 1
grid columnconfigure . 4 -weight 1
grid .bb -row 0 -columnspan 6
eval grid [cols] -row 1 -sticky nsew
grid .sby -row 1 -column 5 -sticky ns
grid .sbxA -row 2 -columnspan 2 -sticky ew







>
>
>
>
>
>
>
>
>
>
>
>
>




>


|







461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
    $w mark set search $idx
    $w yview -pickplace $idx
    $w tag add search search "$idx +$count chars"
    $w tag config search -background {#fcc000}
  }
  set ::search $w
}

proc toggleWrap {} {
  upvar wrapMode w
  if {$w eq {none}} {
    set w word
  } else {
    set w none
  }
  foreach t {txtCol0 txtCol1} {
    upvar $t tt
    $tt tag config - -wrap $w
  }
}
::ttk::button .bb.quit -text {Quit} -command exit
::ttk::button .bb.invert -text {Invert} -command invertDiff
::ttk::button .bb.save -text {Save As...} -command saveDiff
::ttk::button .bb.search -text {Search} -command searchOnOff
::ttk::button .bb.wrap -text {Wrap} -command toggleWrap
pack .bb.quit .bb.invert -side left
if {$fossilcmd!=""} {pack .bb.save -side left}
pack .bb.files .bb.search .bb.wrap -side left
grid rowconfigure . 1 -weight 1
grid columnconfigure . 1 -weight 1
grid columnconfigure . 4 -weight 1
grid .bb -row 0 -columnspan 6
eval grid [cols] -row 1 -sticky nsew
grid .sby -row 1 -column 5 -sticky ns
grid .sbxA -row 2 -columnspan 2 -sticky ew