Skip to contentSkip to conversation

Display line numbers in gitk?

DISCUSSION Sebastian Schuberth 1 participant 2 messages Jun 15, 2016 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hi,

is there currently a way to display line numbers next to each line in the diff shown by gitk, e.g. in some kind of gutter?

If that's currently not possible, how much work would it require to add that feature as an option?

Signature · 1 line
Sebastian Schuberth

A message that is not in the archive (sent off-list or not yet received): CABNJ2GLaquXK7o_V_6KmOtnbcCGXMgbupbVJzXU_yK=2a=wKSg@mail.gmail.com

#2 lore raw

On Tue, Oct 11, 2011 at 16:00, Pat Thoyts <[email protected]> wrote:

(putting the list back on CC)

Quoted 3 lines

Not currently possible. It can be done though. Is this just for the file view or patch view as well?
The following seems to work reasonably well for just the file view.

Thanks, from my tests it seems to work indeed very well. Although I was initially thinking about the patch view.

A downside of line numbers in the file view could be that they'll be copied to the clipboard, too, if you copy and paste code from there, so they should probably be implemented as an option.

Quoted 37 lines

From 0e18a9a2789838925f2ed50b05ce9d7e6c3a9a38 Mon Sep 17 00:00:00 2001
From: Pat Thoyts <[email protected]>
Date: Tue, 11 Oct 2011 14:57:24 +0100
Subject: [PATCH] gitk: display line numbers for file view

---
 gitk |    5 ++++-

 1 files changed, 4 insertions(+), 1 deletions(-)
gitk +0 -0
index 4cde0c4..70d8f57 100755
@@ -2277,6 +2277,9 @@ proc makewindow {} {
     if {$have_tk85} {

       $ctext conf -tabstyle wordprocessor
    }
+    catch {eval font create linenofont [font configure textfont] \
+              -size [expr {[font configure textfont -size] - 2}]}
+    $ctext tag configure lineno -foreground #808080 -font linenofont ${NS}::scrollbar .bleft.bottom.sb -command "$ctext yview" ${NS}::scrollbar .bleft.bottom.sbhorizontal -command "$ctext xview" -orient h
    pack .bleft.top -side top -fill x

gitk +0 -0
@@ -7316,7 +7319,7 @@ proc getblobline {bf id} {

    $ctext config -state normal
    set nl 0
    while {[incr nl] <= 1000 && [gets $bf line] >= 0} {
-       $ctext insert end "$line\n"
+       $ctext insert end $nl lineno "\t" {} "$line\n" }
    if {[eof $bf]} {
       global jump_to_here ctext_file_names commentend --
1.7.7.1.gbba15