diff options
| author | troido <troido@hotmail.com> | 2018-04-14 18:13:19 +0200 |
|---|---|---|
| committer | troido <troido@hotmail.com> | 2018-04-14 18:13:19 +0200 |
| commit | aa5b7c9d753f6f140d7f55d0089e6e19028031b7 (patch) | |
| tree | 6573cbda9383c9f12a625f95bd48bbd20cfd3f22 /asciifarm/client/inputhandling.hy | |
| parent | b15f89a3576b98f57ff1ec083e9299c890c1f7fc (diff) | |
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.
Diffstat (limited to 'asciifarm/client/inputhandling.hy')
| -rw-r--r-- | asciifarm/client/inputhandling.hy | 48 |
1 files changed, 0 insertions, 48 deletions
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))))) -) |
