Ignore:
Timestamp:
Jan 10, 2004, 8:29:12 PM (19 years ago)
Author:
Sam Hocevar
Message:
  • src/graphics: + Initialise the char buffers in the X11 driver.
  • src/io.c: + caca_get_event() and caca_wait_event() immediately return zero if

event_mask is zero.

+ Added support for the Home, End, PgUp? and PgDown? keys.
+ In the S-Lang driver, added a call to SLang_getkey() before the call to

SLkp_getkey(), otherwise a single Escape call will not be interpreted.

  • test/event.c: + The "quit" sequence now quits the program, instead of "q" alone. + Added a status bar below.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/test/event.c

    r331 r332  
    3939        return 1;
    4040
     41    h = caca_get_height() - 1;
     42
    4143    caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLUE);
    4244    caca_draw_line(0, 0, caca_get_width() - 1, 0, ' ');
    4345
     46    caca_draw_line(0, h, caca_get_width() - 1, h, ' ');
     47    caca_putstr(0, h, "type \"quit\" to exit");
     48
    4449    caca_refresh();
    45 
    46     h = caca_get_height();
    4750
    4851    events = malloc(h * sizeof(int));
    4952    memset(events, 0, h * sizeof(int));
    5053
    51     for(quit = 0; !quit; )
     54    for(quit = 0; quit < 4; )
    5255    {
     56        static char const * quit_string[] = { "", "q", "qu", "qui", "quit" };
    5357        unsigned int event = caca_wait_event(CACA_EVENT_ANY);
    5458
     
    5862        do
    5963        {
    60             /* q quits */
    61             if(event == (CACA_EVENT_KEY_PRESS | 'q'))
    62                 quit = 1;
     64            /* "quit" quits */
     65            if(event & CACA_EVENT_KEY_PRESS)
     66            {
     67                int key = event & ~CACA_EVENT_KEY_PRESS;
     68                if((key == 'q' && quit == 0) || (key == 'u' && quit == 1)
     69                    || (key == 'i' && quit == 2) || (key == 't' && quit == 3))
     70                    quit++;
     71                else if(key == 'q')
     72                    quit = 1;
     73                else
     74                    quit = 0;
     75            }
    6376
    6477            memmove(events + 1, events, (h - 1) * sizeof(int));
     
    7588        caca_draw_line(0, 0, caca_get_width() - 1, 0, ' ');
    7689        print_event(0, 0, events[0]);
     90
     91        caca_draw_line(0, h, caca_get_width() - 1, h, ' ');
     92        caca_printf(0, h, "type \"quit\" to exit: %s", quit_string[quit]);
    7793
    7894        /* Print previous events */
Note: See TracChangeset for help on using the changeset viewer.