Codebase list mg / 206fda6
Imported Debian patch 20061119-1 Trent Buck 17 years ago
13 changed file(s) with 114 addition(s) and 87 deletion(s). Raw diff Collapse all Expand all
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 $ */
11
22 /* This file is in the public domain */
33
272272 lp = curwp->w_linep;
273273 while (n-- && lforw(lp) != curbp->b_headp) {
274274 lp = lforw(lp);
275 curwp->w_dotline++;
276275 }
277276 curwp->w_linep = lp;
278277 curwp->w_flag |= WFFULL;
280279 for (n = curwp->w_ntrows; n-- && lp != curbp->b_headp; lp = lforw(lp))
281280 if (lp == curwp->w_dotp)
282281 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 }
284287 curwp->w_doto = 0;
285288 return (TRUE);
286289 }
312315 lp = curwp->w_linep;
313316 while (n-- && lback(lp) != curbp->b_headp) {
314317 lp = lback(lp);
315 curwp->w_dotline--;
316318 }
317319 curwp->w_linep = lp;
318320 curwp->w_flag |= WFFULL;
320322 for (n = curwp->w_ntrows; n-- && lp != curbp->b_headp; lp = lforw(lp))
321323 if (lp == curwp->w_dotp)
322324 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 }
324330 curwp->w_doto = 0;
325331 return (TRUE);
326332 }
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 $ */
11
22 /* This file is in the public domain. */
33
1919 #include "def.h"
2020 #include "kbd.h" /* needed for modes */
2121
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 *);
2424
2525 /* ARGSUSED */
2626 int
484484 if (cflag != TRUE)
485485 return (NULL);
486486
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);
494488
495489 return (bp);
496490 }
500494 * all buffers.
501495 */
502496 static struct buffer *
503 bnew()
504 {
505 struct buffer *bp;
497 bnew(const char *bname)
498 {
499 struct buffer *bp;
506500 struct line *lp;
507501 int i;
508502
540534 bheadp = bp;
541535 bp->b_dotline = bp->b_markline = 1;
542536 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 }
543541
544542 return (bp);
545543 }
622620 wp->w_markp = owp->w_markp;
623621 wp->w_marko = owp->w_marko;
624622 wp->w_dotline = owp->w_dotline;
623 wp->w_markline = owp->w_markline;
625624 break;
626625 }
627626 wp->w_flag |= WFMODE | flags;
+0
-5
config.h less more
0 #define FKEYS
1 #define PREFIXREGION
2 #define REGEX
3 #define XKEYS
4 #define HAVE_ARC4RANDOM
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
010 mg (20060919-1) unstable; urgency=low
111
212 * New upstream release
11 Section: editors
22 Priority: optional
33 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
66
77 Package: mg
88 Architecture: any
99 Depends: ${shlibs:Depends}, ${misc:Depends}
1010 Suggests: zile, qemacs | qemacs-nox
11 Provides: editor
1112 Description: microscopic GNU Emacs-style editor
1213 This program is intended to be a small, fast, and portable
1314 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 $ */
11
22 /* This file is in the public domain. */
33
602602 /* undo.c X */
603603 void free_undo_record(struct undo_rec *);
604604 int undo_dump(int, int);
605 int undo_enabled(void);
605606 int undo_enable(int);
606607 void undo_add_boundary(void);
607608 void undo_add_modified(void);
608609 int undo_add_insert(struct line *, int, int);
609610 int undo_add_delete(struct line *, int, int);
610 void undo_no_boundary(int);
611 void undo_boundary_enable(int);
611612 int undo_add_change(struct line *, int, int);
612613 int undo(int, int);
613614
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 $ */
11
22 /* This file is in the public domain. */
33
288288 struct line *lp1, *lp2;
289289 struct line *olp; /* line we started at */
290290 struct mgwin *wp;
291 int nbytes, s, nline = 0, siz, x = -1, x2;
291 int nbytes, s, nline = 0, siz, x, x2;
292292 int opos; /* offset we started at */
293293 int oline; /* original line number */
294294
295295 if (replacebuf == TRUE)
296296 x = undo_enable(FALSE);
297 else
298 x = undo_enabled();
297299
298300 lp1 = NULL;
299301 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 $ */
11
22 /* This file is in the public domain. */
33
558558 return (FALSE);
559559 }
560560 undo_add_boundary();
561 undo_no_boundary(TRUE);
561 undo_boundary_enable(FALSE);
562562
563563 (void)backchar(FFARG | FFRAND, (int)plen);
564564 (void)ldelete(plen, KNONE);
567567 region_put_data(st, rlen);
568568 lchange(WFFULL);
569569
570 undo_no_boundary(FALSE);
570 undo_boundary_enable(TRUE);
571571 undo_add_boundary();
572572 return (TRUE);
573573 }
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 $ */
11
22 /* This file is in the public domain. */
33
130130 char wbuf[MAXWORD]; /* buffer for current word */
131131
132132 undo_add_boundary();
133 undo_no_boundary(TRUE);
133 undo_boundary_enable(FALSE);
134134
135135 /* record the pointer to the line just past the EOP */
136136 (void)gotoeop(FFRAND, 1);
236236 (void)backchar(FFRAND, 1);
237237 retval = TRUE;
238238 cleanup:
239 undo_no_boundary(FALSE);
239 undo_boundary_enable(TRUE);
240240 undo_add_boundary();
241241 return (retval);
242242 }
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 $ */
11
22 /* This file is in the public domain. */
33
119119 dotp = curwp->w_dotp;
120120 doto = curwp->w_doto;
121121 undo_add_boundary();
122 undo_no_boundary(TRUE);
122 undo_boundary_enable(FALSE);
123123 if (doto == llength(dotp)) {
124124 if (--doto <= 0)
125125 return (FALSE);
135135 linsert(1, cr);
136136 if (fudge != TRUE)
137137 (void)backchar(FFRAND, 1);
138 undo_no_boundary(FALSE);
138 undo_boundary_enable(TRUE);
139139 undo_add_boundary();
140140 lchange(WFEDIT);
141141 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 $ */
11
22 /* This file is in the public domain. */
33
2525 #define SRCH_MARK (-5)
2626
2727 struct srchcom {
28 int s_code;
28 int s_code;
2929 struct line *s_dotp;
30 int s_doto;
30 int s_doto;
31 int s_dotline;
3132 };
3233
3334 static int isearch(int);
201202 srch_lastdir = dir;
202203 curwp->w_markp = clp;
203204 curwp->w_marko = cbo;
205 curwp->w_markline = cdotline;
204206 ewprintf("Mark set");
205207 return (TRUE);
206208 case CCHR('G'):
304306
305307 while (cbo < llength(clp)) {
306308 c = lgetc(clp, cbo++);
307 if ((!firstc && !isalnum(c)) || pptr == NPAT)
309 if ((!firstc && !isalnum(c)))
308310 break;
309311
312 if (pptr == NPAT - 1) {
313 ttbeep();
314 break;
315 }
310316 firstc = 0;
311317 if (!xcase && ISUPPER(c))
312318 c = TOLOWER(c);
341347 ungetkey(c);
342348 curwp->w_markp = clp;
343349 curwp->w_marko = cbo;
350 curwp->w_markline = cdotline;
344351 ewprintf("Mark set");
345352 curwp->w_flag |= WFMOVE;
346353 return (TRUE);
353360 pptr = 0;
354361 if (pptr == 0)
355362 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 }
362369 is_lpush();
363370 if (success != FALSE) {
364371 if (is_find(dir) != FALSE)
395402 cmds[ctp].s_code = SRCH_NOPR;
396403 cmds[ctp].s_doto = curwp->w_doto;
397404 cmds[ctp].s_dotp = curwp->w_dotp;
405 cmds[ctp].s_dotline = curwp->w_dotline;
398406 }
399407
400408 static void
403411 if (cmds[cip].s_code != SRCH_NOPR) {
404412 curwp->w_doto = cmds[cip].s_doto;
405413 curwp->w_dotp = cmds[cip].s_dotp;
414 curwp->w_dotline = cmds[cip].s_dotline;
406415 curwp->w_flag |= WFMOVE;
407416 cmds[cip].s_code = SRCH_NOPR;
408417 }
453462 static int
454463 is_find(int dir)
455464 {
456 int plen, odoto;
465 int plen, odoto, odotline;
457466 struct line *odotp;
458467
459468 odoto = curwp->w_doto;
460469 odotp = curwp->w_dotp;
470 odotline = curwp->w_dotline;
461471 plen = strlen(pat);
462472 if (plen != 0) {
463473 if (dir == SRCH_FORW) {
465475 if (forwsrch() == FALSE) {
466476 curwp->w_doto = odoto;
467477 curwp->w_dotp = odotp;
478 curwp->w_dotline = odotline;
468479 return (FALSE);
469480 }
470481 return (TRUE);
474485 if (backsrch() == FALSE) {
475486 curwp->w_doto = odoto;
476487 curwp->w_dotp = odotp;
488 curwp->w_dotline = odotline;
477489 return (FALSE);
478490 }
479491 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 $ */
11 /*
22 * Copyright (c) 2002 Vincent Labrecque <vincent@openbsd.org>
33 * Copyright (c) 2005, 2006 Kjell Wooding <kjell@openbsd.org>
3434 */
3535 static LIST_HEAD(, undo_rec) undo_free;
3636 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;
4839
4940 /*
5041 * Local functions
180171 }
181172
182173 /*
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 /*
183183 * undo_enable(TRUE/FALSE) will enable / disable the undo mechanism.
184184 * Returns TRUE if previously enabled, FALSE otherwise.
185185 */
186186 int
187187 undo_enable(int on)
188188 {
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);
193193 }
194194
195195 /*
196196 * 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.
199199 * If undo is disabled, this function has no effect.
200200 */
201
201202 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.
210211 * Does nothing if previous undo entry is already a boundary or 'modified' flag.
211212 */
212213 void
215216 struct undo_rec *rec;
216217 int last;
217218
218 if (nobound)
219 if (boundary_flag == FALSE)
219220 return;
220221
221222 last = lastrectype();
253254 struct undo_rec *rec;
254255 int pos;
255256
256 if (undo_disable_flag)
257 if (undo_enable_flag == FALSE)
257258 return (TRUE);
258259 reg.r_linep = lp;
259260 reg.r_offset = offset;
298299 struct undo_rec *rec;
299300 int pos;
300301
301 if (undo_disable_flag)
302 if (undo_enable_flag == FALSE)
302303 return (TRUE);
303304
304305 reg.r_linep = lp;
347348 int
348349 undo_add_change(struct line *lp, int offset, int size)
349350 {
350 if (undo_disable_flag)
351 if (undo_enable_flag == FALSE)
351352 return (TRUE);
352353 undo_add_boundary();
353 nobound = TRUE;
354 boundary_flag = FALSE;
354355 undo_add_delete(lp, offset, size);
355356 undo_add_insert(lp, offset, size);
356 nobound = FALSE;
357 boundary_flag = TRUE;
357358 undo_add_boundary();
358359
359360 return (TRUE);
502503
503504 undo_add_boundary();
504505
505 save = nobound;
506 nobound = TRUE;
506 save = boundary_flag;
507 boundary_flag = FALSE;
507508
508509 done = 0;
509510 do {
552553 ptr = LIST_NEXT(ptr, next);
553554 } while (ptr != NULL && !done);
554555
555 nobound = save;
556 boundary_flag = save;
556557 undo_add_boundary();
557558
558559 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 $ */
11
22 /* This file is in the public domain. */
33
222222 nline = 0;
223223
224224 undo_add_boundary();
225 undo_no_boundary(TRUE);
225 undo_boundary_enable(FALSE);
226226 while (n--) {
227227 /* mark around last yank */
228228 isetmark();
250250 curwp->w_linep = lp;
251251 curwp->w_flag |= WFFULL;
252252 }
253 undo_no_boundary(FALSE);
253 undo_boundary_enable(TRUE);
254254 undo_add_boundary();
255255 return (TRUE);
256256 }