diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 46734f2b82..6ff0f90cd9 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,35 @@ The license applies to all entries newer than 2009-04-28. */ +2012-08-10 19:43 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbqt/qtgui/hbqt_hbqplaintextedit.cpp + % Code cleanup. + + * contrib/hbide/setup.ui + + Added: a new page next to . + It holds the user-defined values for next level of + source editing intellisense. Read below. + + * contrib/hbide/edit.prg + + Implemented: most of the next level of editing intellisense + points are configurable by the developer. These include: + 1. To activate the closing structure of a statements + as a whole lot [YES] + 2. To toggle IF/ENDIF [YES] ELSE [NO] Embrace Lower Lines [NO] + 3. To toggle FOR/NEXT [YES] + 4. To toggle DO WHILE/ENDDO [YES] + 5. To toggle DO CASE/ENDCASE [YES] # CASES [3] OTHERWISE [NO] + 6. To toggle SWITCH/ENDSWITCH [YES ] # CASES [3] OTHERWISE [NO] + EXIT on same line [NO] + 7. To toggle ADD CLOSING PARENTHESIS of a function [NO] + 8. To toggle INSERT SPACES - () >= ( . ) [NO] + 9. To toggle ADD CODEBLOCK BODY - {|. => {|.| } [NO] + 10.To toggle ADD SPACE AFTER := [NO] + 11.To toggle ALIGN := WITH PREVIOUS LINES [NO] [TOBE] + 12.To toggle FORMAT LINE AFTER ENTER [NO] [TOBE] + + ; Please forward your suggessions. + 2012-08-10 13:44 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/qtcore/hbqt_hbqslots.cpp ! Fixed: a wrong variable used in trace call under debug mode. diff --git a/harbour/contrib/hbide/edit.prg b/harbour/contrib/hbide/edit.prg index 5f48cfdd92..013571f8f7 100644 --- a/harbour/contrib/hbide/edit.prg +++ b/harbour/contrib/hbide/edit.prg @@ -557,7 +557,7 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p, p1 ) HB_SYMBOL_UNUSED( p1 ) SWITCH nEvent - CASE QEvent_KeyPress + CASE QEvent_KeyPress /* The key is sent here prior TO applying TO editor */ key := p:key() kbm := p:modifiers() @@ -653,12 +653,6 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p, p1 ) ::aSelectionInfo := p1 ::oDK:setButtonState( "SelectionMode", ::aSelectionInfo[ 5 ] > 1 ) EXIT - CASE 21001 - ::handlePreviousWord( .t. ) - EXIT - CASE 21002 - ::loadFuncHelp() - EXIT CASE 21011 ::copyBlockContents() EXIT @@ -2273,7 +2267,8 @@ METHOD IdeEdit:reformatLine( nPos, nDeleted, nAdded ) qCursor:beginEditBlock() - IF cPWord == "." .AND. cPPWord $ ::hLogicals + // Group I operations + IF cPWord == "." .AND. cPPWord $ ::hLogicals /* ALWAYS */ IF ! ::oINI:lSupressHbKWordsToUpper qCursor:movePosition( QTextCursor_PreviousWord, QTextCursor_MoveAnchor, 2 ) qCursor:select( QTextCursor_WordUnderCursor ) @@ -2282,35 +2277,29 @@ METHOD IdeEdit:reformatLine( nPos, nDeleted, nAdded ) qCursor:setPosition( nPostn ) ENDIF - #if 0 /* CONFIGURABLE */ - ELSEIF cPWord == ":=" .AND. cCWord == "=" .AND. nAdded == 1 + ELSEIF ::oINI:lISOperator .AND. cPWord == ":=" .AND. cCWord == "=" .AND. nAdded == 1 qCursor:insertText( " " ) - #endif - ELSEIF cCWord == "(" .AND. hbide_isHarbourFunction( cPPWord, @cCased ) + ELSEIF ::oINI:lISCodeBlock .AND. Right( cPWord, 2 ) == "{|" .AND. cCWord == "|" .AND. nAdded == 1 .AND. Empty( cRest ) + qCursor:insertText( "| }" ) + qCursor:setPosition( nPostn ) + + ELSEIF cCWord == "(" .AND. ( hbide_isHarbourFunction( cPPWord, @cCased ) .OR. hbide_isQtFunction( cPPWord, @cCased ) .OR. hbide_isUserFunction( cPPWord, @cCased ) ) hbide_replaceWord( qCursor, 2, cCased, nPostn ) - #if 0 /* CONFIGURABLE */ + IF ::oINI:lISClosingP IF cCWord == "(" .AND. nAdded == 1 - qCursor:insertText( " )" ) + qCursor:insertText( ")" ) + IF ::oINI:lISSpaceP + qCursor:setPosition( nPostn ) + qCursor:insertText( " " ) + nPostn++ + ENDIF ENDIF - #endif + ENDIF qCursor:setPosition( nPostn ) - ELSEIF cCWord == "(" .AND. hbide_isQtFunction( cPPWord, @cCased ) + ELSEIF cCWord == " " .AND. hbide_isUserFunction( cPPWord, @cCased ) /* User dictionaries : only keywords */ hbide_replaceWord( qCursor, 2, cCased, nPostn ) - #if 0 /* CONFIGURABLE */ - IF cCWord == "(" .AND. nAdded == 1 - qCursor:insertText( " )" ) - ENDIF - #endif - qCursor:setPosition( nPostn ) - - ELSEIF ( cCWord == "(" .OR. cCWord == " " ) .AND. hbide_isUserFunction( cPPWord, @cCased ) /* User dictionaries : base work */ - qCursor:movePosition( QTextCursor_PreviousWord, QTextCursor_MoveAnchor, 2 ) - qCursor:select( QTextCursor_WordUnderCursor ) - qCursor:removeSelectedText() - qCursor:insertText( cCased ) - qCursor:setPosition( nPostn ) ELSEIF cCWord == " " .AND. cPPWord != "#" .AND. hbide_isHarbourKeyword( cPWord ) IF ! ::oINI:lSupressHbKWordsToUpper @@ -2323,56 +2312,69 @@ METHOD IdeEdit:reformatLine( nPos, nDeleted, nAdded ) ENDIF + // Group II operations IF empty( cPPWord ) .AND. cCWord == " " IF hbide_isStartingKeyword( cPWord, ::oIde ) /* FUNCTION PROCEDURE CLASS */ qCursor:movePosition( QTextCursor_StartOfBlock ) qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_KeepAnchor, nCPrev ) qCursor:removeSelectedText() + qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_MoveAnchor, Len( cPWord ) + 1 ) ELSEIF hbide_isMinimumIndentableKeyword( cPWord, ::oIde ) .AND. ::oINI:lAutoIndent /* LOCAL STATIC DEFAULT PRIVATE PUBLIC ENDCLASS RETURN */ qCursor:movePosition( QTextCursor_StartOfBlock ) qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_KeepAnchor, nCPrev ) qCursor:removeSelectedText() qCursor:insertText( space( ::nTabSpaces ) ) - qCursor:movePosition( QTextCursor_EndOfLine ) + qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_MoveAnchor, Len( cPWord ) + 1 ) ELSEIF hbide_isIndentableKeyword( cPWord, ::oIde ) .AND. ::oINI:lAutoIndent /* IF SWITCH FOR DO */ IF nCPrev < ::nTabSpaces nOff := ::nTabSpaces - nCPrev qCursor:movePosition( QTextCursor_StartOfBlock ) qCursor:insertText( space( nOff ) ) - qCursor:movePosition( QTextCursor_EndOfLine ) + qCursor:setPosition( nPostn + nOff ) - ELSEIF ( nOff := nCPrev % ::nTabSpaces ) > 0 + ELSEIF ( nOff := nCPrev % ::nTabSpaces ) > 0 /* We always go back to the previous indent */ qCursor:movePosition( QTextCursor_StartOfBlock ) qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_KeepAnchor, nOff ) qCursor:removeSelectedText() - qCursor:movePosition( QTextCursor_EndOfLine ) + qCursor:setPosition( nPostn - nOff ) ENDIF ENDIF ENDIF - IF .T. /* CONFIGURABLE */ - IF cCWord == " " .AND. nAdded == 1 + // Group III operations + IF cCWord == " " .AND. nAdded == 1 .AND. Empty( cRest ) /* Only first time having only word on a line */ + IF ::oINI:lISClosing cWord := Lower( cPWord ) - IF cWord == "if" - hbide_appendEndif( qCursor, hbide_getFrontSpacesAndWord( qCursor:block():text() ), qCursor:position() ) - ELSEIF cWord == "for" + IF ::oINI:lISIf .AND. cWord == "if" + hbide_appendIf( qCursor, hbide_getFrontSpacesAndWord( qCursor:block():text() ), qCursor:position(), ::nTabSpaces, ::oINI:lISElse, ::oINI:lISEmbrace ) + + ELSEIF ::oINI:lISFor .AND. cWord == "for" hbide_appendFor( qCursor, hbide_getFrontSpacesAndWord( qCursor:block():text() ), qCursor:position() ) - ELSEIF cWord == "switch" /* CASE indentation: CONFIGURABLE */ - hbide_appendSwitch( qCursor, hbide_getFrontSpacesAndWord( qCursor:block():text() ), qCursor:position(), ::nTabSpaces ) - ELSEIF Lower( cPPWord ) == "do" .AND. cWord == "case" /* CASE indentation: CONFIGURABLE */ - hbide_appendCase( qCursor, hbide_getFrontSpacesAndWord( qCursor:block():text() ), qCursor:position() ) - ELSEIF Lower( cPPWord ) == "do" .AND. cWord == "while" + + ELSEIF ::oINI:lISSwitch .AND. cWord == "switch" /* CASE indentation: CONFIGURABLE */ + hbide_appendSwitch( qCursor, hbide_getFrontSpacesAndWord( qCursor:block():text() ), qCursor:position(), ::nTabSpaces, ::oINI:nISSwitchCases, ::oINI:lISSwitchOWise, ::oINI:lISExitSameLine ) + + ELSEIF ::oINI:lISDoCase .AND. Lower( cPPWord ) == "do" .AND. cWord == "case" /* CASE indentation: CONFIGURABLE */ + hbide_appendCase( qCursor, hbide_getFrontSpacesAndWord( qCursor:block():text() ), qCursor:position(), ::oINI:nISCaseCases, ::oINI:lISCaseOWise ) + + ELSEIF ::oINI:lISDoWhile .AND. Lower( cPPWord ) == "do" .AND. cWord == "while" hbide_appendWhile( qCursor, hbide_getFrontSpacesAndWord( qCursor:block():text() ), qCursor:position() ) - ELSEIF cWord == "elseif" .OR. cWord == "else" - hbide_alignToPrevWord( qCursor, "if", "endif", Len( cWord ), nPostn ) ENDIF ENDIF + + IF cWord == "elseif" .OR. cWord == "else" .OR. cWord == "endif" + hbide_alignToPrevWord( qCursor, "if", "endif", Len( cWord ), nPostn ) + + ELSEIF cWord == "next" + hbide_alignToPrevWord( qCursor, "for", "next", Len( cWord ), nPostn ) + ENDIF ENDIF - ::qEdit:setTextCursor( qCursor ) + qCursor:endEditBlock() + ::qEdit:setTextCursor( qCursor ) ENDIF HB_SYMBOL_UNUSED( nCPrevPrev ) ENDIF @@ -2392,7 +2394,6 @@ METHOD IdeEdit:reformatLine( nPos, nDeleted, nAdded ) HB_SYMBOL_UNUSED( nPos ) HB_SYMBOL_UNUSED( nDeleted ) - HB_SYMBOL_UNUSED( nAdded ) RETURN cRest @@ -2442,45 +2443,49 @@ STATIC FUNCTION hbide_replaceWord( qCursor, nWord, cWord, nPostn ) /*----------------------------------------------------------------------*/ -STATIC FUNCTION hbide_appendCase( qCursor, nIndent, nCurPos ) +STATIC FUNCTION hbide_appendCase( qCursor, nIndent, nCurPos, nCases, lOWise ) LOCAL i - LOCAL nCases := 3 /* CONFIGURABLE */ -// qCursor:beginEditBlock() qCursor:movePosition( QTextCursor_EndOfBlock ) FOR i := 1 TO nCases qCursor:insertBlock() qCursor:insertText( Space( nIndent ) + "CASE " ) NEXT - qCursor:insertBlock() - qCursor:insertText( Space( nIndent ) + "OTHERWISE" ) + IF lOWise + qCursor:insertBlock() + qCursor:insertText( Space( nIndent ) + "OTHERWISE" ) + ENDIF qCursor:insertBlock() qCursor:insertText( Space( nIndent ) + "ENDCASE" ) qCursor:setPosition( nCurPos ) qCursor:movePosition( QTextCursor_NextBlock ) qCursor:movePosition( QTextCursor_EndOfLine ) -// qCursor:endEditBlock() RETURN NIL /*----------------------------------------------------------------------*/ -STATIC FUNCTION hbide_appendSwitch( qCursor, nIndent, nCurPos, nTabSpaces ) +STATIC FUNCTION hbide_appendSwitch( qCursor, nIndent, nCurPos, nTabSpaces, nCases, lOWise, lExitSameLine ) LOCAL i - LOCAL nCases := 3 /* CONFIGURABLE */ -// qCursor:beginEditBlock() qCursor:movePosition( QTextCursor_EndOfBlock ) FOR i := 1 TO nCases qCursor:insertBlock() - qCursor:insertText( Space( nIndent ) + "CASE " ) - qCursor:insertBlock() - qCursor:insertText( Space( nIndent + nTabSpaces ) + "EXIT" ) + IF lExitSameLine + qCursor:insertText( Space( nIndent ) + "CASE ; EXIT" ) + ELSE + qCursor:insertText( Space( nIndent ) + "CASE " ) + qCursor:insertBlock() + qCursor:insertText( Space( nIndent + nTabSpaces ) + "EXIT" ) + ENDIF NEXT + IF lOWise + qCursor:insertBlock() + qCursor:insertText( Space( nIndent ) + "OTHERWISE" ) + ENDIF qCursor:insertBlock() qCursor:insertText( Space( nIndent ) + "ENDSWITCH" ) qCursor:setPosition( nCurPos ) -// qCursor:endEditBlock() RETURN NIL @@ -2488,12 +2493,10 @@ STATIC FUNCTION hbide_appendSwitch( qCursor, nIndent, nCurPos, nTabSpaces ) STATIC FUNCTION hbide_appendWhile( qCursor, nIndent, nCurPos ) -// qCursor:beginEditBlock() qCursor:movePosition( QTextCursor_EndOfBlock ) qCursor:insertBlock() qCursor:insertText( Space( nIndent ) + "ENDDO" ) qCursor:setPosition( nCurPos ) -// qCursor:endEditBlock() RETURN NIL @@ -2501,25 +2504,49 @@ STATIC FUNCTION hbide_appendWhile( qCursor, nIndent, nCurPos ) STATIC FUNCTION hbide_appendFor( qCursor, nIndent, nCurPos ) -// qCursor:beginEditBlock() qCursor:movePosition( QTextCursor_EndOfBlock ) qCursor:insertBlock() qCursor:insertText( Space( nIndent ) + "NEXT" ) qCursor:setPosition( nCurPos ) -// qCursor:endEditBlock() RETURN NIL /*----------------------------------------------------------------------*/ -STATIC FUNCTION hbide_appendEndif( qCursor, nIndent, nCurPos ) +STATIC FUNCTION hbide_appendIf( qCursor, nIndent, nCurPos, nTabSpaces, lElse, lEmbrace ) + + IF lEmbrace + qCursor:movePosition( QTextCursor_StartOfBlock ) + IF qCursor:movePosition( QTextCursor_NextBlock ) + /* First line after IF must be starting on same indent where IF starts ; TO qualify FOR embracing */ + IF hbide_getFrontSpacesAndWord( qCursor:block():text() ) == nIndent + /* We can confirm from developer IF TO embrace ? - Later... */ + qCursor:insertText( Space( nTabSpaces ) ) + DO WHILE qCursor:movePosition( QTextCursor_NextBlock ) + IF ! Empty( qCursor:block():text() ) + IF hbide_getFrontSpacesAndWord( qCursor:block():text() ) < nIndent + qCursor:movePosition( QTextCursor_PreviousBlock ) + EXIT + ENDIF + qCursor:insertText( Space( nTabSpaces ) ) + ENDIF + ENDDO + ENDIF + ELSE + qCursor:setPosition( nCurPos ) + ENDIF + ELSE + qCursor:setPosition( nCurPos ) + ENDIF -// qCursor:beginEditBlock() qCursor:movePosition( QTextCursor_EndOfBlock ) + IF lElse + qCursor:insertBlock() + qCursor:insertText( Space( nIndent ) + "ELSE" ) + ENDIF qCursor:insertBlock() qCursor:insertText( Space( nIndent ) + "ENDIF" ) qCursor:setPosition( nCurPos ) -// qCursor:endEditBlock() RETURN NIL @@ -2970,8 +2997,8 @@ FUNCTION hbide_isStartingKeyword( cWord, oIde ) 'function' => NIL,; 'procedure' => NIL,; 'class' => NIL,; - 'return' => NIL,; - 'method' => NIL } + 'method' => NIL,; + 'return' => NIL } ENDIF ENDIF @@ -2986,11 +3013,11 @@ FUNCTION hbide_isMinimumIndentableKeyword( cWord, oIde ) IF ! oIde:oINI:lReturnAsBeginKeyword s_b_ := { ; 'local' => NIL,; - 'static' => NIL,; - 'return' => NIL,; 'private' => NIL,; 'public' => NIL,; - 'default' => NIL } + 'static' => NIL,; + 'default' => NIL,; + 'return' => NIL } ELSE s_b_ := { ; 'local' => NIL,; diff --git a/harbour/contrib/hbide/setup.ui b/harbour/contrib/hbide/setup.ui index 2951ae3146..f08858d8aa 100644 --- a/harbour/contrib/hbide/setup.ui +++ b/harbour/contrib/hbide/setup.ui @@ -22,6 +22,9 @@ 397 + + 10 + false @@ -41,7 +44,7 @@ - 0 + 1 @@ -449,6 +452,326 @@ + + + + + 0 + 0 + 351 + 365 + + + + + + + + + 8 + 8 + 333 + 125 + + + + Closing Statements + + + true + + + + + 8 + 20 + 72 + 18 + + + + IF + + + + + + 8 + 40 + 72 + 18 + + + + FOR + + + + + + 8 + 60 + 72 + 18 + + + + DO WHILE + + + + + + 8 + 80 + 72 + 18 + + + + DO CASE + + + + + + 8 + 101 + 72 + 18 + + + + SWITCH + + + + + + 80 + 80 + 37 + 16 + + + + CASEs + + + + + + 116 + 77 + 33 + 21 + + + + 1 + + + + + + 156 + 80 + 85 + 18 + + + + OTHERWISE + + + + + + 156 + 24 + 49 + 18 + + + + ELSE + + + + + + 156 + 101 + 85 + 18 + + + + OTHERWISE + + + + + + 80 + 101 + 37 + 16 + + + + CASEs + + + + + + 116 + 100 + 29 + 21 + + + + 1 + + + + + + 240 + 101 + 89 + 18 + + + + EXIT Same Line + + + + + + 236 + 24 + 93 + 18 + + + + Embrace Lower + + + + + + + 8 + 136 + 333 + 41 + + + + Function Calls + + + false + + + + + 8 + 20 + 149 + 18 + + + + Add Clsong Parenthesis ? + + + + + + 156 + 20 + 169 + 18 + + + + Add Spaces After/Before () + + + + + + + 8 + 180 + 329 + 177 + + + + General + + + + + 8 + 16 + 185 + 18 + + + + Add Closing Body of CodeBlock ? + + + + + + 8 + 36 + 177 + 18 + + + + Add Space After := Operator ? + + + + + + 8 + 152 + 205 + 18 + + + + Format Line after ENTER is pressed ? + + + + + + 8 + 56 + 205 + 18 + + + + Align Operator := to Previous Lines ? + + + + + @@ -1889,7 +2212,7 @@ - + diff --git a/harbour/contrib/hbqt/qtgui/hbqt_hbqplaintextedit.cpp b/harbour/contrib/hbqt/qtgui/hbqt_hbqplaintextedit.cpp index 0e52d0d303..20fd719b33 100644 --- a/harbour/contrib/hbqt/qtgui/hbqt_hbqplaintextedit.cpp +++ b/harbour/contrib/hbqt/qtgui/hbqt_hbqplaintextedit.cpp @@ -218,11 +218,6 @@ void HBQPlainTextEdit::hbShowPrototype( const QString & tip, int rows, int cols Q_UNUSED( rows ); Q_UNUSED( cols ); - if( ! isCompletionTipsActive ) - { - QToolTip::hideText(); - return; - } if( tip == ( QString ) "" ) { QToolTip::hideText(); @@ -1447,27 +1442,10 @@ bool HBQPlainTextEdit::hbHandlePopup( QKeyEvent * event ) case Qt::Key_Escape : case Qt::Key_Tab : case Qt::Key_Backtab : + { event->ignore(); - return true; /* let the completer do default behavior */ - case Qt::Key_Space: - if( block ) - { - PHB_ITEM p1 = hb_itemPutNI( NULL, 21001 ); - hb_vmEvalBlockV( block, 1, p1 ); - hb_itemRelease( p1 ); - hbRefreshCompleter(); /* Watch closely */ - } - break; - case Qt::Key_ParenLeft: - if( block ) - { - PHB_ITEM p1 = hb_itemPutNI( NULL, 21002 ); - hb_vmEvalBlockV( block, 1, p1 ); - hb_itemRelease( p1 ); - } - break; - default: - break; + return true; + } } } return false;