Exemplo n.º 1
0
void give( SUser* user, std::vector< S3UInt32 > coins, uint32 path, uint32 flag/* = 0 */ )
{
    if ( coins.empty() )
        return;

    coins = merge_coins( coins );

    //优先通知客户端
    if ( state_not( flag, kCoinFlagQuiet ) )
    {
        PRNotifyCoin msg;
        bccopy( msg, user->ext );

        msg.coins = coins;

        msg.set_type = kObjectAdd;
        msg.path = path;

        local::write( local::access, msg );
    }

    //给予货币
    for ( std::vector< S3UInt32 >::iterator i = coins.begin();
        i != coins.end();
        ++i )
    {
        //这里使用 kCoinFlagQuiet 避免 give 下层函数重复通知用户
        give( user, *i, path, state_add( flag, kCoinFlagQuiet ) );
    }
}
Exemplo n.º 2
0
void MultiSemBase::give_any(ulen index)
 {
  if( Dev::IsIntContext() )
    give_int(index);
  else
    give(index);
 }
Exemplo n.º 3
0
double HeMoKunzelMaterial :: computeCapacityCoeff(MatResponseMode mode, GaussPoint *gp, TimeStep *atTime)
{
    //     if  (gp->giveElement()->giveNumber() == 4)
    //       double bzzz = 20;


    if ( mode == Capacity_ww ) {
        TransportMaterialStatus *status = static_cast< TransportMaterialStatus * >( this->giveStatus(gp) );
        FloatArray s;
        double h;
        double dw_dh;

        //       s = status->giveTempStateVector();
        s = status->giveTempField();
        if ( s.isEmpty() ) {
            OOFEM_ERROR("computeCapacityCoeff: undefined state vector");
        }

        h = s.at(2);
        dw_dh = this->sorptionIsothermDerivative(h);

        return dw_dh;

        // CONSTANT
        //return 10.;
    } else if ( mode == Capacity_wh ) {
        return 0.0;
    } else if ( mode == Capacity_hw ) {
        return 0.0;
    } else if ( mode == Capacity_hh ) {
        TransportMaterialStatus *status = static_cast< TransportMaterialStatus * >( this->giveStatus(gp) );
        FloatArray s;
        double h, w;
        double dHs_dT, dHw_dT;

        //s = status->giveTempStateVector();
        s = status->giveTempField();
        if ( s.isEmpty() ) {
            OOFEM_ERROR("computeCapacityCoeff: undefined state vector");
        }

        h = s.at(2);

        w = this->sorptionIsotherm(h);

        dHs_dT = cs * give('d', NULL);
        dHw_dT = cw * w;

        return ( dHs_dT + dHw_dT );

        // CONSTANT	return 1.7e6;
    } else {
        OOFEM_ERROR("Unknown MatResponseMode");
    }

    return 0.0; // to make compiler happy
}
Exemplo n.º 4
0
int main(){
	bint a, start, end, mid, temp;
	type i, j, len;
	int s[200];
	while(input(a)){
		give(a,end);
		end.len = a.len/3  + 2;
		end.dig[end.len-1] = 0;
		end.dig[end.len] = 1;
		shift(end,10);
		give(a,start);
		start.len = a.len/3 - 1;
		if(start.len<0)start.len = 0;
		start.dig[start.len] = 1;
		shift(start,10);
		shift(a,30);
		while(cmp(end,start)>=0){
			add(end,start,mid);
			move(mid);
			by(mid,mid,temp);
			by(mid,temp,temp);
			if(cmp(temp,a)<=0)add(mid,type(1), start);
			else sub(mid,type(1),end);
		}
		for(i=0;i<30;i++)div(end,10,end,j);
		j = 0, len = 0;
		give(end,temp);
		while( !(temp.dig[0]==0&&temp.len==0) ){
			j += temp.dig[0]%10;
			s[len++] = temp.dig[0]%10;
			j %= 10;
			div(temp,10,temp,i);
		}
		printf("%d ",j);
		len--;
		while(len>=10)printf("%d",s[len--]);
		printf(".");
		while(len>=0)printf("%d",s[len--]);
		printf("\n");
	}
	return 0;
}
Exemplo n.º 5
0
bool sample_giver::give(float array[], int howmany)
{ if (howmany==0) return true;
  if (howmany<0) return false;
  mgave=0;
  bool failedyet=false; // failed yet?
  for (int i=0; i<howmany; i++)
  { failedyet = failedyet || !give(array[i]); // depends on short-circuit
    if (!failedyet) mgave++;
    else array[i]=0.;
  }
  return !failedyet;
};
Exemplo n.º 6
0
   void take_loop()
    {
     ulen count=0;

     while( take_flag ) count+=take();

     while( total_take<total_give ) count+=take();

     give();

     Printf(Con,"count = #;\n",count);
    }
