bool GuiTextEntry::onKey(sf::Event::KeyEvent key, int unicode)
{
    if (key.code == sf::Keyboard::BackSpace && text.length() > 0)
    {
        text = text.substr(0, -1);
        if (func)
            func(text);
    }
    if (key.code == sf::Keyboard::Return)
    {
        if (enter_func)
            enter_func(text);
    }
    if (key.code == sf::Keyboard::V && key.control)
    {
        for(int unicode : Clipboard::readClipboard())
        {
            if (unicode > 31 && unicode < 128)
                text += string(char(unicode));
        }
        if (func)
            func(text);
        return true;
    }
    if (unicode > 31 && unicode < 128)
    {
        text += string(char(unicode));
        if (func)
            func(text);
    }
    return true;
}
Example #2
0
void exit_bc_thread()
{
	enter_func();
	close(sockfd);

	ev_break(bc_loop, EVBREAK_ALL);
}
Example #3
0
File: ads29.c Project: jleffler/soq
static void merge(void *left, size_t size, size_t l_len, void *right,
                  size_t r_len, void *output, Comparator cmp)
{
    char  *l_pos = left;
    char  *r_pos = right;
    char  *l_end  = l_pos + l_len * size;
    char  *r_end  = r_pos + r_len * size;
    char  *o_pos = output;
    enter_func(__func__);
    while (r_pos < r_end && l_pos < l_end)
    {
        if ((*cmp)(r_pos, l_pos) < 0)
        {
            memmove(o_pos, r_pos, size);
            o_pos += size;
            r_pos += size;
        }
        else
        {
            memmove(o_pos, l_pos, size);
            o_pos += size;
            l_pos += size;
        }
    }
    /* Only one of these conditions is active */
    if (r_pos < r_end)
        memmove(o_pos, r_pos, r_end - r_pos);
    if (l_pos < l_end)
        memmove(o_pos, l_pos, l_end - l_pos);
    exit_func(__func__);
}
Example #4
0
int bc_main()
{
	enter_func();
	bc_loop = ev_loop_new(0);

	sockfd = init_bc_socket();
	if (sockfd < 0) {
		DBG(D_ERROR, "init_socket failed \n ");
		exit(0);
	}
	init_bc_socket_watcher();
	init_bc_async_watcher();
	init_bc_periodic_watcher();

    ev_run(bc_loop, 0);

    ev_loop_destroy(bc_loop);
    DBG(D_INFO, "bcast ev_run exits");
	return (0);
}
Example #5
0
File: ads29.c Project: jleffler/soq
void merge_sort(void *array, size_t arrlen, size_t size, Comparator cmp)
{
    if (arrlen <= 1)
        return;

    char *base = array;
    size_t mid = arrlen / 2;
    size_t l_len = mid;
    size_t r_len = arrlen - mid;
    char l_data[l_len * size];
    char r_data[r_len * size];

    enter_func(__func__);
    memmove(l_data, base, l_len * size);
    memmove(r_data, base + l_len * size, r_len * size);
    merge_sort(l_data, l_len, size, cmp);
    merge_sort(r_data, r_len, size, cmp);
    merge(l_data, size, l_len, r_data, r_len, array, cmp);
    exit_func(__func__);
}
Example #6
0
bool GuiTextEntry::onKey(sf::Keyboard::Key key, int unicode)
{
    if (key == sf::Keyboard::BackSpace && text.length() > 0)
    {
        text = text.substr(0, -1);
        if (func)
            func(text);
    }
    if (key == sf::Keyboard::Return)
    {
        if (enter_func)
            enter_func(text);
    }
    if (unicode > 31 && unicode < 128)
    {
        text += string(char(unicode));
        if (func)
            func(text);
    }
    return true;
}
Example #7
0
File: ms27.c Project: jleffler/soq
static void merge(int *left, size_t l_len, int *right, size_t r_len, int *output)
{
    size_t r_pos = 0;
    size_t l_pos = 0;
    size_t o_pos = 0;
    enter_func(__func__);
    dump_array("Left:", left, l_len);
    dump_array("Right:", right, r_len);
    while (r_pos < r_len && l_pos < l_len)
    {
        if (right[r_pos] < left[l_pos])
            output[o_pos++] = right[r_pos++];
        else
            output[o_pos++] = left[l_pos++];
    }
    while (r_pos < r_len)
        output[o_pos++] = right[r_pos++];
    while (l_pos < l_len)
        output[o_pos++] = left[l_pos++];
    dump_array("Output:", output, r_len + l_len);
    exit_func(__func__);
}
Example #8
0
/*!
 * Standard Button-Zuordnung bei Initialisierung.
 * \param button Welcher Taster wurde gerade gedrückt.
 * \param status Zustand des Tasters (losgelassen, gedrückt, gehalten, etc..)
 */
void default_button_handler(buttons_ButtonsType button, uint8_t status) {

  if ( (BUTTON_REPEAT == status || BUTTON_PRESS == status) && (button == BTN_NEXT || button == BTN_ENTER) )
  {

    default_gui_beep();

    switch (button)
    {

      case BTN_NEXT:  next_func();   break;   /* Pointer to function executing default next step defined in menu */
      case BTN_ENTER: enter_func();  break;   /* Pointer to function executing default enter sequence defined in menu */

      case SW1_1: break;
      case SW1_2: break;
   
      //case BTN_NEXT: gui_screen_set(AL_MENU_TOGGLE); break;
      //case BTN_ENTER: break;
    }

  }

}
Example #9
0
File: ms27.c Project: jleffler/soq
void merge_sort(int *array, size_t len)
{
    if (len <= 1)
        return;
    int left[(len+1)/2];
    int l_pos = 0;
    int right[(len+1)/2];
    int r_pos = 0;
    size_t mid = len / 2;

    enter_func(__func__);
    dump_array("Input:", array, len);
    for (size_t i = 0; i < mid; i++)
        left[l_pos++] = array[i];
    for (size_t i = mid; i < len; i++)
        right[r_pos++] = array[i];
    dump_array("Left:", left, l_pos);
    dump_array("Right:", right, r_pos);
    merge_sort(left, l_pos);
    merge_sort(right, r_pos);
    merge(left, l_pos, right, r_pos, array);
    dump_array("Result:", array, len);
    exit_func(__func__);
}
Example #10
0
void bc_async_cb(struct ev_loop *bc_loop, ev_async *w, int revent)
{
	enter_func();
	exit_bc_thread();
}