Skip to content

Commit 99ba48e

Browse files
committed
Merge branch 'pt/non-mouse-usage' into pu
2 parents c7fb7bf + 30508bc commit 99ba48e

File tree

2 files changed

+155
-42
lines changed

2 files changed

+155
-42
lines changed

git-gui.sh

Lines changed: 69 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2511,20 +2511,36 @@ proc force_first_diff {after} {
25112511
}
25122512
}
25132513
2514-
proc toggle_or_diff {w x y} {
2514+
proc toggle_or_diff {mode w args} {
25152515
global file_states file_lists current_diff_path ui_index ui_workdir
25162516
global last_clicked selected_paths
25172517
2518-
set pos [split [$w index @$x,$y] .]
2519-
set lno [lindex $pos 0]
2520-
set col [lindex $pos 1]
2518+
if {$mode eq "click"} {
2519+
foreach {x y} $args break
2520+
set pos [split [$w index @$x,$y] .]
2521+
foreach {lno col} $pos break
2522+
} else {
2523+
if {$last_clicked ne {}} {
2524+
set lno [lindex $last_clicked 1]
2525+
} else {
2526+
set lno [expr {int([lindex [$w tag ranges in_diff] 0])}]
2527+
}
2528+
if {$mode eq "toggle"} {
2529+
set col 0; set y 2
2530+
} else {
2531+
incr lno [expr {$mode eq "up" ? -1 : 1}]
2532+
set col 1
2533+
}
2534+
}
2535+
25212536
set path [lindex $file_lists($w) [expr {$lno - 1}]]
25222537
if {$path eq {}} {
25232538
set last_clicked {}
25242539
return
25252540
}
25262541
25272542
set last_clicked [list $w $lno]
2543+
focus $w
25282544
array unset selected_paths
25292545
$ui_index tag remove in_sel 0.0 end
25302546
$ui_workdir tag remove in_sel 0.0 end
@@ -2604,7 +2620,7 @@ proc add_range_to_selection {w x y} {
26042620
global file_lists last_clicked selected_paths
26052621
26062622
if {[lindex $last_clicked 0] ne $w} {
2607-
toggle_or_diff $w $x $y
2623+
toggle_or_diff click $w $x $y
26082624
return
26092625
}
26102626
@@ -3184,16 +3200,38 @@ if {$use_ttk} {
31843200
}
31853201
pack .vpane -anchor n -side top -fill both -expand 1
31863202
3203+
# -- Working Directory File List
3204+
3205+
textframe .vpane.files.workdir -height 100 -width 200
3206+
tlabel .vpane.files.workdir.title -text [mc "Unstaged Changes"] \
3207+
-background lightsalmon -foreground black
3208+
ttext $ui_workdir -background white -foreground black \
3209+
-borderwidth 0 \
3210+
-width 20 -height 10 \
3211+
-wrap none \
3212+
-takefocus 1 -highlightthickness 1\
3213+
-cursor $cursor_ptr \
3214+
-xscrollcommand {.vpane.files.workdir.sx set} \
3215+
-yscrollcommand {.vpane.files.workdir.sy set} \
3216+
-state disabled
3217+
${NS}::scrollbar .vpane.files.workdir.sx -orient h -command [list $ui_workdir xview]
3218+
${NS}::scrollbar .vpane.files.workdir.sy -orient v -command [list $ui_workdir yview]
3219+
pack .vpane.files.workdir.title -side top -fill x
3220+
pack .vpane.files.workdir.sx -side bottom -fill x
3221+
pack .vpane.files.workdir.sy -side right -fill y
3222+
pack $ui_workdir -side left -fill both -expand 1
3223+
31873224
# -- Index File List
31883225
#
3189-
${NS}::frame .vpane.files.index -height 100 -width 200
3226+
textframe .vpane.files.index -height 100 -width 200
31903227
tlabel .vpane.files.index.title \
31913228
-text [mc "Staged Changes (Will Commit)"] \
31923229
-background lightgreen -foreground black
3193-
text $ui_index -background white -foreground black \
3230+
ttext $ui_index -background white -foreground black \
31943231
-borderwidth 0 \
31953232
-width 20 -height 10 \
31963233
-wrap none \
3234+
-takefocus 1 -highlightthickness 1\
31973235
-cursor $cursor_ptr \
31983236
-xscrollcommand {.vpane.files.index.sx set} \
31993237
-yscrollcommand {.vpane.files.index.sy set} \
@@ -3205,26 +3243,8 @@ pack .vpane.files.index.sx -side bottom -fill x
32053243
pack .vpane.files.index.sy -side right -fill y
32063244
pack $ui_index -side left -fill both -expand 1
32073245
3208-
# -- Working Directory File List
3246+
# -- Insert the workdir and index into the panes
32093247
#
3210-
${NS}::frame .vpane.files.workdir -height 100 -width 200
3211-
tlabel .vpane.files.workdir.title -text [mc "Unstaged Changes"] \
3212-
-background lightsalmon -foreground black
3213-
text $ui_workdir -background white -foreground black \
3214-
-borderwidth 0 \
3215-
-width 20 -height 10 \
3216-
-wrap none \
3217-
-cursor $cursor_ptr \
3218-
-xscrollcommand {.vpane.files.workdir.sx set} \
3219-
-yscrollcommand {.vpane.files.workdir.sy set} \
3220-
-state disabled
3221-
${NS}::scrollbar .vpane.files.workdir.sx -orient h -command [list $ui_workdir xview]
3222-
${NS}::scrollbar .vpane.files.workdir.sy -orient v -command [list $ui_workdir yview]
3223-
pack .vpane.files.workdir.title -side top -fill x
3224-
pack .vpane.files.workdir.sx -side bottom -fill x
3225-
pack .vpane.files.workdir.sy -side right -fill y
3226-
pack $ui_workdir -side left -fill both -expand 1
3227-
32283248
.vpane.files add .vpane.files.workdir
32293249
.vpane.files add .vpane.files.index
32303250
if {!$use_ttk} {
@@ -3307,7 +3327,7 @@ if {![is_enabled nocommit]} {
33073327
#
33083328
${NS}::frame .vpane.lower.commarea.buffer
33093329
${NS}::frame .vpane.lower.commarea.buffer.header
3310-
set ui_comm .vpane.lower.commarea.buffer.t
3330+
set ui_comm .vpane.lower.commarea.buffer.frame.t
33113331
set ui_coml .vpane.lower.commarea.buffer.header.l
33123332
33133333
if {![is_enabled nocommit]} {
@@ -3350,20 +3370,25 @@ if {![is_enabled nocommit]} {
33503370
pack .vpane.lower.commarea.buffer.header.new -side right
33513371
}
33523372
3353-
text $ui_comm -background white -foreground black \
3373+
textframe .vpane.lower.commarea.buffer.frame
3374+
ttext $ui_comm -background white -foreground black \
33543375
-borderwidth 1 \
33553376
-undo true \
33563377
-maxundo 20 \
33573378
-autoseparators true \
3379+
-takefocus 1 \
3380+
-highlightthickness 1 \
33583381
-relief sunken \
33593382
-width $repo_config(gui.commitmsgwidth) -height 9 -wrap none \
33603383
-font font_diff \
3361-
-yscrollcommand {.vpane.lower.commarea.buffer.sby set}
3362-
${NS}::scrollbar .vpane.lower.commarea.buffer.sby \
3384+
-yscrollcommand {.vpane.lower.commarea.buffer.frame.sby set}
3385+
${NS}::scrollbar .vpane.lower.commarea.buffer.frame.sby \
33633386
-command [list $ui_comm yview]
3364-
pack .vpane.lower.commarea.buffer.header -side top -fill x
3365-
pack .vpane.lower.commarea.buffer.sby -side right -fill y
3387+
3388+
pack .vpane.lower.commarea.buffer.frame.sby -side right -fill y
33663389
pack $ui_comm -side left -fill y
3390+
pack .vpane.lower.commarea.buffer.header -side top -fill x
3391+
pack .vpane.lower.commarea.buffer.frame -side left -fill y
33673392
pack .vpane.lower.commarea.buffer -side left -fill y
33683393
33693394
# -- Commit Message Buffer Context Menu
@@ -3461,12 +3486,13 @@ bind_button3 .vpane.lower.diff.header.path "tk_popup $ctxm %X %Y"
34613486
34623487
# -- Diff Body
34633488
#
3464-
${NS}::frame .vpane.lower.diff.body
3489+
textframe .vpane.lower.diff.body
34653490
set ui_diff .vpane.lower.diff.body.t
3466-
text $ui_diff -background white -foreground black \
3491+
ttext $ui_diff -background white -foreground black \
34673492
-borderwidth 0 \
34683493
-width 80 -height 5 -wrap none \
34693494
-font font_diff \
3495+
-takefocus 1 -highlightthickness 1 \
34703496
-xscrollcommand {.vpane.lower.diff.body.sbx set} \
34713497
-yscrollcommand {.vpane.lower.diff.body.sby set} \
34723498
-state disabled
@@ -3821,10 +3847,10 @@ bind . <$M1B-Key-r> ui_do_rescan
38213847
bind . <$M1B-Key-R> ui_do_rescan
38223848
bind . <$M1B-Key-s> do_signoff
38233849
bind . <$M1B-Key-S> do_signoff
3824-
bind . <$M1B-Key-t> do_add_selection
3825-
bind . <$M1B-Key-T> do_add_selection
3826-
bind . <$M1B-Key-u> do_unstage_selection
3827-
bind . <$M1B-Key-U> do_unstage_selection
3850+
bind . <$M1B-Key-t> { toggle_or_diff toggle %W }
3851+
bind . <$M1B-Key-T> { toggle_or_diff toggle %W }
3852+
bind . <$M1B-Key-u> { toggle_or_diff toggle %W }
3853+
bind . <$M1B-Key-U> { toggle_or_diff toggle %W }
38283854
bind . <$M1B-Key-j> do_revert_selection
38293855
bind . <$M1B-Key-J> do_revert_selection
38303856
bind . <$M1B-Key-i> do_add_all
@@ -3836,9 +3862,11 @@ bind . <$M1B-Key-plus> {show_more_context;break}
38363862
bind . <$M1B-Key-KP_Add> {show_more_context;break}
38373863
bind . <$M1B-Key-Return> do_commit
38383864
foreach i [list $ui_index $ui_workdir] {
3839-
bind $i <Button-1> "toggle_or_diff $i %x %y; break"
3840-
bind $i <$M1B-Button-1> "add_one_to_selection $i %x %y; break"
3841-
bind $i <Shift-Button-1> "add_range_to_selection $i %x %y; break"
3865+
bind $i <Button-1> { toggle_or_diff click %W %x %y; break }
3866+
bind $i <$M1B-Button-1> { add_one_to_selection %W %x %y; break }
3867+
bind $i <Shift-Button-1> { add_range_to_selection %W %x %y; break }
3868+
bind $i <Key-Up> { toggle_or_diff up %W; break }
3869+
bind $i <Key-Down> { toggle_or_diff down %W; break }
38423870
}
38433871
unset i
38443872

lib/themed.tcl

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,57 @@ proc InitTheme {} {
7878
}
7979
}
8080

81+
# Define a style used for the surround of text widgets.
82+
proc InitEntryFrame {} {
83+
ttk::style theme settings default {
84+
ttk::style layout EntryFrame {
85+
EntryFrame.field -sticky nswe -border 0 -children {
86+
EntryFrame.fill -sticky nswe -children {
87+
EntryFrame.padding -sticky nswe
88+
}
89+
}
90+
}
91+
ttk::style configure EntryFrame -padding 1 -relief sunken
92+
ttk::style map EntryFrame -background {}
93+
}
94+
ttk::style theme settings classic {
95+
ttk::style configure EntryFrame -padding 2 -relief sunken
96+
ttk::style map EntryFrame -background {}
97+
}
98+
ttk::style theme settings alt {
99+
ttk::style configure EntryFrame -padding 2
100+
ttk::style map EntryFrame -background {}
101+
}
102+
ttk::style theme settings clam {
103+
ttk::style configure EntryFrame -padding 2
104+
ttk::style map EntryFrame -background {}
105+
}
106+
107+
# Ignore errors for missing native themes
108+
catch {
109+
ttk::style theme settings winnative {
110+
ttk::style configure EntryFrame -padding 2
111+
}
112+
ttk::style theme settings xpnative {
113+
ttk::style configure EntryFrame -padding 1
114+
ttk::style element create EntryFrame.field vsapi \
115+
EDIT 1 {disabled 4 focus 3 active 2 {} 1} -padding 1
116+
}
117+
ttk::style theme settings vista {
118+
ttk::style configure EntryFrame -padding 2
119+
ttk::style element create EntryFrame.field vsapi \
120+
EDIT 6 {disabled 4 focus 3 active 2 {} 1} -padding 2
121+
}
122+
}
123+
124+
bind EntryFrame <Enter> {%W instate !disabled {%W state active}}
125+
bind EntryFrame <Leave> {%W state !active}
126+
bind EntryFrame <<ThemeChanged>> {
127+
set pad [ttk::style lookup EntryFrame -padding]
128+
%W configure -padding [expr {$pad eq {} ? 1 : $pad}]
129+
}
130+
}
131+
81132
proc gold_frame {w args} {
82133
global use_ttk
83134
if {$use_ttk} {
@@ -123,7 +174,7 @@ proc paddedlabel {w args} {
123174
# place a themed frame over the surface.
124175
proc Dialog {w args} {
125176
eval [linsert $args 0 toplevel $w -class Dialog]
126-
catch {wm attributes $w -type dialog}
177+
catch {wm attributes $w -type dialog}
127178
pave_toplevel $w
128179
return $w
129180
}
@@ -193,6 +244,40 @@ proc tspinbox {w args} {
193244
}
194245
}
195246

247+
# Create a text widget with any theme specific properties.
248+
proc ttext {w args} {
249+
global use_ttk
250+
if {$use_ttk} {
251+
switch -- [ttk::style theme use] {
252+
"vista" - "xpnative" {
253+
lappend args -highlightthickness 0 -borderwidth 0
254+
}
255+
}
256+
}
257+
set w [eval [linsert $args 0 text $w]]
258+
if {$use_ttk} {
259+
if {[winfo class [winfo parent $w]] eq "EntryFrame"} {
260+
bind $w <FocusIn> {[winfo parent %W] state focus}
261+
bind $w <FocusOut> {[winfo parent %W] state !focus}
262+
}
263+
}
264+
return $w
265+
}
266+
267+
# themed frame suitable for surrounding a text field.
268+
proc textframe {w args} {
269+
global use_ttk
270+
if {$use_ttk} {
271+
if {[catch {ttk::style layout EntryFrame}]} {
272+
InitEntryFrame
273+
}
274+
eval [linsert $args 0 ttk::frame $w -class EntryFrame -style EntryFrame]
275+
} else {
276+
eval [linsert $args 0 frame $w]
277+
}
278+
return $w
279+
}
280+
196281
proc tentry {w args} {
197282
global use_ttk
198283
if {$use_ttk} {

0 commit comments

Comments
 (0)