if not self text tag_ranges(sel)showerror('pyedit''no text selected'elseself oncopy(save and delete selected text self ondelete(def onpaste(self)trytext self selection_get(selection='clipboard'except tclerrorshowerror('pyedit''nothing to paste'return self text insert(inserttextadd at current insert cursor self text tag_remove(sel' 'endself text tag_add(selinsert+'-%dclen(text)insertself text see(insertselect itso it can be cut def onselectall(self)self text tag_add(sel' 'end+'- 'self text mark_set(insert' 'self text see(insertselect entire text move insert point to top scroll to top ###########################################################################search menu commands ###########################################################################def ongoto(selfforceline=none)line forceline or askinteger('pyedit''enter line number'self text update(self text focus(if line is not nonemaxindex self text index(end+'- 'maxline int(maxindex split(')[ ]if line and line <maxlineself text mark_set(insert'% linegoto line self text tag_remove(sel' 'enddelete selects self text tag_add(selinsert'insert 'select line self text see(insertscroll to line elseshowerror('pyedit''bad line number'def onfind(selflastkey=none)key lastkey or askstring('pyedit''enter search string'self text update(self text focus(self lastfind key if key nocase nocase configs get('caseinsens'true config where self text search(keyinsertendnocase=nocaseif not wheredon' wrap showerror('pyedit''string not found'else complete gui programs