xref: /plan9/sys/src/cmd/sam/mesg.h (revision 219b2ee8daee37f4aad58d63f21287faa8e4ffdc)
1 #define	VERSION	0
2 
3 #define	TBLOCKSIZE 512		  /* largest piece of text sent to terminal */
4 #define	DATASIZE  (UTFmax*TBLOCKSIZE+30) /* ... including protocol header stuff */
5 #define	SNARFSIZE 4096		/* maximum length of exchanged snarf buffer */
6 /*
7  * Messages originating at the terminal
8  */
9 typedef enum Tmesg
10 {
11 	Tversion,	/* version */
12 	Tstartcmdfile,	/* terminal just opened command frame */
13 	Tcheck,		/* ask host to poke with Hcheck */
14 	Trequest,	/* request data to fill a hole */
15 	Torigin,	/* gimme an Horigin near here */
16 	Tstartfile,	/* terminal just opened a file's frame */
17 	Tworkfile,	/* set file to which commands apply */
18 	Ttype,		/* add some characters, but terminal already knows */
19 	Tcut,
20 	Tpaste,
21 	Tsnarf,
22 	Tstartnewfile,	/* terminal just opened a new frame */
23 	Twrite,		/* write file */
24 	Tclose,		/* terminal requests file close; check mod. status */
25 	Tlook,		/* search for literal current text */
26 	Tsearch,	/* search for last regular expression */
27 	Tsend,		/* pretend he typed stuff */
28 	Tdclick,	/* double click */
29 	Tstartsnarf,	/* initiate snarf buffer exchange */
30 	Tsetsnarf,	/* remember string in snarf buffer */
31 	Tack,		/* acknowledge Hack */
32 	Texit,		/* exit */
33 	TMAX,
34 }Tmesg;
35 /*
36  * Messages originating at the host
37  */
38 typedef enum Hmesg
39 {
40 	Hversion,	/* version */
41 	Hbindname,	/* attach name[0] to text in terminal */
42 	Hcurrent,	/* make named file the typing file */
43 	Hnewname,	/* create "" name in menu */
44 	Hmovname,	/* move file name in menu */
45 	Hgrow,		/* insert space in rasp */
46 	Hcheck0,	/* see below */
47 	Hcheck,		/* ask terminal to check whether it needs more data */
48 	Hunlock,	/* command is finished; user can do things */
49 	Hdata,		/* store this data in previously allocated space */
50 	Horigin,	/* set origin of file/frame in terminal */
51 	Hunlockfile,	/* unlock file in terminal */
52 	Hsetdot,	/* set dot in terminal */
53 	Hgrowdata,	/* Hgrow + Hdata folded together */
54 	Hmoveto,	/* scrolling, context search, etc. */
55 	Hclean,		/* named file is now 'clean' */
56 	Hdirty,		/* named file is now 'dirty' */
57 	Hcut,		/* remove space from rasp */
58 	Hsetpat,	/* set remembered regular expression */
59 	Hdelname,	/* delete file name from menu */
60 	Hclose,		/* close file and remove from menu */
61 	Hsetsnarf,	/* remember string in snarf buffer */
62 	Hsnarflen,	/* report length of implicit snarf */
63 	Hack,		/* request acknowledgement */
64 	Hexit,
65 	HMAX,
66 }Hmesg;
67 typedef struct Header{
68 	uchar	type;		/* one of the above */
69 	uchar	count0;		/* low bits of data size */
70 	uchar	count1;		/* high bits of data size */
71 	uchar	data[1];	/* variable size */
72 }Header;
73 /*
74  * File transfer protocol schematic, a la Holzmann
75  *
76  *	proc h
77  *	{	pvar n = 0;
78  *		queue h[4];
79  *
80  *		do
81  *		:: (n <  N)  -> n++; t!Hgrow
82  *		:: (n == N)  -> n++; t!Hcheck0
83  *		:: h?Trequest -> t!Hdata
84  *		:: h?Tcheck  -> t!Hcheck
85  *		od
86  *	}
87  *	proc t
88  *	{	queue t[4];
89  *		do
90  *		:: t?Hgrow -> h!Trequest
91  *		:: t?Hdata -> skip
92  *		:: t?Hcheck0 -> h!Tcheck
93  *		:: t?Hcheck ->
94  *			if
95  *			:: break
96  *			:: h!Trequest; h!Tcheck
97  *			fi
98  *		od
99  *	}
100  */
101