From e638eb574983a3e7d48c15ec77a1aa56d421b372 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Wed, 15 Aug 2012 06:50:03 +0000 Subject: [PATCH] 2012-08-14 23:45 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbide/edit.prg * contrib/hbide/editor.prg % Optimized: collection of variables: a) longer than 3 characters, b) variable is collected if space,coma,collon " ,:" follows it. + Started: matching of control structures, a work-in-progress. --- harbour/ChangeLog | 9 +++++ harbour/contrib/hbide/edit.prg | 58 ++++++++++++++++++++++++++------ harbour/contrib/hbide/editor.prg | 20 +++++------ 3 files changed, 67 insertions(+), 20 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 92983e137b..92f8edafa8 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,15 @@ The license applies to all entries newer than 2009-04-28. */ +2012-08-14 23:45 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbide/edit.prg + * contrib/hbide/editor.prg + % Optimized: collection of variables: + a) longer than 3 characters, + b) variable is collected if space,coma,collon " ,:" follows it. + + + Started: matching of control structures, a work-in-progress. + 2012-08-14 20:07 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbide/edit.prg * contrib/hbide/editor.prg diff --git a/harbour/contrib/hbide/edit.prg b/harbour/contrib/hbide/edit.prg index 701fb6802f..dc8733568a 100644 --- a/harbour/contrib/hbide/edit.prg +++ b/harbour/contrib/hbide/edit.prg @@ -143,7 +143,7 @@ CLASS IdeEdit INHERIT IdeObject METHOD create( oIde, oEditor, nMode ) METHOD destroy() METHOD execEvent( nMode, p, p1 ) - METHOD execKeyEvent( nMode, nEvent, p, p1 ) + METHOD execKeyEvent( nMode, nEvent, p, p1, p2 ) METHOD connectEditSignals() METHOD disconnectEditSignals() @@ -251,6 +251,7 @@ CLASS IdeEdit INHERIT IdeObject METHOD highlightPage() METHOD reformatLine( nPos, nDeleted, nAdded ) METHOD handleTab( key ) + METHOD matchPair( x, y ) ENDCLASS @@ -323,9 +324,8 @@ METHOD IdeEdit:create( oIde, oEditor, nMode ) ::qEdit:connect( QEvent_FocusIn , {| | ::execKeyEvent( 104, QEvent_FocusIn ) } ) ::qEdit:connect( QEvent_Resize , {| | ::execKeyEvent( 106, QEvent_Resize ) } ) ::qEdit:connect( QEvent_FocusOut , {| | ::execKeyEvent( 105, QEvent_FocusOut ) } ) - ::qEdit:connect( QEvent_MouseButtonDblClick, {|p| ::execKeyEvent( 103, QEvent_MouseButtonDblClick, p ) } ) - ::qEdit:hbSetEventBlock( {|p,p1| ::execKeyEvent( 115, 1001, p, p1 ) } ) + ::qEdit:hbSetEventBlock( {|p,p1,p2| ::execKeyEvent( 115, 1001, p, p1, p2 ) } ) ::qTimer := QTimer() ::qTimer:setInterval( 2000 ) @@ -355,6 +355,7 @@ METHOD IdeEdit:destroy() ::qEdit:disconnect( QEvent_FocusOut ) ::qEdit:disconnect( QEvent_Resize ) ::qEdit:disconnect( QEvent_MouseButtonDblClick ) + ::qEdit:disconnect( QEvent_MouseMove ) ::disconnectEditSignals() @@ -548,7 +549,7 @@ METHOD IdeEdit:execEvent( nMode, p, p1 ) /*----------------------------------------------------------------------*/ -METHOD IdeEdit:execKeyEvent( nMode, nEvent, p, p1 ) +METHOD IdeEdit:execKeyEvent( nMode, nEvent, p, p1, p2 ) LOCAL key, kbm, lAlt, lCtrl, lShift HB_SYMBOL_UNUSED( nMode ) @@ -641,12 +642,15 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p, p1 ) EXIT CASE QEvent_Wheel EXIT - CASE QEvent_MouseButtonDblClick + CASE QEvent_MouseButtonDblClick /* Not being received: tobe investigated */ ::lCopyWhenDblClicked := .t. ::clickFuncHelp() EXIT CASE 1001 /* Fired from hbqt_hbqplaintextedit.cpp */ SWITCH p + CASE QEvent_MouseButtonPress + ::matchPair( p1, p2 ) + EXIT CASE 21000 /* Sends Block Info { t,l,b,r,mode,state } hbGetBlockInfo() */ ::aSelectionInfo := p1 ::oDK:setButtonState( "SelectionMode", ::aSelectionInfo[ 5 ] > 1 ) @@ -1777,6 +1781,27 @@ METHOD IdeEdit:unHighlight() /*----------------------------------------------------------------------*/ +METHOD IdeEdit:matchPair( x, y ) + LOCAL qCursor, cWord + + qCursor := ::qEdit:cursorForPosition( ::qEdit:mapFromGlobal( QPoint( x,y ) ) ) + IF ! qCursor:isNull() + qCursor:select( QTextCursor_WordUnderCursor ) + cWord := qCursor:selectedText() + SWITCH cWord + CASE "IF" + EXIT + CASE "ENDIF" + EXIT + CASE "ENDDO" + EXIT + ENDSWITCH + ENDIF + + RETURN NIL + +/*----------------------------------------------------------------------*/ + METHOD IdeEdit:highlightAll( cText ) LOCAL qDoc, qFormat, qCursor, qFormatHL, qCur, lModified @@ -1792,7 +1817,7 @@ METHOD IdeEdit:highlightAll( cText ) qCur := ::getCursor() qCur:beginEditBlock() - qCursor := QTextCursor( "QTextDocument", qDoc ) + qCursor := QTextCursor( qDoc ) qFormat := qCursor:charFormat() qFormatHL := qFormat qFormatHL:setBackground( QBrush( QColor( Qt_yellow ) ) ) @@ -2311,11 +2336,24 @@ METHOD IdeEdit:reformatLine( nPos, nDeleted, nAdded ) qCursor:setPosition( nPostn ) ENDIF - ELSEIF cCWord == " " .AND. ! Empty( cPWord ) .AND. ! ( Left( cPWord, 1 ) $ ":=,;<>/?'[]{}()-\|~`!@#$%^&*" ) - IF ! cPWord $ ::oEM:hEditingWords - ::oEM:hEditingWords[ cPWord ] := cPWord - ::oEM:updateCompleter() + ENDIF + + IF cCWord == " " .AND. ! Empty( cPWord ) .AND. ! ( Left( cPWord, 1 ) $ "`~!@#$%^&*()+1234567890-=+[]{}|\':;?/>.<," ) + IF Len( cPWord ) > 3 + IF ! cPWord $ ::oEM:hEditingWords + ::oEM:hEditingWords[ cPWord ] := cPWord + ::oEM:updateCompleter() + ENDIF ENDIF + + ELSEIF cCWord $ ",:" .AND. ! Empty( cPPWord ) .AND. ! ( Left( cPPWord, 1 ) $ "`~!@#$%^&*()+1234567890-=+[]{}|\':;?/>.<," ) + IF Len( cPPWord ) > 3 + IF ! cPPWord $ ::oEM:hEditingWords + ::oEM:hEditingWords[ cPPWord ] := cPPWord + ::oEM:updateCompleter() + ENDIF + ENDIF + ENDIF /* Group II operations */ diff --git a/harbour/contrib/hbide/editor.prg b/harbour/contrib/hbide/editor.prg index 9433f0e06e..feb124b605 100644 --- a/harbour/contrib/hbide/editor.prg +++ b/harbour/contrib/hbide/editor.prg @@ -350,22 +350,20 @@ METHOD IdeEditsManager:updateCompleter() k_:= {} FOR EACH s IN ::aProtos - s := alltrim( s ) - IF ::oINI:lCompletionWithArgs - IF ascan( k_, s ) == 0 - aadd( k_, s ) - ENDIF - ELSE + // s := alltrim( s ) + IF ! ::oINI:lCompletionWithArgs IF ( n := at( "(", s ) ) == 0 IF ( n := at( " ", s ) ) > 0 - aadd( k_, substr( s, 1, n - 1 ) ) - ELSE - aadd( k_, s ) + s := substr( s, 1, n - 1 ) ENDIF ELSE - aadd( k_, trim( substr( s, 1, n - 1 ) ) ) + s := substr( s, 1, n - 1 ) ENDIF ENDIF + s := alltrim( s ) + IF ascan( k_, s ) == 0 + aadd( k_, s ) + ENDIF NEXT asort( k_, , , {|e,f| lower( e ) < lower( f ) } ) @@ -382,6 +380,8 @@ METHOD IdeEditsManager:updateCompleter() ::qCompleter:setCompletionMode( QCompleter_PopupCompletion ) ::qCompleter:popup():setAlternatingRowColors( .t. ) ::qCompleter:popup():setFont( QFont( "Courier New", 8 ) ) + ::qCompleter:popup():setMaximumWidth( 400 ) + ::qCompleter:popup():setHorizontalScrollBarPolicy ( Qt_ScrollBarAsNeeded ) ::qCompleter:connect( "activated(QString)", {|p| ::execEvent( __qcompleter_activated__, p ) } )