Annotation of src/usr.bin/mg/theo.c, Revision 1.150
1.150 ! lum 1: /* $OpenBSD: theo.c,v 1.149 2015/11/14 21:24:11 sthen Exp $ */
1.45 art 2: /*
3: * Copyright (c) 2002 Artur Grabowski <art@openbsd.org>
1.58 deraadt 4: * All rights reserved.
1.45 art 5: *
1.58 deraadt 6: * Redistribution and use in source and binary forms, with or without
7: * modification, are permitted provided that the following conditions
8: * are met:
1.45 art 9: *
1.58 deraadt 10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
1.45 art 12: * 2. The name of the author may not be used to endorse or promote products
1.58 deraadt 13: * derived from this software without specific prior written permission.
1.45 art 14: *
15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
16: * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
17: * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
18: * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23: * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
1.58 deraadt 24: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.45 art 25: */
1.19 hugh 26:
1.145 bcallah 27: #include <sys/queue.h>
28: #include <signal.h>
29: #include <stdio.h>
30: #include <stdlib.h>
31: #include <string.h>
32:
1.1 art 33: #include "def.h"
1.145 bcallah 34: #include "funmap.h"
1.1 art 35: #include "kbd.h"
36:
1.81 db 37: void theo_init(void);
1.1 art 38: static int theo_analyze(int, int);
39: static int theo(int, int);
40:
41: static PF theo_pf[] = {
1.81 db 42: theo_analyze
1.1 art 43: };
44:
1.146 bcallah 45: static struct KEYMAPE (1) theomap = {
46: 1,
1.1 art 47: 1,
48: rescan,
49: {
1.81 db 50: { CCHR('M'), CCHR('M'), theo_pf, NULL }
1.1 art 51: }
52: };
53:
54: void
55: theo_init(void)
56: {
57: funmap_add(theo, "theo");
58: maps_add((KEYMAP *)&theomap, "theo");
59: }
60:
1.91 kjell 61: /* ARGSUSED */
1.1 art 62: static int
63: theo(int f, int n)
64: {
1.97 deraadt 65: struct buffer *bp;
66: struct mgwin *wp;
1.1 art 67:
68: bp = bfind("theo", TRUE);
69: if (bclear(bp) != TRUE)
1.81 db 70: return (FALSE);
1.1 art 71:
72: bp->b_modes[0] = name_mode("fundamental");
73: bp->b_modes[1] = name_mode("theo");
74: bp->b_nmodes = 1;
75:
1.109 kjell 76: if ((wp = popbuf(bp, WNONE)) == NULL)
1.81 db 77: return (FALSE);
1.1 art 78:
1.90 deraadt 79: curbp = bp;
1.1 art 80: curwp = wp;
1.147 lum 81: (void)onlywind(FFRAND, 1);
1.122 lum 82:
1.81 db 83: return (TRUE);
1.1 art 84: }
85:
1.3 mickey 86: static const char *talk[] = {
1.1 art 87: "Write more code.",
88: "Make more commits.",
89: "That's because you have been slacking.",
90: "slacker!",
91: "That's what happens when you're lazy.",
92: "idler!",
93: "slackass!",
94: "lazy bum!",
1.2 millert 95: "Stop slacking you lazy bum!",
1.4 mickey 96: "slacker slacker lazy bum bum bum slacker!",
1.5 miod 97: "I could search... but I'm a lazy bum ;)",
1.6 mickey 98: "sshutup sshithead, ssharpsshooting susshi sshplats ssharking assholes.",
1.7 mickey 99: "Lazy bums slacking on your asses.",
1.8 beck 100: "35 commits an hour? That's pathetic!",
1.9 angelos 101: "Fine software takes time to prepare. Give a little slack.",
1.12 fgsch 102: "I am just stating a fact",
1.16 beck 103: "you bring new meaning to the terms slackass. I will have to invent a new term.",
104: "if they cut you out, muddy their back yards",
1.17 beck 105: "Make them want to start over, and play nice the next time.",
1.21 miod 106: "It is clear that this has not been thought through.",
1.29 mickey 107: "avoid using abort(). it is not nice.",
1.23 kjell 108: "That's the most ridiculous thing I've heard in the last two or three minutes!",
1.24 aaron 109: "I'm not just doing this for crowd response. I need to be right.",
1.26 kjell 110: "I'd put a fan on my bomb.. And blinking lights...",
1.27 kjell 111: "I love to fight",
1.29 mickey 112: "No sane people allowed here. Go home.",
1.30 henning 113: "you have to stop peeing on your breakfast",
1.31 henning 114: "feature requests come from idiots",
1.32 mickey 115: "henning and darren / sitting in a tree / t o k i n g / a joint or three",
1.33 henning 116: "KICK ASS. TIME FOR A JASON LOVE IN! WE CAN ALL GET LOST IN HIS HAIR!",
1.34 henning 117: "shame on you for following my rules.",
1.35 henning 118: "altq's parser sucks dead whale farts through the finest chemistry pipette's",
1.36 pvalchev 119: "screw this operating system shit, i just want to drive!",
1.38 miod 120: "Search for fuck. Anytime you see that word, you have a paragraph to write.",
1.40 henning 121: "Yes, but the ports people are into S&M.",
1.43 mcbride 122: "Buttons are for idiots.",
1.44 grange 123: "We are not hackers. We are turd polishing craftsmen.",
1.47 grange 124: "who cares. style(9) can bite my ass",
1.49 mickey 125: "It'd be one fucking happy planet if it wasn't for what's under this fucking sticker.",
1.50 drahn 126: "I would explain, but I am too drunk.",
1.60 mickey 127: "you slackers don't deserve pictures yet",
1.53 todd 128: "Vegetarian my ass",
1.56 pvalchev 129: "Wait a minute, that's a McNally's!",
1.62 jolan 130: "don't they recognize their moral responsibility to entertain me?",
1.95 cloder 131: "#ifdef is for emacs developers.",
1.74 miod 132: "Many well known people become net-kooks in their later life, because they lose touch with reality.",
1.64 mcbride 133: "You're not allowed to have an opinion.",
1.66 marco 134: "tweep tweep tweep",
1.74 miod 135: "Quite frankly, SSE's alignment requirement is the most utterly retarded idea since eating your own shit.",
136: "Holy verbose prom startup Batman.",
1.71 marco 137: "Any day now, when we sell out.",
1.75 henning 138: "optimism in man kind does not belong here",
1.76 henning 139: "First user who tries to push this button, he pounds into the ground with a rant of death.",
1.77 marco 140: "we did farts. now we do sperm. we are cutting edge.",
1.78 jolan 141: "the default configuration is a mixture of piss, puke, shit, and bloody entrails.",
142: "Stop wasting your time reading people's licenses.",
143: "doing it with environment variables is OH SO SYSTEM FIVE LIKE OH MY GOD PASS ME THE SPOON",
1.79 jolan 144: "Linux is fucking POO, not just bad, bad REALLY REALLY BAD",
1.80 henning 145: "penguins are not much more than chickens that swim.",
1.82 djm 146: "i am a packet sniffing fool, let me wipe my face with my own poo",
1.84 todd 147: "Whiners. They scale really well.",
1.85 todd 148: "in your world, you would have a checklist of 50 fucking workarounds just to make a coffee.",
1.86 henning 149: "for once, I have nothing to say.",
1.87 jason 150: "You have no idea how fucked we are",
1.88 reyk 151: "You can call it fart if you want to.",
1.89 marco 152: "wavelan is a battle field",
1.98 djm 153: "You are in a maze of gpio pins, all alike, all undocumented, and a few are wired to bombs.",
1.99 kjell 154: "And that is why humppa sucks... cause it has no cause.",
1.100 djm 155: "cache aliasing is a problem that would have stopped in 1992 if someone had killed about 5 people who worked at Sun.",
156: "Don't spread rumours about me being gentle.",
1.101 jasper 157: "If municipal water filtering equipment was built by the gcc developers, the western world would be dead by now.",
1.103 beck 158: "kettenis supported a new machine in my basement and all I got to do was fix a 1 character typo in his html page commit.",
1.104 henning 159: "industry told us a lesson: when you're an asshole, they mail you hardware",
1.105 claudio 160: "I was joking, really. I think I am funny :-)",
1.107 djm 161: "the kernel is a harsh mistress",
1.108 sthen 162: "Have I ever been subtle? If my approach ever becomes subtle, shoot me.",
1.110 jasper 163: "the acpi stabs you in the back. the acpi stabs you in the back. you die ...",
1.111 henning 164: "My cats are more observant than you.",
1.112 claudio 165: "our kernels have no bugs",
1.113 oga 166: "style(9) has all these fascist rules, and i have a problem with some of them because i didn't come up with them",
1.114 oga 167: "I'm not very reliable",
1.115 schwarze 168: "I don't like control",
1.118 jasper 169: "You aren't being conservative -- you are trying to be a caveman.",
1.119 jasper 170: "nfs loves everyone",
1.120 henning 171: "basically, dung beetles fucking. that's what kerberosV + openssl is like",
1.121 djm 172: "I would rather run Windows than use vi.",
1.123 claudio 173: "if you assign that responsibility to non-hikers I will walk over and cripple you now.",
1.124 mlarkin 174: "i ojbect two yoru splelng of achlhlocis.",
1.125 florian 175: "We have two kinds of developers - those that deal with their own shit and those that deal with other people's shit.",
1.126 sthen 176: "If people keep adding such huge stuff, soon mg will be bigger than emacs.",
1.127 reyk 177: "this change comes down to: This year, next year, 5 years from now, 10 years from now, or Oh fuck.",
1.128 blambert 178: "backwards compatibility is king, and will remain king, until 2038.",
1.129 henning 179: "I don't know if the Internet's safe yet.",
1.130 henning 180: "Those who don't understand Unix are condemned to reinvent Multics in a browser",
1.131 florian 181: "Don't tell anybody I said that.",
1.132 tedu 182: "Complaint forms are handled in another department.",
183: "You'd be safer using Windows than the code which was just deleted.",
1.134 tedu 184: "Shit should not be shared.",
185: "the randomization in this entire codebase is a grand experiment in stupid",
1.135 tedu 186: "My mailbox is full of shock.",
1.136 sthen 187: "my integer overflow spidey senses are tingling.",
1.137 tedu 188: "I'm just trying to improve the code...",
1.138 schwarze 189: "It's a pleasure to work on code you can't make worse.",
1.139 tedu 190: "It's largely bad style to do (int)sizeof",
1.140 schwarze 191: "When I see Makefile.in, I know that \"in\" is short for \"insane\".",
1.141 benno 192: "This is the beer. And that's why we need a hackathon.",
1.142 tedu 193: "Kill the past with fire, and declare Duran Duran is less cool today. Await remixes of the same thing performed by new talent.",
194: "Where did my \"fuck backwards compat\" compatriots go?",
1.143 schwarze 195: "I want a new vax, one that's not so slow.",
1.148 tedu 196: "This sausage is made from unsound meat.",
1.149 sthen 197: "The people who wrote this code are not on your side.",
1.1 art 198: };
199:
1.117 jasper 200: static const int ntalk = sizeof(talk)/sizeof(talk[0]);
1.1 art 201:
1.91 kjell 202: /* ARGSUSED */
1.1 art 203: static int
204: theo_analyze(int f, int n)
205: {
1.81 db 206: const char *str;
207: int len;
1.1 art 208:
1.102 djm 209: str = talk[arc4random_uniform(ntalk)];
1.1 art 210: len = strlen(str);
211:
1.150 ! lum 212: undo_boundary_enable(FFRAND, 0);
1.144 bcallah 213: enewline(FFRAND, 2);
1.1 art 214:
1.81 db 215: while (len--)
1.1 art 216: linsert(1, *str++);
217:
1.144 bcallah 218: enewline(FFRAND, 2);
1.150 ! lum 219: undo_boundary_enable(FFRAND, 1);
1.1 art 220:
1.81 db 221: return (TRUE);
1.2 millert 222: }