Ejemplo n.º 1
0
// Print a vector a sequence of JSON values, comma separated, wrapped in "[]".
template<typename T> void PrintVector(const Vector<T> &v, Type type,
                                      int indent, const GeneratorOptions &opts,
                                      std::string *_text) {
  std::string &text = *_text;
  text += "[";
  text += NewLine(opts);
  for (uoffset_t i = 0; i < v.size(); i++) {
    if (i) {
      text += ",";
      text += NewLine(opts);
    }
    text.append(indent + Indent(opts), ' ');
    if (IsStruct(type))
      Print(v.GetStructFromOffset(i * type.struct_def->bytesize), type,
            indent + Indent(opts), nullptr, opts, _text);
    else
      Print(v[i], type, indent + Indent(opts), nullptr,
            opts, _text);
  }
  text += NewLine(opts);
  text.append(indent, ' ');
  text += "]";
}
Ejemplo n.º 2
0
void TopDecls() {
  EmitLn("section .data");
  Scan();
  while(Token != 'b') {
    switch(Token) {
      case 'v': Decl(); break;
      default:
        sprintf(tmp,"Unrecognized Keyword '%s'", Value);
        Abort(tmp);
    }
    Scan();
    NewLine();
  }
}
Ejemplo n.º 3
0
void TextBox::ProcessWord(Uint16 word)
{
  Uint16 str[2] = {0, 0};
  str[0] = word;
  
  if (wordW + nowX + WIDTH_DELTA > WLwidth) {
    NewLine();
  }

  if (nowY + wordH > WLheight) return;
  
  Font::GetInstance()->DrawTextBlended(str, TextColor, canvas->surface, nowX, nowY);
  nowX += wordW + WIDTH_DELTA;
}
Ejemplo n.º 4
0
void HandleWord (void)
{
	char	word[WORDLIMIT];
	int	wordindex,
	      wwidth,
         wheight,
         newpos;


	//
	// copy the next word into [word]
	//
	word[0] = *text++;
	wordindex = 1;
	while (*text>32)
	{
		word[wordindex] = *text++;
		if (++wordindex == WORDLIMIT)
			Error ("PageLayout: Word limit exceeded");
	}
	word[wordindex] = 0;		// stick a null at end for C

	//
	// see if it fits on this line
	//
	VW_MeasurePropString (word, &wwidth, &wheight);

	while (px+wwidth > rightmargin[rowon])
	{
		NewLine ();
		if (layoutdone)
			return;		// overflowed page
	}

	//
	// print it
	//
	newpos = px+wwidth;
	VWB_DrawPropString (word);
	px = newpos;

	//
	// suck up any extra spaces
	//
	while (*text == ' ')
	{
		px += SPACEWIDTH;
		text++;
	}
}
Ejemplo n.º 5
0
static void PrintSources (const cc65_sourceinfo* S)
/* Output a list of sources */
{
    unsigned I;
    const cc65_sourcedata* D;

    /* Segments */
    for (I = 0, D = S->data; I < S->count; ++I, ++D) {
        PrintId (D->source_id, 8);
        Print ("%-30s", D->source_name);
        PrintNumber (D->source_size, 7, 9);
        PrintTime (D->source_mtime, 0);
        NewLine ();
    }
}
Ejemplo n.º 6
0
U0 MenuSprite()
{
  I64 i;
  DocPut->flags|=DOCF_FORM; //Cursor navigation will skip empty locations.
  do {
    DocClear;
    NewLine(1);

//Sprite with flags for left-expression and an exit.
//See $LK,"doc_dft_flags1","MN:doc_dft_flags1"$.	Note the %d in the string for the sprite number.
    PutSprite($IB,"<1>",1$,"$$FG,LTBLUE$$$$SP+LE+X,\"50 Hz\",50,%d$$");

    NewLine(3);
    "$$MU,\"100 Hz\",100$$\n";
    "$$MU,\"200 Hz\",200$$\n";
    "$$MU,\"CANCEL\",DOCM_CANCEL$$\n";
    i=DocMenuDo(DocPut);
    if (i>0) Snd(i);
  } while (i>=0);
  Snd(0);
  DocClear;
  NewLine(1);
  DocPut->flags&=~DOCF_FORM;
}
Ejemplo n.º 7
0
static void PutChar(unsigned char *screendata, int c)
{
    unsigned char *p;
   
    p = screendata + cur_y * TXT_SCREEN_W * 2 +  cur_x * 2;

    switch (c)
    {
        case '\n':
            NewLine(screendata);
            break;

        case '\b':
            // backspace
            --cur_x;
            if (cur_x < 0)
                cur_x = 0;
            break;

        default:

            // Add a new character to the buffer

            p[0] = c;
            p[1] = fgcolor | (bgcolor << 4);

            ++cur_x;

            if (cur_x >= TXT_SCREEN_W) 
            {
                NewLine(screendata);
            }

            break;
    }
}
Ejemplo n.º 8
0
void Block() {
  Scan();
  NewLine();
  while(Token != 'e' && Token != 'l') {
    switch(Token) {
      case 'i':
        DoIf();
        break;
      case 'w':
        DoWhile();
        break;
      case 'W':
        DoWrite();
        break;
      case 'R':
        DoRead();
        break;
      default:
        Assignment();
    }
    NewLine();
    Scan();
  }
}
Ejemplo n.º 9
0
void ClipLineInPlace( line_t **inout, vec3d_t norm, fp_t dist )
{
	fp_t		d1, d2;
	int		i;
	fp_t		scl;
	vec3d_t		clip;
	line_t		*l;

	l = *inout;

	d1 = Vec3dDotProduct( norm, l->p1 ) - dist;
	d2 = Vec3dDotProduct( norm, l->p2 ) - dist;

	if ( d1 > 0.0 && d2 > 0.0 )
	{
		FreeLine( l );
		*inout = NULL;
		return;
	}

	if ( d1 <= 0.0 && d2 <= 0.0 )
	{
		return;
	}

	scl = d1 / (d1-d2);
	for ( i = 0; i < 3; i++ )
	{
		clip[i] = l->p1[i] + scl*(l->p2[i]-l->p1[i]);
	}

	l = NewLine();
	if ( d1 <= 0.0 )
	{
	       Vec3dCopy( l->p1, (*inout)->p1 );
	       Vec3dCopy( l->p2, clip );
	       FreeLine( *inout );
	       *inout = l;
	}
	else
	{
		Vec3dCopy( l->p2, (*inout)->p2 );
		Vec3dCopy( l->p1, clip );
		FreeLine( *inout );
		*inout = l;
	}

}
Ejemplo n.º 10
0
static void PrintLines (const cc65_lineinfo* L)
/* Output a list of lines */
{
    unsigned I;
    const cc65_linedata* D;

    /* Lines */
    for (I = 0, D = L->data; I < L->count; ++I, ++D) {
        PrintId (D->line_id, 8);
        PrintId (D->source_id, 8);
        PrintNumber (D->source_line, 6, 9);
        PrintNumber (D->line_type, 4, 6);
        PrintNumber (D->count, 3, 0);
        NewLine ();
    }
}
Ejemplo n.º 11
0
static void PrintModules (const cc65_moduleinfo* M)
/* Output a list of modules */
{
    unsigned I;
    const cc65_moduledata* D;

    /* Modules */
    for (I = 0, D = M->data; I < M->count; ++I, ++D) {
        PrintId (D->module_id, 8);
        Print ("%-24s", D->module_name);
        PrintId (D->source_id, 8);
        PrintId (D->library_id, 9);
        PrintId (D->scope_id, 6);
        NewLine ();
    }
}
Ejemplo n.º 12
0
U0 Song()
{
  SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
  Fs->text_attr=BLACK<<4+WHITE;
  Fs->task_end_cb=&SndTaskEndCB;
  MusicSettingsRst;
  music_tempo= 2.480;
  music_stacatto_factor= 0.9;
  try {
    while (!ScanKey) {
      DocClear;
      "$$BG,BLACK$$$$FG,WHITE$$\n\n\n\n\nWait for the end...";
      NewLine(5);
      Spaces(17);
      PutSprite($IB+BP,"<1>",1,"::/TempleOS/Demo/Graphics/SpritePut.CPP.Z,1"$);
      Play("3e.GsGe.GsFe.EsG4e.CsDe.EsEe.EsDqCe.CsB");
      NewLine;
      Play("e.AsAe.AsBe.CsBe.CsA3e.G4sA3e.GsEqGe.GsG");
      NewLine;
      Play("e.GsGe.GsFe.EsG4e.CsDe.EsEe.EsDqCC");
      NewLine;
      Play("DDCBh.CqR");
      NewLine;
      Play("3(Ge.G");
      NewLine;
      Play("sFe.EsG4e.CsDhEq.CeR");
      NewLine;
      Play("q(Ae.A");
      NewLine;
      Play("sBe.CsBe.CsA3hGq.EeR");
      NewLine;
      Play("q(Ge.G");
      NewLine;
      Play("sFe.EsG4e.CsDhEqCC");
      NewLine;
      Play("DDCBh.CqR");
      NewLine;
      Play("etEEGqCsDCDCFCFCqAetCDBBD3G4FCF");
      NewLine;
      Play("EEGqCsDCDCFCFCqAetCDBBD3G4FCF");
      NewLine;
    }
  } catch
    CatchAll;
  DocClear;
  SettingsPop;
}
Ejemplo n.º 13
0
static void PrintSegments (const cc65_segmentinfo* S)
/* Output a list of segments */
{
    unsigned I;
    const cc65_segmentdata* D;

    /* Segments */
    for (I = 0, D = S->data; I < S->count; ++I, ++D) {
        PrintId (D->segment_id, 8);
        Print ("%-16s", D->segment_name);
        PrintAddr (D->segment_start, 9);
        PrintSize (D->segment_size, 7);
        Print ("%-16s", D->output_name? D->output_name : "");
        PrintSize (D->output_offs, 6);
        NewLine ();
    }
}
Ejemplo n.º 14
0
line_t * BaseLineForPlane( vec3d_t norm, fp_t dist )
{
	vec3d_t		p1, p2;
	vec3d_t		q1, q2;
	fp_t		d1, d2, scl;
	int		i;

	line_t		*l;

	l = NewLine();

	if ( fabs(norm[0]) >= fabs(norm[2]) )
	{
		// major x
		Vec3dInit( p1, -8192.0, 0.0, -8192.0 );
		Vec3dInit( p2,  8192.0, 0.0, -8192.0 );
		Vec3dInit( q1, -8192.0, 0.0,  8192.0 );
		Vec3dInit( q2,  8192.0, 0.0,  8192.0 );
	}
	else
	{
		// major z
		Vec3dInit( p1, -8192.0, 0.0, -8192.0 );
		Vec3dInit( p2, -8192.0, 0.0,  8192.0 );
		Vec3dInit( q1,  8192.0, 0.0, -8192.0 );
		Vec3dInit( q2,  8192.0, 0.0,  8192.0 );
	}

	d1 = Vec3dDotProduct( p1, norm ) - dist;
	d2 = Vec3dDotProduct( p2, norm ) - dist;
	scl = d1 / (d1-d2);
	for ( i = 0; i < 3; i++ )
	{
		l->p1[i] = p1[i] + scl*(p2[i]-p1[i]);
	}

	d1 = Vec3dDotProduct( q1, norm ) - dist;
	d2 = Vec3dDotProduct( q2, norm ) - dist;
	scl = d1 / (d1-d2);
	for ( i = 0; i < 3; i++ )
	{
		l->p2[i] = q1[i] + scl*(q2[i]-q1[i]);
	}
	
	return l;
}
Ejemplo n.º 15
0
static void PrintScopes (const cc65_scopeinfo* S)
/* Output a list of scopes */
{
    unsigned I;
    const cc65_scopedata* D;

    /* Segments */
    for (I = 0, D = S->data; I < S->count; ++I, ++D) {
        PrintId (D->scope_id, 8);
        Print ("%-24s", D->scope_name);
        PrintNumber (D->scope_type, 4, 8);     /* ## */
        PrintSize (D->scope_size, 8);
        PrintId (D->parent_id, 8);
        PrintId (D->symbol_id, 8);
        PrintId (D->module_id, 0);
        NewLine ();
    }
}
Ejemplo n.º 16
0
static void PrintSpans (const cc65_spaninfo* S)
/* Output a list of spans */
{
    unsigned I;
    const cc65_spandata* D;

    /* Segments */
    for (I = 0, D = S->data; I < S->count; ++I, ++D) {
        PrintId (D->span_id, 7);
        PrintAddr (D->span_start, 8);
        PrintAddr (D->span_end, 9);
        PrintId (D->segment_id, 7);
        PrintId (D->type_id, 6);
        PrintNumber (D->line_count, 6, 7);
        PrintNumber (D->scope_count, 7, 0);
        NewLine ();
    }
}
Ejemplo n.º 17
0
void interpretChar(char c) {
	switch (engInfo.mode) {
		case PRINTING_MODE:
			switch (c) {
				case ASCII_ESC:
					engInfo.mode = INTERPRETING_MODE;
					break;
				case ASCII_CR:
					SetCursorPosition(ROW(TermInfo), 0);
					break;
				case ASCII_LF:
					NewLine();
					break;
				case ASCII_BS:
					BackSpace();
					break;
				case ASCII_BELL:
					Beep(750, 300);
					break;
				case 0x0F:
					// do nothing!
					break;

				default:
					PrintChar(c);
					break;
			}
			break;
		case INTERPRETING_MODE:
			engInfo.code[engInfo.codeLen] = c;
			switch (parseCode()) {
				case PARTIAL:
					engInfo.codeLen++;
					break;
				case VALID:
					resetCode();
					break;
				case INVALID:
					resetCode();
					break;
			}
	}
}
Ejemplo n.º 18
0
/**
 *	Output a non-formatted message to the log file
 *	
 *	@param message the message
 *	@param source the source of the message, or NULL to use the previous source
 */
