@@ -86,7 +86,7 @@ void Editor::setLineNumber(int num)
8686 setTextCursor (cur);
8787}
8888
89- #undef SPIN_AUTOCON
89+ #define SPIN_AUTOCON
9090
9191void Editor::keyPressEvent (QKeyEvent *e)
9292{
@@ -109,13 +109,6 @@ void Editor::keyPressEvent (QKeyEvent *e)
109109 QPlainTextEdit::keyPressEvent (e);
110110 return ;
111111 }
112- #if 0 // highlighting like this causes editor trouble. don't do it.
113- if(text.length() > 0) {
114- //qDebug() << "keyPressEvent ctrlPressed " << text;
115- if(static_cast<MAINWINDOW*>(mainwindow)->isTagged(text))
116- this->setTextCursor(cur);
117- }
118- #endif
119112 QPlainTextEdit::keyPressEvent (e);
120113 return ;
121114 }
@@ -437,85 +430,6 @@ void Editor::mouseDoubleClickEvent (QMouseEvent *e)
437430}
438431
439432int Editor::autoEnterColumn ()
440- {
441- if (fileName.endsWith (" .spin" , Qt::CaseInsensitive)) {
442- return autoEnterColumnSpin ();
443- }
444- else if (fileName.endsWith (" .c" , Qt::CaseInsensitive) ||
445- fileName.endsWith (" .cpp" , Qt::CaseInsensitive) ||
446- fileName.endsWith (" .h" , Qt::CaseInsensitive)
447- ) {
448- return autoEnterColumnC ();
449- }
450- return 0 ;
451- }
452-
453- int Editor::autoEnterColumnC ()
454- {
455- QTextCursor cur = this ->textCursor ();
456- if (cur.selectedText ().length () > 0 ) {
457- return 0 ;
458- }
459-
460- int line = cur.blockNumber ();
461- int col = cur.columnNumber ();
462- cur.movePosition (QTextCursor::StartOfLine,QTextCursor::MoveAnchor);
463- cur.movePosition (QTextCursor::Right, QTextCursor::KeepAnchor,col);
464- QString text = cur.selectedText ();
465- cur.clearSelection ();
466- if (text.length () == 0 ) return 0 ;
467-
468- int stop = -1 ;
469- int indent = -1 ;
470- int star = -1 ;
471- int slcm = text.indexOf (" //" );
472-
473- // don't indent under closed comment
474- if (text.indexOf (" */" ) > -1 ) {
475- return 0 ;
476- }
477- if (isCommentOpen (line)) {
478- star = stop = text.indexOf (" *" );
479- }
480- if (stop < 0 && slcm > -1 ) {
481- stop = slcm;
482- }
483- if (stop < 0 && text.lastIndexOf (" {" ) == text.length ()-1 ) {
484- indent = propDialog->getTabSpaces ();
485- }
486-
487- qDebug () << text;
488- /* start a single undo/redo operation */
489- cur.beginEditBlock ();
490-
491- cur.insertBlock ();
492-
493- for (int n = 0 ; n <= stop || isspace (text[n].toLatin1 ()); n++) {
494- if (n == star) {
495- cur.insertText (" *" );
496- }
497- else if (n == slcm) {
498- cur.insertText (" // " );
499- }
500- else {
501- cur.insertText (" " );
502- }
503- }
504-
505- if (indent > 0 ) {
506- for (int n = 0 ; n < indent; n++) {
507- cur.insertText (" " );
508- }
509- }
510-
511- this ->setTextCursor (cur);
512- /* end a single undo/redo operation */
513- cur.endEditBlock ();
514-
515- return 1 ;
516- }
517-
518- int Editor::autoEnterColumnSpin ()
519433{
520434 QTextCursor cur = this ->textCursor ();
521435 if (cur.selectedText ().length () > 0 ) {
0 commit comments