blob: dd1dd75b78f5dc9e3e3e6a0984dbc13e84dc24c7 [file] [log] [blame]
rscc42a1d32006-02-21 18:37:05 +00001#include "a.h"
2
3/*
4 * 11. Local Horizontal and Vertical Motions, and the Width Function.
5 */
6
7int
8e_0(void)
9{
10 /* digit-width space */
11 return ' ';
12}
13
14int
15dv(int d)
16{
17 Rune sub[6];
18
19 d += getnr(L(".dv"));
20 nr(L(".dv"), d);
21
22 runestrcpy(sub, L("<sub>"));
23 sub[0] = Ult;
24 sub[4] = Ugt;
25 if(d < 0){
26 sub[3] = 'p';
27 ihtml(L(".dv"), sub);
28 }else if(d > 0)
29 ihtml(L(".dv"), sub);
30 else
31 ihtml(L(".dv"), nil);
32 return 0;
33}
34
35int
36e_v(void)
37{
38 dv(eval(getqarg()));
39 return 0;
40}
41
42int
43e_u(void)
44{
45 dv(eval(L("-0.5m")));
46 return 0;
47}
48
49int
50e_d(void)
51{
52 dv(eval(L("0.5m")));
53 return 0;
54}
55
56int
57e_r(void)
58{
59 dv(eval(L("-1m")));
60 return 0;
61}
62
63int
64e_h(void)
65{
66 getqarg();
67 return 0;
68}
69
70int
71e_w(void)
72{
73 Rune *a;
74 Rune buf[40];
rscd0648192007-04-21 22:37:13 +000075 static Rune zero;
76
rscc42a1d32006-02-21 18:37:05 +000077 a = getqarg();
rscd0648192007-04-21 22:37:13 +000078 if(a == nil){
79 warn("no arg for \\w");
80 a = &zero;
81 }
rscc42a1d32006-02-21 18:37:05 +000082 runesnprint(buf, sizeof buf, "%ld", runestrlen(a));
83 pushinputstring(buf);
84 nr(L("st"), 0);
85 nr(L("sb"), 0);
86 nr(L("ct"), 0);
87 return 0;
88}
89
90int
91e_k(void)
92{
93 getname();
94 warn("%Ck not available", backslash);
95 return 0;
96}
97
98void
99t11init(void)
100{
101 addesc('|', e_nop, 0);
102 addesc('^', e_nop, 0);
103 addesc('v', e_v, 0);
104 addesc('h', e_h, 0);
105 addesc('w', e_w, 0);
106 addesc('0', e_0, 0);
107 addesc('u', e_u, 0);
108 addesc('d', e_d, 0);
109 addesc('r', e_r, 0);
110 addesc('k', e_k, 0);
111}
112