示例#1
0
/*
==================
CON_Print
==================
*/
void CON_Print(const char *msg)
{
	int col;
	bool scroll = (lastline > scrollline && lastline <= scrollline + LOG_LINES);

	if (!curses_on) {
		CON_Print_tty(msg);
		return;
	}

	// Print the message in the log window
	CON_ColorPrint(logwin, msg, qtrue);
	getyx(logwin, lastline, col);
	if (col)
		lastline++;
	if (scroll) {
		scrollline = lastline - LOG_LINES;
		if (scrollline < 0)
			scrollline = 0;
		pnoutrefresh(logwin, scrollline, 0, 2, 1, LOG_LINES + 1, LOG_COLS + 1);
	}

	// Add the message to the log buffer
	if (insert + strlen(msg) >= logbuf + sizeof(logbuf)) {
		memmove(logbuf, logbuf + sizeof(logbuf) / 2, sizeof(logbuf) / 2);
		memset(logbuf + sizeof(logbuf) / 2, 0, sizeof(logbuf) / 2);
		insert -= sizeof(logbuf) / 2;
	}
	strcpy(insert, msg);
	insert += strlen(msg);

	// Update the scrollbar
	CON_DrawScrollBar();

	// Move the cursor back to the input field
	CON_UpdateCursor();
	doupdate();
}
示例#2
0
文件: STRUM2.cpp 项目: RTcmix/RTcmix
int STRUM2::run()
{
	for (int i = 0; i < framesToRun(); i++) {
		if (--_branch <= 0) {
			doupdate();
			_branch = getSkip();
		}

		float out[2];

		out[0] = _strum->next() * _amp;

		if (outputChannels() == 2) {
			out[1] = out[0] * (1.0f - _pan);
			out[0] *= _pan;
		}

		rtaddout(out);
		increment();
	}

	return framesToRun();
}
示例#3
0
文件: NCUI.cpp 项目: ronw23/prime-osx
int
shNCursesInterface::diag (const char *format, ...)
{
    int res;
    va_list ap;

    mColor = kMagenta;
    va_start (ap, format);
    char dbgbuf[100];
    res = vsnprintf (dbgbuf, 100, format, ap);
    if (mWin[kDiag]) {
        wattrset (mWin[kDiag], ColorMap[kCyan]);
        waddstr (mWin[kDiag], dbgbuf);
        waddch (mWin[kDiag], '\n');
        touchwin (mWin[kDiag]);
        wnoutrefresh (mWin[kDiag]);
        doupdate ();
    }
    debug.log ("%s", dbgbuf);
    va_end (ap);
    mColor = kGray;
    return res;
}
示例#4
0
void LYrefresh( void )
{
  if ( stdscr != LYwin )
  {
    int y = -1, x = -1;
    if ( LYcols - ( LYShowScrollbar != 0 ) < x )
      x = LYcols - ( LYShowScrollbar != 0 );
    wmove( stdscr, y, x );
    wnoutrefresh( stdscr );
    pnoutrefresh( LYwin, 0, LYshiftWin, 0, 0, LYlines, LYscreenWidth( ) + -1 );
    if ( my_subwindow )
    {
      wtouchln( my_subwindow, 0, -1, 1 );
      wnoutrefresh( my_subwindow );
    }
    doupdate( );
  }
  else
  {
    wrefresh( stdscr );
  }
  return;
}
示例#5
0
int PAN :: run()
{
   const int samps = framesToRun() * inputChannels();

   rtgetin(in, this, samps);

   for (int i = 0; i < samps; i += inputChannels()) {
      if (--branch <= 0) {
         doupdate();
         branch = skip;
      }
      float insig = in[i + inchan] * amp;

      float out[2];
      out[0] = insig * pan[0];
      out[1] = insig * pan[1];

      rtaddout(out);
      increment();
   }

   return framesToRun();
}
示例#6
0
void showmenu(struct MENU *menu)
{
    struct ITEM *itemptr;	/* points to each item in turn */
    int ctr = 1;		/* counts each item */

    wattrset(menu->menuwin, BOXATTR);	/* set to bg+/b */
    colorwin(menu->menuwin);	/* color window */
    box(menu->menuwin, ACS_VLINE, ACS_HLINE);	/* draw border */

    itemptr = menu->itemlist;	/* point to start */

    wattrset(menu->menuwin, STDATTR);

    do {			/* display items */
	wmove(menu->menuwin, ctr, 1);
	showitem(menu, itemptr, NOTSELECTED);	/* show items, initially unselected */
	ctr++;
	itemptr = itemptr->next;
    } while (ctr <= menu->itemcount);

    update_panels();
    doupdate();
}
示例#7
0
void Ozette::run() {
	if (_editors.empty()) show_browser();
	timeout(100);
	do {
		if (sig_io_flag.exchange(false)) {
			_shell.poll();
		}
		int ch = fix_control_quirks(getch());
		switch (ch) {
			case Control::UpArrow: show_browser(); break;
			case Control::NewFile: new_file(); break;
			case Control::Open: open_file(); break;
			case Control::Directory: change_directory(); break;
			case Control::Help: show_help(); break;
			case Control::Execute: execute(); break;
			case KEY_F(4): search(); break;
			case KEY_F(5): build(); break;
			default: _done |= !_shell.process(ch);
		}
		update_panels();
		doupdate();
	} while (!_done);
}
示例#8
0
文件: loop.c 项目: linehan/barnacle
/*
 * render_cb 
 *
 * Called by the rendering loop, which is the tightest of the event loops. 
 * It writes any modified state to the screen, and tries not to calculate much
 * itself, since it has to return quickly.
 * Repeat: .02 seconds
 */
