From d73eb1aeb47c3ede5fea35fedae483365ea7e16c Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Fri, 23 Apr 2010 05:52:55 +0000 Subject: [PATCH] 2010-04-22 10:47 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbqt/hbqt_hbqplaintextedit.cpp * contrib/hbide/ideeditor.prg * contrib/hbide/ideshortcuts.prg ! Fixed few artifacts belonging to function prototype display as tooltip and code completion behavior. --- harbour/ChangeLog | 8 +++ harbour/contrib/hbide/ideeditor.prg | 64 +++++++++++-------- harbour/contrib/hbide/ideshortcuts.prg | 2 +- .../contrib/hbqt/hbqt_hbqplaintextedit.cpp | 26 ++++++-- 4 files changed, 67 insertions(+), 33 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 980ffc65a2..47303cbb48 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,14 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-04-22 10:47 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbqt/hbqt_hbqplaintextedit.cpp + + * contrib/hbide/ideeditor.prg + * contrib/hbide/ideshortcuts.prg + ! Fixed few artifacts belonging to function prototype display + as tooltip and code completion behavior. + 2010-04-23 02:36 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * utils/hbmk2/hbmk2.prg * Minor adjustment to watcom -warn=max mapping. diff --git a/harbour/contrib/hbide/ideeditor.prg b/harbour/contrib/hbide/ideeditor.prg index 557fe05d27..823bf0825d 100644 --- a/harbour/contrib/hbide/ideeditor.prg +++ b/harbour/contrib/hbide/ideeditor.prg @@ -261,7 +261,7 @@ METHOD IdeEditsManager:addSourceInTree( cSourceFile, cView ) #if 0 cPathA := hbide_pathNormalized( cPath ) - +array2table( IF ( n := ascan( ::aEditorPath, {|e_| e_[ 2 ] == cPathA } ) ) == 0 oParent := oGrand:addItem( cPath ) aadd( ::aProjData, { oParent, "Editor Path", oGrand, cPathA, cSourceFile } ) @@ -1806,11 +1806,13 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p, p1 ) ::moveLine( -1 ) RETURN .t. ENDIF + EXIT CASE Qt_Key_Down IF lCtrl .AND. lShift ::moveLine( 1 ) RETURN .t. ENDIF + EXIT CASE Qt_Key_ParenLeft IF ! lCtrl .AND. ! lAlt ::loadFuncHelp() // Also invokes prototype display @@ -1833,10 +1835,12 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p, p1 ) EXIT + CASE QEvent_Enter CASE QEvent_FocusIn ::resumePrototype() EXIT + CASE QEvent_Leave CASE QEvent_FocusOut ::suspendPrototype() EXIT @@ -2145,8 +2149,9 @@ METHOD IdeEdit:getLineNo() METHOD IdeEdit:insertSeparator( cSep ) LOCAL qCursor := QTextCursor():configure( ::qEdit:textCursor() ) - DEFAULT cSep TO ::cSeparator - + IF empty( cSep ) + cSep := ::cSeparator + ENDIF qCursor:beginEditBlock() qCursor:movePosition( QTextCursor_StartOfBlock ) qCursor:insertBlock() @@ -2327,11 +2332,37 @@ METHOD IdeEdit:clickFuncHelp() /*----------------------------------------------------------------------*/ +METHOD IdeEdit:loadFuncHelp() + LOCAL qEdit, qCursor, qTextBlock, cText, cWord, nCol, cPro + + qEdit := ::qEdit + qCursor := QTextCursor():configure( qEdit:textCursor() ) + qTextBlock := QTextBlock():configure( qCursor:block() ) + cText := qTextBlock:text() + nCol := qCursor:columnNumber() + cWord := hbide_getPreviousWord( cText, nCol ) + + IF !empty( cWord ) + IF ! empty( ::oHL ) + ::oHL:jumpToFunction( cWord ) + ENDIF + IF !empty( cPro := ::oFN:positionToFunction( cWord, .t. ) ) + IF empty( ::cProto ) + ::showPrototype( ::cProto := hbide_formatProto( cPro ) ) + ENDIF + ENDIF + ENDIF + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD IdeEdit:resumePrototype() ::isSuspended := .f. IF !empty( ::qEdit ) - ::qEdit:hbShowPrototype( ::cProto ) + IF ::getLineNo() == ::nProtoLine .AND. ::getColumnNo() >= ::nProtoCol + ::qEdit:hbShowPrototype( ::cProto ) + ENDIF ENDIF RETURN Self @@ -2394,30 +2425,6 @@ METHOD IdeEdit:completeCode( p ) /*----------------------------------------------------------------------*/ -METHOD IdeEdit:loadFuncHelp() - LOCAL qEdit, qCursor, qTextBlock, cText, cWord, nCol, cPro - - qEdit := ::qEdit - - qCursor := QTextCursor():configure( qEdit:textCursor() ) - qTextBlock := QTextBlock():configure( qCursor:block() ) - cText := qTextBlock:text() - nCol := qCursor:columnNumber() - cWord := hbide_getPreviousWord( cText, nCol ) - IF !empty( cWord ) - IF ! empty( ::oHL ) - ::oHL:jumpToFunction( cWord ) - ENDIF - IF !empty( cPro := ::oFN:positionToFunction( cWord, .t. ) ) - IF empty( ::cProto ) - ::showPrototype( ::cProto := hbide_formatProto( cPro ) ) - ENDIF - ENDIF - ENDIF - RETURN Self - -/*----------------------------------------------------------------------*/ - FUNCTION hbide_getPreviousWord( cText, nPos ) LOCAL cWord, n @@ -2542,6 +2549,7 @@ FUNCTION hbide_isHarbourKeyword( cWord ) 'var' => NIL,; 'destructor' => NIL,; 'inline' => NIL,; + 'setget' => NIL,; 'assign' => NIL,; 'access' => NIL,; 'inherit' => NIL,; diff --git a/harbour/contrib/hbide/ideshortcuts.prg b/harbour/contrib/hbide/ideshortcuts.prg index 514207de43..0c8995a7c3 100644 --- a/harbour/contrib/hbide/ideshortcuts.prg +++ b/harbour/contrib/hbide/ideshortcuts.prg @@ -1098,7 +1098,7 @@ METHOD IdeShortcuts:loadMethods() 'insert( "" )', ; 'Insert at current cursor position.' } ) aadd( ::aMethods, { 'separator( cSep )', ; - 'separator( "" )', ; + 'separator( ' + '/*' + replicate( "-", 68 ) + '*/' + ' )', ; 'Inserts separator line immediately before current line. defaults to "/*---*/"' } ) aadd( ::aMethods, { 'getWord( lSelect )', ; 'getWord( .f. )' , ; diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp index 682324fe1d..46484ccdfe 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp @@ -197,16 +197,27 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event ) QPlainTextEdit::keyPressEvent( event ); + if( ! c ) + return; + + if( ( event->modifiers() & ( Qt::ControlModifier | Qt::AltModifier ) ) ) + { + c->popup()->hide(); + return; + } + const bool ctrlOrShift = event->modifiers() & ( Qt::ControlModifier | Qt::ShiftModifier ); - if( !c || ( ctrlOrShift && event->text().isEmpty() ) ) + if( ( ctrlOrShift && event->text().isEmpty() ) ) return; static QString eow( "~!@#$%^&*()+{}|:\"<>?,./;'[]\\-=" ); /* end of word */ bool hasModifier = ( event->modifiers() != Qt::NoModifier ) && !ctrlOrShift; QString completionPrefix = hbTextUnderCursor(); - if( ( hasModifier || event->text().isEmpty() || completionPrefix.length() < 3 - || eow.contains( event->text().right( 1 ) ) ) ) + if( ( hasModifier || + event->text().isEmpty() || + completionPrefix.length() < 3 || + eow.contains( event->text().right( 1 ) ) ) ) { c->popup()->hide(); return; @@ -221,7 +232,14 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event ) cr.setWidth( c->popup()->sizeHintForColumn( 0 ) + c->popup()->verticalScrollBar()->sizeHint().width() ); c->complete( cr ); // popup it up! } - +#if 0 +QString HBQPlainTextEdit::hbTextForPrefix() +{ + QTextCursor tc = textCursor(); + tc.select( QTextCursor::WordUnderCursor ); + return tc.selectedText(); +} +#endif QString HBQPlainTextEdit::hbTextUnderCursor() { QTextCursor tc = textCursor();