Imported Debian patch 20061119-1
Trent Buck
17 years ago
0 | /* $OpenBSD: basic.c,v 1.26 2006/07/25 08:27:09 kjell Exp $ */ | |
0 | /* $OpenBSD: basic.c,v 1.27 2006/11/18 20:36:50 kjell Exp $ */ | |
1 | 1 | |
2 | 2 | /* This file is in the public domain */ |
3 | 3 | |
272 | 272 | lp = curwp->w_linep; |
273 | 273 | while (n-- && lforw(lp) != curbp->b_headp) { |
274 | 274 | lp = lforw(lp); |
275 | curwp->w_dotline++; | |
276 | 275 | } |
277 | 276 | curwp->w_linep = lp; |
278 | 277 | curwp->w_flag |= WFFULL; |
280 | 279 | for (n = curwp->w_ntrows; n-- && lp != curbp->b_headp; lp = lforw(lp)) |
281 | 280 | if (lp == curwp->w_dotp) |
282 | 281 | return (TRUE); |
283 | curwp->w_dotp = curwp->w_linep; | |
282 | /* Advance the dot the slow way, for line nos */ | |
283 | while (curwp->w_dotp != curwp->w_linep) { | |
284 | curwp->w_dotp = lforw(curwp->w_dotp); | |
285 | curwp->w_dotline++; | |
286 | } | |
284 | 287 | curwp->w_doto = 0; |
285 | 288 | return (TRUE); |
286 | 289 | } |
312 | 315 | lp = curwp->w_linep; |
313 | 316 | while (n-- && lback(lp) != curbp->b_headp) { |
314 | 317 | lp = lback(lp); |
315 | curwp->w_dotline--; | |
316 | 318 | } |
317 | 319 | curwp->w_linep = lp; |
318 | 320 | curwp->w_flag |= WFFULL; |
320 | 322 | for (n = curwp->w_ntrows; n-- && lp != curbp->b_headp; lp = lforw(lp)) |
321 | 323 | if (lp == curwp->w_dotp) |
322 | 324 | return (TRUE); |
323 | curwp->w_dotp = curwp->w_linep; | |
325 | /* Move the dot the slow way, for line nos */ | |
326 | while (curwp->w_dotp != curwp->w_linep) { | |
327 | curwp->w_dotp = lback(curwp->w_dotp); | |
328 | curwp->w_dotline--; | |
329 | } | |
324 | 330 | curwp->w_doto = 0; |
325 | 331 | return (TRUE); |
326 | 332 | } |
0 | /* $OpenBSD: buffer.c,v 1.63 2006/07/25 08:27:09 kjell Exp $ */ | |
0 | /* $OpenBSD: buffer.c,v 1.65 2006/11/18 23:05:24 kjell Exp $ */ | |
1 | 1 | |
2 | 2 | /* This file is in the public domain. */ |
3 | 3 | |
19 | 19 | #include "def.h" |
20 | 20 | #include "kbd.h" /* needed for modes */ |
21 | 21 | |
22 | static struct buffer *makelist(void); | |
23 | static struct buffer *bnew(void); | |
22 | static struct buffer *makelist(void); | |
23 | static struct buffer *bnew(const char *); | |
24 | 24 | |
25 | 25 | /* ARGSUSED */ |
26 | 26 | int |
484 | 484 | if (cflag != TRUE) |
485 | 485 | return (NULL); |
486 | 486 | |
487 | bp = bnew(); | |
488 | ||
489 | if ((bp->b_bname = strdup(bname)) == NULL) { | |
490 | ewprintf("Can't get %d bytes", strlen(bname) + 1); | |
491 | free(bp); | |
492 | return (NULL); | |
493 | } | |
487 | bp = bnew(bname); | |
494 | 488 | |
495 | 489 | return (bp); |
496 | 490 | } |
500 | 494 | * all buffers. |
501 | 495 | */ |
502 | 496 | static struct buffer * |
503 | bnew() | |
504 | { | |
505 | struct buffer *bp; | |
497 | bnew(const char *bname) | |
498 | { | |
499 | struct buffer *bp; | |
506 | 500 | struct line *lp; |
507 | 501 | int i; |
508 | 502 | |
540 | 534 | bheadp = bp; |
541 | 535 | bp->b_dotline = bp->b_markline = 1; |
542 | 536 | bp->b_lines = 1; |
537 | if ((bp->b_bname = strdup(bname)) == NULL) { | |
538 | ewprintf("Can't get %d bytes", strlen(bname) + 1); | |
539 | return (NULL); | |
540 | } | |
543 | 541 | |
544 | 542 | return (bp); |
545 | 543 | } |
622 | 620 | wp->w_markp = owp->w_markp; |
623 | 621 | wp->w_marko = owp->w_marko; |
624 | 622 | wp->w_dotline = owp->w_dotline; |
623 | wp->w_markline = owp->w_markline; | |
625 | 624 | break; |
626 | 625 | } |
627 | 626 | wp->w_flag |= WFMODE | flags; |
0 | mg (20061119-1) unstable; urgency=low | |
1 | ||
2 | * New upstream release (Closes: #391827) | |
3 | * control: provides editor (Closes: 396297) | |
4 | * control: follow to latest Debian Policy | |
5 | * control: remove explicit libc6-dev, see | |
6 | http://lintian.debian.org/reports/Tdepends-on-build-essential-package-without-using-version.html | |
7 | ||
8 | -- Trent Buck <trentbuck@gmail.com> Sun, 19 Nov 2006 13:13:20 +1100 | |
9 | ||
0 | 10 | mg (20060919-1) unstable; urgency=low |
1 | 11 | |
2 | 12 | * New upstream release |
1 | 1 | Section: editors |
2 | 2 | Priority: optional |
3 | 3 | Maintainer: Trent Buck <trentbuck@gmail.com> |
4 | Build-Depends: debhelper (>= 4.0.0), autotools-dev, libc6-dev, libncurses-dev | |
5 | Standards-Version: 3.6.2 | |
4 | Build-Depends: debhelper (>= 4.0.0), autotools-dev, libncurses-dev | |
5 | Standards-Version: 3.7.2 | |
6 | 6 | |
7 | 7 | Package: mg |
8 | 8 | Architecture: any |
9 | 9 | Depends: ${shlibs:Depends}, ${misc:Depends} |
10 | 10 | Suggests: zile, qemacs | qemacs-nox |
11 | Provides: editor | |
11 | 12 | Description: microscopic GNU Emacs-style editor |
12 | 13 | This program is intended to be a small, fast, and portable |
13 | 14 | editor for people who can't (or don't want to) run real |
0 | /* $OpenBSD: def.h,v 1.95 2006/07/25 08:27:09 kjell Exp $ */ | |
0 | /* $OpenBSD: def.h,v 1.97 2006/11/17 08:45:31 kjell Exp $ */ | |
1 | 1 | |
2 | 2 | /* This file is in the public domain. */ |
3 | 3 | |
602 | 602 | /* undo.c X */ |
603 | 603 | void free_undo_record(struct undo_rec *); |
604 | 604 | int undo_dump(int, int); |
605 | int undo_enabled(void); | |
605 | 606 | int undo_enable(int); |
606 | 607 | void undo_add_boundary(void); |
607 | 608 | void undo_add_modified(void); |
608 | 609 | int undo_add_insert(struct line *, int, int); |
609 | 610 | int undo_add_delete(struct line *, int, int); |
610 | void undo_no_boundary(int); | |
611 | void undo_boundary_enable(int); | |
611 | 612 | int undo_add_change(struct line *, int, int); |
612 | 613 | int undo(int, int); |
613 | 614 |
0 | /* $OpenBSD: file.c,v 1.62 2006/07/25 08:27:09 kjell Exp $ */ | |
0 | /* $OpenBSD: file.c,v 1.63 2006/11/17 08:45:31 kjell Exp $ */ | |
1 | 1 | |
2 | 2 | /* This file is in the public domain. */ |
3 | 3 | |
288 | 288 | struct line *lp1, *lp2; |
289 | 289 | struct line *olp; /* line we started at */ |
290 | 290 | struct mgwin *wp; |
291 | int nbytes, s, nline = 0, siz, x = -1, x2; | |
291 | int nbytes, s, nline = 0, siz, x, x2; | |
292 | 292 | int opos; /* offset we started at */ |
293 | 293 | int oline; /* original line number */ |
294 | 294 | |
295 | 295 | if (replacebuf == TRUE) |
296 | 296 | x = undo_enable(FALSE); |
297 | else | |
298 | x = undo_enabled(); | |
297 | 299 | |
298 | 300 | lp1 = NULL; |
299 | 301 | if (line == NULL) { |
0 | /* $OpenBSD: line.c,v 1.42 2006/07/25 08:27:09 kjell Exp $ */ | |
0 | /* $OpenBSD: line.c,v 1.43 2006/11/17 08:45:31 kjell Exp $ */ | |
1 | 1 | |
2 | 2 | /* This file is in the public domain. */ |
3 | 3 | |
558 | 558 | return (FALSE); |
559 | 559 | } |
560 | 560 | undo_add_boundary(); |
561 | undo_no_boundary(TRUE); | |
561 | undo_boundary_enable(FALSE); | |
562 | 562 | |
563 | 563 | (void)backchar(FFARG | FFRAND, (int)plen); |
564 | 564 | (void)ldelete(plen, KNONE); |
567 | 567 | region_put_data(st, rlen); |
568 | 568 | lchange(WFFULL); |
569 | 569 | |
570 | undo_no_boundary(FALSE); | |
570 | undo_boundary_enable(TRUE); | |
571 | 571 | undo_add_boundary(); |
572 | 572 | return (TRUE); |
573 | 573 | } |
0 | /* $OpenBSD: paragraph.c,v 1.14 2006/07/25 08:22:32 kjell Exp $ */ | |
0 | /* $OpenBSD: paragraph.c,v 1.15 2006/11/17 08:45:31 kjell Exp $ */ | |
1 | 1 | |
2 | 2 | /* This file is in the public domain. */ |
3 | 3 | |
130 | 130 | char wbuf[MAXWORD]; /* buffer for current word */ |
131 | 131 | |
132 | 132 | undo_add_boundary(); |
133 | undo_no_boundary(TRUE); | |
133 | undo_boundary_enable(FALSE); | |
134 | 134 | |
135 | 135 | /* record the pointer to the line just past the EOP */ |
136 | 136 | (void)gotoeop(FFRAND, 1); |
236 | 236 | (void)backchar(FFRAND, 1); |
237 | 237 | retval = TRUE; |
238 | 238 | cleanup: |
239 | undo_no_boundary(FALSE); | |
239 | undo_boundary_enable(TRUE); | |
240 | 240 | undo_add_boundary(); |
241 | 241 | return (retval); |
242 | 242 | } |
0 | /* $OpenBSD: random.c,v 1.22 2006/07/25 08:27:09 kjell Exp $ */ | |
0 | /* $OpenBSD: random.c,v 1.23 2006/11/17 08:45:31 kjell Exp $ */ | |
1 | 1 | |
2 | 2 | /* This file is in the public domain. */ |
3 | 3 | |
119 | 119 | dotp = curwp->w_dotp; |
120 | 120 | doto = curwp->w_doto; |
121 | 121 | undo_add_boundary(); |
122 | undo_no_boundary(TRUE); | |
122 | undo_boundary_enable(FALSE); | |
123 | 123 | if (doto == llength(dotp)) { |
124 | 124 | if (--doto <= 0) |
125 | 125 | return (FALSE); |
135 | 135 | linsert(1, cr); |
136 | 136 | if (fudge != TRUE) |
137 | 137 | (void)backchar(FFRAND, 1); |
138 | undo_no_boundary(FALSE); | |
138 | undo_boundary_enable(TRUE); | |
139 | 139 | undo_add_boundary(); |
140 | 140 | lchange(WFEDIT); |
141 | 141 | return (TRUE); |
0 | /* $OpenBSD: search.c,v 1.32 2006/07/25 08:27:09 kjell Exp $ */ | |
0 | /* $OpenBSD: search.c,v 1.34 2006/11/18 22:46:16 kjell Exp $ */ | |
1 | 1 | |
2 | 2 | /* This file is in the public domain. */ |
3 | 3 | |
25 | 25 | #define SRCH_MARK (-5) |
26 | 26 | |
27 | 27 | struct srchcom { |
28 | int s_code; | |
28 | int s_code; | |
29 | 29 | struct line *s_dotp; |
30 | int s_doto; | |
30 | int s_doto; | |
31 | int s_dotline; | |
31 | 32 | }; |
32 | 33 | |
33 | 34 | static int isearch(int); |
201 | 202 | srch_lastdir = dir; |
202 | 203 | curwp->w_markp = clp; |
203 | 204 | curwp->w_marko = cbo; |
205 | curwp->w_markline = cdotline; | |
204 | 206 | ewprintf("Mark set"); |
205 | 207 | return (TRUE); |
206 | 208 | case CCHR('G'): |
304 | 306 | |
305 | 307 | while (cbo < llength(clp)) { |
306 | 308 | c = lgetc(clp, cbo++); |
307 | if ((!firstc && !isalnum(c)) || pptr == NPAT) | |
309 | if ((!firstc && !isalnum(c))) | |
308 | 310 | break; |
309 | 311 | |
312 | if (pptr == NPAT - 1) { | |
313 | ttbeep(); | |
314 | break; | |
315 | } | |
310 | 316 | firstc = 0; |
311 | 317 | if (!xcase && ISUPPER(c)) |
312 | 318 | c = TOLOWER(c); |
341 | 347 | ungetkey(c); |
342 | 348 | curwp->w_markp = clp; |
343 | 349 | curwp->w_marko = cbo; |
350 | curwp->w_markline = cdotline; | |
344 | 351 | ewprintf("Mark set"); |
345 | 352 | curwp->w_flag |= WFMOVE; |
346 | 353 | return (TRUE); |
353 | 360 | pptr = 0; |
354 | 361 | if (pptr == 0) |
355 | 362 | success = TRUE; |
356 | pat[pptr++] = c; | |
357 | if (pptr == NPAT) { | |
358 | ewprintf("Pattern too long"); | |
359 | return (FALSE); | |
360 | } | |
361 | pat[pptr] = '\0'; | |
363 | if (pptr == NPAT - 1) | |
364 | ttbeep(); | |
365 | else { | |
366 | pat[pptr++] = c; | |
367 | pat[pptr] = '\0'; | |
368 | } | |
362 | 369 | is_lpush(); |
363 | 370 | if (success != FALSE) { |
364 | 371 | if (is_find(dir) != FALSE) |
395 | 402 | cmds[ctp].s_code = SRCH_NOPR; |
396 | 403 | cmds[ctp].s_doto = curwp->w_doto; |
397 | 404 | cmds[ctp].s_dotp = curwp->w_dotp; |
405 | cmds[ctp].s_dotline = curwp->w_dotline; | |
398 | 406 | } |
399 | 407 | |
400 | 408 | static void |
403 | 411 | if (cmds[cip].s_code != SRCH_NOPR) { |
404 | 412 | curwp->w_doto = cmds[cip].s_doto; |
405 | 413 | curwp->w_dotp = cmds[cip].s_dotp; |
414 | curwp->w_dotline = cmds[cip].s_dotline; | |
406 | 415 | curwp->w_flag |= WFMOVE; |
407 | 416 | cmds[cip].s_code = SRCH_NOPR; |
408 | 417 | } |
453 | 462 | static int |
454 | 463 | is_find(int dir) |
455 | 464 | { |
456 | int plen, odoto; | |
465 | int plen, odoto, odotline; | |
457 | 466 | struct line *odotp; |
458 | 467 | |
459 | 468 | odoto = curwp->w_doto; |
460 | 469 | odotp = curwp->w_dotp; |
470 | odotline = curwp->w_dotline; | |
461 | 471 | plen = strlen(pat); |
462 | 472 | if (plen != 0) { |
463 | 473 | if (dir == SRCH_FORW) { |
465 | 475 | if (forwsrch() == FALSE) { |
466 | 476 | curwp->w_doto = odoto; |
467 | 477 | curwp->w_dotp = odotp; |
478 | curwp->w_dotline = odotline; | |
468 | 479 | return (FALSE); |
469 | 480 | } |
470 | 481 | return (TRUE); |
474 | 485 | if (backsrch() == FALSE) { |
475 | 486 | curwp->w_doto = odoto; |
476 | 487 | curwp->w_dotp = odotp; |
488 | curwp->w_dotline = odotline; | |
477 | 489 | return (FALSE); |
478 | 490 | } |
479 | 491 | return (TRUE); |
0 | /* $OpenBSD: undo.c,v 1.41 2006/07/25 08:22:32 kjell Exp $ */ | |
0 | /* $OpenBSD: undo.c,v 1.42 2006/11/17 08:45:31 kjell Exp $ */ | |
1 | 1 | /* |
2 | 2 | * Copyright (c) 2002 Vincent Labrecque <vincent@openbsd.org> |
3 | 3 | * Copyright (c) 2005, 2006 Kjell Wooding <kjell@openbsd.org> |
34 | 34 | */ |
35 | 35 | static LIST_HEAD(, undo_rec) undo_free; |
36 | 36 | static int undo_free_num; |
37 | static int nobound; | |
38 | ||
39 | /* | |
40 | * Global variables | |
41 | */ | |
42 | /* | |
43 | * undo_disable_flag: Stop doing undo (useful when we know are | |
44 | * going to deal with huge deletion/insertions | |
45 | * that we don't plan to undo) | |
46 | */ | |
47 | int undo_disable_flag; | |
37 | static int boundary_flag = TRUE; | |
38 | static int undo_enable_flag = TRUE; | |
48 | 39 | |
49 | 40 | /* |
50 | 41 | * Local functions |
180 | 171 | } |
181 | 172 | |
182 | 173 | /* |
174 | * Returns TRUE if undo is enabled, FALSE otherwise. | |
175 | */ | |
176 | int | |
177 | undo_enabled(void) | |
178 | { | |
179 | return (undo_enable_flag); | |
180 | } | |
181 | ||
182 | /* | |
183 | 183 | * undo_enable(TRUE/FALSE) will enable / disable the undo mechanism. |
184 | 184 | * Returns TRUE if previously enabled, FALSE otherwise. |
185 | 185 | */ |
186 | 186 | int |
187 | 187 | undo_enable(int on) |
188 | 188 | { |
189 | int pon = undo_disable_flag; | |
190 | ||
191 | undo_disable_flag = (on == TRUE) ? 0 : 1; | |
192 | return ((pon == TRUE) ? FALSE : TRUE); | |
189 | int pon = undo_enable_flag; | |
190 | ||
191 | undo_enable_flag = on; | |
192 | return (pon); | |
193 | 193 | } |
194 | 194 | |
195 | 195 | /* |
196 | 196 | * If undo is enabled, then: |
197 | * undo_no_boundary(TRUE) stops recording undo boundaries between actions. | |
198 | * undo_no_boundary(FALSE) enables undo boundaries. | |
197 | * undo_boundary_enable(FALS) stops recording undo boundaries between actions. | |
198 | * undo_boundary_enable(TRUE) enables undo boundaries. | |
199 | 199 | * If undo is disabled, this function has no effect. |
200 | 200 | */ |
201 | ||
201 | 202 | void |
202 | undo_no_boundary(int flag) | |
203 | { | |
204 | if (undo_disable_flag == FALSE) | |
205 | nobound = flag; | |
206 | } | |
207 | ||
208 | /* | |
209 | * Record an undo boundary, unless 'nobound' is set via undo_no_boundary. | |
203 | undo_boundary_enable(int flag) | |
204 | { | |
205 | if (undo_enable_flag == TRUE) | |
206 | boundary_flag = flag; | |
207 | } | |
208 | ||
209 | /* | |
210 | * Record an undo boundary, unless boundary_flag == FALSE. | |
210 | 211 | * Does nothing if previous undo entry is already a boundary or 'modified' flag. |
211 | 212 | */ |
212 | 213 | void |
215 | 216 | struct undo_rec *rec; |
216 | 217 | int last; |
217 | 218 | |
218 | if (nobound) | |
219 | if (boundary_flag == FALSE) | |
219 | 220 | return; |
220 | 221 | |
221 | 222 | last = lastrectype(); |
253 | 254 | struct undo_rec *rec; |
254 | 255 | int pos; |
255 | 256 | |
256 | if (undo_disable_flag) | |
257 | if (undo_enable_flag == FALSE) | |
257 | 258 | return (TRUE); |
258 | 259 | reg.r_linep = lp; |
259 | 260 | reg.r_offset = offset; |
298 | 299 | struct undo_rec *rec; |
299 | 300 | int pos; |
300 | 301 | |
301 | if (undo_disable_flag) | |
302 | if (undo_enable_flag == FALSE) | |
302 | 303 | return (TRUE); |
303 | 304 | |
304 | 305 | reg.r_linep = lp; |
347 | 348 | int |
348 | 349 | undo_add_change(struct line *lp, int offset, int size) |
349 | 350 | { |
350 | if (undo_disable_flag) | |
351 | if (undo_enable_flag == FALSE) | |
351 | 352 | return (TRUE); |
352 | 353 | undo_add_boundary(); |
353 | nobound = TRUE; | |
354 | boundary_flag = FALSE; | |
354 | 355 | undo_add_delete(lp, offset, size); |
355 | 356 | undo_add_insert(lp, offset, size); |
356 | nobound = FALSE; | |
357 | boundary_flag = TRUE; | |
357 | 358 | undo_add_boundary(); |
358 | 359 | |
359 | 360 | return (TRUE); |
502 | 503 | |
503 | 504 | undo_add_boundary(); |
504 | 505 | |
505 | save = nobound; | |
506 | nobound = TRUE; | |
506 | save = boundary_flag; | |
507 | boundary_flag = FALSE; | |
507 | 508 | |
508 | 509 | done = 0; |
509 | 510 | do { |
552 | 553 | ptr = LIST_NEXT(ptr, next); |
553 | 554 | } while (ptr != NULL && !done); |
554 | 555 | |
555 | nobound = save; | |
556 | boundary_flag = save; | |
556 | 557 | undo_add_boundary(); |
557 | 558 | |
558 | 559 | ewprintf("Undo!"); |
0 | /* $OpenBSD: yank.c,v 1.4 2006/07/25 08:22:32 kjell Exp $ */ | |
0 | /* $OpenBSD: yank.c,v 1.5 2006/11/17 08:45:31 kjell Exp $ */ | |
1 | 1 | |
2 | 2 | /* This file is in the public domain. */ |
3 | 3 | |
222 | 222 | nline = 0; |
223 | 223 | |
224 | 224 | undo_add_boundary(); |
225 | undo_no_boundary(TRUE); | |
225 | undo_boundary_enable(FALSE); | |
226 | 226 | while (n--) { |
227 | 227 | /* mark around last yank */ |
228 | 228 | isetmark(); |
250 | 250 | curwp->w_linep = lp; |
251 | 251 | curwp->w_flag |= WFFULL; |
252 | 252 | } |
253 | undo_no_boundary(FALSE); | |
253 | undo_boundary_enable(TRUE); | |
254 | 254 | undo_add_boundary(); |
255 | 255 | return (TRUE); |
256 | 256 | } |