Ejemplo n.º 1
0
void EditorModel::addNewLineInMiddle(){
	// Initialize variables concerning text
	const int currentColumnNum = cursorColumn()-1;
	const int currentLineNum = cursorLine();

	const std::string& currentString = text.at(currentLineNum);
	const int currentLineLen = currentString.length();

	std::string beforeCursor = currentString.substr(0, currentColumnNum);			  // This is the string left behind
	std::string afterCursor = currentString.substr(currentColumnNum, currentLineLen); // This is the string that gets put in new line

	// Sets line position to add new line
	std::vector<std::string>::iterator linePosition;
	linePosition = text.begin()+cursorLine()+1;

	// Assign new line to text
	text.at(currentLineNum) = beforeCursor;
	text.insert(linePosition, afterCursor);
}
Ejemplo n.º 2
0
void MetaInfo::save( KConfig * conf )
{
	conf->writeEntry( "Bookmarks", bookmarks() );
	conf->writeEntry( "Breakpoints", breakpoints() );
	conf->writeEntry( "OutputMethod", toID(outputMethodInfo().method()) );
	conf->writePathEntry( "OutputPath", outputMethodInfo().outputFile().prettyURL() );
	conf->writeEntry( "OutputPicID", outputMethodInfo().picID() );
	conf->writeEntry( "CursorLine", cursorLine() );
	conf->writeEntry( "CursorColumn", cursorColumn() );
}
Ejemplo n.º 3
0
void EditorModel::deleteNewLineInMiddle(){
	// Initialize variables concerning text
	const int currentLineNum = cursorLine();

	// Gets line of text to be removed from the middle
	const std::string& currentString = text.at(currentLineNum);

	// Add line of text to previous line, delete current one from the middle
	text.at(currentLineNum-1) += currentString;
	text.erase(text.begin() + currentLineNum);
}
Ejemplo n.º 4
0
// DELETE HANDLING FUNCTIONS
void EditorModel::deleteNewLine(){
	// Initialize variables concerning text
	const int currentLineNum = cursorLine();

	// Gets line of text to be removed
	const std::string& currentString = text.at(currentLineNum);

	// Add line of text to previous line, delete current one
	text.at(currentLineNum-1) += currentString;
	text.pop_back();
}
Ejemplo n.º 5
0
void EditorModel::deleteChar(){
	// Initialize variables concerning text
	const int currentColumnNum = cursorColumn()-1;
	const int currentLineNum = cursorLine();

	// Get current line of string to be worked with
	const std::string& currentString = text.at(currentLineNum);
	const int currentLineLen = currentString.length();

	// Get two strings of text from before and after cursor
	std::string beforeCursor = currentString.substr(0, currentColumnNum-1);
	std::string afterCursor = currentString.substr(currentColumnNum, currentLineLen);

	// Assign line of text to new string without deleted character
	text.at(currentLineNum) = beforeCursor + afterCursor;
}
Ejemplo n.º 6
0
void EditorModel::insertNewLine(){
	// Initialize variables concerning text
	const int currentColumnNum = cursorColumn()-1;
	const int currentLineNum = cursorLine();

	const std::string& currentString = text.at(currentLineNum);
	const int currentLineLen = currentString.length();

	// String of text before cursor
	std::string beforeCursor = currentString.substr(0, currentColumnNum);
	// String of text after cursor
	std::string afterCursor = currentString.substr(currentColumnNum, currentLineLen);

	// Assigns previous line to string of text before cursor, adds text after cursor to new line
	text.at(currentLineNum) = beforeCursor;
	text.push_back(afterCursor);
}
Ejemplo n.º 7
0
// INSERT HANDLING FUNCTIONS
void EditorModel::insert(const char c){

	// Initialize variables concerning text
	const int currentColumnNum = cursorColumn()-1;
	const int currentLineNum = cursorLine();

	const std::string& currentString = text.at(currentLineNum);
	const int currentLineLen = currentString.length();


	// String of text before cursor
	std::string beforeCursor = currentString.substr(0, currentColumnNum);
	// String of text after cursor
	std::string afterCursor = currentString.substr(currentColumnNum, currentLineLen);
	// New string created from inserting new character
	std::string newString = beforeCursor + c + afterCursor;

	// Assign line of text to new string created
	text.at(currentLineNum) = newString;
}