Skip to content

Commit 3cb8921

Browse files
committed
Merge branch 'master' of git://ozlabs.org/~paulus/gitk
* 'master' of git://ozlabs.org/~paulus/gitk: gitk: Do not mistake unchanged lines for submodule changes gitk: Use right colour for remote refs in the "Tags and heads" dialog gitk: Add Chinese (zh_CN) translation gitk: Make web links clickable
2 parents f1d4a28 + 9ea831a commit 3cb8921

File tree

2 files changed

+1427
-4
lines changed

2 files changed

+1427
-4
lines changed

gitk-git/gitk

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3404,6 +3404,8 @@ set rectmask {
34043404
}
34053405
image create bitmap reficon-H -background black -foreground "#00ff00" \
34063406
-data $rectdata -maskdata $rectmask
3407+
image create bitmap reficon-R -background black -foreground "#ffddaa" \
3408+
-data $rectdata -maskdata $rectmask
34073409
image create bitmap reficon-o -background black -foreground "#ddddff" \
34083410
-data $rectdata -maskdata $rectmask
34093411

@@ -7016,6 +7018,7 @@ proc commit_descriptor {p} {
70167018

70177019
# append some text to the ctext widget, and make any SHA1 ID
70187020
# that we know about be a clickable link.
7021+
# Also look for URLs of the form "http[s]://..." and make them web links.
70197022
proc appendwithlinks {text tags} {
70207023
global ctext linknum curview
70217024

@@ -7032,6 +7035,18 @@ proc appendwithlinks {text tags} {
70327035
setlink $linkid link$linknum
70337036
incr linknum
70347037
}
7038+
set wlinks [regexp -indices -all -inline -line \
7039+
{https?://[^[:space:]]+} $text]
7040+
foreach l $wlinks {
7041+
set s2 [lindex $l 0]
7042+
set e2 [lindex $l 1]
7043+
set url [string range $text $s2 $e2]
7044+
incr e2
7045+
$ctext tag delete link$linknum
7046+
$ctext tag add link$linknum "$start + $s2 c" "$start + $e2 c"
7047+
setwlink $url link$linknum
7048+
incr linknum
7049+
}
70357050
}
70367051

70377052
proc setlink {id lk} {
@@ -7064,6 +7079,18 @@ proc setlink {id lk} {
70647079
}
70657080
}
70667081

7082+
proc setwlink {url lk} {
7083+
global ctext
7084+
global linkfgcolor
7085+
global web_browser
7086+
7087+
if {$web_browser eq {}} return
7088+
$ctext tag conf $lk -foreground $linkfgcolor -underline 1
7089+
$ctext tag bind $lk <1> [list browseweb $url]
7090+
$ctext tag bind $lk <Enter> {linkcursor %W 1}
7091+
$ctext tag bind $lk <Leave> {linkcursor %W -1}
7092+
}
7093+
70677094
proc appendshortlink {id {pre {}} {post {}}} {
70687095
global ctext linknum
70697096

@@ -7098,6 +7125,16 @@ proc linkcursor {w inc} {
70987125
}
70997126
}
71007127

7128+
proc browseweb {url} {
7129+
global web_browser
7130+
7131+
if {$web_browser eq {}} return
7132+
# Use eval here in case $web_browser is a command plus some arguments
7133+
if {[catch {eval exec $web_browser [list $url] &} err]} {
7134+
error_popup "[mc "Error starting web browser:"] $err"
7135+
}
7136+
}
7137+
71017138
proc viewnextline {dir} {
71027139
global canv linespc
71037140

@@ -8191,11 +8228,11 @@ proc parseblobdiffline {ids line} {
81918228
} else {
81928229
$ctext insert end "$line\n" filesep
81938230
}
8194-
} elseif {![string compare -length 3 " >" $line]} {
8231+
} elseif {$currdiffsubmod != "" && ![string compare -length 3 " >" $line]} {
81958232
set $currdiffsubmod ""
81968233
set line [encoding convertfrom $diffencoding $line]
81978234
$ctext insert end "$line\n" dresult
8198-
} elseif {![string compare -length 3 " <" $line]} {
8235+
} elseif {$currdiffsubmod != "" && ![string compare -length 3 " <" $line]} {
81998236
set $currdiffsubmod ""
82008237
set line [encoding convertfrom $diffencoding $line]
82018238
$ctext insert end "$line\n" d0
@@ -10022,6 +10059,7 @@ proc sel_reflist {w x y} {
1002210059
set n [lindex $ref 0]
1002310060
switch -- [lindex $ref 1] {
1002410061
"H" {selbyid $headids($n)}
10062+
"R" {selbyid $headids($n)}
1002510063
"T" {selbyid $tagids($n)}
1002610064
"o" {selbyid $otherrefids($n)}
1002710065
}
@@ -10051,7 +10089,11 @@ proc refill_reflist {} {
1005110089
foreach n [array names headids] {
1005210090
if {[string match $reflistfilter $n]} {
1005310091
if {[commitinview $headids($n) $curview]} {
10054-
lappend refs [list $n H]
10092+
if {[string match "remotes/*" $n]} {
10093+
lappend refs [list $n R]
10094+
} else {
10095+
lappend refs [list $n H]
10096+
}
1005510097
} else {
1005610098
interestedin $headids($n) {run refill_reflist}
1005710099
}
@@ -11488,7 +11530,7 @@ proc create_prefs_page {w} {
1148811530
proc prefspage_general {notebook} {
1148911531
global NS maxwidth maxgraphpct showneartags showlocalchanges
1149011532
global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
11491-
global hideremotes want_ttk have_ttk maxrefs
11533+
global hideremotes want_ttk have_ttk maxrefs web_browser
1149211534

1149311535
set page [create_prefs_page $notebook.general]
1149411536

@@ -11539,6 +11581,13 @@ proc prefspage_general {notebook} {
1153911581
pack configure $page.extdifff.l -padx 10
1154011582
grid x $page.extdifff $page.extdifft -sticky ew
1154111583

11584+
${NS}::entry $page.webbrowser -textvariable web_browser
11585+
${NS}::frame $page.webbrowserf
11586+
${NS}::label $page.webbrowserf.l -text [mc "Web browser" ]
11587+
pack $page.webbrowserf.l -side left
11588+
pack configure $page.webbrowserf.l -padx 10
11589+
grid x $page.webbrowserf $page.webbrowser -sticky ew
11590+
1154211591
${NS}::label $page.lgen -text [mc "General options"]
1154311592
grid $page.lgen - -sticky w -pady 10
1154411593
${NS}::checkbutton $page.want_ttk -variable want_ttk \
@@ -12310,13 +12359,19 @@ if {[tk windowingsystem] eq "win32"} {
1231012359
set bgcolor SystemWindow
1231112360
set fgcolor SystemWindowText
1231212361
set selectbgcolor SystemHighlight
12362+
set web_browser "cmd /c start"
1231312363
} else {
1231412364
set uicolor grey85
1231512365
set uifgcolor black
1231612366
set uifgdisabledcolor "#999"
1231712367
set bgcolor white
1231812368
set fgcolor black
1231912369
set selectbgcolor gray85
12370+
if {[tk windowingsystem] eq "aqua"} {
12371+
set web_browser "open"
12372+
} else {
12373+
set web_browser "xdg-open"
12374+
}
1232012375
}
1232112376
set diffcolors {red "#00a000" blue}
1232212377
set diffcontext 3
@@ -12390,6 +12445,7 @@ set config_variables {
1239012445
filesepbgcolor filesepfgcolor linehoverbgcolor linehoverfgcolor
1239112446
linehoveroutlinecolor mainheadcirclecolor workingfilescirclecolor
1239212447
indexcirclecolor circlecolors linkfgcolor circleoutlinecolor
12448+
web_browser
1239312449
}
1239412450
foreach var $config_variables {
1239512451
config_init_trace $var

0 commit comments

Comments
 (0)