xref: /inferno-os/appl/acme/graph.b (revision 37da2899f40661e3e9631e497da8dc59b971cbd0)
1implement Graph;
2
3include "common.m";
4
5sys : Sys;
6drawm : Draw;
7dat : Dat;
8gui : Gui;
9utils : Utils;
10
11Image, Point, Rect, Font, Display : import drawm;
12black, white, display : import gui;
13error : import utils;
14
15refp : ref Point;
16pixarr : array of byte;
17
18init(mods : ref Dat->Mods)
19{
20	sys = mods.sys;
21	drawm = mods.draw;
22	dat = mods.dat;
23	gui = mods.gui;
24	utils = mods.utils;
25
26	refp = ref Point;
27	refp.x = refp.y = 0;
28}
29
30charwidth(f : ref Font, c : int) : int
31{
32	s : string = "z";
33
34	s[0] = c;
35	return f.width(s);
36}
37
38strwidth(f : ref Font, s : string) : int
39{
40	return f.width(s);
41}
42
43balloc(r : Rect, c : Draw->Chans, col : int) : ref Image
44{
45	im := display.newimage(r, c, 0, col);
46	if (im == nil)
47		error("failed to get new image");
48	return im;
49}
50
51draw(d : ref Image, r : Rect, s : ref Image, m : ref Image, p : Point)
52{
53	d.draw(r, s, m, p);
54}
55
56stringx(d : ref Image, p : Point, f : ref Font, s : string, c : ref Image)
57{
58	d.text(p, c, (0, 0), f, s);
59}
60
61cursorset(p : Point)
62{
63	gui->cursorset(p);
64}
65
66cursorswitch(c : ref Dat->Cursor)
67{
68	gui->cursorswitch(c);
69}
70
71binit()
72{
73}
74
75bflush()
76{
77}
78
79berror(s : string)
80{
81	error(s);
82}
83