Exemplo n.º 7
0
//(15)
void div(bint a, bint b, bint& c, bint& d){
	type x, k;
	bint temp;
	give(a, d);
	c.len = c.dig[0] = 0;
	while( cmp(d,b)>0 ){
		k = d.len - b.len;
		if( d.dig[d.len] > b.dig[b.len] )
			x = d.dig[d.len] / (b.dig[b.len] + 1);
		else if( k )
			k--, x =  ( d.dig[d.len]*mod + d.dig[d.len-1])/(b.dig[b.len] + 1);
		else break;
		by( b, x, temp);
		shift( temp, k );
		sub(d, temp, d);
		give( x, temp );
		shift(temp, k);
		add(c, temp, c);
	}
	if(cmp(d,b)>=0) sub(d,b,d), add(c,(type)1, c); 	
}
Exemplo n.º 8
0
bool sample_giver::skip(int howmany)
{ if (howmany==0) return true;
  if (howmany<0) return false;
  mgave=0;
  bool failedyet=false;
  float dummy;
  for (int i=0; i<howmany; i++)
  { failedyet = failedyet || !give(dummy);
    if (!failedyet) mgave++;
  }
  return !failedyet;
};
Exemplo n.º 9
0
void
HydratingHeMoMaterial :: updateInternalState(const FloatArray &vec, GaussPoint *gp, TimeStep *tStep)
{
    TransportMaterialStatus *ms = static_cast< TransportMaterialStatus * >( this->giveStatus(gp) );
    FloatArray aux;
    if ( ms ) {
        ms->letTempStateVectorBe(vec);
        if ( hydration ) {
            /* OBSOLETE
             * FloatArray s = ms->giveStateVector ();
             * if (vec.isEmpty()) OOFEM_ERROR("empty new state vector");
             * aux.resize(2);
             * aux.at(1) = vec.at(1);
             * if (s.isEmpty()||(tStep->giveTime()<=0)) aux.at(2) = initialHydrationDegree; // apply initial conditions
             * else {
             *  aux.at(2) = s.at(2);
             *  if (!castAt || (tStep->giveTime()>=castAt)) aux.at(2) += hydrationModel->dksi (s.at(2), vec.at(1), tStep->giveTimeIncrement()); // compute hydration degree increment
             * }
             */
            // it is necessary to convert the passed state vector to relative humidity expected by the hydration model
            //!!! might be cleaner to choose wc / h in hydration model, but it must be defined which one is passed anyway; so relative humidity was chosen
            //!!! also, the humidity vector might be evaluated by a function (ensure 2 elements and set humidity)
            FloatArray vech = vec;
            if ( vech.giveSize() >= 2 ) {
                vech.at(2) = inverse_sorption_isotherm( vec.at(2) );           // compute relative humidity
            } else {
                vech.resize(2);
                vech.at(2) = 1.; // saturated if undefined
            }

            HydrationModelInterface :: updateInternalState(vech, gp, tStep);

            // additional file output !!!
            if ( teplotaOut && ( gp->giveNumber() == 1 ) && giveStatus(gp) ) {
                FILE *vyst = fopen("teplota.out", "a");
                computeInternalSourceVector(aux, gp, tStep, VM_Incremental);
                if ( aux.isEmpty() ) {
                    aux.resize(1);
                    aux.zero();
                }

                aux.times( 1. / give('d', gp) );
                fprintf( vyst, "Elem %.3d krok %.2d: t= %.0f, dt=%.0f, %ld. it, ksi= %.12f, T= %.8f, heat=%.8f\n", gp->giveElement()->giveNumber(), tStep->giveNumber(),
                        tStep->giveTargetTime(), tStep->giveTimeIncrement(), tStep->giveSolutionStateCounter(),
                        giveHydrationDegree(gp, tStep, VM_Total), vec.at(1), aux.at(1) * tStep->giveTimeIncrement() );
                fclose(vyst);
            }
        }
    }
}
Exemplo n.º 10
0
const char *pass(type *tmplate)
{
  static char str[80];
  char *chp;
  chp = str;

  while(*tmplate)
  {
     *chp=give(*tmplate);
     chp++;
     tmplate++;
    };
  *chp = 0 ;
  return str;
}
Exemplo n.º 11
0
double
HeMoKunzelMaterial :: perm_hh(double h, double T)
{
    // Function calculates permability water temperature-temperature (k_hh)

    double k_hh;
    double lambda, deltap, dpsat_dT, w;

    w = this->sorptionIsotherm(h);
    lambda = lambda0 * ( 1. + b * w / give('d', NULL) );
    deltap = this->computeWaterVaporPerm(T);
    dpsat_dT = computeSatVaporPressureDerivative(T);

    k_hh = lambda + hv * deltap * h * dpsat_dT;

    return ( k_hh );

    // return 2.;
}
Exemplo n.º 12
0
void
HydratingIsoHeatMaterial :: updateInternalState(const FloatArray &vec, GaussPoint *gp, TimeStep *tStep)
{
    TransportMaterialStatus *ms = static_cast< TransportMaterialStatus * >( this->giveStatus(gp) );
    FloatArray aux;
    if ( ms ) {
        ms->letTempStateVectorBe(vec);
        if ( hydration ) {
            /* OBSOLETE
             * FloatArray s = ms->giveStateVector ();
             * if (vec.isEmpty()) OOFEM_ERROR("empty new state vector");
             * aux.resize(2);
             * aux.at(1) = vec.at(1);
             * if (s.isEmpty()||(tStep->giveTime()<=0)) aux.at(2) = initialHydrationDegree; // apply initial conditions
             * else {
             *  aux.at(2) = s.at(2);
             *  if (!castAt || (tStep->giveTime()>=castAt)) aux.at(2) += hydrationModel->dksi (s.at(2), vec.at(1), tStep->giveTimeIncrement()); // compute hydration degree increment
             * }
             */
            HydrationModelInterface :: updateInternalState(vec, gp, tStep);

            // additional file output !!!
            if ( ( gp->giveNumber() == 1 ) && giveStatus(gp) ) {
                FILE *vyst = fopen("teplota.out", "a");
                computeInternalSourceVector(aux, gp, tStep, VM_Incremental);
                if ( aux.isEmpty() ) {
                    aux.resize(1);
                    aux.zero();
                }

                aux.times( 1. / give('d', gp, tStep) );
                fprintf( vyst, "Elem %.3d krok %.2d: t= %.0f, dt=%.0f, %ld. it, ksi= %.12f, T= %.8f, heat=%.8f\n", gp->giveElement()->giveNumber(), tStep->giveNumber(),
                        tStep->giveTargetTime(), tStep->giveTimeIncrement(), tStep->giveSolutionStateCounter(),
                        giveHydrationDegree(gp, tStep, VM_Total), vec.at(1), aux.at(1) * tStep->giveTimeIncrement() );
                fclose(vyst);
            }
        }
    }
}
Exemplo n.º 13
0
MainWindow::MainWindow(QWidget *parent) :
	QMainWindow(parent),
	ui(new Ui::MainWindow),
	logic(this),
	connectDialog(new ZeroconfConnectDialog(this)),
	ipConnectDialog(new IPConnectDialog(this))
{
	ui->setupUi(this);

	ui->centralwidget->setClientLogic(&logic);
/*
	connect(connectDialog, SIGNAL(connectedTo(QHostAddress,quint16)),
			this,		   SLOT(newServerConnection(QHostAddress,quint16)));
*/
	connect(ipConnectDialog, SIGNAL(setLocalAddress(QHostAddress)),
			&logic,			 SLOT(setLocalAddress(QHostAddress)));

	connect(ipConnectDialog, SIGNAL(connectedTo(QHostAddress,quint16)),
			this,		   SLOT(newServerConnection(QHostAddress,quint16)));



	connect(ui->centralwidget, SIGNAL(take(QString)),
			this,			   SLOT(takeNode(QString)));

	connect(ui->centralwidget, SIGNAL(give(QString)),
			this,			   SLOT(giveNode(QString)));

	connect(&logic,			   SIGNAL(serverPoolChanged()),
			ui->centralwidget, SLOT(updateServerPool()));

	connect(&logic,			   SIGNAL(localPoolChanged()),
			ui->centralwidget, SLOT(updateLocalPool()));

	connect(&logic,			   SIGNAL(sendLog(QString)),
			ui->centralwidget, SLOT(addLog(QString)));
}
Exemplo n.º 14
0
Arquivo: fdf.c Projeto: NSSX/fdfgt
int		main(int argc, char **argv)
{
	char		*line;
	int			i;
	t_struct	*mystruct;
	char		***coord;
	char		**tab;

	i = 0;
	if (error(argc) == 0)
		return (0);
	mystruct = give(mystruct);
	legend(mystruct->mlx, mystruct->win);
	tab = create_tab(argv[1], tab);
	while (tab[i])
		i++;
	coord = create_coord_tab(tab, coord, i);
	mystruct = give2(mystruct, i, tab, coord);
	mystruct->img = give_img(mystruct->mlx);
	mystruct->event = give_myevent();
	mlx_key_hook(mystruct->win, event_mlx, mystruct);
	mlx_loop(mystruct->mlx);
	return (0);
}
Exemplo n.º 15
0
/* deal with a new player command in dungeon or city mode*/
void p_process(void)
{
    static int searchval=0;

    if (Player.status[BERSERK])
        if (goberserk()) {
            setgamestatus(SKIP_PLAYER);
            drawvision(Player.x,Player.y);
        }
    if (! gamestatusp(SKIP_PLAYER)) {
        if (searchval > 0) {
            searchval--;
            if (searchval == 0) resetgamestatus(FAST_MOVE);
        }
        drawvision(Player.x,Player.y);
        if (! gamestatusp(FAST_MOVE)) {
            searchval = 0;
            Cmd = mgetc();
            clear_if_necessary();
        }
        Command_Duration = 0;
        switch (Cmd) {
        case ' ':
        case 13:
            setgamestatus(SKIP_MONSTERS);
            break; /*no op on space or return*/
        case 6:
            abortshadowform();
            break; /* ^f */
        case 7:
            wizard();
            break; /* ^g */
        case 4:
            player_dump();
            break; /* ^d */
        case 9:
            display_pack();
            morewait();
            xredraw();
            break; /* ^i */
        case 11:
            if (gamestatusp(CHEATED)) frobgamestatus();
            break;
        case 12:
            xredraw();
            setgamestatus(SKIP_MONSTERS);
            break; /* ^l */
#if !defined(WIN32)
        case 16:
            bufferprint();
            setgamestatus(SKIP_MONSTERS);
            break; /* ^p */
#else
        case 15:
            bufferprint();
            setgamestatus(SKIP_MONSTERS);
            break; /* ^o */
#endif
        case 18:
            redraw();
            setgamestatus(SKIP_MONSTERS);
            break; /* ^r */
        case 23:
            if (gamestatusp(CHEATED)) drawscreen();
            break; /* ^w */
        case 24: /* ^x */
            if (gamestatusp(CHEATED) ||
                    Player.rank[ADEPT])
                wish(1);
            Command_Duration = 5;
            break;
        case 'a':
            zapwand();
            Command_Duration = Player.speed*8/5;
            break;
        case 'c':
            closedoor();
            Command_Duration = Player.speed*2/5;
            break;
        case 'd':
            drop();
            Command_Duration = Player.speed*5/5;
            break;
        case 'e':
            eat();
            Command_Duration = 30;
            break;
        case 'f':
            fire();
            Command_Duration = Player.speed*5/5;
            break;
        case 'g':
            pickup();
            Command_Duration = Player.speed*10/5;
            break;
        case 'i':
            do_inventory_control();
            break;
        case 'm':
            magic();
            Command_Duration = 12;
            break;
        case 'o':
            opendoor();
            Command_Duration = Player.speed*5/5;
            break;
        case 'p':
            pickpocket();
            Command_Duration = Player.speed*20/5;
            break;
        case 'q':
            quaff();
            Command_Duration = 10;
            break;
        case 'r':
            peruse();
            Command_Duration = 20;
            break;
        case 's':
            search(&searchval);
            Command_Duration = 20;
            break;
        case 't':
            talk();
            Command_Duration = 10;
            break;
        case 'v':
            vault();
            Command_Duration = Player.speed*10/5;
            break;
        case 'x':
            examine();
            Command_Duration = 1;
            break;
        case 'z':
            bash_location();
            Command_Duration = Player.speed*10/5;
            break;
        case 'A':
            activate();
            Command_Duration = 10;
            break;
        case 'C':
            callitem();
            break;
        case 'D':
            disarm();
            Command_Duration = 30;
            break;
        case 'E':
            dismount_steed();
            Command_Duration = Player.speed*10/5;
            break;
        case 'F':
            tacoptions();
            break;
        case 'G':
            give();
            Command_Duration = 10;
            break;
        case 'I':
            if (! optionp(TOPINV)) top_inventory_control();
            else {
                display_possessions();
                inventory_control();
            }
            break;
        case 'M':
            city_move();
            Command_Duration = 10;
            break;
        case 'O':
            setoptions();
#if defined(WIN32)
            show_screen();
            xredraw();
#endif
            break;
        case 'P':
            show_license();
            break; /* actually show_license is in file.c */
        case 'Q':
            quit();
            break;
        case 'R':
            rename_player();
            break;
        case 'S':
            save(FALSE);
            break;
        case 'T':
            tunnel();
            Command_Duration =  Player.speed*30/5;
            break;
        case 'V':
            version();
            break;
        case 'Z':
            bash_item();
            Command_Duration = Player.speed*10/5;
            break;
        case '.':
            rest();
            Command_Duration = 10;
            break;
        case ',':
            Command_Duration = 10;
            nap();
            break;
        case '>':
            downstairs();
            break;
        case '<':
            upstairs();
            break;
        case '@':
            p_movefunction(Level->site[Player.x][Player.y].p_locf);
            Command_Duration = 5;
            break;
        case '#':
            if (gamestatusp(CHEATED)) editstats();
            break; /* RAC - char editor */
        case '/':
            charid();
            setgamestatus(SKIP_MONSTERS);
            break;
        case '?':
            help();
            setgamestatus(SKIP_MONSTERS);
            break;
        case '4':
        case 'h':
            moveplayer(-1,0);
            Command_Duration = Player.speed*5/5;
            break;
        case '2':
        case 'j':
            moveplayer(0,1);
            Command_Duration = Player.speed*5/5;
            break;
        case '8':
        case 'k':
            moveplayer(0,-1);
            Command_Duration = Player.speed*5/5;
            break;
        case '6':
        case 'l':
            moveplayer(1,0);
            Command_Duration = Player.speed*5/5;
            break;
        case '1':
        case 'b':
            moveplayer(-1,1);
            Command_Duration = Player.speed*5/5;
            break;
        case '3':
        case 'n':
            moveplayer(1,1);
            Command_Duration = Player.speed*5/5;
            break;
        case '7':
        case 'y':
            moveplayer(-1,-1);
            Command_Duration = Player.speed*5/5;
            break;
        case '9':
        case 'u':
            moveplayer(1,-1);
            Command_Duration = Player.speed*5/5;
            break;
        case '5':
            setgamestatus(SKIP_MONSTERS); /* don't do anything; a dummy turn */
            Cmd = mgetc();
            while ((Cmd != ESCAPE) &&
                    ((Cmd < '1') || (Cmd > '9') || (Cmd=='5'))) {
                print3("Run in keypad direction [ESCAPE to abort]: ");
                Cmd = mgetc();
            }
            if (Cmd != ESCAPE) 
                setgamestatus(FAST_MOVE);
            else
                clearmsg3();
            break;
        case 'H':
            setgamestatus(FAST_MOVE);
            Cmd = 'h';
            moveplayer(-1,0);
            Command_Duration = Player.speed*4/5;
            break;
        case 'J':
            setgamestatus(FAST_MOVE);
            Cmd = 'j';
            moveplayer(0,1);
            Command_Duration = Player.speed*4/5;
            break;
        case 'K':
            setgamestatus(FAST_MOVE);
            Cmd = 'k';
            moveplayer(0,-1);
            Command_Duration = Player.speed*4/5;
            break;
        case 'L':
            setgamestatus(FAST_MOVE);
            Cmd = 'l';
            moveplayer(1,0);
            Command_Duration = Player.speed*4/5;
            break;
        case 'B':
            setgamestatus(FAST_MOVE);
            Cmd = 'b';
            moveplayer(-1,1);
            Command_Duration = Player.speed*4/5;
            break;
        case 'N':
            setgamestatus(FAST_MOVE);
            Cmd = 'n';
            moveplayer(1,1);
            Command_Duration = Player.speed*4/5;
            break;
        case 'Y':
            setgamestatus(FAST_MOVE);
            Cmd = 'y';
            moveplayer(-1,-1);
            Command_Duration = Player.speed*4/5;
            break;
        case 'U':
            setgamestatus(FAST_MOVE);
            Cmd = 'u';
            moveplayer(1,-1);
            Command_Duration = Player.speed*4/5;
            break;
        default:
            commanderror();
            setgamestatus(SKIP_MONSTERS);
            break;
        }
    }
    if (Current_Environment != E_COUNTRYSIDE) roomcheck();
    screencheck(Player.x,Player.y);
}
Exemplo n.º 16
0
int main() {

    printf("Ada gave me %d\n", give());

    return 0;
}
Exemplo n.º 17
0
/**
 * @brief Give a semaphore.
 * The Semaphore is given with an associated value.
 * @param [in] value The value to associate with the semaphore.
 */
