@matheusbsbs / matheus-bagliano / commits / c11b5f20d3
Fork 0

git-gui: Allow the user to copy name of the file in the diff viewer.

There's a lot of reasons why the user might need to obtain the complete (or just part of) path of a file which they are currently viewing in the diff viewer pane. So now we allow selection on this widget by using a text widget instead of a label. We also offer a context menu which has actions for copying the selection or the entire value onto the clipboard. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Nov 12, 2006 at 21:11 UTC c11b5f20d3bc2e8bc4fcd965b16e1575b87c0d5f
1 file changed +26 -4
git-gui
+26 -4
@@ -511,7 +511,7 @@ proc show_diff {path {w {}} {lno {}}} {
511 set m [lindex $s 0]
512 set diff_3way 0
513 set diff_active 1
514 - set ui_fname_value [escape_path $path]
514 + set ui_fname_value $path
515 set ui_fstatus_value [mapdesc $m $path]
516 set ui_status_value "Loading diff of [escape_path $path]..."
517
@@ -2284,11 +2284,33 @@ frame .vpane.lower.diff.header -background orange
2284 label .vpane.lower.diff.header.l1 -text {File:} \
2285 -background orange \
2286 -font font_ui
2287 -label .vpane.lower.diff.header.l2 -textvariable ui_fname_value \
2287 +set ui_fname .vpane.lower.diff.header.l2
2288 +text $ui_fname \
2289 -background orange \
2289 - -anchor w \
2290 - -justify left \
2290 + -height 1 \
2291 + -relief flat \
2292 + -state disabled \
2293 -font font_ui
2294 +menu $ui_fname.ctxm -tearoff 0
2295 +$ui_fname.ctxm add command -label "Copy Only Selection" \
2296 + -font font_ui \
2297 + -command "tk_textCopy $ui_fname"
2298 +$ui_fname.ctxm add command -label "Copy Complete Name" \
2299 + -font font_ui \
2300 + -command "
2301 + $ui_fname tag add sel 0.0 {end -1c}
2302 + tk_textCopy $ui_fname
2303 + $ui_fname tag remove sel 0.0 end
2304 + "
2305 +bind_button3 $ui_fname "tk_popup $ui_fname.ctxm %X %Y"
2306 +trace add variable ui_fname_value write $ui_fname.update
2307 +proc $ui_fname.update {varname args} {
2308 + global ui_fname ui_fname_value
2309 + $ui_fname configure -state normal
2310 + $ui_fname delete 0.0 end
2311 + $ui_fname insert end [escape_path $ui_fname_value]
2312 + $ui_fname configure -state disabled
2313 +}
2314 label .vpane.lower.diff.header.l3 -text {Status:} \
2315 -background orange \
2316 -font font_ui