self moveup self movelineend(else self _curcolndx - moves the cursor to the front of the current line def movelinehomeself self _curcolndx moves the cursor to the end of the current line def movelineendself )self _curcolndx self numchars( starts new line at the cursor position def breaklineself )save the text following the cursor position nlcontents self _curline text[self _curcolndx:insert newline character and truncate the line del self _curline text[self __curcolndx:self _curline text append'\ninsert the new line and increment the line counter self _insertnodeself _curlinenlcontents move the cursor self _curline newline self _curlinendx + self _curcolndx inserts the given character at the current cursor position def addcharselfchar )if char ='\nself breakline(else ndx self _curcolndx if self ininsertmode(self _curline text insertndxchar else if self getchar(='\nself _curline text insertndxchar else self _curline textndx char self _curcolndx + removes the character preceding the cursorcursor remains fixed def deletecharself )if self getchar(!'\nself _curline text popself _curcolndx else if self _curline is self _lastline return else nextline self _curline next self _curline text pop(self _curline text extendnextline text self _removenodenextline (listing continued