-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathSetReplaceStyleData.m
64 lines (49 loc) · 2.53 KB
/
SetReplaceStyleData.m
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
Package["SetReplace`"]
PackageImport["GeneralUtilities`"]
PackageExport["SetReplaceStyleData"]
PackageExport["WolframPhysicsProjectStyleData"]
(* Documentation *)
SetUsage @ "
SetReplaceStyleData[] yields an association describing default styles used in SetReplace.
SetReplaceStyleData[theme$] gives styles for a particular theme$.
SetReplaceStyleData[plotType$] gives styles for a particular plotType$.
SetReplaceStyleData[plotType$, element$] gives a value for a particular element$ of plotType$.
SetReplaceStyleData[theme$, plotType$, element$] gives a value for the element$ of plotType$ in theme$.
";
SyntaxInformation[SetReplaceStyleData] = {"ArgumentsPattern" -> {theme_., group_., element_.}};
$styleGroupNames = Keys[$styleNames];
$styleElementNames = Catenate[Keys /@ Values @ $styleNames];
With[{
themesAndGroups = Join[$SetReplacePlotThemes, $styleGroupNames],
groupsAndElements = Join[$styleGroupNames, $styleElementNames],
elements = $styleElementNames},
FE`Evaluate[FEPrivate`AddSpecialArgCompletion[
"SetReplaceStyleData" -> {themesAndGroups, groupsAndElements, elements}]]];
(* Implementation *)
(* Evaluate needed to get values for PackageScope symbols loaded after style.m *)
SetReplaceStyleData[theme : Alternatives @@ $SetReplacePlotThemes : $lightTheme] :=
Map[Evaluate, $styleNames /. style[theme], {2}];
SetReplaceStyleData[
theme : Alternatives @@ $SetReplacePlotThemes : $lightTheme,
group : Alternatives @@ $styleGroupNames] :=
Evaluate /@ ($styleNames[group] /. style[theme]);
SetReplaceStyleData[
theme : Alternatives @@ $SetReplacePlotThemes : $lightTheme,
group : Alternatives @@ $styleGroupNames,
element_] /; MemberQ[Keys[$styleNames[group]], element] :=
$styleNames[group][element] /. style[theme];
SetReplaceStyleData[args___] /;
!Developer`CheckArgumentCount[SetReplaceStyleData[args], 0, 3] := (
0 /; False
);
SetReplaceStyleData::invalidArg =
"The arguments in `1` should be a style theme (optional), a style group, and a style element (optional).";
expr : SetReplaceStyleData[RepeatedNull[_, 3]] := (
Message[SetReplaceStyleData::invalidArg, Defer[expr]];
0 /; False
);
(* for compatibility reasons we preserve WolframPhysicsProjectStyleData *)
SetUsage[WolframPhysicsProjectStyleData, "WolframPhysicsProjectStyleData is deprecated. Use SetReplaceStyleData."];
SyntaxInformation[WolframPhysicsProjectStyleData] = SyntaxInformation[SetReplaceStyleData];
Options[WolframPhysicsProjectStyleData] = Options[SetReplaceStyleData];
WolframPhysicsProjectStyleData = SetReplaceStyleData;