[PATCH v2] gitk: new config options for wrapping and diff modes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Using gitk for tracking changes in large text files,
which often have very long lines consisting of, e.g.,
a paragarph of an article, it is highly desirable to
wrap the lines in the diff view and also to set the
default diff mode to "Markup words" or "Color lines".

There is a configurable option "wrapcomment" to make the
comments wrap in gitk, and now an additional "wraplines"
option is introduced for warpping lines in the source files.
Similarly, an option "worddiffdefault" is introduced which
sets the default diff view mode to "Markup words" or
"Color lines". These options can be set by editing gitk's
configuration file. The default behaviours are unchanged.

The new options are documented in Documentation/gitk.txt,
where the formerly undocumented feature "wrapcomment"
also got explained, which was introduced by Commit f1b8629453
([PATCH] gitk: Display commit messages with word wrap, 2006-05-15).

Suggested-by: Ailin Nemui <ailin.nemui@xxxxxxxxx>
(https://www.spinics.net/lists/git/msg274761.html )
Signed-off-by: András P Gilyén <gilyen@xxxxxxxx>
---
I fixed a typo in the documentation and made some cosmetic
edits to the patch in order to improve its readability.

 Documentation/gitk.txt | 26 ++++++++++++++++++++++++--
 gitk-git/gitk          | 18 +++++++++++++-----
 2 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/Documentation/gitk.txt b/Documentation/gitk.txt
index 35b3996029..82ff7e5370 100644
--- a/Documentation/gitk.txt
+++ b/Documentation/gitk.txt
@@ -161,10 +161,32 @@ If neither of the above exist then `$XDG_CONFIG_HOME/git/gitk` is created and
 used by default. If '$XDG_CONFIG_HOME' is not set it defaults to
 `$HOME/.config` in all cases.

+The following are some options that are configurable by updating the contents
+of the above configuration file. To set an option to a specific value add a
+line containing "set <option> <value>".
+
+wrapcomment::
+
+	Describes whether the comment section of a commit should be displayed
+	with (word) wrapded lines or without any wrapping of the lines.
+	Vaild options are none (default setting) and word.
+
+wraplines::
+
+	Describes whether the source section in the gitk viewer should be
+	displayed with (word) wrapded lines or should be scrollaple with
+	unwrapped lines. Vaild options are none (default setting) and word.
+
+worddiffdefault::
+
+	Sets the default diff view mode for gitk. Valid options are:
+	line -- for "Line diff" (default setting)
+	markup -- for "Markup words"
+	color -- for "Color words"
+
 History
 -------
-Gitk was the first graphical repository browser. It's written in
-tcl/tk.
+Gitk was the first graphical repository browser. It's written in tcl/tk.

 'gitk' is actually maintained as an independent project, but stable
 versions are distributed as part of the Git suite for the convenience
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 7a087f123d..4bcb989bb7 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -2089,7 +2089,7 @@ proc makewindow {} {
     global diffcontextstring diffcontext
     global ignorespace
     global maincursor textcursor curtextcursor
-    global rowctxmenu fakerowmenu mergemax wrapcomment
+    global rowctxmenu fakerowmenu mergemax wrapcomment wraplines
     global highlight_files gdttype
     global searchstring sstring
     global bgcolor fgcolor bglist fglist diffcolors diffbgcolors selectbgcolor
@@ -2101,7 +2101,7 @@ proc makewindow {} {
     global rprogitem rprogcoord rownumsel numcommits
     global have_tk85 use_ttk NS
     global git_version
-    global worddiff
+    global worddiff worddiffdefault

     # The "mc" arguments here are purely so that xgettext
     # sees the following string as needing to be translated
@@ -2420,7 +2420,13 @@ proc makewindow {} {
         -command changeignorespace -variable ignorespace
     pack .bleft.mid.ignspace -side left -padx 5

-    set worddiff [mc "Line diff"]
+    if {$worddiffdefault == "color" && [package vcompare $git_version "1.7.2"] >= 0} {
+        set worddiff [mc "Color words"]
+    } elseif {$worddiffdefault == "markup" && [package vcompare $git_version "1.7.2"] >= 0} {
+        set worddiff [mc "Markup words"]
+    } else {
+        set worddiff [mc "Line diff"]
+    }
     if {[package vcompare $git_version "1.7.2"] >= 0} {
         makedroplist .bleft.mid.worddiff worddiff [mc "Line diff"] \
             [mc "Markup words"] [mc "Color words"]
@@ -2431,7 +2437,7 @@ proc makewindow {} {
     set ctext .bleft.bottom.ctext
     text $ctext -background $bgcolor -foreground $fgcolor \
         -state disabled -undo 0 -font textfont \
-        -yscrollcommand scrolltext -wrap none \
+        -yscrollcommand scrolltext -wrap $wraplines \
         -xscrollcommand ".bleft.bottom.sbhorizontal set"
     if {$have_tk85} {
         $ctext conf -tabstyle wordprocessor
@@ -12392,6 +12398,7 @@ set downarrowlen 5
 set mingaplen 100
 set cmitmode "patch"
 set wrapcomment "none"
+set wraplines "none"
 set showneartags 1
 set hideremotes 0
 set maxrefs 20
@@ -12438,6 +12445,7 @@ set diffbgcolors {"#fff3f3" "#f0fff0"}
 set diffcontext 3
 set mergecolors {red blue "#00ff00" purple brown "#009090" magenta "#808000" "#009000" "#ff0080" cyan "#b07070" "#70b0f0" "#70f0b0" "#f0b070" "#ff70b0"}
 set ignorespace 0
+set worddiffdefault "line"
 set worddiff ""
 set markbgcolor "#e0e0ff"

@@ -12506,7 +12514,7 @@ set config_variables {
     filesepbgcolor filesepfgcolor linehoverbgcolor linehoverfgcolor
     linehoveroutlinecolor mainheadcirclecolor workingfilescirclecolor
     indexcirclecolor circlecolors linkfgcolor circleoutlinecolor diffbgcolors
-    web_browser
+    web_browser wraplines worddiffdefault
 }
 foreach var $config_variables {
     config_init_trace $var
--
2.34.1





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux