diff options
author | Kjell Wooding <kjell@cvs.openbsd.org> | 2008-06-13 19:10:18 +0000 |
---|---|---|
committer | Kjell Wooding <kjell@cvs.openbsd.org> | 2008-06-13 19:10:18 +0000 |
commit | caa47d9de6f7aa5b73ac1a14b51a10ffa6de0b48 (patch) | |
tree | a9e4ac0dac61b23c8554082d9368533d04ecbd4c | |
parent | 611deb6fc7ad982974b2771342e24b2d0de47e74 (diff) |
phessler noted that c-mode ignored blinking braces.
Add "c-handle-special-brace" which does a blink and indent, rather
than just a selfinsert and indent
-rw-r--r-- | usr.bin/mg/cmode.c | 19 | ||||
-rw-r--r-- | usr.bin/mg/def.h | 3 |
2 files changed, 19 insertions, 3 deletions
diff --git a/usr.bin/mg/cmode.c b/usr.bin/mg/cmode.c index 7552264a4d7..54a18371e7f 100644 --- a/usr.bin/mg/cmode.c +++ b/usr.bin/mg/cmode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmode.c,v 1.2 2008/06/12 21:51:18 kjell Exp $ */ +/* $OpenBSD: cmode.c,v 1.3 2008/06/13 19:10:17 kjell Exp $ */ /* * This file is in the public domain. * @@ -35,7 +35,7 @@ int cc_comment(int, int); /* Keymaps */ static PF cmode_brace[] = { - cc_char, /* } */ + cc_brace, /* } */ }; static PF cmode_ci[] = { @@ -68,6 +68,7 @@ cmode_init(void) { funmap_add(cmode, "c-mode"); funmap_add(cc_char, "c-handle-special-char"); + funmap_add(cc_brace, "c-handle-special-brace"); funmap_add(cc_tab, "c-tab-or-indent"); funmap_add(cc_indent, "c-indent"); funmap_add(cc_lfindent, "c-indent-and-newline"); @@ -97,6 +98,20 @@ cc_char(int f, int n) } /* + * Handle special C character - selfinsert then indent. + */ +int +cc_brace(int f, int n) +{ + if (n < 0) + return (FALSE); + if (showmatch(FFRAND, 1) == FALSE) + return (FALSE); + return (cc_indent(FFRAND, n)); +} + + +/* * If we are in the whitespace at the beginning of the line, * simply act as a regular tab. If we are not, indent * current line according to whitespace rules. diff --git a/usr.bin/mg/def.h b/usr.bin/mg/def.h index da4e15853a1..bd3b8ce677f 100644 --- a/usr.bin/mg/def.h +++ b/usr.bin/mg/def.h @@ -1,4 +1,4 @@ -/* $OpenBSD: def.h,v 1.103 2008/06/12 01:58:44 kjell Exp $ */ +/* $OpenBSD: def.h,v 1.104 2008/06/13 19:10:17 kjell Exp $ */ /* This file is in the public domain. */ @@ -622,6 +622,7 @@ int add_autoexec(const char *, const char *); void mail_init(void); /* cmode.c X */ int cmode(int, int); +int cc_brace(int, int); int cc_char(int, int); int cc_tab(int, int); int cc_indent(int, int); |