void IDebugLog::Message(const char * message, const char * source)
{
	if(source)
		SetSource(source);

	if(inBlock)
	{
		SeekCursor(RoundToTab((indentLevel * 4) + strlen(headerText)));
	}
	else
	{
		SeekCursor(indentLevel * 4);

		PrintText(headerText);
	}

	PrintText(message);
	NewLine();
}
Ejemplo n.º 19
0
static void PrintCSymbols (const cc65_csyminfo* S)
/* Output a list of C symbols */
{
    unsigned I;
    const cc65_csymdata* D;

    /* Segments */
    for (I = 0, D = S->data; I < S->count; ++I, ++D) {
        PrintId (D->csym_id, 6);
        Print ("%-28s", D->csym_name);
        PrintId (D->type_id, 6);
        PrintNumber (D->csym_kind, 4, 6);
        PrintNumber (D->csym_sc, 4, 6);
        PrintNumber (D->csym_offs, 4, 8);
        PrintId (D->symbol_id, 6);
        PrintId (D->scope_id, 0);
        NewLine ();
    }
}
Ejemplo n.º 20
0
static void PrintSymbols (const cc65_symbolinfo* S)
/* Output a list of symbols */
{
    unsigned I;
    const cc65_symboldata* D;

    /* Segments */
    for (I = 0, D = S->data; I < S->count; ++I, ++D) {
        PrintId (D->symbol_id, 6);
        Print ("%-24s", D->symbol_name);
        PrintNumber (D->symbol_type, 4, 6);
        PrintNumber (D->symbol_size, 4, 6);
        PrintNumber (D->symbol_value, 5, 7);
        PrintId (D->export_id, 7);
        PrintId (D->segment_id, 6);
        PrintId (D->scope_id, 6);
        PrintId (D->parent_id, 0);
        NewLine ();
    }
}
Ejemplo n.º 21
0
void
TerminalWindow::Write(const char *p, size_t length)
{
  const char *end = p + length;
  while (p < end) {
    char ch = *p++;

    if (ch == '\n')
      NewLine();
    else if (ch == '\r')
      continue;
    else {
      if (!IsPrintableASCII(ch))
        ch = '.';
      data.Get(cursor_x, cursor_y) = ch;
      Advance();
    }
  }

  Invalidate();
}
Ejemplo n.º 22
0
DimensionsStream & DimensionsStream::operator << (const std::string & String)
{
	glColor3d(0, 0, 0);

	std::string::size_type Start = 0, End;
	do
	{
		End = String.find_first_of('\n', Start);

		auto Length = ((std::string::npos != End) ? End : String.length()) - Start;
		PrintLine(String.substr(Start, Length));
		if (std::string::npos != End)
		{
			NewLine();
		}

		Start = End + 1;
	}
	while (std::string::npos != End);

	return *this;
}
Ejemplo n.º 23
0
OpenGLStream & OpenGLStream::operator << (const std::string & String)
{
	glColor3dv(m_Foreground.GetComponents());

	std::string::size_type Start = 0, End;
	do
	{
		End = String.find_first_of('\n', Start);

		auto Length = ((std::string::npos != End) ? End : String.length()) - Start;
		PrintLine(String.substr(Start, Length));
		if (std::string::npos != End)
		{
			NewLine();
		}

		Start = End + 1;
	}
	while (std::string::npos != End);

	return *this;
}
Ejemplo n.º 24
0
void TextBox::DrawText()
{
  if (performState == suspend) return;
 
  if (performState == running && checkVisible()) {
    if (--draw_current <= 0) {
      if (wordsToRender[0] == '/') { //部分文字输出结束,等待用户继续,'/p'为不换行,'/n'为换行
	wordsToRender.erase(0, 1);
	if (wordsToRender[0] == 'n') {
	  NewLine();
	}
	wordsToRender.erase(0, 1);
	performState = waiting;
      } else {
	ProcessWord(wordsToRender[0]);
	wordsToRender.erase(0, 1);
	if (wordsToRender.empty()) 
	  performState = suspend;
      }
      draw_current = draw_interval;
    }
  }
}
Ejemplo n.º 25
0
    void FileLogger::Write(const QString& line)
    {

        //Write
        QTextStream out(File);
        out.setCodec("UTF-8");
        out<<line<<"\r\n";

        //Increase counters
        FlushNumber++;
        NewFileNumber++;

        //Flush
        if(FlushNumber >= 100)
        {
            FlushNumber = 0;
            File->flush();
        }
        //CreateNewFile
        if(NewFileNumber >= 1000000)
        {
            FileIterator++;
            QFileInfo info(FileName);
            QString suffix = info.suffix();
            QString OldFileName = FileName;
            QString NewFileName = FileName.replace(suffix, QString::number(FileIterator) + "." + suffix);
            FileName = OldFileName;
            NewFileNumber = 0;
            File->close();
            delete File;
            File = new QFile(NewFileName);
            File->open(QIODevice::WriteOnly | QIODevice::Append);

        }
        emit NewLine();
    }
