Преглед изворни кода

* Minor cosmetic changes in the test programs.

* Code enhancements in the ncurses driver.
  * Added a comment to explain why slang has a higher priority than ncurses.
tags/v0.99.beta14
Sam Hocevar sam пре 18 година
родитељ
комит
1f3e745f52
4 измењених фајлова са 42 додато и 130 уклоњено
  1. +2
    -0
      caca/caca.c
  2. +38
    -128
      caca/driver_ncurses.c
  3. +1
    -1
      test/colors.c
  4. +1
    -1
      test/input.c

+ 2
- 0
caca/caca.c Прегледај датотеку

@@ -161,6 +161,8 @@ static int caca_init_driver(caca_display_t *dp)
#if defined(USE_GL)
if(gl_install(dp) == 0) return 0;
#endif
/* slang has a higher priority than ncurses because though ncurses handles
* color a bit better across terminals, its UTF-8 supports seems broken. */
#if defined(USE_SLANG)
if(slang_install(dp) == 0) return 0;
#endif


+ 38
- 128
caca/driver_ncurses.c Прегледај датотеку

@@ -255,136 +255,44 @@ static int ncurses_get_event(caca_display_t *dp, caca_event_t *ev)

switch(mevent.bstate)
{
case BUTTON1_PRESSED:
ev->data.mouse.button = 1;
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
break;
case BUTTON1_RELEASED:
ev->data.mouse.button = 1;
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
break;
case BUTTON1_CLICKED:
ev->data.mouse.button = 1;
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
break;
case BUTTON1_DOUBLE_CLICKED:
ev->data.mouse.button = 1;
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
break;
case BUTTON1_TRIPLE_CLICKED:
ev->data.mouse.button = 1;
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
break;
case BUTTON1_RESERVED_EVENT:
break;

case BUTTON2_PRESSED:
ev->data.mouse.button = 2;
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
break;
case BUTTON2_RELEASED:
ev->data.mouse.button = 2;
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
break;
case BUTTON2_CLICKED:
ev->data.mouse.button = 2;
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
break;
case BUTTON2_DOUBLE_CLICKED:
ev->data.mouse.button = 2;
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
break;
case BUTTON2_TRIPLE_CLICKED:
ev->data.mouse.button = 2;
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
break;
case BUTTON2_RESERVED_EVENT:
break;

case BUTTON3_PRESSED:
ev->data.mouse.button = 3;
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
break;
case BUTTON3_RELEASED:
ev->data.mouse.button = 3;
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
break;
case BUTTON3_CLICKED:
ev->data.mouse.button = 3;
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
break;
case BUTTON3_DOUBLE_CLICKED:
ev->data.mouse.button = 3;
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
break;
case BUTTON3_TRIPLE_CLICKED:
ev->data.mouse.button = 3;
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
break;
case BUTTON3_RESERVED_EVENT:
break;

case BUTTON4_PRESSED:
ev->data.mouse.button = 4;
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
break;
case BUTTON4_RELEASED:
ev->data.mouse.button = 4;
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
break;
case BUTTON4_CLICKED:
ev->data.mouse.button = 4;
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
break;
case BUTTON4_DOUBLE_CLICKED:
ev->data.mouse.button = 4;
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
break;
case BUTTON4_TRIPLE_CLICKED:
ev->data.mouse.button = 4;
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev);
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev);
break;
case BUTTON4_RESERVED_EVENT:
break;
#define PRESS(x) ev->data.mouse.button = x; \
ev->type = CACA_EVENT_MOUSE_PRESS; _push_event(dp, ev)
#define RELEASE(x) ev->data.mouse.button = x; \
ev->type = CACA_EVENT_MOUSE_RELEASE; _push_event(dp, ev)
#define CLICK(x) PRESS(x); RELEASE(x)
case BUTTON1_PRESSED: PRESS(1); break;
case BUTTON1_RELEASED: RELEASE(1); break;
case BUTTON1_CLICKED: CLICK(1); break;
case BUTTON1_DOUBLE_CLICKED: CLICK(1); CLICK(1); break;
case BUTTON1_TRIPLE_CLICKED: CLICK(1); CLICK(1); CLICK(1); break;
case BUTTON1_RESERVED_EVENT: break;

case BUTTON2_PRESSED: PRESS(2); break;
case BUTTON2_RELEASED: RELEASE(2); break;
case BUTTON2_CLICKED: CLICK(2); break;
case BUTTON2_DOUBLE_CLICKED: CLICK(2); CLICK(2); break;
case BUTTON2_TRIPLE_CLICKED: CLICK(2); CLICK(2); CLICK(2); break;
case BUTTON2_RESERVED_EVENT: break;

case BUTTON3_PRESSED: PRESS(3); break;
case BUTTON3_RELEASED: RELEASE(3); break;
case BUTTON3_CLICKED: CLICK(3); break;
case BUTTON3_DOUBLE_CLICKED: CLICK(3); CLICK(3); break;
case BUTTON3_TRIPLE_CLICKED: CLICK(3); CLICK(3); CLICK(3); break;
case BUTTON3_RESERVED_EVENT: break;

case BUTTON4_PRESSED: PRESS(4); break;
case BUTTON4_RELEASED: RELEASE(4); break;
case BUTTON4_CLICKED: CLICK(4); break;
case BUTTON4_DOUBLE_CLICKED: CLICK(4); CLICK(4); break;
case BUTTON4_TRIPLE_CLICKED: CLICK(4); CLICK(4); CLICK(4); break;
case BUTTON4_RESERVED_EVENT: break;

default:
break;
#undef PRESS
#undef RELEASE
#undef CLICK
}

if(dp->mouse.x == (unsigned int)mevent.x &&
@@ -429,7 +337,9 @@ static int ncurses_get_event(caca_display_t *dp, caca_event_t *ev)
case KEY_F(11): ev->data.key.ch = CACA_KEY_F11; break;
case KEY_F(12): ev->data.key.ch = CACA_KEY_F12; break;

default: ev->type = CACA_EVENT_NONE; return 0;
default:
/* Unknown key */
ev->type = CACA_EVENT_NONE; return 0;
}

ev->type = CACA_EVENT_KEY_PRESS;


+ 1
- 1
test/colors.c Прегледај датотеку

@@ -46,7 +46,7 @@ int main(int argc, char **argv)
{
cucul_set_color(cv, i, j);
cucul_putstr(cv, (j >= 8 ? 41 : 40) + j * 2, i + (i >= 8 ? 4 : 3),
"# ");
"Aa");
}
}



+ 1
- 1
test/input.c Прегледај датотеку

@@ -74,7 +74,7 @@ int main(void)
}

/* Put the cursor on the active textentry */
cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_WHITE);
cucul_set_color(cv, CUCUL_COLOR_LIGHTRED, CUCUL_COLOR_LIGHTRED);
cucul_putchar(cv, 2 + entries[e].cursor, 3 * e + 4, ' ');

caca_refresh_display(dp);


Loading…
Откажи
Сачувај