void FreeRTOS::Semaphore::give(uint32_t value) {
	m_value = value;
	give();
} // give
Exemplo n.º 18
0
 void give_loop()
  {
   for(ulen count=Rep; count ;count--) give();
  }
Exemplo n.º 19
0
   void stop()
    {
     take_flag=0;

     give();
    }
Exemplo n.º 20
0
	~fork()
	{
		if (used_)
			give();
	}
Exemplo n.º 21
0
double
IsotropicHeatTransferMaterial :: giveIsotropicConductivity(GaussPoint *gp, TimeStep *tStep) {
    return give('k', gp, tStep);
}
Exemplo n.º 22
0
/* returns 0 if error or no more commands to do,
 *         1 if there are more commands remaining on the current input line
 */
int
cypher(void)
{
	int     n;
	int     junk;
	int     lflag = -1;
	char   *filename, *rfilename;
	size_t  filename_len;

	while (wordnumber <= wordcount) {
		if (wordtype[wordnumber] != VERB &&
		    !(wordtype[wordnumber] == OBJECT &&
		    wordvalue[wordnumber] == KNIFE)) {
			printf("%s: How's that?\n",
			    (wordnumber == wordcount) ? words[wordnumber - 1] : words[wordnumber]);
			return (0);
		}

		switch (wordvalue[wordnumber]) {

		case AUXVERB:
			/* Take the following word as the verb */
			wordnumber++;
			return(cypher());
			break;

		case UP:
			if (location[position].access || wiz || tempwiz) {
				if (!location[position].access)
					puts("Zap!  A gust of wind lifts you up.");
				if (!moveplayer(location[position].up, AHEAD))
					return (0);
			} else {
				puts("There is no way up.");
				return (0);
			}
			lflag = 0;
			break;

		case DOWN:
			if (!moveplayer(location[position].down, AHEAD))
				return (0);
			lflag = 0;
			break;

		case LEFT:
			if (!moveplayer(left, LEFT))
				return (0);
			lflag = 0;
			break;

		case RIGHT:
			if (!moveplayer(right, RIGHT))
				return (0);
			lflag = 0;
			break;

		case AHEAD:
			if (!moveplayer(ahead, AHEAD))
				return (0);
			lflag = 0;
			break;

		case BACK:
			if (!moveplayer(back, BACK))
				return (0);
			lflag = 0;
			break;

		case SHOOT:
			verb_with_all(location[position].objects, OBJ_PERSON,
			    shoot, "shoot at");
			break;

		case TAKE:
			if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
				int things;
				things = 0;
				for (n = 0; n < NUMOFOBJECTS; n++)
					if (TestBit(location[position].objects, n) && objsht[n]) {
						things++;
						wordvalue[wordnumber + 1] = n;
/* Some objects (type NOUNS) have special treatment in take().  For these
 * we must set the type to NOUNS.  However for SWORD and BODY all it does
 * is find which of many objects is meant, so we need do nothing here.
 * BATHGOD must become NORMGOD as well.  NOUNS with no special case must be
 * included here to get the right error.  DOOR cannot occur as an object so
 * need not be included.
 */
						switch (n) {
						case BATHGOD:
							wordvalue[wordnumber + 1] = NORMGOD;
							/* FALLTHROUGH */
						case NORMGOD:
						case AMULET:
						case MEDALION:
						case TALISMAN:
						case MAN:
						case TIMER:
						case NATIVE:
							wordtype[wordnumber + 1] = NOUNS;
							break;
						default:
							wordtype[wordnumber + 1] = OBJECT;
						}
						wordnumber = take(location[position].objects);
						wordnumber += 2;
					}
				if (!things)
					puts("Nothing to take!");
			} else
				take(location[position].objects);
			break;

		case DROP:
			if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
				int things;
				things = 0;
				for (n = 0; n < NUMOFOBJECTS; n++)
					if (TestBit(inven, n)) {
						things++;
						wordvalue[wordnumber + 1] = n;
						wordnumber = drop("Dropped");
					}
				wordnumber++;
				wordnumber++;
				if (!things)
					puts("Nothing to drop!");
			} else
				drop("Dropped");
			break;


		case KICK:
		case THROW:
			if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
				int things, wv;
				things = 0;
				wv = wordvalue[wordnumber];
				for (n = 0; n < NUMOFOBJECTS; n++)
					if (TestBit(inven, n) ||
					  (TestBit(location[position].objects, n) && objsht[n])) {
						things++;
						wordvalue[wordnumber + 1] = n;
						wordnumber = throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
					}
				wordnumber += 2;
				if (!things)
					printf("Nothing to %s!\n", wv == KICK ? "kick" : "throw");
			} else
				throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
			break;

		case TAKEOFF:
			verb_with_all(wear, 0, takeoff, "take off");
			break;

		case DRAW:
			verb_with_all(wear, 0, draw, "draw");
			break;

		case PUTON:
			verb_with_all(location[position].objects, 0, puton, "put on");
			break;

		case WEARIT:
			verb_with_all(inven, 0, wearit, "wear");
			break;

		case EAT:
			verb_with_all(inven, 0, eat, "eat");
			break;

		case PUT:
			put();
			break;

		case INVEN:
			if (ucard(inven)) {
				puts("You are holding:\n");
				for (n = 0; n < NUMOFOBJECTS; n++)
					if (TestBit(inven, n))
						printf("\t%s\n", objsht[n]);
				printf("\n= %d kilogram%s ", carrying,
				    (carrying == 1 ?  "." : "s."));
				if (WEIGHT)
					printf("(%d%%)\n", carrying * 100 / WEIGHT);
				else
					printf("(can't lift any weight%s)\n",
					    (carrying ? " or move with what you have" : ""));
				if (CUMBER)
					printf("Your arms are %d%% full.\n",
					    encumber * 100 / CUMBER);
				else
					printf("You can't pick anything up.\n");
			} else
				puts("You aren't carrying anything.");

			if (ucard(wear)) {
				puts("\nYou are wearing:\n");
				for (n = 0; n < NUMOFOBJECTS; n++)
					if (TestBit(wear, n))
						printf("\t%s\n", objsht[n]);
			} else
				puts("\nYou are stark naked.");
			if (card(injuries, NUMOFINJURIES)) {
				puts("\nYou have suffered:\n");
				for (n = 0; n < NUMOFINJURIES; n++)
					if (injuries[n])
						printf("\t%s\n", ouch[n]);
				printf("\nYou can still carry up to %d kilogram%s\n", WEIGHT, (WEIGHT == 1 ? "." : "s."));
			} else
				puts("\nYou are in perfect health.");
			break;

		case USE:
			lflag = use();
			break;

		case OPEN:
			dooropen();
			break;

		case LOOK:
			if (!notes[CANTSEE] || TestBit(inven, LAMPON) ||
			    TestBit(location[position].objects, LAMPON)
			    || matchlight) {
				beenthere[position] = 2;
				writedes();
				printobjs();
				if (matchlight) {
					puts("\nYour match splutters out.");
					matchlight = 0;
				}
			} else
				puts("I can't see anything.");
			return (0);	/* No commands after a look */
			break;

		case SU:
			if (wiz || tempwiz) {
				getnum(&position, "\nRoom (was %d) = ", position);
				getnum(&ourtime, "Time (was %d) = ", ourtime);
				getnum(&fuel, "Fuel (was %d) = ", fuel);
				getnum(&torps, "Torps (was %d) = ", torps);
				getnum(&CUMBER, "CUMBER (was %d) = ", CUMBER);
				getnum(&WEIGHT, "WEIGHT (was %d) = ", WEIGHT);
				getnum(&ourclock, "Clock (was %d) = ", ourclock);
				if (getnum(&junk, "Wizard (was %d, %d) = ", wiz, tempwiz) != -1 && !junk)
					tempwiz = wiz = 0;
				printf("\nDONE.\n");
				return (0);	/* No commands after a SU */
			} else
				puts("You aren't a wizard.");
			break;

		case SCORE:
			printf("\tPLEASURE\tPOWER\t\tEGO\n");
			printf("\t%3d\t\t%3d\t\t%3d\n\n", pleasure, power, ego);
			printf("This gives you the rating of %s in %d turns.\n", rate(), ourtime);
			printf("You have visited %d out of %d rooms this run (%d%%).\n", card(beenthere, NUMOFROOMS), NUMOFROOMS, card(beenthere, NUMOFROOMS) * 100 / NUMOFROOMS);
			break;

		/* case KNIFE: */
		case KILL:
			murder();
			break;

		case UNDRESS:
			undress();
			break;

		case RAVAGE:
			ravage();
			break;

		case SAVE:
			printf("\nSave file name (default %s):  ",
			    DEFAULT_SAVE_FILE);
			filename = fgetln(stdin, &filename_len);
			if (filename_len == 0
			    || (filename_len == 1 && filename[0] == '\n'))
				rfilename = save_file_name(DEFAULT_SAVE_FILE,
				    strlen(DEFAULT_SAVE_FILE));
			else {
				if (filename[filename_len - 1] == '\n')
					filename_len--;
				rfilename = save_file_name(filename,
				    filename_len);
			}
			save(rfilename);
			free(rfilename);
			break;

		case VERBOSE:
			verbose = 1;
			printf("[Maximum verbosity]\n");
			break;

		case BRIEF:
			verbose = 0;
			printf("[Standard verbosity]\n");
			break;

		case FOLLOW:
			lflag = follow();
			break;

		case GIVE:
			give();
			break;

		case KISS:
			kiss();
			break;

		case LOVE:
			love();
			break;

		case RIDE:
			lflag = ride();
			break;

		case DRIVE:
			lflag = drive();
			break;

		case LIGHT:
			light();
			break;

		case LAUNCH:
			if (!launch())
				return (0);
			else
				lflag = 0;
			break;

		case LANDIT:
			if (!land())
				return (0);
			else
				lflag = 0;
			break;

		case TIME:
			chime();
			break;

		case SLEEP:
			zzz();
			break;

		case DIG:
			dig();
			break;

		case JUMP:
			lflag = jump();
			break;

		case BURY:
			bury();
			break;

		case SWIM:
			puts("Surf's up!");
			break;

		case DRINK:
			drink();
			break;

		case QUIT:
			die(0);

		default:
			puts("How's that?");
			return (0);
			break;

		}
		if (!lflag)
			newlocation();
		if (wordnumber < wordcount && !stop_cypher &&
		    (*words[wordnumber] == ',' || *words[wordnumber] == '.')) {
			wordnumber++;
			return (1);
		} else
			return (0);
	}
	return (0);
}
Exemplo n.º 23
0
int main(int argc, char* argv[])
{
    initscr();
    scrollok(stdscr, TRUE);
    wprintw(stdscr, "Welcome to Scripted ver. %d.%d for the Brave Quest engine.\nCopyright 2012 Mad Science Inc.\nPlease do not redistrubute.\n",scriptedvernum,scriptedvernum2);
    stufffilename();
    if(loadscript(filename) == 1)
    {
        wprintw(stdscr, "File not Found. Would you like to make a new file?\n");
        if(bie() == 'y')
        {
            cleanfilebuff();
            if(savescript(filename) == 1)
            {
                wprintw(stdscr, "Your disk sucks.\n");
                bi();
                return 1;
            }
        }
        else
        {
            wprintw(stdscr, "Goodbye.\n");
            endwin();
            return 1;
        }
    }
    currlinenum = linenum;
    menu();
    wprintw(stdscr, "Press escape to go to the save menu\n");
    for(;;)
    {
        wprintw(stdscr, "q= give, w= take, e= say, r= flag, t= move, y= battle, u= check flag, i= check item, o= party add, p= party remove, [ = check character\n");
        wprintw(stdscr, "a= warp, s= check experience, d= give experience, f= make experience, g= exec script, h= screen effect, j= user input, k= goline, l= make health\n");
        wprintw(stdscr, "b= check stat, n= make stat, m= blank, ,= show line, .= change line.\n");
        input[0] = bie();
        if(input[0] == 27)
            menu();
        if(input[0] == 'q')
            give();
        if(input[0] == 'w')
            take();
        if(input[0] == 'e')
            say();
        if(input[0] == 'r')
            flag();
        if(input[0] == 't')
            mmove();
        if(input[0] == 'y')
            battle();
        if(input[0] == 'u')
            checkflag();
        if(input[0] == 'i')
            checkitem();
        if(input[0] == 'o')
            partyadd();
        if(input[0] == 'p')
            partyrm();
        if(input[0] == '[')
            checkparty();
        if(input[0] == 'a')
            warp();
        if(input[0] == 's')
            checkexp();
        if(input[0] == 'd')
            giveexp();
        if(input[0] == 'f')
            makeexp();
        if(input[0] == 'g')
            execscript();
        if(input[0] == 'h')
            screeneffect();
        if(input[0] == 'j')
            userinput();
        if(input[0] == 'k')
            goline();
        if(input[0] == 'l')
            makehealth();
        if(input[0] == 'z')
            teachspell();
        if(input[0] == 'x')
            unlearnspell();
        if(input[0] == 'b')
            checkstat();
        if(input[0] == 'n')
            makestat();
        if(input[0] == 'm')
            blank();
        if(input[0] == ',')
            showline();
        if(input[0] == '.')
            changeline();
        if(currlinenum > linenum)
            linenum = currlinenum;
    }
    return 0;
};
Exemplo n.º 24
0
void feabhOS_counting_semaphore_give(feabhOS_COUNTING_SEMAPHORE * const pSemaphore)
{
  feabhOS_COUNTING_SEMAPHORE self = *pSemaphore;
  give(self->semaphore);
}
Exemplo n.º 25
0
void feabhOS_binary_semaphore_give(feabhOS_BINARY_SEMAPHORE * const pSemaphore)
{
  feabhOS_BINARY_SEMAPHORE self = *pSemaphore;
  give(self->semaphore);
}
Exemplo n.º 26
0
int
cypher(void)
{
	int n;
	int junk;
	int lflag;
	char buffer[10];

	lflag = -1;
	while (wordtype[wordnumber] == ADJS)
		wordnumber++;
	while (wordnumber <= wordcount) {
		switch (wordvalue[wordnumber]) {
		case UP:
			if (location[position].access || wiz || tempwiz) {
				if (!location[position].access)
					puts("Zap!  A gust of wind lifts you up.");
				if (!battlestar_move(location[position].up, AHEAD))
					return (-1);
			} else {
				puts("There is no way up");
				return (-1);
			}
			lflag = 0;
			break;

		case DOWN:
			if (!battlestar_move(location[position].down, AHEAD))
				return (-1);
			lflag = 0;
			break;

		case LEFT:
			if (!battlestar_move(left, LEFT))
				return (-1);
			lflag = 0;
			break;

		case RIGHT:
			if (!battlestar_move(right, RIGHT))
				return (-1);
			lflag = 0;
			break;

		case AHEAD:
			if (!battlestar_move(ahead, AHEAD))
				return (-1);
			lflag = 0;
			break;

		case BACK:
			if (!battlestar_move(back, BACK))
				return (-1);
			lflag = 0;
			break;

		case SHOOT:
			if (wordnumber < wordcount &&
			    wordvalue[wordnumber + 1] == EVERYTHING) {
				for (n = 0; n < NUMOFOBJECTS; n++)
					if (testbit(location[position].objects,
					    n) && objsht[n]) {
						wordvalue[wordnumber + 1] = n;
						wordnumber = shoot();
					}
				wordnumber++;
				wordnumber++;
			} else
				shoot();
			break;

		case TAKE:
			if (wordnumber < wordcount &&
			    wordvalue[wordnumber + 1] == EVERYTHING) {
				for (n = 0; n < NUMOFOBJECTS; n++)
					if (testbit(location[position].objects,
					    n) && objsht[n]) {
						wordvalue[wordnumber + 1] = n;
						wordnumber =
							take(location[position].objects);
					}
				wordnumber++;
				wordnumber++;
			} else
				take(location[position].objects);
			break;

		case DROP:
			if (wordnumber < wordcount &&
			    wordvalue[wordnumber + 1] == EVERYTHING) {
				for (n = 0; n < NUMOFOBJECTS; n++)
					if (testbit(inven, n)) {
						wordvalue[wordnumber + 1] = n;
						wordnumber = drop("Dropped");
					}
				wordnumber++;
				wordnumber++;
			} else
				drop("Dropped");
			break;

		case KICK:
		case THROW:
			if (wordnumber < wordcount &&
			    wordvalue[wordnumber + 1] == EVERYTHING) {
				for (n = 0; n < NUMOFOBJECTS; n++) {
					if ((testbit(inven, n) ||
					     testbit(location[position].objects, n)) && objsht[n]) {
						wordvalue[wordnumber + 1] = n;
						wordnumber = throw(wordvalue[wordnumber] ==
							KICK ? "Kicked" : "Thrown");
					}
				}
				wordnumber += 2;
			} else
				throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
			break;

		case TAKEOFF:
			if (wordnumber < wordcount &&
			    wordvalue[wordnumber + 1] == EVERYTHING) {
				for (n = 0; n < NUMOFOBJECTS; n++)
					if (testbit(wear, n)) {
						wordvalue[wordnumber + 1] = n;
						wordnumber = takeoff();
					}
				wordnumber += 2;
			} else
				takeoff();
			break;

		case DRAW:
			if (wordnumber < wordcount &&
			    wordvalue[wordnumber + 1] == EVERYTHING) {
				for (n = 0; n < NUMOFOBJECTS; n++)
					if (testbit(wear, n)) {
						wordvalue[wordnumber + 1] = n;
						wordnumber = draw();
					}
				wordnumber += 2;
			} else
				draw();
			break;

		case PUTON:
			if (wordnumber < wordcount &&
			    wordvalue[wordnumber + 1] == EVERYTHING) {
				for (n = 0; n < NUMOFOBJECTS; n++)
					if (testbit(location[position].objects,
					    n) && objsht[n]) {
						wordvalue[wordnumber + 1] = n;
						wordnumber = puton();
					}
				wordnumber += 2;
			} else
				puton();
			break;

		case WEARIT:
			if (wordnumber < wordcount &&
			    wordvalue[wordnumber + 1] == EVERYTHING) {
				for (n = 0; n < NUMOFOBJECTS; n++)
					if (testbit(inven, n)) {
						wordvalue[wordnumber + 1] = n;
						wordnumber = wearit();
					}
				wordnumber += 2;
			} else
				wearit();
			break;

		case EAT:
			if (wordnumber < wordcount &&
			    wordvalue[wordnumber + 1] == EVERYTHING) {
				for (n = 0; n < NUMOFOBJECTS; n++)
					if (testbit(inven, n)) {
						wordvalue[wordnumber + 1] = n;
						wordnumber = eat();
					}
				wordnumber += 2;
			} else
				eat();
			break;

		case PUT:
			put();
			break;

		case INVEN:
			if (ucard(inven)) {
				puts("You are holding:\n");
				for (n = 0; n < NUMOFOBJECTS; n++)
					if (testbit(inven, n))
						printf("\t%s\n", objsht[n]);
				printf("\n= %d kilogram%s (%d%%)\n", carrying,
				       (carrying == 1 ? "." : "s."),
				       (WEIGHT ? carrying * 100 / WEIGHT : -1));
				printf("Your arms are %d%% full.\n",
				       encumber * 100 / CUMBER);
			} else
				puts("You aren't carrying anything.");

			if (ucard(wear)) {
				puts("\nYou are wearing:\n");
				for (n = 0; n < NUMOFOBJECTS; n++)
					if (testbit(wear, n))
						printf("\t%s\n", objsht[n]);
			} else
				puts("\nYou are stark naked.");
			if (card(injuries, NUMOFINJURIES)) {
				puts("\nYou have suffered:\n");
				for (n = 0; n < NUMOFINJURIES; n++)
					if (injuries[n])
						printf("\t%s\n", ouch[n]);
				printf("\nYou can still carry up to %d kilogram%s\n",
				    WEIGHT, (WEIGHT == 1 ? "." : "s."));
			} else
				puts("\nYou are in perfect health.");
			break;

		case USE:
			lflag = use();
			break;

		case LOOK:
			if (!notes[CANTSEE] || testbit(inven, LAMPON) ||
			    testbit(location[position].objects, LAMPON) ||
			    matchlight) {
				beenthere[position] = 2;
				writedes();
				printobjs();
				if (matchlight) {
					puts("\nYour match splutters out.");
					matchlight = 0;
				}
			} else
				puts("I can't see anything.");
			return (-1);
			break;

		case SU:
			if (wiz || tempwiz) {
				printf("\nRoom (was %d) = ", position);
				fgets(buffer, 10, stdin);
				if (*buffer != '\n')
					sscanf(buffer, "%d", &position);
				printf("Time (was %d) = ", gtime);
				fgets(buffer, 10, stdin);
				if (*buffer != '\n')
					sscanf(buffer, "%d", &gtime);
				printf("Fuel (was %d) = ", fuel);
				fgets(buffer, 10, stdin);
				if (*buffer != '\n')
					sscanf(buffer, "%d", &fuel);
				printf("Torps (was %d) = ", torps);
				fgets(buffer, 10, stdin);
				if (*buffer != '\n')
					sscanf(buffer, "%d", &torps);
				printf("CUMBER (was %d) = ", CUMBER);
				fgets(buffer, 10, stdin);
				if (*buffer != '\n')
					sscanf(buffer, "%d", &CUMBER);
				printf("WEIGHT (was %d) = ", WEIGHT);
				fgets(buffer, 10, stdin);
				if (*buffer != '\n')
					sscanf(buffer, "%d", &WEIGHT);
				printf("Clock (was %d) = ", gclock);
				fgets(buffer, 10, stdin);
				if (*buffer != '\n')
					sscanf(buffer, "%d", &gclock);
				printf("Wizard (was %d, %d) = ", wiz, tempwiz);
				fgets(buffer, 10, stdin);
				if (*buffer != '\n') {
					sscanf(buffer, "%d", &junk);
					if (!junk)
						tempwiz = wiz = 0;
				}
				printf("\nDONE.\n");
				return (0);
			} else
				puts("You aren't a wizard.");
			break;

		case SCORE:
			printf("\tPLEASURE\tPOWER\t\tEGO\n");
			printf("\t%3d\t\t%3d\t\t%3d\n\n", pleasure, power, ego);
			printf("This gives you the rating of %s in %d turns.\n",
			    rate(), gtime);
			printf("You have visited %d out of %d rooms this run (%d%%).\n",
			    card(beenthere, NUMOFROOMS), NUMOFROOMS,
			    card(beenthere, NUMOFROOMS) * 100 / NUMOFROOMS);
			break;

		case KNIFE:
		case KILL:
			murder();
			break;

		case UNDRESS:
		case RAVAGE:
			ravage();
			break;

		case SAVE:
			save();
			break;

		case FOLLOW:
			lflag = follow();
			break;

		case GIVE:
			give();
			break;

		case KISS:
			kiss();
			break;

		case LOVE:
			love();
			break;

		case RIDE:
			lflag = ride();
			break;

		case DRIVE:
			lflag = drive();
			break;

		case LIGHT:
			light();
			break;

		case LAUNCH:
			if (!launch())
				return (-1);
			else
				lflag = 0;
			break;

		case LANDIT:
			if (!land())
				return (-1);
			else
				lflag = 0;
			break;

		case TIME:
			chime();
			break;

		case SLEEP:
			zzz();
			break;

		case DIG:
			dig();
			break;

		case JUMP:
			lflag = jump();
			break;

		case BURY:
			bury();
			break;

		case SWIM:
			puts("Surf's up!");
			break;

		case DRINK:
			drink();
			break;

		case QUIT:
			die(0);

		default:
			puts("How's that?");
			return (-1);
			break;
		}
		if (wordnumber < wordcount && *words[wordnumber++] == ',')
			continue;
		else
			return (lflag);
	}
	return (lflag);
}
Exemplo n.º 27
0
/// This method adds all factory keys to the texteditor keymap
/// This method does NOT clear the existing items.
/// @param km the command manager
void FactoryCommandMap::fill(TextEditorCommandMap* cm)
{
    give( "goto_next_char", new SelectionCommand( SelectionCommand::MoveCaretsOrDeselect, 1 ) );
    give( "goto_prev_char", new SelectionCommand( SelectionCommand::MoveCaretsOrDeselect, -1 ) );
    give( "goto_next_word", new SelectionCommand( SelectionCommand::MoveCaretByWord, 1 ) );
    give( "goto_prev_word", new SelectionCommand( SelectionCommand::MoveCaretByWord, -1 ) );
    give( "goto_bol", new SelectionCommand( SelectionCommand::MoveCaretToLineBoundary, -1 ) );
    give( "goto_eol", new SelectionCommand( SelectionCommand::MoveCaretToLineBoundary, 1 ) );
    give( "goto_next_line", new SelectionCommand( SelectionCommand::MoveCaretByLine, 1 ) );
    give( "goto_prev_line", new SelectionCommand( SelectionCommand::MoveCaretByLine, -1 ) );
    give( "goto_bof", new SelectionCommand( SelectionCommand::MoveCaretToDocumentBegin ) );
    give( "goto_eof", new SelectionCommand( SelectionCommand::MoveCaretToDocumentEnd ) );
    give( "goto_page_down", new SelectionCommand( SelectionCommand::MoveCaretByPage, 1 ));
    give( "goto_page_up", new SelectionCommand( SelectionCommand::MoveCaretByPage, -1 ));

    // selection
    give( "sel_next_char", new SelectionCommand( SelectionCommand::MoveCaretByCharacter, 1, true ) );
    give( "sel_prev_char", new SelectionCommand( SelectionCommand::MoveCaretByCharacter, -1, true ) );
    give( "sel_next_word", new SelectionCommand( SelectionCommand::MoveCaretByWord, 1, true ) );
    give( "sel_prev_word", new SelectionCommand( SelectionCommand::MoveCaretByWord, -1, true ) );
    give( "sel_to_bol", new SelectionCommand( SelectionCommand::MoveCaretToLineBoundary, -1, true) );
    give( "sel_to_eol", new SelectionCommand( SelectionCommand::MoveCaretToLineBoundary, 1, true ) );
    give( "sel_to_next_line", new SelectionCommand( SelectionCommand::MoveCaretByLine, 1, true ) );
    give( "sel_to_prev_Line", new SelectionCommand( SelectionCommand::MoveCaretByLine, -1, true ) );
    give( "sel_to_bof", new SelectionCommand( SelectionCommand::MoveCaretToDocumentBegin, -1, true ) );
    give( "sel_to_eof", new SelectionCommand( SelectionCommand::MoveCaretToDocumentEnd, 1, true ) );
    give( "sel_page_down", new SelectionCommand( SelectionCommand::MoveCaretByPage, 1, true ));
    give( "sel_page_up", new SelectionCommand( SelectionCommand::MoveCaretByPage, -1, true ));

    give( "sel_all", new SelectionCommand( SelectionCommand::SelectAll ) );
    give( "sel_word", new SelectionCommand( SelectionCommand::SelectWord ));
    give( "sel_line", new SelectionCommand( SelectionCommand::SelectFullLine, 1 ));
    give( "sel_prev_line", new SelectionCommand( SelectionCommand::SelectFullLine, -1 ));
    give( "add_caret_prev_line", new SelectionCommand( SelectionCommand::AddCaretByLine, -1));
    give( "add_caret_next_line", new SelectionCommand( SelectionCommand::AddCaretByLine, 1));
    give( "sel_reset", new SelectionCommand( SelectionCommand::ResetSelection ) );

    // line entry
    give( "ins_newline", new NewlineCommand( NewlineCommand::NormalNewline ) );
    give( "ins_newline_before", new NewlineCommand( NewlineCommand::AddLineBefore ) );
    give( "ins_newline_after", new NewlineCommand( NewlineCommand::AddLineAfter ) );

    // remove text at the left
    give( "del_left", new RemoveCommand( RemoveCommand::RemoveChar, RemoveCommand::Left ) );
    give( "del_word_left", new RemoveCommand( RemoveCommand::RemoveWord, RemoveCommand::Left ) );
    give( "del_line_left", new RemoveCommand( RemoveCommand::RemoveLine, RemoveCommand::Left ) );

    // remove text at the rigth
    give( "del_right", new RemoveCommand( RemoveCommand::RemoveChar, RemoveCommand::Right ) );
    give( "del_word_right", new RemoveCommand( RemoveCommand::RemoveWord, RemoveCommand::Right ) );
    give( "del_line_right", new RemoveCommand( RemoveCommand::RemoveLine, RemoveCommand::Right ) );

    // special text entry commands
    give( "duplicate", new DuplicateCommand() );
    give( "toggle_comment", new CommentCommand( false) );
    give( "toggle_block_comment", new CommentCommand( true) );

    // tab entry
    //give( "tab", new ReplaceSelectionCommand( "\t", CoalesceId_InsertTab ));
    /// TODO: add a backtab action here
    //set( QKeySequence( Qt::Key_BackTab ), new )
    give( "tab", new TabCommand( TabCommand::Forward, true ));
    give( "tab_back", new TabCommand( TabCommand::Backward, true ));

    give( "indent", new TabCommand( TabCommand::Forward, false));
    give( "outdent", new TabCommand( TabCommand::Backward, false ));

    // undo / redo comamnds
    give( "undo", new UndoCommand() );
    give( "redo", new RedoCommand() );
    give( "soft_undo", new UndoCommand(true) );
    give( "soft_redo", new RedoCommand(true) );

    // clipboard operations
    give( "copy", new CopyCommand( ) );
    give( "cut", new CutCommand() );
    give( "paste", new PasteCommand() );

    // debug commands
    give( "debug_dump_scopes", new DebugCommand( DebugCommand::DumpScopes ) );
    give( "debug_rebuild_scopes", new DebugCommand( DebugCommand::RebuildScopes ) );
    give( "debug_dump_undo_stack", new DebugCommand( DebugCommand::DumpUndoStack ) );
    give( "debug_dump_character_codes", new DebugCommand( DebugCommand::DumpCharacterCodes ) );

    // find items
    give( "find_use_sel", new FindCommand( FindCommand::UseSelectionForFind ) );
    give( "find_next_match", new FindCommand( FindCommand::FindNextMatch) );
    give( "find_prev_match", new FindCommand( FindCommand::FindPreviousMatch) );
    give( "sel_next_match", new FindCommand( FindCommand::SelectNextMatch ));
    give( "sel_prev_match", new FindCommand( FindCommand::SelectPreviousMatch));
    give( "sel_all_matches", new FindCommand( FindCommand::SelectAllMatches ));

    give( "select_under_expand", new FindCommand( FindCommand::SelectUnderExpand ));
    give( "select_all_under", new FindCommand( FindCommand::SelectAllUnder ));

    give( "move_lines_up", new MoveLineCommand(-1));
    give( "move_lines_down", new MoveLineCommand(1));
}