#include "editor.h" #include #include #include using namespace std; /** constructs a new editor instance. * * Initial contents should represent empty string. * Initial capacity, measured in text characters, set by parameter. * The cursor should be at the "end". * * @param maxText number of text characters that can be stored. */ editor::editor(size_t maxText) : memory(3*maxText) // this creates vector with original size of 3*maxText { } /** Advances the cursor, if not already at the end. * If cursor is at end, leave it there. * (do not generate an error) */ void editor::forward() { } /** Move cursor backward, if not already at the beginning. * If cursor is at beginning, leave it there. * (do not generate an error) */ void editor::backward() { } /** Moves cursor to the beginning. * This is the location of the first text character if any, * or equivalent to end when text is empty. */ void editor::begin() { } /** Moves cursor to the end. * The end represents the hypothetical position which is just * beyond the last character of text. */ void editor::end() { } /** Reassigns character at current cursor position. * The cursor should remain unchanged by the insertion. * * If cursor is at end of list, should not do anything. * * @param c new character value */ void editor::assign(char c) { } /** Inserts a new character immediate BEFORE current cursor position. * The cursor should remain unchanged by the insertion. * * @param c new character to insert. * @throw bal_alloc when out of space */ void editor::insert(char c) { } /** Erases the character at the current cursor position (if any). * * After the operation, the new cursor position should be the one * which follows the deleted character. * * If current cursor position was end, operation should not do anything * (do not generate an error, though) */ void editor::erase() { } /** Generates a string based on the implicit contents of the editor. * @return string of zero or more characters, ordered appropriately. */ string editor::toString() const { } /********************************************************************* * Debugging code * * The following method is really here for debug purposes. In a * real implementation, it would be declared as private, but we are * making it public for convenience so that we can call it from * within our driver. * *********************************************************************/ /** Create an appropriate vertical dump of your entire memory. * Ideally it should be formatted so that slots that are "pointers" * are printed as integers and slots that are "data" are printed as * characters. * @param out the output stream on which to insert your representation. */ void editor::rawDump(ostream& out) const { } /********************************************************************* * Extra credit * * For extra credit, we will have our editor support the standard * notion of cut/paste, allowing multiple characters to be cut as a * unit, saved in a buffer, and perhaps pasted elsewhere. * *********************************************************************/ /** Set the "mark" to be equal to the current "cursor" position. * The cursor itself is unchanged. */ void editor::setMark() { } /** Cut the text between the mark and the cursor. * * Specifically, if cursor is at or beyond mark, this technically removes * all characters stating from the mark, up to but not including the character at the cursor. * * However if the cursor if strictly before the mark, then the roles are interchanged. * This should cut starting at the cursor, going up to but not including the mark. * * In either case, the deleted text should be "saved" implicitly in the cut-buffer. * (any previously cut text in the cut-buffer is lost) */ void editor::cut() { } /** The contents of the cut-buffer is inserted in FRONT of current cursor. * * The cursor itself is unchanged. * * If cut-buffer is empty string, nothing is inserted. * * As a side effect of pasting, the cut-buffer is reset to empty. * (that is, we do not allow the same text to be pasted multiple times) */ void editor::paste() { }