Exemplo n.º 1
0
void Text_clear_call(bContext *C, ReportList *reports, PointerRNA *_ptr, ParameterList *_parms)
{
	struct Text *_self;
	_self= (struct Text *)_ptr->data;
	
	clear_text(_self);
}
Exemplo n.º 2
0
static void
append_char(int c)
{
    if (yyleng >= MAXTEXTLEN - 1) {
	end_text();
	clear_text();
    }
    yytext[yyleng++] = c;
}
Exemplo n.º 3
0
void scuola::cerca()
{
    QSqlQuery query;
    query.prepare("select * from scuola where id=1");
    query.exec();

    if(query.next()){
        ui->denom->setText(query.value(1).toString());
        ui->cap->setText(query.value(2).toString());
        ui->citta->setText(query.value(3).toString());
        ui->indirizzo->setText(query.value(4).toString());
        ui->lineEdit->setText(query.value(5).toString());
        ui->dirigente->setText(query.value(6).toString());
    }
    else
    {
        clear_text();
    }
}
Exemplo n.º 4
0
/*  first_draw
 *  Draw interface for the first frame
 */
void first_draw() {
  if (game_menu == 1) { draw_menu(); }
  else {
    // Regular game
    if ((game_mode == 0) && (game_paused == 0)) {
	  	unsigned char txt2[] = {'D','r','a','w',' ','g','a','m','e','\n','\0'};
	  	console_out(txt2);
      fill_screen(C_BLACK);
	  	clear_text();
      subset(4, C_GREEN);
      meta_bar(C_BLACK);
      border(8,24,2,C_WHITE);
      paddle(PADDLE_1_XOFF,p1_h,p1_c);
      paddle(PADDLE_2_XOFF,p2_h,p2_c);
    }
    // Paused game
    if (game_paused == 1) {
			unsigned char txt3[] = {'P','A','U','S','E','D','\n','\0'};
			console_out(txt3);
      fill_screen(C_RED);
		  char* hw = "GAME PAUSED";
			int x = 10;
			while (*hw) {
				write_char(x, 2, *hw);
				x++;
				hw++;
			}
    }
    // Different mode, not implemented
    if (game_mode != 0) {
			unsigned char txt4[] = {'U','N','K','N','O','W','N','\n','\0'};
			console_out(txt4);
      fill_screen(C_DBLUE);
    }
  }
}
Exemplo n.º 5
0
static int
id_token(void)
{
    extern symptr lookup(char *, int);
    extern symptr install(char *, int, int, int, Int);
    extern int  local_declare(char *);
    extern int  lookup_local(char *);
    int         i;
    symptr      sp;
    char        *tempyytext;
    char	*tempagentname;
    char	aname[80];
	int context;
	void *tempoid;

	context = basecontext;
    tempagentname = agentName;

    while (isalnum(nextc) || nextc == '_') {
      input();
    }

	end_text1();

    /* printf("yytext %s", yytext); */
    if ((i = keyword_token(yytext))) {	/* keyword ? */
      if (i==EVAL) inEVAL = 1;
      end_text();
      return i;		/* return the lexeme */
    }

	if (nextc == ':') {
		if (peek() == ':') {
			strcpy(aname, yytext);
			tempagentname = aname;
			input();
			input();
			end_text();
			clear_text();
	
			while (isalnum(nextc) || nextc == '_') {
				input();
			}
	
			end_text1();
		}
	
	}


    if (inauto || inpara) {	/* declaring local variables ? */
        end_text();
	yylval.narg = local_declare(yytext);
	return LOCAL;
    } else {			/* in statements */
	if ((i = lookup_local(yytext))) {	/* local variable ? */
            end_text();
	    if (i < 0) {	/* it is an argument */
		yylval.narg = -i;
		return ARG;
	    } else {		/* it is a local variable */
		yylval.narg = i;
		return LOCAL;
	    }
	} else {
	    if (builtin_ft_check(yytext) == 0) {
	      /* Don't append (pre or post) an agent name if: 1) if a
                 built-in function, 2) if we're in the general context
                 (no >> syntax etc used), 3) the definitions are from
                 a Scout window definition, 4) similarly, if the
                 definitions are from a Donald 'within' definition, 5)
                 if the name already has a ~ prefix [Ash, with
                 Patrick] */
	      /* printf("yytext1 = %s %s %i %i %i\n", yytext, agentName,
		 appAgentName, append_agentName, append_NoAgentName); */
	       if (*tempagentname != 0 && appAgentName > 0 && append_agentName > 0
	           && append_NoAgentName > 0) {
		   /*tempyytext = yytext;
		   new_yytext[0] = '\0';
                   if (yytext[0] == '_' && inPrefix) {
                     strcat(new_yytext, "_");
                     tempyytext++;
                   }
		   if (inPrefix) strcat(new_yytext, agentName);
		      else  strcat(new_yytext, tempyytext);
		   strcat(new_yytext, "_"); *//* New double underbar for DOSTE context [Nick] */
		   /*if (inPrefix) strcat(new_yytext, tempyytext);
		      else  strcat(new_yytext, agentName);
          	   strcpy(yytext, new_yytext);
          	   yyleng = strlen(yytext);*/
 		   /*   printf("agentName = %s \n", agentName);  */
		   /* printf("yytext = %s \n", yytext); */

			/* Make a context from agent name [Nick] */
			context = doste_context(tempagentname);
	       }

		
	    }
	    end_text();

	    /* must be global [Ash] */
 	    if ((sp = lookup(yytext, context)) == 0)  {
	      /* doesn't already exist [Ash] */
	      sp = install(yytext,context, VAR, UNDEF, 0);
	      /* printf("new_yytext = %s", yytext);  */
            }
#ifdef DISTRIB
            if (!strcmp(sp->name, "higherPriority")) setHighPrior=1;
#endif /* DISTRIB */
	    yylval.sym = sp;
	    return sp->stype;
	}
    }
}
Exemplo n.º 6
0
/* For VA [Ash, with Patrick] */
static void
getAgentName(void) {
   extern symptr lookup(char *, int);
   symptr sp;
   char secondC, firstC;

      *agentType = '\0';
      if ((firstC = nextc) == '>') inPrefix = 1;
         else  inPrefix = 0;
      agentType[0] = firstC;
      input();     /* skip second '>' */
      secondC = nextc;
      agentType[1] = secondC;
      agentType[2] = '\0';
      input();
      clear_text();
      while (isalnum(nextc) || nextc == '_')
        input();
      end_text1();
      *agentName = '\0';
      /* printf("secondc = %c \n", secondC); */
      if (yytext[0] == '\0') {
#ifndef TTYEDEN
	/* Show the agent name on the interface [Ash] */
          Tcl_VarEval(interp, ".agentName config -text {}", 0);
#endif
          clear_text();
          return;
      }
      if (secondC=='>' || secondC=='~') {
           /* printf("getagentName = %s \n", yytext); */
           strcpy(agentName, yytext);
#ifndef TTYEDEN
           Tcl_VarEval(interp, ".agentName config -text {current agent: ", agentName, "}", 0);
#endif
           /*strcat(agentName, "_");*/
           clear_text();
           if (secondC=='~') append_NoAgentName = 0;
           else append_NoAgentName = 1;
    	   return;
      }
      if (secondC=='<') {
        append_NoAgentName = 1;
        if ((sp = lookup(yytext, basecontext)) == 0) {
#ifndef TTYEDEN
           Tcl_VarEval(interp, ".agentName config -text {}", 0);
#endif
           clear_text();
           return;
        } else {
           switch(sp->d.type) {
             case  INTEGER:
                  sprintf(agentName, "%d", sp->d.u.i); break;
             case  MYCHAR:
                  sprintf(agentName, "%c", sp->d.u.i); break;
             case  STRING:
                  sprintf(agentName, "%s", sp->d.u.s); break;
             default:
               error2("expecting string, char or integer for virtual agent", sp->name);
           }
           /* printf("getagentName = %s \n", sp->d.u.s); */

           /* strcpy(agentName, sp->d.u.s); */
#ifndef TTYEDEN
           Tcl_VarEval(interp, ".agentName config -text {current agent: ", agentName, "}", 0);
#endif
           /*strcat(agentName, "_");*/
           clear_text();
    	   return;
    	}
      }
}
Exemplo n.º 7
0
int
yylex(void)
{
    char       *s;
    uDatum	u;
#ifdef DISTRIB
    extern Int *higherPriority;
#endif /* DISTRIB */

    /* initial for a token */
    clear_text();

    if (bof) {
	bof = 0;
	if (nextc == '%') {	/* comment line */
	    skip_percent_comment();/* return next token */
	    end_text();
	    clear_text();
	}
	/* printf("bof \n"); */
	if (nextc == '>' || nextc == '<') getAgentName();
    }

restart:

    while (isspace(nextc) && (nextc != '\n') && (nextc != '\r')) {
      /* skip blanks */
      input();
    }

    if ((nextc == '\n') || (nextc == '\r')) {
      input();
      if (nextc == '%') {	/* comment line */
	skip_percent_comment();/* return next token */
	end_text();
	clear_text();
      }
      /* printf("restart\n"); */
      if (nextc == '>' || nextc == '<') getAgentName();
      
      goto restart;
    }
    end_text();
    clear_text();

    if (nextc == 0) {		/* EOF */
#ifdef DISTRIB
        if (setHighPrior) { *higherPriority=0; setHighPrior = 0; }
#endif
	return 0;		/* don't do input() so next token is EOF */
    }

#ifdef TTYEDEN
    prompt = promptsemi;
#endif

    if (isdigit(nextc) || nextc == '.')	/* a number or a dot */
	return number_token();

    if (isalpha(nextc) || nextc == '_')	/* a keyword or an identifier */
      {
        append_agentName = 1;
	return id_token();
      }

    /*if (nextc == '^') {
	input();
	append_agentName = 1;
	return context_token();
	}*/

    if (nextc == '\'') {
	while (input(), nextc != '\'') {
	    if (nextc == '\\')
		input();
	    else if (nextc == 0)
		error("unexpected end-of-file in character constant");
	}
	input();		/* read the quote */

	/* mustn't alter the following two lines */
	end_text();		/* accept the text */
	last_char = '\0';	/* delete the last quote */

	backslash(yytext + 1);	/* resolve the backslashs */
	if (yytext[2])		/* more than one char */
	    error("single char expected");
	u.i = yytext[1];
	yylval.dp = makedatum(MYCHAR, u);
	return CONSTANT;
    }
    if (nextc == '\"') {
#ifdef TTYEDEN
        prompt = promptchar;
#endif
	while (input(), nextc != '\"') {
	    if (nextc == '\\')
		input();
	    else if (nextc == 0)
		error("unexpected end-of-file in string constant");
	}
	input();		/* read the quote */

	/* mustn't alter the following two lines */
	end_text();		/* accept the text */
	last_char = '\0';	/* delete the last quote */

	backslash(yytext + 1);	/* resolve the backslashs */
	s = (char *) emalloc(strlen(yytext));
	strcpy(s, yytext + 1);
	u.s = s;
	yylval.dp = makedatum(STRING, u);
	return CONSTANT;
    }
    input();			/* accept the char, must be the 1st char */

    switch (*yytext) {		/* the 1st char */
    case '@':
      yylval.dp = makedatum(UNDEF, u);  /* bug fix Ash + Carters */
      RETURN_TOKEN(CONSTANT);
      break;

    case '~':                   /* for agency  --sun */
         if (isalpha(nextc) || nextc == '_') {
            clear_text();
            append_agentName = 0;
            return id_token();
         }
         break;

    case '$':
	while (isdigit(nextc))
	    input();
	if (yyleng == 1)
	    RETURN_TOKEN('$');
	yylval.narg = atoi(yytext + 1);
	RETURN_TOKEN(ARG);

    case '/':
#ifdef TTYEDEN
        prompt = promptcomment;
#endif
	if (nextc == '*') {	/* nested comment */
	    skip_comment();	/* return next token */
	    end_text();
	    clear_text();
#ifdef TTYEDEN
	    prompt = prompt1;
#endif
	    goto restart;
	}
	break;

    case '#':
      if (nextc == '#') {
	skip_one_line_comment();
	end_text();
	clear_text();
#ifdef TTYEDEN
	prompt = prompt1;
#endif
	goto restart;
      }
      break;

    }

    return (multi_symbol_token());
}
Exemplo n.º 8
0
/**
 * Inits things for the game
 */
