Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
19386:0e25a9e25931 | 19387:f2e4fdb3dd27 |
---|---|
207 .sourcefirst { border-bottom: 1px solid #999; font-weight: bold; } | 207 .sourcefirst { border-bottom: 1px solid #999; font-weight: bold; } |
208 .sourcelast { border-top: 1px solid #999; } | 208 .sourcelast { border-top: 1px solid #999; } |
209 .source a { color: #999; font-size: smaller; font-family: monospace;} | 209 .source a { color: #999; font-size: smaller; font-family: monospace;} |
210 .bottomline { border-bottom: 1px solid #999; } | 210 .bottomline { border-bottom: 1px solid #999; } |
211 | 211 |
212 .sourcelines { | |
213 font-size: 90%; | |
214 position: relative; | |
215 } | |
216 | |
217 .sourcelines > span { | |
218 display: inline-block; | |
219 width: 100%; | |
220 padding: 1px 0px; | |
221 counter-increment: lineno; | |
222 } | |
223 | |
224 .sourcelines > span:before { | |
225 -moz-user-select: -moz-none; | |
226 -khtml-user-select: none; | |
227 -webkit-user-select: none; | |
228 -ms-user-select: none; | |
229 user-select: none; | |
230 display: inline-block; | |
231 width: 4em; | |
232 margin-right: 1em; | |
233 font-size: smaller; | |
234 color: #999; | |
235 text-align: right; | |
236 content: counter(lineno); | |
237 } | |
238 | |
239 .sourcelines > span:nth-child(4n+1) { background-color: #f0f0f0; } | |
240 .sourcelines > span:nth-child(4n+3) { background-color: white; } | |
241 | |
242 .sourcelines > a { | |
243 display: inline-block; | |
244 position: absolute; | |
245 left: 0px; | |
246 width: 4em; | |
247 height: 1em; | |
248 } | |
249 | |
212 .fileline { font-family: monospace; } | 250 .fileline { font-family: monospace; } |
213 .fileline img { border: 0; } | 251 .fileline img { border: 0; } |
214 | 252 |
215 .tagEntry .closed { color: #99f; } | 253 .tagEntry .closed { color: #99f; } |
216 | 254 |