Annotation of src/usr.bin/mg/theo.c, Revision 1.8
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!",
1.5 miod 64: "I could search... but I'm a lazy bum ;)",
1.6 mickey 65: "sshutup sshithead, ssharpsshooting susshi sshplats ssharking assholes.",
1.7 mickey 66: "Lazy bums slacking on your asses.",
1.8 ! beck 67: "35 commits an hour? That's pathetic!",
1.7 mickey 68: "Fine software takes time to prepare. Give a little slack."
1.1 art 69: };
70:
1.3 mickey 71: static const int ntalk = sizeof(talk)/sizeof(talk[0]);
1.1 art 72:
73: static int
74: theo_analyze(int f, int n)
75: {
1.3 mickey 76: const char *str;
1.1 art 77: int len;
78:
79: str = talk[arc4random() % ntalk];
80: len = strlen(str);
81:
82: newline(FFRAND, 2);
83:
84: while (len--) {
85: linsert(1, *str++);
86: }
87:
88: newline(FFRAND, 2);
89:
90: return TRUE;
1.2 millert 91: }