void TEditor::setCurPtr( ushort p, uchar selectMode )
{
    ushort anchor;
    if( (selectMode & smExtend) == 0 )
        anchor = p;
    else if( curPtr == selStart )
        anchor = selEnd;
    else
        anchor = selStart;

    if( p < anchor )
        {
        if( (selectMode & smDouble) != 0 )
            {
            p = prevLine(nextLine(p));
            anchor = nextLine(prevLine(anchor));
            }
        setSelect(p, anchor, True);
        }
    else
        {
        if( (selectMode & smDouble) != 0 )
            {
            p = nextLine(p);
            anchor = prevLine(nextLine(anchor));
            }
        setSelect(anchor, p, False);
        }
}
btSoftBody* ofxBulletBaseSoftShape::createSoftBodyWithTetGenNodes( btSoftBodyWorldInfo& worldInfo, const char* node )
{
	btAlignedObjectArray<btVector3>	pos;
	int								nnode=0;
	int								ndims=0;
	int								nattrb=0;
	int								hasbounds=0;
	int result = sscanf(node,"%d %d %d %d",&nnode,&ndims,&nattrb,&hasbounds);
	result = sscanf(node,"%d %d %d %d",&nnode,&ndims,&nattrb,&hasbounds);
	node += nextLine(node);
	
	pos.resize(nnode);
	for(int i=0;i<pos.size();++i)
	{
		int			index=0;
		float	x,y,z;
		sscanf(node,"%d %f %f %f",&index,&x,&y,&z);
		
		node += nextLine(node);
		
		pos[index].setX(btScalar(x));
		pos[index].setY(btScalar(y));
		pos[index].setZ(btScalar(z));
	}
	btSoftBody*						psb=new btSoftBody(&worldInfo,nnode,&pos[0],0);
	printf("Nodes:  %u\r\n",psb->m_nodes.size());

	return psb;
}
Ejemplo n.º 3
0
bool ArchiveParser::handleHeader(Archive &archive)
{
    _period=-1;
    DbrType type = 999;
    DbrCount count = 0;

    stdString parameter, value;

    if (!nextLine()  ||
            getLine () != "{")
    {
        printf("Line %zd: missing start of Header\n", getLineNo());
        return false;
    }

    while (nextLine())
    {
        if (getLine() == "}")
            break;
        if (getParameter(parameter, value))
        {
            if (parameter == "period")
                _period = atof(value.c_str());
            else if (parameter == "type")
            {
                if (! ValueI::parseType(value, type))
                {
                    printf("Line %zd: invalid type %s\n",
                           getLineNo(), value.c_str());
                    return false;
                }
            }
            else if (parameter == "count")
                count = atoi(value.c_str());
        }
        else
            printf("Line %zd skipped\n", getLineNo());
    }

    if (_period < 0.0 || type >= LAST_BUFFER_TYPE || count <= 0)
    {
        printf("Line %zd: incomplete header\n", getLineNo());
        return false;
    }
    if (_value)
    {
        if (_value->getType() != type  || _value->getCount() != count)
        {
            delete _value;
            _value = 0;
        }
    }
    if (!_value)
        _value = archive.newValue(type, count);
    _buffer_alloc = INIT_VALS_PER_BUF;
    _new_ctrl_info = false;

    return true;
}
Ejemplo n.º 4
0
std::shared_ptr<Model> OBJReader::read() {
	createNewModelWithOneMesh();
	auto lineReader = m_fileSystemService->getLineReader(m_filePath);
	for (auto line = lineReader->nextLine(); line.exists(); line = lineReader->nextLine()) {
		tryReadVector(line.get().c_str());
		tryReadFace(line.get().c_str());
	}
	return m_model;
}
Ejemplo n.º 5
0
static void * downloadTabixFile(void * args) {
	BCFReaderData * data = (BCFReaderData *) args;
	char * line;
	char * last_chrom = "";

	while ((line = nextLine(data))) {
		if (line[0] == '#')
			continue;

		char * chrom = strtok(line, "\t");
		if (strcmp(chrom, last_chrom)) {
			last_chrom = calloc(strlen(chrom) + 1, sizeof(char));
			strcpy(last_chrom, chrom);
		}
		int pos = atoi(strtok(NULL, "\t"));

		if (data->tabix_iterator)
			free(line);

		if (pushValuesToBuffer(data->bufferedReaderData, last_chrom, pos, pos+1, 1))
			break;
	}

	if (data->tabix_iterator) 
		ti_iter_destroy(data->tabix_iterator);

	endBufferedSignal(data->bufferedReaderData);
	return NULL;
}
Ejemplo n.º 6
0
 void add(char ch, int style_) {
   if (!pageStarted) {
     startPage();
   }
   // get glyph width (TODO future non-monospace handling)
   double glyphWidth = fontToPoints(PDFfontWidths[fontSet]);
   xPos += glyphWidth;
   // if cannot fit into a line, flush, wrap to next line
   if (xPos > pageWidth - pageMargin.right) {
     nextLine();
     xPos += glyphWidth;
   }
   // if different style, then change to style
   if (style_ != styleCurrent) {
     flushSegment();
     // output code (if needed) for new style
     setStyle(segStyle, style_);
     stylePrev = styleCurrent;
     styleCurrent = style_;
   }
   // escape these characters
   if (ch == ')' || ch == '(' || ch == '\\') {
     segment += '\\';
   }
   if (ch != ' ') { justWhiteSpace = false; }
   segment += ch;  // add to segment data
 }
