2 * The routines in this file implement commands that work word at a time.
3 * There are all sorts of word mode commands. If I do any sentence and/or
4 * paragraph mode commands, they are likely to be put in this file.
11 /* Word wrap on n-spaces. Back-over whatever precedes the point on the current
12 * line and stop on the first word-break or the beginning of the line. If we
13 * reach the beginning of the line, jump back to the end of the word and start
14 * a new line. Otherwise, break the line at the word-break, eat it, and jump
15 * back to the end of the word.
16 * NOTE: This function may leaving trailing blanks.
17 * Returns TRUE on success, FALSE on errors.
33 if ((oldp
== curwp
->w_dotp
) && curwp
->w_doto
) {
39 return(forwword(0, 1) && forwchar(0, cnt
));
43 * Move the cursor backward by "n" words. All of the details of motion are
44 * performed by the "backchar" and "forwchar" routines. Error if you try to
45 * move beyond the buffers.
52 return (forwword(f
, -n
));
53 if (backchar(FALSE
, 1) == FALSE
)
56 while (inword() == FALSE
) {
57 if (backchar(FALSE
, 1) == FALSE
)
60 while (inword() != FALSE
) {
61 if (backchar(FALSE
, 1) == FALSE
)
65 return (forwchar(FALSE
, 1));
69 * Move the cursor forward by the specified number of words. All of the motion
70 * is done by "forwchar". Error if you try and move beyond the buffer's end.
77 return (backword(f
, -n
));
79 while (inword() == FALSE
) {
80 if (forwchar(FALSE
, 1) == FALSE
)
83 while (inword() != FALSE
) {
84 if (forwchar(FALSE
, 1) == FALSE
)
92 * Move the cursor forward by the specified number of words. As you move,
93 * convert any characters to upper case. Error if you try and move beyond the
94 * end of the buffer. Bound to "M-U".
105 while (inword() == FALSE
) {
106 if (forwchar(FALSE
, 1) == FALSE
)
109 while (inword() != FALSE
) {
110 c
= lgetc(curwp
->w_dotp
, curwp
->w_doto
);
111 if (c
>='a' && c
<='z') {
113 lputc(curwp
->w_dotp
, curwp
->w_doto
, c
);
116 if (forwchar(FALSE
, 1) == FALSE
)
124 * Move the cursor forward by the specified number of words. As you move
125 * convert characters to lower case. Error if you try and move over the end of
126 * the buffer. Bound to "M-L".
137 while (inword() == FALSE
) {
138 if (forwchar(FALSE
, 1) == FALSE
)
141 while (inword() != FALSE
) {
142 c
= lgetc(curwp
->w_dotp
, curwp
->w_doto
);
143 if (c
>='A' && c
<='Z') {
145 lputc(curwp
->w_dotp
, curwp
->w_doto
, c
);
148 if (forwchar(FALSE
, 1) == FALSE
)
156 * Move the cursor forward by the specified number of words. As you move
157 * convert the first character of the word to upper case, and subsequent
158 * characters to lower case. Error if you try and move past the end of the
159 * buffer. Bound to "M-C".
170 while (inword() == FALSE
) {
171 if (forwchar(FALSE
, 1) == FALSE
)
174 if (inword() != FALSE
) {
175 c
= lgetc(curwp
->w_dotp
, curwp
->w_doto
);
176 if (c
>='a' && c
<='z') {
178 lputc(curwp
->w_dotp
, curwp
->w_doto
, c
);
181 if (forwchar(FALSE
, 1) == FALSE
)
183 while (inword() != FALSE
) {
184 c
= lgetc(curwp
->w_dotp
, curwp
->w_doto
);
185 if (c
>='A' && c
<='Z') {
187 lputc(curwp
->w_dotp
, curwp
->w_doto
, c
);
190 if (forwchar(FALSE
, 1) == FALSE
)
199 * Kill forward by "n" words. Remember the location of dot. Move forward by
200 * the right number of words. Put dot back where it was and issue the kill
201 * command for the right number of characters. Bound to "M-D".
213 dotp
= curwp
->w_dotp
;
214 doto
= curwp
->w_doto
;
217 while (inword() == FALSE
) {
218 if (forwchar(FALSE
, 1) == FALSE
)
222 while (inword() != FALSE
) {
223 if (forwchar(FALSE
, 1) == FALSE
)
228 curwp
->w_dotp
= dotp
;
229 curwp
->w_doto
= doto
;
230 return (ldelete(size
, TRUE
));
234 * Kill backwards by "n" words. Move backwards by the desired number of words,
235 * counting the characters. When dot is finally moved to its resting place,
236 * fire off the kill command. Bound to "M-Rubout" and to "M-Backspace".
246 if (backchar(FALSE
, 1) == FALSE
)
250 while (inword() == FALSE
) {
251 if (backchar(FALSE
, 1) == FALSE
)
255 while (inword() != FALSE
) {
256 if (backchar(FALSE
, 1) == FALSE
)
261 if (forwchar(FALSE
, 1) == FALSE
)
263 return (ldelete(size
, TRUE
));
267 * Return TRUE if the character at dot is a character that is considered to be
268 * part of a word. The word character list is hard coded. Should be setable.
274 if (curwp
->w_doto
== llength(curwp
->w_dotp
))
276 c
= lgetc(curwp
->w_dotp
, curwp
->w_doto
);
277 if (c
>='a' && c
<='z')
279 if (c
>='A' && c
<='Z')
281 if (c
>='0' && c
<='9')
283 if (c
=='$' || c
=='_') /* For identifiers */