示例#1
0
文件: windows.c 项目: rayslava/toxic
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);
}
示例#2
0
文件: windows.c 项目: Jman012/toxic
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);
}
示例#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);
    }
}
示例#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;
}
示例#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;
}
示例#6
0
文件: windows.c 项目: Jman012/toxic
int add_window(Tox *m, ToxWindow w)
{
    if (LINES < 2)
        return -1;

    int i;

    for (i = 0; i < MAX_WINDOWS_NUM; i++) {
        if (windows[i].active)
            continue;

        w.window = newwin(LINES - 2, COLS, 0, 0);

        if (w.window == NULL)
            return -1;
#ifdef URXVT_FIX
        /* Fixes text color problem on some terminals. */
        wbkgd(w.window, COLOR_PAIR(6));
#endif
        windows[i] = w;
        w.onInit(&w, m);

        ++num_active_windows;

        return i;
    }

    return -1;
}
示例#7
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);
}
示例#8
0
文件: windows.c 项目: dbruenig/toxic
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);
    }
}
示例#9
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;
}
示例#10
0
int add_window(ToxWindow w, int n)
{
  if (w_num >= TOXWINDOWS_MAX_NUM)
    return -1;

  if (LINES < 2)
    return -1;

  w.window = newwin(LINES - 2, COLS, 0, 0);
  if (w.window == NULL)
    return -1;

  windows[n] = w;
  w.onInit(&w);
  w_num++;
  return n;
}
示例#11
0
int add_window(ToxWindow w) {
  if(w_num == TOXWINDOWS_MAX_NUM)
    return -1;

  if(LINES < 2)
    return -1;

  w.window = newwin(LINES - 2, COLS, 0, 0);

  if(w.window == NULL)
    return -1;

  windows[w_num++] = w;
  w.onInit(&w);

  return w_num - 1;
}