5 * 14407 SW Teal Blvd. #C
11 /* This file contains the word-oriented movement functions */
17 MARK
m_fword(m
, cnt
, cmd
, prevkey
)
18 MARK m
; /* movement is relative to this mark */
19 long cnt
; /* a numeric argument */
20 int cmd
; /* either 'w' or 'W' */
21 int prevkey
;/* previous command... if 'c' then exclude whitespace */
31 text
= ptext
+ markidx(m
);
34 /* As a special case, "cw" or "cW" on whitespace without a count
35 * treats the single whitespace character under the cursor as a word.
37 if (cnt
== 1L && prevkey
== 'c' && isspace(*text
))
43 while (cnt
-- > 0) /* yes, ASSIGNMENT! */
49 /* include any non-whitespace */
50 while (i
&& !isspace(i
))
55 else if (isalnum(i
) || i
== '_')
57 /* include an alphanumeric word */
58 while (i
&& isalnum(i
))
65 /* include contiguous punctuation */
66 while (i
&& !isalnum(i
) && !isspace(i
))
72 /* if not part of "cw" or "cW" command... */
73 if (prevkey
!= 'c' || cnt
> 0)
75 /* include trailing whitespace */
76 while (!i
|| isspace(i
))
78 /* did we hit the end of this line? */
81 /* "dw" shouldn't delete newline after word */
82 if (prevkey
&& cnt
== 0)
87 /* move to next line, if there is one */
103 /* if argument to operator, then back off 1 char since "w" and "W"
104 * include the last char in the affected text.
111 /* construct a MARK for this place */
117 MARK
m_bword(m
, cnt
, cmd
)
118 MARK m
; /* movement is relative to this mark */
119 long cnt
; /* a numeric argument */
120 int cmd
; /* either 'b' or 'B' */
129 text
= ptext
+ markidx(m
);
130 while (cnt
-- > 0) /* yes, ASSIGNMENT! */
134 /* include preceding whitespace */
135 while (text
< ptext
|| isspace(*text
))
137 /* did we hit the end of this line? */
140 /* move to preceding line, if there is one */
147 text
= ptext
+ plen
- 1;
157 /* include any non-whitespace */
158 while (text
>= ptext
&& !isspace(*text
))
163 else if (isalnum(*text
) || *text
== '_')
165 /* include an alphanumeric word */
166 while (text
>= ptext
&& isalnum(*text
))
173 /* include contiguous punctuation */
174 while (text
>= ptext
&& !isalnum(*text
) && !isspace(*text
))
182 /* construct a MARK for this place */
187 MARK
m_eword(m
, cnt
, cmd
)
188 MARK m
; /* movement is relative to this mark */
189 long cnt
; /* a numeric argument */
190 int cmd
; /* either 'e' or 'E' */
200 text
= ptext
+ markidx(m
);
201 while (cnt
-- > 0) /* yes, ASSIGNMENT! */
207 /* include preceding whitespace */
208 while (!i
|| isspace(i
))
210 /* did we hit the end of this line? */
213 /* move to next line, if there is one */
228 /* include any non-whitespace */
229 while (i
&& !isspace(i
))
234 else if (isalnum(i
) || i
== '_')
236 /* include an alphanumeric word */
237 while (i
&& isalnum(i
))
244 /* include contiguous punctuation */
245 while (i
&& !isalnum(i
) && !isspace(i
))
253 /* construct a MARK for this place */