diff options
author | Kjell Wooding <kjell@cvs.openbsd.org> | 2008-06-14 08:39:31 +0000 |
---|---|---|
committer | Kjell Wooding <kjell@cvs.openbsd.org> | 2008-06-14 08:39:31 +0000 |
commit | 51974cb6f416b8d6c346edb2101261825e22f7ee (patch) | |
tree | 3a5f8449404ca6ec26668c0ffcecb650dfb6348c /usr.bin | |
parent | 6d63c5c28d1fe760ae7cbb47f13a485d7dabe584 (diff) |
Add compile (c-C c-P) to the c-mode keymap (export from grep.c)
Also, attempt to make indent an atomic undo operation.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mg/cmode.c | 40 | ||||
-rw-r--r-- | usr.bin/mg/def.h | 3 | ||||
-rw-r--r-- | usr.bin/mg/grep.c | 5 |
3 files changed, 38 insertions, 10 deletions
diff --git a/usr.bin/mg/cmode.c b/usr.bin/mg/cmode.c index 54a18371e7f..e728a8eccf2 100644 --- a/usr.bin/mg/cmode.c +++ b/usr.bin/mg/cmode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmode.c,v 1.3 2008/06/13 19:10:17 kjell Exp $ */ +/* $OpenBSD: cmode.c,v 1.4 2008/06/14 08:39:30 kjell Exp $ */ /* * This file is in the public domain. * @@ -38,7 +38,18 @@ static PF cmode_brace[] = { cc_brace, /* } */ }; -static PF cmode_ci[] = { +static PF cmode_cCP[] = { + compile, /* C-c P */ +}; + + +static PF cmode_cc[] = { + NULL, /* ^C */ + rescan, /* ^D */ + rescan, /* ^E */ + rescan, /* ^F */ + rescan, /* ^G */ + rescan, /* ^H */ cc_tab, /* ^I */ rescan, /* ^J */ rescan, /* ^K */ @@ -50,12 +61,21 @@ static PF cmode_spec[] = { cc_char, /* : */ }; +static struct KEYMAPE (1 + IMAPEXT) cmode_cmap = { + 1, + 1 + IMAPEXT, + rescan, + { + { 'P', 'P', cmode_cCP, NULL } + } +}; + static struct KEYMAPE (3 + IMAPEXT) cmodemap = { 3, 3 + IMAPEXT, rescan, { - { CCHR('I'), CCHR('M'), cmode_ci, NULL }, + { CCHR('C'), CCHR('M'), cmode_cc, (KEYMAP *) &cmode_cmap }, { ':', ':', cmode_spec, NULL }, { '}', '}', cmode_brace, NULL } } @@ -139,10 +159,13 @@ cc_indent(int f, int n) int pi, mi; /* Previous indents */ int ci, dci; /* current indent, don't care */ struct line *lp; - + int ret; + if (n < 0) return (FALSE); + undo_add_boundary(); + undo_boundary_enable(FALSE); if (cc_strip_trailp) deltrailwhite(FFRAND, 1); @@ -161,9 +184,14 @@ cc_indent(int f, int n) dci = getindent(curwp->w_dotp, &ci); if (pi + ci < 0) - return(indent(FFOTHARG, 0)); + ret = indent(FFOTHARG, 0); else - return(indent(FFOTHARG, pi + ci)); + ret = indent(FFOTHARG, pi + ci); + + undo_boundary_enable(TRUE); + undo_add_boundary(); + + return (ret); } /* diff --git a/usr.bin/mg/def.h b/usr.bin/mg/def.h index 451d792829f..f26d46a2505 100644 --- a/usr.bin/mg/def.h +++ b/usr.bin/mg/def.h @@ -1,4 +1,4 @@ -/* $OpenBSD: def.h,v 1.105 2008/06/14 07:38:53 kjell Exp $ */ +/* $OpenBSD: def.h,v 1.106 2008/06/14 08:39:30 kjell Exp $ */ /* This file is in the public domain. */ @@ -631,6 +631,7 @@ int cc_lfindent(int, int); /* grep.c X */ int next_error(int, int); int globalwdtoggle(int, int); +int compile(int, int); /* * Externals. diff --git a/usr.bin/mg/grep.c b/usr.bin/mg/grep.c index aaa6234c141..11d02c26c01 100644 --- a/usr.bin/mg/grep.c +++ b/usr.bin/mg/grep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grep.c,v 1.35 2008/06/10 00:19:31 kjell Exp $ */ +/* $OpenBSD: grep.c,v 1.36 2008/06/14 08:39:30 kjell Exp $ */ /* This file is in the public domain */ @@ -15,7 +15,6 @@ int globalwd = FALSE; static int compile_goto_error(int, int); int next_error(int, int); static int grep(int, int); -static int compile(int, int); static int gid(int, int); static struct buffer *compile_mode(const char *, const char *); static int xlint(int, int); @@ -107,7 +106,7 @@ xlint(int f, int n) } /* ARGSUSED */ -static int +int compile(int f, int n) { char cprompt[NFILEN], *bufp; |