void render_cb(EV_P_ ev_timer *w, int revents)
{
        spin_render_loop();

        if (game_is_paused)
                pause_loop();

        tick();

        free_nouns();
        update_nouns();

        dock_update();

        print_dock();
        update_map_control();
        update_panels();  /* Were slowing down performance, unnecessary */
        doupdate();
        MAPBOOK->restack(ACTIVE);
        map_refresh(ACTIVE);

        ev_timer_again(EV_DEFAULT, w);
}
示例#9
0
文件: readline.c 项目: uhlin/swirc
/**
 * Recreate the 2 readline panels with respect to the screen size.
 *
 * @param rows Size of the screen in rows
 * @param cols Size of the screen in cols
 * @return Void
 */
void
readline_recreate(int rows, int cols)
{
    struct term_window_size newsize = {
	.rows      = 1,
	.cols      = cols,
	.start_row = rows - 1,
	.start_col = 0,
    };

    readline_pan1 = term_resize_panel(readline_pan1, &newsize);
    readline_pan2 = term_resize_panel(readline_pan2, &newsize);

    apply_readline_options(panel_window(readline_pan1));
    apply_readline_options(panel_window(readline_pan2));
}

/**
 * Puts the currently active readline panel on the top of all panels
 * in the stack.
 */
void
readline_top_panel(void)
{
    if (panel_state == PANEL1_ACTIVE) {
	if (readline_pan1)
	    (void) top_panel(readline_pan1);
    } else if (panel_state == PANEL2_ACTIVE) {
	if (readline_pan2)
	    (void) top_panel(readline_pan2);
    } else {
	sw_assert_not_reached();
    }

    update_panels();
    (void) doupdate();
}
示例#10
0
文件: kcterm.c 项目: danielkitta/kcio
static void
input_loop(int portfd)
{
  if (portfd >= FD_SETSIZE)
  {
    destroy_screen();
    fputs("File descriptor too large\n", stderr);
    exit(1);
  }

  for (;;)
  {
    fd_set fds;

    FD_ZERO(&fds);
    FD_SET(STDIN_FILENO, &fds);
    FD_SET(portfd, &fds);

    int rc = select(portfd + 1, &fds, 0, 0, 0);
    if (rc <= 0)
    {
      if (rc < 0 && errno != EINTR)
        exit_error("select", errno);
      continue;
    }

    if (FD_ISSET(portfd, &fds))
      receive_kctext(portfd, win_output);

    if (FD_ISSET(STDIN_FILENO, &fds)
        && handle_key_input(portfd, win_input))
      break;

    wnoutrefresh(win_input);
    doupdate();
  }
}
示例#11
0
/******************************************************\
 * Description:	Creates a "window popup" where given  *
 * 		the parameters, and message, it       *
 * 		creates a window and displays the     *
 * 		message.  Some current restrictions   *
 * 		are that it must only be one line, and*
 * 		it is assumed that the text is padded *
 * 		with one space left for the border and*
 * 		another space left for aesthetics     *
\******************************************************/
void popupWin(char *msg, int time)
{
    WINDOW *tmpwin;

    int y = (LINES / 2) - 3,				/* calc location      */
        len = strlen(msg),
        x = (COLS - len)/2;

    y = (y < 2) ? 2 : y;				/* minimum height     */
    time = (!time) ? 2 : time;

    tmpwin = drawbox(y, x, 5, len + 6);			/* create window      */

    keypad(tmpwin, TRUE);

    mvwprintw(tmpwin,2,3, msg);				/* output mesg        */
    wmove(tmpwin,2,len+4);
    wrefresh(tmpwin);

    if (time == -1)
        wgetch(tmpwin);
    else
        sleep(time);					/* wait               */

    delwin(tmpwin);

    wtouchln(windows->hex, y - 1, 5, 1);		/* touch windows      */
    wtouchln(windows->ascii, y - 1, 5, 1);
    wtouchln(windows->address, y - 1, 5, 1);
    wtouchln(windows->hex_outline, y, 5, 1);
    wtouchln(windows->ascii_outline, y, 5, 1);
    wtouchln(windows->scrollbar, y, 5, 1);

    refreshall(windows);				/* refresh all wins   */

    doupdate();
}
示例#12
0
void addfield(struct FIELDLIST *list, unsigned int len,
              unsigned int y, unsigned int x, char *initstr)
{
    struct FIELD *newfield;
    int i;

    newfield = malloc(sizeof(struct FIELD));

    if (list->list == NULL) {
        list->list = newfield;
        newfield->prevfield = newfield;
        newfield->nextfield = newfield;
    } else {
        newfield->prevfield = list->list->prevfield;
        list->list->prevfield->nextfield = newfield;
        list->list->prevfield = newfield;
        newfield->nextfield = list->list;
    }

    newfield->xpos = x;
    newfield->ypos = y;
    newfield->len = len;
    newfield->tlen = strlen(initstr);
    newfield->buf = malloc(len + 1);
    strcpy(newfield->buf, initstr);

    wattrset(list->fieldwin, FIELDATTR);
    wmove(list->fieldwin, y, x);
    for (i = 1; i <= (signed)len; i++)
        wprintw(list->fieldwin, " ");

    wmove(list->fieldwin, y, x);
    wprintw(list->fieldwin, "%s", initstr);

    update_panels();
    doupdate();
}
示例#13
0
void destroymenu(struct MENU *menu)
{
    struct ITEM *tnode;
    struct ITEM *tnextnode;

    if (menu->itemlist != NULL) {
	tnode = menu->itemlist;
	tnextnode = menu->itemlist->next;

	tnode->prev->next = NULL;

	while (tnode != NULL) {
	    free(tnode);
	    tnode = tnextnode;

	    if (tnextnode != NULL)
		tnextnode = tnextnode->next;
	}
    }
    del_panel(menu->menupanel);
    delwin(menu->menuwin);
    update_panels();
    doupdate();
}
示例#14
0
int main()
{
	WINDOW *my_wins[3];
	PANEL  *my_panels[3];
	int lines = 15, cols = 45, y = 2, x = 4, i;

	initscr();
	cbreak();
	noecho();

	/* Create windows for the panels */
	my_wins[0] = newwin(lines, cols, y, x);
	my_wins[1] = newwin(lines, cols, y + 1, x + 5);
	my_wins[2] = newwin(lines, cols, y + 2, x + 10);

	/* 
	 * Create borders around the windows so that you can see the effect
	 * of panels
	 */
	for(i = 0; i < 3; ++i)
		box(my_wins[i], 0, 0);

	/* Attach a panel to each window */ 	/* Order is bottom up */
	my_panels[0] = new_panel(my_wins[0]); 	/* Push 0, order: stdscr-0 */
	my_panels[1] = new_panel(my_wins[1]); 	/* Push 1, order: stdscr-0-1 */
	my_panels[2] = new_panel(my_wins[2]); 	/* Push 2, order: stdscr-0-1-2 */

	/* Update the stacking order. 2nd panel will be on top */
	update_panels();

	/* Show it on the screen */
	doupdate();
	
	getch();
	endwin();
}
int MSHAKERS :: run()
{
	int   i;
	float out[2];

	for (i = 0; i < framesToRun(); i++) {
		if (--branch <= 0) {
			doupdate();
			branch = getSkip();
		}

		out[0] = theShake->tick() * aamp;

		if (outputChannels() == 2) {
			out[1] = out[0] * (1.0 - pctleft);
			out[0] *= pctleft;
		}

		rtaddout(out);
		increment();
	}

	return framesToRun();
}
示例#16
0
/**
 * Main game loop.
 */
