@@ -3467,8 +3467,8 @@ proc shellsplit {str} {
3467
3467
# Code to implement multiple views
3468
3468
3469
3469
proc newview {ishighlight} {
3470
- global nextviewnum newviewname newviewperm newishighlight
3471
- global newviewargs revtreeargs viewargscmd newviewargscmd curview
3470
+ global nextviewnum newviewname newishighlight
3471
+ global revtreeargs viewargscmd newviewopts curview
3472
3472
3473
3473
set newishighlight $ishighlight
3474
3474
set top .gitkview
@@ -3477,59 +3477,173 @@ proc newview {ishighlight} {
3477
3477
return
3478
3478
}
3479
3479
set newviewname($nextviewnum ) " [ mc " View" ] $nextviewnum "
3480
- set newviewperm ($nextviewnum ) 0
3481
- set newviewargs ($nextviewnum ) [shellarglist $revtreeargs ]
3482
- set newviewargscmd( $nextviewnum ) $viewargscmd($curview)
3480
+ set newviewopts ($nextviewnum ,perm ) 0
3481
+ set newviewopts ($nextviewnum ,cmd) $viewargscmd($curview)
3482
+ decode_view_opts $nextviewnum $revtreeargs
3483
3483
vieweditor $top $nextviewnum [mc " Gitk view definition" ]
3484
3484
}
3485
3485
3486
+ set known_view_options {
3487
+ {perm b . {} {mc " Remember this view" }}
3488
+ {args t50= + {} {mc " Commits to include (arguments to git log):" }}
3489
+ {all b * " --all" {mc " Use all refs" }}
3490
+ {dorder b . {" --date-order" " -d" } {mc " Strictly sort by date" }}
3491
+ {lright b . " --left-right" {mc " Mark branch sides" }}
3492
+ {since t15 + {" --since=*" " --after=*" } {mc " Since date:" }}
3493
+ {until t15 . {" --until=*" " --before=*" } {mc " Until date:" }}
3494
+ {limit t10 + " --max-count=*" {mc " Max count:" }}
3495
+ {skip t10 . " --skip=*" {mc " Skip:" }}
3496
+ {first b . " --first-parent" {mc " Limit to first parent" }}
3497
+ {cmd t50= + {} {mc " Command to generate more commits to include:" }}
3498
+ }
3499
+
3500
+ proc encode_view_opts {n} {
3501
+ global known_view_options newviewopts
3502
+
3503
+ set rargs [list ]
3504
+ foreach opt $known_view_options {
3505
+ set patterns [lindex $opt 3]
3506
+ if {$patterns eq {}} continue
3507
+ set pattern [lindex $patterns 0]
3508
+
3509
+ set val $newviewopts($n,[lindex $opt 0])
3510
+
3511
+ if {[lindex $opt 1] eq " b" } {
3512
+ if {$val } {
3513
+ lappend rargs $pattern
3514
+ }
3515
+ } else {
3516
+ set val [string trim $val ]
3517
+ if {$val ne {}} {
3518
+ set pfix [string range $pattern 0 end-1]
3519
+ lappend rargs $pfix$val
3520
+ }
3521
+ }
3522
+ }
3523
+ return [concat $rargs [shellsplit $newviewopts($n,args) ]]
3524
+ }
3525
+
3526
+ proc decode_view_opts {n view_args} {
3527
+ global known_view_options newviewopts
3528
+
3529
+ foreach opt $known_view_options {
3530
+ if {[lindex $opt 1] eq " b" } {
3531
+ set val 0
3532
+ } else {
3533
+ set val {}
3534
+ }
3535
+ set newviewopts($n ,[lindex $opt 0]) $val
3536
+ }
3537
+ set oargs [list ]
3538
+ foreach arg $view_args {
3539
+ if {[regexp -- {^-([0-9]+)$} $arg arg cnt]
3540
+ && ![info exists found(limit)]} {
3541
+ set newviewopts($n ,limit) $cnt
3542
+ set found(limit) 1
3543
+ continue
3544
+ }
3545
+ catch { unset val }
3546
+ foreach opt $known_view_options {
3547
+ set id [lindex $opt 0]
3548
+ if {[info exists found($id )]} continue
3549
+ foreach pattern [lindex $opt 3] {
3550
+ if {![string match $pattern $arg ]} continue
3551
+ if {[lindex $opt 1] ne " b" } {
3552
+ set size [string length $pattern ]
3553
+ set val [string range $arg [expr {$size -1}] end]
3554
+ } else {
3555
+ set val 1
3556
+ }
3557
+ set newviewopts($n ,$id ) $val
3558
+ set found($id ) 1
3559
+ break
3560
+ }
3561
+ if {[info exists val]} break
3562
+ }
3563
+ if {[info exists val]} continue
3564
+ lappend oargs $arg
3565
+ }
3566
+ set newviewopts($n ,args) [shellarglist $oargs ]
3567
+ }
3568
+
3486
3569
proc editview {} {
3487
3570
global curview
3488
- global viewname viewperm newviewname newviewperm
3489
- global viewargs newviewargs viewargscmd newviewargscmd
3571
+ global viewname viewperm newviewname newviewopts
3572
+ global viewargs viewargscmd
3490
3573
3491
3574
set top .gitkvedit-$curview
3492
3575
if {[winfo exists $top ]} {
3493
3576
raise $top
3494
3577
return
3495
3578
}
3496
- set newviewname($curview ) $viewname($curview)
3497
- set newviewperm ($curview ) $viewperm($curview)
3498
- set newviewargs ($curview ) [shellarglist $viewargs ($curview)]
3499
- set newviewargscmd( $curview ) $viewargscmd ($curview)
3579
+ set newviewname($curview ) $viewname($curview)
3580
+ set newviewopts ($curview ,perm ) $viewperm($curview)
3581
+ set newviewopts ($curview ,cmd) $viewargscmd ($curview)
3582
+ decode_view_opts $curview $viewargs ($curview)
3500
3583
vieweditor $top $curview " Gitk: edit view $viewname($curview) "
3501
3584
}
3502
3585
3503
3586
proc vieweditor {top n title} {
3504
- global newviewname newviewperm viewfiles bgcolor
3587
+ global newviewname newviewopts viewfiles bgcolor
3588
+ global known_view_options
3505
3589
3506
3590
toplevel $top
3507
3591
wm title $top $title
3508
3592
wm transient $top .
3593
+
3594
+ # View name
3595
+ frame $top .nfr
3509
3596
label $top .nl -text [mc " Name" ]
3510
3597
entry $top .name -width 20 -textvariable newviewname($n )
3511
- grid $top .nl $top .name -sticky w -pady 5
3512
- checkbutton $top .perm -text [mc " Remember this view" ] \
3513
- -variable newviewperm($n )
3514
- grid $top .perm - -pady 5 -sticky w
3515
- message $top .al -aspect 1000 \
3516
- -text [mc " Commits to include (arguments to git log):" ]
3517
- grid $top .al - -sticky w -pady 5
3518
- entry $top .args -width 50 -textvariable newviewargs($n ) \
3519
- -background $bgcolor
3520
- grid $top .args - -sticky ew -padx 5
3521
-
3522
- message $top .ac -aspect 1000 \
3523
- -text [mc " Command to generate more commits to include:" ]
3524
- grid $top .ac - -sticky w -pady 5
3525
- entry $top .argscmd -width 50 -textvariable newviewargscmd($n ) \
3526
- -background white
3527
- grid $top .argscmd - -sticky ew -padx 5
3528
-
3529
- message $top .l -aspect 1000 \
3598
+ pack $top .nfr -in $top -fill x -pady 5 -padx 3
3599
+ pack $top .nl -in $top .nfr -side left -padx {0 30}
3600
+ pack $top .name -in $top .nfr -side left
3601
+
3602
+ # View options
3603
+ set cframe $top .nfr
3604
+ set cexpand 0
3605
+ set cnt 0
3606
+ foreach opt $known_view_options {
3607
+ set id [lindex $opt 0]
3608
+ set type [lindex $opt 1]
3609
+ set flags [lindex $opt 2]
3610
+ set title [eval [lindex $opt 4]]
3611
+ set lxpad 0
3612
+
3613
+ if {$flags eq " +" || $flags eq " *" } {
3614
+ set cframe $top .fr$cnt
3615
+ incr cnt
3616
+ frame $cframe
3617
+ pack $cframe -in $top -fill x -pady 3 -padx 3
3618
+ set cexpand [expr {$flags eq " *" }]
3619
+ } else {
3620
+ set lxpad 5
3621
+ }
3622
+
3623
+ if {$type eq " b" } {
3624
+ checkbutton $cframe .c_$id -text $title -variable newviewopts($n ,$id )
3625
+ pack $cframe .c_$id -in $cframe -side left \
3626
+ -padx [list $lxpad 0] -expand $cexpand -anchor w
3627
+ } elseif {[regexp {^t(\d+)$} $type type sz]} {
3628
+ message $cframe .l_$id -aspect 1500 -text $title
3629
+ entry $cframe .e_$id -width $sz -background $bgcolor \
3630
+ -textvariable newviewopts($n ,$id )
3631
+ pack $cframe .l_$id -in $cframe -side left -padx [list $lxpad 0]
3632
+ pack $cframe .e_$id -in $cframe -side left -expand 1 -fill x
3633
+ } elseif {[regexp {^t(\d+)=$} $type type sz]} {
3634
+ message $cframe .l_$id -aspect 1500 -text $title
3635
+ entry $cframe .e_$id -width $sz -background $bgcolor \
3636
+ -textvariable newviewopts($n ,$id )
3637
+ pack $cframe .l_$id -in $cframe -side top -pady [list 3 0] -anchor w
3638
+ pack $cframe .e_$id -in $cframe -side top -fill x
3639
+ }
3640
+ }
3641
+
3642
+ # Path list
3643
+ message $top .l -aspect 1500 \
3530
3644
-text [mc " Enter files and directories to include, one per line:" ]
3531
- grid $top .l - -sticky w
3532
- text $top .t -width 40 -height 10 -background $bgcolor -font uifont
3645
+ pack $top .l -in $top -side top -pady [ list 7 0] -anchor w -padx 3
3646
+ text $top .t -width 40 -height 5 -background $bgcolor -font uifont
3533
3647
if {[info exists viewfiles($n )]} {
3534
3648
foreach f $viewfiles($n) {
3535
3649
$top .t insert end $f
@@ -3538,15 +3652,19 @@ proc vieweditor {top n title} {
3538
3652
$top .t delete {end - 1c} end
3539
3653
$top .t mark set insert 0.0
3540
3654
}
3541
- grid $top .t - -sticky ew -padx 5
3655
+ pack $top .t -in $top -side top -pady [ list 0 5] -fill both -expand 1 -padx 3
3542
3656
frame $top .buts
3543
3657
button $top .buts.ok -text [mc " OK" ] -command [list newviewok $top $n ]
3658
+ button $top .buts.apply -text [mc " Apply (F5)" ] -command [list newviewok $top $n 1]
3544
3659
button $top .buts.can -text [mc " Cancel" ] -command [list destroy $top ]
3660
+ bind $top <Control-Return> [list newviewok $top $n ]
3661
+ bind $top <F5> [list newviewok $top $n 1]
3545
3662
bind $top <Escape> [list destroy $top ]
3546
- grid $top .buts.ok $top .buts.can
3663
+ grid $top .buts.ok $top .buts.apply $top .buts. can
3547
3664
grid columnconfigure $top .buts 0 -weight 1 -uniform a
3548
3665
grid columnconfigure $top .buts 1 -weight 1 -uniform a
3549
- grid $top .buts - -pady 10 -sticky ew
3666
+ grid columnconfigure $top .buts 2 -weight 1 -uniform a
3667
+ pack $top .buts -in $top -side top -fill x
3550
3668
focus $top .t
3551
3669
}
3552
3670
@@ -3567,13 +3685,13 @@ proc allviewmenus {n op args} {
3567
3685
# doviewmenu $viewhlmenu 1 [list addvhighlight $n] $op $args
3568
3686
}
3569
3687
3570
- proc newviewok {top n} {
3688
+ proc newviewok {top n {apply 0} } {
3571
3689
global nextviewnum newviewperm newviewname newishighlight
3572
3690
global viewname viewfiles viewperm selectedview curview
3573
- global viewargs newviewargs viewargscmd newviewargscmd viewhlmenu
3691
+ global viewargs viewargscmd newviewopts viewhlmenu
3574
3692
3575
3693
if {[catch {
3576
- set newargs [shellsplit $newviewargs($n) ]
3694
+ set newargs [encode_view_opts $n ]
3577
3695
} err]} {
3578
3696
error_popup " [ mc " Error in commit selection arguments:" ] $err " $top
3579
3697
return
@@ -3589,10 +3707,10 @@ proc newviewok {top n} {
3589
3707
# creating a new view
3590
3708
incr nextviewnum
3591
3709
set viewname($n ) $newviewname($n)
3592
- set viewperm($n ) $newviewperm ($n)
3710
+ set viewperm($n ) $newviewopts ($n,perm )
3593
3711
set viewfiles($n ) $files
3594
3712
set viewargs($n ) $newargs
3595
- set viewargscmd($n ) $newviewargscmd ($n)
3713
+ set viewargscmd($n ) $newviewopts ($n,cmd )
3596
3714
addviewmenu $n
3597
3715
if {!$newishighlight } {
3598
3716
run showview $n
@@ -3601,7 +3719,7 @@ proc newviewok {top n} {
3601
3719
}
3602
3720
} else {
3603
3721
# editing an existing view
3604
- set viewperm($n ) $newviewperm ($n)
3722
+ set viewperm($n ) $newviewopts ($n,perm )
3605
3723
if {$newviewname($n) ne $viewname($n) } {
3606
3724
set viewname($n ) $newviewname($n)
3607
3725
doviewmenu .bar.view 5 [list showview $n ] \
@@ -3610,15 +3728,16 @@ proc newviewok {top n} {
3610
3728
# entryconf [list -label $viewname($n) -value $viewname($n)]
3611
3729
}
3612
3730
if {$files ne $viewfiles($n) || $newargs ne $viewargs($n) || \
3613
- $newviewargscmd ($n) ne $viewargscmd($n) } {
3731
+ $newviewopts ($n,cmd ) ne $viewargscmd($n) } {
3614
3732
set viewfiles($n ) $files
3615
3733
set viewargs($n ) $newargs
3616
- set viewargscmd($n ) $newviewargscmd ($n)
3734
+ set viewargscmd($n ) $newviewopts ($n,cmd )
3617
3735
if {$curview == $n } {
3618
3736
run reloadcommits
3619
3737
}
3620
3738
}
3621
3739
}
3740
+ if {$apply } return
3622
3741
catch {destroy $top }
3623
3742
}
3624
3743
0 commit comments