void init()
{
	// Init PA
	PA_Init();
	PA_InitVBL();
	
    // Init Sound
    PA_InitSound();
    
	// Init Text
	PA_InitText(SCREEN_TOP, 0);
	
//	debug();
	
	// Roll pre-game credits
	if(false)
	{
		// Code I wish I could put into rollPreCredits();
		u8 counter=0; // used to count till timeout
		
		// Text
		clear_text();
		print(5,3,PRECREDITS);
		
		// logo on bottom screen
		PA_EasyBgLoad(SCREEN_BOTTOM,3, splash_pong);
		
		// Wait & fade out
		counter = 0;
		PA_WaitFor(Pad.Newpress.A || Pad.Newpress.Start || Stylus.Newpress || counter++>IDLETIME);
		fadeOut();
		
		// run DSX/Comp screen
		PA_EasyBgLoad(SCREEN_TOP,	3, splash_comp);
		PA_EasyBgLoad(SCREEN_BOTTOM,3, splash_comp2);
		
		// Wait & fade out
		counter = 0;
		PA_WaitFor(Pad.Newpress.A || Pad.Newpress.Start || Stylus.Newpress || counter++>IDLETIME);
		fadeOut();
		
		// run PA_Lib & Eclipse screens
		PA_EasyBgLoad(SCREEN_TOP,	3, splash_palib);
		PA_EasyBgLoad(SCREEN_BOTTOM,3, splash_eclipse);
		
		// Wait & fade out
		counter = 0;
		PA_WaitFor(Pad.Newpress.A || Pad.Newpress.Start || Stylus.Newpress || counter++>IDLETIME);
		fadeOut();
		//rollPreCredits();
	}
	
	PA_InitText(SCREEN_TOP, 0);
	PA_SetTextCol(SCREEN_TOP, 0, 0, 0);
	
	// Some variables
	game.smartAI	= 0;
	game.score		= 0;
	game.lives		= 3;
	game.rank		= "";
	game.gameover	= false;
	
	// Load Palletes
	PA_LoadSpritePal(SCREEN_TOP,	1,	(void*)ball_Pal);
	PA_LoadSpritePal(SCREEN_BOTTOM,	2,	(void*)ball_Pal);
	PA_LoadSpritePal(SCREEN_TOP,	3,	(void*)paddle_a_Pal);
	PA_LoadSpritePal(SCREEN_BOTTOM,	4,	(void*)paddle_b_Pal);
	
	// create sprites
	PA_CreateSprite(SCREEN_BOTTOM,	BALL_BOTTOM,	(void*)ball_Sprite,		OBJ_SIZE_16X16, 1, 1, 	-BALL_WIDTH,	-BALL_HEIGHT);
	PA_CreateSprite(SCREEN_TOP,		BALL_TOP,		(void*)ball_Sprite,		OBJ_SIZE_16X16, 1, 2, 	-BALL_WIDTH,	-BALL_HEIGHT);
	PA_CreateSprite(SCREEN_BOTTOM,	PADDLE1,		(void*)paddle_a_Sprite,	OBJ_SIZE_32X16, 1, 3,	-PADDLE_WIDTH,	-PADDLE_HEIGHT);
	PA_CreateSprite(SCREEN_TOP,		PADDLE2,		(void*)paddle_b_Sprite,	OBJ_SIZE_32X16, 1, 4,	-PADDLE_WIDTH,	-PADDLE_HEIGHT);
	
	// create backgrounds
	PA_EasyBgLoad(SCREEN_TOP,		2, background_top);
	PA_EasyBgLoad(SCREEN_BOTTOM,	2, background_bottom);
	
	// Init high score to 0. (Should probably read from a save)
	highscore.points	= 0;
	highscore.name		= "No one";
	highscore.submitted	= false;
}
Exemplo n.º 9
0
static void rna_Text_clear(Text *text)
{
	clear_text(text);
	WM_main_add_notifier(NC_TEXT|NA_EDITED, text);
}
Exemplo n.º 10
0
static void prepare_about(void) {
	clear_text();
	center_text(-1, screen_height - FONT_H * 2, "mpflow Copyright (C) 2009 Walter de Jong <*****@*****.**>", YELLOW);
}
Exemplo n.º 11
0
/**
 * Gets user input from stdin and parses it into a newly allocated text.  This destroys any data in the passed in text. May return NULL if allocation fails!
 * @param[in,out] str - Pointer to a text.  Will be destroyed and reallocated in function.
 * @return Returns str with contents of parsed stdin.  May return NULL.
 */
