Repository navigation
Expand file tree
/
Copy patheef2.c
More file actions
executable file
·311 lines (268 loc) · 5.89 KB
/
Copy patheef2.c
File metadata and controls
executable file
·311 lines (268 loc) · 5.89 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
/* ELLE - Copyright 1982, 1984, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/*
* EEF2 Various functions
*/
#include "elle.h"
/* Line Handling functions */
/* EFUN: "Beginning of Line" */
f_begline()
{ e_gobol();
ed_setcur();
}
/* EFUN: "End of Line" */
f_endline()
{ e_goeol();
ed_setcur();
}
/* EFUN: "Next Line" */
/* Goes to beginning of next line */
f_nxtline()
{ return(down_bline(exp));
}
/* EFUN: "Previous Line" */
/* Goes to beginning of previous line */
f_prvline()
{ return(down_bline(-exp));
}
/* EFUN: "Down Real Line" */
f_dnrline ()
{ down_line(exp);
}
/* EFUN: "Up Real Line" */
f_uprline ()
{ down_line(-exp);
}
#if FX_OLINE
/* EFUN: "Open Line" */
f_oline()
{ register int i;
chroff savdot;
savdot = cur_dot;
if((i = exp) > 0)
do { ed_crins(); }
while(--i);
e_gosetcur(savdot);
}
#endif /*FX_OLINE*/
#if FX_DELBLINES
/* EFUN: "Delete Blank Lines" */
/* Delete blank lines around point.
*/
f_delblines()
{ register int c;
chroff dot1, dot2, oldcur;
oldcur = cur_dot;
do { e_gobwsp(); }
while ((c = e_rgetc()) == LF);
if (c != EOF)
e_gonl();
dot1 = e_dot();
if(dot1 > oldcur) return;
do { e_gofwsp(); }
while ((c = e_getc()) == LF);
if(c != EOF)
e_gobol();
dot2 = e_dot();
if(dot2 < oldcur) return;
ed_delete(dot1,dot2);
}
#endif /*FX_DELBLINES*/
#if FX_KLINE
/* EFUN: "Kill Line" */
f_kline()
{
if(exp_p)
e_goline(exp); /* Move that many lines */
/* (if 0, goes to BOL) */
else /* No arg, handle specially */
{ if(e_lblankp()) /* Is rest of line blank? */
; /* Yes, now at next line! */
else e_goeol(); /* No, go to EOL rather than NL */
}
ed_kill(cur_dot,e_dot());
e_setcur();
this_cmd = KILLCMD;
}
#endif /*FX_KLINE*/
#if FX_BKLINE
/* EFUN: "Backward Kill Line" (not EMACS) */
/* Originally an Iconographics function.
*/
f_bkline()
{
if(exp_p) exp = -exp; /* If arg, invert it */
else
{ exp = 0; /* No arg, furnish 0 */
exp_p = 1;
}
f_kline(); /* Invoke "Kill Line" */
}
#endif /*FX_BKLINE*/
#if FX_GOLINE
/* EFUN: "Goto Line" (not EMACS) (GNU goto-line) */
f_goline()
{
e_gobob();
down_bline(exp-1); /* already at line 1 */
}
#endif /*FX_GOLINE*/
down_bline(arg)
int arg;
{
if(arg)
e_goline(arg);
ed_setcur();
}
#if FX_DNRLINE || FX_UPRLINE
down_line (x)
int x;
{ register int i, res;
res = x ? e_goline(x) : 1; /* Move that many lines */
goal = 0;
if(res == 0) /* Hit buffer limits (EOF)? */
{ if(x > 0) /* Moving downwards? */
{
#if !(IMAGEN) /* If IMAGEN, do not extend!! */
if(x == 1) ed_crins(); /* Yeah, maybe extend */
else
#endif
goal = indtion(cur_dot);
goto done;
}
}
if(last_cmd == LINECMD /* If previous cmd also a line move */
&& pgoal != -1) /* and we have a previous goal col */
goal = pgoal; /* then make it the current goal */
else goal = indtion(cur_dot); /* Else invent goal from current pos */
i = inindex(e_dot(), goal); /* See # chars needed to reach goal */
if(i == -1) /* If off edge of line, */
e_goeol(); /* just move to end of this line */
else e_igoff(i); /* else move to goal. */
done: pgoal = goal;
this_cmd = LINECMD;
ed_setcur();
}
#endif /*FX_DNRLINE || FX_UPRLINE*/
/* Region Handling functions */
/* EFUN: "Set/Pop Mark" */
f_setmark()
{
mark_dot = e_dot();
mark_p = 1;
if(ev_markshow) /* If have one, show indicator */
saytoo(ev_markshow); /* that mark was set. */
}
/* EFUN: "Exchange Point and Mark" */
f_exchmark()
{ chroff tmpdot;
if(chkmark())
{ tmpdot = mark_dot;
mark_dot = cur_dot;
ed_go(tmpdot); /* Set cur_dot and go there */
}
}
/* EFUN: "Kill Region" */
f_kregion()
{
if(chkmark())
{ ed_kill(cur_dot,mark_dot); /* Will adj cur_dot, mark_dot */
e_gocur();
this_cmd = KILLCMD;
}
}
/* EFUN: "Copy Region" */
f_copreg()
{
if(chkmark())
{ e_gocur();
kill_push(e_copyn(mark_dot - cur_dot));
e_gocur();
}
}
/* EFUN: "Uppercase Region" */
f_ucreg()
{ ef_creg(0);
}
/* EFUN: "Lowercase Region" */
f_lcreg()
{ ef_creg(1);
}
ef_creg(downp)
int downp;
{
if(chkmark())
ed_case(cur_dot,mark_dot,downp);
}
#if FX_FILLREG
/* EFUN: "Fill Region" */
f_fillreg()
{ if(chkmark())
ed_fill(mark_dot,cur_dot,0);
}
#endif /*FX_FILLREG*/
/* CHKMARK() - minor utility for region-hacking functions.
* Returns TRUE if mark exists.
* Otherwise complains to user and returns 0.
*/
chkmark()
{ if(mark_p == 0)
ding("No mark!");
return(mark_p);
}
/* Paragraph functions */
#if FX_FPARA
/* EFUN: "Forward Paragraph" */
f_fpara()
{ int e_gobpa(), e_goepa();
exp_do(e_goepa, e_gobpa);
ed_setcur();
}
#endif /*FX_FPARA*/
#if FX_BPARA
/* EFUN: "Backward Paragraph" */
/* Go to beginning of paragraph.
* Skip all whitespace until text seen, then stop at beginning of
* 1st line starting with whitespace.
*/
f_bpara()
{ int e_gobpa(), e_goepa();
exp_do(e_gobpa, e_goepa);
ed_setcur();
}
#endif /*FX_BPARA*/
#if FX_MRKPARA
/* EFUN: "Mark Paragraph" */
f_mrkpara()
{
f_fpara(); /* Go to end of paragraph */
f_setmark(); /* Put mark there */
f_bpara(); /* Then back to start of paragraph */
}
#endif /*FX_MRKPARA*/
#if FX_FILLPARA
/* EFUN: "Fill Paragraph" */
f_fillpara()
{
chroff savloc, endloc;
savloc = cur_dot;
#if ICONOGRAPHICS
e_getc(); /* DON'T go to next para if at end */
e_gobpa(); /* of this one!! */
#endif /*ICONOGRAPHICS*/
e_goepa(); /* Go to end of parag */
if(e_rgetc() != LF) /* If last char EOL, back over it. */
e_getc();
endloc = e_dot(); /* Remember where end is */
e_gobpa(); /* Go to beg of parag */
#if ICONOGRAPHICS
kill_push(e_copyn(endloc - e_dot ()));
/* put old version on kill ring */
#endif /*ICONOGRAPHICS*/
e_fwsp(); /* Move over initial whitespace */
ed_fill(e_dot(), endloc, 0); /* Fill this region, return to dot */
}
#endif /*FX_FILLPARA*/