diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-05-22 11:37:15 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-05-22 11:37:15 +0000 |
commit | 0157a77a51c5e35e093ae03581f66dea010edcc8 (patch) | |
tree | 5e8bd32aa4d2b5ed37b7cf3ad26e8bdfc7f20a04 /usr.bin/vi/ex/ex_map.c | |
parent | 806021be093ad00ce2022a532c0f4cc99b0065ac (diff) |
new vi
Diffstat (limited to 'usr.bin/vi/ex/ex_map.c')
-rw-r--r-- | usr.bin/vi/ex/ex_map.c | 109 |
1 files changed, 35 insertions, 74 deletions
diff --git a/usr.bin/vi/ex/ex_map.c b/usr.bin/vi/ex/ex_map.c index ec67dbd9472..bc2cf085591 100644 --- a/usr.bin/vi/ex/ex_map.c +++ b/usr.bin/vi/ex/ex_map.c @@ -1,60 +1,29 @@ /*- * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. + * Copyright (c) 1992, 1993, 1994, 1995, 1996 + * Keith Bostic. All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * See the LICENSE file for redistribution information. */ +#include "config.h" + #ifndef lint -static char sccsid[] = "@(#)ex_map.c 8.19 (Berkeley) 8/17/94"; +static const char sccsid[] = "@(#)ex_map.c 10.9 (Berkeley) 3/6/96"; #endif /* not lint */ #include <sys/types.h> #include <sys/queue.h> -#include <sys/time.h> #include <bitstring.h> #include <ctype.h> #include <limits.h> -#include <signal.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <termios.h> -#include "compat.h" -#include <curses.h> -#include <db.h> -#include <regex.h> - -#include "vi.h" -#include "excmd.h" +#include "../common/common.h" /* * ex_map -- :map[!] [input] [replacement] @@ -69,23 +38,25 @@ static char sccsid[] = "@(#)ex_map.c 8.19 (Berkeley) 8/17/94"; * mark at the start of the map, e.g. map X mx"xy ...), or if you * put the map in a .exrc file, things would often work much better. * No clue why. + * + * PUBLIC: int ex_map __P((SCR *, EXCMD *)); */ int -ex_map(sp, ep, cmdp) +ex_map(sp, cmdp) SCR *sp; - EXF *ep; - EXCMDARG *cmdp; + EXCMD *cmdp; { - enum seqtype stype; + seq_t stype; CHAR_T *input, *p; - stype = F_ISSET(cmdp, E_FORCE) ? SEQ_INPUT : SEQ_COMMAND; + stype = FL_ISSET(cmdp->iflags, E_C_FORCE) ? SEQ_INPUT : SEQ_COMMAND; switch (cmdp->argc) { case 0: if (seq_dump(sp, stype, 1) == 0) - msgq(sp, M_INFO, "No %s map entries", - stype == SEQ_INPUT ? "input" : "command"); + msgq(sp, M_INFO, stype == SEQ_INPUT ? + "132|No input map entries" : + "133|No command map entries"); return (0); case 2: input = cmdp->argv[0]->bp; @@ -95,21 +66,22 @@ ex_map(sp, ep, cmdp) } /* - * If the mapped string is #[0-9]* (and wasn't quoted) then store - * the function key mapping, and call the screen specific routine. - * Note, if the screen specific routine is able to create the - * mapping, the SEQ_FUNCMAP type stays around, maybe the next screen - * type can get it right. + * If the mapped string is #[0-9]* (and wasn't quoted) then store the + * function key mapping. If the screen specific routine has been set, + * call it as well. Note, the SEQ_FUNCMAP type is persistent across + * screen types, maybe the next screen type will get it right. */ - if (input[0] == '#') { - for (p = input + 1; isdigit(*p); ++p); + if (input[0] == '#' && isdigit(input[1])) { + for (p = input + 2; isdigit(*p); ++p); if (p[0] != '\0') goto nofunc; if (seq_set(sp, NULL, 0, input, cmdp->argv[0]->len, - cmdp->argv[1]->bp, cmdp->argv[1]->len, stype, SEQ_FUNCMAP)) + cmdp->argv[1]->bp, cmdp->argv[1]->len, stype, + SEQ_FUNCMAP | SEQ_USERDEF)) return (1); - return (sp->s_fmap(sp, stype, input, cmdp->argv[0]->len, + return (sp->gp->scr_fmap == NULL ? 0 : + sp->gp->scr_fmap(sp, stype, input, cmdp->argv[0]->len, cmdp->argv[1]->bp, cmdp->argv[1]->len)); } @@ -119,7 +91,8 @@ nofunc: if (stype == SEQ_COMMAND && input[1] == '\0') case K_COLON: case K_ESCAPE: case K_NL: - msgq(sp, M_ERR, "The %s character may not be remapped", + msgq(sp, M_ERR, + "134|The %s character may not be remapped", KEY_NAME(sp, input[0])); return (1); } @@ -130,31 +103,19 @@ nofunc: if (stype == SEQ_COMMAND && input[1] == '\0') /* * ex_unmap -- (:unmap[!] key) * Unmap a key. + * + * PUBLIC: int ex_unmap __P((SCR *, EXCMD *)); */ int -ex_unmap(sp, ep, cmdp) +ex_unmap(sp, cmdp) SCR *sp; - EXF *ep; - EXCMDARG *cmdp; + EXCMD *cmdp; { if (seq_delete(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len, - F_ISSET(cmdp, E_FORCE) ? SEQ_INPUT : SEQ_COMMAND)) { - msgq(sp, M_INFO, "\"%s\" isn't mapped", cmdp->argv[0]->bp); + FL_ISSET(cmdp->iflags, E_C_FORCE) ? SEQ_INPUT : SEQ_COMMAND)) { + msgq_str(sp, M_INFO, + cmdp->argv[0]->bp, "135|\"%s\" isn't currently mapped"); return (1); } return (0); } - -/* - * map_save -- - * Save the mapped sequences to a file. - */ -int -map_save(sp, fp) - SCR *sp; - FILE *fp; -{ - if (seq_save(sp, fp, "map ", SEQ_COMMAND)) - return (1); - return (seq_save(sp, fp, "map! ", SEQ_INPUT)); -} |