From mboxrd@z Thu Jan 1 00:00:00 1970 From: andy at warmcat.com (Andy Green) Date: Fri, 29 Jun 2018 09:39:54 +0800 Subject: [PATCH v6 0/7] line range highlight In-Reply-To: References: Message-ID: <153023597876.27756.7476186508120329174.stgit@mail.warmcat.com> The following series adds the ability to direct the browser to highlight specific lines and ranges of lines in /tree/, /source/, and /blame/ views, using the existing #URLs. As part of the implementation it adds a new cgit.js file that is included in cgit page along with a new config "js" to specify its url, defaulting to "/cgit.js". It can be disabled by setting the "js" config to an empty string. Highlit lines or ranges are centred vertically rather than the default of scrolled to the top of the browser window area. You can click on the line number links to highlight individual lines, or line ranges when an individual line is already highlit. If a range is highlit, clicking on a line number link clears the range and just highlights that line again. When you click on a line number link, a sticky "burger" menu (***) appears on the left of the link. If you click on this, a popup menu appears with the options Copy Lines Copy Link View / Remove Blame (which depends if you are in /blame/) Copy Lines copies the text in the line or range that is highlit into the clipboard. Copy Link copies the full #URL from the browser URL bar. View / Remove Blame toggles between /tree/ and /blame/ views at the same highlit range. CSS transitions are used throughout. v6 switches to the burger menu and introduces the popup menu and related option. There's some cleanup of the JS and introduce a copyright notice at the top. You can find the patches as a usable tree here https://warmcat.com/git/cgit/log/ Examples: https://libwebsockets.org/git/libwebsockets/tree/lib/core/private.h#n152 https://libwebsockets.org/git/libwebsockets/tree/lib/core/private.h#n39-47 --- Andy Green (7): config: add js cgit.js: line range highlight: introduce javascript cgit.js: line range highlight: make responsive to url changes cgit.js: line range highlight: improve vertical scroll logic line-range-highlight: onclick handler and range selection line-range-highlight: burger menu and popup menu line-range-highlight: copy text Makefile | 1 cgit.c | 3 cgit.css | 78 ++++++++++++ cgit.h | 1 cgit.js | 367 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ cgitrc.5.txt | 5 + ui-blame.c | 2 ui-shared.c | 5 + ui-tree.c | 2 9 files changed, 462 insertions(+), 2 deletions(-) create mode 100644 cgit.js -- Signature