samterm.h - sam - An updated version of the sam text editor.
(HTM) git clone git://vernunftzentrum.de/sam.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
samterm.h (5418B)
---
1 /* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
2 #define SAMTERM
3
4 #define RUNESIZE sizeof(wchar_t)
5 #define MAXFILES 256
6 #define NL 5
7
8 enum{
9 Cescape = Csysmax + 1, /* highlight recently typed text */
10 Cscrolldown, /* scroll file down by screen */
11 Cscrollup, /* scroll file up by screen */
12 Cscrolldownline, /* scroll file down by line */
13 Cscrollupline, /* scroll file up by line */
14 Cjump, /* jump to/from command file */
15 Ccharright, /* move dot right by character */
16 Ccharleft, /* move dot left by character */
17 Clinedown, /* move dot down by line */
18 Clineup, /* move dot up by line */
19 Cdelword, /* delete word to left of dot */
20 Cdelbol, /* delete to beginning of line */
21 Cdelbs, /* delete character to left of dot */
22 Cdel, /* delete character to right of dot */
23 Csnarf, /* snarf dot */
24 Ccut, /* cut dot */
25 Cpaste, /* paste from snarf buffer */
26 Cexchange, /* exchange snarf buffer with OS */
27 Ceol, /* move to beginning of line */
28 Cbol, /* move to end of line */
29 Ctab, /* insert a possibly expanded tab */
30 Csend, /* send a command to the editor */
31 Cwrite, /* write the current file */
32 Clook, /* literal search */
33 Csearch, /* search for regex again */
34 Cmax /* invalid command */
35 };
36
37 enum{
38 Up,
39 Down
40 };
41
42 typedef struct Text Text;
43 typedef struct Section Section;
44 typedef struct Rasp Rasp;
45
46 struct Section
47 {
48 int64_t nrunes;
49 wchar_t *text; /* if null, we haven't got it */
50 Section *next;
51 };
52
53 struct Rasp
54 {
55 int64_t nrunes;
56 Section *sect;
57 };
58
59 #define Untagged ((uint16_t)65535)
60
61 struct Text
62 {
63 Rasp rasp;
64 int16_t nwin;
65 int16_t front; /* input window */
66 uint16_t tag;
67 char lock;
68 Flayer l[NL]; /* screen storage */
69 };
70
71 enum Resource
72 {
73 Eextern = 0x08,
74 Ehost = 0x04,
75 RHost = Ehost,
76 RExtern = Eextern,
77 RKeyboard = Ekeyboard,
78 RMouse = Emouse
79 };
80
81 extern Text *text[];
82 extern uint8_t *name[];
83 extern uint16_t tag[];
84 extern int nname;
85 extern unsigned int cursor;
86 extern Flayer *which;
87 extern Flayer *work;
88 extern Text cmd;
89 extern wchar_t *scratch;
90 extern int64_t nscralloc;
91 extern char lock;
92 extern bool hasunlocked;
93 extern int64_t snarflen;
94 extern Mouse mouse;
95 extern bool modified;
96 extern bool followfocus;
97
98 wchar_t *stgettext(Flayer*, int64_t, uint64_t*);
99 void *alloc(uint64_t n);
100
101 void iconinit(void);
102 void getscreen(int, char**);
103 void initio(void);
104 void setlock(void);
105 void outcmd(void);
106 void rinit(Rasp*);
107 void startnewfile(int, Text*);
108 void cursorset(Point);
109 void getmouse(void);
110 void mouseunblock(void);
111 void kbdblock(void);
112 int button(int but);
113 int waitforio(void);
114 int rcvchar(void);
115 int getch(void);
116 Keystroke qpeekc(void);
117 Keystroke kbdchar(void);
118 void mouseexit(void);
119 void cut(Text*, int, bool, bool);
120 void paste(Text*, int);
121 void snarf(Text*, int);
122 int center(Flayer*, int64_t);
123 int xmenuhit(int, Menu*);
124 void buttons(int);
125 int getr(Rectangle*);
126 void current(Flayer*);
127 void duplicate(Flayer*, Rectangle, XftFont*, int);
128 void startfile(Text*);
129 void panic(char*);
130 void closeup(Flayer*);
131 void Strgrow(wchar_t**, int64_t*, int);
132 int RESHAPED(void);
133 void reshape(void);
134 void rcv(void);
135 void type(Flayer*);
136 void menu2hit(void);
137 void menu3hit(void);
138 void scroll(Flayer*, int, int);
139 void hcheck(int);
140 void rclear(Rasp*);
141 int whichmenu(int);
142 void hcut(int, int64_t, int64_t);
143 void horigin(int, int64_t, Flayer *);
144 void hgrow(int, int64_t, int64_t, bool);
145 int hdata(int, int64_t, uint8_t*, int);
146 int hdatarune(int, int64_t, wchar_t*, int);
147 wchar_t *rload(Rasp*, uint64_t, uint64_t, uint64_t*);
148 void menuins(int, uint8_t*, Text*, int, int);
149 void menudel(int);
150 Text *sweeptext(int, int);
151 void setpat(char*);
152 bool haspat(void);
153 void scrdraw(Flayer*, int64_t tot);
154 int rcontig(Rasp*, uint64_t, uint64_t, bool);
155 int rmissing(Rasp*, uint64_t, uint64_t);
156 void rresize(Rasp *, int64_t, int64_t, int64_t);
157 void rdata(Rasp*, int64_t, int64_t, wchar_t*);
158 void rclean(Rasp*);
159 void scrorigin(Flayer*, int, int64_t);
160 int64_t scrtotal(Flayer*);
161 void flnewlyvisible(Flayer*);
162 char *rcvstring(void);
163 void Strcpy(wchar_t*, wchar_t*);
164 void Strncpy(wchar_t*, wchar_t*, int64_t);
165 void flushtyping(bool);
166 void dumperrmsg(int, int, int, int);
167 int screensize(int*,int*);
168
169 #include "../sam/mesg.h"
170
171 void outTs(Tmesg, int);
172 void outT0(Tmesg);
173 void outTl(Tmesg, int64_t);
174 void outTslS(Tmesg, int, int64_t, wchar_t*);
175 void outTslll(Tmesg, int, int64_t, int64_t, int64_t);
176 void outTsll(Tmesg, int, int64_t, int64_t);
177 void outTsl(Tmesg, int, int64_t);
178 void outTv(Tmesg, void*);
179 void outstart(Tmesg);
180 void outcopy(int, uint8_t*);
181 void outshort(int);
182 void outlong(int64_t);
183 void outsend(void);
184 int getlayer(const Flayer *l, const Text *t);
185 void loadrcfile(FILE *);
186 void installdefaultbindings(void);
187 void installdefaultchords(void);