Lines 45-56
Link Here
|
45 |
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
45 |
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
46 |
*/ |
46 |
*/ |
47 |
|
47 |
|
48 |
static int is_letter __P((int)); |
48 |
static int is_letter __P((char)); |
49 |
static void nextword __P((int *, int *, int, int)); |
49 |
static void nextword __P((int *, int *, int, int)); |
50 |
static int linestart __P((int)); |
50 |
static int linestart __P((int)); |
51 |
static int lineend __P((int)); |
51 |
static int lineend __P((int)); |
52 |
static int rem __P((int, int , int , int , int , char *, int)); |
52 |
static int rem __P((int, int, int, int, int, char *, int)); |
53 |
static int eq __P((int, int )); |
53 |
static int eq __P((int, int)); |
54 |
static int MarkScrollDownDisplay __P((int)); |
54 |
static int MarkScrollDownDisplay __P((int)); |
55 |
static int MarkScrollUpDisplay __P((int)); |
55 |
static int MarkScrollUpDisplay __P((int)); |
56 |
|
56 |
|
Lines 69-144
Link Here
|
69 |
int pastefont = 1; |
69 |
int pastefont = 1; |
70 |
#endif |
70 |
#endif |
71 |
|
71 |
|
72 |
struct LayFuncs MarkLf = |
72 |
struct LayFuncs MarkLf = { |
73 |
{ |
73 |
MarkProcess, |
74 |
MarkProcess, |
74 |
MarkAbort, |
75 |
MarkAbort, |
75 |
MarkRedisplayLine, |
76 |
MarkRedisplayLine, |
76 |
DefClearLine, |
77 |
DefClearLine, |
77 |
MarkRewrite, |
78 |
MarkRewrite, |
78 |
DefResize, |
79 |
DefResize, |
79 |
DefRestore, |
80 |
DefRestore, |
80 |
0 |
81 |
0 |
|
|
82 |
}; |
81 |
}; |
83 |
|
82 |
|
84 |
int join_with_cr = 0; |
83 |
int join_with_cr = 0; |
85 |
int compacthist = 0; |
84 |
int compacthist = 0; |
86 |
|
85 |
|
87 |
unsigned char mark_key_tab[256]; /* this array must be initialised first! */ |
86 |
unsigned char mark_key_tab[256]; /* this array must be initialised first! */ |
88 |
|
87 |
|
89 |
static struct markdata *markdata; |
88 |
static struct markdata *markdata; |
90 |
|
89 |
|
91 |
|
|
|
92 |
/* |
90 |
/* |
93 |
* VI like is_letter: 0 - whitespace |
91 |
* VI like is_letter: 0 - whitespace |
94 |
* 1 - letter |
92 |
* 1 - letter |
95 |
* 2 - other |
93 |
* 2 - other |
96 |
*/ |
94 |
*/ |
97 |
static int is_letter(c) |
95 |
static int |
98 |
char c; |
96 |
is_letter(char c) |
99 |
{ |
97 |
{ |
100 |
if ((c >= 'a' && c <= 'z') || |
98 |
if ((c >= 'a' && c <= 'z') || |
101 |
(c >= 'A' && c <= 'Z') || |
99 |
(c >= 'A' && c <= 'Z') || |
102 |
(c >= '0' && c <= '9') || |
100 |
(c >= '0' && c <= '9') || |
103 |
c == '_' || c == '.' || |
101 |
c == '_' || c == '.' || |
104 |
c == '@' || c == ':' || |
102 |
c == '@' || c == ':' || |
105 |
c == '%' || c == '!' || |
103 |
c == '%' || c == '!' || |
106 |
c == '-' || c == '+') |
104 |
c == '-' || c == '+') |
107 |
/* thus we can catch email-addresses as a word :-) */ |
105 |
/* thus we can catch email-addresses as a word :-) */ |
108 |
return 1; |
106 |
return 1; |
109 |
else if (c != ' ') |
107 |
else if (c != ' ') |
110 |
return 2; |
108 |
return 2; |
111 |
return 0; |
109 |
return 0; |
112 |
} |
110 |
} |
113 |
|
111 |
|
114 |
static int |
112 |
static int |
115 |
linestart(y) |
113 |
linestart(int y) |
116 |
int y; |
|
|
117 |
{ |
114 |
{ |
118 |
register int x; |
115 |
register int x; |
119 |
register unsigned char *i; |
116 |
register unsigned char *i; |
120 |
|
117 |
|
121 |
for (x = markdata->left_mar, i = WIN(y)->image + x; x < fore->w_width - 1; x++) |
118 |
for (x = markdata->left_mar, i = WIN(y)->image + x; x < fore->w_width - 1; x++) |
122 |
if (*i++ != ' ') |
119 |
if (*i++ != ' ') |
123 |
break; |
120 |
break; |
124 |
if (x == fore->w_width - 1) |
121 |
if (x == fore->w_width - 1) |
125 |
x = markdata->left_mar; |
122 |
x = markdata->left_mar; |
126 |
return x; |
123 |
return x; |
127 |
} |
124 |
} |
128 |
|
125 |
|
129 |
static int |
126 |
static int |
130 |
lineend(y) |
127 |
lineend(int y) |
131 |
int y; |
|
|
132 |
{ |
128 |
{ |
133 |
register int x; |
129 |
register int x; |
134 |
register unsigned char *i; |
130 |
register unsigned char *i; |
135 |
|
131 |
|
136 |
for (x = markdata->right_mar, i = WIN(y)->image + x; x >= 0; x--) |
132 |
for (x = markdata->right_mar, i = WIN(y)->image + x; x >= 0; x--) |
137 |
if (*i-- != ' ') |
133 |
if (*i-- != ' ') |
138 |
break; |
134 |
break; |
139 |
if (x < 0) |
135 |
if (x < 0) |
140 |
x = markdata->left_mar; |
136 |
x = markdata->left_mar; |
141 |
return x; |
137 |
return x; |
142 |
} |
138 |
} |
143 |
|
139 |
|
144 |
/* |
140 |
/* |
Lines 149-198
Link Here
|
149 |
static int |
145 |
static int |
150 |
nextchar(int *xp, int *yp, int direction, char target, int num) |
146 |
nextchar(int *xp, int *yp, int direction, char target, int num) |
151 |
{ |
147 |
{ |
152 |
int width; /* width of the current window. */ |
148 |
int width; /* width of the current window. */ |
153 |
int x; /* x coordinate of the current cursor position. */ |
149 |
int x; /* x coordinate of the current cursor position. */ |
154 |
int step; /* amount to increment x (+1 or -1) */ |
150 |
int step; /* amount to increment x (+1 or -1) */ |
155 |
int adjust; /* Final adjustment of cursor position. */ |
151 |
int adjust; /* Final adjustment of cursor position. */ |
156 |
char *displayed_line; /* Line in which search takes place. */ |
152 |
char *displayed_line; /* Line in which search takes place. */ |
157 |
|
153 |
|
158 |
debug("nextchar\n"); |
154 |
debug("nextchar\n"); |
159 |
|
155 |
|
160 |
x = *xp; |
156 |
x = *xp; |
161 |
step = 1; |
157 |
step = 1; |
162 |
adjust = 0; |
158 |
adjust = 0; |
163 |
width = fore->w_width; |
159 |
width = fore->w_width; |
164 |
displayed_line = (char *)WIN(*yp) -> image; |
160 |
displayed_line = (char *)WIN(*yp)->image; |
165 |
|
161 |
|
166 |
switch(direction) { |
162 |
switch (direction) { |
167 |
case 't': |
163 |
case 't': |
168 |
adjust = -1; /* fall through */ |
164 |
adjust = -1; /* fall through */ |
169 |
case 'f': |
165 |
case 'f': |
170 |
step = 1; |
166 |
step = 1; |
171 |
break; |
167 |
break; |
172 |
case 'T': |
168 |
case 'T': |
173 |
adjust = 1; /* fall through */ |
169 |
adjust = 1; /* fall through */ |
174 |
case 'F': |
170 |
case 'F': |
175 |
step = -1; |
171 |
step = -1; |
176 |
break; |
172 |
break; |
177 |
default: |
173 |
default: |
178 |
ASSERT(0); |
174 |
ASSERT(0); |
179 |
} |
175 |
} |
180 |
|
176 |
|
181 |
x += step; |
177 |
x += step; |
182 |
|
178 |
|
183 |
debug1("ml->image = %s\n", displayed_line); |
179 |
debug1("ml->image = %s\n", displayed_line); |
184 |
debug2("num = %d, width = %d\n",num, width); |
180 |
debug2("num = %d, width = %d\n", num, width); |
185 |
debug2("x = %d target = %c\n", x, target ); |
181 |
debug2("x = %d target = %c\n", x, target); |
186 |
|
182 |
|
187 |
for ( ;x>=0 && x <= width; x += step) { |
183 |
for (; x >= 0 && x <= width; x += step) { |
188 |
if (displayed_line[x] == target) { |
184 |
if (displayed_line[x] == target) { |
189 |
if (--num == 0) { |
185 |
if (--num == 0) { |
190 |
*xp = x + adjust; |
186 |
*xp = x + adjust; |
191 |
return 0; |
187 |
return 0; |
192 |
} |
188 |
} |
193 |
} |
189 |
} |
194 |
} |
190 |
} |
195 |
return -1; |
191 |
return -1; |
196 |
} |
192 |
} |
197 |
|
193 |
|
198 |
/* |
194 |
/* |
Lines 204-425
Link Here
|
204 |
* NW_BIG: match WORDs not words |
200 |
* NW_BIG: match WORDs not words |
205 |
*/ |
201 |
*/ |
206 |
|
202 |
|
207 |
#define NW_BACK (1<<0) |
203 |
#define NW_BACK (1<<0) |
208 |
#define NW_ENDOFWORD (1<<1) |
204 |
#define NW_ENDOFWORD (1<<1) |
209 |
#define NW_MUSTMOVE (1<<2) |
205 |
#define NW_MUSTMOVE (1<<2) |
210 |
#define NW_BIG (1<<3) |
206 |
#define NW_BIG (1<<3) |
211 |
|
|
|
212 |
|
213 |
|
207 |
|
214 |
static void |
208 |
static void |
215 |
nextword(xp, yp, flags, num) |
209 |
nextword(int *xp, int *yp, int flags, int num) |
216 |
int *xp, *yp, flags, num; |
|
|
217 |
{ |
210 |
{ |
218 |
int xx = fore->w_width, yy = fore->w_histheight + fore->w_height; |
211 |
int xx = fore->w_width, yy = fore->w_histheight + fore->w_height; |
219 |
register int sx, oq, q, x, y; |
212 |
register int sx, oq, q, x, y; |
220 |
struct mline *ml; |
213 |
struct mline *ml; |
221 |
|
214 |
|
222 |
x = *xp; |
215 |
x = *xp; |
223 |
y = *yp; |
216 |
y = *yp; |
224 |
sx = (flags & NW_BACK) ? -1 : 1; |
217 |
sx = (flags & NW_BACK) ? -1 : 1; |
225 |
if ((flags & NW_ENDOFWORD) && (flags & NW_MUSTMOVE)) |
218 |
if ((flags & NW_ENDOFWORD) && (flags & NW_MUSTMOVE)) |
226 |
x += sx; |
219 |
x += sx; |
227 |
ml = WIN(y); |
220 |
ml = WIN(y); |
228 |
for (oq = -1; ; x += sx, oq = q) |
221 |
for (oq = -1;; x += sx, oq = q) { |
229 |
{ |
222 |
if (x >= xx || x < 0) |
230 |
if (x >= xx || x < 0) |
223 |
q = 0; |
231 |
q = 0; |
224 |
else if (flags & NW_BIG) |
232 |
else if (flags & NW_BIG) |
225 |
q = ml->image[x] == ' '; |
233 |
q = ml->image[x] == ' '; |
226 |
else |
234 |
else |
227 |
q = is_letter(ml->image[x]); |
235 |
q = is_letter(ml->image[x]); |
228 |
|
236 |
if (oq >= 0 && oq != q) |
229 |
if (oq >= 0 && oq != q) { |
237 |
{ |
230 |
if (oq == 0 || !(flags & NW_ENDOFWORD)) |
238 |
if (oq == 0 || !(flags & NW_ENDOFWORD)) |
231 |
*xp = x; |
239 |
*xp = x; |
232 |
else |
240 |
else |
233 |
*xp = x - sx; |
241 |
*xp = x-sx; |
234 |
*yp = y; |
242 |
*yp = y; |
235 |
|
243 |
if ((!(flags & NW_ENDOFWORD) && q) || |
236 |
if ((!(flags & NW_ENDOFWORD) && q) || ((flags & NW_ENDOFWORD) && oq)) { |
244 |
((flags & NW_ENDOFWORD) && oq)) |
237 |
if (--num <= 0) |
245 |
{ |
238 |
return; |
246 |
if (--num <= 0) |
239 |
} |
247 |
return; |
240 |
} |
248 |
} |
241 |
|
249 |
} |
242 |
if (x == xx) { |
250 |
if (x == xx) |
243 |
x = -1; |
251 |
{ |
244 |
if (++y >= yy) |
252 |
x = -1; |
245 |
return; |
253 |
if (++y >= yy) |
246 |
ml = WIN(y); |
254 |
return; |
247 |
} else if (x < 0) { |
255 |
ml = WIN(y); |
248 |
x = xx; |
256 |
} |
249 |
if (--y < 0) |
257 |
else if (x < 0) |
250 |
return; |
258 |
{ |
251 |
ml = WIN(y); |
259 |
x = xx; |
252 |
} |
260 |
if (--y < 0) |
|
|
261 |
return; |
262 |
ml = WIN(y); |
263 |
} |
253 |
} |
264 |
} |
|
|
265 |
} |
254 |
} |
266 |
|
255 |
|
267 |
|
|
|
268 |
/* |
256 |
/* |
269 |
* y1, y2 are WIN coordinates |
257 |
* y1, y2 are WIN coordinates |
270 |
* |
258 |
* |
271 |
* redisplay: 0 - just copy |
259 |
* redisplay: 0 - just copy |
272 |
* 1 - redisplay + copy |
260 |
* 1 - redisplay + copy |
273 |
* 2 - count + copy, don't redisplay |
261 |
* 2 - count + copy, don't redisplay |
274 |
*/ |
262 |
*/ |
275 |
|
263 |
|
276 |
static int |
264 |
static int |
277 |
rem(x1, y1, x2, y2, redisplay, pt, yend) |
265 |
rem(int x1, int y1, int x2, int y2, int redisplay, char *pt, int yend) |
278 |
int x1, y1, x2, y2, redisplay, yend; |
|
|
279 |
char *pt; |
280 |
{ |
266 |
{ |
281 |
int i, j, from, to, ry, c; |
267 |
int i, j, from, to, ry, c; |
282 |
int l = 0; |
268 |
int l = 0; |
283 |
unsigned char *im; |
269 |
unsigned char *im; |
284 |
struct mline *ml; |
270 |
struct mline *ml; |
285 |
#ifdef FONT |
271 |
#ifdef FONT |
286 |
int cf, cfx, font; |
272 |
int cf, cfx, font; |
287 |
unsigned char *fo, *fox; |
273 |
unsigned char *fo, *fox; |
288 |
#endif |
274 |
#endif |
289 |
|
275 |
|
290 |
markdata->second = 0; |
276 |
markdata->second = 0; |
291 |
if (y2 < y1 || ((y2 == y1) && (x2 < x1))) |
277 |
if (y2 < y1 || ((y2 == y1) && (x2 < x1))) { |
292 |
{ |
278 |
i = y2; |
293 |
i = y2; |
279 |
y2 = y1; |
294 |
y2 = y1; |
280 |
y1 = i; |
295 |
y1 = i; |
281 |
i = x2; |
296 |
i = x2; |
282 |
x2 = x1; |
297 |
x2 = x1; |
283 |
x1 = i; |
298 |
x1 = i; |
284 |
} |
299 |
} |
285 |
ry = y1 - markdata->hist_offset; |
300 |
ry = y1 - markdata->hist_offset; |
286 |
|
301 |
|
287 |
i = y1; |
302 |
i = y1; |
288 |
if (redisplay != 2 && pt == 0 && ry < 0) { |
303 |
if (redisplay != 2 && pt == 0 && ry <0) |
289 |
i -= ry; |
304 |
{ |
290 |
ry = 0; |
305 |
i -= ry; |
291 |
} |
306 |
ry = 0; |
292 |
for (; i <= y2; i++, ry++) { |
307 |
} |
293 |
if (redisplay != 2 && pt == 0 && ry > yend) |
308 |
for (; i <= y2; i++, ry++) |
294 |
break; |
309 |
{ |
295 |
ml = WIN(i); |
310 |
if (redisplay != 2 && pt == 0 && ry > yend) |
296 |
from = (i == y1) ? x1 : 0; |
311 |
break; |
297 |
|
312 |
ml = WIN(i); |
298 |
if (from < markdata->left_mar) |
313 |
from = (i == y1) ? x1 : 0; |
299 |
from = markdata->left_mar; |
314 |
if (from < markdata->left_mar) |
300 |
for (to = fore->w_width, im = ml->image + to; to >= 0; to--) |
315 |
from = markdata->left_mar; |
301 |
if (*im-- != ' ') |
316 |
for (to = fore->w_width, im = ml->image + to; to >= 0; to--) |
302 |
break; |
317 |
if (*im-- != ' ') |
303 |
if (i == y2 && x2 < to) |
318 |
break; |
304 |
to = x2; |
319 |
if (i == y2 && x2 < to) |
305 |
if (to > markdata->right_mar) |
320 |
to = x2; |
306 |
to = markdata->right_mar; |
321 |
if (to > markdata->right_mar) |
307 |
if (redisplay == 1 && from <= to && ry >= 0 && ry <= yend) |
322 |
to = markdata->right_mar; |
308 |
MarkRedisplayLine(ry, from, to, 0); |
323 |
if (redisplay == 1 && from <= to && ry >=0 && ry <= yend) |
309 |
if (redisplay != 2 && pt == 0) /* don't count/copy */ |
324 |
MarkRedisplayLine(ry, from, to, 0); |
310 |
continue; |
325 |
if (redisplay != 2 && pt == 0) /* don't count/copy */ |
311 |
j = from; |
326 |
continue; |
|
|
327 |
j = from; |
328 |
#ifdef DW_CHARS |
312 |
#ifdef DW_CHARS |
329 |
if (dw_right(ml, j, fore->w_encoding)) |
313 |
if (dw_right(ml, j, fore->w_encoding)) |
330 |
j--; |
314 |
j--; |
331 |
#endif |
315 |
#endif |
332 |
im = ml->image + j; |
316 |
im = ml->image + j; |
333 |
#ifdef FONT |
317 |
#ifdef FONT |
334 |
fo = ml->font + j; |
318 |
fo = ml->font + j; |
335 |
fox = ml->fontx + j; |
319 |
fox = ml->fontx + j; |
336 |
font = ASCII; |
320 |
font = ASCII; |
337 |
#endif |
321 |
#endif |
338 |
for (; j <= to; j++) |
322 |
for (; j <= to; j++) { |
339 |
{ |
323 |
c = (unsigned char)*im++; |
340 |
c = (unsigned char)*im++; |
|
|
341 |
#ifdef FONT |
324 |
#ifdef FONT |
342 |
cf = (unsigned char)*fo++; |
325 |
cf = (unsigned char)*fo++; |
343 |
cfx = (unsigned char)*fox++; |
326 |
cfx = (unsigned char)*fox++; |
344 |
# ifdef UTF8 |
327 |
# ifdef UTF8 |
345 |
if (fore->w_encoding == UTF8) |
328 |
if (fore->w_encoding == UTF8) { |
346 |
{ |
329 |
c |= cf << 8 | cfx << 16; |
347 |
c |= cf << 8 | cfx << 16; |
330 |
if (c == UCS_HIDDEN) |
348 |
if (c == UCS_HIDDEN) |
331 |
continue; |
349 |
continue; |
332 |
c = ToUtf8_comb(pt, c); |
350 |
c = ToUtf8_comb(pt, c); |
333 |
l += c; |
351 |
l += c; |
334 |
if (pt) |
352 |
if (pt) |
335 |
pt += c; |
353 |
pt += c; |
336 |
continue; |
354 |
continue; |
337 |
} |
355 |
} |
|
|
356 |
# endif |
338 |
# endif |
357 |
# ifdef DW_CHARS |
339 |
# ifdef DW_CHARS |
358 |
if (is_dw_font(cf)) |
340 |
if (is_dw_font(cf)) { |
359 |
{ |
341 |
c = c << 8 | (unsigned char)*im++; |
360 |
c = c << 8 | (unsigned char)*im++; |
342 |
fo++; |
361 |
fo++; |
343 |
j++; |
362 |
j++; |
344 |
} |
363 |
} |
|
|
364 |
# endif |
345 |
# endif |
365 |
if (pastefont) |
346 |
if (pastefont) { |
366 |
{ |
347 |
c = EncodeChar(pt, c | cf << 16, fore->w_encoding, &font); |
367 |
c = EncodeChar(pt, c | cf << 16, fore->w_encoding, &font); |
348 |
l += c; |
368 |
l += c; |
349 |
if (pt) |
369 |
if (pt) |
350 |
pt += c; |
370 |
pt += c; |
351 |
continue; |
371 |
continue; |
352 |
} |
372 |
} |
|
|
373 |
#endif /* FONT */ |
353 |
#endif /* FONT */ |
374 |
if (pt) |
354 |
if (pt) |
375 |
*pt++ = c; |
355 |
*pt++ = c; |
376 |
l++; |
356 |
l++; |
377 |
} |
357 |
} |
378 |
#ifdef FONT |
358 |
#ifdef FONT |
379 |
if (pastefont && font != ASCII) |
359 |
if (pastefont && font != ASCII) { |
380 |
{ |
360 |
if (pt) { |
381 |
if (pt) |
361 |
strcpy(pt, "\033(B"); |
382 |
{ |
362 |
pt += 3; |
383 |
strcpy(pt, "\033(B"); |
363 |
} |
384 |
pt += 3; |
364 |
l += 3; |
385 |
} |
365 |
} |
386 |
l += 3; |
|
|
387 |
} |
388 |
#endif |
366 |
#endif |
389 |
if (i != y2 && (to != fore->w_width - 1 || ml->image[to + 1] == ' ')) |
367 |
if (i != y2 && (to != fore->w_width - 1 || ml->image[to + 1] == ' ')) { |
390 |
{ |
368 |
/* |
391 |
/* |
369 |
* this code defines, what glues lines together |
392 |
* this code defines, what glues lines together |
370 |
*/ |
393 |
*/ |
371 |
switch (markdata->nonl) { |
394 |
switch (markdata->nonl) |
372 |
case 0: /* lines separated by newlines */ |
395 |
{ |
373 |
if (pt) |
396 |
case 0: /* lines separated by newlines */ |
374 |
*pt++ = '\r'; |
397 |
if (pt) |
375 |
l++; |
398 |
*pt++ = '\r'; |
376 |
if (join_with_cr) { |
399 |
l++; |
377 |
if (pt) |
400 |
if (join_with_cr) |
378 |
*pt++ = '\n'; |
401 |
{ |
379 |
l++; |
402 |
if (pt) |
380 |
} |
403 |
*pt++ = '\n'; |
381 |
break; |
404 |
l++; |
382 |
case 1: /* nothing to separate lines */ |
|
|
383 |
break; |
384 |
case 2: /* lines separated by blanks */ |
385 |
if (pt) |
386 |
*pt++ = ' '; |
387 |
l++; |
388 |
break; |
389 |
case 3: /* seperate by comma, for csh junkies */ |
390 |
if (pt) |
391 |
*pt++ = ','; |
392 |
l++; |
393 |
break; |
394 |
} |
405 |
} |
395 |
} |
406 |
break; |
|
|
407 |
case 1: /* nothing to separate lines */ |
408 |
break; |
409 |
case 2: /* lines separated by blanks */ |
410 |
if (pt) |
411 |
*pt++ = ' '; |
412 |
l++; |
413 |
break; |
414 |
case 3: /* seperate by comma, for csh junkies */ |
415 |
if (pt) |
416 |
*pt++ = ','; |
417 |
l++; |
418 |
break; |
419 |
} |
420 |
} |
396 |
} |
421 |
} |
397 |
return l; |
422 |
return l; |
|
|
423 |
} |
398 |
} |
424 |
|
399 |
|
425 |
/* Check if two chars are identical. All digits are treated |
400 |
/* Check if two chars are identical. All digits are treated |
Lines 427-493
Link Here
|
427 |
*/ |
402 |
*/ |
428 |
|
403 |
|
429 |
static int |
404 |
static int |
430 |
eq(a, b) |
405 |
eq(int a, int b) |
431 |
int a, b; |
|
|
432 |
{ |
406 |
{ |
433 |
if (a == b) |
407 |
if (a == b) |
434 |
return 1; |
408 |
return 1; |
435 |
if (a == 0 || b == 0) |
409 |
if (a == 0 || b == 0) |
436 |
return 1; |
410 |
return 1; |
437 |
if (a <= '9' && a >= '0' && b <= '9' && b >= '0') |
411 |
if (a <= '9' && a >= '0' && b <= '9' && b >= '0') |
438 |
return 1; |
412 |
return 1; |
439 |
return 0; |
413 |
return 0; |
440 |
} |
414 |
} |
441 |
|
415 |
|
442 |
|
|
|
443 |
/**********************************************************************/ |
416 |
/**********************************************************************/ |
444 |
|
417 |
|
445 |
int |
418 |
int |
446 |
GetHistory() /* return value 1 if copybuffer changed */ |
419 |
GetHistory() /* return value 1 if copybuffer changed */ |
447 |
{ |
420 |
{ |
448 |
int i = 0, q = 0, xx, yy, x, y; |
421 |
int i = 0, q = 0, xx, yy, x, y; |
449 |
unsigned char *linep; |
422 |
unsigned char *linep; |
450 |
struct mline *ml; |
423 |
struct mline *ml; |
451 |
|
424 |
|
452 |
ASSERT(display && fore); |
425 |
ASSERT(display && fore); |
453 |
x = fore->w_x; |
426 |
x = fore->w_x; |
454 |
if (x >= fore->w_width) |
427 |
if (x >= fore->w_width) |
455 |
x = fore->w_width - 1; |
428 |
x = fore->w_width - 1; |
456 |
y = fore->w_y + fore->w_histheight; |
429 |
y = fore->w_y + fore->w_histheight; |
457 |
debug2("cursor is at x=%d, y=%d\n", x, y); |
430 |
debug2("cursor is at x=%d, y=%d\n", x, y); |
458 |
ml = WIN(y); |
431 |
ml = WIN(y); |
459 |
for (xx = x - 1, linep = ml->image + xx; xx >= 0; xx--) |
432 |
for (xx = x - 1, linep = ml->image + xx; xx >= 0; xx--) |
460 |
if ((q = *linep--) != ' ' ) |
433 |
if ((q = *linep--) != ' ') |
461 |
break; |
434 |
break; |
462 |
debug3("%c at (%d,%d)\n", q, xx, y); |
435 |
debug3("%c at (%d,%d)\n", q, xx, y); |
463 |
for (yy = y - 1; yy >= 0; yy--) |
436 |
for (yy = y - 1; yy >= 0; yy--) { |
464 |
{ |
437 |
ml = WIN(yy); |
465 |
ml = WIN(yy); |
438 |
linep = ml->image; |
466 |
linep = ml->image; |
439 |
if (xx < 0 || eq(linep[xx], q)) { /* line is matching... */ |
467 |
if (xx < 0 || eq(linep[xx], q)) |
440 |
for (i = fore->w_width - 1, linep += i; i >= x; i--) |
468 |
{ /* line is matching... */ |
441 |
if (*linep-- != ' ') |
469 |
for (i = fore->w_width - 1, linep += i; i >= x; i--) |
442 |
break; |
470 |
if (*linep-- != ' ') |
443 |
if (i >= x) |
471 |
break; |
444 |
break; |
472 |
if (i >= x) |
445 |
} |
473 |
break; |
446 |
} |
474 |
} |
447 |
if (yy < 0) |
475 |
} |
448 |
return 0; |
476 |
if (yy < 0) |
449 |
if (D_user->u_plop.buf) |
477 |
return 0; |
450 |
UserFreeCopyBuffer(D_user); |
478 |
if (D_user->u_plop.buf) |
451 |
if ((D_user->u_plop.buf = (char *)malloc((unsigned)(i - x + 2))) == |
479 |
UserFreeCopyBuffer(D_user); |
452 |
NULL) { |
480 |
if ((D_user->u_plop.buf = (char *)malloc((unsigned) (i - x + 2))) == NULL) |
453 |
LMsg(0, "Not enough memory... Sorry."); |
481 |
{ |
454 |
return 0; |
482 |
LMsg(0, "Not enough memory... Sorry."); |
455 |
} |
483 |
return 0; |
456 |
bcopy((char *)linep - i + x + 1, D_user->u_plop.buf, i - x + 1); |
484 |
} |
457 |
D_user->u_plop.len = i - x + 1; |
485 |
bcopy((char *)linep - i + x + 1, D_user->u_plop.buf, i - x + 1); |
|
|
486 |
D_user->u_plop.len = i - x + 1; |
487 |
#ifdef ENCODINGS |
458 |
#ifdef ENCODINGS |
488 |
D_user->u_plop.enc = fore->w_encoding; |
459 |
D_user->u_plop.enc = fore->w_encoding; |
489 |
#endif |
460 |
#endif |
490 |
return 1; |
461 |
return 1; |
491 |
} |
462 |
} |
492 |
|
463 |
|
493 |
/**********************************************************************/ |
464 |
/**********************************************************************/ |
Lines 496-593
Link Here
|
496 |
void |
467 |
void |
497 |
MarkRoutine() |
468 |
MarkRoutine() |
498 |
{ |
469 |
{ |
499 |
int x, y; |
470 |
int x, y; |
500 |
|
471 |
|
501 |
ASSERT(fore && display && D_user); |
472 |
ASSERT(fore && display && D_user); |
502 |
|
473 |
|
503 |
debug2("MarkRoutine called: fore nr %d, display %s\n", |
474 |
debug2("MarkRoutine called: fore nr %d, display %s\n", fore->w_number, D_usertty); |
504 |
fore->w_number, D_usertty); |
|
|
505 |
|
475 |
|
506 |
if (InitOverlayPage(sizeof(*markdata), &MarkLf, 1)) |
476 |
if (InitOverlayPage(sizeof(*markdata), &MarkLf, 1)) |
507 |
return; |
477 |
return; |
508 |
flayer->l_encoding = fore->w_encoding; |
478 |
flayer->l_encoding = fore->w_encoding; |
509 |
flayer->l_mode = 1; |
479 |
flayer->l_mode = 1; |
510 |
markdata = (struct markdata *)flayer->l_data; |
480 |
markdata = (struct markdata *)flayer->l_data; |
511 |
markdata->md_user = D_user; /* XXX: Correct? */ |
481 |
markdata->md_user = D_user; /* XXX: Correct? */ |
512 |
markdata->md_window = fore; |
482 |
markdata->md_window = fore; |
513 |
markdata->second = 0; |
483 |
markdata->second = 0; |
514 |
markdata->rep_cnt = 0; |
484 |
markdata->rep_cnt = 0; |
515 |
markdata->append_mode = 0; |
485 |
markdata->append_mode = 0; |
516 |
markdata->write_buffer = 0; |
486 |
markdata->write_buffer = 0; |
517 |
markdata->nonl = 0; |
487 |
markdata->nonl = 0; |
518 |
markdata->left_mar = 0; |
488 |
markdata->left_mar = 0; |
519 |
markdata->right_mar = fore->w_width - 1; |
489 |
markdata->right_mar = fore->w_width - 1; |
520 |
markdata->hist_offset = fore->w_histheight; |
490 |
markdata->hist_offset = fore->w_histheight; |
521 |
x = fore->w_x; |
491 |
x = fore->w_x; |
522 |
y = D2W(fore->w_y); |
492 |
y = D2W(fore->w_y); |
523 |
if (x >= fore->w_width) |
493 |
if (x >= fore->w_width) |
524 |
x = fore->w_width - 1; |
494 |
x = fore->w_width - 1; |
525 |
|
495 |
|
526 |
LGotoPos(flayer, x, W2D(y)); |
496 |
LGotoPos(flayer, x, W2D(y)); |
527 |
LMsg(0, "Copy mode - Column %d Line %d(+%d) (%d,%d)", |
497 |
LMsg(0, "Copy mode - Column %d Line %d(+%d) (%d,%d)", x + 1, W2D(y + 1), fore->w_histheight, fore->w_width, fore->w_height); |
528 |
x + 1, W2D(y + 1), fore->w_histheight, fore->w_width, fore->w_height); |
498 |
markdata->cx = markdata->x1 = x; |
529 |
markdata->cx = markdata->x1 = x; |
499 |
markdata->cy = markdata->y1 = y; |
530 |
markdata->cy = markdata->y1 = y; |
500 |
flayer->l_x = x; |
531 |
flayer->l_x = x; |
501 |
flayer->l_y = W2D(y); |
532 |
flayer->l_y = W2D(y); |
|
|
533 |
} |
502 |
} |
534 |
|
503 |
|
535 |
static void |
504 |
static void |
536 |
MarkProcess(inbufp,inlenp) |
505 |
MarkProcess(char **inbufp, int *inlenp) |
537 |
char **inbufp; |
|
|
538 |
int *inlenp; |
539 |
{ |
506 |
{ |
540 |
char *inbuf, *pt; |
507 |
char *inbuf, *pt; |
541 |
int inlen; |
508 |
int inlen; |
542 |
int cx, cy, x2, y2, j, yend; |
509 |
int cx, cy, x2, y2, j, yend; |
543 |
int newcopylen = 0, od; |
510 |
int newcopylen = 0, od; |
544 |
int in_mark; |
511 |
int in_mark; |
545 |
int rep_cnt; |
512 |
int rep_cnt; |
546 |
struct acluser *md_user; |
513 |
struct acluser *md_user; |
547 |
|
514 |
|
548 |
/* |
515 |
/* |
549 |
char *extrap = 0, extrabuf[100]; |
516 |
char *extrap = 0, extrabuf[100]; |
550 |
*/ |
517 |
*/ |
551 |
|
518 |
|
552 |
markdata = (struct markdata *)flayer->l_data; |
519 |
markdata = (struct markdata *)flayer->l_data; |
553 |
fore = markdata->md_window; |
520 |
fore = markdata->md_window; |
554 |
md_user = markdata->md_user; |
521 |
md_user = markdata->md_user; |
555 |
if (inbufp == 0) |
522 |
if (inbufp == 0) { |
556 |
{ |
523 |
MarkAbort(); |
557 |
MarkAbort(); |
524 |
return; |
558 |
return; |
525 |
} |
559 |
} |
526 |
|
560 |
|
527 |
LGotoPos(flayer, markdata->cx, W2D(markdata->cy)); |
561 |
LGotoPos(flayer, markdata->cx, W2D(markdata->cy)); |
528 |
inbuf = *inbufp; |
562 |
inbuf= *inbufp; |
529 |
inlen = *inlenp; |
563 |
inlen= *inlenp; |
530 |
pt = inbuf; |
564 |
pt = inbuf; |
531 |
in_mark = 1; |
565 |
in_mark = 1; |
532 |
while (in_mark && (inlen /* || extrap */)) { |
566 |
while (in_mark && (inlen /* || extrap */)) |
533 |
unsigned char ch = (unsigned char)*pt++; |
567 |
{ |
534 |
inlen--; |
568 |
unsigned char ch = (unsigned char )*pt++; |
535 |
if (flayer->l_mouseevent.start) { |
569 |
inlen--; |
536 |
int r = LayProcessMouse(flayer, ch); |
570 |
if (flayer->l_mouseevent.start) |
537 |
if (r == -1) |
571 |
{ |
538 |
LayProcessMouseSwitch(flayer, 0); |
572 |
int r = LayProcessMouse(flayer, ch); |
539 |
else { |
573 |
if (r == -1) |
540 |
if (r) |
574 |
LayProcessMouseSwitch(flayer, 0); |
541 |
ch = 0222; |
575 |
else |
542 |
else |
576 |
{ |
543 |
continue; |
577 |
if (r) |
544 |
} |
578 |
ch = 0222; |
545 |
} |
579 |
else |
546 |
od = mark_key_tab[(int)ch]; |
580 |
continue; |
547 |
rep_cnt = markdata->rep_cnt; |
581 |
} |
548 |
if (od >= '0' && od <= '9' && !markdata->f_cmd.flag) { |
582 |
} |
549 |
if (rep_cnt < 1001 && (od != '0' || rep_cnt != 0)) { |
583 |
od = mark_key_tab[(int)ch]; |
550 |
markdata->rep_cnt = 10 * rep_cnt + od - '0'; |
584 |
rep_cnt = markdata->rep_cnt; |
551 |
continue; |
585 |
if (od >= '0' && od <= '9' && !markdata->f_cmd.flag) |
|
|
586 |
{ |
587 |
if (rep_cnt < 1001 && (od != '0' || rep_cnt != 0)) |
588 |
{ |
589 |
markdata->rep_cnt = 10 * rep_cnt + od - '0'; |
590 |
continue; |
591 |
/* |
552 |
/* |
592 |
* Now what is that 1001 here? Well, we have a screen with |
553 |
* Now what is that 1001 here? Well, we have a screen with |
593 |
* 25 * 80 = 2000 characters. Movement is at most across the full |
554 |
* 25 * 80 = 2000 characters. Movement is at most across the full |
Lines 598-629
Link Here
|
598 |
* words, as they should be more advanced. jw. |
559 |
* words, as they should be more advanced. jw. |
599 |
* Oh, wrong. We still give even the experienced user a factor of ten. |
560 |
* Oh, wrong. We still give even the experienced user a factor of ten. |
600 |
*/ |
561 |
*/ |
601 |
} |
562 |
} |
602 |
} |
563 |
} |
603 |
cx = markdata->cx; |
564 |
cx = markdata->cx; |
604 |
cy = markdata->cy; |
565 |
cy = markdata->cy; |
605 |
|
566 |
|
606 |
if (markdata -> f_cmd.flag) { |
567 |
if (markdata->f_cmd.flag) { |
607 |
debug2("searching for %c:%d\n",od,rep_cnt); |
568 |
debug2("searching for %c:%d\n", od, rep_cnt); |
608 |
markdata->f_cmd.flag = 0; |
569 |
markdata->f_cmd.flag = 0; |
609 |
markdata->rep_cnt = 0; |
570 |
markdata->rep_cnt = 0; |
610 |
|
571 |
|
611 |
if (isgraph (od)) { |
572 |
if (isgraph(od)) { |
612 |
markdata->f_cmd.target = od; |
573 |
markdata->f_cmd.target = od; |
613 |
rep_cnt = (rep_cnt) ? rep_cnt : 1; |
574 |
rep_cnt = (rep_cnt) ? rep_cnt : 1; |
614 |
nextchar(&cx, &cy, markdata->f_cmd.direction, od, rep_cnt ); |
575 |
nextchar(&cx, &cy, markdata->f_cmd.direction, od, rep_cnt); |
615 |
revto(cx, cy); |
576 |
revto(cx, cy); |
616 |
continue; |
577 |
continue; |
617 |
} |
578 |
} |
618 |
} |
579 |
} |
619 |
|
580 |
|
620 |
processchar: |
581 |
processchar: |
621 |
switch (od) |
582 |
switch (od) { |
622 |
{ |
583 |
case 'f': /* fall through */ |
623 |
case 'f': /* fall through */ |
584 |
case 'F': /* fall through */ |
624 |
case 'F': /* fall through */ |
585 |
case 't': /* fall through */ |
625 |
case 't': /* fall through */ |
586 |
case 'T': /* fall through */ |
626 |
case 'T': /* fall through */ |
|
|
627 |
/* |
587 |
/* |
628 |
* Set f_cmd to do a search on the next key stroke. |
588 |
* Set f_cmd to do a search on the next key stroke. |
629 |
* If we break, rep_cnt will be reset, so we |
589 |
* If we break, rep_cnt will be reset, so we |
Lines 632-1536
Link Here
|
632 |
* break here so later followon code will be |
592 |
* break here so later followon code will be |
633 |
* hit. |
593 |
* hit. |
634 |
*/ |
594 |
*/ |
635 |
markdata->f_cmd.flag = 1; |
595 |
markdata->f_cmd.flag = 1; |
636 |
markdata->f_cmd.direction = od; |
596 |
markdata->f_cmd.direction = od; |
637 |
debug("entering char search\n"); |
597 |
debug("entering char search\n"); |
638 |
continue; |
598 |
continue; |
639 |
case ';': |
599 |
case ';': |
640 |
case ',': |
600 |
case ',': |
641 |
if (!markdata->f_cmd.target) |
601 |
if (!markdata->f_cmd.target) |
642 |
break; |
602 |
break; |
643 |
if (!rep_cnt) |
603 |
if (!rep_cnt) |
644 |
rep_cnt = 1; |
604 |
rep_cnt = 1; |
645 |
nextchar(&cx, &cy, |
605 |
nextchar(&cx, |
646 |
od == ';' ? markdata->f_cmd.direction : (markdata->f_cmd.direction ^ 0x20), |
606 |
&cy, |
647 |
markdata->f_cmd.target, rep_cnt ); |
607 |
od == ';' ? markdata->f_cmd.direction : (markdata->f_cmd.direction ^ 0x20), |
648 |
revto(cx, cy); |
608 |
markdata->f_cmd.target, |
649 |
break; |
609 |
rep_cnt); |
650 |
case 'o': |
610 |
revto(cx, cy); |
651 |
case 'x': |
611 |
break; |
652 |
if (!markdata->second) |
612 |
case 'o': |
653 |
break; |
613 |
case 'x': |
654 |
markdata->cx = markdata->x1; |
614 |
if (!markdata->second) |
655 |
markdata->cy = markdata->y1; |
615 |
break; |
656 |
markdata->x1 = cx; |
616 |
markdata->cx = markdata->x1; |
657 |
markdata->y1 = cy; |
617 |
markdata->cy = markdata->y1; |
658 |
revto(markdata->cx, markdata->cy); |
618 |
markdata->x1 = cx; |
659 |
break; |
619 |
markdata->y1 = cy; |
660 |
case '\014': /* CTRL-L Redisplay */ |
620 |
revto(markdata->cx, markdata->cy); |
661 |
Redisplay(0); |
621 |
break; |
662 |
LGotoPos(flayer, cx, W2D(cy)); |
622 |
case '\014': /* CTRL-L Redisplay */ |
663 |
break; |
623 |
Redisplay(0); |
664 |
case 0202: /* M-C-b */ |
624 |
LGotoPos(flayer, cx, W2D(cy)); |
665 |
case '\010': /* CTRL-H Backspace */ |
625 |
break; |
666 |
case 'h': |
626 |
case 0202: /* M-C-b */ |
667 |
if (rep_cnt == 0) |
627 |
case '\010': /* CTRL-H Backspace */ |
668 |
rep_cnt = 1; |
628 |
case 'h': |
669 |
revto(cx - rep_cnt, cy); |
629 |
if (rep_cnt == 0) |
670 |
break; |
630 |
rep_cnt = 1; |
671 |
case 0216: /* M-C-p */ |
631 |
revto(cx - rep_cnt, cy); |
672 |
case '\016': /* CTRL-N */ |
632 |
break; |
673 |
case 'j': |
633 |
case 0216: /* M-C-p */ |
674 |
if (rep_cnt == 0) |
634 |
case '\016': /* CTRL-N */ |
675 |
rep_cnt = 1; |
635 |
case 'j': |
676 |
revto(cx, cy + rep_cnt); |
636 |
if (rep_cnt == 0) |
677 |
break; |
637 |
rep_cnt = 1; |
678 |
case '+': |
638 |
revto(cx, cy + rep_cnt); |
679 |
if (rep_cnt == 0) |
639 |
break; |
680 |
rep_cnt = 1; |
640 |
case '+': |
681 |
j = cy + rep_cnt; |
641 |
if (rep_cnt == 0) |
682 |
if (j > fore->w_histheight + fore->w_height - 1) |
642 |
rep_cnt = 1; |
683 |
j = fore->w_histheight + fore->w_height - 1; |
643 |
j = cy + rep_cnt; |
684 |
revto(linestart(j), j); |
644 |
if (j > fore->w_histheight + fore->w_height - 1) |
685 |
break; |
645 |
j = fore->w_histheight + fore->w_height - 1; |
686 |
case '-': |
646 |
revto(linestart(j), j); |
687 |
if (rep_cnt == 0) |
647 |
break; |
688 |
rep_cnt = 1; |
648 |
case '-': |
689 |
cy -= rep_cnt; |
649 |
if (rep_cnt == 0) |
690 |
if (cy < 0) |
650 |
rep_cnt = 1; |
691 |
cy = 0; |
651 |
cy -= rep_cnt; |
692 |
revto(linestart(cy), cy); |
652 |
if (cy < 0) |
693 |
break; |
653 |
cy = 0; |
694 |
case '^': |
654 |
revto(linestart(cy), cy); |
695 |
revto(linestart(cy), cy); |
655 |
break; |
696 |
break; |
656 |
case '^': |
697 |
case '\n': |
657 |
revto(linestart(cy), cy); |
698 |
revto(markdata->left_mar, cy + 1); |
658 |
break; |
699 |
break; |
659 |
case '\n': |
700 |
case 0220: /* M-C-p */ |
660 |
revto(markdata->left_mar, cy + 1); |
701 |
case '\020': /* CTRL-P */ |
661 |
break; |
702 |
case 'k': |
662 |
case 0220: /* M-C-p */ |
703 |
if (rep_cnt == 0) |
663 |
case '\020': /* CTRL-P */ |
704 |
rep_cnt = 1; |
664 |
case 'k': |
705 |
revto(cx, cy - rep_cnt); |
665 |
if (rep_cnt == 0) |
706 |
break; |
666 |
rep_cnt = 1; |
707 |
case 0206: /* M-C-f */ |
667 |
revto(cx, cy - rep_cnt); |
708 |
case 'l': |
668 |
break; |
709 |
if (rep_cnt == 0) |
669 |
case 0206: /* M-C-f */ |
710 |
rep_cnt = 1; |
670 |
case 'l': |
711 |
revto(cx + rep_cnt, cy); |
671 |
if (rep_cnt == 0) |
712 |
break; |
672 |
rep_cnt = 1; |
713 |
case '\001': /* CTRL-A from tcsh/emacs */ |
673 |
revto(cx + rep_cnt, cy); |
714 |
case '0': |
674 |
break; |
715 |
revto(markdata->left_mar, cy); |
675 |
case '\001': /* CTRL-A from tcsh/emacs */ |
716 |
break; |
676 |
case '0': |
717 |
case '\004': /* CTRL-D down half screen */ |
677 |
revto(markdata->left_mar, cy); |
718 |
if (rep_cnt == 0) |
678 |
break; |
719 |
rep_cnt = (fore->w_height + 1) >> 1; |
679 |
case '\004': /* CTRL-D down half screen */ |
720 |
revto_line(cx, cy + rep_cnt, W2D(cy)); |
680 |
if (rep_cnt == 0) |
721 |
break; |
681 |
rep_cnt = (fore->w_height + 1) >> 1; |
722 |
case '$': |
682 |
revto_line(cx, cy + rep_cnt, W2D(cy)); |
723 |
revto(lineend(cy), cy); |
683 |
break; |
724 |
break; |
684 |
case '$': |
725 |
case '\022': /* CTRL-R emacs style backwards search */ |
685 |
revto(lineend(cy), cy); |
726 |
ISearch(-1); |
686 |
break; |
727 |
in_mark = 0; |
687 |
case '\022': /* CTRL-R emacs style backwards search */ |
728 |
break; |
688 |
ISearch(-1); |
729 |
case '\023': /* CTRL-S emacs style search */ |
689 |
in_mark = 0; |
730 |
ISearch(1); |
690 |
break; |
731 |
in_mark = 0; |
691 |
case '\023': /* CTRL-S emacs style search */ |
732 |
break; |
692 |
ISearch(1); |
733 |
case '\025': /* CTRL-U up half screen */ |
693 |
in_mark = 0; |
734 |
if (rep_cnt == 0) |
694 |
break; |
735 |
rep_cnt = (fore->w_height + 1) >> 1; |
695 |
case '\025': /* CTRL-U up half screen */ |
736 |
revto_line(cx, cy - rep_cnt, W2D(cy)); |
696 |
if (rep_cnt == 0) |
737 |
break; |
697 |
rep_cnt = (fore->w_height + 1) >> 1; |
738 |
case '\007': /* CTRL-G show cursorpos */ |
698 |
revto_line(cx, cy - rep_cnt, W2D(cy)); |
739 |
if (markdata->left_mar == 0 && markdata->right_mar == fore->w_width - 1) |
699 |
break; |
740 |
LMsg(0, "Column %d Line %d(+%d)", cx+1, W2D(cy)+1, |
700 |
case '\007': /* CTRL-G show cursorpos */ |
741 |
markdata->hist_offset); |
701 |
if (markdata->left_mar == 0 && markdata->right_mar == fore->w_width - 1) |
742 |
else |
702 |
LMsg(0, "Column %d Line %d(+%d)", cx + 1, W2D(cy) + 1, markdata->hist_offset); |
743 |
LMsg(0, "Column %d(%d..%d) Line %d(+%d)", cx+1, |
703 |
else |
744 |
markdata->left_mar+1, markdata->right_mar+1, W2D(cy)+1, markdata->hist_offset); |
704 |
LMsg(0, "Column %d(%d..%d) Line %d(+%d)", |
745 |
break; |
705 |
cx + 1, markdata->left_mar + 1, |
746 |
case '\002': /* CTRL-B back one page */ |
706 |
markdata->right_mar + 1, W2D(cy) + 1, |
747 |
if (rep_cnt == 0) |
707 |
markdata->hist_offset); |
748 |
rep_cnt = 1; |
708 |
break; |
749 |
rep_cnt *= fore->w_height; |
709 |
case '\002': /* CTRL-B back one page */ |
750 |
revto(cx, cy - rep_cnt); |
710 |
if (rep_cnt == 0) |
751 |
break; |
711 |
rep_cnt = 1; |
752 |
case '\006': /* CTRL-F forward one page */ |
712 |
rep_cnt *= fore->w_height; |
753 |
if (rep_cnt == 0) |
713 |
revto(cx, cy - rep_cnt); |
754 |
rep_cnt = 1; |
714 |
break; |
755 |
rep_cnt *= fore->w_height; |
715 |
case '\006': /* CTRL-F forward one page */ |
756 |
revto(cx, cy + rep_cnt); |
716 |
if (rep_cnt == 0) |
757 |
break; |
717 |
rep_cnt = 1; |
758 |
case '\005': /* CTRL-E scroll up */ |
718 |
rep_cnt *= fore->w_height; |
759 |
if (rep_cnt == 0) |
719 |
revto(cx, cy + rep_cnt); |
760 |
rep_cnt = 1; |
720 |
break; |
761 |
rep_cnt = MarkScrollUpDisplay(rep_cnt); |
721 |
case '\005': /* CTRL-E scroll up */ |
762 |
if (cy < D2W(0)) |
722 |
if (rep_cnt == 0) |
763 |
revto(cx, D2W(0)); |
723 |
rep_cnt = 1; |
764 |
else |
724 |
rep_cnt = MarkScrollUpDisplay(rep_cnt); |
765 |
LGotoPos(flayer, cx, W2D(cy)); |
725 |
if (cy < D2W(0)) |
766 |
break; |
726 |
revto(cx, D2W(0)); |
767 |
case '\031': /* CTRL-Y scroll down */ |
727 |
else |
768 |
if (rep_cnt == 0) |
728 |
LGotoPos(flayer, cx, W2D(cy)); |
769 |
rep_cnt = 1; |
729 |
break; |
770 |
rep_cnt = MarkScrollDownDisplay(rep_cnt); |
730 |
case '\031': /* CTRL-Y scroll down */ |
771 |
if (cy > D2W(fore->w_height-1)) |
731 |
if (rep_cnt == 0) |
772 |
revto(cx, D2W(fore->w_height-1)); |
732 |
rep_cnt = 1; |
773 |
else |
733 |
rep_cnt = MarkScrollDownDisplay(rep_cnt); |
774 |
LGotoPos(flayer, cx, W2D(cy)); |
734 |
if (cy > D2W(fore->w_height - 1)) |
775 |
break; |
735 |
revto(cx, D2W(fore->w_height - 1)); |
776 |
case '@': |
736 |
else |
|
|
737 |
LGotoPos(flayer, cx, W2D(cy)); |
738 |
break; |
739 |
case '@': |
777 |
/* it may be useful to have a key that does nothing */ |
740 |
/* it may be useful to have a key that does nothing */ |
778 |
break; |
741 |
break; |
779 |
case '%': |
742 |
case '%': |
780 |
/* rep_cnt is a percentage for the history buffer */ |
743 |
/* rep_cnt is a percentage for the history buffer */ |
781 |
if (rep_cnt < 0) |
744 |
if (rep_cnt < 0) |
782 |
rep_cnt = 0; |
745 |
rep_cnt = 0; |
783 |
if (rep_cnt > 100) |
746 |
if (rep_cnt > 100) |
784 |
rep_cnt = 100; |
747 |
rep_cnt = 100; |
785 |
revto_line(markdata->left_mar, |
748 |
|
786 |
fore->w_histheight - fore->w_scrollback_height + |
749 |
revto_line(markdata->left_mar, |
787 |
(int)(rep_cnt * (fore->w_scrollback_height + fore->w_height) / 100.0), |
750 |
fore->w_histheight - fore->w_scrollback_height + |
788 |
(fore->w_height - 1) / 2); |
751 |
(int)(rep_cnt * (fore->w_scrollback_height + |
789 |
break; |
752 |
fore->w_height) / 100.0), (fore->w_height - 1) / 2); |
790 |
case 0201: |
753 |
break; |
791 |
case 'g': |
754 |
case 0201: |
792 |
rep_cnt = 1; |
755 |
case 'g': |
|
|
756 |
rep_cnt = 1; |
793 |
/* FALLTHROUGH */ |
757 |
/* FALLTHROUGH */ |
794 |
case 0205: |
758 |
case 0205: |
795 |
case 'G': |
759 |
case 'G': |
796 |
/* rep_cnt is here the WIN line number */ |
760 |
/* rep_cnt is here the WIN line number */ |
797 |
if (rep_cnt == 0) |
761 |
if (rep_cnt == 0) |
798 |
rep_cnt = fore->w_histheight + fore->w_height; |
762 |
rep_cnt = fore->w_histheight + fore->w_height; |
799 |
revto_line(markdata->left_mar, --rep_cnt, (fore->w_height - 1) / 2); |
763 |
revto_line(markdata->left_mar, --rep_cnt, (fore->w_height - 1) / 2); |
800 |
break; |
764 |
break; |
801 |
case 'H': |
765 |
case 'H': |
802 |
revto(markdata->left_mar, D2W(0)); |
766 |
revto(markdata->left_mar, D2W(0)); |
803 |
break; |
767 |
break; |
804 |
case 'M': |
768 |
case 'M': |
805 |
revto(markdata->left_mar, D2W((fore->w_height - 1) / 2)); |
769 |
revto(markdata->left_mar, D2W((fore->w_height - 1) / 2)); |
806 |
break; |
770 |
break; |
807 |
case 'L': |
771 |
case 'L': |
808 |
revto(markdata->left_mar, D2W(fore->w_height - 1)); |
772 |
revto(markdata->left_mar, D2W(fore->w_height - 1)); |
809 |
break; |
773 |
break; |
810 |
case '|': |
774 |
case '|': |
811 |
revto(--rep_cnt, cy); |
775 |
revto(--rep_cnt, cy); |
812 |
break; |
776 |
break; |
813 |
case 'w': |
777 |
case 'w': |
814 |
if (rep_cnt == 0) |
778 |
if (rep_cnt == 0) |
815 |
rep_cnt = 1; |
779 |
rep_cnt = 1; |
816 |
nextword(&cx, &cy, NW_MUSTMOVE, rep_cnt); |
780 |
nextword(&cx, &cy, NW_MUSTMOVE, rep_cnt); |
817 |
revto(cx, cy); |
781 |
revto(cx, cy); |
818 |
break; |
782 |
break; |
819 |
case 'e': |
783 |
case 'e': |
820 |
case 'E': |
784 |
case 'E': |
821 |
if (rep_cnt == 0) |
785 |
if (rep_cnt == 0) |
822 |
rep_cnt = 1; |
786 |
rep_cnt = 1; |
823 |
nextword(&cx, &cy, NW_ENDOFWORD|NW_MUSTMOVE | (od == 'E' ? NW_BIG : 0), rep_cnt); |
787 |
nextword(&cx, &cy, NW_ENDOFWORD|NW_MUSTMOVE | (od == 'E' ? NW_BIG : 0), rep_cnt); |
824 |
revto(cx, cy); |
788 |
revto(cx, cy); |
825 |
break; |
789 |
break; |
826 |
case 'b': |
790 |
case 'b': |
827 |
case 'B': |
791 |
case 'B': |
828 |
if (rep_cnt == 0) |
792 |
if (rep_cnt == 0) |
829 |
rep_cnt = 1; |
793 |
rep_cnt = 1; |
830 |
nextword(&cx, &cy, NW_BACK|NW_ENDOFWORD|NW_MUSTMOVE | (od == 'B' ? NW_BIG : 0), rep_cnt); |
794 |
nextword(&cx, &cy, NW_BACK|NW_ENDOFWORD|NW_MUSTMOVE | (od == 'B' ? NW_BIG : 0), rep_cnt); |
831 |
revto(cx, cy); |
795 |
revto(cx, cy); |
832 |
break; |
796 |
break; |
833 |
case 'a': |
797 |
case 'a': |
834 |
markdata->append_mode = 1 - markdata->append_mode; |
798 |
markdata->append_mode = 1 - markdata->append_mode; |
835 |
debug1("append mode %d--\n", markdata->append_mode); |
799 |
debug1("append mode %d--\n", markdata->append_mode); |
836 |
LMsg(0, (markdata->append_mode) ? ":set append" : ":set noappend"); |
800 |
LMsg(0, (markdata->append_mode) ? ":set append" : ":set noappend"); |
837 |
break; |
801 |
break; |
838 |
case 'v': |
802 |
case 'v': |
839 |
case 'V': |
803 |
case 'V': |
840 |
/* this sets start column to column 9 for VI :set nu users */ |
804 |
/* this sets start column to column 9 for VI :set nu users */ |
841 |
if (markdata->left_mar == 8) |
805 |
if (markdata->left_mar == 8) |
842 |
rep_cnt = 1; |
806 |
rep_cnt = 1; |
843 |
else |
807 |
else |
844 |
rep_cnt = 9; |
808 |
rep_cnt = 9; |
845 |
/* FALLTHROUGH */ |
809 |
/* FALLTHROUGH */ |
846 |
case 'c': |
810 |
case 'c': |
847 |
case 'C': |
811 |
case 'C': |
848 |
/* set start column (c) and end column (C) */ |
812 |
/* set start column (c) and end column (C) */ |
849 |
if (markdata->second) |
813 |
if (markdata->second) { |
850 |
{ |
814 |
rem(markdata->x1, markdata->y1, cx, cy, 1, (char *)0, fore->w_height - 1); /* Hack */ |
851 |
rem(markdata->x1, markdata->y1, cx, cy, 1, (char *)0, fore->w_height-1); /* Hack */ |
815 |
markdata->second = 1; /* rem turns off second */ |
852 |
markdata->second = 1; /* rem turns off second */ |
816 |
} |
853 |
} |
817 |
rep_cnt--; |
854 |
rep_cnt--; |
818 |
if (rep_cnt < 0) |
855 |
if (rep_cnt < 0) |
819 |
rep_cnt = cx; |
856 |
rep_cnt = cx; |
820 |
if (od != 'C') { |
857 |
if (od != 'C') |
821 |
markdata->left_mar = rep_cnt; |
858 |
{ |
822 |
if (markdata->left_mar > markdata->right_mar) |
859 |
markdata->left_mar = rep_cnt; |
823 |
markdata->left_mar = markdata->right_mar; |
860 |
if (markdata->left_mar > markdata->right_mar) |
824 |
} else { |
861 |
markdata->left_mar = markdata->right_mar; |
825 |
markdata->right_mar = rep_cnt; |
862 |
} |
826 |
if (markdata->left_mar > markdata->right_mar) |
863 |
else |
827 |
markdata->right_mar = markdata->left_mar; |
864 |
{ |
828 |
} |
865 |
markdata->right_mar = rep_cnt; |
829 |
if (markdata->second) { |
866 |
if (markdata->left_mar > markdata->right_mar) |
830 |
markdata->cx = markdata->x1; |
867 |
markdata->right_mar = markdata->left_mar; |
831 |
markdata->cy = markdata->y1; |
868 |
} |
832 |
revto(cx, cy); |
869 |
if (markdata->second) |
833 |
} |
870 |
{ |
834 |
if (od == 'v' || od == 'V') |
871 |
markdata->cx = markdata->x1; markdata->cy = markdata->y1; |
835 |
LMsg(0, (markdata->left_mar != 8) ? ":set nonu" : ":set nu"); |
872 |
revto(cx, cy); |
836 |
break; |
873 |
} |
837 |
case 'J': |
874 |
if (od == 'v' || od == 'V') |
838 |
/* how do you join lines in VI ? */ |
875 |
LMsg(0, (markdata->left_mar != 8) ? ":set nonu" : ":set nu"); |
839 |
markdata->nonl = (markdata->nonl + 1) % 4; |
876 |
break; |
840 |
switch (markdata->nonl) { |
877 |
case 'J': |
841 |
case 0: |
878 |
/* how do you join lines in VI ? */ |
842 |
if (join_with_cr) |
879 |
markdata->nonl = (markdata->nonl + 1) % 4; |
843 |
LMsg(0, "Multiple lines (CR/LF)"); |
880 |
switch (markdata->nonl) |
844 |
else |
881 |
{ |
845 |
LMsg(0, "Multiple lines (LF)"); |
882 |
case 0: |
846 |
break; |
883 |
if (join_with_cr) |
847 |
case 1: |
884 |
LMsg(0, "Multiple lines (CR/LF)"); |
848 |
LMsg(0, "Lines joined"); |
885 |
else |
849 |
break; |
886 |
LMsg(0, "Multiple lines (LF)"); |
850 |
case 2: |
887 |
break; |
851 |
LMsg(0, "Lines joined with blanks"); |
888 |
case 1: |
852 |
break; |
889 |
LMsg(0, "Lines joined"); |
853 |
case 3: |
890 |
break; |
854 |
LMsg(0, "Lines joined with comma"); |
891 |
case 2: |
855 |
break; |
892 |
LMsg(0, "Lines joined with blanks"); |
856 |
} |
893 |
break; |
857 |
break; |
894 |
case 3: |
858 |
case '/': |
895 |
LMsg(0, "Lines joined with comma"); |
859 |
Search(1); |
896 |
break; |
860 |
in_mark = 0; |
897 |
} |
861 |
break; |
898 |
break; |
862 |
case '?': |
899 |
case '/': |
863 |
Search(-1); |
900 |
Search(1); |
864 |
in_mark = 0; |
901 |
in_mark = 0; |
865 |
break; |
902 |
break; |
866 |
case 'n': |
903 |
case '?': |
867 |
Search(0); |
904 |
Search(-1); |
868 |
break; |
905 |
in_mark = 0; |
869 |
case 'N': |
906 |
break; |
870 |
markdata->isdir = -markdata->isdir; |
907 |
case 'n': |
871 |
Search(0); |
908 |
Search(0); |
872 |
markdata->isdir = -markdata->isdir; |
909 |
break; |
873 |
break; |
910 |
case 'N': |
874 |
case 'y': |
911 |
markdata->isdir = -markdata->isdir; |
875 |
case 'Y': |
912 |
Search(0); |
876 |
if (markdata->second == 0) { |
913 |
markdata->isdir = -markdata->isdir; |
877 |
revto(linestart(cy), cy); |
914 |
break; |
878 |
markdata->second++; |
915 |
case 'y': |
879 |
cx = markdata->x1 = markdata->cx; |
916 |
case 'Y': |
880 |
cy = markdata->y1 = markdata->cy; |
917 |
if (markdata->second == 0) |
881 |
} |
918 |
{ |
882 |
if (--rep_cnt > 0) |
919 |
revto(linestart(cy), cy); |
883 |
revto(cx, cy + rep_cnt); |
920 |
markdata->second++; |
884 |
revto(lineend(markdata->cy), markdata->cy); |
921 |
cx = markdata->x1 = markdata->cx; |
885 |
if (od == 'y') |
922 |
cy = markdata->y1 = markdata->cy; |
886 |
break; |
923 |
} |
|
|
924 |
if (--rep_cnt > 0) |
925 |
revto(cx, cy + rep_cnt); |
926 |
revto(lineend(markdata->cy), markdata->cy); |
927 |
if (od == 'y') |
928 |
break; |
929 |
/* FALLTHROUGH */ |
887 |
/* FALLTHROUGH */ |
930 |
case 'W': |
888 |
case 'W': |
931 |
if (od == 'W') |
889 |
if (od == 'W') { |
932 |
{ |
890 |
if (rep_cnt == 0) |
933 |
if (rep_cnt == 0) |
891 |
rep_cnt = 1; |
934 |
rep_cnt = 1; |
892 |
if (!markdata->second) { |
935 |
if (!markdata->second) |
893 |
nextword(&cx, &cy, NW_BACK|NW_ENDOFWORD, 1); |
936 |
{ |
894 |
revto(cx, cy); |
937 |
nextword(&cx, &cy, NW_BACK|NW_ENDOFWORD, 1); |
895 |
markdata->second++; |
938 |
revto(cx, cy); |
896 |
cx = markdata->x1 = markdata->cx; |
939 |
markdata->second++; |
897 |
cy = markdata->y1 = markdata->cy; |
940 |
cx = markdata->x1 = markdata->cx; |
898 |
} |
941 |
cy = markdata->y1 = markdata->cy; |
899 |
nextword(&cx, &cy, NW_ENDOFWORD, rep_cnt); |
942 |
} |
900 |
revto(cx, cy); |
943 |
nextword(&cx, &cy, NW_ENDOFWORD, rep_cnt); |
901 |
} |
944 |
revto(cx, cy); |
902 |
cx = markdata->cx; |
945 |
} |
903 |
cy = markdata->cy; |
946 |
cx = markdata->cx; |
|
|
947 |
cy = markdata->cy; |
948 |
/* FALLTHROUGH */ |
904 |
/* FALLTHROUGH */ |
949 |
case 'A': |
905 |
case 'A': |
950 |
if (od == 'A') |
906 |
if (od == 'A') |
951 |
markdata->append_mode = 1; |
907 |
markdata->append_mode = 1; |
952 |
/* FALLTHROUGH */ |
908 |
/* FALLTHROUGH */ |
953 |
case '>': |
909 |
case '>': |
954 |
if (od == '>') |
910 |
if (od == '>') |
955 |
markdata->write_buffer = 1; |
911 |
markdata->write_buffer = 1; |
956 |
/* FALLTHROUGH */ |
912 |
/* FALLTHROUGH */ |
957 |
case ' ': |
913 |
case ' ': |
958 |
case '\r': |
914 |
case '\r': |
959 |
if (!markdata->second) |
915 |
if (!markdata->second) { |
960 |
{ |
916 |
markdata->second++; |
961 |
markdata->second++; |
917 |
markdata->x1 = cx; |
962 |
markdata->x1 = cx; |
918 |
markdata->y1 = cy; |
963 |
markdata->y1 = cy; |
919 |
revto(cx, cy); |
964 |
revto(cx, cy); |
920 |
LMsg(0, "First mark set - Column %d Line %d", cx + 1, W2D(cy) + 1); |
965 |
LMsg(0, "First mark set - Column %d Line %d", cx+1, W2D(cy)+1); |
921 |
break; |
966 |
break; |
922 |
} else { |
967 |
} |
923 |
int append_mode = markdata->append_mode; |
968 |
else |
924 |
int write_buffer = markdata->write_buffer; |
969 |
{ |
925 |
|
970 |
int append_mode = markdata->append_mode; |
926 |
x2 = cx; |
971 |
int write_buffer = markdata->write_buffer; |
927 |
y2 = cy; |
972 |
|
928 |
newcopylen = rem(markdata->x1, markdata->y1, x2, y2, 2, (char *)0, 0); /* count */ |
973 |
x2 = cx; |
929 |
if (md_user->u_plop.buf && !append_mode) |
974 |
y2 = cy; |
930 |
UserFreeCopyBuffer(md_user); |
975 |
newcopylen = rem(markdata->x1, markdata->y1, x2, y2, 2, (char *)0, 0); /* count */ |
931 |
yend = fore->w_height - 1; |
976 |
if (md_user->u_plop.buf && !append_mode) |
932 |
if (fore->w_histheight - markdata->hist_offset < fore->w_height) { |
977 |
UserFreeCopyBuffer(md_user); |
933 |
markdata->second = 0; |
978 |
yend = fore->w_height - 1; |
934 |
yend -= MarkScrollUpDisplay(fore->w_histheight - markdata->hist_offset); |
979 |
if (fore->w_histheight - markdata->hist_offset < fore->w_height) |
935 |
} |
980 |
{ |
936 |
if (newcopylen > 0) { |
981 |
markdata->second = 0; |
|
|
982 |
yend -= MarkScrollUpDisplay(fore->w_histheight - markdata->hist_offset); |
983 |
} |
984 |
if (newcopylen > 0) |
985 |
{ |
986 |
/* the +3 below is for : cr + lf + \0 */ |
937 |
/* the +3 below is for : cr + lf + \0 */ |
987 |
if (md_user->u_plop.buf) |
938 |
if (md_user->u_plop.buf) |
988 |
md_user->u_plop.buf = realloc(md_user->u_plop.buf, |
939 |
md_user->u_plop.buf = realloc(md_user->u_plop.buf, (unsigned)(md_user->u_plop.len + newcopylen + 3)); |
989 |
(unsigned) (md_user->u_plop.len + newcopylen + 3)); |
940 |
else { |
990 |
else |
941 |
md_user->u_plop.len = 0; |
991 |
{ |
942 |
md_user->u_plop.buf = malloc((unsigned)(newcopylen + 3)); |
992 |
md_user->u_plop.len = 0; |
943 |
} |
993 |
md_user->u_plop.buf = malloc((unsigned) (newcopylen + 3)); |
944 |
if (!md_user->u_plop.buf) { |
994 |
} |
945 |
MarkAbort(); |
995 |
if (!md_user->u_plop.buf) |
946 |
in_mark = 0; |
996 |
{ |
947 |
LMsg(0, "Not enough memory... Sorry."); |
997 |
MarkAbort(); |
948 |
md_user->u_plop.len = 0; |
998 |
in_mark = 0; |
949 |
md_user->u_plop.buf = 0; |
999 |
LMsg(0, "Not enough memory... Sorry."); |
950 |
break; |
1000 |
md_user->u_plop.len = 0; |
951 |
} |
1001 |
md_user->u_plop.buf = 0; |
952 |
if (append_mode) { |
1002 |
break; |
953 |
switch (markdata->nonl) { |
1003 |
} |
|
|
1004 |
if (append_mode) |
1005 |
{ |
1006 |
switch (markdata->nonl) |
1007 |
{ |
1008 |
/* |
954 |
/* |
1009 |
* this code defines, what glues lines together |
955 |
* this code defines, what glues lines together |
1010 |
*/ |
956 |
*/ |
1011 |
case 0: |
957 |
case 0: |
1012 |
if (join_with_cr) |
958 |
if (join_with_cr) { |
1013 |
{ |
959 |
md_user->u_plop.buf[md_user->u_plop.len] = '\r'; |
1014 |
md_user->u_plop.buf[md_user->u_plop.len] = '\r'; |
960 |
md_user->u_plop.len++; |
1015 |
md_user->u_plop.len++; |
961 |
} |
1016 |
} |
962 |
md_user->u_plop.buf[md_user->u_plop.len] = '\n'; |
1017 |
md_user->u_plop.buf[md_user->u_plop.len] = '\n'; |
963 |
md_user->u_plop.len++; |
1018 |
md_user->u_plop.len++; |
964 |
break; |
1019 |
break; |
965 |
case 1: |
1020 |
case 1: |
966 |
break; |
1021 |
break; |
967 |
case 2: |
1022 |
case 2: |
968 |
md_user->u_plop.buf[md_user->u_plop.len] = ' '; |
1023 |
md_user->u_plop.buf[md_user->u_plop.len] = ' '; |
969 |
md_user->u_plop.len++; |
1024 |
md_user->u_plop.len++; |
970 |
break; |
1025 |
break; |
971 |
case 3: |
1026 |
case 3: |
972 |
md_user->u_plop.buf[md_user->u_plop.len] = ','; |
1027 |
md_user->u_plop.buf[md_user->u_plop.len] = ','; |
973 |
md_user->u_plop.len++; |
1028 |
md_user->u_plop.len++; |
974 |
break; |
1029 |
break; |
975 |
} |
1030 |
} |
976 |
} |
1031 |
} |
977 |
md_user->u_plop.len += rem(markdata->x1, |
1032 |
md_user->u_plop.len += rem(markdata->x1, markdata->y1, x2, y2, |
978 |
markdata->y1, |
1033 |
markdata->hist_offset == fore->w_histheight, |
979 |
x2, |
1034 |
md_user->u_plop.buf + md_user->u_plop.len, yend); |
980 |
y2, |
|
|
981 |
markdata->hist_offset == fore->w_histheight, |
982 |
md_user->u_plop.buf + md_user->u_plop.len, |
983 |
yend); |
1035 |
#ifdef ENCODINGS |
984 |
#ifdef ENCODINGS |
1036 |
md_user->u_plop.enc = fore->w_encoding; |
985 |
md_user->u_plop.enc = fore->w_encoding; |
1037 |
#endif |
986 |
#endif |
1038 |
} |
987 |
} |
1039 |
if (markdata->hist_offset != fore->w_histheight) |
988 |
if (markdata->hist_offset != fore->w_histheight) { |
1040 |
{ |
989 |
LAY_CALL_UP(LRefreshAll(flayer, 0)); |
1041 |
LAY_CALL_UP(LRefreshAll(flayer, 0)); |
990 |
} |
1042 |
} |
991 |
ExitOverlayPage(); |
1043 |
ExitOverlayPage(); |
992 |
WindowChanged(fore, 'P'); |
1044 |
WindowChanged(fore, 'P'); |
993 |
|
1045 |
if (append_mode) |
994 |
if (append_mode) |
1046 |
LMsg(0, "Appended %d characters to buffer", |
995 |
LMsg(0, "Appended %d characters to buffer", newcopylen); |
1047 |
newcopylen); |
996 |
else |
1048 |
else |
997 |
LMsg(0, "Copied %d characters into buffer", md_user->u_plop.len); |
1049 |
LMsg(0, "Copied %d characters into buffer", md_user->u_plop.len); |
998 |
|
1050 |
if (write_buffer) |
999 |
if (write_buffer) |
1051 |
WriteFile(md_user, (char *)0, DUMP_EXCHANGE); |
1000 |
WriteFile(md_user, (char *)0, DUMP_EXCHANGE); |
1052 |
in_mark = 0; |
1001 |
in_mark = 0; |
1053 |
break; |
1002 |
break; |
1054 |
} |
1003 |
} |
1055 |
|
|
|
1056 |
case 0222: |
1057 |
if (flayer->l_mouseevent.start) |
1058 |
{ |
1059 |
int button = flayer->l_mouseevent.buffer[0]; |
1060 |
if (button == 'a') |
1061 |
{ |
1062 |
/* Scroll down */ |
1063 |
od = 'j'; |
1064 |
} |
1065 |
else if (button == '`') |
1066 |
{ |
1067 |
/* Scroll up */ |
1068 |
od = 'k'; |
1069 |
} |
1070 |
else if (button == ' ') |
1071 |
{ |
1072 |
/* Left click */ |
1073 |
cx = flayer->l_mouseevent.buffer[1]; |
1074 |
cy = D2W(flayer->l_mouseevent.buffer[2]); |
1075 |
revto(cx, cy); |
1076 |
od = ' '; |
1077 |
} |
1078 |
else |
1079 |
od = 0; |
1080 |
LayProcessMouseSwitch(flayer, 0); |
1081 |
if (od) |
1082 |
goto processchar; |
1083 |
} |
1084 |
else |
1085 |
LayProcessMouseSwitch(flayer, 1); |
1086 |
break; |
1087 |
|
1004 |
|
1088 |
default: |
1005 |
case 0222: |
1089 |
MarkAbort(); |
1006 |
if (flayer->l_mouseevent.start) { |
1090 |
LMsg(0, "Copy mode aborted"); |
1007 |
int button = flayer->l_mouseevent.buffer[0]; |
1091 |
in_mark = 0; |
1008 |
if (button == 'a') { |
1092 |
break; |
1009 |
/* Scroll down */ |
1093 |
} |
1010 |
od = 'j'; |
1094 |
if (in_mark) /* markdata may be freed */ |
1011 |
} else if (button == '`') { |
1095 |
markdata->rep_cnt = 0; |
1012 |
/* Scroll up */ |
1096 |
} |
1013 |
od = 'k'; |
1097 |
if (in_mark) |
1014 |
} else if (button == ' ') { |
1098 |
{ |
1015 |
/* Left click */ |
1099 |
flayer->l_x = markdata->cx; |
1016 |
cx = flayer->l_mouseevent.buffer[1]; |
1100 |
flayer->l_y = W2D(markdata->cy); |
1017 |
cy = D2W(flayer->l_mouseevent.buffer[2]); |
1101 |
} |
1018 |
revto(cx, cy); |
1102 |
*inbufp = pt; |
1019 |
od = ' '; |
1103 |
*inlenp = inlen; |
1020 |
} else |
|
|
1021 |
od = 0; |
1022 |
LayProcessMouseSwitch(flayer, 0); |
1023 |
if (od) |
1024 |
goto processchar; |
1025 |
} else |
1026 |
LayProcessMouseSwitch(flayer, 1); |
1027 |
break; |
1028 |
|
1029 |
default: |
1030 |
MarkAbort(); |
1031 |
LMsg(0, "Copy mode aborted"); |
1032 |
in_mark = 0; |
1033 |
break; |
1034 |
} |
1035 |
if (in_mark) /* markdata may be freed */ |
1036 |
markdata->rep_cnt = 0; |
1037 |
} |
1038 |
if (in_mark) { |
1039 |
flayer->l_x = markdata->cx; |
1040 |
flayer->l_y = W2D(markdata->cy); |
1041 |
} |
1042 |
*inbufp = pt; |
1043 |
*inlenp = inlen; |
1104 |
} |
1044 |
} |
1105 |
|
1045 |
|
1106 |
void revto(tx, ty) |
1046 |
void |
1107 |
int tx, ty; |
1047 |
revto(int tx, int ty) |
1108 |
{ |
1048 |
{ |
1109 |
revto_line(tx, ty, -1); |
1049 |
revto_line(tx, ty, -1); |
1110 |
} |
1050 |
} |
1111 |
|
1051 |
|
1112 |
/* tx, ty: WINDOW, line: DISPLAY */ |
1052 |
/* tx, ty: WINDOW, line: DISPLAY */ |
1113 |
void revto_line(tx, ty, line) |
1053 |
void |
1114 |
int tx, ty, line; |
1054 |
revto_line(int tx, int ty, int line) |
1115 |
{ |
1055 |
{ |
1116 |
int fx, fy; |
1056 |
int fx, fy; |
1117 |
int x, y, t, revst, reven, qq, ff, tt, st, en, ce = 0; |
1057 |
int x, y, t, revst, reven, qq, ff, tt, st, en, ce = 0; |
1118 |
int ystart = 0, yend = fore->w_height-1; |
1058 |
int ystart = 0, yend = fore->w_height - 1; |
1119 |
int i, ry; |
1059 |
int i, ry; |
1120 |
unsigned char *wi; |
1060 |
unsigned char *wi; |
1121 |
struct mline *ml; |
1061 |
struct mline *ml; |
1122 |
struct mchar mc; |
1062 |
struct mchar mc; |
1123 |
|
1063 |
|
1124 |
if (tx < 0) |
1064 |
if (tx < 0) |
1125 |
tx = 0; |
1065 |
tx = 0; |
1126 |
else if (tx > fore->w_width - 1) |
1066 |
else if (tx > fore->w_width - 1) |
1127 |
tx = fore->w_width -1; |
1067 |
tx = fore->w_width - 1; |
1128 |
if (ty < fore->w_histheight - fore->w_scrollback_height) |
1068 |
if (ty < fore->w_histheight - fore->w_scrollback_height) |
1129 |
ty = fore->w_histheight - fore->w_scrollback_height; |
1069 |
ty = fore->w_histheight - fore->w_scrollback_height; |
1130 |
else if (ty > fore->w_histheight + fore->w_height - 1) |
1070 |
else if (ty > fore->w_histheight + fore->w_height - 1) |
1131 |
ty = fore->w_histheight + fore->w_height - 1; |
1071 |
ty = fore->w_histheight + fore->w_height - 1; |
1132 |
|
1072 |
|
1133 |
fx = markdata->cx; fy = markdata->cy; |
1073 |
fx = markdata->cx; |
|
|
1074 |
fy = markdata->cy; |
1134 |
|
1075 |
|
1135 |
#ifdef DW_CHARS |
1076 |
#ifdef DW_CHARS |
1136 |
/* don't just move inside of a kanji, the user wants to see something */ |
1077 |
/* don't just move inside of a kanji, the user wants to see something */ |
1137 |
ml = WIN(ty); |
1078 |
ml = WIN(ty); |
1138 |
if (ty == fy && fx + 1 == tx && dw_right(ml, tx, fore->w_encoding) && tx < D_width - 1) |
1079 |
if (ty == fy && fx + 1 == tx && dw_right(ml, tx, fore->w_encoding) && tx < D_width - 1) |
1139 |
tx++; |
1080 |
tx++; |
1140 |
if (ty == fy && fx - 1 == tx && dw_right(ml, fx, fore->w_encoding) && tx) |
1081 |
if (ty == fy && fx - 1 == tx && dw_right(ml, fx, fore->w_encoding) && tx) |
1141 |
tx--; |
1082 |
tx--; |
1142 |
#endif |
1083 |
#endif |
1143 |
|
1084 |
|
1144 |
markdata->cx = tx; markdata->cy = ty; |
1085 |
markdata->cx = tx; |
|
|
1086 |
markdata->cy = ty; |
1145 |
|
1087 |
|
1146 |
/* |
1088 |
/* |
1147 |
* if we go to a position that is currently offscreen |
1089 |
* if we go to a position that is currently offscreen |
1148 |
* then scroll the screen |
1090 |
* then scroll the screen |
1149 |
*/ |
1091 |
*/ |
1150 |
i = 0; |
1092 |
i = 0; |
1151 |
if (line >= 0 && line < fore->w_height) |
1093 |
|
1152 |
i = W2D(ty) - line; |
1094 |
if (line >= 0 && line < fore->w_height) |
1153 |
else if (ty < markdata->hist_offset) |
1095 |
i = W2D(ty) - line; |
1154 |
i = ty - markdata->hist_offset; |
1096 |
else if (ty < markdata->hist_offset) |
1155 |
else if (ty > markdata->hist_offset + (fore->w_height - 1)) |
1097 |
i = ty - markdata->hist_offset; |
1156 |
i = ty - markdata->hist_offset - (fore->w_height - 1); |
1098 |
else if (ty > markdata->hist_offset + (fore->w_height - 1)) |
1157 |
if (i > 0) |
1099 |
i = ty - markdata->hist_offset - (fore->w_height - 1); |
1158 |
yend -= MarkScrollUpDisplay(i); |
1100 |
|
1159 |
else if (i < 0) |
1101 |
if (i > 0) |
1160 |
ystart += MarkScrollDownDisplay(-i); |
1102 |
yend -= MarkScrollUpDisplay(i); |
1161 |
|
1103 |
else if (i < 0) |
1162 |
if (markdata->second == 0) |
1104 |
ystart += MarkScrollDownDisplay(-i); |
1163 |
{ |
1105 |
|
1164 |
flayer->l_x = tx; |
1106 |
if (markdata->second == 0) { |
1165 |
flayer->l_y = W2D(ty); |
1107 |
flayer->l_x = tx; |
1166 |
LGotoPos(flayer, tx, W2D(ty)); |
1108 |
flayer->l_y = W2D(ty); |
1167 |
return; |
1109 |
LGotoPos(flayer, tx, W2D(ty)); |
1168 |
} |
1110 |
return; |
1169 |
|
1111 |
} |
1170 |
qq = markdata->x1 + markdata->y1 * fore->w_width; |
1112 |
|
1171 |
ff = fx + fy * fore->w_width; /* "from" offset in WIN coords */ |
1113 |
qq = markdata->x1 + markdata->y1 * fore->w_width; |
1172 |
tt = tx + ty * fore->w_width; /* "to" offset in WIN coords*/ |
1114 |
ff = fx + fy * fore->w_width; /* "from" offset in WIN coords */ |
1173 |
|
1115 |
tt = tx + ty * fore->w_width; /* "to" offset in WIN coords*/ |
1174 |
if (ff > tt) |
1116 |
|
1175 |
{ |
1117 |
if (ff > tt) { |
1176 |
st = tt; en = ff; |
1118 |
st = tt; |
1177 |
x = tx; y = ty; |
1119 |
en = ff; |
1178 |
} |
1120 |
x = tx; |
1179 |
else |
1121 |
y = ty; |
1180 |
{ |
1122 |
} else { |
1181 |
st = ff; en = tt; |
1123 |
st = ff; |
1182 |
x = fx; y = fy; |
1124 |
en = tt; |
1183 |
} |
1125 |
x = fx; |
1184 |
if (st > qq) |
1126 |
y = fy; |
1185 |
{ |
1127 |
} |
1186 |
st++; |
1128 |
|
1187 |
x++; |
1129 |
if (st > qq) { |
1188 |
} |
1130 |
st++; |
1189 |
if (en < qq) |
1131 |
x++; |
1190 |
en--; |
|
|
1191 |
if (tt > qq) |
1192 |
{ |
1193 |
revst = qq; reven = tt; |
1194 |
} |
1195 |
else |
1196 |
{ |
1197 |
revst = tt; reven = qq; |
1198 |
} |
1199 |
ry = y - markdata->hist_offset; |
1200 |
if (ry < ystart) |
1201 |
{ |
1202 |
y += (ystart - ry); |
1203 |
x = 0; |
1204 |
st = y * fore->w_width; |
1205 |
ry = ystart; |
1206 |
} |
1207 |
ml = WIN(y); |
1208 |
for (t = st; t <= en; t++, x++) |
1209 |
{ |
1210 |
if (x >= fore->w_width) |
1211 |
{ |
1212 |
x = 0; |
1213 |
y++, ry++; |
1214 |
ml = WIN(y); |
1215 |
} |
1216 |
if (ry > yend) |
1217 |
break; |
1218 |
if (t == st || x == 0) |
1219 |
{ |
1220 |
wi = ml->image + fore->w_width; |
1221 |
for (ce = fore->w_width; ce >= 0; ce--, wi--) |
1222 |
if (*wi != ' ') |
1223 |
break; |
1224 |
} |
1132 |
} |
1225 |
if (x <= ce && x >= markdata->left_mar && x <= markdata->right_mar) |
1133 |
|
1226 |
{ |
1134 |
if (en < qq) |
|
|
1135 |
en--; |
1136 |
|
1137 |
if (tt > qq) { |
1138 |
revst = qq; |
1139 |
reven = tt; |
1140 |
} else { |
1141 |
revst = tt; |
1142 |
reven = qq; |
1143 |
} |
1144 |
ry = y - markdata->hist_offset; |
1145 |
|
1146 |
if (ry < ystart) { |
1147 |
y += (ystart - ry); |
1148 |
x = 0; |
1149 |
st = y * fore->w_width; |
1150 |
ry = ystart; |
1151 |
} |
1152 |
ml = WIN(y); |
1153 |
|
1154 |
for (t = st; t <= en; t++, x++) { |
1155 |
if (x >= fore->w_width) { |
1156 |
x = 0; |
1157 |
y++, ry++; |
1158 |
ml = WIN(y); |
1159 |
} |
1160 |
if (ry > yend) |
1161 |
break; |
1162 |
if (t == st || x == 0) { |
1163 |
wi = ml->image + fore->w_width; |
1164 |
for (ce = fore->w_width; ce >= 0; ce--, wi--) |
1165 |
if (*wi != ' ') |
1166 |
break; |
1167 |
} |
1168 |
|
1169 |
if (x <= ce && x >= markdata->left_mar && x <= markdata->right_mar) { |
1227 |
#ifdef DW_CHARS |
1170 |
#ifdef DW_CHARS |
1228 |
if (dw_right(ml, x, fore->w_encoding)) |
1171 |
if (dw_right(ml, x, fore->w_encoding)) { |
1229 |
{ |
1172 |
if (t == revst) |
1230 |
if (t == revst) |
1173 |
revst--; |
1231 |
revst--; |
1174 |
t--; |
1232 |
t--; |
1175 |
x--; |
1233 |
x--; |
1176 |
} |
1234 |
} |
|
|
1235 |
#endif |
1177 |
#endif |
1236 |
if (t >= revst && t <= reven) |
1178 |
if (t >= revst && t <= reven) { |
1237 |
{ |
1179 |
mc = mchar_so; |
1238 |
mc = mchar_so; |
|
|
1239 |
#ifdef FONT |
1180 |
#ifdef FONT |
1240 |
if (pastefont) |
1181 |
if (pastefont) { |
1241 |
{ |
1182 |
mc.font = ml->font[x]; |
1242 |
mc.font = ml->font[x]; |
1183 |
mc.fontx = ml->fontx[x]; |
1243 |
mc.fontx = ml->fontx[x]; |
1184 |
} |
1244 |
} |
|
|
1245 |
#endif |
1185 |
#endif |
1246 |
mc.image = ml->image[x]; |
1186 |
mc.image = ml->image[x]; |
1247 |
} |
1187 |
} else |
1248 |
else |
1188 |
copy_mline2mchar(&mc, ml, x); |
1249 |
copy_mline2mchar(&mc, ml, x); |
|
|
1250 |
#ifdef DW_CHARS |
1189 |
#ifdef DW_CHARS |
1251 |
if (dw_left(ml, x, fore->w_encoding)) |
1190 |
if (dw_left(ml, x, fore->w_encoding)) { |
1252 |
{ |
1191 |
mc.mbcs = ml->image[x + 1]; |
1253 |
mc.mbcs = ml->image[x + 1]; |
1192 |
LPutChar(flayer, &mc, x, W2D(y)); |
1254 |
LPutChar(flayer, &mc, x, W2D(y)); |
1193 |
t++; |
1255 |
t++; |
1194 |
} |
1256 |
} |
|
|
1257 |
#endif |
1195 |
#endif |
1258 |
LPutChar(flayer, &mc, x, W2D(y)); |
1196 |
LPutChar(flayer, &mc, x, W2D(y)); |
1259 |
#ifdef DW_CHARS |
1197 |
#ifdef DW_CHARS |
1260 |
if (dw_left(ml, x, fore->w_encoding)) |
1198 |
if (dw_left(ml, x, fore->w_encoding)) |
1261 |
x++; |
1199 |
x++; |
1262 |
#endif |
1200 |
#endif |
|
|
1201 |
} |
1263 |
} |
1202 |
} |
1264 |
} |
1203 |
flayer->l_x = tx; |
1265 |
flayer->l_x = tx; |
1204 |
flayer->l_y = W2D(ty); |
1266 |
flayer->l_y = W2D(ty); |
1205 |
LGotoPos(flayer, tx, W2D(ty)); |
1267 |
LGotoPos(flayer, tx, W2D(ty)); |
|
|
1268 |
} |
1206 |
} |
1269 |
|
1207 |
|
1270 |
static void |
1208 |
static void |
1271 |
MarkAbort() |
1209 |
MarkAbort() |
1272 |
{ |
1210 |
{ |
1273 |
int yend, redisp; |
1211 |
int yend, redisp; |
1274 |
|
1212 |
|
1275 |
debug("MarkAbort\n"); |
1213 |
debug("MarkAbort\n"); |
1276 |
markdata = (struct markdata *)flayer->l_data; |
1214 |
markdata = (struct markdata *)flayer->l_data; |
1277 |
fore = markdata->md_window; |
1215 |
fore = markdata->md_window; |
1278 |
yend = fore->w_height - 1; |
1216 |
yend = fore->w_height - 1; |
1279 |
redisp = markdata->second; |
1217 |
redisp = markdata->second; |
1280 |
if (fore->w_histheight - markdata->hist_offset < fore->w_height) |
1218 |
if (fore->w_histheight - markdata->hist_offset < fore->w_height) { |
1281 |
{ |
1219 |
markdata->second = 0; |
1282 |
markdata->second = 0; |
1220 |
yend -= MarkScrollUpDisplay(fore->w_histheight - markdata->hist_offset); |
1283 |
yend -= MarkScrollUpDisplay(fore->w_histheight - markdata->hist_offset); |
1221 |
} |
1284 |
} |
1222 |
if (markdata->hist_offset != fore->w_histheight) { |
1285 |
if (markdata->hist_offset != fore->w_histheight) |
1223 |
LAY_CALL_UP(LRefreshAll(flayer, 0)); |
1286 |
{ |
1224 |
} else { |
1287 |
LAY_CALL_UP(LRefreshAll(flayer, 0)); |
1225 |
rem(markdata->x1, markdata->y1, markdata->cx, markdata->cy, redisp, (char *)0, yend); |
1288 |
} |
1226 |
} |
1289 |
else |
1227 |
ExitOverlayPage(); |
1290 |
{ |
1228 |
WindowChanged(fore, 'P'); |
1291 |
rem(markdata->x1, markdata->y1, markdata->cx, markdata->cy, redisp, (char *)0, yend); |
|
|
1292 |
} |
1293 |
ExitOverlayPage(); |
1294 |
WindowChanged(fore, 'P'); |
1295 |
} |
1229 |
} |
1296 |
|
1230 |
|
1297 |
|
|
|
1298 |
static void |
1231 |
static void |
1299 |
MarkRedisplayLine(y, xs, xe, isblank) |
1232 |
MarkRedisplayLine(int y, int xs, int xe, int isblank) /* NOTE: y is in DISPLAY coords system! */ |
1300 |
int y; /* NOTE: y is in DISPLAY coords system! */ |
|
|
1301 |
int xs, xe; |
1302 |
int isblank; |
1303 |
{ |
1233 |
{ |
1304 |
int wy, x, i, rm; |
1234 |
int wy, x, i, rm; |
1305 |
int sta, sto, cp; /* NOTE: these 3 are in WINDOW coords system */ |
1235 |
int sta, sto, cp; /* NOTE: these 3 are in WINDOW coords system */ |
1306 |
unsigned char *wi; |
1236 |
unsigned char *wi; |
1307 |
struct mline *ml; |
1237 |
struct mline *ml; |
1308 |
struct mchar mchar_marked; |
1238 |
struct mchar mchar_marked; |
1309 |
|
1239 |
|
1310 |
if (y < 0) /* No special full page handling */ |
1240 |
if (y < 0) /* No special full page handling */ |
1311 |
return; |
1241 |
return; |
1312 |
|
1242 |
|
1313 |
markdata = (struct markdata *)flayer->l_data; |
1243 |
markdata = (struct markdata *)flayer->l_data; |
1314 |
fore = markdata->md_window; |
1244 |
fore = markdata->md_window; |
1315 |
|
1245 |
|
1316 |
mchar_marked = mchar_so; |
1246 |
mchar_marked = mchar_so; |
1317 |
|
1247 |
|
1318 |
wy = D2W(y); |
1248 |
wy = D2W(y); |
1319 |
ml = WIN(wy); |
1249 |
ml = WIN(wy); |
1320 |
|
1250 |
|
1321 |
if (markdata->second == 0) |
1251 |
if (markdata->second == 0) { |
1322 |
{ |
1252 |
if (dw_right(ml, xs, fore->w_encoding) && xs > 0) |
1323 |
if (dw_right(ml, xs, fore->w_encoding) && xs > 0) |
1253 |
xs--; |
1324 |
xs--; |
1254 |
if (dw_left(ml, xe, fore->w_encoding) && xe < fore->w_width - 1) |
1325 |
if (dw_left(ml, xe, fore->w_encoding) && xe < fore->w_width - 1) |
1255 |
xe++; |
1326 |
xe++; |
1256 |
if (xs == 0 && y > 0 && wy > 0 && WIN(wy - 1)->image[flayer->l_width] == 0) |
1327 |
if (xs == 0 && y > 0 && wy > 0 && WIN(wy - 1)->image[flayer->l_width] == 0) |
1257 |
LCDisplayLineWrap(flayer, ml, y, xs, xe, isblank); |
1328 |
LCDisplayLineWrap(flayer, ml, y, xs, xe, isblank); |
1258 |
else |
1329 |
else |
1259 |
LCDisplayLine(flayer, ml, y, xs, xe, isblank); |
1330 |
LCDisplayLine(flayer, ml, y, xs, xe, isblank); |
1260 |
return; |
1331 |
return; |
1261 |
} |
1332 |
} |
1262 |
|
1333 |
|
1263 |
sta = markdata->y1 * fore->w_width + markdata->x1; |
1334 |
sta = markdata->y1 * fore->w_width + markdata->x1; |
1264 |
sto = markdata->cy * fore->w_width + markdata->cx; |
1335 |
sto = markdata->cy * fore->w_width + markdata->cx; |
1265 |
if (sta > sto) { |
1336 |
if (sta > sto) |
1266 |
i = sta; |
1337 |
{ |
1267 |
sta = sto; |
1338 |
i=sta; sta=sto; sto=i; |
1268 |
sto = i; |
1339 |
} |
1269 |
} |
1340 |
cp = wy * fore->w_width + xs; |
1270 |
cp = wy * fore->w_width + xs; |
1341 |
|
1271 |
|
1342 |
rm = markdata->right_mar; |
1272 |
rm = markdata->right_mar; |
1343 |
for (x = fore->w_width, wi = ml->image + fore->w_width; x >= 0; x--, wi--) |
1273 |
for (x = fore->w_width, wi = ml->image + fore->w_width; x >= 0; x--, wi--) |
1344 |
if (*wi != ' ') |
1274 |
if (*wi != ' ') |
1345 |
break; |
1275 |
break; |
1346 |
if (x < rm) |
1276 |
if (x < rm) |
1347 |
rm = x; |
1277 |
rm = x; |
1348 |
|
1278 |
|
1349 |
for (x = xs; x <= xe; x++, cp++) |
1279 |
for (x = xs; x <= xe; x++, cp++) |
1350 |
if (cp >= sta && x >= markdata->left_mar) |
1280 |
if (cp >= sta && x >= markdata->left_mar) |
1351 |
break; |
1281 |
break; |
1352 |
#ifdef DW_CHARS |
1282 |
#ifdef DW_CHARS |
1353 |
if (dw_right(ml, x, fore->w_encoding)) |
1283 |
if (dw_right(ml, x, fore->w_encoding)) |
1354 |
x--; |
1284 |
x--; |
1355 |
#endif |
1285 |
#endif |
1356 |
if (x > xs) |
1286 |
if (x > xs) |
1357 |
LCDisplayLine(flayer, ml, y, xs, x - 1, isblank); |
1287 |
LCDisplayLine(flayer, ml, y, xs, x - 1, isblank); |
1358 |
for (; x <= xe; x++, cp++) |
1288 |
for (; x <= xe; x++, cp++) { |
1359 |
{ |
1289 |
if (cp > sto || x > rm) |
1360 |
if (cp > sto || x > rm) |
1290 |
break; |
1361 |
break; |
|
|
1362 |
#ifdef FONT |
1291 |
#ifdef FONT |
1363 |
if (pastefont) |
1292 |
if (pastefont) { |
1364 |
{ |
1293 |
mchar_marked.font = ml->font[x]; |
1365 |
mchar_marked.font = ml->font[x]; |
1294 |
mchar_marked.fontx = ml->fontx[x]; |
1366 |
mchar_marked.fontx = ml->fontx[x]; |
1295 |
} |
1367 |
} |
|
|
1368 |
#endif |
1296 |
#endif |
1369 |
mchar_marked.image = ml->image[x]; |
1297 |
mchar_marked.image = ml->image[x]; |
1370 |
#ifdef DW_CHARS |
1298 |
#ifdef DW_CHARS |
1371 |
mchar_marked.mbcs = 0; |
1299 |
mchar_marked.mbcs = 0; |
1372 |
if (dw_left(ml, x, fore->w_encoding)) |
1300 |
if (dw_left(ml, x, fore->w_encoding)) { |
1373 |
{ |
1301 |
mchar_marked.mbcs = ml->image[x + 1]; |
1374 |
mchar_marked.mbcs = ml->image[x + 1]; |
1302 |
cp++; |
1375 |
cp++; |
1303 |
} |
1376 |
} |
|
|
1377 |
#endif |
1304 |
#endif |
1378 |
LPutChar(flayer, &mchar_marked, x, y); |
1305 |
LPutChar(flayer, &mchar_marked, x, y); |
1379 |
#ifdef DW_CHARS |
1306 |
#ifdef DW_CHARS |
1380 |
if (dw_left(ml, x, fore->w_encoding)) |
1307 |
if (dw_left(ml, x, fore->w_encoding)) |
1381 |
x++; |
1308 |
x++; |
1382 |
#endif |
1309 |
#endif |
1383 |
} |
1310 |
} |
1384 |
if (x <= xe) |
1311 |
if (x <= xe) |
1385 |
LCDisplayLine(flayer, ml, y, x, xe, isblank); |
1312 |
LCDisplayLine(flayer, ml, y, x, xe, isblank); |
1386 |
} |
1313 |
} |
1387 |
|
1314 |
|
1388 |
|
|
|
1389 |
/* |
1315 |
/* |
1390 |
* This ugly routine is to speed up GotoPos() |
1316 |
* This ugly routine is to speed up GotoPos() |
1391 |
*/ |
1317 |
*/ |
1392 |
static int |
1318 |
static int |
1393 |
MarkRewrite(ry, xs, xe, rend, doit) |
1319 |
MarkRewrite(int ry, int xs, int xe, struct mchar *rend, int doit) |
1394 |
int ry, xs, xe, doit; |
|
|
1395 |
struct mchar *rend; |
1396 |
{ |
1320 |
{ |
1397 |
int dx, x, y, st, en, t, rm; |
1321 |
int dx, x, y, st, en, t, rm; |
1398 |
unsigned char *i; |
1322 |
unsigned char *i; |
1399 |
struct mline *ml; |
1323 |
struct mline *ml; |
1400 |
struct mchar mchar_marked; |
1324 |
struct mchar mchar_marked; |
1401 |
|
1325 |
|
1402 |
mchar_marked = mchar_so; |
1326 |
mchar_marked = mchar_so; |
1403 |
|
1327 |
|
1404 |
debug3("MarkRewrite %d, %d-%d\n", ry, xs, xe); |
1328 |
debug3("MarkRewrite %d, %d-%d\n", ry, xs, xe); |
1405 |
markdata = (struct markdata *)flayer->l_data; |
1329 |
markdata = (struct markdata *)flayer->l_data; |
1406 |
fore = markdata->md_window; |
1330 |
fore = markdata->md_window; |
1407 |
y = D2W(ry); |
1331 |
y = D2W(ry); |
1408 |
ml = WIN(y); |
1332 |
ml = WIN(y); |
1409 |
#ifdef UTF8 |
1333 |
#ifdef UTF8 |
1410 |
if (fore->w_encoding && fore->w_encoding != UTF8 && D_encoding == UTF8 && ContainsSpecialDeffont(ml, xs, xe, fore->w_encoding)) |
1334 |
if (fore->w_encoding && fore->w_encoding != UTF8 && D_encoding == UTF8 && ContainsSpecialDeffont(ml, xs, xe, fore->w_encoding)) |
1411 |
return EXPENSIVE; |
1335 |
return EXPENSIVE; |
1412 |
#endif |
1336 |
#endif |
1413 |
dx = xe - xs + 1; |
1337 |
dx = xe - xs + 1; |
1414 |
if (doit) |
1338 |
if (doit) { |
1415 |
{ |
1339 |
i = ml->image + xs; |
1416 |
i = ml->image + xs; |
1340 |
while (dx--) |
1417 |
while (dx--) |
1341 |
PUTCHAR(*i++); |
1418 |
PUTCHAR(*i++); |
1342 |
return 0; |
1419 |
return 0; |
1343 |
} |
1420 |
} |
1344 |
|
1421 |
|
1345 |
if (markdata->second == 0) |
1422 |
if (markdata->second == 0) |
1346 |
st = en = -1; |
1423 |
st = en = -1; |
1347 |
else { |
1424 |
else |
1348 |
st = markdata->y1 * fore->w_width + markdata->x1; |
1425 |
{ |
1349 |
en = markdata->cy * fore->w_width + markdata->cx; |
1426 |
st = markdata->y1 * fore->w_width + markdata->x1; |
1350 |
if (st > en) { |
1427 |
en = markdata->cy * fore->w_width + markdata->cx; |
1351 |
t = st; |
1428 |
if (st > en) |
1352 |
st = en; |
1429 |
{ |
1353 |
en = t; |
1430 |
t = st; st = en; en = t; |
1354 |
} |
1431 |
} |
1355 |
} |
1432 |
} |
1356 |
t = y * fore->w_width + xs; |
1433 |
t = y * fore->w_width + xs; |
1357 |
for (rm = fore->w_width, i = ml->image + fore->w_width; rm >= 0; rm--) |
1434 |
for (rm = fore->w_width, i = ml->image + fore->w_width; rm >= 0; rm--) |
1358 |
if (*i-- != ' ') |
1435 |
if (*i-- != ' ') |
1359 |
break; |
1436 |
break; |
1360 |
if (rm > markdata->right_mar) |
1437 |
if (rm > markdata->right_mar) |
1361 |
rm = markdata->right_mar; |
1438 |
rm = markdata->right_mar; |
1362 |
x = xs; |
1439 |
x = xs; |
1363 |
while (dx--) { |
1440 |
while (dx--) |
1364 |
if (t >= st && t <= en && x >= markdata->left_mar && x <= rm) { |
1441 |
{ |
|
|
1442 |
if (t >= st && t <= en && x >= markdata->left_mar && x <= rm) |
1443 |
{ |
1444 |
#ifdef FONT |
1365 |
#ifdef FONT |
1445 |
if (pastefont) |
1366 |
if (pastefont) { |
1446 |
{ |
1367 |
mchar_marked.font = ml->font[x]; |
1447 |
mchar_marked.font = ml->font[x]; |
1368 |
mchar_marked.fontx = ml->fontx[x]; |
1448 |
mchar_marked.fontx = ml->fontx[x]; |
1369 |
} |
1449 |
} |
|
|
1450 |
#endif |
1370 |
#endif |
1451 |
rend->image = mchar_marked.image; |
1371 |
rend->image = mchar_marked.image; |
1452 |
if (!cmp_mchar(rend, &mchar_marked)) |
1372 |
if (!cmp_mchar(rend, &mchar_marked)) |
1453 |
return EXPENSIVE; |
1373 |
return EXPENSIVE; |
1454 |
} |
1374 |
} else { |
1455 |
else |
1375 |
rend->image = ml->image[x]; |
1456 |
{ |
1376 |
if (!cmp_mchar_mline(rend, ml, x)) |
1457 |
rend->image = ml->image[x]; |
1377 |
return EXPENSIVE; |
1458 |
if (!cmp_mchar_mline(rend, ml, x)) |
1378 |
} |
1459 |
return EXPENSIVE; |
1379 |
x++; |
1460 |
} |
1380 |
} |
1461 |
x++; |
1381 |
return xe - xs + 1; |
1462 |
} |
|
|
1463 |
return xe - xs + 1; |
1464 |
} |
1382 |
} |
1465 |
|
1383 |
|
1466 |
|
|
|
1467 |
/* |
1384 |
/* |
1468 |
* scroll the screen contents up/down. |
1385 |
* scroll the screen contents up/down. |
1469 |
*/ |
1386 |
*/ |
1470 |
static int MarkScrollUpDisplay(n) |
1387 |
static int |
1471 |
int n; |
1388 |
MarkScrollUpDisplay(int n) |
1472 |
{ |
1389 |
{ |
1473 |
int i; |
1390 |
int i; |
1474 |
|
1391 |
|
1475 |
debug1("MarkScrollUpDisplay(%d)\n", n); |
1392 |
debug1("MarkScrollUpDisplay(%d)\n", n); |
1476 |
if (n <= 0) |
1393 |
if (n <= 0) |
1477 |
return 0; |
1394 |
return 0; |
1478 |
if (n > fore->w_histheight - markdata->hist_offset) |
1395 |
if (n > fore->w_histheight - markdata->hist_offset) |
1479 |
n = fore->w_histheight - markdata->hist_offset; |
1396 |
n = fore->w_histheight - markdata->hist_offset; |
1480 |
markdata->hist_offset += n; |
1397 |
|
1481 |
i = (n < flayer->l_height) ? n : (flayer->l_height); |
1398 |
markdata->hist_offset += n; |
1482 |
LScrollV(flayer, i, 0, flayer->l_height - 1, 0); |
1399 |
i = (n < flayer->l_height) ? n : (flayer->l_height); |
1483 |
while (i-- > 0) |
1400 |
LScrollV(flayer, i, 0, flayer->l_height - 1, 0); |
1484 |
MarkRedisplayLine(flayer->l_height - i - 1, 0, flayer->l_width - 1, 1); |
1401 |
while (i-- > 0) |
1485 |
return n; |
1402 |
MarkRedisplayLine(flayer->l_height - i - 1, 0, flayer->l_width - 1, 1); |
|
|
1403 |
return n; |
1486 |
} |
1404 |
} |
1487 |
|
1405 |
|
1488 |
static int |
1406 |
static int |
1489 |
MarkScrollDownDisplay(n) |
1407 |
MarkScrollDownDisplay(int n) |
1490 |
int n; |
|
|
1491 |
{ |
1408 |
{ |
1492 |
int i; |
1409 |
int i; |
1493 |
|
1410 |
|
1494 |
debug1("MarkScrollDownDisplay(%d)\n", n); |
1411 |
debug1("MarkScrollDownDisplay(%d)\n", n); |
1495 |
if (n <= 0) |
1412 |
if (n <= 0) |
1496 |
return 0; |
1413 |
return 0; |
1497 |
if (n > markdata->hist_offset) |
1414 |
if (n > markdata->hist_offset) |
1498 |
n = markdata->hist_offset; |
1415 |
n = markdata->hist_offset; |
1499 |
markdata->hist_offset -= n; |
1416 |
markdata->hist_offset -= n; |
1500 |
i = (n < flayer->l_height) ? n : (flayer->l_height); |
1417 |
i = (n < flayer->l_height) ? n : (flayer->l_height); |
1501 |
LScrollV(flayer, -i, 0, fore->w_height - 1, 0); |
1418 |
LScrollV(flayer, -i, 0, fore->w_height - 1, 0); |
1502 |
while (i-- > 0) |
1419 |
while (i-- > 0) |
1503 |
MarkRedisplayLine(i, 0, flayer->l_width - 1, 1); |
1420 |
MarkRedisplayLine(i, 0, flayer->l_width - 1, 1); |
1504 |
return n; |
1421 |
return n; |
1505 |
} |
1422 |
} |
1506 |
|
1423 |
|
1507 |
void |
1424 |
void |
1508 |
MakePaster(pa, buf, len, bufiscopy) |
1425 |
MakePaster(struct paster *pa, char *buf, int len, int bufiscopy) |
1509 |
struct paster *pa; |
|
|
1510 |
char *buf; |
1511 |
int len; |
1512 |
int bufiscopy; |
1513 |
{ |
1426 |
{ |
1514 |
FreePaster(pa); |
1427 |
FreePaster(pa); |
1515 |
pa->pa_pasteptr = buf; |
1428 |
pa->pa_pasteptr = buf; |
1516 |
pa->pa_pastelen = len; |
1429 |
pa->pa_pastelen = len; |
1517 |
if (bufiscopy) |
1430 |
if (bufiscopy) |
1518 |
pa->pa_pastebuf = buf; |
1431 |
pa->pa_pastebuf = buf; |
1519 |
pa->pa_pastelayer = flayer; |
1432 |
pa->pa_pastelayer = flayer; |
1520 |
DoProcess(Layer2Window(flayer), &pa->pa_pasteptr, &pa->pa_pastelen, pa); |
1433 |
DoProcess(Layer2Window(flayer), &pa->pa_pasteptr, &pa->pa_pastelen, pa); |
1521 |
} |
1434 |
} |
1522 |
|
1435 |
|
1523 |
void |
1436 |
void |
1524 |
FreePaster(pa) |
1437 |
FreePaster(struct paster *pa) |
1525 |
struct paster *pa; |
|
|
1526 |
{ |
1438 |
{ |
1527 |
if (pa->pa_pastebuf) |
1439 |
if (pa->pa_pastebuf) |
1528 |
free(pa->pa_pastebuf); |
1440 |
free(pa->pa_pastebuf); |
1529 |
pa->pa_pastebuf = 0; |
1441 |
pa->pa_pastebuf = 0; |
1530 |
pa->pa_pasteptr = 0; |
1442 |
pa->pa_pasteptr = 0; |
1531 |
pa->pa_pastelen = 0; |
1443 |
pa->pa_pastelen = 0; |
1532 |
pa->pa_pastelayer = 0; |
1444 |
pa->pa_pastelayer = 0; |
1533 |
evdeq(&pa->pa_slowev); |
1445 |
evdeq(&pa->pa_slowev); |
1534 |
} |
1446 |
} |
1535 |
|
1447 |
|
1536 |
#endif /* COPY_PASTE */ |
1448 |
#endif /* COPY_PASTE */ |