@matheusbsbs / matheus-bagliano / commits / 9861671de2
Fork 0

git-gui: Created edit menu and basic editing bindings.

Users have come to expect basic editing features within their applications, such as cut/copy/paste/undo/redo/select-all. I found these features to be lacking in git-gui so now we have them. I also added basic keyboard bindings for the diff viewing area so that the arrow keys move around single units (lines or columns) and the M1-X/C keys will copy the selected text and the M1-A key will select the entire diff. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Nov 11, 2006 at 15:51 UTC 9861671de26bf7cd41f591bd2099ac299349f284
1 file changed +60 -1
git-gui
+60 -1
@@ -1525,6 +1525,7 @@ default {set M1B M1; set M1T M1}
1525 # -- Menu Bar
1526 menu .mbar -tearoff 0
1527 .mbar add cascade -label Project -menu .mbar.project
1528 +.mbar add cascade -label Edit -menu .mbar.edit
1529 .mbar add cascade -label Commit -menu .mbar.commit
1530 .mbar add cascade -label Fetch -menu .mbar.fetch
1531 .mbar add cascade -label Pull -menu .mbar.pull
@@ -1545,6 +1546,40 @@ menu .mbar.project
1546 -accelerator $M1T-Q \
1547 -font $mainfont
1548
1549 +# -- Edit Menu
1550 +#
1551 +menu .mbar.edit
1552 +.mbar.edit add command -label Undo \
1553 + -command {catch {[focus] edit undo}} \
1554 + -accelerator $M1T-Z \
1555 + -font $mainfont
1556 +.mbar.edit add command -label Redo \
1557 + -command {catch {[focus] edit redo}} \
1558 + -accelerator $M1T-Y \
1559 + -font $mainfont
1560 +.mbar.edit add separator
1561 +.mbar.edit add command -label Cut \
1562 + -command {catch {tk_textCut [focus]}} \
1563 + -accelerator $M1T-X \
1564 + -font $mainfont
1565 +.mbar.edit add command -label Copy \
1566 + -command {catch {tk_textCopy [focus]}} \
1567 + -accelerator $M1T-C \
1568 + -font $mainfont
1569 +.mbar.edit add command -label Paste \
1570 + -command {catch {tk_textPaste [focus]; [focus] see insert}} \
1571 + -accelerator $M1T-V \
1572 + -font $mainfont
1573 +.mbar.edit add command -label Delete \
1574 + -command {catch {[focus] delete sel.first sel.last}} \
1575 + -accelerator Del \
1576 + -font $mainfont
1577 +.mbar.edit add separator
1578 +.mbar.edit add command -label {Select All} \
1579 + -command {catch {[focus] tag add sel 0.0 end}} \
1580 + -accelerator $M1T-A \
1581 + -font $mainfont
1582 +
1583 # -- Commit Menu
1584 menu .mbar.commit
1585 .mbar.commit add command -label Rescan \
@@ -1586,7 +1621,8 @@ menu .mbar.push
1621
1622 # -- Options Menu
1623 menu .mbar.options
1589 -.mbar.options add checkbutton -label {Trust File Modification Timestamps} \
1624 +.mbar.options add checkbutton \
1625 + -label {Trust File Modification Timestamps} \
1626 -offvalue false \
1627 -onvalue true \
1628 -variable cfg_trust_mtime
@@ -1696,6 +1732,8 @@ trace add variable commit_type write {uplevel #0 {
1732 * {$ui_coml conf -text {Commit Message:}}
1733 }}
1734 text $ui_comm -background white -borderwidth 1 \
1735 + -undo true \
1736 + -autoseparators true \
1737 -relief sunken \
1738 -width 75 -height 9 -wrap none \
1739 -font $difffont \
@@ -1781,6 +1819,27 @@ eval .vpane.files sash place 0 [lindex $repo_config(gui.geometry) 0 2]
1819 bind $ui_comm <$M1B-Key-Return> {do_commit;break}
1820 bind $ui_comm <$M1B-Key-i> {do_include_all;break}
1821 bind $ui_comm <$M1B-Key-I> {do_include_all;break}
1822 +bind $ui_comm <$M1B-Key-x> {tk_textCut %W;break}
1823 +bind $ui_comm <$M1B-Key-X> {tk_textCut %W;break}
1824 +bind $ui_comm <$M1B-Key-c> {tk_textCopy %W;break}
1825 +bind $ui_comm <$M1B-Key-C> {tk_textCopy %W;break}
1826 +bind $ui_comm <$M1B-Key-v> {tk_textPaste %W; %W see insert; break}
1827 +bind $ui_comm <$M1B-Key-V> {tk_textPaste %W; %W see insert; break}
1828 +bind $ui_comm <$M1B-Key-a> {%W tag add sel 0.0 end;break}
1829 +bind $ui_comm <$M1B-Key-A> {%W tag add sel 0.0 end;break}
1830 +
1831 +bind $ui_diff <$M1B-Key-x> {tk_textCopy %W;break}
1832 +bind $ui_diff <$M1B-Key-X> {tk_textCopy %W;break}
1833 +bind $ui_diff <$M1B-Key-c> {tk_textCopy %W;break}
1834 +bind $ui_diff <$M1B-Key-C> {tk_textCopy %W;break}
1835 +bind $ui_diff <$M1B-Key-v> {break}
1836 +bind $ui_diff <$M1B-Key-V> {break}
1837 +bind $ui_diff <$M1B-Key-a> {%W tag add sel 0.0 end;break}
1838 +bind $ui_diff <$M1B-Key-A> {%W tag add sel 0.0 end;break}
1839 +bind $ui_diff <Key-Up> {%W yview scroll -1 units}
1840 +bind $ui_diff <Key-Down> {%W yview scroll 1 units}
1841 +bind $ui_diff <Key-Left> {%W xview scroll -1 units}
1842 +bind $ui_diff <Key-Right> {%W xview scroll 1 units}
1843
1844 bind . <Destroy> do_quit
1845 bind all <Key-F5> do_rescan