/* * mark_get -- * Get the location referenced by a mark. * * PUBLIC: int mark_get __P((SCR *, ARG_CHAR_T, MARK *, mtype_t)); */ int mark_get(SCR *sp, ARG_CHAR_T key, MARK *mp, mtype_t mtype) { LMARK *lmp; if (key == ABSMARK2) key = ABSMARK1; lmp = mark_find(sp, key); if (lmp == NULL || (ARG_CHAR_T)lmp->name != key) { msgq(sp, mtype, "017|Mark %s: not set", KEY_NAME(sp, key)); return (1); } if (F_ISSET(lmp, MARK_DELETED)) { msgq(sp, mtype, "018|Mark %s: the line was deleted", KEY_NAME(sp, key)); return (1); } /* * !!! * The absolute mark is initialized to lno 1/cno 0, and historically * you could use it in an empty file. Make such a mark always work. */ if ((lmp->lno != 1 || lmp->cno != 0) && !db_exist(sp, lmp->lno)) { msgq(sp, mtype, "019|Mark %s: cursor position no longer exists", KEY_NAME(sp, key)); return (1); } mp->lno = lmp->lno; mp->cno = lmp->cno; return (0); }
/* * mark_set -- * Set the location referenced by a mark. * * PUBLIC: int mark_set __P((SCR *, ARG_CHAR_T, MARK *, int)); */ int mark_set(SCR *sp, ARG_CHAR_T key, MARK *value, int userset) { LMARK *lmp, *lmt; if (key == ABSMARK2) key = ABSMARK1; /* * The rules are simple. If the user is setting a mark (if it's a * new mark this is always true), it always happens. If not, it's * an undo, and we set it if it's not already set or if it was set * by a previous undo. */ lmp = mark_find(sp, key); if (lmp == NULL || (ARG_CHAR_T)lmp->name != key) { MALLOC_RET(sp, lmt, LMARK *, sizeof(LMARK)); if (lmp == NULL) { LIST_INSERT_HEAD(&sp->ep->marks, lmt, q); } else LIST_INSERT_AFTER(lmp, lmt, q); lmp = lmt; } else if (!userset &&
void proj_setup_attach_mark(proj_setup_type *proj_setup) { proj_setup->mark.idx=mark_find(proj_setup->mark.name); }