Mercurial > hg
view mercurial/templates/static/style-paper.css @ 19387:f2e4fdb3dd27
hgweb: code selection without line numbers in file source view
All the source lines are put in a <pre> tag, which gives correct display and
copy&paste in both Chromium (WebKit) and FireFox: line numbers are not copied,
all the tabs and spaces are kept. This doesn't change the visual appearance
of the view compared to current hgweb version and doesn't use any JS code.
Also, stripes in this view are now generated clientside with CSS.
This implementation is chosen because other variants have important issues:
Strategy FF Chrome
current D,LT,E,T,L D,L
pre S,NW S,NW
pre/div/nbsp LT,E,T,TS,NW TS,NW
pre/div/br LT,E,T,NW NW
ol/li/nbsp LT,E,T,TS,AJ TS,AJ
ol/li/br LT,E,T,AJ AJ
pre/span LV LV
Legend
Strategies:
- current: implemented in hgweb before this patch, i.e. divs for each line,
and line numbers links in the div too
- pre: the whole code in one pre tag with newlines, all line numbers
in another one with 'float: left'
- pre/div/{nbsp,br}: same as just 'pre', but separate divs for each line and
or <br> instead of empty lines (otherwise they are not copied at all)
- ol/li/{nbsp,br}: a single ol with li's and divs for each line,
or <br> same as in previous strategy
- pre/span: this patch
Problems:
D = (very minor) display problems, like wrong width of leading tabs
LT = loses leading/trailing whitespace
E = loses embedded whitespace
B = loses blank lines
T = loses tabs
L = selects line numbers
LV = (only) visually selects line numbers
LVE = (only) visually selects line numbers at empty lines
S = no stripes (and no ability to easily highlight
lines-which-are-linked-at in the future)
TS = space copied instead of empty line
AJ = get anchor links only with JS (they work even without)
NW = no linewrap easily possible (in future)
As for browser versions compatibility, the CSS tricks used are supported in
(according to caniuse.com):
a) line numbers generation with 'content:' property and CSS counters:
IE 8+, all other popular browsers (in pre-WebKit Opera numbers are being copied)
b) stripes ('nth-child' selector):
IE 8+, FF 3.5+, Safari 3.2+, Opera 9.5+, all other popular browsers
c) line numbers are not visually selected ('user-select:' property):
IE 10+, Opera 15.0+, all other popular browsers
This patch is based on a demo implementation by
Martin Geisler <martin@geisler.net>.
author | Alexander Plavin <me@aplavin.ru> |
---|---|
date | Thu, 04 Jul 2013 14:18:44 +0400 |
parents | 30d899febef8 |
children | 7f0a30744366 |
line wrap: on
line source
body { margin: 0; padding: 0; background: white; font-family: sans-serif; } .container { padding-left: 115px; } .main { position: relative; background: white; padding: 2em 2em 2em 0; } #.main { width: 98%; } .overflow { width: 100%; overflow: auto; } .menu { width: 90px; margin: 0; font-size: 80%; text-align: left; position: absolute; top: 20px; left: 20px; right: auto; } .menu ul { list-style: none; padding: 0; margin: 10px 0 0 0; border-left: 2px solid #999; } .menu li { margin-bottom: 3px; padding: 2px 4px; background: white; color: black; font-weight: normal; } .menu li.active { font-weight: bold; } .menu img { width: 75px; height: 90px; border: 0; } .atom-logo img{ width: 14px; height: 14px; border: 0; } .menu a { color: black; display: block; } .search { position: absolute; top: .7em; right: 2em; } form.search div#hint { display: none; position: absolute; top: 40px; right: 0px; width: 190px; padding: 5px; background: #ffc; font-size: 70%; border: 1px solid yellow; -moz-border-radius: 5px; /* this works only in camino/firefox */ -webkit-border-radius: 5px; /* this is just for Safari */ } form.search:hover div#hint { display: block; } a { text-decoration:none; } .age { white-space:nowrap; } .date { white-space:nowrap; } .indexlinks { white-space:nowrap; } .parity0 { background-color: #f0f0f0; } .parity1 { background-color: white; } .plusline { color: green; } .minusline { color: #dc143c; } /* crimson */ .atline { color: purple; } .diffstat-file { white-space: nowrap; font-size: 90%; } .diffstat-total { white-space: nowrap; font-size: 90%; } .diffstat-graph { width: 100%; } .diffstat-add { background-color: green; float: left; } .diffstat-remove { background-color: red; float: left; } .navigate { text-align: right; font-size: 60%; margin: 1em 0; } .tag { color: #999; font-size: 70%; font-weight: normal; margin-left: .5em; vertical-align: baseline; } .branchhead { color: #000; font-size: 80%; font-weight: normal; margin-left: .5em; vertical-align: baseline; } ul#graphnodes .branchhead { font-size: 75%; } .branchname { color: #000; font-size: 60%; font-weight: normal; margin-left: .5em; vertical-align: baseline; } h3 .branchname { font-size: 80%; } /* Common */ pre { margin: 0; } h2 { font-size: 120%; border-bottom: 1px solid #999; } h2 a { color: #000; } h3 { margin-top: -.7em; font-size: 100%; } /* log and tags tables */ .bigtable { border-bottom: 1px solid #999; border-collapse: collapse; font-size: 90%; width: 100%; font-weight: normal; text-align: left; } .bigtable td { vertical-align: top; } .bigtable th { padding: 1px 4px; border-bottom: 1px solid #999; } .bigtable tr { border: none; } .bigtable .age { width: 7em; } .bigtable .author { width: 15em; } .bigtable .description { } .bigtable .description .base { font-size: 70%; float: right; line-height: 1.66; } .bigtable .node { width: 5em; font-family: monospace;} .bigtable .permissions { width: 8em; text-align: left;} .bigtable .size { width: 5em; text-align: right; } .bigtable .annotate { text-align: right; } .bigtable td.annotate { font-size: smaller; } .bigtable td.source { font-size: inherit; } .source, .sourcefirst, .sourcelast { font-family: monospace; white-space: pre; padding: 1px 4px; font-size: 90%; } .sourcefirst { border-bottom: 1px solid #999; font-weight: bold; } .sourcelast { border-top: 1px solid #999; } .source a { color: #999; font-size: smaller; font-family: monospace;} .bottomline { border-bottom: 1px solid #999; } .sourcelines { font-size: 90%; position: relative; } .sourcelines > span { display: inline-block; width: 100%; padding: 1px 0px; counter-increment: lineno; } .sourcelines > span:before { -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none; -ms-user-select: none; user-select: none; display: inline-block; width: 4em; margin-right: 1em; font-size: smaller; color: #999; text-align: right; content: counter(lineno); } .sourcelines > span:nth-child(4n+1) { background-color: #f0f0f0; } .sourcelines > span:nth-child(4n+3) { background-color: white; } .sourcelines > a { display: inline-block; position: absolute; left: 0px; width: 4em; height: 1em; } .fileline { font-family: monospace; } .fileline img { border: 0; } .tagEntry .closed { color: #99f; } /* Changeset entry */ #changesetEntry { border-collapse: collapse; font-size: 90%; width: 100%; margin-bottom: 1em; } #changesetEntry th { padding: 1px 4px; width: 4em; text-align: right; font-weight: normal; color: #999; margin-right: .5em; vertical-align: top; } div.description { border-left: 2px solid #999; margin: 1em 0 1em 0; padding: .3em; white-space: pre; font-family: monospace; } /* Graph */ div#wrapper { position: relative; border-top: 1px solid black; border-bottom: 1px solid black; margin: 0; padding: 0; } canvas { position: absolute; z-index: 5; top: -0.7em; margin: 0; } ul#graphnodes { position: absolute; z-index: 10; top: -1.0em; list-style: none inside none; padding: 0; } ul#nodebgs { list-style: none inside none; padding: 0; margin: 0; top: -0.7em; } ul#graphnodes li, ul#nodebgs li { height: 39px; } ul#graphnodes li .info { display: block; font-size: 70%; position: relative; top: -3px; } /* Comparison */ .legend { padding: 1.5% 0 1.5% 0; } .legendinfo { border: 1px solid #999; font-size: 80%; text-align: center; padding: 0.5%; } .equal { background-color: #ffffff; } .delete { background-color: #faa; color: #333; } .insert { background-color: #ffa; } .replace { background-color: #e8e8e8; } .header { text-align: center; } .block { border-top: 1px solid #999; } .breadcrumb { color: gray; } .breadcrumb a { color: blue; }