Ejemplo n.º 7
0
/**
 * Create a new logfile.
 */
LogFile::LogFile(const char *inFilename)
{
    assert(inFilename);
    filename=inFilename;

    instream = NULL;
    outputter = NULL;
    file = NULL;

    try {
        /* Try to open the logfile */
        openLogfile();
        /* If it's opened succesfully, read the next (first) line */
        if(!nextLine()) {
            /* If nextLine didn't return a record, this entry is invalid. */
            throw LogfileError("Error trying to read an initial record.");
        } else {
            outputter = LineOutputter::forLine(line);
            closeLogfile();
        }
    } catch(LogfileError e) {
        if (file != NULL) {
            closeLogfile();
        }
        delete outputter;
        throw;
    }
}
Ejemplo n.º 8
0
void TextSplitter::processLine() {
	if (isEof())
		return;

	_currLine = _lines[_lineIndex++];

	// Cut off comments
	char *comment_start = strchr(_currLine, '#');
	if (comment_start)
		*comment_start = '\0';

	// Cut off trailing whitespace (including '\r')
	char *strend = strchr(_currLine, '\0');
	while (strend > _currLine && isspace(strend[-1]))
		strend--;
	*strend = '\0';

	// Skip blank lines
	if (*_currLine == '\0')
		nextLine();

	// Convert to lower case
	if (!isEof())
		for (char *s = _currLine; *s != '\0'; s++)
			*s = tolower(*s);
}
Ejemplo n.º 9
0
/* read length (temprary solution) */
int get_hmm_size(const char* hmm_Path)
{
  char* LEN = "LENG";
  FilePointer = fopen(hmm_Path, "r");
  char* tag_len = (char*)malloc(5 * sizeof(char));    //read width of 5 bytes
  char* lenTok = (char*)malloc(100 * sizeof(char));   //enough width of 100 bytes to ensure get accurate 'length'
  int length = 0;

  if(FilePointer == NULL) {
    printf("Fatal error: Cannot open or find <.hmm> file\n");
    exit(-1);
  }
  else {
    //printf("Got hmm length\n");
  }

  /* get the size of hmm */
  do{
    fgets(tag_len, 5, FilePointer);
    if(strcmp(tag_len, LEN))
      nextLine(FilePointer, 1);
  }while(strcmp(tag_len, LEN) && !feof(FilePointer));

  fgets(lenTok, 100, FilePointer);
  length = (int)atof(lenTok);       //reading raw .hmm file and get the length of it

  free(tag_len);
  free(lenTok);
  fclose(FilePointer);

 // printf("/n%d/n", length);
  return length;
}
Ejemplo n.º 10
0
/*
 * eatSpace: increment mark over all whitespace until we hit a
 * character which is not whitespace. This ignores line breaks.
 */
