{"thread":{"id":"29609","subject":"[PATCH] git-gui: add configurable tab size to the diff view","startedAt":"2012-02-12T15:55:17Z","lastAt":"2012-03-02T12:36:26Z","messageCount":2,"participants":["Michael Lutz"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"184516","messageId":"1329062117-8076-1-git-send-email-michi@icosahedron.de","threadId":"29609","inReplyTo":null,"subject":"[PATCH] git-gui: add configurable tab size to the diff view","fromName":"Michael Lutz","fromEmail":"michi@icosahedron.de","sentAt":"2012-02-12T15:55:17Z","receivedAt":"2012-02-12T15:55:17Z","isPatch":true,"sender":{"key":"michi@icosahedron.de","avatar":"https://avatars.githubusercontent.com/u/1447653?v=4"},"body":"For Tk 8.5 the \"wordprocessor\" mode allows us to get a bit fancy for merge\ndiffs and intend the tabs by one to compensate for the additional diff\nmarker at the line start.\n\nThe code is heavily based on how gitk handles tabs.\n\nSigned-off-by: Michael Lutz <michi@icosahedron.de>\n---\n git-gui.sh     |    1 +\n lib/diff.tcl   |   20 +++++++++++++++++++-\n lib/option.tcl |    1 +\n 3 files changed, 21 insertions(+), 1 deletions(-)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex ba4e5c1..22d7665 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -892,6 +892,7 @@ set default_config(gui.fontdiff) [font configure font_diff]\n set default_config(gui.maxfilesdisplayed) 5000\n set default_config(gui.usettk) 1\n set default_config(gui.warndetachedcommit) 1\n+set default_config(gui.tabsize) 8\n set font_descs {\n \t{fontui   font_ui   {mc \"Main Font\"}}\n \t{fontdiff font_diff {mc \"Diff/Console Font\"}}\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex ec44055..f314197 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -1,6 +1,19 @@\n # git-gui diff viewer\n # Copyright (C) 2006, 2007 Shawn Pearce\n \n+proc apply_tab_size {{firsttab {}}} {\n+\tglobal have_tk85 repo_config ui_diff\n+\n+\tset w [font measure font_diff \"0\"]\n+\tif {$have_tk85 && $firsttab != 0} {\n+\t\t$ui_diff configure -tabs [list [expr {$firsttab * $w}] [expr {($firsttab + $repo_config(gui.tabsize)) * $w}]]\n+\t} elseif {$have_tk85 || $repo_config(gui.tabsize) != 8} {\n+\t\t$ui_diff configure -tabs [expr {$repo_config(gui.tabsize) * $w}]\n+\t} else {\n+\t\t$ui_diff configure -tabs {}\n+\t}\n+}\n+\n proc clear_diff {} {\n \tglobal ui_diff current_diff_path current_diff_header\n \tglobal ui_index ui_workdir\n@@ -105,6 +118,8 @@ proc show_diff {path w {lno {}} {scroll_pos {}} {callback {}}} {\n \n \tset cont_info [list $scroll_pos $callback]\n \n+\tapply_tab_size 0\n+\n \tif {[string first {U} $m] >= 0} {\n \t\tmerge_load_stages $path [list show_unmerged_diff $cont_info]\n \t} elseif {$m eq {_O}} {\n@@ -398,7 +413,10 @@ proc read_diff {fd conflict_size cont_info} {\n \n \t\t# -- Automatically detect if this is a 3 way diff.\n \t\t#\n-\t\tif {[string match {@@@ *} $line]} {set is_3way_diff 1}\n+\t\tif {[string match {@@@ *} $line]} {\n+\t\t\tset is_3way_diff 1\n+\t\t\tapply_tab_size 1\n+\t\t}\n \n \t\tif {$::current_diff_inheader} {\n \ndiff --git a/lib/option.tcl b/lib/option.tcl\nindex 0cf1da1..b940c44 100644\n--- a/lib/option.tcl\n+++ b/lib/option.tcl\n@@ -159,6 +159,7 @@ proc do_options {} {\n \t\t{c gui.encoding {mc \"Default File Contents Encoding\"}}\n \t\t{b gui.warndetachedcommit {mc \"Warn before committing to a detached head\"}}\n \t\t{s gui.stageuntracked {mc \"Staging of untracked files\"} {list \"yes\" \"no\" \"ask\"}}\n+\t\t{i-1..99 gui.tabsize {mc \"Tab spacing\"}}\n \t\t} {\n \t\tset type [lindex $option 0]\n \t\tset name [lindex $option 1]\n-- \n1.7.5.1\n"},{"id":"185913","messageId":"4F50BECA.2020300@icosahedron.de","threadId":"29609","inReplyTo":"1329062117-8076-1-git-send-email-michi@icosahedron.de","subject":"Re: [PATCH] git-gui: add configurable tab size to the diff view","fromName":"Michael Lutz","fromEmail":"michi@icosahedron.de","sentAt":"2012-03-02T12:36:26Z","receivedAt":"2012-03-02T12:36:26Z","isPatch":true,"sender":{"key":"michi@icosahedron.de","avatar":"https://avatars.githubusercontent.com/u/1447653?v=4"},"body":"Am 12.02.2012 16:55 schrieb Michael Lutz:\n> [patch omitted]\n\nPing?\n\nIs somebody else maintaining git-gui now?\n\n\n-- Michael Lutz\n"}]}