blob: 8255348dcc905413f4e4c0aa8a81aa9128dc0cad (
plain)
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
|
%
% CoDi: Commutative Diagrams for TeX
% Copyright (c) 2015-2023 Paolo Brasolin <paolo.brasolin@gmail.com>
% SPDX-License-Identifier: MIT
%
% This file is part of CoDi 1.1.0, released on 2023/08/23 under MIT license.
%
% εκτροπή • (ektropí)
% 1. diversion
% 2. deflection
% 3. aberration
% Ektropi is a mechanism to hijack the /tikz/.unknown handler.
% It allows the addition of maximum priority paths in the key finding algorithm.
% The diversions are globally scoped, cumulative and removable.
\usetikzlibrary{commutative-diagrams.koinos}
\kDStoreCatcodeOf @
\catcode`@=11
%==[ handler restoring procedure ]==============================================
% The default handler's code is backed up as a token list at load time.
% NOTE: this has strong implications on loading order!
\newtoks\kDEktropiDefaultToksBackup
\expandafter\expandafter
\expandafter\kDEktropiDefaultToksBackup
\expandafter\expandafter
\expandafter{\csname pgfk@/tikz/.unknown/.@body\endcsname}
\def\kDEktropiRestore{
% Restore handler body.
\def\kDAct{\pgfkeyssetvalue{/tikz/.unknown/.@body}}
\expandafter\kDAct\expandafter{\the\kDEktropiDefaultToksBackup}
% Restore handler macro.
% NOTE: #s are doubled since we're inside \kDAct helper.
\def\kDAct{\long\def\kDAct####1\pgfeov}
\expandafter\kDAct\expandafter{\the\kDEktropiDefaultToksBackup}
\pgfkeyslet{/tikz/.unknown/.@cmd}\kDAct
}
% This key is the user interface. Self explanatory.
\pgfkeys{/ektropi/restore/.code={\kDEktropiRestore}}
%==[ handler hacking procedure ]================================================
% This key is the user interface. It wraps the /tikz/.unknown handler code
% with a conditional that executes it only if the unknown key retrieval
% fails inside the path passed to /ektropi/add.
\pgfkeys{/ektropi/add/.style={
/tikz/.unknown/.add code=
{
\let\tikz@key\pgfkeyscurrentname
\pgfkeys{#1/\tikz@key/.try={##1}}
\ifpgfkeyssuccess\else
}{
\fi
}
}
}
\kDRestoreCatcodeOf @
|