Annotation of src/usr.bin/mg/theo.c, Revision 1.4
1.1 art 1: #include "def.h"
2: #include "kbd.h"
3: #include "funmap.h"
4:
5: void theo_init(void);
6: static int theo_analyze(int, int);
7: static int theo(int, int);
8:
9: static PF theo_pf[] = {
10: theo_analyze,
11: };
12:
13: static struct KEYMAPE (1 + IMAPEXT) theomap = {
14: 1,
15: 1 + IMAPEXT,
16: rescan,
17: {
18: { CCHR('M'), CCHR('M'), theo_pf, NULL },
19: }
20: };
21:
22: static BUFFER *tbuf;
23:
24: void
25: theo_init(void)
26: {
27: funmap_add(theo, "theo");
28: maps_add((KEYMAP *)&theomap, "theo");
29: }
30:
31: static int
32: theo(int f, int n)
33: {
34: BUFFER *bp;
35: MGWIN *wp;
36:
37: bp = bfind("theo", TRUE);
38: if (bclear(bp) != TRUE)
39: return FALSE;
40:
41: bp->b_modes[0] = name_mode("fundamental");
42: bp->b_modes[1] = name_mode("theo");
43: bp->b_nmodes = 1;
44:
45: if ((wp = popbuf(bp)) == NULL)
46: return FALSE;
47:
48: tbuf = curbp = bp;
49: curwp = wp;
50: return TRUE;
51: }
52:
1.3 mickey 53: static const char *talk[] = {
1.1 art 54: "Write more code.",
55: "Make more commits.",
56: "That's because you have been slacking.",
57: "slacker!",
58: "That's what happens when you're lazy.",
59: "idler!",
60: "slackass!",
61: "lazy bum!",
1.2 millert 62: "Stop slacking you lazy bum!",
1.4 ! mickey 63: "slacker slacker lazy bum bum bum slacker!",
! 64: "I could search... but I'm a lazy bum ;)"
1.1 art 65: };
66:
1.3 mickey 67: static const int ntalk = sizeof(talk)/sizeof(talk[0]);
1.1 art 68:
69: static int
70: theo_analyze(int f, int n)
71: {
1.3 mickey 72: const char *str;
1.1 art 73: int len;
74:
75: str = talk[arc4random() % ntalk];
76: len = strlen(str);
77:
78: newline(FFRAND, 2);
79:
80: while (len--) {
81: linsert(1, *str++);
82: }
83:
84: newline(FFRAND, 2);
85:
86: return TRUE;
1.2 millert 87: }