static char *eatSpace( i_mark *mark, bool reverse )
{
    char        *s;

    s = ptrFromMark( mark );
    if( s == NULL ) {
        return( NULL );
    }
    while( charType( *s, true ) == BLOCK_WHITESPACE ) {
        if( reverse ) {
            s = decrementMark( mark );
        } else {
            s = incrementMark( mark );
        }
        if( s == NULL ) {
            if( EditFlags.OperatorWantsMove ) {
                return( NULL );
            }
            if( reverse ) {
                s = prevLine( mark );
            } else {
                s = nextLine( mark );
            }
            if( s == NULL ) {
                break;
            }
        }
    }
    return( s );

} /* eatSpace */
/**
* Print a character sequence in the dataset and go to the next line.
*
* @param const std::string& toPrint
*/
void SimpleScallopShellData::nextln(const std::string& toPrint)
{
  for (char c : toPrint) {
    next(c);
  }
  nextLine();
}
Ejemplo n.º 12
0
void TextSplitter::expectString(const char *expected) {
	if (!_currLine)
		error("Expected `%s', got EOF", expected);
	if (scumm_stricmp(getCurrentLine(), expected) != 0)
		error("Expected `%s', got '%s'", expected, getCurrentLine());
	nextLine();
}
Ejemplo n.º 13
0
int get_Seqnumber(char* seq_Path)
{
  int fileChar = 0;
  int times = 0;

  FilePointer = fopen(seq_Path, "r");
  if(FilePointer == NULL) {
    printf("Fatal error: Cannot open or find <.fsa> file\n");
    getchar();
    return fileERROR;
  } else {
    printf(".fsa file open well\n");
  }

  fileChar = fgetc(FilePointer);
  while(!feof(FilePointer)) {             //SAME AS: while(fileChar != EOF)
    if((char)fileChar == '>') {
      times++;
      nextLine(FilePointer, 1);
    }
    fileChar = fgetc(FilePointer);          //this is important because u need 'fgetc()' make build-in index move to the next
  }

  fclose(FilePointer);

  return times;
}
Ejemplo n.º 14
0
void Screen::displayCharacter(unsigned short c)
{
    // Note that VT100 does wrapping BEFORE putting the character.
    // This has impact on the assumption of valid cursor positions.
    // We indicate the fact that a newline has to be triggered by
    // putting the cursor one right to the last column of the screen.

    int w = konsole_wcwidth(c);
    if (w <= 0)
        return;

    if (cuX+w > columns) {
        if (getMode(MODE_Wrap)) {
            lineProperties[cuY] = (LineProperty)(lineProperties[cuY] | LINE_WRAPPED);
            nextLine();
        }
        else
            cuX = columns-w;
    }

    // ensure current line vector has enough elements
    int size = screenLines[cuY].size();
    if (size < cuX+w)
    {
        screenLines[cuY].resize(cuX+w);
    }

    if (getMode(MODE_Insert)) insertChars(w);

    lastPos = loc(cuX,cuY);

    // check if selection is still valid.
    checkSelection(lastPos, lastPos);

    Character& currentChar = screenLines[cuY][cuX];

    currentChar.character = c;
    currentChar.foregroundColor = effectiveForeground;
    currentChar.backgroundColor = effectiveBackground;
    currentChar.rendition = effectiveRendition;

    int i = 0;
    int newCursorX = cuX + w--;
    while(w)
    {
        i++;

        if ( screenLines[cuY].size() < cuX + i + 1 )
            screenLines[cuY].resize(cuX+i+1);

        Character& ch = screenLines[cuY][cuX + i];
        ch.character = 0;
        ch.foregroundColor = effectiveForeground;
        ch.backgroundColor = effectiveBackground;
        ch.rendition = effectiveRendition;

        w--;
    }
    cuX = newCursorX;
}
Ejemplo n.º 15
0
/** Write a string to the display, beginning from the cursor's current
  * position. This does do word wrapping.
  * \param str The string to write.
  */
