Changeset 33

Show
Ignore:
Timestamp:
04/08/07 00:31:48 (2 years ago)
Author:
pmac
Message:

Replace poorly named key_event class with event_type (per code review)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/birth.c

    r30 r33  
    792792        while(i < N_ELEMENTS(menu_defs)) 
    793793        { 
    794                 key_event cx; 
     794                event_type cx; 
    795795                int cursor = *values[i]; 
    796796                menu.flags = MN_NO_TAGS | MN_DBL_TAP; 
  • trunk/src/cmd4.c

    r32 r33  
    170170                                byte attr_top, char char_left); 
    171171 
    172 static bool visual_mode_command(key_event ke, bool *visual_list_ptr,  
     172static bool visual_mode_command(event_type ke, bool *visual_list_ptr,  
    173173                                int height, int width,  
    174174                                byte *attr_top_ptr, char *char_left_ptr,  
     
    460460        /* with "pop-up menu" for lore */ 
    461461        while((!flag) && (grp_cnt)) { 
    462                 key_event ke, ke0; 
     462                event_type ke, ke0; 
    463463                if(redraw) { 
    464464                        region_erase(&title_area); 
     
    768768 *  Do visual mode command -- Change symbols 
    769769 */ 
    770 static bool visual_mode_command(key_event ke, bool *visual_list_ptr,  
     770static bool visual_mode_command(event_type ke, bool *visual_list_ptr,  
    771771                                int height, int width,  
    772772                                byte *attr_top_ptr, char *char_left_ptr,  
     
    16621662void do_cmd_change_name(void) 
    16631663{ 
    1664         key_event ke; 
     1664        event_type ke; 
    16651665 
    16661666        int mode = 0; 
     
    17731773void do_cmd_messages(void) 
    17741774{ 
    1775         key_event ke; 
     1775        event_type ke; 
    17761776 
    17771777        int i, j, n, q; 
     
    21252125        for(;;) 
    21262126        { 
    2127                 key_event cx; 
     2127                event_type cx; 
    21282128                cx = menu_select(menu, &cursor_pos, EVT_MOVE); 
    21292129                if (cx.type == EVT_BACK || ESCAPE == cx.key) break; 
     
    21582158        int x = 0; 
    21592159 
    2160         key_event ke; 
     2160        event_type ke; 
    21612161 
    21622162        u32b old_flag[ANGBAND_TERM_MAX]; 
     
    28892889        while (1) 
    28902890        { 
    2891                 key_event c; 
     2891                event_type c; 
    28922892                int evt; 
    28932893                /* Clear screen */ 
     
    33733373        while (1) 
    33743374        { 
    3375                 key_event key; 
     3375                event_type key; 
    33763376                int evt = -1; 
    33773377                Term_clear(); 
     
    35443544        while (1) 
    35453545        { 
    3546                 key_event key; 
     3546                event_type key; 
    35473547                int evt; 
    35483548                Term_clear(); 
     
    40344034        menu_layout(&option_menu, &SCREEN_REGION); 
    40354035        for(;;) { 
    4036                 key_event c; 
     4036                event_type c; 
    40374037                Term_clear(); 
    40384038                c = menu_select(&option_menu, &cursor, 0); 
     
    40514051        menu_layout(&knowledge_menu, &SCREEN_REGION); 
    40524052        for(;;) { 
    4053                 key_event c; 
     4053                event_type c; 
    40544054                Term_clear(); 
    40554055                c = menu_select(&knowledge_menu, &cursor, 0); 
  • trunk/src/externs.h

    r32 r33  
    684684extern char anykey(void); 
    685685extern char inkey(void); 
    686 extern key_event inkey_ex(void); 
     686extern event_type inkey_ex(void); 
    687687extern void bell(cptr reason); 
    688688extern void sound(int val); 
  • trunk/src/squelch.c

    r32 r33  
    772772        int sqlev = (int) arg; 
    773773        int i; 
    774         key_event ke = {EVT_REFRESH, 0, 0, 0}; 
     774        event_type ke = {EVT_REFRESH, 0, 0, 0}; 
    775775        for (i = 0; i < SQUELCH_BYTES; i++) { 
    776776                if(tvals[i].squelch_bits & ( 1 << sqlev)) 
     
    785785{ 
    786786        int sqlev = (int) arg; 
    787         key_event ke = {EVT_REFRESH, 0, 0, 0}; 
     787        event_type ke = {EVT_REFRESH, 0, 0, 0}; 
    788788        bool refresh = FALSE; 
    789789        if((squelch_level[q_rendez.item_pos] != sqlev) && 
     
    866866        region item_region = {0, 0, 20, 0}; 
    867867        region command_region = {25, 0, 0, 0}; 
    868         key_event ke = {EVT_NONE}; 
     868        event_type ke = {EVT_NONE}; 
    869869        menu_layout(&squelch_q_items, &item_region); 
    870870        menu_layout(&squelch_q_menu, &command_region); 
  • trunk/src/ui.c

    r32 r33  
    1313Implementation of Extremely Basic Event Model. 
    1414  Limits: 
    15     all events are of the concrete type key_event (see z-util.h),  
     15    all events are of the concrete type event_type (see z-util.h),  
    1616    which are supposed to model simple UI actions: 
    1717        - < escape > 
     
    2323 
    2424There are 3 basic event-related classes: 
    25 The key_event
     25The event_type
    2626Concrete event, with at most 32 distinct types. 
    2727 
     
    6969} 
    7070 
    71 bool region_inside(const region *loc, const key_event *key) 
     71bool region_inside(const region *loc, const event_type *key) 
    7272{ 
    7373        if ((loc->col > key->mousex) || (loc->col + loc->width <= key->mousex)) 
     
    9292void stop_event_loop() 
    9393{ 
    94         key_event stop = { EVT_STOP }; 
     94        event_type stop = { EVT_STOP }; 
    9595 
    9696        /* Stop right away! */ 
     
    110110 *    The first unhandled event - forever is false. 
    111111 */ 
    112 key_event run_event_loop(event_target * target, bool forever, const key_event *start) 
    113 { 
    114         key_event ke; 
     112event_type run_event_loop(event_target * target, bool forever, const event_type *start) 
     113{ 
     114        event_type ke; 
    115115        bool handled = TRUE; 
    116116 
     
    297297}; 
    298298 
    299 /* Simple strings */ 
    300  
     299/* Simple strings - display and selection only */ 
    301300static void display_string(menu_type *menu, int oid, bool cursor, 
    302301               int row, int col, int width) 
     
    531530                menu->row_funcs->row_handler(cmd, (void *)menu->menu_data, oid)) 
    532531        { 
    533                 key_event ke; 
     532                event_type ke; 
    534533                ke.type = EVT_SELECT; 
    535534                ke.key = cmd; 
     
    601600 
    602601/* The menu event loop */ 
    603 static bool menu_handle_event(menu_type *menu, const key_event *in) 
     602static bool menu_handle_event(menu_type *menu, const event_type *in) 
    604603{ 
    605604        int n = menu->filter_count; 
    606605        int *cursor = &menu->cursor; 
    607         key_event out; 
     606        event_type out; 
    608607 
    609608        out.key = '\xff'; 
     
    802801 * Returns: an event, possibly requiring further handling. 
    803802 * Return values: 
    804  *  EVT_SELECT - success. key_event::index is set to the cursor position. 
     803 *  EVT_SELECT - success. event_type::index is set to the cursor position. 
    805804 *      *cursor is also set to the cursor position. 
    806805 *  EVT_OK  - success. A command event was handled. 
     
    810809 *  EVT_KBRD - An unhandled keyboard event 
    811810 */ 
    812 key_event menu_select(menu_type *menu, int *cursor, int no_handle) 
    813 { 
    814         key_event ke; 
     811event_type menu_select(menu_type *menu, int *cursor, int no_handle) 
     812{ 
     813        event_type ke; 
    815814 
    816815        menu->cursor = *cursor; 
  • trunk/src/ui.h

    r32 r33  
    6060void region_erase(const region *loc); 
    6161/* Check whether a (mouse) event is inside a region */ 
    62 bool region_inside(const region *loc, const key_event *key); 
     62bool region_inside(const region *loc, const event_type *key); 
    6363 
    6464 
     
    7373 
    7474/* An event handler member function */ 
    75 typedef bool (*handler_f)(void *object, const key_event *in); 
     75typedef bool (*handler_f)(void *object, const event_type *in); 
    7676 
    7777/* Frees the resources for an owned event listener */ 
     
    110110 
    111111void remove_listener (event_target *parent, event_listener *child); 
    112 key_event run_event_loop(event_target *parent, bool forever, const key_event *start); 
     112event_type run_event_loop(event_target *parent, bool forever, const event_type *start); 
    113113 
    114114 
     
    209209 
    210210        /* Appearance & behavior */ 
     211 
    211212        MN_REL_TAGS     = 0x0100, /* Tags are associated with the view, not the element */ 
    212213        MN_NO_TAGS      = 0x0200, /* No tags -- movement key and mouse browsing only */ 
     
    215216        MN_DBL_TAP      = 0x1000, /* double tap for selection; single tap is cursor movement */ 
    216217        MN_NO_ACT       = 0x2000, /* Do not invoke the specified action; menu selection only */ 
     218        MN_PAGE         = 0x4000, /* Use full-page scrolling rather than small increment */ 
    217219        MN_NO_CURSOR = 0x8000, /* No cursor movement */ 
    218220 
     
    230232        /* Skins */ 
    231233        MN_SCROLL       = 0x0000, /* Ordinary scrollable single-column list */ 
    232         MN_PAGE         = 0x0001, /* Use full-page scrolling rather than small increment */ 
    233234        MN_COLUMNS      = 0x0002, /* multicolumn view */ 
    234235        MN_NATIVE       = 0x0003, /* Not implemented -- OS menu */ 
     
    333334 * reserved commands are 0xff for selection and ESCAPE for escape. 
    334335 */ 
    335 key_event menu_select(menu_type *menu, int *cursor, int no_handle); 
     336event_type menu_select(menu_type *menu, int *cursor, int no_handle); 
    336337 
    337338/* TODO: This belongs in the VTAB */ 
  • trunk/src/util.c

    r28 r33  
    868868 * known not to be that macro trigger.  XXX XXX XXX 
    869869 */ 
    870 static key_event inkey_aux(void) 
     870static event_type inkey_aux(void) 
    871871{ 
    872872        int k = 0, n, p = 0, w = 0; 
    873873         
    874         key_event ke, ke0; 
     874        event_type ke, ke0; 
    875875        char ch; 
    876876         
     
    11051105 * control of the keyboard from the user. 
    11061106 */ 
    1107 key_event inkey_ex(void) 
     1107event_type inkey_ex(void) 
    11081108{ 
    11091109        bool cursor_state; 
    1110         key_event kk; 
    1111         key_event ke; 
     1110        event_type kk; 
     1111        event_type ke; 
    11121112         
    11131113        bool done = FALSE; 
     
    13431343char anykey(void) 
    13441344{ 
    1345   key_event ke; 
     1345  event_type ke; 
    13461346   
    13471347  /* Only accept a keypress or mouse click*/ 
     
    13591359char inkey(void) 
    13601360{ 
    1361         key_event ke; 
     1361        event_type ke; 
    13621362 
    13631363        /* Only accept a keypress */ 
  • trunk/src/z-term.c

    r27 r33  
    19291929{ 
    19301930        if (!k) return (-1); 
    1931         key_event ke; 
     1931        event_type ke; 
    19321932        ke.type = EVT_KBRD; 
    19331933        ke.index = 0; 
     
    19361936} 
    19371937 
    1938 errr Term_event_push(const key_event *ke) 
     1938errr Term_event_push(const event_type *ke) 
    19391939{ 
    19401940        /* Hack -- Refuse to enqueue non-keys */ 
     
    19741974 * Remove the keypress if "take" is true. 
    19751975 */ 
    1976 errr Term_inkey(key_event *ch, bool wait, bool take) 
     1976errr Term_inkey(event_type *ch, bool wait, bool take) 
    19771977{ 
    19781978        /* Assume no key */ 
     
    24312431 
    24322432        /* Allocate the input queue */ 
    2433         C_MAKE(t->key_queue, t->key_size, key_event); 
     2433        C_MAKE(t->key_queue, t->key_size, event_type); 
    24342434 
    24352435 
  • trunk/src/z-term.h

    r28 r33  
    8585 
    8686 
    87 typedef struct key_event key_event
    88  
    89 struct key_event 
     87typedef struct event_type event_type
     88 
     89struct event_type 
    9090{ 
    9191        event_class type; 
     
    223223        char char_blank; 
    224224 
    225         key_event *key_queue; 
     225        event_type *key_queue; 
    226226 
    227227        u16b key_head; 
     
    341341extern errr Term_keypress(int k); 
    342342extern errr Term_key_push(int k); 
    343 extern errr Term_event_push(const key_event *ke); 
    344 extern errr Term_inkey(key_event *ch, bool wait, bool take); 
     343extern errr Term_event_push(const event_type *ke); 
     344extern errr Term_inkey(event_type *ch, bool wait, bool take); 
    345345 
    346346extern errr Term_set_resize_hook(void (*hook)(void));