[PATCH RFC] hgweb: code selection without line numbers in file source view
Alexander Plavin
me at aplavin.ru
Wed Jul 3 07:23:15 CDT 2013
Actually, this seems quite nice for me. Waiting for others to give
their opinion.
2013/7/3 Martin Geisler <martin at geisler.net>:
> Alexander Plavin <me at aplavin.ru> writes:
>
> (You're top-posting. It is more convenient if you put your comments
> after the thing they apply to.)
>
>> In this case the whole lines are links, which makes it impossible to
>> select a random region (at least I couldn't do it) and isn't a good
>> thing anyway as for me. Also, both embedded and leading tabs are lost
>> on copy (tried several times, as you state the opposite, but same
>> result).
>
> Okay, you have a good point about the links making the text
> un-selectable. What do you think about the version below where we use
> JavaScript to install a click handler? I can mark text anywhere and when
> doing so the URL is updated to include the relevant ID, so that one can
> copy-paste the URL.
>
> <html>
> <head>
> <style>
> pre > span {
> display: inline-block;
> width: 100%;
> white-space: pre-wrap;
> counter-increment: lineno;
> }
> pre > span:before {
> display: inline-block;
> width: 2em;
> margin-right: 1em;
> font-size: small;
> font-style: italic;
> text-align: right;
> content: counter(lineno);
> }
> pre > span:nth-child(even) {
> background-color: lightgrey;
> }
> pre > span:target {
> background-color: yellow;
> }
> </style>
>
> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
> <script type="text/javascript">
> $(document).ready(function () {
> $("pre").on("click", "span", function (e) {
> window.location = "#" + this.id;
> });
> });
> </script>
> </head>
> <body>
>
> <p>Text before</p>
>
> <pre>
> <span id="l1"> Leading tab: x</span>
> <span id="l2"> Leading whitespace!</span>
> <span id="l3">Trailing whitespace! </span>
> <span id="l4">More trailing whitespace... </span>
> <span id="l5">Embedded tab.</span>
> <span id="l6">Very, very, long, very, long, very, long, very, long, very, long, long line...</span>
> <span id="l7">Trailing whitespace! </span>
> <span id="l8">More trailing whitespace... </span>
> </pre>
>
> <p>Text after</p>
>
> </body>
>
> </html>
>
>
> --
> Martin Geisler
More information about the Mercurial-devel
mailing list