3 * Rainbow keyboard function key definitions
6 #define Function_Key 0x0100
10 #define Help_Key 0x0100
12 #define Compose_Key 0x0102
13 #define Print_Scr_Key 0x0103
15 #define Interrupt_Key 0x0107
16 #define Resume_Key 0x0109
17 #define Cancel_Key 0x010B
18 #define Main_Scr_Key 0x010D
19 #define Exit_Key 0x010F
20 #define Options_Key 0x0111
21 #define F17_Key 0x0113
22 #define F18_Key 0x0115
23 #define F19_Key 0x0117
24 #define F20_Key 0x0119
25 #define Find_Key 0x011B
26 #define Insert_Key 0x011D
27 #define Remove_Key 0x011F
28 #define Select_Key 0x0121
29 #define Prev_Scr_Key 0x0123
30 #define Next_Scr_Key 0x0125
32 #define Down_Key 0x0129
33 #define Right_Key 0x012B
34 #define Left_Key 0x012D
35 #define Keypad_0 0x012F
36 #define Keypad_1 0x0132
37 #define Keypad_2 0x0135
38 #define Keypad_3 0x0138
39 #define Keypad_4 0x013B
40 #define Keypad_5 0x013E
41 #define Keypad_6 0x0141
42 #define Keypad_7 0x0144
43 #define Keypad_8 0x0147
44 #define Keypad_9 0x014A
45 #define Keypad_Dash 0x014D
46 #define Keypad_Comma 0x0150
47 #define Keypad_Period 0x0153
48 #define Keypad_Enter 0x0156
49 #define Keypad_PF1 0x0159
50 #define Keypad_PF2 0x015C
51 #define Keypad_PF3 0x015F
52 #define Keypad_PF4 0x0162
53 #define Break_Key 0x0165
57 dir
*.-h
- random
.c
2914:829:999 random
.c
59 * This file contains the command processing functions for a number of random
60 * commands. There is no functional grouping here, for sure.
66 int tabsize
; /* Tab size (0: use real tabs) */
69 * Set fill column to n.
78 * Display the current position of the cursor, in origin 1 X-Y coordinates,
79 * the character that is under the cursor (in octal), and the fraction of the
80 * text that is before the cursor. The displayed column is not the current
81 * column, but the column that would be used on an infinite width display.
82 * Normally this is bound to "C-X =".
96 clp
= lforw(curbp
->b_linep
); /* Grovel the data. */
100 if (clp
==curwp
->w_dotp
&& cbo
==curwp
->w_doto
) {
102 if (cbo
== llength(clp
))
105 cac
= lgetc(clp
, cbo
);
107 if (cbo
== llength(clp
)) {
108 if (clp
== curbp
->b_linep
)
116 col
= getccol(FALSE
); /* Get real column. */
117 ratio
= 0; /* Ratio before dot. */
119 ratio
= (100L*nbc
) / nch
;
120 mlwrite("X=%d Y=%d CH=0x%x .=%D (%d%% of %D)",
121 col
+1, currow
+1, cac
, nbc
, ratio
, nch
);
126 * Return current column. Stop at first non-blank given TRUE argument.
131 register int c
, i
, col
;
133 for (i
=0; i
<curwp
->w_doto
; ++i
) {
134 c
= lgetc(curwp
->w_dotp
, i
);
135 if (c
!=' ' && c
!='\t' && bflg
)
139 else if (c
<0x20 || c
==0x7F)
147 * Twiddle the two characters on either side of dot. If dot is at the end of
148 * the line twiddle the two characters before it. Return with an error if dot
149 * is at the beginning of line; it seems to be a bit pointless to make this
150 * work. This fixes up a very common typo with a single stroke. Normally bound
151 * to "C-T". This always works within a line, so "WFEDIT" is good enough.
160 dotp
= curwp
->w_dotp
;
161 doto
= curwp
->w_doto
;
162 if (doto
==llength(dotp
) && --doto
<0)
164 cr
= lgetc(dotp
, doto
);
167 cl
= lgetc(dotp
, doto
);
168 lputc(dotp
, doto
+0, cr
);
169 lputc(dotp
, doto
+1, cl
);
175 * Quote the next character, and insert it into the buffer. All the characters
176 * are taken literally, with the exception of the newline, which always has
177 * its line splitting meaning. The character is always read, even if it is
178 * inserted 0 times, for regularity. Bound to "M-Q" (for me) and "C-Q" (for
179 * Rich, and only on terminals that don't need XON-XOFF).
186 c
= (*term
.t_getchar
)();
194 } while (s
==TRUE
&& --n
);
197 return (linsert(n
, c
));
201 * Set tab size if given non-default argument (n <> 1). Otherwise, insert a
202 * tab into file. If given argument, n, of zero, change to true tabs.
203 * If n > 1, simulate tab stop every n-characters using spaces. This has to be
204 * done in this slightly funny way because the tab (in ASCII) has been turned
205 * into "C-I" (in 10 bit code) already. Bound to "C-I".
211 if (n
== 0 || n
> 1) {
216 return(linsert(1, '\t'));
217 return(linsert(tabsize
- (getccol(FALSE
) % tabsize
), ' '));
221 * Open up some blank space. The basic plan is to insert a bunch of newlines,
222 * and then back up over them. Everything is done by the subcommand
223 * procerssors. They even handle the looping. Normally this is bound to "C-O".
234 i
= n
; /* Insert newlines. */
237 } while (s
==TRUE
&& --i
);
238 if (s
== TRUE
) /* Then back up overtop */
239 s
= backchar(f
, n
); /* of them all. */
244 * Insert a newline. Bound to "C-M". If you are at the end of the line and the
245 * next line is a blank line, just move into the blank line. This makes "C-O"
246 * and "C-X C-O" work nicely, and reduces the ammount of screen update that
247 * has to be done. This would not be as critical if screen update were a lot
260 if (llength(lp
) == curwp
->w_doto
261 && lp
!= curbp
->b_linep
262 && llength(lforw(lp
)) == 0) {
263 if ((s
=forwchar(FALSE
, 1)) != TRUE
)
265 } else if ((s
=lnewline()) != TRUE
)
272 * Delete blank lines around dot. What this command does depends if dot is
273 * sitting on a blank line. If dot is sitting on a blank line, this command
274 * deletes all the blank lines above and below the current line. If it is
275 * sitting on a non blank line then it deletes all of the blank lines after
276 * the line. Normally this command is bound to "C-X C-O". Any argument is
286 while (llength(lp1
)==0 && (lp2
=lback(lp1
))!=curbp
->b_linep
)
290 while ((lp2
=lforw(lp2
))!=curbp
->b_linep
&& llength(lp2
)==0)
294 curwp
->w_dotp
= lforw(lp1
);
296 return (ldelete(nld
));
300 * Insert a newline, then enough tabs and spaces to duplicate the indentation
301 * of the previous line. Assumes tabs are every eight characters. Quite simple.
302 * Figure out the indentation of the current line. Insert a newline by calling
303 * the standard routine. Insert the indentation by inserting the right number
304 * of tabs and spaces. Return TRUE if all ok. Return FALSE if one of the
305 * subcomands failed. Normally bound to "C-J".
317 for (i
=0; i
<llength(curwp
->w_dotp
); ++i
) {
318 c
= lgetc(curwp
->w_dotp
, i
);
319 if (c
!=' ' && c
!='\t')
325 if (lnewline() == FALSE
326 || ((i
=nicol
/8)!=0 && linsert(i
, '\t')==FALSE
)
327 || ((i
=nicol
%8)!=0 && linsert(i
, ' ')==FALSE
))
334 * Delete forward. This is real easy, because the basic delete routine does
335 * all of the work. Watches for negative arguments, and does the right thing.
336 * If any argument is present, it kills rather than deletes, to prevent loss
337 * of text if typed with a big argument. Normally bound to "C-D".
342 return (backdel(f
, -n
));
343 if (f
!= FALSE
) { /* Really a kill. */
344 if ((lastflag
&CFKILL
) == 0)
348 return (ldelete(n
, f
));
352 * Delete backwards. This is quite easy too, because it's all done with other
353 * functions. Just move the cursor back, and delete forwards. Like delete
354 * forward, this actually does a kill if presented with an argument. Bound to
355 * both "RUBOUT" and "C-H".
362 return (forwdel(f
, -n
));
363 if (f
!= FALSE
) { /* Really a kill. */
364 if ((lastflag
&CFKILL
) == 0)
368 if ((s
=backchar(f
, n
)) == TRUE
)
374 * Kill text. If called without an argument, it kills from dot to the end of
375 * the line, unless it is at the end of the line, when it kills the newline.
376 * If called with an argument of 0, it kills from the start of the line to dot.
377 * If called with a positive argument, it kills from dot forward over that
378 * number of newlines. If called with a negative argument it kills backwards
379 * that number of newlines. Normally bound to "C-K".
384 register LINE
*nextp
;
386 if ((lastflag
&CFKILL
) == 0) /* Clear kill buffer if */
387 kdelete(); /* last wasn't a kill. */
390 chunk
= llength(curwp
->w_dotp
)-curwp
->w_doto
;
394 chunk
= curwp
->w_doto
;
397 chunk
= llength(curwp
->w_dotp
)-curwp
->w_doto
+1;
398 nextp
= lforw(curwp
->w_dotp
);
400 if (nextp
== curbp
->b_linep
)
402 chunk
+= llength(nextp
)+1;
403 nextp
= lforw(nextp
);
409 return (ldelete(chunk
, TRUE
));
413 * Yank text back from the kill buffer. This is really easy. All of the work
414 * is done by the standard insert routines. All you do is run the loop, and
415 * check for errors. Bound to "C-Y". The blank lines are inserted with a call
416 * to "newline" instead of a call to "lnewline" so that the magic stuff that
417 * happens when you type a carriage return also happens when a carriage return
418 * is yanked back from the kill buffer.
430 while ((c
=kremove(i
)) >= 0) {
432 if (newline(FALSE
, 1) == FALSE
)
435 if (linsert(1, c
) == FALSE
)