aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/htmlroff/t11.c
blob: 2e273ac4d65facd56276ec1ae925725e7d0ed9ed (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
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
#include "a.h"

/*
 * 11. Local Horizontal and Vertical Motions, and the Width Function.
 */

int
e_0(void)
{
	/* digit-width space */
	return ' ';
}

int
dv(int d)
{
	Rune sub[6];

	d += getnr(L(".dv"));
	nr(L(".dv"), d);

	runestrcpy(sub, L("<sub>"));
	sub[0] = Ult;
	sub[4] = Ugt;
	if(d < 0){
		sub[3] = 'p';
		ihtml(L(".dv"), sub);
	}else if(d > 0)
		ihtml(L(".dv"), sub);
	else
		ihtml(L(".dv"), nil);
	return 0;
}

int
e_v(void)
{
	dv(eval(getqarg()));
	return 0;
}

int
e_u(void)
{
	dv(eval(L("-0.5m")));
	return 0;
}

int
e_d(void)
{
	dv(eval(L("0.5m")));
	return 0;
}

int
e_r(void)
{
	dv(eval(L("-1m")));
	return 0;
}

int
e_h(void)
{
	getqarg();
	return 0;
}

int
e_w(void)
{
	Rune *a;
	Rune buf[40];
	static Rune zero;

	a = getqarg();
	if(a == nil){
		warn("no arg for \\w");
		a = &zero;
	}
	runesnprint(buf, sizeof buf, "%ld", runestrlen(a));
	pushinputstring(buf);
	nr(L("st"), 0);
	nr(L("sb"), 0);
	nr(L("ct"), 0);
	return 0;
}

int
e_k(void)
{
	getname();
	warn("%Ck not available", backslash);
	return 0;
}

void
t11init(void)
{
	addesc('|', e_nop, 0);
	addesc('^', e_nop, 0);
	addesc('v', e_v, 0);
	addesc('h', e_h, 0);
	addesc('w', e_w, 0);
	addesc('0', e_0, 0);
	addesc('u', e_u, 0);
	addesc('d', e_d, 0);
	addesc('r', e_r, 0);
	addesc('k', e_k, 0);
}