Annotation of src/usr.bin/mg/theo.c, Revision 1.3
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!",
63: "slacker slacker lazy bum bum bum slacker!"
1.1 art 64: };
65:
1.3 ! mickey 66: static const int ntalk = sizeof(talk)/sizeof(talk[0]);
1.1 art 67:
68: static int
69: theo_analyze(int f, int n)
70: {
1.3 ! mickey 71: const char *str;
1.1 art 72: int len;
73:
74: str = talk[arc4random() % ntalk];
75: len = strlen(str);
76:
77: newline(FFRAND, 2);
78:
79: while (len--) {
80: linsert(1, *str++);
81: }
82:
83: newline(FFRAND, 2);
84:
85: return TRUE;
1.2 millert 86: }