text* strgett (text* str)
{
	//  Initialization  //
	char c = 0;			//This is the character we get from stdin 
	char p_char = ' ';	//This is a parsing character that'll determine whether the last character was 'whitespace' or not
	int alloc_new = 0;  //Determines if we should create a new word when the next character is entered.

	clear_text(str);	//Allocate a new, empty string.

	//  NULL Validation  //
	if (str == NULL || str->first == NULL)
		return NULL;

	// Primary Function //
	printf(">");	//Prompt user for input with 'cursor'
	while (c != '\n')
	{
		c =  getchar();
		switch (c)
		{
			//Kill garbage characters/Treat as whitespace
			case '.':
			case ';':
			case ',':
			case '\'':
			case '\\':
			case '?':
			case '!':
			case '\n':
			case ' ':		//This parses/breaks up the words appropriately
				if (p_char != ' ')
				{
					alloc_new = 1;
					p_char = ' ';
				}
				break;
			default:
				if (alloc_new == 1)
				{
					str->next = alloc_textFirst((text*)str->first);
					str = str->next;
					alloc_new = 0;
				}
				p_char = c;
				str->word = strccat(str->word, toupper(c));
				break;
		}
	}

	str = str->first;

	/// TEST ROUTINES //
	//print_text(str);
	//printf("Word count: %d\n", txtcnt(str));
	//printf("Text length: %d\n", txtlen(str));
	//printf("Compare A BC DEF: %d\n", txtncmp(str, atot("A BC DEF\n"))); //atot is kind of buggy
	//printf("\n");
	/// END TEST ROUTINES //

	// Default Return //
	return str;
}
Exemplo n.º 12
0
/**
 * Converts a C String to a text object.
 * @param[in] str - Pointer to a C String.
 * @return Returns a newly allocated text object, populated with contents of str.
 */