static void loop(void)
{
    extern nyancat_t nc;
    gametime_t time;
    int key_ready = 0, ch;

    /* switch to intro mode */
    gamemode_enter(mode_intro);
    gamemode_draw();

    while (gamemode_valid()) {
        /* look for the first to run event */
        time = queue_get_first_time();
        if (time) {
            /* wait for time to run the first event form queue or the first
             * keypress, wichever comes first. */
            key_ready = io_wait_for_key(time);
        } else {
            /* no event queue item found */
            io_wait_for_key(0);
            key_ready = 1;
        }
        if (key_ready > 0) {
            ch = getch();
            /* no redraw call explicite because this should be done bey the
             * key handlers called functions */
            gamemode_key(ch);
        } else {
            /* TODO find a better way for prevening hight cpu usage here. But
             * for now insert a sleep for the minimum ticks used in game */
            usleep(SECOND * TICK(0.1));
            queue_run_until(time);
        }
        doupdate();
    }
}
示例#17
0
文件: view.c 项目: bytbox/iv
void view_flush() {
    /* fill the screen with blanks */
    int x,y;
    for(y=0;y<getmaxy(stdscr);y++)
        for(x=0;x<getmaxx(stdscr);x++)
            mvaddch(y,x,' '); /* empty the screen */
    attron(A_BOLD);
    for(y=0;y<getmaxy(stdscr)-1;y++)
        mvaddch(y,0,'~'); /* display blank lines */
    attroff(A_BOLD);
    /* display the message at the bottom of the screen */
    mvaddstr(getmaxy(stdscr)-1,0,displayed_message());
    if(view_layout.hsplit) {
        /* paint a line down the center */
        attrset(A_REVERSE);
        for(y=0;y<getmaxy(stdscr)-1;y++)
            mvaddch(y,view_layout.v1size,'|');
        attrset(A_NORMAL);
        /* display a bottom row with info */
        
        /* buffer 1 info */

        /* buffer 2 info */
    } else if(view_layout.vsplit) {
        /* display a line through the middle */
        attrset(A_REVERSE);

        attrset(A_NORMAL);
    } else {
        /* just draaw the view */
        draw_view(view_layout.active,0,0,getmaxy(stdscr)-1,getmaxx(stdscr));
    }
    /* update and refresh the screen (curses stuff) */
    doupdate();
    refresh();
}
示例#18
0
文件: ex_cmd.c 项目: jollywho/nav
static void ex_draw()
{
  log_msg("EXCMD", "ex_draw");
  werase(ex.nc_win);

  if (ex.ex_state == EX_CMD_STATE)
    menu_draw(ex.menu);

  pos_T max = layout_size();
  wchar_t *wline = str2wide(ex.line);
  int len = 2 + wcswidth(wline, -1);
  int offset = MAX(len - (max.col - 1), 0);

  mvwaddch(ex.nc_win, 0, 0, ex.state_symbol);
  mvwaddwstr(ex.nc_win, 0, 1, &wline[offset]);
  mvwchgat(ex.nc_win, 0, 0, 1, A_NORMAL, ex.col_symb, NULL);
  mvwchgat(ex.nc_win, 0, 1, -1, A_NORMAL, ex.col_text, NULL);

  doupdate();
  curs_set(1);
  wmove(ex.nc_win, 0, (ex.curpos + 1) - offset);
  wnoutrefresh(ex.nc_win);
  free(wline);
}
/* Returns a character read from stdin with appropriate interpretation */
int get_event (Gpm_Event *event, int redo_event, int block)
{
    int c;
    static int flag;			/* Return value from select */
    static int dirty = 3;

    if ((dirty == 1) || is_idle ()){
	refresh ();
	doupdate ();
	dirty = 1;
    } else
	dirty++;

    vfs_timeout_handler ();
    
    c = block ? getch_with_delay () : get_key_code (1);

    if (!c) {
        /* Code is 0, so this is a Control key or mouse event */
        return EV_NONE; /* FIXME: mouse not supported */
    }

    return c;
}
示例#20
0
int MBANDEDWG :: run()
{
	int   i;
	float out[2];

	for (i = 0; i < framesToRun(); i++) {
		if (--branch <= 0) {
			doupdate();
			branch = getSkip();
		}

		out[0] = theBar->tick(velocity) * amp;

		if (outputChannels() == 2) {
			out[1] = out[0] * (1.0 - pctleft);
			out[0] *= pctleft;
		}

		rtaddout(out);
		increment();
	}

	return framesToRun();
}
示例#21
0
文件: readline.c 项目: uhlin/swirc
/**
 * Key left
 */
