~ubuntu-branches/ubuntu/precise/tkcvs/precise

« back to all changes in this revision

Viewing changes to tkcvs/dircanvas.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Tim Cutts
  • Date: 2008-06-12 12:34:36 UTC
  • mfrom: (1.2.5 upstream) (3.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20080612123436-7mk82kha32mqpy5q
Tags: 8.1-1
* New upstream version (Closes: #485923)
* Moved to tk8.5
* Updated standards to 3.7.3
* Revised menu location according to policy
* Added short description to tkdirdiff manpage
* tkdiff is now being provided by tkcvs internally

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
# Columns for listing CVS files and their status
3
3
#
4
4
 
5
 
proc DirCanvas:create {w args} {
 
5
proc DirCanvas:create {w} {
6
6
  global cvscfg
7
7
  global cvsglb
8
8
  global arr
10
10
  global insvn
11
11
  global inrcs
12
12
 
13
 
  gen_log:log T "ENTER ($w $args)"
 
13
  gen_log:log T "ENTER ($w)"
14
14
 
15
15
  if {[catch "image type folder"]} {
16
16
    DirCanvas:loadimages
17
17
  }
18
 
 
19
 
  frame $w.filecol -relief sunken -bd 2
20
 
  frame $w.statcol -relief sunken -bd 2
21
 
  frame $w.datecol -relief sunken -bd 2
22
 
  frame $w.wrevcol -relief sunken -bd 2
23
 
  frame $w.editcol -relief sunken -bd 2
24
 
 
25
 
  eval canvas $w.filecol.list $args
26
 
  eval canvas $w.statcol.list $args
27
 
  eval canvas $w.datecol.list $args
28
 
  eval canvas $w.wrevcol.list $args
29
 
  eval canvas $w.editcol.list $args
 
18
  if [winfo exists $w.pw] {
 
19
    catch {DirCanvas:destroy $w.pw}
 
20
    catch {destroy $w.pw}
 
21
  }
 
22
 
 
23
  set winwid [winfo width $w]
 
24
  set beginwid [expr {$winwid / 5}]
 
25
  panedwindow $w.pw -relief sunk -bd 2
 
26
  $w.pw configure -handlepad 35 -sashwidth 4 -sashpad 0 -handlesize 10
 
27
 
 
28
  foreach column {filecol statcol datecol wrevcol editcol} {
 
29
    frame $w.$column
 
30
    canvas $w.$column.list -highlightthickness 0 -width $beginwid
 
31
    $w.$column configure -bg $cvsglb(canvbg)
 
32
    $w.$column.list configure -bg $cvsglb(canvbg)
 
33
    gen_log:log D "$column start width $beginwid"
 
34
  }
30
35
  scrollbar $w.yscroll -orient vertical -command "DirCanvas:scroll_windows $w" \
31
36
    -highlightthickness 0
32
 
 
33
37
  pack $w.yscroll -side right -fill y
34
38
 
35
 
  set cvsglb(fmbg) [lindex [$w.filecol configure -background] 4]
36
 
  if {[winfo exists .workdir]} {
37
 
    set cvsglb(fg) [lindex [.workdir.top.bmodbrowse configure -foreground] 4]
38
 
    set cvsglb(dfg) [lindex [.workdir.top.bmodbrowse configure -disabledforeground] 4]
39
 
    set buttonhilite [lindex [.workdir.top.bmodbrowse configure -highlightbackground] 4]
40
 
  }
41
 
  #set cvsglb(canvbg) [lindex [$w.filecol.list configure -background] 4]
42
 
  set selcolor [option get . selectColor selectColor]
43
 
  if {[string length $selcolor]} {
44
 
    set cvsglb(hlbg) $selcolor
45
 
  }
46
 
  if {$cvsglb(hlbg) == $cvsglb(canvbg)} {
47
 
    set cvsglb(hlbg) $buttonhilite
48
 
  }
49
 
  if {! [info exists cvsglb(glb_highlight)]} {
50
 
    set cvsglb(glb_highlight) $cvsglb(hlbg)
51
 
  }
52
 
 
53
39
  DirCanvas:column $w filecol "file"
54
40
  DirCanvas:column $w statcol "status"
55
41
  DirCanvas:column $w datecol "date"
62
48
 
63
49
  # Put an extra arrow on the file column for sorting by status
64
50
  set statusbutton $w.filecol.head.statbut
65
 
  button $statusbutton -image arr_dn -bg $cvsglb(fmbg) \
 
51
  button $statusbutton -image arr_dn -highlightbackground $cvsglb(bg) \
66
52
    -relief raised -bd 1 -highlightthickness 0
67
53
  set arr(filestatcol) $statusbutton
68
54
  pack $statusbutton -side left
116
102
  global inrcs
117
103
  global arr
118
104
 
119
 
  #gen_log:log T "ENTER ($w $column headtext)"
120
 
  #gen_log:log T "showstatcol $cvscfg(showstatcol) showdatecol $cvscfg(showdatecol) showeditcol $cvscfg(showeditcol)"
 
105
  gen_log:log T "ENTER ($w $column headtext)"
 
106
  gen_log:log T "showstatcol $cvscfg(showstatcol) showdatecol $cvscfg(showdatecol) showeditcol $cvscfg(showeditcol)"
121
107
 
122
108
  $w.$column.list configure -yscrollcommand "$w.yscroll set"
123
109
  bind $w.$column.list <Next>  "DirCanvas:scroll_windows $w scroll  1 pages"
135
121
  frame $w.$column.head -relief raised -bd 2
136
122
  label $w.$column.head.lbl -text "$headtext"
137
123
  button $w.$column.head.sbut -image arr_dn -relief flat \
138
 
    -highlightthickness 0 -bg $cvsglb(fmbg)
 
124
    -highlightthickness 0 -highlightbackground $cvsglb(bg)
139
125
  set arr($column) $w.$column.head.sbut
140
126
  gen_log:log D "$w.$column.head.sbut"
141
127
 
142
 
 
143
128
  bind $w.$column.head.sbut <ButtonPress-1> "DirCanvas:toggle_col $w $column"
144
129
  bind $w.$column.head.sbut <ButtonPress-2> "DirCanvas:sort_by_col $w $column -decreasing"
145
130
  bind $w.$column.head.sbut <ButtonPress-3> "DirCanvas:sort_by_col $w $column -increasing"
146
131
 
147
 
  scrollbar $w.$column.xscroll -orient horizontal -width 10 \
148
 
     -command "$w.$column.list xview"
149
 
  pack $w.$column.xscroll -side bottom -fill x
150
 
 
151
132
  if {$column == "datecol"} {
152
133
    if {$cvscfg(showdatecol)} {
153
134
      DirCanvas:map_column $w datecol
177
158
 
178
159
proc DirCanvas:map_column {w column} {
179
160
 
180
 
  #gen_log:log T "ENTER ($w $column)"
181
 
  set mapped_columns [pack slaves $w]
182
 
  gen_log:log D "$mapped_columns"
 
161
  gen_log:log T "ENTER ($w $column)"
 
162
  set mapped_columns [$w.pw panes]
 
163
  gen_log:log D "mapped columns: $mapped_columns"
183
164
 
184
165
  if {[lsearch -exact $mapped_columns "$w.statcol"] > -1} {
185
166
    set leftcol "$w.statcol"
188
169
  }
189
170
 
190
171
  if {$column == "datecol"} {
191
 
    pack $w.$column -after $leftcol -side left -fill both -expand yes
 
172
    $w.pw add $w.$column -after $leftcol -minsize 50
 
173
    gen_log:log D "ADD $w.$column"
192
174
  } elseif {$column == "statcol"} {
193
 
    pack $w.$column -after $w.filecol -side left -fill both -expand yes
 
175
    $w.pw add $w.$column -after $w.filecol -minsize 50
 
176
    gen_log:log D "ADD $w.$column"
194
177
  } elseif {$column == "editcol"} {
195
 
    pack $w.$column -after $w.wrevcol -side left -fill both -expand yes
 
178
    $w.pw add $w.$column -after $w.wrevcol -minsize 50
 
179
    gen_log:log D "ADD $w.$column"
196
180
  } else {
197
 
    pack $w.$column -side left -fill both -expand yes
 
181
    $w.pw add $w.$column -minsize 50
 
182
    gen_log:log D "ADD $w.$column"
198
183
  }
199
184
  pack $w.$column.head -side top -fill x -expand no
200
185
  pack $w.$column.head.sbut -side right
201
186
  pack $w.$column.head.lbl -side right -fill x -expand yes
202
187
  pack $w.$column.list -side top -fill both -ipadx 2 -expand yes
203
188
 
204
 
  #gen_log:log T "LEAVE"
 
189
  set winwid [winfo width $w]
 
190
  gen_log:log D "WIDTH $winwid"
 
191
  set mapped_columns [$w.pw panes]
 
192
  set num_columns [llength $mapped_columns]
 
193
  gen_log:log D "mapped_columns: $mapped_columns"
 
194
  set newwid [expr {$winwid / $num_columns}]
 
195
  update idletasks
 
196
  for {set i 0} { $i < [expr {$num_columns - 1}] } {incr i} {
 
197
    set coords [$w.pw sash coord $i]
 
198
    $w.pw sash place $i [expr {($i+1) * $newwid}] [lindex $coords 1]
 
199
    gen_log:log D "$column: moving sash $i from  $coords to [expr {($i+1) * $newwid}] [lindex $coords 1]"
 
200
  }
 
201
  update idletasks
 
202
 
 
203
  gen_log:log T "LEAVE"
205
204
}
206
205
 
207
 
#
208
 
# Pass configuration options to the list widget
209
 
#
210
 
proc DirCanvas:config {w args} {
211
 
  gen_log:log T "ENTER ($w $args)"
212
 
  eval $w.filecol.list config $args
213
 
  eval $w.statcol config $args
214
 
  eval $w.datecol config $args
215
 
  eval $w.wrevcol config $args
216
 
  eval $w.editcol config $args
 
206
proc DirCanvas:unmap_column {w column} {
 
207
  gen_log:log T "ENTER ($w $column)"
 
208
 
 
209
  $w.pw forget $w.$column
 
210
  set winwid [winfo width $w]
 
211
gen_log:log D "WIDTH $winwid"
 
212
  set mapped_columns [$w.pw panes]
 
213
  set num_columns [llength $mapped_columns]
 
214
  gen_log:log D "mapped_columns: $mapped_columns"
 
215
  set newwid [expr {$winwid /$num_columns}]
 
216
  for {set i 0} { $i < [expr {$num_columns - 1}] } {incr i} {
 
217
    set coords [$w.pw sash coord $i]
 
218
    $w.pw sash place $i [expr {($i+1) * $newwid}] [lindex $coords 1]
 
219
    gen_log:log D "$column: moving sash $i from  $coords to [expr {($i+1) * $newwid}] [lindex $coords 1]"
 
220
  }
217
221
  gen_log:log T "LEAVE"
218
222
}
219
223
 
306
310
proc DirCanvas:deltree {w} {
307
311
  global DirList
308
312
 
309
 
  catch {destroy $w.filecol}
310
 
  catch {destroy $w.statcol}
311
 
  catch {destroy $w.datecol}
312
 
  catch {destroy $w.wrevcol}
313
 
  catch {destroy $w.editcol}
 
313
  foreach column {filecol statcol datecol wrevcol editcol} {
 
314
    catch {destroy $w.$column}
 
315
  }
314
316
  catch {destroy $w.yscroll}
315
317
  foreach t [array names DirList $w:*] {
316
318
    unset DirList($t)
318
320
}
319
321
 
320
322
proc DirCanvas:flash {w y} {
321
 
  global cvsglb
 
323
  global cvscfg
322
324
 
323
 
  DirCanvas:setTextHBox $w $w.filecol.list.tx$y
 
325
  $w.filecol.list itemconfigure $w.filecol.list.tx$y -font $cvscfg(flashfont)
 
326
  foreach column [lrange [$w.pw panes] 1 end] {
 
327
    set i [$column.list find withtag $w.filecol.list.tx$y]
 
328
    $column.list itemconfigure $i -font $cvscfg(flashfont)
 
329
  }
324
330
}
325
331
 
326
 
proc DirCanvas:unflash {w y f} {
327
 
  global DirList
328
 
  #global cvsglb
 
332
proc DirCanvas:unflash {w y} {
 
333
  global cvscfg
329
334
 
330
 
  # Don't unflash if this is one that is selected:
331
 
  if { ! $DirList($w:$f:selected) } {
332
 
    DirCanvas:clearTextHBox $w $w.filecol.list.tx$y
333
 
    #if {! [file exists ./$f]} {
334
 
      # If a file CVS knows about doesn't exist, write its name in light ink
335
 
      #$w.filecol.list itemconfigure $w.filecol.list.tx$y -fill $cvsglb(dfg)
336
 
    #}
 
335
  $w.filecol.list itemconfigure $w.filecol.list.tx$y -font $cvscfg(listboxfont)
 
336
  foreach column [lrange [$w.pw panes] 1 end] {
 
337
    set i [$column.list find withtag $w.filecol.list.tx$y]
 
338
    $column.list itemconfigure $i -font $cvscfg(listboxfont)
337
339
  }
338
340
}
339
341
 
353
355
  set cvsglb(current_selection) $DirList($w:selection)
354
356
  DirCanvas:setTextHBox $w $w.filecol.list.tx$y
355
357
 
356
 
  # This seems to be necessary to enable some OS's (esp. Mandrake)
357
 
  # to get a double-click
358
 
  after 250
359
 
 
360
358
  gen_log:log T "LEAVE"
361
359
}
362
360
 
393
391
 
394
392
# clear any text highlight box (used by set/clearselection)
395
393
proc DirCanvas:clearTextHBox {w id} {
396
 
   global cvsglb
 
394
  global cvsglb
397
395
 
398
 
    # clear the tag corresponding to the text label
399
 
    catch {$w.filecol.list delete HBox$id}
400
 
    $w.filecol.list itemconfigure $id -fill $cvsglb(fg)
 
396
  # clear the tag corresponding to the text label
 
397
  foreach column [$w.pw panes] {
 
398
    catch {$column.list delete HBox$id}
 
399
    $column.list itemconfigure $id -fill $cvsglb(fg)
 
400
  }
401
401
}
402
402
 
403
403
# set a text highligh box (used by set/clearselection)
404
404
proc DirCanvas:setTextHBox {w id} {
405
 
   global cvsglb
406
 
 
407
 
   # get the bounding box for the text id
408
 
   set bbox [$w.filecol.list bbox $id]
409
 
   if {[llength $bbox]==4} {
410
 
    # create rectangle with fill, tagged with the same ID as the text, so we can delete it later
411
 
    set i [eval $w.filecol.list create rectangle $bbox -fill $cvsglb(hlbg) -tag HBox$id -outline \"\"]
412
 
 
413
 
    $w.filecol.list itemconfigure $id -fill $cvsglb(hlfg)
414
 
    $w.filecol.list lower $i
 
405
  global cvsglb
 
406
 
 
407
  # get the bounding box for the text id
 
408
  set bbox [$w.filecol.list bbox $id]
 
409
  if {[llength $bbox] != 4} {
 
410
    return
 
411
  }
 
412
  set lx [lindex $bbox 0]
 
413
  #set uy [lindex $bbox 1]
 
414
  set ly [lindex $bbox 3]
 
415
  set ly [expr {$ly +1}]
 
416
  set uy [expr {$ly -16}]
 
417
  set i [eval $w.filecol.list create rectangle \
 
418
    $lx $ly [winfo width $w.filecol] $uy \
 
419
    -fill $cvsglb(hlbg) -tag HBox$id -outline \"\"]
 
420
  $w.filecol.list itemconfigure $id -fill $cvsglb(hlfg)
 
421
  $w.filecol.list lower $i
 
422
  foreach column [lrange [$w.pw panes] 1 end] {
 
423
    # create rectangle with fill, tagged with the same ID as the text,
 
424
    # so we can delete it later
 
425
    set i [eval $column.list create rectangle \
 
426
      0 $ly [winfo width $column] $uy \
 
427
      -fill $cvsglb(hlbg) -tag HBox$id -outline \"\"]
 
428
    $column.list itemconfigure $id -fill $cvsglb(hlfg)
 
429
    $column.list lower $i
415
430
  }
416
431
}
417
432
 
418
 
 
419
433
proc DirCanvas:addrange {w y f} {
420
434
  global DirList
421
435
  global cvsglb
485
499
      set y $DirList($w:$f:y)
486
500
      set DirList($w:$f:selected) 0
487
501
      DirCanvas:clearTextHBox $w $w.filecol.list.tx$y
488
 
      # Prepending ./ to the filename prevents tilde expansion
489
 
      #if {! [file exists ./$f]} {
490
 
        # If a file CVS knows about doesn't exist, write its name in light ink
491
 
        #$w.filecol.list itemconfigure $w.filecol.list.tx$y -fill $cvsglb(dfg)
492
 
      #}
493
502
    }
494
503
    set DirList($w:selection) {}
495
504
    set cvsglb(current_selection) {}
497
506
  gen_log:log T "LEAVE"
498
507
}
499
508
 
500
 
proc DirCanvas:areaStart {w x y} {
501
 
  global areaX1 areaY1
502
 
  global areaX2 areaY2
503
 
 
504
 
  gen_log:log T "ENTER ($w $x $y)"
505
 
  $w delete area
506
 
  set areaX1 [$w canvasx $x]
507
 
  set areaY1 [$w canvasy $y]
508
 
  set areaX2 $areaX1
509
 
  set areaY2 $areaY1
510
 
}
511
 
 
512
 
proc DirCanvas:areaStroke {w x y} {
513
 
  global areaX1 areaY1
514
 
  global areaX2 areaY2
515
 
  global cvsglb
516
 
  global cvscfg
517
 
 
518
 
  set x [$w canvasx $x]
519
 
  set y [$w canvasy $y]
520
 
  if {$areaY1 != $y && $areaX1 != $x} {
521
 
    $w delete area
522
 
    $w addtag area withtag \
523
 
      [$w create rect $areaX1 $areaY1 $x $y -outline $cvsglb(glb_highlight)]
524
 
    set areaX2 $x
525
 
    set areaY2 $y
526
 
  }
527
 
}
528
 
 
529
 
proc DirCanvas:areaFind {w} {
530
 
  global areaX1 areaY1
531
 
  global areaX2 areaY2
532
 
  global DirList
533
 
 
534
 
  gen_log:log T "ENTER ($w)"
535
 
  gen_log:log D "$areaX1 $areaY1 $areaX2 $areaY2"
536
 
  set items {}
537
 
  foreach i [$w find enclosed $areaX1 $areaY1 $areaX2 $areaY2] {
538
 
    lappend items $i
539
 
  }
540
 
  foreach i [$w find overlapping $areaX1 $areaY1 $areaX2 $areaY2] {
541
 
      lappend items $i
542
 
  }
543
 
  gen_log:log D "Items in area: $items"
544
 
  set parent [winfo parent [winfo parent $w]]
545
 
  foreach i $items {
546
 
    set itags [$w gettags $i]
547
 
    if { [string match .workdir* [lindex $itags 0]]  } {
548
 
      set iy [lindex $itags 1]
549
 
      gen_log:log D "$w tx$iy"
550
 
      DirCanvas:addselection $parent $iy [lindex $itags 2]
551
 
    }
552
 
  }
553
 
  $w delete area
554
 
}
555
 
 
556
509
# Internal use only.
557
510
# Draw the files on the canvas
558
511
proc DirCanvas:build {w} {
565
518
  global inrcs
566
519
 
567
520
  gen_log:log T "ENTER ($w)"
568
 
  set flist $w.filecol.list
569
 
  foreach b [winfo children $flist] {
 
521
  foreach b [winfo children $w.filecol.list] {
570
522
    destroy $b
571
523
  }
572
 
  $flist delete all
573
 
  $w.statcol.list delete all
574
 
  $w.datecol.list delete all
575
 
  $w.wrevcol.list delete all
576
 
  $w.editcol.list delete all
 
524
  foreach column [$w.pw panes] {
 
525
    $column.list delete all
 
526
  }
577
527
  catch {unset DirList($w:buildpending)}
578
528
 
579
529
  set x 3
580
530
  set lblx 21
581
531
  set y 20
582
532
  set imy [expr {[image height paper] + 2}]
583
 
  set fy [font metrics $cvscfg(listboxfont) -displayof $flist -linespace]
 
533
  set fy [font metrics $cvscfg(listboxfont) -displayof $w.filecol.list -linespace]
584
534
  set fy [expr {$fy + 2}]
585
535
  if {$imy > $fy} {
586
536
    set yincr $imy
743
693
      }
744
694
     "<directory:RCS>" {
745
695
       set DirList($w:$f:icon) rcsdir
746
 
       set DirList($w:$f:popup) rcsdir_pop
 
696
       set DirList($w:$f:popup) folder_pop
747
697
      }
748
698
     "Up-to-date" {
749
699
       set DirList($w:$f:icon) stat_ok
789
739
      }
790
740
      "Locally Modified" {
791
741
       set DirList($w:$f:icon) stat_mod
792
 
       set DirList($w:$f:popup) stat_mod_pop
 
742
       switch -- $rtype {
 
743
          "CVS" {
 
744
             set DirList($w:$f:popup) stat_mod_pop
 
745
          }
 
746
          "SVN" {
 
747
             set DirList($w:$f:popup) stat_svnmod_pop
 
748
          }
 
749
       }
793
750
      }
794
751
      "Locally Added" {
795
752
       set DirList($w:$f:icon) stat_plus
829
786
    }
830
787
 
831
788
    # Easy way to unselect everything by clicking in a blank area
832
 
    bind $flist <1> "DirCanvas:unselectall $w 0"
833
 
    bind $flist <Shift-1> " "
 
789
    bind $w.filecol.list <1> "DirCanvas:unselectall $w 0"
 
790
    bind $w.filecol.list <Shift-1> " "
 
791
    # For columns except filecol, this breaks selecting the text item.  Why??
 
792
    #bind $w.datecol.list <1> "DirCanvas:unselectall $w 0"
834
793
 
835
 
    bind $flist <2> "DirCanvas:areaStart $flist %x %y"
836
 
    bind $flist <B2-Motion> "DirCanvas:areaStroke $flist %x %y; \
837
 
                             DirCanvas:drag_windows $w %W %y"
838
 
    bind $flist <B2-Motion><ButtonRelease-2> "DirCanvas:unselectall $w 1; \
839
 
                                              DirCanvas:areaFind $flist"
840
 
    bind $flist <3> "DirCanvas:areaStart $flist %x %y"
841
 
    bind $flist <Shift-3> "DirCanvas:areaStart $flist %x %y"
842
 
    bind $flist <B3-Motion> "DirCanvas:areaStroke $flist %x %y; \
843
 
                             DirCanvas:drag_windows $w %W %y"
844
 
    bind $flist <B3-Motion><ButtonRelease-3> "DirCanvas:unselectall $w 1; \
845
 
                                              DirCanvas:areaFind $flist"
846
794
    # In the bindings, filenames need any single percents replaced with
847
795
    # double to avoid interpretation as an event field
848
796
    regsub -all {\%} $f {%%} fn
849
797
    regsub -all {\$} $fn {\$} fn
850
798
 
851
 
    # The "x" tag is used for area selection.
852
799
    # Draw the icon
853
 
     set k [$flist create image $x $y -image $DirList($w:$f:icon) \
854
 
       -anchor w -tags [list x $y] ]
855
 
     $flist bind $k <1> "DirCanvas:setselection $w $y \"$fn\""
856
 
     $flist bind $k <Shift-1> "DirCanvas:addrange $w $y \"$fn\""
857
 
     $flist bind $k <Control-1> "DirCanvas:addselection $w $y \"$fn\""
858
 
     $flist bind $k <Double-1> {workdir_edit_file [workdir_list_files]}
859
 
     $flist bind $k <2> "DirCanvas:areaStart $flist %x %y; \
860
 
                         DirCanvas:popup $flist $y %X %Y \"$fn\""
861
 
     $flist bind $k <3> "DirCanvas:areaStart $flist %x %y; \
862
 
                         DirCanvas:popup $flist $y %X %Y \"$fn\""
 
800
    set k [$w.filecol.list create image $x $y -image $DirList($w:$f:icon) \
 
801
      -anchor w -tags [list $y] ]
 
802
    $w.filecol.list bind $k <1> "DirCanvas:setselection $w $y \"$fn\""
 
803
    $w.filecol.list bind $k <Shift-1> "DirCanvas:addrange $w $y \"$fn\""
 
804
    $w.filecol.list bind $k <Control-1> "DirCanvas:addselection $w $y \"$fn\""
 
805
    $w.filecol.list bind $k <Double-1> {workdir_edit_file [workdir_list_files]}
863
806
 
864
807
    # Draw the label
865
 
     $flist create text $lblx $y  -text $f -font $cvscfg(listboxfont) \
866
 
       -anchor w -tags [list $flist.tx$y $y $fn] -fill $lblfg
867
 
     $flist bind $flist.tx$y <1> "DirCanvas:setselection $w $y \"$fn\""
868
 
     $flist bind $flist.tx$y <Shift-1> "DirCanvas:addrange $w $y \"$fn\""
869
 
     $flist bind $flist.tx$y <Enter> "DirCanvas:flash $w $y"
870
 
     $flist bind $flist.tx$y <Leave> "DirCanvas:unflash $w $y \"$fn\""
871
 
     $flist bind $flist.tx$y <Control-1> "DirCanvas:addselection $w $y \"$fn\""
872
 
     $flist bind $flist.tx$y <Double-1> {workdir_edit_file [workdir_list_files]}
873
 
     $flist bind $flist.tx$y <2> "DirCanvas:areaStart $flist %x %y; \
874
 
                                  DirCanvas:popup $flist $y %X %Y \"$fn\""
875
 
     $flist bind $flist.tx$y <3> "DirCanvas:areaStart $flist %x %y; \
876
 
                                  DirCanvas:popup $flist $y %X %Y \"$fn\""
 
808
    $w.filecol.list create text $lblx $y  -text $f -font $cvscfg(listboxfont) \
 
809
      -anchor w -tags [list $w.filecol.list.tx$y $y $fn] -fill $lblfg
 
810
    $w.filecol.list bind $w.filecol.list.tx$y <1> "DirCanvas:setselection $w $y \"$fn\""
 
811
    $w.filecol.list bind $w.filecol.list.tx$y <Shift-1> "DirCanvas:addrange $w $y \"$fn\""
 
812
    $w.filecol.list bind $w.filecol.list.tx$y <Enter> "DirCanvas:flash $w $y"
 
813
    $w.filecol.list bind $w.filecol.list.tx$y <Leave> "DirCanvas:unflash $w $y"
 
814
    $w.filecol.list bind $w.filecol.list.tx$y <Control-1> "DirCanvas:addselection $w $y \"$fn\""
 
815
    $w.filecol.list bind $w.filecol.list.tx$y <Double-1> {workdir_edit_file [workdir_list_files]}
 
816
    $w.filecol.list bind $w.filecol.list.tx$y <2> " DirCanvas:popup $w.filecol.list $y %X %Y \"$fn\""
 
817
    $w.filecol.list bind $w.filecol.list.tx$y <3> " DirCanvas:popup $w.filecol.list $y %X %Y \"$fn\""
877
818
 
878
819
    set DirList($w:$f:y) $y
879
 
    set DirList($flist:$y) $f
 
820
    set DirList($w.filecol.list:$y) $f
880
821
 
881
822
    set status $DirList($w:$f:status)
882
 
    set k [$w.statcol.list create text 8 $y -fill $cvsglb(fg) \
883
 
       -text $status -font $cvscfg(listboxfont) -anchor w]
 
823
    set k [$w.statcol.list create text 8 $y -text $status \
 
824
      -font $cvscfg(listboxfont) -fill $cvsglb(fg) -anchor w \
 
825
      -tags [list $w.filecol.list.tx$y $y $fn]]
 
826
    $w.statcol.list bind $k <1> "DirCanvas:setselection $w $y \"$fn\""
 
827
    $w.statcol.list bind $k <Shift-1> "DirCanvas:addrange $w $y \"$fn\""
 
828
    $w.statcol.list bind $k <Enter> "DirCanvas:flash $w $y"
 
829
    $w.statcol.list bind $k <Leave> "DirCanvas:unflash $w $y"
 
830
    $w.statcol.list bind $k <Control-1> "DirCanvas:addselection $w $y \"$fn\""
884
831
    set slen [string length $status]
885
832
    if {$slen > $maxstat} {
886
833
      set maxstat $slen
888
835
    }
889
836
 
890
837
    set date $DirList($w:$f:date)
891
 
    set k [$w.datecol.list create text 4 $y -fill $cvsglb(fg) \
892
 
       -text $date -font $cvscfg(listboxfont) -anchor w]
 
838
    set k [$w.datecol.list create text 4 $y -text $date \
 
839
      -font $cvscfg(listboxfont) -fill $cvsglb(fg) -anchor w \
 
840
      -tags [list $w.filecol.list.tx$y $y $fn]]
 
841
    $w.datecol.list bind $k <1> "DirCanvas:setselection $w $y \"$fn\""
 
842
    $w.datecol.list bind $k <Shift-1> "DirCanvas:addrange $w $y \"$fn\""
 
843
    $w.datecol.list bind $k <Enter> "DirCanvas:flash $w $y"
 
844
    $w.datecol.list bind $k <Leave> "DirCanvas:unflash $w $y"
 
845
    $w.datecol.list bind $k <Control-1> "DirCanvas:addselection $w $y \"$fn\""
893
846
    set dlen [string length $date]
894
847
    if {$dlen > $maxdate} {
895
848
      set maxdate $dlen
898
851
 
899
852
    if {[info exists DirList($w:$f:sticky)]} {
900
853
      set tag $DirList($w:$f:sticky)
901
 
      set k [$w.wrevcol.list create text 4 $y -fill $cvsglb(fg) \
902
 
         -text $tag -font $cvscfg(listboxfont) -anchor w]
 
854
      set k [$w.wrevcol.list create text 4 $y -text $tag \
 
855
        -font $cvscfg(listboxfont) -fill $cvsglb(fg) -anchor w \
 
856
        -tags [list $w.filecol.list.tx$y $y $fn]]
 
857
      $w.wrevcol.list bind $k <1> "DirCanvas:setselection $w $y \"$fn\""
 
858
      $w.wrevcol.list bind $k <Shift-1> "DirCanvas:addrange $w $y \"$fn\""
 
859
      $w.wrevcol.list bind $k <Enter> "DirCanvas:flash $w $y"
 
860
      $w.wrevcol.list bind $k <Leave> "DirCanvas:unflash $w $y"
 
861
      $w.wrevcol.list bind $k <Control-1> "DirCanvas:addselection $w $y \"$fn\""
903
862
      set tlen [string length $tag]
904
863
      if {$tlen > $maxtag} {
905
864
        set maxtag $tlen
908
867
    }
909
868
 
910
869
    set editors $DirList($w:$f:editors)
911
 
    set k [$w.editcol.list create text 4 $y -fill $cvsglb(fg) \
912
 
       -text $editors -font $cvscfg(listboxfont) -anchor w]
 
870
    set k [$w.editcol.list create text 4 $y -text $editors \
 
871
      -font $cvscfg(listboxfont) -fill $cvsglb(fg) -anchor w \
 
872
      -tags [list $w.filecol.list.tx$y $y $fn]]
 
873
    $w.editcol.list bind $k <1> "DirCanvas:setselection $w $y \"$fn\""
 
874
    $w.editcol.list bind $k <Shift-1> "DirCanvas:addrange $w $y \"$fn\""
 
875
    $w.editcol.list bind $k <Enter> "DirCanvas:flash $w $y"
 
876
    $w.editcol.list bind $k <Leave> "DirCanvas:unflash $w $y"
 
877
    $w.editcol.list bind $k <Control-1> "DirCanvas:addselection $w $y \"$fn\""
913
878
    set edlen [string length $editors]
914
879
    if {$edlen > $maxed} {
915
880
      set maxed $edlen
921
886
  if {$incvs || $insvn || $inrcs} {
922
887
    if {$cvscfg(showstatcol)} {
923
888
      DirCanvas:map_column $w statcol
924
 
    } else {
925
 
      pack forget $w.statcol
926
889
    }
927
890
    if {$cvscfg(showeditcol)} {
928
891
      DirCanvas:map_column $w editcol
929
 
    } else {
930
 
      pack forget $w.editcol
931
892
    }
932
893
  }
933
894
  if {$cvscfg(showdatecol)} {
934
895
    DirCanvas:map_column $w datecol
935
 
  } else {
936
 
    pack forget $w.datecol
937
896
  }
938
897
 
939
 
 
940
 
  set wid [font measure $cvscfg(listboxfont) -displayof $w $longlbl]
941
 
  set DirList($w:filecolwidth) [expr {$x + $wid + $lblx + 8}]
942
898
  # Set a minimum width for the labels.  Otherwise ".." can be hard to select.
943
899
  set minlabel 6
944
 
  foreach labl [$flist find withtag lbl] {
945
 
    set itags [$flist gettags $labl]
 
900
  foreach labl [$w.filecol.list find withtag lbl] {
 
901
    set itags [$w.filecol.list gettags $labl]
946
902
    set iy [lindex $itags 1]
947
 
    if {[string length $DirList($flist:$iy)] < $minlabel} {
948
 
      $flist.tx$iy configure -width $minlabel
949
 
    }
950
 
  }
951
 
  # Don't let the column be too wide.
952
 
  set maxcolwid 200
953
 
  gen_log:log D "filecol width $DirList($w:filecolwidth)"
954
 
  if {$wid < $maxcolwid} {
955
 
    $flist configure -width $DirList($w:filecolwidth)
956
 
  } else {
957
 
    gen_log:log D "Reducing filecol width from $wid to $maxcolwid"
958
 
    $flist configure -width $maxcolwid
959
 
  }
960
 
  $flist configure -xscrollcommand "$w.filecol.xscroll set"
961
 
 
962
 
  set wid [font measure $cvscfg(listboxfont) -displayof $w $longstat]
963
 
  set DirList($w:statcolwidth) [expr {$wid + 6}]
964
 
  gen_log:log D "statcol width $DirList($w:statcolwidth)"
965
 
  if {$wid < $maxcolwid} {
966
 
    $w.statcol.list configure -width $DirList($w:statcolwidth)
967
 
  } else {
968
 
    gen_log:log D "Reducing statcol width from $wid to $maxcolwid"
969
 
    $w.statcol.list configure -width $maxcolwid
970
 
  }
971
 
  $w.statcol.list configure -xscrollcommand "$w.statcol.xscroll set"
972
 
 
973
 
  set wid [font measure $cvscfg(listboxfont) -displayof $w $longdate]
974
 
  set DirList($w:datecolwidth) [expr {$wid + 6}]
975
 
  if {$wid < $maxcolwid} {
976
 
    $w.datecol.list configure -width $DirList($w:datecolwidth)
977
 
  } else {
978
 
    gen_log:log D "Reducing datecol width from $wid to $maxcolwid"
979
 
    $w.datecol.list configure -width $maxcolwid
980
 
  }
981
 
  $w.datecol.list configure -xscrollcommand "$w.datecol.xscroll set"
982
 
 
983
 
 
984
 
  if {$incvs || $insvn || $inrcs} {
985
 
    set wid [font measure $cvscfg(listboxfont) -displayof $w $longtag]
986
 
    set DirList($w:revcolwidth) [expr {$wid + 6}]
987
 
    gen_log:log D "width of $w.wrevcol $maxtag chars ($wid)"
988
 
    # Don't let the column be too wide.
989
 
    if {$wid < $maxcolwid} {
990
 
      $w.wrevcol.list configure -width $DirList($w:revcolwidth)
991
 
    } else {
992
 
      gen_log:log D "Reducing wrevcol width from $wid to $maxcolwid"
993
 
      $w.wrevcol.list configure -width $maxcolwid
994
 
    }
995
 
    $w.wrevcol.list configure -xscrollcommand "$w.wrevcol.xscroll set"
996
 
 
997
 
    set wid [font measure $cvscfg(listboxfont) -displayof $w $longed]
998
 
    set DirList($w:edcolwidth) [expr {$wid + 6}]
999
 
    gen_log:log D "width of $w.editcol $maxed chars ($wid)"
1000
 
    if {$wid < $maxcolwid} {
1001
 
      $w.editcol.list configure -width $DirList($w:edcolwidth)
1002
 
    } else {
1003
 
      gen_log:log D "Reducing editcol width from $wid to $maxcolwid"
1004
 
      $w.editcol.list configure -width $maxcolwid
1005
 
    }
1006
 
    $w.editcol.list configure -xscrollcommand "$w.editcol.xscroll set"
 
903
    if {[string length $DirList($w.filecol.list:$iy)] < $minlabel} {
 
904
      $w.filecol.list.tx$iy configure -width $minlabel
 
905
    }
1007
906
  }
1008
907
 
1009
908
  # Scroll to the top of the lists
1010
 
  set fbbox [$flist bbox all]
1011
 
  #gen_log:log D "fbbox   \"$fbbox\""
 
909
  set fbbox [$w.filecol.list bbox all]
 
910
  gen_log:log D "fbbox   \"$fbbox\""
1012
911
  if {[llength $fbbox] == 4} {
1013
912
    set ylen [expr {[lindex $fbbox 3] - [lindex $fbbox 1]}]
1014
913
 
1015
 
    set wview [winfo height $flist]
 
914
    set wview [winfo height $w.filecol.list]
1016
915
    $w.yscroll set 0 [expr ($wview * 1.0) / ($ylen * 1.0)]
1017
916
    update idletasks
1018
917
 
1019
 
    $flist config -scrollregion $fbbox
1020
 
    $flist yview moveto 0
 
918
    $w.filecol.list config -scrollregion $fbbox
 
919
    $w.filecol.list yview moveto 0
1021
920
 
1022
921
    if {$cvscfg(showdatecol)} {
1023
 
      set fbbox [$w.datecol.list bbox all]
1024
 
      set botx [lindex $fbbox 0]
1025
 
      set boty [lindex $fbbox 1]
1026
 
      $w.datecol.list config -scrollregion \
1027
 
        [list $botx $boty \
1028
 
          [expr {$botx + $DirList($w:datecolwidth)}] \
1029
 
          [expr {$boty + $ylen}]]
 
922
      $w.datecol.list config -scrollregion [$w.datecol.list bbox all]
1030
923
      $w.datecol.list yview moveto 0
1031
924
    }
1032
925
 
1033
926
    if {$incvs || $insvn || $inrcs} {
1034
 
      set fbbox [$w.wrevcol.list bbox all]
1035
 
      set botx [lindex $fbbox 0]
1036
 
      set boty [lindex $fbbox 1]
1037
 
      $w.wrevcol.list config -scrollregion \
1038
 
        [list $botx $boty \
1039
 
          [expr {$botx + $DirList($w:revcolwidth)}] \
1040
 
          [expr {$boty + $ylen}]]
 
927
      $w.wrevcol.list config -scrollregion [$w.wrevcol.list bbox all]
1041
928
      $w.wrevcol.list yview moveto 0
1042
929
 
1043
930
      if {$cvscfg(showstatcol)} {
1044
 
        set fbbox [$w.statcol.list bbox all]
1045
 
        set botx [lindex $fbbox 0]
1046
 
        set boty [lindex $fbbox 1]
1047
 
        $w.statcol.list config -scrollregion \
1048
 
          [list $botx $boty \
1049
 
            [expr {$botx + $DirList($w:statcolwidth)}] \
1050
 
            [expr {$boty + $ylen}]]
 
931
        $w.statcol.list config -scrollregion [$w.statcol.list bbox all]
1051
932
        $w.statcol.list yview moveto 0
1052
933
      }
1053
934
 
1054
935
      if {$cvscfg(showeditcol)} {
1055
 
        set fbbox [$w.editcol.list bbox all]
1056
 
        set botx [lindex $fbbox 0]
1057
 
        set boty [lindex $fbbox 1]
1058
 
        $w.editcol.list config -scrollregion \
1059
 
          [list $botx $boty \
1060
 
            [expr {$botx + $DirList($w:edcolwidth)}] \
1061
 
            [expr {$boty + $ylen}]]
 
936
        $w.editcol.list config -scrollregion [$w.editcol.list bbox all]
1062
937
        $w.editcol.list yview moveto 0
1063
938
      }
1064
939
    }
1255
1130
  menu $w.needsupdate_pop -tearoff 0
1256
1131
  $w.needsupdate_pop add command -label "Update" \
1257
1132
    -command { \
1258
 
        cvs_update {BASE} {Normal} {Remove} {No} { } [workdir_list_files] }
 
1133
        cvs_update {BASE} {Normal} {Remove} {recurse} {prune} {No} { } [workdir_list_files] }
1259
1134
  $w.needsupdate_pop add command -label "Update with Options" \
1260
 
    -command update_run
 
1135
    -command cvs_update_options
1261
1136
 
1262
1137
  # For CVS files that need merging
1263
1138
  menu $w.stat_merge_pop -tearoff 0
1276
1151
    -command { workdir_edit_file [workdir_list_files] }
1277
1152
  $w.stat_mod_pop add command -label "Diff" \
1278
1153
    -command { comparediff [workdir_list_files] }
1279
 
  $w.stat_mod_pop add command -label "Commit" \
 
1154
  $w.stat_mod_pop add command -label "CVS Commit" \
1280
1155
    -command { cvs_commit_dialog }
1281
 
  $w.stat_mod_pop add command -label "Revert" \
 
1156
  $w.stat_mod_pop add command -label "CVS Revert" \
1282
1157
    -command { cvs_revert [workdir_list_files] }
1283
1158
 
1284
1159
  # For CVS files that have been added or removed but not commited
1285
1160
  menu $w.stat_plus_pop -tearoff 0
1286
1161
  $w.stat_plus_pop add command -label "Edit" \
1287
1162
    -command { workdir_edit_file [workdir_list_files] }
1288
 
  $w.stat_plus_pop add command -label "Commit" \
 
1163
  $w.stat_plus_pop add command -label "CVS Commit" \
1289
1164
    -command { cvs_commit_dialog }
1290
1165
 
1291
1166
  # For CVS files with conflicts
1311
1186
    -command { rcs_lock unlock [workdir_list_files] }
1312
1187
  $w.rcs_pop add command -label "Delete Locally" \
1313
1188
    -command { workdir_delete_file [workdir_list_files] }
1314
 
  $w.rcs_pop add command -label "Revert" \
 
1189
  $w.rcs_pop add command -label "RCS Revert" \
1315
1190
    -command { rcs_revert [workdir_list_files] }
1316
1191
 
1317
1192
  # For SVN files
1324
1199
    -command { svn_branches [workdir_list_files] }
1325
1200
  $w.stat_svnok_pop add command -label "SVN Annotate/Blame" \
1326
1201
    -command { svn_annotate "" [workdir_list_files] }
1327
 
  $w.stat_svnok_pop add command -label "Revert" \
 
1202
  $w.stat_svnok_pop add command -label "SVN Remove" \
 
1203
    -command { subtract_dialog [workdir_list_files] }
 
1204
 
 
1205
  # For SVN files that are modified
 
1206
  menu $w.stat_svnmod_pop -tearoff 0
 
1207
  $w.stat_svnmod_pop add command -label "Edit" \
 
1208
    -command { workdir_edit_file [workdir_list_files] }
 
1209
  $w.stat_svnmod_pop add command -label "Diff" \
 
1210
    -command { comparediff [workdir_list_files] }
 
1211
  $w.stat_svnmod_pop add command -label "SVN Commit" \
 
1212
    -command { svn_commit_dialog }
 
1213
  $w.stat_svnmod_pop add command -label "SVN Revert" \
1328
1214
    -command { svn_revert [workdir_list_files] }
1329
 
  $w.stat_svnok_pop add command -label "SVN Remove" \
1330
 
    -command { subtract_dialog [workdir_list_files] }
1331
1215
 
1332
1216
  # For SVN directories
1333
1217
  menu $w.svnfolder_pop -tearoff 0
1347
1231
  $w.svndir_pop add command -label "SVN Log" \
1348
1232
    -command { svn_log [workdir_list_files] }
1349
1233
 
1350
 
  # For RCS directories
1351
 
  menu $w.rcsdir_pop -tearoff 0
1352
 
  $w.rcsdir_pop add command -label "Descend" \
1353
 
    -command { workdir_edit_file [workdir_list_files] }
1354
 
 
1355
1234
  gen_log:log T "LEAVE"
1356
1235
}
1357
1236
 
1365
1244
  gen_log:log T "LEAVE"
1366
1245
}
1367
1246
 
 
1247
proc DirCanvas:destroy {w} {
 
1248
  foreach u [winfo children $w] {
 
1249
    catch {destroy $u}
 
1250
  }
 
1251
}
 
1252
 
 
1253