text* atot (char* str)
{
	//  Initialization  //
	text* t_str = NULL;
	char c = 0;			//This is the character we get from stdin 
	char p_char = ' ';	//This is a parsing character that'll determine whether the last character was 'whitespace' or not
	int alloc_new = 0;  //Determines if we should create a new word when the next character is entered.
	int i = 0;			//Current position at str.

	t_str = clear_text(t_str);	//Allocate a new, empty string.

	//  NULL Validation  //
	if (t_str == NULL)
		printf("Failed to alloc atot\n");
	else if (t_str->first == NULL)
		printf("Failed to alloc atot first\n");

	if (t_str == NULL || t_str->first == NULL)
		return NULL;

	// Primary Function //
	while (c != '\n')
	{
		c =  str[i];
		switch (c)
		{
			//Kill garbage characters/Treat as whitespace
			case '.':
			case ';':
			case ',':
			case '\'':
			case '\\':
			case '?':
			case '!':
			case '\n':
			case ' ':		//This parses/breaks up the words appropriately
				if (p_char != ' ')
				{
					alloc_new = 1;
					p_char = ' ';
				}
				break;
			case '\0':
				c = '\n';
				break;
			default:
				if (alloc_new == 1)
				{
					t_str->next = alloc_textFirst((text*)t_str->first);
					t_str = t_str->next;
					alloc_new = 0;
				}
				p_char = c;
				t_str->word = strccat(t_str->word, toupper(c));
				break;
		}
		i++;
	}

	t_str = t_str->first;

	/// TEST ROUTINES //
	
	/// END TEST ROUTINES //

	// Default Return //
	return t_str;
}