Exemplo n.º 1
0
Arquivo: draw.c Projeto: sirpengi/rirc
void
redraw(void)
{
	if (draw & D_CHAT)   draw_chat();
	if (draw & D_CHANS)  draw_chans();
	if (draw & D_INPUT)  draw_input();
	if (draw & D_STATUS) draw_status();
	draw = 0;
}
Exemplo n.º 2
0
void
redraw(channel *c)
{
	if (!draw) return;

	if (draw & D_RESIZE) resize();

	if (draw & D_BUFFER) draw_buffer(c);
	if (draw & D_CHANS)  draw_chans(c);
	if (draw & D_INPUT)  draw_input(c);
	if (draw & D_STATUS) draw_status(c);

	draw = 0;

	fflush(stdout);
}
Exemplo n.º 3
0
void
redraw(channel *c)
{
	if (!draw) return;

	if (draw & D_RESIZE) resize();

	struct state const* st = get_state();

	//TODO: pass st to other draw functions
	if (draw & D_BUFFER) draw_buffer(c);
	if (draw & D_CHANS)  draw_nav(st);
	if (draw & D_INPUT)  draw_input(c);
	if (draw & D_STATUS) draw_status(c);

	draw = 0;

	fflush(stdout);
}
Exemplo n.º 4
0
static bool main_loop (void) {
  unsigned int app_state = 0;
  unsigned long int counter = 0;
  double s, t;

  initial_condition(n, px, py, vx, vy, m);

  s = 0.0;

  NBODY_OMP_PARALLEL
    do {
      NBODY_OMP_MASTER
	{
	  t = timer();
	}

      physics_advance(dt, n, px, py, vx, vy, m);

      NBODY_OMP_MASTER
	{
	  t = timer() - t;
	  s += t;

	  if (draw_redraw()) {
	    draw_particles(dt, n, px, py, vx, vy, m);
	    app_state = draw_input(app_state, &dt);
	  }

	  counter += 1;

	  if ((counter % 1000LU) == 0)
	    printf("%lu\n", counter);
	}
      NBODY_OMP_BARRIER
	;
    } while (! (app_state & EXIT) &&
	     ! (app_state & RESET));

  printf("%lu physics iterations over %f seconds, ratio %f\n",
  	 counter, s, counter/s);

  return app_state & RESET;
}
Exemplo n.º 5
0
int main(int argc, char **argv)
{
    int region = -1;
    const char *device = default_device;
    int opt;
    enum {
        OPT_DUMMY = CHAR_MAX,
        OPT_VERSION
    };
    static struct option long_options[] = {
        {"help", no_argument, NULL, 'h'},
        {"version", no_argument, NULL, OPT_VERSION},
        {NULL, 0, NULL, 0}
    };
    while ((opt = getopt_long(argc, argv, "d:l:h", long_options, NULL)) != -1)
        switch (opt)
        {
        case 'd':
            device = optarg;
            break;
        case 'l':
            region = dochttx_region_for_lang(optarg);
            if (region < 0) {
                errno = EINVAL;
                perror("dochttx: -l");
                exit(EXIT_FAILURE);
            }
            break;
        case 'h':
            long_usage(stdout);
            exit(EXIT_SUCCESS);
        case OPT_VERSION:
            print_version();
            exit(EXIT_SUCCESS);
        default: /* '?' */
            usage(stderr);
            exit(EXIT_FAILURE);
        }
    if (optind != argc) {
        usage(stderr);
        exit(EXIT_FAILURE);
    }

    int rc = dochttx_locale_init();
    if (rc < 0) {
        perror("dochttx: locale initialization failed");
        return EXIT_FAILURE;
    }

    if (region < 0)
        region = dochttx_region_for_locale();
    if (region < 0)
        region = dochttx_region_for_lang("en");
    assert(region >= 0);

    struct dochttx_vbi_state* vbi = dochttx_vbi_open(device, region);
    if (vbi == NULL)
        return EXIT_FAILURE;

    dochttx_ncurses_init();

    mvvline(0, 41, ACS_VLINE, 25);
    for (int y = 0; y < 25; y++)
        mvhline(y, 0, ACS_BOARD, 41);
    mvhline(25, 0, ACS_HLINE, COLS);
    mvaddch(25, 41, ACS_BTEE);

    vbi_event_handler_register(vbi->dec, VBI_EVENT_TTX_PAGE, on_event_ttx_page, NULL);

    vbi_pgno req_pgno = 0x100;
    vbi_subno req_subno = VBI_ANY_SUBNO;
    draw_looking_for(req_pgno, req_subno);
    bool req_drawn = false;

    struct input input = {
        .text = {0},
        .position = 0,
        .status = INPUT_NORMAL,
    };
    draw_input(&input);

    refresh();

    while (true) {
        struct pollfd fds[2] = {
            { .fd = STDIN_FILENO, .events = POLLIN },
            { .fd = vbi->fd, .events = POLLIN, .revents = POLLIN },
        };