003 File Manager
Current Path:
/usr/src/contrib/nvi/vi
usr
/
src
/
contrib
/
nvi
/
vi
/
📁
..
📄
extern.h
(4.47 KB)
📄
getc.c
(4.47 KB)
📄
v_at.c
(2.63 KB)
📄
v_ch.c
(5.44 KB)
📄
v_cmd.c
(12.03 KB)
📄
v_delete.c
(2.28 KB)
📄
v_ex.c
(13.78 KB)
📄
v_increment.c
(5.4 KB)
📄
v_init.c
(2.33 KB)
📄
v_itxt.c
(12.1 KB)
📄
v_left.c
(6.25 KB)
📄
v_mark.c
(5.25 KB)
📄
v_match.c
(3.87 KB)
📄
v_paragraph.c
(7.83 KB)
📄
v_put.c
(2.81 KB)
📄
v_redraw.c
(627 B)
📄
v_replace.c
(5.32 KB)
📄
v_right.c
(3.02 KB)
📄
v_screen.c
(1.34 KB)
📄
v_scroll.c
(11.57 KB)
📄
v_search.c
(13.59 KB)
📄
v_section.c
(6.21 KB)
📄
v_sentence.c
(8.21 KB)
📄
v_status.c
(658 B)
📄
v_txt.c
(76.56 KB)
📄
v_ulcase.c
(3.38 KB)
📄
v_undo.c
(4.19 KB)
📄
v_util.c
(2.85 KB)
📄
v_word.c
(12.82 KB)
📄
v_xchar.c
(2.09 KB)
📄
v_yank.c
(2.2 KB)
📄
v_z.c
(3.38 KB)
📄
v_zexit.c
(940 B)
📄
vi.c
(29.95 KB)
📄
vi.h
(15.76 KB)
📄
vs_line.c
(14.42 KB)
📄
vs_msg.c
(21.57 KB)
📄
vs_refresh.c
(23.58 KB)
📄
vs_relative.c
(6.96 KB)
📄
vs_smap.c
(27.8 KB)
📄
vs_split.c
(21.91 KB)
Editing: v_mark.c
/*- * 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. * * See the LICENSE file for redistribution information. */ #include "config.h" #include <sys/types.h> #include <sys/queue.h> #include <sys/time.h> #include <bitstring.h> #include <limits.h> #include <stdlib.h> #include <stdio.h> #include "../common/common.h" #include "vi.h" enum which {BQMARK, FQMARK}; static int mark(SCR *, VICMD *, int, enum which); /* * v_mark -- m[a-z] * Set a mark. * * PUBLIC: int v_mark(SCR *, VICMD *); */ int v_mark(SCR *sp, VICMD *vp) { return (mark_set(sp, vp->character, &vp->m_start, 1)); } /* * v_bmark -- `['`a-z] * Move to a mark. * * Moves to a mark, setting both row and column. * * !!! * Although not commonly known, the "'`" and "'`" forms are historically * valid. The behavior is determined by the first character, so "`'" is * the same as "``". Remember this fact -- you'll be amazed at how many * people don't know it and will be delighted that you are able to tell * them. * * PUBLIC: int v_bmark(SCR *, VICMD *); */ int v_bmark(SCR *sp, VICMD *vp) { return (mark(sp, vp, 1, BQMARK)); } /* * v_fmark -- '['`a-z] * Move to a mark. * * Move to the first nonblank character of the line containing the mark. * * PUBLIC: int v_fmark(SCR *, VICMD *); */ int v_fmark(SCR *sp, VICMD *vp) { return (mark(sp, vp, 1, FQMARK)); } /* * v_emark -- <mouse click> * Mouse mark. * * PUBLIC: int v_emark(SCR *, VICMD *); */ int v_emark(SCR *sp, VICMD *vp) { SMAP *smp; smp = HMAP + vp->ev.e_lno; if (smp > TMAP) { msgq(sp, M_BERR, "320|Unknown cursor position."); return (1); } vp->m_stop.lno = smp->lno; vp->m_stop.cno = vs_colpos(sp, smp->lno, vp->ev.e_cno + (smp->soff - 1) * sp->cols); return (mark(sp, vp, 0, BQMARK)); } /* * mark -- * Mark commands. */ static int mark(SCR *sp, VICMD *vp, int getmark, enum which cmd) { dir_t dir; MARK m; size_t len; if (getmark && mark_get(sp, vp->character, &vp->m_stop, M_BERR)) return (1); /* * !!! * Historically, BQMARKS for character positions that no longer * existed acted as FQMARKS. * * FQMARKS move to the first non-blank. */ switch (cmd) { case BQMARK: if (db_get(sp, vp->m_stop.lno, DBG_FATAL, NULL, &len)) return (1); if (vp->m_stop.cno < len || (vp->m_stop.cno == len && len == 0)) break; if (ISMOTION(vp)) F_SET(vp, VM_LMODE); cmd = FQMARK; /* FALLTHROUGH */ case FQMARK: vp->m_stop.cno = 0; if (nonblank(sp, vp->m_stop.lno, &vp->m_stop.cno)) return (1); break; default: abort(); } /* Non-motion commands move to the end of the range. */ if (!ISMOTION(vp)) { vp->m_final = vp->m_stop; return (0); } /* * !!! * If a motion component to a BQMARK, the cursor has to move. */ if (cmd == BQMARK && vp->m_stop.lno == vp->m_start.lno && vp->m_stop.cno == vp->m_start.cno) { v_nomove(sp); return (1); } /* * If the motion is in the reverse direction, switch the start and * stop MARK's so that it's in a forward direction. (There's no * reason for this other than to make the tests below easier. The * code in vi.c:vi() would have done the switch.) Both forward * and backward motions can happen for any kind of search command. */ if (vp->m_start.lno > vp->m_stop.lno || (vp->m_start.lno == vp->m_stop.lno && vp->m_start.cno > vp->m_stop.cno)) { m = vp->m_start; vp->m_start = vp->m_stop; vp->m_stop = m; dir = BACKWARD; } else dir = FORWARD; /* * Yank cursor motion, when associated with marks as motion commands, * historically behaved as follows: * * ` motion ' motion * Line change? Line change? * Y N Y N * -------------- --------------- * FORWARD: | NM NM | NM NM * | | * BACKWARD: | M M | M NM(1) * * where NM means the cursor didn't move, and M means the cursor * moved to the mark. * * As the cursor was usually moved for yank commands associated * with backward motions, this implementation regularizes it by * changing the NM at position (1) to be an M. This makes mark * motions match search motions, which is probably A Good Thing. * * Delete cursor motion was always to the start of the text region, * regardless. Ignore other motion commands. */ vp->m_final = vp->m_start; /* * Forward marks are always line oriented, and it's set in the * vcmd.c table. */ if (cmd == FQMARK) return (0); /* * BQMARK'S moving backward and starting at column 0, and ones moving * forward and ending at column 0 are corrected to the last column of * the previous line. Otherwise, adjust the starting/ending point to * the character before the current one (this is safe because we know * the search had to move to succeed). * * Mark motions become line mode opertions if they start at the first * nonblank and end at column 0 of another line. */ if (vp->m_start.lno < vp->m_stop.lno && vp->m_stop.cno == 0) { if (db_get(sp, --vp->m_stop.lno, DBG_FATAL, NULL, &len)) return (1); vp->m_stop.cno = len ? len - 1 : 0; len = 0; if (nonblank(sp, vp->m_start.lno, &len)) return (1); if (vp->m_start.cno <= len) F_SET(vp, VM_LMODE); } else --vp->m_stop.cno; return (0); }
Upload File
Create Folder