From aa5b7c9d753f6f140d7f55d0089e6e19028031b7 Mon Sep 17 00:00:00 2001 From: troido Date: Sat, 14 Apr 2018 18:13:19 +0200 Subject: Stopped using hy for keybindings keybindings are now a JSON format. Somehow hy errored for me, and the cleanest solution seemed not to use hy at all Thinking about it, the client was basically loading a new interpreter to optimize something that didn't need optimizing. It didn't make it more readable/writable either, and it always was a lot of hassle. --- asciifarm/client/inputhandling.hy | 48 --------------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 asciifarm/client/inputhandling.hy (limited to 'asciifarm/client/inputhandling.hy') diff --git a/asciifarm/client/inputhandling.hy b/asciifarm/client/inputhandling.hy deleted file mode 100644 index 9c3e254..0000000 --- a/asciifarm/client/inputhandling.hy +++ /dev/null @@ -1,48 +0,0 @@ - -(require [asciifarm.client.keymacros [*]]) -(import [asciifarm.client.keynames [nameFromKey]]) - -(defclass InputHandler [] - - (defn --init-- [self client display connection] - (setv self.client client) - (setv self.display display) - (setv self.connection connection) - (setv self.commands None)) - - (defn readCommands [self commandsstring] (do - (setv self.commands - (dict-comp - (str key) - ( - (eval `(do - (require [asciifarm.client.keymacros [*]]) - (fn [handler] - (fn [] ~value)))) - self) - [[key value] (.items (read-str commandsstring))])) - ((.get self.commands "init" (fn []))))) - - (defn runCommand [self commandstring] - (try - (eval (read-str (+ "(" commandstring ")"))) - (except [e Exception] - (self.client.log (repr e))))) - - (defn parseMessage [self message] - (if message - (if (= (first message) "/") - (do - (setv msg (.join "" (drop 1 message))) - (if (= (first msg) "/") - (send ["chat" msg]) - (self.runCommand msg))) - (send ["chat" message])))) - - (defn getDocs [self] - (if (in "help" self.commands) ((get self.commands "help")) "")) - - (defn onKey [self key] (do - (setv keyname (nameFromKey key)) - (if (in keyname self.commands) ((get self.commands keyname))))) -) -- cgit