コード例 #1
0
ファイル: buffer.cpp プロジェクト: k3rb3ros/Text-Editor
bool Buffer::SearchF(uint8_t* ptrn)
{
	uint16_t len = strlen((char*) ptrn);
	int16_t search = SearchBuffer(ptrn);
	if(search >=0 && search < BUFFSIZE)
	{
		SetPointA(search);
		CreateMark(search, SEARCH_RESULT);
		SetMarkLen(search, len);	
		return true;
	}
	return false;
}
コード例 #2
0
ファイル: buffer.cpp プロジェクト: k3rb3ros/Text-Editor
int32_t Buffer::LookForward(int32_t x) //Search forward if there is another line continue until you get to the current x value of the cursor or we reach the end of the text
{
        uint32_t i = (point - buffer); //get the count for length calculations 

        while(i <= text_length)
        {
                if(buffer[MapToGap(i++)]=='\n') //find the start of the next line //afterwards increment the index
                {
                        int32_t j = 0;
                        for(j=0; j<x; ++j) if(i+j == text_length) break; //advance j to x or the end of the line whichever comes first
                        SetPointA(i+j); //Set the point to the new cursor position                
                        return j%CONSOLE_WIDTH; //return the horizontal the new horizontal position of the cursor
                }
        }
        return -1;
}
コード例 #3
0
ファイル: buffer.cpp プロジェクト: k3rb3ros/Text-Editor
int32_t Buffer::LookBackward(int32_t x)//Return the x coordinate of the previous line if it exists otherwise the x coordinate of the end of the previous line or -1 if there is no previous line
{
	int32_t i = (point - buffer);
	while(i >= 0)
	{
		if(buffer[MapToGap(i--)] == '\n')//check for previous lines
		{
			int32_t j = 0;
			while(i>0 && buffer[MapToGap(i--)] != '\n'); //go to the begining of the previous line
			while(j < x) if(buffer[MapToGap(i+j)] != '\n') j++;
			else break; //advance j until the line ends or we reach x
			SetPointA(i+j); //Set the point there
			return j; //return the x offset to that point
		}
	}
	return -1; //There are no previous lines 
}
コード例 #4
0
ファイル: CTriangle.cpp プロジェクト: cugone/Abrams2010
void Triangle::SetPointA(double x, double y) {
    SetPointA(Point(x, y));
}