From 78ddb279db34aa53dc7d6d63a2195da1ffd180b8 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Mon, 15 Feb 2010 02:15:09 +0000 Subject: [PATCH] 2010-02-14 17:34 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/gtwvg/wvgscrlb.prg ! Defined method :configure() as VIRTUAL. * contrib/hbqt/qth/HBQPlainTextEdit.qth * contrib/hbqt/hbqt_hbqplaintextedit.cpp * contrib/hbqt/hbqt_hbqplaintextedit.h * contrib/hbqt/qtgui/HBQPlainTextEdit.cpp * contrib/hbqt/qtgui/THBQPlainTextEdit.prg + Added class variable :block which can be set with qEdit:hbSetEventBlock( bBlock ). I did not set it via the constructor as it is implementation specific. The goal was to capture mouse or other events which are consumed by parent class itself and are not forwarded to the widget. At present it is used to inform double-click event to qEdit and is scheduled to be extended. * contrib/hbqt/hbqt_misc.prg + Added method :from(), synonymous to :configure() to avoid grasping confusion. Now both syntaxes are supported: qCursor := QTextCursor():configure( qEdit:textCursor() ) qCursor := QTextCursor():from( qEdit:textCursor() ) * contrib/hbide/ideactions.prg * contrib/hbide/idedocks.prg * contrib/hbide/ideeditor.prg * contrib/hbide/idefindreplace.prg * contrib/hbide/idemisc.prg * contrib/hbide/ideprojmanager.prg + Project Management: enabled "Launch Parameters" which are supplied to the executable if "Launch..." is selected with build or otherwise. : supressed auto expansion of "Current Project" at startup. Was a constant cause of annoyance if the project tree been fairly large. + Docking Windows: reworked to occupy proper corners. Please delete idesettings.ini. ! Find_Replace Dialog: set to find from begining if "Find What" is changed. ! Code Skeletons: fixed to not append blank lines while called. : selection menu appears at the current cursor coordinates. + Editor: double-click on some word place the selection in copy buffer in case that word is selected. This feature I always wished-for in xMate. + Editor: highly .prg code suited indentation engine. It comprise so many factors to explain. Please test. I feel you will be really happy. Also let me know what else can be implemented. Code is now under my grasp and probably more ideas are already building up. --- harbour/ChangeLog | 51 +++ harbour/contrib/gtwvg/wvgscrlb.prg | 2 +- harbour/contrib/hbide/ideactions.prg | 2 + harbour/contrib/hbide/idedocks.prg | 8 +- harbour/contrib/hbide/ideeditor.prg | 388 +++++++++++------- harbour/contrib/hbide/idefindreplace.prg | 2 + harbour/contrib/hbide/idemisc.prg | 11 + harbour/contrib/hbide/ideprojmanager.prg | 29 +- .../contrib/hbqt/hbqt_hbqplaintextedit.cpp | 76 ++-- harbour/contrib/hbqt/hbqt_hbqplaintextedit.h | 3 + harbour/contrib/hbqt/hbqt_misc.prg | 1 + .../contrib/hbqt/qtgui/HBQPlainTextEdit.cpp | 8 + .../contrib/hbqt/qtgui/THBQPlainTextEdit.prg | 5 + harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth | 1 + 14 files changed, 393 insertions(+), 194 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 7ecc63d265..9c319c73e6 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,57 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-02-14 17:34 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/gtwvg/wvgscrlb.prg + ! Defined method :configure() as VIRTUAL. + + * contrib/hbqt/qth/HBQPlainTextEdit.qth + * contrib/hbqt/hbqt_hbqplaintextedit.cpp + * contrib/hbqt/hbqt_hbqplaintextedit.h + * contrib/hbqt/qtgui/HBQPlainTextEdit.cpp + * contrib/hbqt/qtgui/THBQPlainTextEdit.prg + + Added class variable :block which can be set with qEdit:hbSetEventBlock( bBlock ). + I did not set it via the constructor as it is implementation specific. + The goal was to capture mouse or other events which are consumed by + parent class itself and are not forwarded to the widget. At present + it is used to inform double-click event to qEdit and is scheduled + to be extended. + + * contrib/hbqt/hbqt_misc.prg + + Added method :from(), synonymous to :configure() to avoid grasping confusion. + Now both syntaxes are supported: + qCursor := QTextCursor():configure( qEdit:textCursor() ) + qCursor := QTextCursor():from( qEdit:textCursor() ) + + * contrib/hbide/ideactions.prg + * contrib/hbide/idedocks.prg + * contrib/hbide/ideeditor.prg + * contrib/hbide/idefindreplace.prg + * contrib/hbide/idemisc.prg + * contrib/hbide/ideprojmanager.prg + + + Project Management: enabled "Launch Parameters" which are supplied to the + executable if "Launch..." is selected with build + or otherwise. + : supressed auto expansion of "Current Project" at startup. + Was a constant cause of annoyance if the project tree + been fairly large. + + Docking Windows: reworked to occupy proper corners. + Please delete idesettings.ini. + + ! Find_Replace Dialog: set to find from begining if "Find What" is changed. + + ! Code Skeletons: fixed to not append blank lines while called. + : selection menu appears at the current cursor coordinates. + + + Editor: double-click on some word place the selection in copy buffer in case + that word is selected. This feature I always wished-for in xMate. + + + Editor: highly .prg code suited indentation engine. It comprise so many + factors to explain. Please test. I feel you will be really happy. + Also let me know what else can be implemented. Code is now + under my grasp and probably more ideas are already building up. + 2010-02-14 21:59 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbwin/tests/testdll1.prg + Displaying success/failure. diff --git a/harbour/contrib/gtwvg/wvgscrlb.prg b/harbour/contrib/gtwvg/wvgscrlb.prg index 661e7b7c9a..edb89bb1a8 100644 --- a/harbour/contrib/gtwvg/wvgscrlb.prg +++ b/harbour/contrib/gtwvg/wvgscrlb.prg @@ -136,7 +136,7 @@ CLASS WvgScrollBar INHERIT WvgWindow, DataRef METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) VIRTUAL METHOD destroy() METHOD handleEvent( nMessage, aNM ) diff --git a/harbour/contrib/hbide/ideactions.prg b/harbour/contrib/hbide/ideactions.prg index 401fcc323d..7114581bd5 100644 --- a/harbour/contrib/hbide/ideactions.prg +++ b/harbour/contrib/hbide/ideactions.prg @@ -367,6 +367,8 @@ METHOD IdeActions:buildToolBar() oTBar:addItem( ::getAction( "ZoomOut" ), , , , , , "ZoomOut" ) oTBar:addItem( , , , , , nSep ) + oTBar:oWidget:setAllowedAreas( Qt_TopToolBarArea ) + /* ComboBox to Manage Views */ ::oIde:qViewsCombo := QComboBox():new() oTBar:oWidget:addWidget( ::qViewsCombo ) diff --git a/harbour/contrib/hbide/idedocks.prg b/harbour/contrib/hbide/idedocks.prg index 5895eb5869..0a69431be0 100644 --- a/harbour/contrib/hbide/idedocks.prg +++ b/harbour/contrib/hbide/idedocks.prg @@ -258,6 +258,8 @@ METHOD IdeDocks:buildDialog() ::oDlg:close := {|| hbide_getYesNo( "hbIDE is about to be closed!", "Are you sure?" ) } ::oDlg:oWidget:setDockOptions( QMainWindow_AllowTabbedDocks + QMainWindow_ForceTabbedDocks ) ::oDlg:oWidget:setTabPosition( Qt_BottomDockWidgetArea, QTabWidget_South ) + ::oDlg:oWidget:setCorner( Qt_BottomLeftCorner, Qt_LeftDockWidgetArea ) + ::oDlg:oWidget:setCorner( Qt_BottomRightCorner, Qt_RightDockWidgetArea ) ::oIde:oDa := ::oDlg:drawingArea @@ -783,7 +785,8 @@ METHOD IdeDocks:buildSkeletonWidget() ::oSkeltn:oWidget := QDockWidget():new( ::oDlg:oWidget ) ::oSkeltn:oWidget:setObjectName( "dockSkeleton" ) ::oDlg:addChild( ::oSkeltn ) - ::oSkeltn:oWidget:setFeatures( QDockWidget_DockWidgetClosable + QDockWidget_DockWidgetFloatable ) + ::oSkeltn:oWidget:setFeatures( QDockWidget_DockWidgetClosable + QDockWidget_DockWidgetFloatable + ; + QDockWidget_DockWidgetVerticalTitleBar ) ::oSkeltn:oWidget:setAllowedAreas( Qt_RightDockWidgetArea ) ::oSkeltn:oWidget:setWindowTitle( "Code Skeletons" ) ::oSkeltn:oWidget:setFocusPolicy( Qt_NoFocus ) @@ -793,7 +796,6 @@ METHOD IdeDocks:buildSkeletonWidget() ::oSkeltn:oWidget:setWidget( ::oIde:oSkeltnUI:oWidget ) ::oDlg:oWidget:addDockWidget_1( Qt_RightDockWidgetArea, ::oSkeltn:oWidget, Qt_Horizontal ) - ::oSkeltn:hide() oUI := ::oIde:oSkeltnUI @@ -811,6 +813,8 @@ METHOD IdeDocks:buildSkeletonWidget() //::oSkeltnUI:q_editCode:setFont( ::oFont:oWidget ) aeval( ::aSkltns, {|e_| ::oSkeltnUI:q_listNames:addItem( e_[ 1 ] ) } ) + ::oSkeltn:hide() + RETURN Self /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbide/ideeditor.prg b/harbour/contrib/hbide/ideeditor.prg index e1191bb47e..cded75edc0 100644 --- a/harbour/contrib/hbide/ideeditor.prg +++ b/harbour/contrib/hbide/ideeditor.prg @@ -1353,6 +1353,8 @@ CLASS IdeEdit INHERIT IdeObject DATA lModified INIT .F. DATA lIndentIt INIT .f. DATA lUpdatePrevWord INIT .f. + DATA lCopyWhenDblClicked INIT .f. + DATA cCurLineText INIT "" METHOD new( oEditor, nMode ) METHOD create( oEditor, nMode ) @@ -1376,6 +1378,8 @@ CLASS IdeEdit INHERIT IdeObject METHOD findLastIndent() METHOD reLayMarkButtons() METHOD presentSkeletons() + METHOD handleCurrentIndent() + METHOD handlePreviousWord( lUpdatePrevWord ) ENDCLASS @@ -1416,8 +1420,11 @@ METHOD IdeEdit:create( oEditor, nMode ) ::connectEditSignals( Self ) - Qt_Events_Connect( ::pEvents, ::qEdit, QEvent_KeyPress, {|p| ::execKeyEvent( 101, QEvent_KeyPress, p ) } ) - Qt_Events_Connect( ::pEvents, ::qEdit, QEvent_Wheel , {|p| ::execKeyEvent( 102, QEvent_Wheel , p ) } ) + Qt_Events_Connect( ::pEvents, ::qEdit, QEvent_KeyPress , {|p| ::execKeyEvent( 101, QEvent_KeyPress, p ) } ) + Qt_Events_Connect( ::pEvents, ::qEdit, QEvent_Wheel , {|p| ::execKeyEvent( 102, QEvent_Wheel , p ) } ) + Qt_Events_Connect( ::pEvents, ::qEdit, QEvent_MouseButtonDblClick, {|p| ::execKeyEvent( 103, QEvent_MouseButtonDblClick, p ) } ) + + ::qEdit:hbSetEventBlock( {|p| ::execKeyEvent( 115, 1001, p ) } ) RETURN Self @@ -1447,9 +1454,9 @@ METHOD IdeEdit:disconnectEditSignals( oEdit ) ::disConnect( oEdit:qEdit, "textChanged()" ) ::disConnect( oEdit:qEdit, "selectionChanged()" ) ::disConnect( oEdit:qEdit, "cursorPositionChanged()" ) + ::disConnect( oEdit:qEdit, "copyAvailable(bool)" ) #if 0 - ::disConnect( oEdit:qEdit, "copyAvailable(bool)" ) ::disConnect( oEdit:qEdit, "modificationChanged(bool)" ) ::disConnect( oEdit:qEdit, "updateRequest(QRect,int)" ) ::disConnect( oEdit:qEdit, "redoAvailable(bool)" ) @@ -1467,9 +1474,9 @@ METHOD IdeEdit:connectEditSignals( oEdit ) ::Connect( oEdit:qEdit, "textChanged()" , {| | ::execEvent( 2, oEdit, ) } ) ::Connect( oEdit:qEdit, "selectionChanged()" , {|p | ::execEvent( 6, oEdit, p ) } ) ::Connect( oEdit:qEdit, "cursorPositionChanged()" , {| | ::execEvent( 9, oEdit, ) } ) + ::Connect( oEdit:qEdit, "copyAvailable(bool)" , {|p | ::execEvent( 3, oEdit, p ) } ) #if 0 - ::Connect( oEdit:qEdit, "copyAvailable(bool)" , {|p | ::execEvent( 3, oEdit, p ) } ) ::Connect( oEdit:qEdit, "modificationChanged(bool)" , {|p | ::execEvent( 4, oEdit, p ) } ) ::Connect( oEdit:qEdit, "updateRequest(QRect,int)" , {|p,p1| ::execEvent( 8, oEdit, p, p1 ) } ) ::Connect( oEdit:qEdit, "redoAvailable(bool)" , {|p | ::execEvent( 5, oEdit, p ) } ) @@ -1481,7 +1488,7 @@ METHOD IdeEdit:connectEditSignals( oEdit ) /*----------------------------------------------------------------------*/ METHOD IdeEdit:execEvent( nMode, oEdit, p, p1 ) - LOCAL pAct, qAct, n, qCursor, qEdit, oo, nSpaces + LOCAL pAct, qAct, n, qCursor, qEdit, oo HB_SYMBOL_UNUSED( p1 ) @@ -1515,10 +1522,12 @@ METHOD IdeEdit:execEvent( nMode, oEdit, p, p1 ) ENDCASE ENDIF EXIT + CASE textChanged hbide_dbg( "textChanged()" ) ::oEditor:setTabImage( qEdit ) EXIT + CASE selectionChanged hbide_dbg( "selectionChanged()" ) ::oEditor:qCqEdit := qEdit @@ -1533,29 +1542,23 @@ METHOD IdeEdit:execEvent( nMode, oEdit, p, p1 ) qEdit:highlightSelectedColumns( ::isColumnSelectionEnabled ) ::oDK:setStatusText( SB_PNL_SELECTEDCHARS, len( qCursor:selectedText() ) ) - EXIT + CASE cursorPositionChanged hbide_dbg( "cursorPositionChanged()" ) ::oEditor:dispEditInfo( qEdit ) - IF ::lUpdatePrevWord - ::lUpdatePrevWord := .f. - hbide_handlePreviousWord( ::qEdit ) - ENDIF - - IF ::lIndentIt - ::lIndentIt := .f. - IF ( nSpaces := ::findLastIndent() ) > 0 - qCursor := QTextCursor():configure( ::qEdit:textCursor() ) - qCursor:insertText( space( nSpaces ) ) - ENDIF - ENDIF - + ::handlePreviousWord( ::lUpdatePrevWord ) + ::handleCurrentIndent() EXIT - #if 0 + CASE copyAvailable - //hbide_dbg( "copyAvailable(bool)", p ) + IF p .AND. ::lCopyWhenDblClicked + ::qEdit:copy() + ENDIF + ::lCopyWhenDblClicked := .f. EXIT + + #if 0 CASE modificationChanged //hbide_dbg( "modificationChanged(bool)", p ) EXIT @@ -1607,6 +1610,7 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p ) EXIT CASE Qt_Key_Return CASE Qt_Key_Enter + ::handlePreviousWord( .t. ) ::lIndentIt := .t. EXIT CASE Qt_Key_Tab @@ -1663,9 +1667,20 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p ) ENDSWITCH EXIT + CASE QEvent_Wheel EXIT + CASE QEvent_MouseButtonDblClick + ::lCopyWhenDblClicked := .t. + EXIT + + CASE 1001 + IF p == QEvent_MouseButtonDblClick + ::lCopyWhenDblClicked := .t. + ENDIF + EXIT + ENDSWITCH RETURN .F. /* Important */ @@ -1673,19 +1688,18 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p ) /*----------------------------------------------------------------------*/ METHOD IdeEdit:presentSkeletons() - LOCAL qCrs, qMenu, pAct, cAct, n, a_, qAct, nPos, nCol, s + LOCAL qCrs, qMenu, pAct, cAct, n, a_, qAct, nPos, nCol, s, qRc IF !empty( ::aSkltns ) qCrs := QTextCursor():configure( ::qEdit:textCursor() ) - - //qRc := QRect():configure( ::qEdit:cursorRect() ) + qRc := QRect():configure( ::qEdit:cursorRect( qCrs ) ) qMenu := QMenu():new( ::qEdit ) FOR EACH a_ IN ::aSkltns qMenu:addAction( a_[ 1 ] ) NEXT - pAct := qMenu:exec_1( ::qEdit:mapToGlobal( QPoint():new( 100,100 ) ) ) + pAct := qMenu:exec_1( ::qEdit:mapToGlobal( QPoint():new( qRc:x(), qRc:y() ) ) ) IF !hbqt_isEmptyQtPointer( pAct ) qAct := QAction():configure( pAct ) cAct := qAct:text() @@ -1698,7 +1712,7 @@ METHOD IdeEdit:presentSkeletons() s := space( nCol ) + s ENDIF NEXT - qCrs:insertText( hbide_arrayToMemo( a_ ) ) + qCrs:insertText( hbide_arrayToMemoEx( a_ ) ) qCrs:setPosition( nPos ) ::qEdit:setTextCursor( qCrs ) ENDIF @@ -1824,6 +1838,90 @@ METHOD IdeEdit:caseInvert() /*----------------------------------------------------------------------*/ +METHOD IdeEdit:handlePreviousWord( lUpdatePrevWord ) + LOCAL qCursor, qTextBlock, cText, cWord, nB, nL, qEdit, lPrevOnly, nCol, nSpace, nSpaces, nOff + + IF ! lUpdatePrevWord + RETURN Self + ENDIF + ::lUpdatePrevWord := .f. + + qEdit := ::qEdit + + qCursor := QTextCursor():configure( qEdit:textCursor() ) + qTextBlock := QTextBlock():configure( qCursor:block() ) + cText := qTextBlock:text() + nCol := qCursor:columnNumber() + IF ( substr( cText, nCol - 1, 1 ) == " " ) + RETURN nil + ENDIF + nSpace := iif( substr( cText, nCol, 1 ) == " ", 1, 0 ) + cWord := hbide_getPreviousWord( cText, nCol + 1 ) + + IF !empty( cWord ) .AND. hbide_isHarbourKeyword( cWord ) + lPrevOnly := left( lower( ltrim( cText ) ), len( cWord ) ) == lower( cWord ) + + nL := len( cWord ) + nSpace + nB := qCursor:position() - nL + + qCursor:beginEditBlock() + qCursor:setPosition( nB ) + qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_KeepAnchor, nL ) + qCursor:removeSelectedText() + qCursor:insertText( upper( cWord ) + space( nSpace ) ) + qCursor:endEditBlock() + qEdit:setTextCursor( qCursor ) + + IF hbide_isStartingKeyword( cWord ) + IF lPrevOnly + qCursor:setPosition( nB ) + IF ( nCol := qCursor:columnNumber() ) > 0 + qCursor:beginEditBlock() + qCursor:movePosition( QTextCursor_StartOfBlock ) + qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_KeepAnchor, nCol ) + qCursor:removeSelectedText() + qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_MoveAnchor, nL ) + qCursor:endEditBlock() + qEdit:setTextCursor( qCursor ) + ENDIF + ENDIF + + ELSEIF hbide_isMinimumIndentableKeyword( cWord ) + IF lPrevOnly + qCursor:setPosition( nB ) + IF ( nCol := qCursor:columnNumber() ) >= 0 + qCursor:beginEditBlock() + qCursor:movePosition( QTextCursor_StartOfBlock ) + qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_KeepAnchor, nCol ) + qCursor:removeSelectedText() + qCursor:insertText( space( ::nTabSpaces ) ) + qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_MoveAnchor, nL ) + qEdit:setTextCursor( qCursor ) + qCursor:endEditBlock() + ENDIF + ENDIF + + ELSEIF hbide_isIndentableKeyword( cWord ) + IF lPrevOnly + nSpaces := hbide_getFrontSpacesAndWord( cText ) + IF nSpaces > 0 .AND. ( nOff := nSpaces % ::nTabSpaces ) > 0 + qCursor:setPosition( nB ) + qCursor:beginEditBlock() + qCursor:movePosition( QTextCursor_PreviousCharacter, QTextCursor_KeepAnchor, nOff ) + qCursor:removeSelectedText() + qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_MoveAnchor, nL ) + qEdit:setTextCursor( qCursor ) + qCursor:endEditBlock() + ENDIF + ENDIF + ENDIF + + ENDIF + + RETURN .t. + +/*----------------------------------------------------------------------*/ + METHOD IdeEdit:findLastIndent() LOCAL qCursor, qTextBlock, cText, cWord LOCAL nSpaces := 0 @@ -1831,6 +1929,7 @@ METHOD IdeEdit:findLastIndent() qCursor := QTextCursor():configure( ::qEdit:textCursor() ) qTextBlock := QTextBlock():configure( qCursor:block() ) + qTextBlock := QTextBlock():configure( qTextBlock:previous() ) DO WHILE .t. IF !( qTextBlock:isValid() ) EXIT @@ -1851,8 +1950,114 @@ METHOD IdeEdit:findLastIndent() /*----------------------------------------------------------------------*/ +METHOD IdeEdit:handleCurrentIndent() + LOCAL qCursor, nSpaces + + IF ::lIndentIt + ::lIndentIt := .f. + IF ( nSpaces := ::findLastIndent() ) > 0 + qCursor := QTextCursor():configure( ::qEdit:textCursor() ) + qCursor:insertText( space( nSpaces ) ) + ENDIF + ENDIF + + RETURN Self + +/*----------------------------------------------------------------------*/ + +FUNCTION hbide_getPreviousWord( cText, nPos ) + LOCAL cWord, n + + cText := alltrim( substr( cText, 1, nPos ) ) + IF ( n := rat( " ", cText ) ) > 0 + cWord := substr( cText, n + 1 ) + ELSE + cWord := cText + ENDIF + + RETURN cWord + +/*----------------------------------------------------------------------*/ + +FUNCTION hbide_getFirstWord( cText ) + LOCAL cWord, n + + cText := alltrim( cText ) + IF ( n := at( " ", cText ) ) > 0 + cWord := left( cText, n-1 ) + ELSE + cWord := cText + ENDIF + + RETURN cWord + +/*----------------------------------------------------------------------*/ + +FUNCTION hbide_getFrontSpacesAndWord( cText, cWord ) + LOCAL n := 0 + + DO WHILE .t. + IF substr( cText, ++n, 1 ) != " " + EXIT + ENDIF + ENDDO + n-- + + cWord := hbide_getFirstWord( cText ) + + RETURN n + +/*----------------------------------------------------------------------*/ + +FUNCTION hbide_isStartingKeyword( cWord ) + STATIC s_b_ := { ; + 'function' => NIL,; + 'class' => NIL,; + 'method' => NIL } + + RETURN Lower( cWord ) $ s_b_ + +/*----------------------------------------------------------------------*/ + +FUNCTION hbide_isMinimumIndentableKeyword( cWord ) + STATIC s_b_ := { ; + 'local' => NIL,; + 'static' => NIL,; + 'return' => NIL,; + 'default' => NIL } + + RETURN Lower( cWord ) $ s_b_ + +/*----------------------------------------------------------------------*/ + +FUNCTION hbide_isIndentableKeyword( cWord ) + STATIC s_b_ := { ; + 'if' => NIL,; + 'else' => NIL,; + 'elseif' => NIL,; + 'docase' => NIL,; + 'case' => NIL,; + 'otherwise' => NIL,; + 'do' => NIL,; + 'while' => NIL,; + 'switch' => NIL,; + 'for' => NIL,; + 'next' => NIL,; + 'begin' => NIL,; + 'sequence' => NIL,; + 'try' => NIL,; + 'catch' => NIL,; + 'always' => NIL,; + 'recover' => NIL,; + 'finally' => NIL } + + RETURN Lower( cWord ) $ s_b_ + +/*----------------------------------------------------------------------*/ + FUNCTION hbide_isHarbourKeyword( cWord ) - STATIC s_b_ := { 'function' => NIL,; + STATIC s_b_ := { ; + 'function' => NIL,; 'return' => NIL,; 'static' => NIL,; 'local' => NIL,; @@ -1904,133 +2109,4 @@ FUNCTION hbide_isHarbourKeyword( cWord ) /*----------------------------------------------------------------------*/ -FUNCTION hbide_isIndentableKeyword( cWord ) - LOCAL s_b_ := { 'function' => NIL,; - 'if' => NIL,; - 'else' => NIL,; - 'elseif' => NIL,; - 'docase' => NIL,; - 'case' => NIL,; - 'otherwise' => NIL,; - 'do' => NIL,; - 'while' => NIL,; - 'switch' => NIL,; - 'for' => NIL,; - 'class' => NIL,; - 'method' => NIL,; - 'begin' => NIL,; - 'sequence' => NIL,; - 'try' => NIL,; - 'catch' => NIL,; - 'always' => NIL,; - 'recover' => NIL,; - 'finally' => NIL } - - RETURN Lower( cWord ) $ s_b_ - -/*----------------------------------------------------------------------*/ - -FUNCTION hbide_isStartingKeyword( cWord ) - STATIC s_b_ := { 'function' => NIL,; - 'method' => NIL } - - RETURN Lower( cWord ) $ s_b_ - -/*----------------------------------------------------------------------*/ - -FUNCTION hbide_handlePreviousWord( qEdit ) - LOCAL qCursor, qTextBlock, cText, nPos, cWord, nB, nL - - qCursor := QTextCursor():configure( qEdit:textCursor() ) - qTextBlock := QTextBlock():configure( qCursor:block() ) - cText := qTextBlock:text() - nPos := qCursor:columnNumber() - IF ( substr( cText, nPos - 1, 1 ) == " " ) - RETURN nil - ENDIF - - cWord := hbide_getPreviousWord( cText, nPos + 1 ) - - IF !empty( cWord ) - nL := len( cWord + " " ) - nB := qCursor:position() - nL - - IF hbide_isHarbourKeyword( cWord ) - //qEdit:setToolTip( cWord ) - - qCursor:beginEditBlock() - qCursor:setPosition( nB ) - qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_KeepAnchor, nL ) - qCursor:removeSelectedText() - qCursor:insertText( upper( cWord ) + " " ) - - qEdit:setTextCursor( qCursor ) - qCursor:endEditBlock() - ENDIF - - IF hbide_isStartingKeyword( cWord ) - qCursor:setPosition( nB ) - nPos := qCursor:columnNumber() - - IF nPos > 0 - qCursor:beginEditBlock() - qCursor:movePosition( QTextCursor_StartOfBlock ) - - qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_KeepAnchor, nPos ) - qCursor:removeSelectedText() - - qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_MoveAnchor, nL ) - qCursor:endEditBlock() - ENDIF - ENDIF - ENDIF - RETURN .t. - -/*----------------------------------------------------------------------*/ - -FUNCTION hbide_getPreviousWord( cText, nPos ) - LOCAL cWord, n - - cText := alltrim( substr( cText, 1, nPos ) ) - IF ( n := rat( " ", cText ) ) > 0 - cWord := substr( cText, n + 1 ) - ELSE - cWord := cText - ENDIF - - RETURN cWord - -/*----------------------------------------------------------------------*/ - -FUNCTION hbide_getFirstWord( cText ) - LOCAL cWord, n - - cText := alltrim( cText ) - IF ( n := at( " ", cText ) ) > 0 - cWord := left( cText, n-1 ) - ELSE - cWord := cText - ENDIF - - RETURN cWord - -/*----------------------------------------------------------------------*/ - -FUNCTION hbide_getFrontSpacesAndWord( cText, cWord ) - LOCAL n := 0 - - DO WHILE .t. - IF substr( cText, ++n, 1 ) != " " - EXIT - ENDIF - ENDDO - n-- - - cWord := hbide_getFirstWord( cText ) - - RETURN n - -/*----------------------------------------------------------------------*/ - - diff --git a/harbour/contrib/hbide/idefindreplace.prg b/harbour/contrib/hbide/idefindreplace.prg index 8235e2fd5c..d80a371a44 100644 --- a/harbour/contrib/hbide/idefindreplace.prg +++ b/harbour/contrib/hbide/idefindreplace.prg @@ -128,6 +128,8 @@ METHOD IdeFindReplace:create( oIde ) ::oUI:signal( "buttonClose" , "clicked()", ; {|| ::oIde:aIni[ INI_HBIDE, FindDialogGeometry ] := hbide_posAndSize( ::oUI:oWidget ), ::oUI:hide() } ) + ::oUI:signal( "comboFindWhat", "editTextChanged(text)", {|| ::oUI:q_radioEntire:setChecked( .t. ) } ) + ::oUI:signal( "comboFindWhat", "currentIndexChanged(text)", ; {|p| ::oIde:oSBar:getItem( SB_PNL_SEARCH ):caption := "FIND: " + p } ) diff --git a/harbour/contrib/hbide/idemisc.prg b/harbour/contrib/hbide/idemisc.prg index 864584caab..b9278d39be 100644 --- a/harbour/contrib/hbide/idemisc.prg +++ b/harbour/contrib/hbide/idemisc.prg @@ -490,6 +490,17 @@ FUNCTION hbide_arrayToMemo( a_ ) /*----------------------------------------------------------------------*/ +FUNCTION hbide_arrayToMemoEx( a_ ) + LOCAL s := "" + + aeval( a_, {|e| s += e + CRLF } ) + + s := substr( s, 1, len( s ) - 2 ) + + RETURN s + +/*----------------------------------------------------------------------*/ + FUNCTION hbide_memoToArray( s ) LOCAL aLine := hb_ATokens( StrTran( RTrim( s ), CRLF, _EOL ), _EOL ) LOCAL nNewSize := 0 diff --git a/harbour/contrib/hbide/ideprojmanager.prg b/harbour/contrib/hbide/ideprojmanager.prg index f823b778f2..23d7c29238 100644 --- a/harbour/contrib/hbide/ideprojmanager.prg +++ b/harbour/contrib/hbide/ideprojmanager.prg @@ -622,9 +622,9 @@ METHOD IdeProjManager:fetchProperties() ::oUI:q_editSources :setPlainText( hbide_arrayToMemo( ::aPrjProps[ PRJ_PRP_SOURCES , 1 ] ) ) ::oUI:q_editMetaData :setPlainText( hbide_arrayToMemo( ::aPrjProps[ PRJ_PRP_METADATA, 1 ] ) ) + ::oUI:q_editLaunchParams:setText( ::oProject:launchParams ) + ::oUI:q_editLaunchExe:setText( ::oProject:launchProgram ) #if 0 - ::oUI:q_editLaunchParams:setText() - ::oUI:q_editLaunchExe:setText() ::oUI:q_editHbp:setPlainText() #endif ENDIF @@ -1223,7 +1223,7 @@ METHOD IdeProjManager:setCurrentProject( cProjectName ) IF !empty( oItem := hbide_findProjTreeItem( ::oIDE, ::cWrkProject, "Project Name" ) ) oItem:oWidget:setForeground( 0, ::qBrushWrkProject ) //oItem:oWidget:setBackground( 0, ::qBrushWrkProject ) - hbide_expandChildren( ::oIDE, oItem ) + //hbide_expandChildren( ::oIDE, oItem ) ::oProjTree:oWidget:setCurrentItem( oItem:oWidget ) ENDIF ENDIF @@ -1402,7 +1402,11 @@ METHOD IdeProjManager:closeProject( cProjectTitle ) METHOD IdeProjManager:promptForPath( cObjPathName, cTitle, cObjFileName, cObjPath2, cObjPath3 ) LOCAL cTemp, cPath, cFile - cTemp := ::oProject:expandMeta( ::oUI:qObj[ cObjPathName ]:Text() ) + IF hb_isObject( ::oProject ) + cTemp := ::oProject:expandMeta( ::oUI:qObj[ cObjPathName ]:Text() ) + ELSE + cTemp := "" + ENDIF IF !hb_isChar( cObjFileName ) cPath := hbide_fetchADir( ::oDlg, cTitle, cTemp ) @@ -1421,9 +1425,9 @@ METHOD IdeProjManager:promptForPath( cObjPathName, cTitle, cObjFileName, cObjPat IF Right( cPath, 1 ) $ '/\' cPath := Left( cPath, Len( cPath ) - 1 ) ENDIF - - cPath := ::oProject:applyMeta( cPath ) - + IF hb_isObject( ::oProject ) + cPath := ::oProject:applyMeta( cPath ) + ENDIF ::oUI:qObj[ cObjPathName ]:setText( cPath ) IF hb_isChar( cObjPath2 ) .AND. Empty( ::oUI:qObj[ cObjPath2 ]:Text() ) @@ -1623,7 +1627,7 @@ METHOD IdeProjManager:finished( nExitCode, nExitStatus, oProcess ) * 03/01/2010 - 09:24:50 */ METHOD IdeProjManager:launchProject( cProject ) - LOCAL cTargetFN, cTmp, oProject, qProcess + LOCAL cTargetFN, cTmp, oProject, qProcess, qStr IF empty( cProject ) cProject := ::oPM:getCurrentProject() @@ -1650,10 +1654,17 @@ METHOD IdeProjManager:launchProject( cProject ) #if 1 qProcess := QProcess():new() qProcess:setWorkingDirectory( hbide_pathToOSPath( oProject:wrkDirectory ) ) - qProcess:startDetached_2( cTargetFN ) + IF !empty( oProject:launchParams ) + qStr := QStringList():new() + qStr:append( oProject:launchParams ) + qProcess:startDetached_1( cTargetFN, qStr ) + ELSE + qProcess:startDetached_2( cTargetFN ) + ENDIF qProcess:waitForStarted() qProcess:pPtr := NIL qProcess := NIL + #else ::oProcess := HbpProcess():new() ::oProcess:output := {|s| hbide_dbg( s ) } diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp index 3461a95fab..775cd049d8 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp @@ -102,6 +102,9 @@ HBQPlainTextEdit::HBQPlainTextEdit( QWidget * parent ) : QPlainTextEdit( parent HBQPlainTextEdit::~HBQPlainTextEdit() { + if( block ) + hb_itemRelease( block ); + disconnect( this, SIGNAL( blockCountChanged( int ) ) ); disconnect( this, SIGNAL( updateRequest( const QRect &, int ) ) ); disconnect( this, SIGNAL( cursorPositionChanged() ) ); @@ -109,6 +112,52 @@ HBQPlainTextEdit::~HBQPlainTextEdit() delete lineNumberArea; } +void HBQPlainTextEdit::hbSetEventBlock( PHB_ITEM pBlock ) +{ + if( pBlock ) + { + block = hb_itemNew( pBlock ); + } +} + +bool HBQPlainTextEdit::event( QEvent *event ) +{ + if( event->type() == QEvent::KeyPress ) + { + QKeyEvent *keyEvent =( QKeyEvent * )event; + if( ( keyEvent->key() == Qt::Key_Tab ) && ( keyEvent->modifiers() & Qt::ControlModifier ) ) + { + return false; + } + else + { + if( ( keyEvent->key() == Qt::Key_Tab ) && !( keyEvent->modifiers() & Qt::ControlModifier & Qt::AltModifier & Qt::ShiftModifier ) ) + { + this->insertTab( 0 ); + return true; + } + else if( ( keyEvent->key() == Qt::Key_Backtab ) && ( keyEvent->modifiers() & Qt::ShiftModifier ) ) + { + this->insertTab( 1 ); + return true; + } + } + } + return QPlainTextEdit::event( event ); +} + +void HBQPlainTextEdit::mouseDoubleClickEvent( QMouseEvent *event ) +{ + HB_TRACE( HB_TR_ALWAYS, ( "void HBQPlainTextEdit::mouseDblClickEvent( QMouseEvent * %p )", event ) ); + if( block ) + { + PHB_ITEM p1 = hb_itemPutNI( NULL, QEvent::MouseButtonDblClick ); + hb_vmEvalBlockV( block, 1, p1 ); + hb_itemRelease( p1 ); + } + QPlainTextEdit::mouseDoubleClickEvent( event ); +} + void HBQPlainTextEdit::paintEvent( QPaintEvent * event ) { QPainter painter( viewport() ); @@ -184,6 +233,7 @@ void HBQPlainTextEdit::lineNumberAreaPaintEvent( QPaintEvent *event ) ++blockNumber; } } + #if 0 void HBQPlainTextEdit::contextMenuEvent( QContextMenuEvent *event ) { @@ -343,32 +393,6 @@ void HBQPlainTextEdit::setSpaces( int newSpaces ) } } -bool HBQPlainTextEdit::event( QEvent *event ) -{ - if( event->type() == QEvent::KeyPress ) - { - QKeyEvent *keyEvent =( QKeyEvent * )event; - if( ( keyEvent->key() == Qt::Key_Tab ) && ( keyEvent->modifiers() & Qt::ControlModifier ) ) - { - return false; - } - else - { - if( ( keyEvent->key() == Qt::Key_Tab ) && !( keyEvent->modifiers() & Qt::ControlModifier & Qt::AltModifier & Qt::ShiftModifier ) ) - { - this->insertTab( 0 ); - return true; - } - else if( ( keyEvent->key() == Qt::Key_Backtab ) && ( keyEvent->modifiers() & Qt::ShiftModifier ) ) - { - this->insertTab( 1 ); - return true; - } - } - } - return QPlainTextEdit::event( event ); -} - int HBQPlainTextEdit::getIndex( const QTextCursor &crQTextCursor ) { QTextBlock b; diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h index 708fba8b62..e5a497443b 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h @@ -76,6 +76,7 @@ public: HBQPlainTextEdit( QWidget * parent = 0 ); ~HBQPlainTextEdit(); + PHB_ITEM block; QColor m_currentLineColor; long m_matchingBegin; long m_matchingEnd; @@ -103,6 +104,7 @@ public: bool numberBlockVisible() { return numberBlock; } void highlightCurrentLine( bool b ) { highlightCurLine = b; } bool highlightCurrentLine() { return highlightCurLine; } + void hbSetEventBlock( PHB_ITEM pBlock ); private: QVector bookMark; @@ -125,6 +127,7 @@ private: protected: bool event( QEvent * event ); void resizeEvent( QResizeEvent * event ); + void mouseDoubleClickEvent( QMouseEvent * event ); #if 0 void contextMenuEvent( QContextMenuEvent * event ); void keyPressEvent( QKeyEvent * event ); diff --git a/harbour/contrib/hbqt/hbqt_misc.prg b/harbour/contrib/hbqt/hbqt_misc.prg index 4db7123b25..9166fc9028 100644 --- a/harbour/contrib/hbqt/hbqt_misc.prg +++ b/harbour/contrib/hbqt/hbqt_misc.prg @@ -61,6 +61,7 @@ CLASS HbQtObjectHandler VAR pPtr METHOD configure( xObject ) + METHOD from( xObject ) INLINE ::configure( xObject ) ERROR HANDLER onError() diff --git a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp index 281266dfe2..18bef60afa 100644 --- a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp +++ b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp @@ -259,6 +259,14 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT_HIGHLIGHTCURRENTLINE_1 ) hb_retl( hbqt_par_HBQPlainTextEdit( 1 )->highlightCurrentLine() ); } +/* + * void hbSetEventBlock( PHB_ITEM block ) + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_HBSETEVENTBLOCK ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->hbSetEventBlock( hb_param( 2, HB_IT_ANY ) ); +} + /* * void updateLineNumberAreaWidth( int newBlockCount ) */ diff --git a/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg b/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg index fb50fd333a..f1f63ef2a0 100644 --- a/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg +++ b/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg @@ -80,6 +80,7 @@ CREATE CLASS HBQPlainTextEdit INHERIT HbQtObjectHandler, QPlainTextEdit METHOD numberBlockVisible_1() METHOD highlightCurrentLine( lB ) METHOD highlightCurrentLine_1() + METHOD hbSetEventBlock( xBlock ) METHOD updateLineNumberAreaWidth( nNewBlockCount ) METHOD caseUpper() METHOD caseLower() @@ -163,6 +164,10 @@ METHOD HBQPlainTextEdit:highlightCurrentLine_1() RETURN Qt_HBQPlainTextEdit_highlightCurrentLine_1( ::pPtr ) +METHOD HBQPlainTextEdit:hbSetEventBlock( xBlock ) + RETURN Qt_HBQPlainTextEdit_hbSetEventBlock( ::pPtr, xBlock ) + + METHOD HBQPlainTextEdit:updateLineNumberAreaWidth( nNewBlockCount ) RETURN Qt_HBQPlainTextEdit_updateLineNumberAreaWidth( ::pPtr, nNewBlockCount ) diff --git a/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth b/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth index 9c92c3d96f..572abacb73 100644 --- a/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth +++ b/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth @@ -108,6 +108,7 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT ) bool numberBlockVisible() void highlightCurrentLine(bool b) bool highlightCurrentLine() + void hbSetEventBlock( PHB_ITEM block )