static void
case_key_left(volatile struct readline_session_context *ctx)
{
    struct current_cursor_pos yx;

    if (ctx->bufpos == 0) {
	term_beep();
	return;
    }

    if (loLim_isset(ctx->act, ctx->prompt_size)) {
	magic_swap_panels(ctx, false);
    }

    ctx->bufpos--;
    yx = term_get_pos(ctx->act);

    if (wmove(ctx->act, yx.cury, yx.curx - 1) == ERR) {
	readline_error(EPERM, "wmove");
    }

    update_panels();
    (void) doupdate();
}
示例#22
0
文件: readline.c 项目: uhlin/swirc
/**
 * Key right
 */
static void
case_key_right(volatile struct readline_session_context *ctx)
{
    struct current_cursor_pos yx;

    if (!ctx->insert_mode) {
	term_beep();
	return;
    }

    if (hiLim_isset(ctx->act)) {
	magic_swap_panels(ctx, true);
    }

    ctx->bufpos++;
    yx = term_get_pos(ctx->act);

    if (wmove(ctx->act, yx.cury, yx.curx + 1) == ERR) {
	readline_error(EPERM, "wmove");
    }

    update_panels();
    (void) doupdate();
}
示例#23
0
int
flushinp(void)
{
#ifdef	DEBUG
	if (outf)
		fprintf(outf, "flushinp(), file %x, SP %x\n",
		    cur_term->Filedes, SP);
#endif	/* DEBUG */

#ifdef	SYSV
	(void) ioctl(cur_term -> Filedes, TCFLSH, 0);
#else	/* SYSV */
	/* for insurance against someone using their own buffer: */
	(void) ioctl(cur_term -> Filedes, TIOCGETP, &(PROGTTY));

	/*
	 * SETP waits on output and flushes input as side effect.
	 * Really want an ioctl like TCFLSH but Berkeley doesn't have one.
	 */
	(void) ioctl(cur_term -> Filedes, TIOCSETP, &(PROGTTY));
#endif	/* SYSV */

	/*
	 * Get rid of any typeahead which was read().
	 * Leave characters which were ungetch()'d.
	 */
	cur_term->_chars_on_queue = cur_term->_ungotten;

	/*
	 * Have to doupdate() because, if we have stopped output due to
	 * typeahead, now that typeahead is gone, so we had better catch up.
	 */
	if (_INPUTPENDING)
		(void) doupdate();
	return (OK);
}
示例#24
0
文件: PINK.cpp 项目: RTcmix/RTcmix
int PINK::run()
{
	for (int i = 0; i < framesToRun(); i++) {
		if (--_branch <= 0) {
			doupdate();
			_branch = getSkip();
		}

		/*
			This is an approximation to a -10dB/decade filter using a weighted sum 
			of first order filters. It is accurate to within +/-0.05dB above 9.2Hz 
			(44100Hz sampling rate). Unity gain is at Nyquist, but can be adjusted 
			by scaling the numbers at the end of each line.  -Paul Kellet
		*/
		const double white = rrand() * _amp;
		_b0 = _b0 * 0.99886 + white * 0.0555179;
		_b1 = _b1 * 0.99332 + white * 0.0750759;
		_b2 = _b2 * 0.96900 + white * 0.1538520;
		_b3 = _b3 * 0.86650 + white * 0.3104856;
		_b4 = _b4 * 0.55000 + white * 0.5329522;
		_b5 = _b5 * -0.7616 - white * 0.0168980;
		double pink = _b0 + _b1 + _b2 + _b3 + _b4 + _b5 + _b6 + white * 0.5362;
		_b6 = white * 0.115926;

		float out[2];
		out[0] = pink * 0.15;

		if (outputChannels() == 2) {
			out[1] = out[0] * (1.0 - _pan);
			out[0] *= _pan;
		}
		rtaddout(out);
		increment();
	}
	return framesToRun();
}
示例#25
0
文件: readline.c 项目: uhlin/swirc
/**
 * Handles what happens if the delete key is pressed.
 */
