From af9fa4d69fd543fa3afcd851962b7fee22cb48e4 Mon Sep 17 00:00:00 2001
From: Gloria Mundi <gloria@gloria-mundi.eu>
Date: Mon, 26 Feb 2024 20:12:43 +0100
Subject: add srclinks

---
 latexHeaders/code.sty | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

(limited to 'latexHeaders/code.sty')

diff --git a/latexHeaders/code.sty b/latexHeaders/code.sty
index a889596..987f43d 100644
--- a/latexHeaders/code.sty
+++ b/latexHeaders/code.sty
@@ -1,3 +1,6 @@
+\usepackage{ocgx2}
+\usepackage{fontawesome}
+
 % Colors, used for syntax highlighting.
 % To print this document, set all colors to black!
 \usepackage{xcolor}
@@ -101,6 +104,20 @@
 %	\addtocounter{lstnumber}{-1}%
 %}
 
+\ifthenelse{\isundefined{\srclink}}{}{
+	\lst@AddToHook{Init}{%
+		\ifthenelse{\equal{\lst@name}{}}{}{%
+			\begin{minipage}[t][0pt]{\linewidth}%
+				\vspace{0pt}%
+				\hfill%
+				\begin{ocg}[printocg=never]{Source links}{srclinks}{1}%
+					\hfill\href{\srclink{\lst@name}}{\faExternalLink}%
+				\end{ocg}%
+			\end{minipage}%
+		}%
+	}
+}
+
 \newenvironment{btHighlight}[1][]
 {\begingroup\tikzset{bt@Highlight@par/.style={#1}}\begin{lrbox}{\@tempboxa}}
 {\end{lrbox}\bt@HL@box[bt@Highlight@par]{\@tempboxa}\endgroup}
-- 
cgit v1.2.3

