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() ); }
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; }
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); }
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); }
// 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; }