summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorart <art@openbsd.org>2001-06-23 04:22:44 +0000
committerart <art@openbsd.org>2001-06-23 04:22:44 +0000
commit6dec1c60dcf2f99deb680620711013a7369886fa (patch)
treece4af47950c48c302384c3fc046ea69a791035af
parent- Add IPv4, UDP, and TCP RX checksum offloading support (diff)
downloadwireguard-openbsd-6dec1c60dcf2f99deb680620711013a7369886fa.tar.xz
wireguard-openbsd-6dec1c60dcf2f99deb680620711013a7369886fa.zip
Add "M-x theo". Just like "M-x doctor" in emacs... Well, almost.
More beer!
-rw-r--r--usr.bin/mg/Makefile4
-rw-r--r--usr.bin/mg/main.c4
-rw-r--r--usr.bin/mg/theo.c85
3 files changed, 90 insertions, 3 deletions
diff --git a/usr.bin/mg/Makefile b/usr.bin/mg/Makefile
index c5eba2bf9cd..1fab7df269b 100644
--- a/usr.bin/mg/Makefile
+++ b/usr.bin/mg/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.8 2001/05/24 10:58:33 art Exp $
+# $OpenBSD: Makefile,v 1.9 2001/06/23 04:22:45 art Exp $
PROG= mg
@@ -22,7 +22,7 @@ SRCS= cinfo.c fileio.c spawn.c ttyio.c tty.c ttykbd.c \
basic.c dir.c dired.c file.c line.c match.c paragraph.c \
random.c region.c search.c version.c window.c word.c \
buffer.c display.c echo.c extend.c help.c kbd.c keymap.c \
- macro.c main.c modes.c re_search.c funmap.c
+ macro.c main.c modes.c re_search.c funmap.c theo.c
#
# More or less standalone extensions.
diff --git a/usr.bin/mg/main.c b/usr.bin/mg/main.c
index 5f9981392b1..14f6b9a87dc 100644
--- a/usr.bin/mg/main.c
+++ b/usr.bin/mg/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.13 2001/05/24 10:58:34 art Exp $ */
+/* $OpenBSD: main.c,v 1.14 2001/06/23 04:22:44 art Exp $ */
/*
* Mainline.
@@ -48,8 +48,10 @@ main(argc, argv)
*/
{
extern void grep_init(void);
+ extern void theo_init(void);
grep_init();
+ theo_init();
}
/*
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