set ui_status_value {Refreshing file status...}
set fd_rf [open "| git update-index -q --unmerged --refresh" r]
fconfigure $fd_rf -blocking 0 -translation binary
- fileevent $fd_rf readable [list update_status_stage2 $fd_rf $final]
+ fileevent $fd_rf readable \
+ [list update_status_stage2 $fd_rf $final]
}
}
set cmd [list | git diff-index -p $PARENT -- $path]
switch $m {
- AM {
- }
MM {
set cmd [list | git diff-index -p -c $PARENT $path]
}
set PARENT $HEAD
set $ui_status_value {Ready.}
} else {
- update_status "Conflicts detected while pulling $branch from $remote."
+ update_status \
+ "Conflicts detected while pulling $branch from $remote."
}
}
$ui_index delete 0.0 end
$ui_other delete 0.0 end
- array unset file_lists
+ set file_lists($ui_index) [list]
+ set file_lists($ui_other) [list]
+
foreach path [lsort [array names file_states]] {
set s $file_states($path)
set m [lindex $s 0]
proc console_init {w} {
global console_cr console_data
- global gitdir appname font_ui font_diff
+ global gitdir appname font_ui font_diff M1B
set console_cr($w) 1.0
toplevel $w
pack $w.m.t -side left -fill both -expand 1
pack $w.m -side top -fill both -expand 1 -padx 5 -pady 10
+ menu $w.ctxm -tearoff 0
+ $w.ctxm add command -label "Copy" \
+ -font $font_ui \
+ -command "tk_textCopy $w.m.t"
+ $w.ctxm add command -label "Select All" \
+ -font $font_ui \
+ -command "$w.m.t tag add sel 0.0 end"
+ $w.ctxm add command -label "Copy All" \
+ -font $font_ui \
+ -command "
+ $w.m.t tag add sel 0.0 end
+ tk_textCopy $w.m.t
+ $w.m.t tag remove sel 0.0 end
+ "
+
button $w.ok -text {Running...} \
-width 15 \
-font $font_ui \
-command "destroy $w"
pack $w.ok -side bottom
+ bind $w.m.t <Any-Button-3> "tk_popup $w.ctxm %X %Y"
+ bind $w.m.t <$M1B-Key-a> "$w.m.t tag add sel 0.0 end;break"
+ bind $w.m.t <$M1B-Key-A> "$w.m.t tag add sel 0.0 end;break"
bind $w <Visibility> "focus $w"
wm title $w "$appname ([lindex [file split \
[file normalize [file dirname $gitdir]]] \
}
}
- set str "Signed-off-by: $GIT_COMMITTER_IDENT"
- if {[$ui_comm get {end -1c linestart} {end -1c}] != $str} {
+ set sob "Signed-off-by: $GIT_COMMITTER_IDENT"
+ set last [$ui_comm get {end -1c linestart} {end -1c}]
+ if {$last != $sob} {
$ui_comm edit separator
- $ui_comm insert end "\n$str"
+ if {$last != {}
+ && ![regexp {^[A-Z][A-Za-z]*-[A-Za-z-]+: *} $last]} {
+ $ui_comm insert end "\n"
+ }
+ $ui_comm insert end "\n$sob"
$ui_comm edit separator
$ui_comm see end
}
set font_ui {Helvetica 10}
set font_diff {Courier 10}
-set maincursor [. cget -cursor]
+set cursor_ptr left_ptr
switch -glob -- "$tcl_platform(platform),$tcl_platform(os)" {
windows,* {set M1B Control; set M1T Ctrl}
unix,Darwin {set M1B M1; set M1T Cmd}
-default {set M1B M1; set M1T M1}
+* {set M1B M1; set M1T M1}
}
# -- Menu Bar
menu .mbar.options
.mbar.options add checkbutton \
-label {Trust File Modification Timestamps} \
+ -font $font_ui \
-offvalue false \
-onvalue true \
-variable cfg_trust_mtime
text $ui_index -background white -borderwidth 0 \
-width 40 -height 10 \
-font $font_ui \
+ -cursor $cursor_ptr \
-yscrollcommand {.vpane.files.index.sb set} \
- -cursor $maincursor \
-state disabled
scrollbar .vpane.files.index.sb -command [list $ui_index yview]
pack .vpane.files.index.title -side top -fill x
text $ui_other -background white -borderwidth 0 \
-width 40 -height 10 \
-font $font_ui \
+ -cursor $cursor_ptr \
-yscrollcommand {.vpane.files.other.sb set} \
- -cursor $maincursor \
-state disabled
scrollbar .vpane.files.other.sb -command [list $ui_other yview]
pack .vpane.files.other.title -side top -fill x
-command do_rescan \
-font $font_ui
pack .vpane.lower.commarea.buttons.rescan -side top -fill x
-lappend disable_on_lock {.vpane.lower.commarea.buttons.rescan conf -state}
+lappend disable_on_lock \
+ {.vpane.lower.commarea.buttons.rescan conf -state}
button .vpane.lower.commarea.buttons.amend -text {Amend Last} \
-command do_amend_last \
-font $font_ui
pack .vpane.lower.commarea.buttons.amend -side top -fill x
-lappend disable_on_lock {.vpane.lower.commarea.buttons.amend conf -state}
+lappend disable_on_lock \
+ {.vpane.lower.commarea.buttons.amend conf -state}
button .vpane.lower.commarea.buttons.incall -text {Include All} \
-command do_include_all \
-font $font_ui
pack .vpane.lower.commarea.buttons.incall -side top -fill x
-lappend disable_on_lock {.vpane.lower.commarea.buttons.incall conf -state}
+lappend disable_on_lock \
+ {.vpane.lower.commarea.buttons.incall conf -state}
button .vpane.lower.commarea.buttons.signoff -text {Sign Off} \
-command do_signoff \
-command do_commit \
-font $font_ui
pack .vpane.lower.commarea.buttons.commit -side top -fill x
-lappend disable_on_lock {.vpane.lower.commarea.buttons.commit conf -state}
+lappend disable_on_lock \
+ {.vpane.lower.commarea.buttons.commit conf -state}
# -- Commit Message Buffer
frame .vpane.lower.commarea.buffer
-relief sunken \
-width 75 -height 9 -wrap none \
-font $font_diff \
- -yscrollcommand {.vpane.lower.commarea.buffer.sby set} \
- -cursor $maincursor
-scrollbar .vpane.lower.commarea.buffer.sby -command [list $ui_comm yview]
+ -yscrollcommand {.vpane.lower.commarea.buffer.sby set}
+scrollbar .vpane.lower.commarea.buffer.sby \
+ -command [list $ui_comm yview]
pack $ui_coml -side top -fill x
pack .vpane.lower.commarea.buffer.sby -side right -fill y
pack $ui_comm -side left -fill y
pack .vpane.lower.commarea.buffer -side left -fill y
+# -- Commit Message Buffer Context Menu
+#
+menu $ui_comm.ctxm -tearoff 0
+$ui_comm.ctxm add command -label "Cut" \
+ -font $font_ui \
+ -command "tk_textCut $ui_comm"
+$ui_comm.ctxm add command -label "Copy" \
+ -font $font_ui \
+ -command "tk_textCopy $ui_comm"
+$ui_comm.ctxm add command -label "Paste" \
+ -font $font_ui \
+ -command "tk_textPaste $ui_comm"
+$ui_comm.ctxm add command -label "Delete" \
+ -font $font_ui \
+ -command "$ui_comm delete sel.first sel.last"
+$ui_comm.ctxm add separator
+$ui_comm.ctxm add command -label "Select All" \
+ -font $font_ui \
+ -command "$ui_comm tag add sel 0.0 end"
+$ui_comm.ctxm add command -label "Copy All" \
+ -font $font_ui \
+ -command "
+ $ui_comm tag add sel 0.0 end
+ tk_textCopy $ui_comm
+ $ui_comm tag remove sel 0.0 end
+ "
+$ui_comm.ctxm add separator
+$ui_comm.ctxm add command -label "Sign Off" \
+ -font $font_ui \
+ -command do_signoff
+bind $ui_comm <Any-Button-3> "tk_popup $ui_comm.ctxm %X %Y"
+
# -- Diff Header
set ui_fname_value {}
set ui_fstatus_value {}
-font $font_diff \
-xscrollcommand {.vpane.lower.diff.body.sbx set} \
-yscrollcommand {.vpane.lower.diff.body.sby set} \
- -cursor $maincursor \
-state disabled
scrollbar .vpane.lower.diff.body.sbx -orient horizontal \
-command [list $ui_diff xview]
$ui_diff tag conf dni -foreground "#a000a0"
$ui_diff tag conf bold -font [concat $font_diff bold]
+# -- Diff Body Context Menu
+#
+menu $ui_diff.ctxm -tearoff 0
+$ui_diff.ctxm add command -label "Copy" \
+ -font $font_ui \
+ -command "tk_textCopy $ui_diff"
+$ui_diff.ctxm add command -label "Select All" \
+ -font $font_ui \
+ -command "$ui_diff tag add sel 0.0 end"
+$ui_diff.ctxm add command -label "Copy All" \
+ -font $font_ui \
+ -command "
+ $ui_diff tag add sel 0.0 end
+ tk_textCopy $ui_diff
+ $ui_diff tag remove sel 0.0 end
+ "
+bind $ui_diff <Any-Button-3> "tk_popup $ui_diff.ctxm %X %Y"
+
# -- Status Bar
set ui_status_value {Initializing...}
label .status -textvariable ui_status_value \
.vpane.files sash place 0 \
[lindex $gm 2] \
[lindex [.vpane.files sash coord 0] 1]
-}
unset gm
+}
# -- Key Bindings
bind $ui_comm <$M1B-Key-Return> {do_commit;break}
bind $i <Button-3> {click %W %x %y 3 %X %Y; break}
bind $i <ButtonRelease-1> {unclick %W %x %y; break}
}
-unset i M1B M1T
+unset i
+
+set file_lists($ui_index) [list]
+set file_lists($ui_other) [list]
wm title . "$appname ([file normalize [file dirname $gitdir]])"
focus -force $ui_comm