Skip to content

Commit faa6cdb

Browse files
Sebastien Poncesponce
Sebastien Ponce
authored andcommitted
Fixed issues with highlighting, scontent and minted
This is a poor fix where code is replicated n times. I did not manage to do better. Any good idea is welcome. But take care, it's a tricky case due to the verbatim status of minted
1 parent 03e9583 commit faa6cdb

File tree

4 files changed

+353
-69
lines changed

4 files changed

+353
-69
lines changed

Diff for: talk/basicconcepts/arrayspointers.tex

+153-15
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@
1616
\end{cppcode}
1717
\end{frame}
1818

19-
\Scontents*[store-cmd=code_arrays]{
19+
\begin{frame}[fragile]
20+
\frametitlecpp[98]{Pointers}
21+
\begin{multicols}{2}
22+
% the code has to be repeated n times here. Anyone finding a better solution
23+
% is welcome, but it's not a trivial task, due to the verbatim nature of minted
24+
\begin{overprint}[\columnwidth]
25+
\onslide<1>
26+
\begin{minted}[linenos]{cpp}
2027
int i = 4;
2128
int *pi = &i;
2229
int j = *pi + 1;
@@ -32,20 +39,151 @@
3239
// seg fault !
3340
int *pak = (int*)k;
3441
int l = *pak;
35-
}
36-
\begin{frame}[fragile]
37-
\frametitlecpp[98]{Pointers}
38-
\begin{multicols}{2}
39-
\begin{overprint}[\columnwidth]
40-
\onslide<1> \highlightCppCode{}{code_arrays}
41-
\onslide<2> \highlightCppCode{1}{code_arrays}
42-
\onslide<3> \highlightCppCode{2}{code_arrays}
43-
\onslide<4> \highlightCppCode{3}{code_arrays}
44-
\onslide<5> \highlightCppCode{5}{code_arrays}
45-
\onslide<6> \highlightCppCode{6}{code_arrays}
46-
\onslide<7> \highlightCppCode{7}{code_arrays}
47-
\onslide<8> \highlightCppCode{8}{code_arrays}
48-
\onslide<9> \highlightCppCode{11}{code_arrays}
42+
\end{minted}
43+
\onslide<2>
44+
\begin{minted}[linenos,highlightlines=1]{cpp}
45+
int i = 4;
46+
int *pi = &i;
47+
int j = *pi + 1;
48+
49+
int ai[] = {1,2,3};
50+
int *pai = ai; // decay to ptr
51+
int *paj = pai + 1;
52+
int k = *paj + 1;
53+
54+
// compile error
55+
int *pak = k;
56+
57+
// seg fault !
58+
int *pak = (int*)k;
59+
int l = *pak;
60+
\end{minted}
61+
\onslide<3>
62+
\begin{minted}[linenos,highlightlines=2]{cpp}
63+
int i = 4;
64+
int *pi = &i;
65+
int j = *pi + 1;
66+
67+
int ai[] = {1,2,3};
68+
int *pai = ai; // decay to ptr
69+
int *paj = pai + 1;
70+
int k = *paj + 1;
71+
72+
// compile error
73+
int *pak = k;
74+
75+
// seg fault !
76+
int *pak = (int*)k;
77+
int l = *pak;
78+
\end{minted}
79+
\onslide<4>
80+
\begin{minted}[linenos,highlightlines=3]{cpp}
81+
int i = 4;
82+
int *pi = &i;
83+
int j = *pi + 1;
84+
85+
int ai[] = {1,2,3};
86+
int *pai = ai; // decay to ptr
87+
int *paj = pai + 1;
88+
int k = *paj + 1;
89+
90+
// compile error
91+
int *pak = k;
92+
93+
// seg fault !
94+
int *pak = (int*)k;
95+
int l = *pak;
96+
\end{minted}
97+
\onslide<5>
98+
\begin{minted}[linenos,highlightlines=5]{cpp}
99+
int i = 4;
100+
int *pi = &i;
101+
int j = *pi + 1;
102+
103+
int ai[] = {1,2,3};
104+
int *pai = ai; // decay to ptr
105+
int *paj = pai + 1;
106+
int k = *paj + 1;
107+
108+
// compile error
109+
int *pak = k;
110+
111+
// seg fault !
112+
int *pak = (int*)k;
113+
int l = *pak;
114+
\end{minted}
115+
\onslide<6>
116+
\begin{minted}[linenos,highlightlines=6]{cpp}
117+
int i = 4;
118+
int *pi = &i;
119+
int j = *pi + 1;
120+
121+
int ai[] = {1,2,3};
122+
int *pai = ai; // decay to ptr
123+
int *paj = pai + 1;
124+
int k = *paj + 1;
125+
126+
// compile error
127+
int *pak = k;
128+
129+
// seg fault !
130+
int *pak = (int*)k;
131+
int l = *pak;
132+
\end{minted}
133+
\onslide<7>
134+
\begin{minted}[linenos,highlightlines=7]{cpp}
135+
int i = 4;
136+
int *pi = &i;
137+
int j = *pi + 1;
138+
139+
int ai[] = {1,2,3};
140+
int *pai = ai; // decay to ptr
141+
int *paj = pai + 1;
142+
int k = *paj + 1;
143+
144+
// compile error
145+
int *pak = k;
146+
147+
// seg fault !
148+
int *pak = (int*)k;
149+
int l = *pak;
150+
\end{minted}
151+
\onslide<8>
152+
\begin{minted}[linenos,highlightlines=8]{cpp}
153+
int i = 4;
154+
int *pi = &i;
155+
int j = *pi + 1;
156+
157+
int ai[] = {1,2,3};
158+
int *pai = ai; // decay to ptr
159+
int *paj = pai + 1;
160+
int k = *paj + 1;
161+
162+
// compile error
163+
int *pak = k;
164+
165+
// seg fault !
166+
int *pak = (int*)k;
167+
int l = *pak;
168+
\end{minted}
169+
\onslide<9>
170+
\begin{minted}[linenos,highlightlines=11]{cpp}
171+
int i = 4;
172+
int *pi = &i;
173+
int j = *pi + 1;
174+
175+
int ai[] = {1,2,3};
176+
int *pai = ai; // decay to ptr
177+
int *paj = pai + 1;
178+
int k = *paj + 1;
179+
180+
// compile error
181+
int *pak = k;
182+
183+
// seg fault !
184+
int *pak = (int*)k;
185+
int l = *pak;
186+
\end{minted}
49187
\end{overprint}
50188
\columnbreak
51189
\onslide<2->{

0 commit comments

Comments
 (0)