diff options
Diffstat (limited to 'usr.bin/vi/common/api.c')
-rw-r--r-- | usr.bin/vi/common/api.c | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/usr.bin/vi/common/api.c b/usr.bin/vi/common/api.c index a4c5a2a73ed..9314fe6d047 100644 --- a/usr.bin/vi/common/api.c +++ b/usr.bin/vi/common/api.c @@ -12,7 +12,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)api.c 8.19 (Berkeley) 6/8/96"; +static const char sccsid[] = "@(#)api.c 8.22 (Berkeley) 8/10/96"; #endif /* not lint */ #include <sys/types.h> @@ -199,6 +199,34 @@ api_setmark(sp, markname, mp) } /* + * api_nextmark -- + * Return the first mark if next not set, otherwise return the + * subsequent mark. + * + * PUBLIC: int api_nextmark __P((SCR *, int, char *)); + */ +int +api_nextmark(sp, next, namep) + SCR *sp; + int next; + char *namep; +{ + LMARK *mp; + + mp = sp->ep->marks.lh_first; + if (next) + for (; mp != NULL; mp = mp->q.le_next) + if (mp->name == *namep) { + mp = mp->q.le_next; + break; + } + if (mp == NULL) + return (1); + *namep = mp->name; + return (0); +} + +/* * api_getcursor -- * Get the cursor. * @@ -269,16 +297,18 @@ api_imessage(sp, text) } /* - * api_iscreen - * Create a new screen and return its id. + * api_edit + * Create a new screen and return its id + * or edit a new file in the current screen. * - * PUBLIC: int api_iscreen __P((SCR *, char *, int *)); + * PUBLIC: int api_edit __P((SCR *, char *, SCR **, int)); */ int -api_iscreen(sp, file, idp) +api_edit(sp, file, spp, newscreen) SCR *sp; char *file; - int *idp; + SCR **spp; + int newscreen; { ARGS *ap[2], a; EXCMD cmd; @@ -288,10 +318,11 @@ api_iscreen(sp, file, idp) ex_cadd(&cmd, &a, file, strlen(file)); } else ex_cinit(&cmd, C_EDIT, 0, OOBLNO, OOBLNO, 0, NULL); - cmd.flags |= E_NEWSCREEN; /* XXX */ + if (newscreen) + cmd.flags |= E_NEWSCREEN; /* XXX */ if (cmd.cmd->fn(sp, &cmd)) return (1); - *idp = sp->nextdisp->id; + *spp = sp->nextdisp; return (0); } |