Esempio n. 1
0
void draw_active_window(Tox *m)
{
    ToxWindow *a = active_window;
    a->alert0 = false;
    a->alert1 = false;
    a->alert2 = false;

    wint_t ch = 0;

    draw_bar();

    touchwin(a->window);
#ifndef WIN32
    wresize(a->window, LINES - 2, COLS);
#endif

    a->onDraw(a, m);
    wrefresh(a->window);

    /* Handle input */
#ifdef HAVE_WIDECHAR
    wget_wch(stdscr, &ch);
#else
    ch = getch();
#endif

    if (ch == T_KEY_NEXT || ch == T_KEY_PREV)
        set_next_window((int) ch);
    else if (ch != ERR)
        a->onKey(a, m, ch);
}
Esempio n. 2
0
void draw_active_window(Tox *m)
{
    ToxWindow *a = active_window;
    wint_t ch = 0;

    touchwin(a->window);
#ifndef WIN32
    wresize(a->window, LINES - 2, COLS);
#endif

    a->blink = false;
    draw_bar();
    a->onDraw(a, m);

    /* Handle input */
#ifdef HAVE_WIDECHAR
    wget_wch(stdscr, &ch);
#else
    ch = getch();
#endif

    if (ch == '\t' || ch == KEY_BTAB)
        set_next_window((int) ch);
    else if (ch != ERR)
        a->onKey(a, m, ch);
}
Esempio n. 3
0
void draw_active_window(Tox *m)
{
    ToxWindow *a = active_window;
    a->alert0 = false;
    a->alert1 = false;
    a->alert2 = false;

    wint_t ch = 0;

    draw_bar();

    touchwin(a->window);
#ifndef WIN32
    wresize(a->window, LINES - 2, COLS);
#endif

    a->onDraw(a, m);
    wrefresh(a->window);

    /* Handle input */
#ifdef HAVE_WIDECHAR
    if (wget_wch(stdscr, &ch) == ERR)
#else
    if ((ch = getch()) == ERR)
#endif
        return;

    if (ch == T_KEY_NEXT || ch == T_KEY_PREV) {
        set_next_window((int) ch);
    } else {
        pthread_mutex_lock(&Winthread.lock);
        a->onKey(a, m, ch);
        pthread_mutex_unlock(&Winthread.lock);
    }
}
Esempio n. 4
0
int main(int argc, char* argv[]) {
  int ch;
  int i = 0;
  int f_flag = 0;
  char *filename = "data";
  ToxWindow* a;

    for(i = 0; i < argc; i++) {
        if(argv[i][0] == '-') {
            if(argv[i][1] == 'f') {
                if(argv[i + 1] != NULL)
                    filename = argv[i + 1];
                else {
                    f_flag = -1;
                }
            }
        }
    }

  init_term();
  init_tox();
  load_data(filename);
  init_windows();

  if(f_flag == -1) {
    attron(COLOR_PAIR(3) | A_BOLD);
    wprintw(prompt->window, "You passed '-f' without giving an argument!\n"
                            "defaulting to 'data' for a keyfile...\n");
    attroff(COLOR_PAIR(3) | A_BOLD);
  }
    

  while(true) {
    // Update tox.
    do_tox();

    // Draw.
    a = &windows[w_active];
    prepare_window(a->window);
    a->blink = false;
    draw_bar();
    a->onDraw(a);

    // Handle input.
    ch = getch();
    if(ch == '\t') {
      w_active = (w_active + 1) % w_num;
    }
    else if(ch == KEY_BTAB) {
      w_active = (w_active + w_num - 1) % w_num;
    }
    else if(ch != ERR) {
      a->onKey(a, ch);
    }

  }

  return 0;
}
Esempio n. 5
0
int main(int argc, char *argv[])
{
  int ch;
  int f_flag = 0;
  char *filename = "data";
  ToxWindow* a;

  int i = 0;
  for (i = 0; i < argc; ++i) {
    if (argv[i] == NULL)
      break;
    else if (argv[i][0] == '-') {
      if (argv[i][1] == 'f') {
        if (argv[i + 1] != NULL)
          filename = argv[i + 1];
        else
          f_flag = -1;
      }
    }
  }

  init_term();
  init_tox();
  load_data(filename);
  init_windows();
  init_window_status();

  if (f_flag == -1) {
    attron(COLOR_PAIR(3) | A_BOLD);
    wprintw(prompt->window, "You passed '-f' without giving an argument!\n"
                            "defaulting to 'data' for a keyfile...\n");
    attroff(COLOR_PAIR(3) | A_BOLD);
  }
  
  while(true) {
    /* Update tox */
    do_tox();

    /* Draw */
    a = &windows[active_window];
    prepare_window(a->window);
    a->blink = false;
    draw_bar();
    a->onDraw(a);

    /* Handle input */
    ch = getch();
    if (ch == '\t' || ch == KEY_BTAB)
      set_active_window(ch);
    else if (ch != ERR)
      a->onKey(a, ch);
  }
  return 0;
}
Esempio n. 6
0
void draw_active_window(Messenger * m)
{

    ToxWindow *a = &windows[active_window];
    prepare_window(a->window);
    a->blink = false;
    draw_bar();
    a->onDraw(a);

    /* Handle input */
    int ch = getch();
    if (ch == '\t' || ch == KEY_BTAB)
        set_active_window(ch);
    else if (ch != ERR)
        a->onKey(a, m, ch);
}
Esempio n. 7
0
void draw_active_window(Tox *m)
{
    ToxWindow *a = active_window;
    a->alert = WINDOW_ALERT_NONE;

    wint_t ch = 0;

    draw_bar();

    touchwin(a->window);
    a->onDraw(a, m);

    /* Handle input */
    bool ltr;
#ifdef HAVE_WIDECHAR
    int status = wget_wch(stdscr, &ch);

    if (status == ERR)
        return;

    if (status == OK)
        ltr = iswprint(ch);
    else /* if (status == KEY_CODE_YES) */
        ltr = false;

#else
    ch = getch();

    if (ch == ERR)
        return;

    /* TODO verify if this works */
    ltr = isprint(ch);
#endif /* HAVE_WIDECHAR */

    if (!ltr && (ch == user_settings_->key_next_tab || ch == user_settings_->key_prev_tab)) {
        set_next_window((int) ch);
    } else {
        pthread_mutex_lock(&Winthread.lock);
        a->onKey(a, m, ch, ltr);
        pthread_mutex_unlock(&Winthread.lock);
    }
}
Esempio n. 8
0
int main(int argc, char* argv[]) {
  int ch;
  ToxWindow* a;

  init_term();
  init_tox();
  load_data();
  init_windows();

  while(true) {
    // Update tox.
    do_tox();

    // Draw.
    a = &windows[w_active];
    prepare_window(a->window);
    a->blink = false;
    draw_bar();
    a->onDraw(a);

    // Handle input.
    ch = getch();
    if(ch == '\t') {
      w_active = (w_active + 1) % w_num;
    }
    else if(ch == KEY_BTAB) {
      w_active = (w_active + w_num - 1) % w_num;
    }
    else if(ch != ERR) {
      a->onKey(a, ch);
    }

  }

  return 0;
}