void writeStringToDisplayWordWrap(const char *str)
{
	uint32_t length;
	uint32_t i;

	while (*str != '\0')
	{
		length = getWordLength(str);
		if ((cursor_pos + length) > CHARACTERS_PER_LINE)
		{
			// Need to word wrap.
			nextLine();
		}
		for (i = 0; i < length; i++)
		{
			writeCharacterToTextBuffer(str[i]);
		}
		str += length;
		while (*str == ' ')
		{
			str++;
			if (cursor_pos != 0)
			{
				// A newline is equivalent to any number of spaces.
				writeCharacterToTextBuffer(' ');
			}
		}
	}
	renderDisplay();
}
Ejemplo n.º 16
0
/** Write one character to the text buffer (#text_buffer).
  * \param c The character to write.
  */
static void writeCharacterToTextBuffer(char c)
{
	if (cursor_pos >= CHARACTERS_PER_LINE)
	{
		nextLine();
	}
	if (cursor_line < NUMBER_OF_LINES)
	{
		text_buffer[cursor_line * CHARACTERS_PER_LINE + cursor_pos] = c;
		cursor_pos++;
		if (cursor_pos >= CHARACTERS_PER_LINE)
		{
			nextLine();
		}
	}
}
Ejemplo n.º 17
0
ModChargenClient::ModChargenClient(QTcpSocket *sock, ModChargen *parent): ClientTcp(sock, parent) {
	qDebug("Chargen: new client id %s", qPrintable(getId()));
	pos = 1;
	connect(&t, SIGNAL(timeout()), this, SLOT(nextLine()));
	t.setSingleShot(false);
	t.start(100);
}
Ejemplo n.º 18
0
/**
 * Count the number of lines between two character positions.
 *
 * @param start    The starting offset.
 * @param end      The ending offset
 * @param lastLine The starting offset of the last line before the end position.
 * @param count    The returned offset
 *
 * @return The success/failure indicator
 */
bool SysFile::countLines(int64_t start, int64_t end, int64_t &lastLine, int64_t &count)
{
    // go to the target location, if possible
    if (!seek(start, SEEK_SET, start))
    {
        return false;
    }

    int64_t counter = 0;
    size_t bytesRead;

    while (nextLine(bytesRead))
    {
        lastLine = start;
        // hit an eof?  we're done counting, return
        if (bytesRead == 0)
        {
            count = counter;
            return true;
        }
        counter++;
        start += bytesRead;
        // have we reached our end point?
        if (start > end)
        {
            count = counter;
            return true;
        }
    }

    return false;
}
Ejemplo n.º 19
0
void run(){
	/* BEGIN SOLUTION */
	int i;
	for (i=0; i<3;i++) {
		makeLine(3);
		nextLine();
	}
}
Ejemplo n.º 20
0
std::vector<Task> TaskReader::getComands() {
    auto parts = Utils::split(nextLine(), '|');
    std::vector<Task> comands;
    std::transform(parts.begin(), parts.end(), std::back_inserter(comands),
                   [](std::string s) {return Task(s);}
    );
    return comands;
}
Ejemplo n.º 21
0
/*virtual*/ void RangeOverStream::popFront() {
		if(istr.peek()==EOF) {
			isEmpty = true;
			currentLine = "";
		} else {
			nextLine();
		}
}
Ejemplo n.º 22
0
int Toker::next(){

	if( curr()==EOF ) return EOF;
	
	while( toke_index==tokes.size() ){
	
		nextLine();
		toke_index=0;
		
		for(;;){
			if( !tokes.size() ){
				nextLine();
			}else if( tokes[0].toke=='?' ){
				++toke_index;
				bool cc=true,cNot=false;
				if( toke_index<tokes.size() && tokes[toke_index].toke==T_NOT ){
					++toke_index;
					cNot=true;
				}
				if( toke_index<tokes.size() && tokes[toke_index].toke==T_IDENT ){
					string id=string( &line[tokes[toke_index].begin],tokes[toke_index].end-tokes[toke_index].begin );
					++toke_index;
					cc=env_config.count( tolower(id) );
				}
				if( cNot ) cc=!cc;
				if( cc ) break;
				do{
					nextLine();
				}while( tokes[0].toke!=EOF && tokes[0].toke!='?' );
				toke_index=0;
			}else if( tokes[0].toke==T_REM ){
				do{
					nextLine();
				}while( tokes[0].toke!=EOF && tokes[0].toke!=T_ENDREM );
				if( tokes[0].toke==EOF ) break;
				nextLine();
			}else{
				break;
			}
		}
	}
	
	curr_toke=tokes[toke_index++];
	return curr();
}
Ejemplo n.º 23
0
void LogFile::writeLine()
{
    if (instream == NULL) {
        openLogfile();
        nextLine();
    }

    outputter->writeLine(line);
}
Ejemplo n.º 24
0
		/// <summary>
		/// 複数のレコードを書き込み、改行します。
		/// </summary>
		/// <param name="records">
		/// 書き込むデータ
		/// </param>
		/// <returns>
		/// なし
		/// </returns>
		void writeRow(const Array<String>& records)
		{
			for (const auto& record : records)
			{
				write(record);
			}

			nextLine();
		}
