Changeset 4082 for libcaca/trunk


Ignore:
Timestamp:
Dec 3, 2009, 2:13:15 AM (10 years ago)
Author:
Sam Hocevar
Message:

Pass Ctrl-C as a keypress to the calling application in the SLang driver.
Original patch courtesy of Romain Bignon.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/driver/slang.c

    r3985 r4082  
    116116{
    117117    char *term;
     118    unsigned int sigint_event;
    118119};
    119120
    120121static void default_sigint (int sig)
    121122{
    122     /* Do nothing */
    123     return;
     123    /* Warn the caller that we got SIGINT. */
     124    sigwinch_d->drv.p->sigint_event++;
    124125}
    125126
     
    127128{
    128129    dp->drv.p = malloc(sizeof(struct driver_private));
     130    dp->drv.p->sigint_event = 0;
    129131
    130132#if defined(HAVE_GETENV) && defined(HAVE_PUTENV)
     
    188190    dp->resize.allow = 0;
    189191
     192    SLsig_unblock_signals();
     193
    190194    return 0;
    191195}
     
    197201    SLtt_set_cursor_visibility(1);
    198202    SLang_reset_tty();
     203    SLsig_block_signals();
    199204    SLsmg_reset_smg();
    200205    SLsig_unblock_signals();
     
    232237    int x, y, i;
    233238
     239    SLsig_block_signals();
    234240    for(i = 0; i < caca_get_dirty_rect_count(dp->cv); i++)
    235241    {
     
    298304    SLsmg_gotorc(caca_wherey(dp->cv), caca_wherex(dp->cv));
    299305    SLsmg_refresh();
     306    SLsig_unblock_signals();
    300307}
    301308
     
    306313    dp->resize.h = SLtt_Screen_Rows;
    307314
     315    SLsig_block_signals();
    308316    if(dp->resize.w != caca_get_canvas_width(dp->cv)
    309317        || dp->resize.h != caca_get_canvas_height(dp->cv))
    310318        SLsmg_reinit_smg();
     319    SLsig_unblock_signals();
    311320}
    312321
     
    314323{
    315324    int intkey;
     325
     326    /* If SIGINT was caught, we pass it to the application as Ctrl-C. */
     327    if(dp->drv.p->sigint_event > 0)
     328    {
     329        ev->type = CACA_EVENT_KEY_PRESS;
     330        ev->data.key.ch = CACA_KEY_CTRL_C;
     331        ev->data.key.utf32 = 0x03;
     332        ev->data.key.utf8[0] = 0x03;
     333        ev->data.key.utf8[1] = 0;
     334        dp->drv.p->sigint_event--;
     335        return 1;
     336    }
    316337
    317338    if(!SLang_input_pending(0))
Note: See TracChangeset for help on using the changeset viewer.