xref: /plan9/sys/src/cmd/samterm/samterm.h (revision 73e742d79f6b0cfc24f3b01d7ade790955db63c2)
1 #define	SAMTERM
2 
3 #define	RUNESIZE	sizeof(Rune)
4 #define	MAXFILES	256
5 #define	READBUFSIZE 8192
6 #define	NL	5
7 
8 enum{
9 	Up,
10 	Down
11 };
12 
13 typedef struct Text	Text;
14 typedef struct Section	Section;
15 typedef struct Rasp	Rasp;
16 typedef struct Readbuf Readbuf;
17 
18 struct Section
19 {
20 	long	nrunes;
21 	Rune	*text;		/* if null, we haven't got it */
22 	Section	*next;
23 };
24 
25 struct Rasp
26 {
27 	long	nrunes;
28 	Section	*sect;
29 };
30 
31 #define	Untagged	((ushort)65535)
32 
33 struct Text
34 {
35 	Rasp	rasp;
36 	short	nwin;
37 	short	front;		/* input window */
38 	ushort	tag;
39 	char	lock;
40 	Flayer	l[NL];		/* screen storage */
41 };
42 
43 struct Readbuf
44 {
45 	short	n;					/* # bytes in buf */
46 	uchar	data[READBUFSIZE];		/* data bytes */
47 };
48 
49 enum Resource
50 {
51 	RHost,
52 	RKeyboard,
53 	RMouse,
54 	RPlumb,
55 	RResize,
56 	NRes,
57 };
58 
59 extern Text	**text;
60 extern uchar	**name;
61 extern ushort	*tag;
62 extern int	nname;
63 extern int	mname;
64 extern Cursor	bullseye;
65 extern Cursor	deadmouse;
66 extern Cursor	lockarrow;
67 extern Cursor	*cursor;
68 extern Flayer	*which;
69 extern Flayer	*work;
70 extern Text	cmd;
71 extern Rune	*scratch;
72 extern long	nscralloc;
73 extern char	hostlock;
74 extern char	hasunlocked;
75 extern long	snarflen;
76 extern Mousectl* mousectl;
77 extern Keyboardctl* keyboardctl;
78 extern Mouse*	mousep;
79 extern long	modified;
80 extern int	maxtab;
81 extern Readbuf	hostbuf[2];	/* double buffer; it's synchronous communication */
82 extern Readbuf	plumbbuf[2];	/* double buffer; it's synchronous communication */
83 extern Channel *plumbc;
84 extern Channel *hostc;
85 extern int	hversion;
86 extern int	plumbfd;
87 extern int	exiting;
88 extern int	autoindent;
89 
90 Rune	*gettext(Flayer*, long, ulong*);
91 void	*alloc(ulong n);
92 
93 void	iconinit(void);
94 void	getscreen(int, char**);
95 void	initio(void);
96 void	setlock(void);
97 void	outcmd(void);
98 void	rinit(Rasp*);
99 void	startnewfile(int, Text*);
100 void	getmouse(void);
101 void	mouseunblock(void);
102 void	kbdblock(void);
103 void	extstart(void);
104 void	hoststart(void);
105 int	plumbstart(void);
106 int	button(int but);
107 int	load(char*, int);
108 int	waitforio(void);
109 int	rcvchar(void);
110 int	getch(void);
111 int	kbdchar(void);
112 int	qpeekc(void);
113 void	cut(Text*, int, int, int);
114 void	paste(Text*, int);
115 void	snarf(Text*, int);
116 int	center(Flayer*, long);
117 int	xmenuhit(int, Menu*);
118 void	buttons(int);
119 int	getr(Rectangle*);
120 void	current(Flayer*);
121 void	duplicate(Flayer*, Rectangle, Font*, int);
122 void	startfile(Text*);
123 void	panic(char*);
124 void	panic1(Display*, char*);
125 void	closeup(Flayer*);
126 void	Strgrow(Rune**, long*, int);
127 int	RESIZED(void);
128 void	resize(void);
129 void	rcv(void);
130 void	type(Flayer*, int);
131 void	menu2hit(void);
132 void	menu3hit(void);
133 void	scroll(Flayer*, int);
134 void	hcheck(int);
135 void	rclear(Rasp*);
136 int	whichmenu(int);
137 void	hcut(int, long, long);
138 void	horigin(int, long);
139 void	hgrow(int, long, long, int);
140 int	hdata(int, long, uchar*, int);
141 int	hdatarune(int, long, Rune*, int);
142 Rune	*rload(Rasp*, ulong, ulong, ulong*);
143 void	menuins(int, uchar*, Text*, int, int);
144 void	menudel(int);
145 Text	*sweeptext(int, int);
146 void	setpat(char*);
147 void	scrdraw(Flayer*, long tot);
148 int	rcontig(Rasp*, ulong, ulong, int);
149 int	rmissing(Rasp*, ulong, ulong);
150 void	rresize(Rasp *, long, long, long);
151 void	rdata(Rasp*, long, long, Rune*);
152 void	rclean(Rasp*);
153 void	scrorigin(Flayer*, int, long);
154 long	scrtotal(Flayer*);
155 void	flnewlyvisible(Flayer*);
156 char	*rcvstring(void);
157 void	Strcpy(Rune*, Rune*);
158 void	Strncpy(Rune*, Rune*, long);
159 void	flushtyping(int);
160 void	dumperrmsg(int, int, int, int);
161 int	screensize(int*,int*);
162 void	getmouse(void);
163 
164 #include "mesg.h"
165 
166 void	outTs(Tmesg, int);
167 void	outT0(Tmesg);
168 void	outTl(Tmesg, long);
169 void	outTslS(Tmesg, int, long, Rune*);
170 void	outTsll(Tmesg, int, long, long);
171 void	outTsl(Tmesg, int, long);
172 void	outTsv(Tmesg, int, vlong);
173 void	outTv(Tmesg, vlong);
174 void	outstart(Tmesg);
175 void	outcopy(int, uchar*);
176 void	outshort(int);
177 void	outlong(long);
178 void	outvlong(vlong);
179 void	outsend(void);
180