Ejemplo n.º 26
0
void gets(char *myString){
  //char myString[256];
  char oneChar;
  int k;
  k=0;

  oneChar=getchar();
  while(oneChar!='\n'){
    putc(oneChar);
    if (oneChar=='\177'){
      myString[--k]='\0';
     //k++;
    }
    else{
      myString[k]=oneChar;
      k++;  
    }
    
    oneChar=getchar();
  }
  myString[k]='\0';
  NewLine();
  scrollDown();
};
Ejemplo n.º 27
0
void commandPrompt(){

    char* vidmem = (char *) 0xb8000;
    char myString[256];


    puts("Your order, Master:");
    gets(myString);
    if (strcmp(myString,"clrscr")){
      clrscr();
    }
    else if (strcmp(myString,"hello")){
      cmd_hello();
    }
    else if (strcmp(myString,"happiness")){
      cmd_happiness();
    }
    else{
      puts("You typed:");
      puts(myString);
      NewLine();
      scrollDown();
    }
};
/*
--------------------------------------------------
void mpPlay(STRING *songName)

Desc:

Returns: -
--------------------------------------------------
*/
void mpPlay(STRING *songName) {
	
	WriteLog("[ ] Now playing: ");
	
	if(media_playing(mpHandle)) media_stop(mpHandle);
	if(mpCount > mpSongs - 1 || mpCount < 0) return;
	
	str_cpy(_mpSongTemp,songName);
	str_trunc(_mpSongTemp, str_len(EXT_MUSIC)-1 ); // because our four chars are: .ogg
	
	WriteLog(_mpSongTemp);
	NewLine();
	
	str_cpy(mpSongTemp,PATH_MUSIC);
	str_cat(mpSongTemp,songName);
	
	str_for_num(_mpCount, mpCount); // strcpy is unnecessary here
	
	mpHandle = media_play(mpSongTemp,NULL,VOL_MUSIC);
	
	while(media_playing(mpHandle)) wait(1);
	mpNext();
	
}
Ejemplo n.º 29
0
/*
 *  PrintUnhandledException
 *      Prints the well known "Unhandled exception at ..." into the logging buffer
 */
