-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsseqkeys.code.tex
2067 lines (1879 loc) · 89.5 KB
/
sseqkeys.code.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%%
%% Package: spectralsequences v1.2.0 2017-09-16 2017-09-16
%% Author: Hood Chatham
%% Email: [email protected]
%% Date: 2017-12-10
%% License: Latex Project Public License
%%
%% File: sseqkeys.code.tex
%% Exposes: \sseqset
%%
%% Sets up the keys for sseqpages. There are a lot of them...
%%
% Run \pgfqkeys{directory}{keys} but for a list of directories. Helps to avoid code duplication.
\def\sseq@pgfqkeysdirlist#1#2{%
\sseq@temptoks{#2}%
\sseq@pgfqkeysdirlist@#1,\sseq@nil
}
\def\sseq@pgfqkeysdirlist@#1,{%
\sseq@eval{\@nx\pgfqkeys{#1}{\the\sseq@temptoks}}%
\@ifnextchar\sseq@nil{\@gobble}{\sseq@pgfqkeysdirlist@}%
}
%%%% Interface macros:
% These are the things that are used outside of this section:
\let\sseq@pgfkeys@error@save\pgfkeys@error
\pgfkeys{/sseqpages/userstyles/.unknown/.code={\sseq@passoptionto{\sseq@sseqsetdirectory}}}
\protected\def\sseqset#1{\pgfqkeys{/sseqpages/userstyles}{#1}}
\def\sseq@sseqsetdirectory{/sseqpages/global/default}
\def\sseq@set{\pgfqkeys{/sseqpages}}
%%%
%%% Local Keys
%%%
% This is where and how we are going to store the results of our local options. Note that definitions need to be local to allow recursion.
\def\sseq@savedoptioncode{}
\def\sseq@d@addto@options{\sseq@d@addto@macro\sseq@savedoptioncode}
\def\sseq@e@addto@options{\sseq@e@addto@macro\sseq@savedoptioncode}
% #1 -- name of key
% #2 -- options
% This is the main way that we use options. (We also use \pgfqkeys{/sseqpages/global} and some similar things)
% Dumps out code that the option indexes into \sseq@savedoptioncode
% This is because \pgfkeys has a high performance cost, so instead of using \pgfkeys once per page,
% we use this once when putting together the spectral sequence and save the result.
\def\sseq@processoptions#1#2{%
\def\sseq@savedoptioncode{}%
\sseq@protectedeval{\@nx % TODO: get rid of this protectedeval
\pgfqkeys{/sseqpages/#1}{#2}
}%
}
% First pass versus second pass:
% Lots of options mainly do stuff on the drawing run, but still need to warn the sseq setup algorithms that they're around
% on the first pass. Some only do things on the first pass or only do things on the second pass.
% For example, shifts: shifts apply a coordinate transform on the second pass, but also need to factor into the coordinates of
% classes etc which are computed at specification time not at draw time. So xshift=2 increases \sseq@x by 2 on it's first pass and
% applies a coordinate transform by 2cm on the second pass.
% normal mode does the firstpass options now and saves the secondpass options in \sseq@savedoptioncode for later use.
% firstpass mode does the firstpass options and throws away the secondpass options.
% secondpass mode throws away the firstpass options and does the secondpass options NOW
% bothpass mode does both firstpass and secondpass options NOW
% We spend the vast majority of our time in normal mode.
\def\sseq@options@use#1{#1}
\def\sseq@options@normalmode{\let\sseq@options@firstpass\sseq@options@use\let\sseq@options@secondpass\sseq@d@addto@options}
\def\sseq@options@firstpassmode{\let\sseq@options@firstpass\sseq@options@use\let\sseq@options@secondpass\@gobble}
\def\sseq@options@secondpassmode{\let\sseq@options@firstpass\@gobble\let\sseq@options@secondpass\sseq@options@use}
\def\sseq@options@bothpassmode{\let\sseq@options@firstpass\sseq@options@use\let\sseq@options@secondpass\sseq@options@use}
\sseq@options@normalmode
\pgfqkeys{/handlers}{
.sseq @ first pass code/.code={
\pgfkeysalso{\pgfkeyscurrentpath/.code={\sseq@options@firstpass{#1}}}
},
.sseq @ first pass append code/.code={
\pgfkeysalso{\pgfkeyscurrentpath/.append code={\sseq@options@firstpass{#1}}}
},
.sseq @ second pass code/.code={
\pgfkeysalso{\pgfkeyscurrentpath/.code={\sseq@options@secondpass{#1}}}
},
.sseq @ second pass append code/.code={
\pgfkeysalso{\pgfkeyscurrentpath/.append code={\sseq@options@secondpass{#1}}}
},
.sseq @ second pass store in/.code={
\pgfkeysalso{\pgfkeyscurrentpath/.code={\sseq@options@secondpass{\def#1{##1}}}}
},
.sseq @ code/.code 2 args={
\pgfkeysalso{\pgfkeyscurrentpath/.code={\sseq@options@firstpass{#1}}}
\pgfkeysalso{\pgfkeyscurrentpath/.append code={\sseq@options@secondpass{#1}}}
},
.sseq @ transform/.code={
\sseq@keys@lastpart
\edef\sseq@temppath{\pgfkeyscurrentpath/\sseq@temp}
\pgfkeysalso{\sseq@temppath/.code/.expanded={\@nx\sseq@checktransform{\sseq@temp}\unexpanded{{##1}}}}
\pgfkeysalso{\sseq@temppath/.sseq @ second pass append code/.expanded={\@nx\sseq@pgfkeysdocommand{\sseq@temp}\unexpanded{{##1}}}}%
},
.sseq @ stdparse do transform/.code={
\sseq@keys@lastpart
\edef\sseq@temppath{\pgfkeyscurrentpath/\sseq@temp}
\ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text
\pgfkeysalso{\sseq@temppath/.code/.expanded={\@nx\sseq@standardparse\@nx\sseq@options@secondpass{\@nx\sseq@pgfkeysdocommand{\sseq@temp}\unexpanded{{##1}}}}}
\else
\pgfkeysalso{\sseq@temppath/.code/.expanded={\@nx\sseq@standardparse\@nx\sseq@options@secondpass{\@nx\sseq@pgfkeysdocommand{\sseq@temp}{#1}}}s}
\fi
},
.sseq @ illegal/.code={
\sseq@keys@lastpart
\edef\sseq@temppath{\pgfkeyscurrentpath/\sseq@temp}
\pgfkeysalso{\sseq@temppath/.code/.expanded={\@nx\sseq@error@n{option-illegal}{\sseq@temp}}}
},
.sseq @ illegal as global/.code={
\sseq@keys@lastpart
\pgfkeysalso{/sseqpages/global/\sseq@temp/.code/.expanded={\@nx\sseq@error@n{option-illegal-as-global}{\sseq@temp}}}
},
.sseq @ global only/.code={
\sseq@keys@lastpart
\pgfkeysalso{/sseqpages/\sseq@temp/.code/.expanded={\@nx\sseq@error@n{option-global-only}{\sseq@temp}}}
}
}
%%% Some easy internal macros
% This is for .unknown handlers. Try same key in different directory #1.
\def\sseq@passoptionto#1{\sseq@eval{\@nx\pgfqkeys{#1}{\pgfkeyscurrentname={\unexpanded\@xp{\pgfkeyscurrentvalue}}}}}
% Immediately execute a key that is either a tikz or pgf key.
% #1 -- key
% #2 -- value
\def\sseq@pgfkeysdocommand#1#2{
\sseq@tempiffalse
\sseq@pgfkeysdocommand@try{/tikz}{#1}{#2}
\sseq@pgfkeysdocommand@try{/pgf}{#1}{#2}
\ifsseq@tempif\else\sseq@error@internal@nn{do-command-failed}{#1}{#2}\fi
}
% Execute a key if \sseq@tempif is true and it is defined, if so set \sseq@tempif to false.
% These are meant to cascade.
% #1 -- directory
% #2 -- key
% #3 -- value
\def\sseq@pgfkeysdocommand@try#1#2#3{
\ifsseq@tempif\else
\pgfkeysifdefined{#1/#2/.@cmd}{
\sseq@tempiftrue
\def\pgfkeysdefaultpath{#1/}
\edef\pgfkeyscurrentkey{#1/#2}
\pgfkeysgetvalue{#1/#2/.@cmd}{\pgfkeys@code}%
\pgfkeys@code#3\pgfeov
}{
\pgfkeysifdefined{#1/#2}{
\sseq@tempiftrue
\pgfkeyssetvalue{#1/#2}{#3}
}{}
}
\fi
}
%%%
% Our main unknown option handler
% This is copied from the standard tikz .unknown handler, but instead of running the code it stores it in \sseq@savedoptioncode.
% When it tries the key in /tikz and in /pgf it also recursively expands \pgfkeysalso's.
\def\sseq@keys@unknown@error@normal{\sseq@error{unknown-key}} % a hook so we can turn off errors if we like
\let\sseq@keys@unknown@error\sseq@keys@unknown@error@normal % This is used in .sseq style
\let\sseq@add@tikzkey@to@options\sseq@e@addto@options % another hook for .sseq style
\def\sseq@keys@unknown{%
\let\tikz@key\pgfkeyscurrentname
\sseq@keys@try@addtooptions{/sseqpages/userstyles,/tikz,/pgf}{}{%
\@xp\pgfutil@in@\@xp!\@xp{\tikz@key}%
\ifpgfutil@in@%
% this is a color!
\sseq@keys@unknown@handlecolor
\else%
\pgfutil@doifcolorelse{\tikz@key}%
{%
\sseq@keys@unknown@handlecolor
}%
{%
% Ok, second chance: This might be an arrow specification:
\@xp\pgfutil@in@\@xp-\@xp{\tikz@key}%
\ifpgfutil@in@%
% Ah, an arrow spec!
\sseq@add@tikzkey@to@options{\@nx\sseq@options@secondpass{\@nx\tikz@processarrows{\tikz@key}}}%
\else%
% Ok, third chance: A shape!
\@xp\ifx\csname pgf@sh@s@\tikz@key\endcsname\relax%
\sseq@keys@unknown@error%
\else%
\sseq@add@tikzkey@to@options{\@nx\sseq@options@secondpass{\def\@nx\tikz@shape{\tikz@key}}}%
\fi%
\fi%
}%
\fi%
}%
}
\def\sseq@keys@unknown@handlecolor{%
\sseq@add@tikzkey@to@options{\@nx\sseq@options@secondpass{\@nx\tikz@addoption{\@nx\tikz@compat@color@set{\tikz@key}}}}%
\sseq@add@tikzkey@to@options{\@nx\sseq@options@secondpass{\def\@nx\tikz@textcolor{\tikz@key}}}%
}
%%% \sseq@keys@try@addtooptions
% #1 -- a comma separated list of directories
% #2 -- success code
% #3 -- failure code
%
% This is for the main .unknown handler and for \sseq@addstylecodetooptions (which pretends to be \pgfkeys executed in a directory with only a .unknown)
% Tries to run the current key (\pgfkeyscurrentname=\pgfkeyscurrentvalue) in each of the directories in turn.
% If it finds the key in one of the directories, recursively expand the \pgfkeysalso in the code,
% add the final result to \sseq@savedoptioncode, and run success code. Otherwise run failure code.
%
% The goal is to avoid storing any commands that require the use of pgfkeys.
% This is only a partial solution, because it misses \tikzset, \pfgqkeys, etc.
% \pgfkeysalso is particularly dangerous though because we might not remember what directory it was supposed to happen in.
% In order to get the recursive expansion of \pgfkeysalso's we need to modify the pgfkeys algorithm so that it
% passes control back to \sseq@keys@addtooptions@checkalso when it's done.
% Modifies tikz commands \pgfkeys@case@one and \pgfkeys@case@two@extern from file /pgf/utilities/pgfkeys.code.tex lines 352 and 365
\def\sseq@keys@try@addtooptions#1{%
\sseq@keys@try@addtooptions@#1,\sseq@nil
}
\def\sseq@keys@try@addtooptions@#1,{%
\bgroup
\def\pgfkeysdefaultpath{#1/}%
\def\next{\egroup\@ifnextchar\sseq@nil{\@xp\@secondoftwo\@gobble}{\sseq@keys@try@addtooptions@}}%
\pgfkeysifdefined{#1/\pgfkeyscurrentname/.@cmd}{%
\edef\pgfkeyscurrentkey{#1/\pgfkeyscurrentname}%
\ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% Hmm... no value
\pgfkeysifdefined{#1/\pgfkeyscurrentname/.@def}%
{\pgfkeysgetvalue{#1/\pgfkeyscurrentname/.@def}{\pgfkeyscurrentvalue}}%
{}% no default, so leave it
\fi%
\pgfkeysgetvalue{#1/\pgfkeyscurrentname/.@cmd}{\pgfkeys@code}%
\sseq@eval{\@nx\sseq@keys@addtooptions@checkalso{\unexpanded\@xptwo{\@xp\pgfkeys@code\pgfkeyscurrentvalue\pgfeov}}}%
\sseq@smuggle@macro\sseq@savedoptioncode
\egroup
\def\next{\@xp\@firstoftwo\sseq@gobble@to@nil}%
}{%
\pgfkeysifdefined{#1/\pgfkeyscurrentname}{%
\egroup
\sseq@add@tikzkey@to@options{\@nx\sseq@options@secondpass{\@nx\pgfkeyssetvalue{#1/\pgfkeyscurrentname}{\unexpanded\@xp{\pgfkeyscurrentvalue}}}}%
\def\next{\@xp\@firstoftwo\sseq@gobble@to@nil}%
}{}%
}%
\next
}
% Iterate over list and run \pgfkeysalso's when we find them. Note that we use our variants of \pgfkeys@case@... which hand control back to this command,
% so this is recursive -- the result is guaranteed not to have any instance of \pgfkeysalso in it!
\def\sseq@keys@addtooptions@checkalso#1{%
\let\pgfkeys@case@one\sseq@pgfkeys@case@one@store
\let\pgfkeys@case@two@extern\sseq@pgfkeys@case@two@extern@store
\sseq@keys@addtooptions@checkalso@#1\pgfkeysalso\sseq@nil
}
\def\sseq@keys@addtooptions@checkalso@#1\pgfkeysalso#2{%
\def\sseq@tempa{/tikz/}%
\def\sseq@tempb{/pgf/}%
% This is an extra hook I needed to add so that my own keys can execute code when they need to...
\sseq@keys@addtooptions@checkdo#1\sseq@keys@do\sseq@nil
\ifx\sseq@nil#2% We're done, restore pgfkeys.
\let\pgfkeys@case@one\sseq@pgfkeys@case@one@save
\let\pgfkeys@case@two@extern\sseq@pgfkeys@case@two@extern@save
\else
\ifx\expandafter#2 % if they wanted to expand the first token, handle that
\sseq@add@tikzkey@to@options{\sseq@options@secondpass@iftikz{\relax\relax}}% The last token was an \expandafter, we need to keep it from doing anything
\@xptwo\sseq@keys@addtooptions@checkalso@xp
\else
\pgfkeysalso{#2}%
\@xptwo\sseq@keys@addtooptions@checkalso@
\fi
\fi
}
\def\sseq@keys@addtooptions@checkalso@xp#1{%
\@xp\pgfkeysalso\@xp{#1}%
\sseq@keys@addtooptions@checkalso@
}
% Used to get collections code to run right.
\def\sseq@keys@addtooptions@checkdo#1\sseq@keys@do#2{%
\sseq@add@tikzkey@to@options{\sseq@options@secondpass@iftikz{\unexpanded{#1}}}%
\ifx#2\sseq@nil\else
#2%
\@xp\sseq@keys@addtooptions@checkdo
\fi
}
% This has to be expandable, so \sseq@tempa and \sseq@tempb are set to "/tikz/" and "/pgf/" ahead of time
% Defer the command if it is in directories /pgf or /tikz, otherwise run it now. TODO: explain here why we need this.
\def\sseq@options@secondpass@iftikz{%
\ifx\pgfkeysdefaultpath\sseq@tempa
\@nx\sseq@options@secondpass
\else
\ifx\pgfkeysdefaultpath\sseq@tempb
\@nx\sseq@options@secondpass
\else
\@xptwo\@firstofone
\fi
\fi
}
% Here we hook into pgfkeys. This is remarkably easy!
\let\sseq@pgfkeys@case@one@save\pgfkeys@case@one
\let\sseq@pgfkeys@case@two@extern@save\pgfkeys@case@two@extern
\def\sseq@pgfkeys@case@one@store{%
\pgfkeysifdefined{\pgfkeyscurrentkey/.@cmd}{%
\pgfkeysgetvalue{\pgfkeyscurrentkey/.@cmd}{\pgfkeys@code}%
% The following line is the only change, it used to be \@xp\pgfkeys@code\pgfkeyscurrentvalue\pgfeov which would just run the code.
% Instead we recursively expand the \pgfkeysalso's and then store in it \sseq@savedoptioncode
\sseq@eval{\@nx\sseq@keys@addtooptions@checkalso{\unexpanded\@xptwo{\@xp\pgfkeys@code\pgfkeyscurrentvalue\pgfeov}}}%
}{\pgfkeys@case@two}%
}
\def\sseq@pgfkeys@case@two@extern@store{%
\ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text%
\pgfkeysvalueof{\pgfkeyscurrentkey}% this probably isn't a real case
\else%
% The following line is the only change, it used to be (roughly) \pgfkeyssetvalue{\pgfkeyscurrentkey}{\pgfkeyscurrentvalue}
% which would immediately set the value. Instead we store in it \sseq@savedoptioncode
\sseq@add@tikzkey@to@options{\@nx\sseq@options@secondpass{\@nx\pgfkeyssetvalue{\pgfkeyscurrentkey}{\unexpanded\@xp{\pgfkeyscurrentvalue}}}}%
\fi%
}
\pgfkeys{%
/sseqpages/.is family,
/sseqpages/.unknown/.code={\sseq@keys@unknown},
%
/sseqpages/class/.unknown/.code={%
\expandafter\ifx\csname pgf@sh@s@\pgfkeyscurrentname\endcsname\relax % is it the name of a shape?
\sseq@passoptionto{/sseqpages}%
\else
\sseq@e@addto@options{\def\@nx\tikz@shape{\pgfkeyscurrentname}}% if so, store it
\fi
},
/sseqpages/.is family,
/sseqpages/scope/.is family,
/sseqpages/scope/.unknown/.code={\sseq@passoptionto{/sseqpages}},
/sseqpages/class/.is family,
/sseqpages/class/label/.is family,
/sseqpages/class/label/.unknown/.code={\sseq@keys@unknown},
/sseqpages/class/label/pin/.unknown/.code={\sseq@keys@unknown},
/sseqpages/class/node texts/.is family,
/sseqpages/class/node texts/.unknown/.code={\sseq@passoptionto{/tikz}},
/sseqpages/differential/.is family,
/sseqpages/differential/.unknown/.code={\sseq@passoptionto{/sseqpages}},
/sseqpages/struct line/.is family,
/sseqpages/struct line/.unknown/.code={\sseq@passoptionto{/sseqpages}},
/sseqpages/label/.is family,
/sseqpages/label/.unknown/.code={\sseq@keys@unknown},
/sseqpages/tikz primitives/.is family,
/sseqpages/tikz primitives/.unknown/.code={\sseq@keys@unknown},
% One off directories
/sseqpages/fit/.is family,
/sseqpages/fit/.unknown/.code={\sseq@passoptionto{/sseqpages}},
/sseqpages/foreach/.unknown/.code={\sseq@passoptionto{/pgf/foreach}},
/sseqpages/class placement/.unknown/.code={\sseq@passoptionto{/tikz}}
}
\pgfqkeys{/sseqpages/class}{shape/.code={\edef\tikz@shape{\pgfkeyscurrentname}}} % shape=whatever shape passing
\newif\ifsseq@pin
\pgfqkeys{/sseqpages/class/label}{% maybe implement multipart node labels this way? No way!
node/.sseq @ first pass code={\sseq@classlabelfalse},
inside/.sseq @ first pass code={\sseq@classlabelfalse},
pin/.sseq @ first pass code = {
\let\sseq@savedoptioncode@save\sseq@savedoptioncode
\sseq@processoptions{class/label/pin}{#1}
\edef\sseq@savedoptioncode{\unexpanded\@xp{\sseq@savedoptioncode@save}\@nx\sseq@d@addto@macro\@nx\sseq@pinoptions{\unexpanded\@xp{\sseq@savedoptioncode}}}
},
pin/.sseq @ second pass append code = {\sseq@pintrue}
}
\def\sseq@pinoptions{}
%% label directions
\def\sseq@labeldirectionlist{\\{above}\\{below}\\{left}\\{right}\\{above left}\\{above right}\\{below left}\\{below right}}
\def\sseq@setlabeldirectionkeys#1{
\@ifnextchar[{\sseq@setlabeldirectionkeys@{#1}}{\sseq@setlabeldirectionkeys@{#1}[/.code]}%]
}
\def\sseq@setlabeldirectionkeys@#1[#2]#3{
\bgroup
\def\sseq@temp##1{#3}
\sseq@temptoks{}
\def\\##1{
\sseq@eval{\sseq@temptoks{\the\sseq@temptoks##1#2={\unexpanded\@xp{\sseq@temp{##1}}},}}
}
\sseq@labeldirectionlist
\sseq@eval{\egroup\@nx\pgfqkeys{#1}{\the\sseq@temptoks}}
}
\begingroup
\def\\#1{\@xp\sseq@addtostorelist\csname sseq@default@#1@distance\endcsname{1ex}}
\sseq@labeldirectionlist
\endgroup
\def\sseq@defaultlabeldistance#1{\@xp\csname sseq@default@#1@distance\endcsname}
\def\sseq@setdefaultlabeldistance#1#2{\sseq@savedpaths@add{\@xp\gdef\csname sseq@default@#1@distance\endcsname{#2}}}
\def\sseq@setdefaultlabeldistances#1{\def\\##1{\sseq@setdefaultlabeldistance{##1}{#1}}\sseq@labeldirectionlist}
\sseq@setlabeldirectionkeys{/sseqpages/class/label}[/.sseq @ first pass code]{\sseq@classlabeltrue}
\sseq@setlabeldirectionkeys{/sseqpages/class/label}[/.sseq @ second pass append code]{\sseq@class@positionlabel{#1}{##1}}
\sseq@setlabeldirectionkeys{/sseqpages/class/label}[/.default]{\sseq@defaultlabeldistance{#1}}
\sseq@setlabeldirectionkeys{/sseqpages/global/class/label}[/.default]{\sseq@defaultlabeldistance{#1}}
\sseq@setlabeldirectionkeys{/sseqpages/global}[ label distance/.code]{\sseq@setdefaultlabeldistance{#1}{##1}}
\sseq@setlabeldirectionkeys{/sseqpages}[ label distance/.code]{\sseq@setdefaultlabeldistance{#1}{##1}}
\sseq@pgfqkeysdirlist{/sseqpages/global,/sseqpages}{
label distance/.code={\sseq@setdefaultlabeldistances{#1}}
}
\def\sseq@class@positionlabel#1#2{\ifx\tikz@fig@name\undefined\else\sseq@pgfkeysdocommand{#1}{#2 of \tikz@fig@name}\fi}
\sseq@addtostorelist\sseq@classlabel@handler{} % \sseq@classlabel@handler is public via "class label handler"
\def\sseq@classlabel@handler@default#1{\def\result{#1}}
\sseq@addtostorelist\sseq@classname@handler{} % \sseq@classname@handler is public via "class name handler"
\def\sseq@classname@handler@default#1{\def\result{#1}}
\def\sseq@labeltextfn#1{#1} % labeltextfn is private
\def\sseq@labeltextfn@rotatescale#1{%
\@nx\ifmmode
\@nx\scalebox{\sseq@labletext@scale@factor}{\@nx\rotatebox{\sseq@labletext@rotate@angle}{$#1$}}%
\@nx\else
\@nx\scalebox{\sseq@labletext@scale@factor}{\@nx\rotatebox{\sseq@labletext@rotate@angle}{#1}}%
\@nx\fi
}
\def\sseq@labletext@rotate@angle{0}
\def\sseq@labletext@scale@factor{1}
\bgroup\lccode`8=`p\lccode`9=`t\lowercase{\egroup
\def\sseq@eatpt#189{#1}
}
\sseq@pgfqkeysdirlist{/sseqpages/label,/sseqpages/class/label}{
rotate/.code={%
\let\sseq@labeltextfn\sseq@labeltextfn@rotatescale
\edef\sseq@labletext@rotate@angle{\@xp\sseq@eatpt\the\dimexpr\sseq@labletext@rotate@angle pt+#1pt}%
},
scale/.code={%
\let\sseq@labeltextfn\sseq@labeltextfn@rotatescale
\edef\sseq@labletext@scale@factor{\@xp\sseq@eatpt\the\dimexpr\sseq@labletext@scale@factor pt*#1}%
},
% shift/.sseq @ second pass code={\pgfkeysalso{xshift=\sseq@shift@getx#1}\pgfkeysalso{yshift=\sseq@shift@gety#1}}
}
\pgfqkeys{/sseqpages/global}{
background color/.initial=white
}
\pgfqkeys{/sseqpages/label}{
description/.code={%
\edef\sseq@edgeoptionhook{\@nx\pgfkeys{/tikz/fill=\pgfkeysvalueof{/sseqpages/global/background color}}}%
},
description/.sseq @ second pass append code={%
\pgfkeysalso{/tikz/anchor=center}%
}
}
\def\sseq@edgeoptionhook{}% This is just to make description work.
%% Labels
%% The code for this that actually does most of the work is inside of sseqmain.code.tex -- search for "Labels"
%% This just handles the interface with the keyvalue system here.
%% Quote handling
% \sseq@handlequote will be installed later as the 'first char syntax' for ".
% Problem is that 'first char syntax' isn't allowed to care what directory it is in, but we need different handling
% for classes versus edges versus scopes. Solution is to use \pgfkeysalso and then define the handler in a key.
\def\sseq@protectlabel{\@nx\sseq@protectlabel\@nx}
\def\sseq@handlequote#1{\pgfkeysalso{handle quote=#1}}
\pgfkeys{%
/sseqpages/class/handle quote/.code={%
\let\tikz@quotes@as@save\tikz@quotes@as
\let\tikz@quotes@as\sseq@handleclassquotes
\tikz@quote@parser{#1}%
\let\tikz@quotes@as\tikz@quotes@as@save
},
/sseqpages/handle quote/.code={%
\let\tikz@quotes@as\sseq@handleedgequotes
\tikz@quote@parser{#1}%
\let\tikz@quotes@as\tikz@quotes@as@save
}
}
% We just do the parsing in sseqkeys, \sseq@handleclassquotes@inner which does the main work is defined sseqmain.
\def\sseq@handlescopequotes#1#2{% We use this via \let\tikz@quotes@as\sseq@handleclassquotes
/utils/exec={% so it's called inside \pgfkeysalso{stuff}. Need to surround with /utils/exec={} to get out.
\global\let\sseq@classnodetext\pgfutil@empty%
\global\let\sseq@classnodetextoptions\pgfutil@empty%
\global\let\sseq@classlabelnodes\pgfutil@empty%
\sseq@handleclassquotes@inner{#1}{#2}
}
}
% We use this via \let\tikz@quotes@as\sseq@handleclassquotes
% so it's called inside \pgfkeysalso{stuff}. Need to surround with /utils/exec={} to get out.
\def\sseq@handleclassquotes#1#2{/utils/exec={\sseq@d@addto@macro\sseq@processlabels{\sseq@handleclassquotes@inner{#1}{#2}}}}
\def\sseq@checktransform@error{\sseq@error@nn{illegal-transform}}
\let\sseq@checktransform\sseq@checktransform@error
%% Parsing, background vs foreground, and context
\def\sseq@standardparse{%
\let\sseq@tikzprimitives@coords@maybeclass\sseq@tikzprimitives@coords@notaclass
\let\sseq@checktransform\@gobbletwo
\let\sseq@tikz@shifttransform\sseq@okayshifttransform
% TODO: This needs fixing:
%((((((((((((((((((
\def\class##1){\sseq@setthiscall{\string\class##1)}\sseq@error@x{standard-parse}{\string\class}}%
\def\replaceclass##1){\sseq@setthiscall{\string\replaceclass##1)}\sseq@error@x{standard-parse}{\string\replaceclass}}%
\def\classoptions##1){\sseq@setthiscall{\string\classoptions##1)}\sseq@error@x{standard-parse}{\string\classoptions}}%
\def\d##1){\sseq@setthiscall{\string\d##1)}\sseq@error@x{standard-parse}{\string\d}}%
\def\doptions##1){\sseq@setthiscall{\string\doptions##1)}\sseq@error@x{standard-parse}{\string\doptions}}%
\def\structline##1)##2){\sseq@setthiscall{\string\structline##1)##2)}\sseq@error@x{standard-parse}{\string\structline}}%
\def\structlineoptions##1)##2){\sseq@setthiscall{\string\structlineoptions##1)##2)}\sseq@error@x{standard-parse}{\string\structlineoptions}}%
}
% I don't think this is ever actually used...
\def\sseq@nodeparse{%
\let\sseq@tikzprimitives@coords@maybeclass\sseq@tikzprimitives@coords@maybeclass@save
\let\sseq@tikzprimitives@coords@maybeclass
\def\sseq@transform{\sseq@error@nn{illegal-transform}} % Disallow most coordinate transforms
\let\sseq@shifttransform\sseq@checkshifttransform
\let\class\sseq@class
\let\replaceclass\sseq@replaceclass
\let\structline\sseq@structline
}
\sseq@pgfqkeysdirlist{/sseqpages,/sseqpages/tikz primitives}{%
standard parse/.code={
\let\sseq@firstpass@shifttransform\@gobbletwo
\sseq@d@addto@options{\sseq@standardparse}
\pgfkeys{/sseqpages/tikz primitives/shift/.sseq @ second pass code={\tikzset{shift={##1}}}}
},
node parse/.code={ % This is never used, probably broken, and likely shouldn't exist
\let\sseq@firstpass@shifttransform\sseq@firstpass@checkshifttransform
\let\sseq@checktransform\sseq@checktransform@error
\sseq@d@addto@options{\sseq@nodeparse}
},
background/.code={\sseq@setsavedpaths{background}\pgfkeysalso{standard parse}},
foreground/.code={\ifsseq@keepchanges\sseq@setsavedpaths{standard}\else\sseq@setsavedpaths{temporary}\fi\pgfkeysalso{node parse}}
}
\pgfkeys{
/sseqpages/tikz primitives/handle quote/.sseq @ second pass code={\tikzset{#1}},
/tikz/handle quote/.code={\sseq@error{tikz-edge-quotes}}
}
\sseq@pgfqkeysdirlist{/sseqpages/class,/sseqpages/differential}{
standard parse/.sseq @ first pass code={\sseq@error@n{option-tikz-prims-only}{standard parse}},
background/.sseq @ first pass code={\sseq@error@n{option-tikz-prims-only}{background}}
}
% Some class options. All of these will make changes local to the current \class command. They are communicated to \class via these commands,
% which we initialize here as empty.
\def\sseq@class@tag{}
\def\sseq@class@tagprefix{}
\def\sseq@class@name{}
\def\sseq@namehandler{}
\def\sseq@currenttag{\sseq@class@tag}% for the user ??
\def\sseq@tooltip{}
\pgfqkeys{/sseqpages/scope}{
tag/.code={\pgfkeys@spdef\sseq@class@tag{#1}},
tag prefix/.code={\pgfkeys@spdef\temp{#1}\sseq@e@addto@macro\sseq@class@tagprefix{\unexpanded\@xp{#1}}}
}
\def\sseq@classinsert{}
\def\sseq@classnameprefix{}
\def\sseq@classnamepostfix{}
\pgfqkeys{/sseqpages}{
class name prefix/.store in=\sseq@classnameprefix,
class name postfix/.store in=\sseq@classnamepostfix
}
\pgfqkeys{/sseqpages/class}{
name/.code={%
\sseq@protectedeval{\@nx\sseq@classname@handler{\sseq@classnameprefix#1\sseq@classnamepostfix}}%
\edef\sseq@class@name{\unexpanded\@xp{\result}}%
\pgfkeysalso{/sseqpages/alias/.expand once=\detokenize\@xp{\sseq@class@name}}%
},
show name/.store in=\sseq@class@showname,
page/.code={\sseq@getnumrange\sseq@class@page{#1}},% page & gen are only for \classoptions.
generation/.code={\sseq@getnumrange\sseq@gen{#1}}, % \class tests if \sseq@class@page is set and throw an error if so.
tag/.code={\sseq@d@addto@macro\sseq@class@tag{#1}},
offset/.store in=\sseq@tempoffset,
tooltip/.sseq @ first pass code={\ifx\sseqtooltip\undefined \sseq@error{no-tooltip}\else \def\sseq@tooltip{#1}\fi},
insert/.store in=\sseq@classinsert
}
\pgfqkeys{/sseqpages/struct line}{
page/.code={\sseq@getnumrange\sseq@structline@page{#1}}
}
\def\sseq@fitalso{}
\pgfqkeys{/sseqpages/fit}{
fit/.sseq @ first pass code={\sseq@d@addto@macro\sseq@fitalso{#1}},
page/.code={\sseq@getnumrange\sseq@fit@page{#1}}
}
\def\sseq@getnumrange#1#2{
\pgfutil@in@{--}{#2}\ifpgfutil@in@
\sseq@getnumrange@range#1#2\sseq@nil
\else
\edef#1{\the\numexpr#2}
\fi
}
\def\sseq@getnumrange@range#1#2--#3\sseq@nil{\edef#1{\the\numexpr#2}\@xp\edef\csname\sseq@macroname#1max\endcsname{\the\numexpr#3}}
%% Needs tikz
% Force \class or \d to fall back to using tikz to render their output
% Rather than using the faster direct \pgf primitives (largely copied from tikz to maximize compatibility)
% Drawing with tikz is slower, but I don't want to reimplement these features
\def\sseq@needstikzandpass#1#2{\sseq@needstikzandpass@{#1}#2,\@nil}
\def\sseq@needstikzandpass@#1#2,{%
\pgfqkeys{#1}{#2/.code={\sseq@options@firstpass{\sseq@needstikztrue}\sseq@options@secondpass{\sseq@pgfkeysdocommand{#2}{##1}\sseq@needstikztrue}}}%
\@ifnextchar\@nil{\@gobble}{\sseq@needstikzandpass@{#1}}%
}
\pgfqkeys{/sseqpages}{needs tikz/.code=\sseq@needstikztrue}
% All of these things need tikz to draw but otherwise require no special handling.
\sseq@needstikzandpass{/sseqpages}{%
shade, blend mode, pattern, path picture, path fading, decorate, pin, label % should pin be here?
}
\sseq@needstikzandpass{/sseqpages/differential}{%
bend left, bend right, in, out, relative, looseness, in looseness, out looseness,
min distance, max distance, out min distance, out max distance, in min distance, in max distance, distance,
controls, in control, out control,
loop, loop above, loop below, loop left, loop right % maybe delete the loops and replace them with errors? It's pretty pointless to use these.
}
\sseq@needstikzandpass{/sseqpages/struct line}{%
bend left, bend right, in, out, relative, looseness, in looseness, out looseness,
min distance, max distance, out min distance, out max distance, in min distance, in max distance, distance,
controls, in control, out control,
loop, loop above, loop below, loop left, loop right % maybe delete the loops and replace them with errors? It's pretty pointless to use these.
}
% circle split/.code=\sseq@needstikzandpass,
% circle solidus/.code=\sseq@needstikzandpass,
% ellipse split/.code=\sseq@needstikzandpass,
% rectangle split/.code=\sseq@needstikzandpass,
% align/.code=\sseq@needstikzandpass,
\sseq@addtostorelist\sseq@runoffarrow@start@differential@spec{}
\sseq@addtostorelist\sseq@runoffarrow@end@differential@spec{>}
\sseq@addtostorelist\sseq@runoffarrow@start@structline@spec{...}
\sseq@addtostorelist\sseq@runoffarrow@end@structline@spec{...}
\sseq@pgfqkeysdirlist{/sseqpages/global,/sseqpages}{
run off differentials/.code args={#1-#2}{\def\sseq@runoffarrow@start@differential@spec{#1}\def\sseq@runoffarrow@end@differential@spec{#2}},
run off struct lines/.code args={#1-#2}{\def\sseq@runoffarrow@start@structline@spec{#1}\def\sseq@runoffarrow@end@structline@spec{#2}},
run off/.forward to=/sseqpages/run off differentials,
run off/.forward to=/sseqpages/run off struct lines
}
\sseq@pgfqkeysdirlist{/sseqpages/differential,/sseqpages/struct line}{
source anchor/.sseq @ second pass store in=\sseq@edgesourceanchor,
target anchor/.sseq @ second pass store in=\sseq@edgetargetanchor,
shorten >/.sseq @ second pass code={\sseq@pgfkeysdocommand{shorten >}{#1}},
shorten </.sseq @ second pass code={\sseq@pgfkeysdocommand{shorten <}{#1}},
}
\pgfqkeys{/sseqpages/differential}{
/sseqpages/differential/invisible/.sseq @ first pass code={\sseq@drawdifferentialfalse}
}
\newif\ifsseq@drawdifferential
\sseq@drawdifferentialtrue
%%%
%%% Global Keys
%%%
%%% Style options
%% Add key code to \sseq@savedoptioncode
% #1 -- a list of directories to search
% #2 -- keys
%
% This is pretty similar in basic concept to \sseq@processoptions, but instead of using the .unknown handlers to walk up the directory,
% it just tries the key in each directory in the list. I'm not actually sure anymore why it was important to do it this way, but there probably was a good reason...
%
% This is a faster and sloppier way of doing:
% \def\sseq@temp{#1}
% \pgfqkeys{/sseqpages/alwaysunknown}{#2}
% and defining an event handler: alwaysunknown/.unknown/.code={\@xp\sseq@keys@try@addtooptions\@xp{\sseq@temp}{}{\sseq@keys@unknown}
% That basically takes advantage of the pgfkeys parser but gives me back control over what to do with the parsed things.
%
% For some reason I made the probably misguided decision that that approach was too slow, even though this isn't performance
% critical code. Maybe I had a better reason for doing this that I can't remember. Instead I copied pgfkeys but deleted all the
% parts that are useless in this context, which is most of it. Occasionally bugs crop up here when it turns out I deleted a little too much.
%
% This uses a hook \sseq@addstylecodetooptions@unknown to allow the sseqs style to sift out the nonglobal keys and handle them differently.
%
% Copied with modification from /pgf/utilities/pfgkeys.code.tex
\def\sseq@addstylecodetooptions#1#2{%
\def\sseq@directorylist{#1}%
\sseq@simple@pgfkeys@parse#2,\pgfkeys@mainstop
}
\def\sseq@simple@pgfkeys@parse{\futurelet\pgfkeys@possiblerelax\sseq@simple@pgfkeys@parse@main}
\def\sseq@simple@pgfkeys@parse@main{%
\ifx\pgfkeys@possiblerelax\pgfkeys@mainstop%
\@xp\@gobble
\else%
\@xp\sseq@simple@pgfkeys@@normal
\fi%
}
\def\sseq@simple@pgfkeys@@normal#1,{%
\sseq@simple@pgfkeys@unpack#1=\pgfkeysnovalue=\pgfkeys@stop
\sseq@simple@pgfkeys@parse
}
\def\sseq@simple@pgfkeys@unpack#1=#2=#3\pgfkeys@stop{%
\pgfkeys@spdef\pgfkeyscurrentkey{#1}%
\pgfkeys@spdef\pgfkeyscurrentvalue{#2}%
\ifx\pgfkeyscurrentkey\pgfkeys@empty\else
\def\next{\@xp\sseq@keys@try@addtooptions\@xp{\sseq@directorylist}{}{\sseq@addstylecodetooptions@unknown}}%
% We deleted the general "first char syntax" handler, so we need to do our own check for the quote.
\sseq@simple@pgfkeys@checkquote#1\sseq@nil{%
\def\pgfkeyscurrentname{handle quote}%
\def\pgfkeyscurrentvalue{#1}%
}{%
\edef\pgfkeyscurrentkey{\pgfkeyscurrentkey}%
\ifx\pgfkeyscurrentkey\pgfkeys@empty
\let\next\relax
\else%
\let\pgfkeyscurrentname\pgfkeyscurrentkey
\fi
}%
\@xp\next
\fi
}
% This is a hook for the "sseqs" style.
\let\sseq@addstylecodetooptions@unknown\sseq@keys@unknown
\long\def\sseq@simple@pgfkeys@checkquote#1#2\sseq@nil{%
\ifx#1"%
\@xp\@firstoftwo
\else
\@xp\@secondoftwo
\fi
}
\def\sseq@stylelist{}
\def\sseq@clearchangestyles{}
% The basic idea here is we make a tokens list \sseq@structlinestyle and define a key "struct lines" that takes a list of keys
% and adds the keys to \sseq@structlinestyle. In order to do this, I need some special trick to delete spaces.
% The macro \sseq@setmacronospaces defined in spectralsequences.sty accomplishes this.
\def\sseq@newstyles#1#2{\def\sseq@temppath{#1}\sseq@newstyles@#2,\sseq@nil}
\def\sseq@newstyles@#1,{\sseq@newsseqstyle{\sseq@trimleadingspaces#1}\@ifnextchar\sseq@nil{\@gobble}{\sseq@newstyles@}}
\def\sseq@set@newstyle#1{\pgfqkeys{/sseqpages}{#1}\pgfqkeys{/sseqpages/global}{#1}\pgfqkeys{/sseqpages/global/default}{#1}}
% Here are two useful wrappers around addstylecodetotoks.
% #1 -- token list
% #2 -- path
% #3 -- code
\def\sseq@addstylecodetotoks#1#2#3{%
\let\sseq@savedoptioncode@store\sseq@savedoptioncode
\edef\sseq@savedoptioncode{\the#1}%
\sseq@addstylecodetooptions{#2}{#3}%
#1\@xp{\sseq@savedoptioncode}%
\let\sseq@savedoptioncode\sseq@savedoptioncode@store
}
% #1 -- macro
% #2 -- path
% #3 -- code
\def\sseq@addstylecodetomacro#1#2#3{%
\let\sseq@savedoptioncode@store\sseq@savedoptioncode
\let\sseq@savedoptioncode#1%
\sseq@addstylecodetooptions{#2}{#3}%
\let#1\sseq@savedoptioncode
\let\sseq@savedoptioncode\sseq@savedoptioncode@store
}
\def\sseq@newsseqstyle#1{%
\sseq@setmacronospaces\sseq@tempcmd{sseq@#1style}%
\edef\sseq@tempcmdb{\csname\@xp\sseq@macroname\sseq@tempcmd @page\endcsname}%
\sseq@setmacronospaces\sseq@tempcmdc{sseq@the#1style}%
\@xp\edef\sseq@tempcmdc{\@nx\the\@xp\@nx\sseq@tempcmd\@nx\the\sseq@tempcmdb}%
\@xp\newtoks\sseq@tempcmd
\@xp\newtoks\sseq@tempcmdb
\sseq@x@addto@macro\sseq@stylelist{\sseq@tempcmd{\@nx\the\sseq@tempcmd}}%
\sseq@x@addto@macro\sseq@clearchangestyles{\sseq@tempcmdb{}}%
\sseq@set@newstyle{%
#1s/.ecode={%
\@nx\sseq@addstylecodetotoks{\sseq@tempcmd}{\sseq@temppath}{##1}
\@nx\ifsseq@inprogress
\@nx\sseq@savedpaths@xadd{\@nx\sseq@style@object{\sseq@tempcmd{\@nx\the\sseq@tempcmd}}}%
\@nx\fi
},%
change #1s/.ecode={%
\@nx\ifsseq@ispageenv\@nx\else\@nx\sseq@error@nn{change-style-data}{#1}{##1}\@nx\fi
\@nx\ifsseq@hasname\@nx\else\@nx\sseq@error@nn{change-style-standalone}{#1}{##1}\@nx\fi
\@nx\sseq@addstylecodetotoks{\sseq@tempcmdb}{\sseq@temppath}{##1}
}
}%
}
\newtoks\sseq@sseqstyle
\newtoks\sseq@sseqstyle@page
\def\sseq@thesseqstyle{\the\sseq@sseqstyle\the\sseq@sseqstyle@page}
% sseqs has to be handled separately, because it must decide whether an option is a global option or not
% and handle them at different times. This makes the code a little trickier.
\def\sseq@sseqstyle@globalpart{}
\sseq@g@addto@macro\sseq@stylelist{\sseq@sseqstyle{\the\sseq@sseqstyle}}%
\sseq@g@addto@macro\sseq@clearchangestyles{\sseq@sseqstyle@page{}}%
\sseq@set@newstyle{
sseqs/.code={%
% This will get called on each key that isn't a defined global option. Then we add it to \sseq@sseqstyle to be applied
% locally to absolutely everything.
\def\sseq@addstylecodetooptions@unknown{%
\let\sseq@sseqstyle@globalpart\sseq@savedoptioncode
\edef\sseq@savedoptioncode{\the\sseq@sseqstyle}%
\sseq@keys@unknown
\sseq@sseqstyle\@xp{\sseq@savedoptioncode}%
\let\sseq@savedoptioncode\sseq@sseqstyle@globalpart
}%
\sseq@addstylecodetomacro\sseq@sseqstyle@globalpart{/sseqpages/global}{#1}%
\ifsseq@inprogress
\sseq@savedpaths@xadd{\@nx\sseq@style@object{\sseq@sseqstyle{\the\sseq@sseqstyle}}}%
\fi
% Restore hook
\let\sseq@addstylecodetooptions@unknown\sseq@keys@unknown
},%
% It's not clear to me that "change sseqs" should even exist as an option.
change sseqs/.code={%
\ifsseq@ispageenv\else\sseq@error@nn{change-style-data}{sseq}{#1}\fi
\ifsseq@hasname\else\sseq@error@nn{change-style-standalone}{sseq}{#1}\fi
\sseq@addstylecodetotoks{\sseq@sseqstyle@page}{\sseq@temppath}{#1}%
}
}
% sseq needs special handling, so is done by hand above.
%\sseq@newstyles{/sseqpages/}{sseq}% DON'T make this /global/default! Bad things will happen.
\sseq@newstyles{/sseqpages/label,/sseqpages}{edge, label, edge label, differential label, struct line label}
\sseq@newstyles{/sseqpages/class,/sseqpages}{class, permanent cycle, transient cycle, this page cycle}
\sseq@newstyles{/sseqpages/differential,/sseqpages}{differential}
\sseq@newstyles{/sseqpages/struct line,/sseqpages}{struct line, this page struct line}
\sseq@newstyles{/sseqpages/class/label}{class label, inner class label, outer class label}
\sseq@newstyles{/sseqpages/class/label/pin}{pin}
\sseq@newstyles{/sseqpages/tikz primitives}{tikz primitive}
\sseq@newstyles{/sseqpages/fit}{circle class}
\sseq@set@newstyle{sseq/.style={sseqs={#1}},change sseq/.style={change sseqs={#1}},
classes/.style={classs={#1}},change classes/.style={change classs={#1}},
circle classes/.style={circle classs={#1}},change circle classes/.style={change circle classs={#1}},
}% "class" has a nonstandard plural
\sseq@set@newstyle{
cycles/.code={\pgfkeysalso{classes={#1}}},
permanent classes/.code={\pgfkeysalso{permanent cycles={#1}}},
transient classes/.code={\pgfkeysalso{transient cycles={#1}}},
this page classes/.code={\pgfkeysalso{this page cycles={#1}}},
}%
\def\sseq@newplotstyle#1{
\sseq@setmacronospaces\sseq@tempcmd{sseq@#1style}
\sseq@setmacronospaces\sseq@tempcmdb{sseq@#1style@default}
\sseq@eval{\@nx\sseq@addtostorelist\@xp\@nx\sseq@tempcmd{\@xp\@nx\sseq@tempcmdb}}
\@xp\def\sseq@tempcmdb{}
\pgfqkeys{/sseqpages/global}{%
#1 style/.ecode={
\@nx\sseq@addstylecodetomacro{\@xp\@nx\sseq@tempcmd}{/tikz}{##1}
}
}
% Only difference here is \sseq@tempcmdb -- which puts it in the default code -- instead of \sseq@tempcmd
\pgfqkeys{/sseqpages/global/default}{%
#1 style/.ecode={
\@nx\sseq@addstylecodetomacro{\@xp\@nx\sseq@tempcmdb}{/tikz}{##1}
}
}
}
\def\sseq@newplotstyles#1{\def\sseq@temppath{#1}\sseq@newplotstyles@#1,\sseq@nil}
\def\sseq@newplotstyles@#1,{\sseq@newplotstyle{\sseq@trimleadingspaces#1}\@ifnextchar\sseq@nil{\@gobble}{\sseq@newplotstyles@}}
\sseq@newplotstyles{x tick, y tick}
%%
%%
%% Families (also called collections in code)
%%
%% These are supposed to make it easy to display / hide and change appearance of logically connected families of classes.
%% In order to allow a set of options to be given that applies uniformly to all features, we separately apply the options in each of these bins.
%%
\def\sseq@featurelist{\\{class}\\{differential}\\{structline}\\{circleclass}\\{tikzprimitive}}
\def\sseq@mapfeaturelist#1{\def\\##1{#1}\sseq@featurelist}
\def\sseq@familylist{}
\def\sseq@collections@featuretype{}
\def\sseqnewfamily#1{%
% Make five bins associated to the new family, one for each feature type. Add them to storelist with empty defaults.
\sseq@mapfeaturelist{
\@xp\sseq@setmacronospaces\csname sseq@tempcmd@##1\endcsname{sseq@user@#1@##1@style}
\@xp\sseq@setmacronospaces\csname sseq@tempcmd@##1@default\endcsname{sseq@user@#1@##1@style@default}
\sseq@eval{\@nx\sseq@addtostorelist\@xptwo\@nx\csname sseq@tempcmd@##1\endcsname{\@xptwo\@nx\csname sseq@tempcmd@##1@default\endcsname}}
\@xptwo\def\csname sseq@user@#1@##1@style@default\endcsname{}
}
% This is for deciding what set of options to apply to a feature
\@xp\sseq@setnospaces\csname sseq@tempcmd\endcsname{sseq@user@#1}
%
% A flag to decide whether to draw the family. Set/unset using "draw family" and "no family".
\@xp\sseq@addtostorelist\csname sseq@#1@maybedraw\endcsname{}
\pgfqkeys{/sseqpages/global}{%
#1 style/.ecode={%
\@nx\sseq@addstylecodetomacro\@xp\@nx\sseq@tempcmd@class{/sseqpages/class,/sseqpages/collections/class}{##1}%
\@nx\sseq@addstylecodetomacro\@xp\@nx\sseq@tempcmd@differential{/sseqpages/differential,/sseqpages/collections/differential}{##1}%
\@nx\sseq@addstylecodetomacro\@xp\@nx\sseq@tempcmd@structline{/sseqpages/struct line,/sseqpages/collections/struct line}{##1}%
\@nx\sseq@addstylecodetomacro\@xp\@nx\sseq@tempcmd@circleclass{/sseqpages/fit,/sseqpages/collections/fit}{##1}%
\@nx\sseq@addstylecodetomacro\@xp\@nx\sseq@tempcmd@tikzprimitive{/sseqpages/tikz primitives,/sseqpages/collections/tikz primitives}{##1}%
},
draw #1/.ecode = {\def\@xp\@nx\csname sseq@#1@maybedraw\endcsname{\@nx\sseq@drawtrue}},
no #1/.ecode = {\def\@xp\@nx\csname sseq@#1@maybedraw\endcsname{\@nx\sseq@drawfalse}}
}%
\pgfqkeys{/sseqpages/global/default}{%
#1 style/.ecode={%
\@nx\sseq@addstylecodetomacro\@xp\@nx\sseq@tempcmd@class@default{/sseqpages/class}{##1}%
\@nx\sseq@addstylecodetomacro\@xp\@nx\sseq@tempcmd@differential@default{/sseqpages/differential}{##1}%
\@nx\sseq@addstylecodetomacro\@xp\@nx\sseq@tempcmd@structline@default{/sseqpages/struct line}{##1}%
\@nx\sseq@addstylecodetomacro\@xp\@nx\sseq@tempcmd@circleclass@default{/sseqpages/fit}{##1}%
\@nx\sseq@addstylecodetomacro\@xp\@nx\sseq@tempcmd@tikzprimitive@default{/sseqpages/tikz primitives}{##1}%
},
draw #1/.ecode = {\def\@xp\@nx\csname sseq@#1@maybedraw@default\endcsname{\@nx\sseq@drawtrue}},
no #1/.ecode = {\def\@xp\@nx\csname sseq@#1@maybedraw@default\endcsname{\@nx\sseq@drawfalse}}
}%
%
\pgfqkeys{/sseqpages}{
#1/.ecode={
\@nx\sseq@d@addto@macro\@nx\sseq@familylist{\@nx\csname sseq@#1@maybedraw\endcsname}
\@nx\sseq@options@secondpass{
\unexpanded\@xp{\@xp\csname\sseq@tempcmd @\sseq@collections@featuretype @style\endcsname}
}
}
}
}
\def\sseq@collections@classlabels@hook{}
\def\sseq@collections@innerclasslabels@hook{}
\def\sseq@collections@outerclasslabels@hook{}
\def\sseq@collections@pins@hook{}
\def\sseq@collections@labels@hook{}
\def\sseq@collections@edgelabels@hook{}
\def\sseq@collections@differentiallabels@hook{}
\def\sseq@collections@structlinelabels@hook{}
\def\sseq@collections@setempty#1{\sseq@collections@setempty@#1,\sseq@nil}
\def\sseq@collections@setempty@#1,{
\pgfqkeys{/sseqpages/collections}{
class/#1/.code={},
differential/#1/.code={},
struct line/#1/.code={},
fit/#1/.code={},
tikz primitives/#1/.code={}
}
\@ifnextchar\sseq@nil{\@gobble}{\sseq@collections@setempty@}
}
\sseq@collections@setempty{%
classes, cycles, permanent classes, permanent cycles, transient classes, transient cycles, this page classes, this page cycles,
edges, differentials,struct lines, this page struct lines,circleclasses, tikz primitives,
labels, edge labels, differential labels, struct line labels,
class labels, inner class labels, outer class labels,pins
}