1 // Copyright 2022 Garrett D'Amore 2 // 3 // Distributed under the Boost Software License, Version 1.0. 4 // (See accompanying file LICENSE or https://www.boost.org/LICENSE_1_0.txt) 5 6 module dcell.event; 7 8 import core.time; 9 10 import dcell.key; 11 import dcell.mouse; 12 13 enum EventType 14 { 15 none = 0, 16 closed, /// input queue is closed (no more events will be received) 17 error, /// an error condition 18 key, /// a keyboard press 19 mouse, /// a mouse event 20 paste, /// a paste event 21 resize, /// window was resized 22 } 23 24 /** 25 * Event is the abstract from of an event. We use structs because 26 * these will be sent by value over the message box. Other event 27 * types should "derive" from this by using it as their first member 28 * and using alias this. 29 */ 30 struct Event 31 { 32 EventType type; 33 MonoTime when; 34 union 35 { 36 MouseEvent mouse; 37 KeyEvent key; 38 ResizeEvent resize; 39 PasteEvent paste; 40 } 41 } 42 43 /** 44 * Resize is fired when a window resize event has occurred. 45 * It is something the application should use to determine 46 * when it needs to update layouts, etc. 47 */ 48 struct ResizeEvent 49 { 50 } 51 52 /** 53 * Paste start or stop. 54 */ 55 struct PasteEvent 56 { 57 dstring content; 58 }