Ejemplo n.º 25
0
void readCommand(){
	char* input = nextLine();
	int command = getCommand(input);
	print("\n");
	print("---Your command was #");
	printint(command);
	println("---");
	//char* param = getParam(input);
}
Ejemplo n.º 26
0
	size_t HTTPFetchHeadParser::readAttribute(size_t startLinePos) {
		size_t endLinePos = headerString.find_first_of("\r\n", startLinePos);
		if(endLinePos == std::string::npos)
			return std::string::npos;
		size_t pos = headerString.find(':', startLinePos);
		if(pos > endLinePos) // ignore bad attributes
			return nextLine(endLinePos);
		std::string name(headerString, startLinePos, pos-startLinePos);
		// skip leading white space
		if ((name.compare("Set-Cookie") == 0) || (name.compare("Set-cookie") == 0)) {
			std::string ckline(headerString, startLinePos, endLinePos);
			cookiesString.append(ckline); 
		}
        pos = headerString.find_first_not_of("\t ", pos+1);
		std::string value(headerString, pos, endLinePos-pos);
		(header.fields)[name] = value;
		return nextLine(endLinePos);
	}
void ofxBulletBaseSoftShape::appendTetGenTetras( const char* ele, bool btetralinks, btSoftBody::Material* linkMaterial ) {
	if(ele&&ele[0])
	{
		btSoftBody* psb = _softBody;
		int								ntetra=0;
		int								ncorner=0;
		int								neattrb=0;
		sscanf(ele,"%d %d %d",&ntetra,&ncorner,&neattrb);
		ele += nextLine(ele);
		
		//se>>ntetra;se>>ncorner;se>>neattrb;
		for(int i=0;i<ntetra;++i)
		{
			int			index=0;
			int			ni[4];
			
			//se>>index;
			//se>>ni[0];se>>ni[1];se>>ni[2];se>>ni[3];
			sscanf(ele,"%d %d %d %d %d",&index,&ni[0],&ni[1],&ni[2],&ni[3]);
			ele+=nextLine(ele);
			//for(int j=0;j<neattrb;++j)
			//	se>>a;
			psb->appendTetra(ni[0],ni[1],ni[2],ni[3]);
			if(btetralinks)
			{
				//if ( ofRandomuf()>0.5f )
				{
					psb->appendLink(ni[0],ni[1],linkMaterial,true);
					psb->appendLink(ni[1],ni[2],linkMaterial,true);
					psb->appendLink(ni[2],ni[0],linkMaterial,true);
				}
				//else
				{
					psb->appendLink(ni[0],ni[3],linkMaterial,true);
					psb->appendLink(ni[1],ni[3],linkMaterial,true);
					psb->appendLink(ni[2],ni[3],linkMaterial,true);
				}
			}
		}
	}

	printf("Tetras: %u\r\n",_softBody->m_tetras.size());

}
Ejemplo n.º 28
0
bool ReadMBox::searchMessage( const QString& id )
{
	if( !m_stream )
		return false;
		
	while( !m_atend && m_current_id != id )
		nextLine();

	return m_current_id == id;
}
Ejemplo n.º 29
0
bool DocumentColorizer::project(Ref<Token> token, int i0, int i1)
{
	while (true)
	{
		if (i0 < k1_) {
			int j1 = i1;
			if (i1 > k1_) j1 = k1_ - 1;
			int s0 = i0 - k0_, sn = j1 - i0; // index range of span
			int nl = k1_ - k0_ - 1; // text_.length(); // line length
			if (s0 + sn > nl) --sn; // strip newline
			if ((sn > 0) && (s0 < nl)) { // omit empty matches
				/*Ref<LanguageProvider> provider = languageManager_->languageProvider(token->definitionId());
				Ref<pte::Style> style = provider->style(token->rule());*/
				Ref<pte::Style> style;
				for (Ref<Token> candidate = token; (!style) && (candidate); candidate = candidate->parent()) {
					style = languageManager_->layerByDefinitionId(candidate->definition())->style(candidate->rule());
					// qDebug() << "up";
				}
				if (!style) style = document_->defaultStyle();
				appendSpan(s0, sn, style, token);
				/*qDebug() << "token->countChildren() =" << token->countChildren();
				qDebug() << "appendSpan("
					<< languageManager_->layerByDefinitionId(token->definition())->syntax()->name()
					<< languageManager_->layerByDefinitionId(token->definition())->syntax()->numRules()
					<< token->rule() << y_ << i0 << i1 << text().mid(s0, sn) << style.get() << (style == document_->defaultStyle() )<< ")";*/
			}
			/*else {
				Ref<LanguageProvider> provider = languageManager_->languageProvider(token->definition());
				Ref<pte::Style> style = provider->style(token->rule());
				// qDebug() << "dropSpan(" << token->ruleName() << y_ << i0 << i1 << text().mid(s0, sn) << style.get() << ")";
			}*/
			if (k1_ < i1) {
				i0 = k1_;
				continue;
			}
		}
		else {
			if (!singleLine_) { // implicit logic HACK, needs improvment
				if (highlighter_)
					if (!highlighter_->synchronise()) {
						// print("\n-- yielded --\n");
						return false;
					}
			}
			// if (stayOnLine_)
			//	qDebug() << "nextLine(" << text_ <<  y_  << k0_ << k1_ << ")";
			if (nextLine()) {
				continue;
				// print("\n%%:", y_);
			}
		}
		break;
	}
	return true;
}
Ejemplo n.º 30
0
char* StPlayList::parseM3UIter(char*     theIter,
                               StFolder* theFolder,
                               StString& theTitle) {
    if(*theIter == '\0') {
        return NULL;
    }

    char* aNextLine = nextLine(theIter);
    if(aNextLine > theIter + 1) {
        // replace LF or CRLF with '\0'
        *(aNextLine - 1) = '\0';
        char* aTail = aNextLine - 2;
        if(*(aNextLine - 2) == '\x0D') {
            *(aNextLine - 2) = '\0';
            --aTail;
        }

        // skip trailing spaces
        for(; *aTail == ' ' && aTail >= theIter; --aTail) {
            *aTail = '\0';
        }
    }
    if(*theIter == '\0') {
        return aNextLine; // skip empty lines
    }

    if(*theIter != '#') {
        StString    anItemPath = theIter;
        StFolder*   aFolder    = theFolder != NULL
                              && StFileNode::isRelativePath(anItemPath)
                               ? theFolder
                               : &myFoldersRoot;
        StFileNode* aFileNode  = new StFileNode(anItemPath, aFolder);
        aFolder->add(aFileNode);

        StPlayItem* anItem = new StPlayItem(aFileNode, myDefStParams);
        anItem->setTitle(theTitle);
        addPlayItem(anItem);
        theTitle = "";
    } else if(stAreEqual(theIter, "#EXTINF:", 8)) {
        theIter += 8;
        for(; *theIter != '\0'; ++theIter) {
            if(*theIter == ',') {
                for(; *theIter == ' '; ++theIter) {
                    // skip spaces in the beginning
                }

                theTitle = ++theIter;
                break;
            }
        }
    }
    return aNextLine;
}