static void
case_key_dc(volatile struct readline_session_context *ctx)
{
    wchar_t	*ptr;
    const int	 this_index = ctx->bufpos + 1;

    if (!ctx->insert_mode) {
	term_beep();
	return;
    }

    ptr = &ctx->buffer[this_index];
    (void) wmemmove(ptr - 1, ptr, wcslen(ptr));
    ctx->buffer[--ctx->n_insert] = 0L;

    if (wdelch(ctx->act) == ERR || wclrtoeol(ctx->act) == ERR) {
	readline_error(EPERM, "wdelch or wclrtoeol");
    }

    readline_winsnstr(ctx->act, &ctx->buffer[ctx->bufpos], -1);

    update_panels();
    (void) doupdate();
}
示例#26
0
  /**
   * For Lua instruments, the run method also performs the Lua 
   * portion of the init method. That is because the init 
   * method is called from the main RTcmix thread whereas the 
   * run method is called from the traverse thread, but Lua 
   * is not thread-safe and our Lua state management code
   * creates a separate Lua state for each thread.
   */
  virtual int run()
  {
    //advise("LUAINST::run", "Began (thread %p)...", pthread_self());
    int result = 0;
    if (state.parameters[2] != 0.0) 
      {
	state.inputSampleCount = RTBUFSAMPS * inputChannels();
	rtgetin(state.input, this, state.inputSampleCount);
      }
    lua_State *L = manageLuaState();
    LuaInstrumentClass_t &luaInstrumentClass = manageLuaInstrumentClass(L, state.name);
    if (!luaInstrumentClass.initialized) 
      {
	const char *luacode = luaCodeForInstrumentNames[state.name].c_str();
	advise("LUAINST", "Defining Lua instrument code:\n\n%0.120s\n...\n", luacode);
	result = luaL_dostring(L, luacode);
	if (result == 0)
	  {
	    char init_function[0x100];
	    std::snprintf(init_function, 0x100, "%s_init", state.name);
	    lua_getglobal(L, init_function);
	    if (!lua_isnil(L, 1))
	      {
		luaInstrumentClass.init_key = luaL_ref(L, LUA_REGISTRYINDEX);
		lua_pop(L, 1);
	      }
	    else
	      {
		exit(die("LUAINST", "Failed to register: %s.", init_function));
	      }
	    char run_function[0x100];
	    std::snprintf(run_function, 0x100, "%s_run", state.name);
	    lua_getglobal(L, run_function);
	    if (!lua_isnil(L, 1))
	      {
		luaInstrumentClass.run_key = luaL_ref(L, LUA_REGISTRYINDEX);
		lua_pop(L, 1);
	      }
	    else
	      {
		exit(die("LUAINST", "Failed to register: %s.", run_function));
	      }
	  }
	else
	  {
	    warn("LUAINST", "Failed with: %d\n", result);
	  }
	luaInstrumentClass.initialized = true;
      }
    if (!state.initialized) 
      {
	lua_rawgeti(L, LUA_REGISTRYINDEX, luaInstrumentClass.init_key);
	lua_pushlightuserdata(L, &state);
	if (lua_pcall(L, 1, 1, 0) != 0)
	  {
	    rterror("LUAINST", "Lua error in \"%s_init\": %s.\n", state.name, lua_tostring(L, -1));
	  }
	result = lua_tonumber(L, -1);
	lua_pop(L, 1);
	state.initialized = true;
      }
    state.startFrame = state.endFrame;
    long frameCount = framesToRun();
    state.endFrame += frameCount;
    doupdate();
    lua_rawgeti(L, LUA_REGISTRYINDEX, luaInstrumentClass.run_key);
    lua_pushlightuserdata(L, &state);
    if (lua_pcall(L, 1, 1, 0) != 0)
      {
	die("LUAINST", "Lua error in \"%s_run\": %s with key %p frame %i.\n", state.name, lua_tostring(L, -1), luaInstrumentClass.run_key, state.currentFrame);
	exit(-1);
      }
    result = lua_tonumber(L, -1);
    lua_pop(L, 1);
    rtbaddout(state.output, frameCount);
    increment(frameCount);
    return framesToRun();
  }