void ExceptionTracer::PrintUnhandledException()
{
    char module_name[MAX_PATH];
    auto dwExceptionCode = record.ExceptionCode;
    uintptr_t address = (uintptr_t)record.ExceptionAddress;

    // Find out our module name for logging
    if (!this->module || !GetModuleFileNameA(this->module, module_name, sizeof(module_name)))
        strcpy(module_name, "unknown");

    // Log the exception in a similar format similar to debuggers format
    Print("Unhandled exception at 0x%p in %s", address, FindModuleName(module, module_name, sizeof(module_name)));
    if (module) Print(" (+0x%x)", address - (uintptr_t)(module));
    Print(": 0x%X: %s", dwExceptionCode, GetExceptionCodeString(dwExceptionCode));

    // If exception is IN_PAGE_ERROR or ACCESS_VIOLATION, we have additional information such as an address
    if (dwExceptionCode == EXCEPTION_IN_PAGE_ERROR || dwExceptionCode == EXCEPTION_ACCESS_VIOLATION)
    {
        auto rw = (DWORD)record.ExceptionInformation[0];  // read or write?
        auto addr = (ULONG_PTR)record.ExceptionInformation[1];  // which address?

        Print(" %s 0x%p",
            rw == 0 ? "reading location" : rw == 1 ? "writing location" : rw == 8 ? "DEP at" : "",
            addr);

        // IN_PAGE_ERROR have another information...
        if (dwExceptionCode == EXCEPTION_IN_PAGE_ERROR)
        {
            NewLine();
            Print("Underlying NTSTATUS code that resulted in the exception is 0x%p",
                record.ExceptionInformation[2]);
        }
    }

    Print(".");
}
Ejemplo n.º 30
0
void ParseCondBlock(sInt *elsemod,sBool useelse)
{
  sInt mod;
  sBool kill,always;

  kill = always = sFALSE;

  if(!useelse)
  {
    mod = Modify++;
    if(elsemod)
      *elsemod = Modify++;
  }
  else
    mod = *elsemod;

  if(elsemod && Mode==2)
  {
    if(!useelse)
    {
      kill = !ModArray[*elsemod - 1];
      always = !ModArray[*elsemod];
    }
    else
    {
      kill = !ModArray[*elsemod];
      always = !ModArray[*elsemod - 1];
    }
  }

  Pre();
  if(kill || always)
  {
    OutBOpen();
    OutBClose();
    NewLine();
    if(kill)
      OutF("if(0)");
    else
      OutF("if(1)");
  }

  if(Token==TOK_BOPEN)
  {
    MatchBOpen();
    sInt ind = Indent;
    BeginIf(mod);
    sInt ind2 = Indent;

    while(Token!=TOK_BCLOSE)
    {
      ParseStatement();
    }

    sVERIFY(Indent == ind2);
    EndIf(mod);
    sVERIFY(Indent == ind);
    MatchBClose();
  }
  else
  {
    OutBOpen();
    BeginIf(mod);

    ParseStatement();

    EndIf(mod);
    OutBClose();
  }
}