diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2001-06-23 04:22:46 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2001-06-23 04:22:46 +0000 |
commit | da04c514294f0ebbb2d4ae73cdfb5028d0df8ec5 (patch) | |
tree | 5c6957a2f2637d91b7bcbd27b5cf58b6d572f56e /usr.bin/mg/theo.c | |
parent | a7d20e5d9c6a9ce17389d354f858f53fe9e3063b (diff) |
Add "M-x theo". Just like "M-x doctor" in emacs... Well, almost.
More beer!
Diffstat (limited to 'usr.bin/mg/theo.c')
-rw-r--r-- | usr.bin/mg/theo.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/usr.bin/mg/theo.c b/usr.bin/mg/theo.c new file mode 100644 index 00000000000..4998c23c661 --- /dev/null +++ b/usr.bin/mg/theo.c @@ -0,0 +1,85 @@ +#include "def.h" +#include "kbd.h" +#include "funmap.h" + +void theo_init(void); +static int theo_analyze(int, int); +static int theo(int, int); + +static PF theo_pf[] = { + theo_analyze, +}; + +static struct KEYMAPE (1 + IMAPEXT) theomap = { + 1, + 1 + IMAPEXT, + rescan, + { + { CCHR('M'), CCHR('M'), theo_pf, NULL }, + } +}; + +static BUFFER *tbuf; + +void +theo_init(void) +{ + funmap_add(theo, "theo"); + maps_add((KEYMAP *)&theomap, "theo"); +} + +static int +theo(int f, int n) +{ + BUFFER *bp; + MGWIN *wp; + + bp = bfind("theo", TRUE); + if (bclear(bp) != TRUE) + return FALSE; + + bp->b_modes[0] = name_mode("fundamental"); + bp->b_modes[1] = name_mode("theo"); + bp->b_nmodes = 1; + + if ((wp = popbuf(bp)) == NULL) + return FALSE; + + tbuf = curbp = bp; + curwp = wp; + return TRUE; +} + +static char *talk[] = { + "Write more code.", + "Make more commits.", + "That's because you have been slacking.", + "slacker!", + "That's what happens when you're lazy.", + "idler!", + "slackass!", + "lazy bum!", + "Stop slacking your lazy bum!", +}; + +static int ntalk = sizeof(talk)/sizeof(talk[0]); + +static int +theo_analyze(int f, int n) +{ + char *str; + int len; + + str = talk[arc4random() % ntalk]; + len = strlen(str); + + newline(FFRAND, 2); + + while (len--) { + linsert(1, *str++); + } + + newline(FFRAND, 2); + + return TRUE; +}
\ No newline at end of file |