示例#27
0
WRAP_API int
wrap_doupdate(void)
{
	return doupdate();
}
示例#28
0
/*******************************************************************************
Funktion NeuesSpiel()
Uebergabe Parameter:    iSchwierigkeit, ccNickname[]
Rueckgabe:              -
Beschreibung:           Startet ein neues Spiel und initialisiert die dafuer
                        notwendigen Komponenten.
                        Verarbeitet in einer Dauerschleife die Benutzereingaben.
                        Verwaltet die Spielelemente.
*******************************************************************************/
void NeuesSpiel(int iSchwierigkeit, const char ccNickname[])
{
    WINDOW *spielfeldFenster, *infoFenster, *kommandoFenster;
    SUDOKUFELD spielfelder[ANZAHL_SPIELFELDER];
    CURSOR cursor = { CURSOR_START_POSITION_SPALTE, CURSOR_START_POSITION_ZEILE,
                      CURSOR_START_ZEILE, CURSOR_START_SPALTE };
    time_t Startzeit;
    int iGedrueckteTaste = -1, iAnzahlHilfeGenutzt = 0;
    int iSpielGeloest = FALSE;
    char cZeit[9];
    timeout(33);

    // Erstellen der einzelnen Fenster
    spielfeldFenster = ErstelleNeuesSpielfeldFenster();
    infoFenster = ErstelleNeuesInfoFenster();
    kommandoFenster = ErstelleNeuesKommandoFenster();

    // Initialisierung vom Cursor sowie die Befuellung der Spielfelder
    InitialisiereCursor(&cursor);
    BefuelleSpielfelder(spielfelder, iSchwierigkeit);

    // Zeichnen der einzelnen Fenster
    ZeichneSpielfeld(spielfeldFenster);
    ZeichneSpielfelder(spielfeldFenster, spielfelder);
    ZeichneInfo(infoFenster);
    ZeichneKommandos(kommandoFenster);

    // Holen der Startzeit
    time(&Startzeit);

    // Loesungsanzeige oder ein geloestes Spiel als Abbruchbedingung
    while(!iSpielGeloest
          && (iGedrueckteTaste != 'L' && iGedrueckteTaste != 'l'))
    {
        // Entgegennehmen und verarbeiten der gedrueckten Tasten
        iGedrueckteTaste = VerarbeiteEingabe(spielfelder, &cursor,
                                             &iAnzahlHilfeGenutzt);

        ZeichneVerstricheneZeit(infoFenster, Startzeit, iAnzahlHilfeGenutzt);
        ZeichneAnzahlGenutzterHilfe(infoFenster, iAnzahlHilfeGenutzt);

        doupdate(); // Zeichne alles auf einmal neu

        // Ueberpruefung, ob das Sudoku komplett ausgefuellt ist
        if(AlleFelderGefuellt(spielfelder))
        {
            /* Ueberpruefung, ob das ausgefuellte Sudoku mit der Loesung
               uebereinstimmt */
            if(FelderKorrektAusgefuellt(spielfelder))
            {
                // Endzeit berechnen
                BerechneVerstricheneZeit(cZeit, Startzeit, iAnzahlHilfeGenutzt);

                SpielGewonnenMenue(cZeit);

                // Nur wenn eingeloggter Benutzer
                if(strlen(ccNickname) > 0)
                {
                    InBestenlisteEintragenDialog(iSchwierigkeit,
                                                 ccNickname, cZeit);
                }

                iSpielGeloest = TRUE;
            }
            else
            {
                /* Hinweis, dass sich ein Fehler im 
                   ausgefuellten Sudoku befindet */
                mvwprintw(kommandoFenster, 5, 0, "Im Sudoku befindet");
                mvwprintw(kommandoFenster, 6, 0, "sich ein Fehler!");
                wnoutrefresh(kommandoFenster);
            }
        }
    }

    timeout(-1); // Timeout deaktivieren

    // Zeichne die Loesung nur wenn das Spiel nicht vom Benutzer geloest wurde
    if(!iSpielGeloest)
    {
        ZeichneLoesung(spielfeldFenster, spielfelder);
    }

    // Schließen der zuvor erstellten Fenster
    delwin(infoFenster);
    delwin(spielfeldFenster);
    delwin(kommandoFenster);

    clear(); // Bildschirm leeren
}
int main()
{
	WINDOW *new_window_ptr;
	WINDOW *popup_window_ptr;
	int x_loop;
	int y_loop;
	char a_letter = 'a';

	initscr();

	move(5,5);
	printw("%s", "Testing multiple windows");
	refresh();
	for (y_loop = 0; y_loop < LINES - 1; y_loop++) {
		for (x_loop = 0; x_loop < COLS - 1; x_loop++) {

			mvwaddch(stdscr, y_loop, x_loop, a_letter);
			a_letter++;
			if (a_letter > 'z')
				a_letter = 'a';
		}
	}
	refresh();
	sleep(2);

	new_window_ptr = newwin(10, 20, 5, 5);
	mvwprintw(new_window_ptr, 2, 2, "%s", "Hello World");
	mvwprintw(new_window_ptr, 5, 2, "%s",
			"Notice how very long lines wrap inside the window");
	wrefresh(new_window_ptr);
	sleep(2);

	a_letter = '0';
	for (y_loop = 0; y_loop < LINES - 1; y_loop++) {
		for (x_loop = 0; x_loop < COLS - 1; x_loop++) {
			mvwaddch(stdscr, y_loop, x_loop, a_letter);
			a_letter++;
			if (a_letter > '9')
				a_letter = '0';
		}
	}
	wnoutrefresh(stdscr);
	doupdate();
	sleep(2);
	
	//however it will not change, you cannot see this window
	wnoutrefresh(new_window_ptr);
	doupdate();
	sleep(2);

	//touch means repainting when wrefresh. you will see the window.
	touchwin(new_window_ptr);
	wrefresh(new_window_ptr);
	sleep(2);

	popup_window_ptr = newwin(10, 20, 8, 8);
	box(popup_window_ptr, '|', '-');
	mvwprintw(popup_window_ptr, 5, 2, "%s", "Pop Up window!");
	wrefresh(popup_window_ptr);
	sleep(2);

	touchwin(new_window_ptr);
	wrefresh(new_window_ptr);
	sleep(2);
	wclear(new_window_ptr);
	wrefresh(new_window_ptr);
	sleep(2);
	delwin(new_window_ptr);
	touchwin(popup_window_ptr);
	wrefresh(popup_window_ptr);
	sleep(2);
	delwin(popup_window_ptr);
	touchwin(stdscr);
	refresh();
	sleep(2);

	endwin();
	exit(EXIT_SUCCESS);


	//when you want to see the window.
	//do add touchwin before you wrefresh
}
示例#30
0
文件: ndhelp.c 项目: Orc/ndialog
/*
 * _nd_help() displays helpfiles
 */
