summaryrefslogtreecommitdiff
path: root/tex/context/base/meta-tex.mkiv
blob: e35f9538567bfeebcc216f7d355987225713c5b6 (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
67
68
69
70
71
72
%D \module
%D   [       file=meta-tex,
%D        version=2006.06.07,
%D          title=\CONTEXT\ Support Macros,
%D       subtitle=\METAPOST\ fast text insertion,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright=\PRAGMA]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\unprotect

% Ok, we support this in MkIV because Mojca kept the pressure on. It
% looks a bit like a hack.

\long\def\startTeXtexts#1\stopTeXtexts
  {#1}

\long\def\TeXtext
  {\dosingleempty\doTeXtext}

\long\def\doTeXtext[#1]#2#3% contrary to mkii we don't process yet but we do expand
  {\long\setxvalue{@@st@@::#2}{\noexpand\dodoTeXtext{#1}{#3}}}

\long\def\dodoTeXtext#1#2%
  {\begingroup
   \setbox\nextbox\hbox{\executeifdefined{textext@@#1}\firstofoneargument{#2}}%
   \executeifdefined{textext::#1}{\getvalue{textext::depth}}%
   \box\nextbox
   \endgroup}

\def\getTeXtext#1%
  {\getvalue{@@st@@::#1}}

\setvalue{textext::d}{\setbox\nextbox\hbox{\lower\dp\nextbox\box\nextbox}}  % unchecked
\setvalue{textext::n}{}                                                     % unchecked

\setvalue  {textext::depth}{\getvalue{textext::d}}
\setvalue{textext::nodepth}{\getvalue{textext::n}}

% \definetextext[framed]{\framed}
%
% \startMPcode
%     draw \sometxt[framed]{black} rotated 45 ;
% \stopMPcode

\unexpanded\def\definetextext[#1]#2{\setvalue{@@st@@[#1]}{#2}\setvalue{@@st@@[#1] }{#2}} % we don't grab spaces after [#1]

\long\def\sometxt#1#{\dosometxt{#1}}  % grab optional [args]

\long\def\dosometxt#1#2%
  {textext.drt("\ifcsname @@st@@#1\endcsname\csname @@st@@#1\endcsname{#2}\else#2\fi")}

% Best use the mp macro instead since it provides positioning.
%
% \startuseMPgraphic{testgraphic}
% draw \sometxt{\ruledhbox{\strut hans hagen}} scaled 3;
% % draw textext.drt("\ruledhbox{\strut hans hagen}") scaled 3;
% % draw textext.dlft("\ruledhbox{\strut hans hagen}") scaled 3;
% % draw textext.lft("\ruledhbox{\strut hans hagen}") scaled 3;
% draw llcorner currentpicture -- urcorner currentpicture withcolor yellow;
% draw lrcorner currentpicture -- ulcorner currentpicture withcolor yellow;
% draw boundingbox currentpicture withcolor blue ;
% draw origin withcolor red withpen pencircle scaled 1pt;
% \stopuseMPgraphic
%
% {\showstruts\useMPgraphic{testgraphic}}

\protect \endinput