From: mrjohnson <mrj...@us...> - 2005-12-31 18:41:15
|
Update of /cvsroot/tora/tora In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28676 Modified Files: tomarkedtext.cpp tomarkedtext.h Log Message: fix selection replace, affected the autoindent Index: tomarkedtext.cpp =================================================================== RCS file: /cvsroot/tora/tora/tomarkedtext.cpp,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** tomarkedtext.cpp 26 Sep 2005 08:17:05 -0000 1.69 --- tomarkedtext.cpp 31 Dec 2005 18:41:04 -0000 1.70 *************** *** 595,600 **** void toMarkedText::insert(const QString &str, bool select) { - // NOTE: this may need some modification in case of insertion when - // there is active selection causes selection replacement int lineFrom; int indexFrom; --- 595,598 ---- *************** *** 602,616 **** int indexTo; ! // get current position ! if (select) { ! getCursorPosition (&lineFrom, &indexFrom); ! } QextScintilla::insert(str); // get new position and select if requested ! if (select) { ! getCursorPosition (&lineTo, &indexTo); ! setSelection (lineFrom, indexFrom, lineTo, indexTo); } } --- 600,622 ---- int indexTo; ! QextScintilla::removeSelectedText(); ! ! if(select) ! getCursorPosition(&lineFrom, &indexFrom); + // insert() doesn't work as advertised. + // docs say: "The new current position if after the inserted text." + + // I thought it would mean that the cursor would be at the end of + // the inserted text. Now I'm not really sure what the heck that + // means. + + // That means the selection is broken for now. QextScintilla::insert(str); // get new position and select if requested ! if(select) { ! getCursorPosition(&lineTo, &indexTo); ! setSelection(lineFrom, indexFrom, lineTo, indexTo); } } *************** *** 647,652 **** if ( r == id[ IdClear ] ) clear(); ! else if ( r == id[ IdSelectAll ] ) ! selectAll(); else if ( r == id[ IdUndo ] ) undo(); --- 653,658 ---- if ( r == id[ IdClear ] ) clear(); ! else if ( r == id[ IdSelectAll ] ) ! editSelectAll(); else if ( r == id[ IdUndo ] ) undo(); Index: tomarkedtext.h =================================================================== RCS file: /cvsroot/tora/tora/tomarkedtext.h,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** tomarkedtext.h 26 Sep 2005 08:17:05 -0000 1.48 --- tomarkedtext.h 31 Dec 2005 18:41:04 -0000 1.49 *************** *** 224,227 **** --- 224,239 ---- } + /** QextScintilla's selectAll doesn't always work like we want. + * + */ + virtual void selectAll (bool select = TRUE) + { + // selectAll(true) doesn't work if there's a selection already. + if(QextScintilla::hasSelectedText()) + QextScintilla::selectAll(false); + + QextScintilla::selectAll(); + } + /** Move to top of data */ |