void
_nd_help(char *document)
{
    STRING(Page) pages;
    Page *cur, *up = 0;
    int rc;
    void *help, *chain;
    char *topic;		/* help topic title, for putting on the
				 * help box titlebar*/

    if (document == 0)
	return;

    CREATE(pages);

    cur = &EXPAND(pages);
    
    cur->cursor = 0;
    cur->file = helpfile(document, root);

    do {
	help = newHelp(0, 0, (COLS*3)/4, LINES-10,
		       cur->file, (pfo)ndhcallback, 0);

	/*setObjTitle(help, cur->file);*/

	if (cur->cursor)
	    setHelpCursor(help, cur->cursor);

	chain = ObjChain(help, newCancelButton(0,"Done", 0, 0));

	rc = MENU(chain, -1, -1, getHelpTopic(help), 0, 0);

	if (rc == MENU_OK) {
	    if (( topic = currentHtmlTag(help) )) {
		cur->cursor = getHelpCursor(help);

		up = cur;
		cur = &EXPAND(pages);
		cur->cursor = 0;
		cur->file = helpfile(topic, up ? up->file : root);
	    }
	}
	else if (rc == MENU_ESCAPE) {
	    free(cur->file);
	    S(pages)--;
	    up = (S(pages) > 1) ? &T(pages)[S(pages)-2]:0;
	    cur = &T(pages)[S(pages)-1];
	}
	else if (rc == MENU_CANCEL) {
	    int i;
	    for (i = 0; i < S(pages); i++)
		free(T(pages)[i].file);
	}
	deleteObjChain(chain);
    } while ( S(pages) > 0 );
    DELETE(pages);
#if HAVE_DOUPDATE
    doupdate();
#else
    refresh();
#endif
} /* _nd_help */