diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 25b126051e..2249a86f00 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,21 @@ The license applies to all entries newer than 2009-04-28. */ +2012-01-03 14:39 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbide/ideconsole.prg + * Minor. + + * contrib/hbide/finddialog.ui + * Changed: the appearance and a bit of functionality of + "Find & Replace" dialog. It was occupying larger desktop + territory than needed, which, at times is too precious. + + * contrib/hbide/idefindreplace.prg + * Reworked: the way "Find What" edit control of "Find & Replace" + dialog was behaving. Now it is almost at par with XMate. + * Fixed: the window coordinates were not being maintained either + with repositioning or close via "X" button. + 2012-01-03 15:40 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * harbour/src/rtl/filebuf.c ! fixed next three integer overflows exploited by HB64 locking mode. diff --git a/harbour/contrib/hbide/finddialog.ui b/harbour/contrib/hbide/finddialog.ui index e4c5271493..04cf00d43a 100644 --- a/harbour/contrib/hbide/finddialog.ui +++ b/harbour/contrib/hbide/finddialog.ui @@ -6,8 +6,8 @@ 0 0 - 415 - 166 + 333 + 155 @@ -16,9 +16,9 @@ - 332 - 8 - 75 + 272 + 6 + 51 24 @@ -29,18 +29,21 @@ false - true + false - 332 - 106 - 75 + 272 + 98 + 51 24 + + Qt::NoFocus + Replace @@ -54,21 +57,27 @@ - 332 - 136 - 77 + 272 + 124 + 51 24 + + Qt::NoFocus + Close + + false + - 70 - 108 + 10 + 100 253 22 @@ -80,12 +89,15 @@ - 70 - 136 + 10 + 128 71 19 + + Qt::NoFocus + Global @@ -93,34 +105,24 @@ - 192 - 136 + 132 + 128 89 19 + + Qt::NoFocus + No prompting - - - - 12 - 108 - 53 - 20 - - - - Replace: - - - 70 - 60 + 10 + 52 161 41 @@ -137,6 +139,9 @@ 19 + + Qt::NoFocus + Start from cursor position @@ -150,6 +155,9 @@ 19 + + Qt::NoFocus + Entire file @@ -158,8 +166,8 @@ - 240 - 60 + 180 + 52 81 41 @@ -176,6 +184,9 @@ 19 + + Qt::NoFocus + up @@ -189,6 +200,9 @@ 19 + + Qt::NoFocus + Down @@ -197,12 +211,15 @@ - 70 - 36 + 10 + 32 81 19 + + Qt::NoFocus + Match case @@ -210,12 +227,15 @@ - 192 - 36 + 132 + 32 71 19 + + Qt::NoFocus + List only @@ -223,8 +243,8 @@ - 70 - 10 + 10 + 8 253 22 @@ -233,19 +253,6 @@ true - - - - 10 - 10 - 51 - 20 - - - - Find what: - - diff --git a/harbour/contrib/hbide/ideconsole.prg b/harbour/contrib/hbide/ideconsole.prg index f8cb67a5bc..e3938a7de7 100644 --- a/harbour/contrib/hbide/ideconsole.prg +++ b/harbour/contrib/hbide/ideconsole.prg @@ -1035,10 +1035,6 @@ METHOD hbCUIEditor:operate() keyboard( chr( K_UP ) ) DO WHILE .t. - IF hbide_setExitCuiEd() - EXIT - ENDIF - ::nRowPrev := ::nRowCur ::nColPrev := ::nColCur ::xRefresh := OBJ_REFRESH_NIL @@ -1048,7 +1044,7 @@ METHOD hbCUIEditor:operate() DO WHILE .t. ::nLastKey := inkey( 0, INKEY_ALL + HB_INKEY_GTEVENT ) - IF ::nLastKey <> K_MOUSEMOVE + IF ::nLastKey <> 0 .OR. ::nLastKey <> K_MOUSEMOVE EXIT ENDIF ENDDO diff --git a/harbour/contrib/hbide/idefindreplace.prg b/harbour/contrib/hbide/idefindreplace.prg index 8df35975b0..435ecd8b16 100644 --- a/harbour/contrib/hbide/idefindreplace.prg +++ b/harbour/contrib/hbide/idefindreplace.prg @@ -413,6 +413,8 @@ METHOD IdeSearchReplace:startFromTop() CLASS IdeFindReplace INHERIT IdeObject DATA qLineEdit + DATA qReplaceEdit + DATA cText METHOD new( oIde ) METHOD create( oIde ) @@ -421,7 +423,7 @@ CLASS IdeFindReplace INHERIT IdeObject METHOD onClickReplace() METHOD replaceSelection( cReplWith ) METHOD replace() - METHOD onClickFind() + METHOD onClickFind( nFrom ) METHOD find( lWarn ) METHOD updateFindReplaceData( cMode ) @@ -441,6 +443,8 @@ METHOD IdeFindReplace:destroy() IF !empty( ::oUI ) ::qLineEdit:disConnect( "returnPressed()" ) + ::qLineEdit:disConnect( "textChanged(QString)" ) + ::qReplaceEdit:disConnect( "returnPressed()" ) ::oUI:destroy() ENDIF @@ -464,6 +468,8 @@ METHOD IdeFindReplace:create( oIde ) ::oUI:q_radioFromCursor:setChecked( .t. ) ::oUI:q_radioDown:setChecked( .t. ) + ::oUI:connect( QEvent_Close, {|| ::oIde:oINI:cFindDialogGeometry := hbide_posAndSize( ::oUI:oWidget ) } ) + ::oUI:q_buttonFind :connect( "clicked()", {|| ::onClickFind() } ) ::oUI:q_buttonReplace:connect( "clicked()", {|| ::onClickReplace() } ) ::oUI:q_buttonClose :connect( "clicked()", {|| ::oIde:oINI:cFindDialogGeometry := hbide_posAndSize( ::oUI:oWidget ), ::oUI:hide() } ) @@ -474,32 +480,107 @@ METHOD IdeFindReplace:create( oIde ) iif( p == 1, ::oUI:q_buttonReplace:setEnabled( .f. ), NIL ) } ) ::qLineEdit := ::oUI:q_comboFindWhat:lineEdit() + ::qLineEdit:connect( "returnPressed()", {|| iif( empty( ::cText ), NIL, ; + ::qLineEdit:setText( ::cText ) ), ::cText := "", ::onClickFind( 1 ) } ) + + ::qReplaceEdit := ::oUI:q_comboReplaceWith:lineEdit() + ::qReplaceEdit:connect( "returnPressed()", {|| ::onClickReplace() } ) RETURN Self /*----------------------------------------------------------------------*/ METHOD IdeFindReplace:show() - LOCAL cText + + IF ! ::oUI:isHidden() + ::oIde:oINI:cFindDialogGeometry := hbide_posAndSize( ::oUI:oWidget ) + ::oUI:hide() + ENDIF + + ::oIde:setPosByIniEx( ::oUI:oWidget, ::oINI:cFindDialogGeometry ) ::oUI:q_buttonReplace:setEnabled( .f. ) ::oUI:q_checkGlobal:setEnabled( .f. ) ::oUI:q_checkNoPrompting:setEnabled( .f. ) ::oUI:q_checkListOnly:setChecked( .f. ) - ::oIde:setPosByIniEx( ::oUI:oWidget, ::oINI:cFindDialogGeometry ) ::oUI:q_comboFindWhat:setFocus() - IF !empty( cText := ::oEM:getSelectedText() ) - ::qLineEdit:setText( cText ) + IF ! empty( ::cText := ::oEM:getSelectedText() ) + ::qLineEdit:setText( ::cText ) + ::updateFindReplaceData( "find" ) ENDIF ::qLineEdit:selectAll() - ::oUI:show() RETURN Self /*----------------------------------------------------------------------*/ +METHOD IdeFindReplace:onClickFind( nFrom ) + LOCAL lFound, nPos, qCursor + + DEFAULT nFrom TO 0 // Click on Find Button + + IF nFrom == 0 + ::updateFindReplaceData( "find" ) + ENDIF + + IF ::oUI:q_radioEntire:isChecked() + ::oUI:q_radioFromCursor:setChecked( .t. ) + qCursor := ::qCurEdit:textCursor() + nPos := qCursor:position() + + qCursor:setPosition( 0 ) + ::qCurEdit:setTextCursor( qCursor ) + IF ! ( lFound := ::find() ) + qCursor:setPosition( nPos ) + ::qCurEdit:setTextCursor( qCursor ) + ENDIF + ELSE + lFound := ::find() + ENDIF + + IF lFound + ::oUI:q_buttonReplace:setEnabled( .t. ) + ::oUI:q_checkGlobal:setEnabled( .t. ) + ::oUI:q_checkNoPrompting:setEnabled( .t. ) + ELSE + ::oUI:q_buttonReplace:setEnabled( .f. ) + ::oUI:q_checkGlobal:setEnabled( .f. ) + ::oUI:q_checkNoPrompting:setEnabled( .f. ) + ::oUI:hide() + ::oUI:show() + ::oUI:q_comboFindWhat:setFocus() + ::qLineEdit:selectAll() + ENDIF + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeFindReplace:find( lWarn ) + LOCAL nFlags, qfocus + LOCAL cText := ::oUI:q_comboFindWhat:lineEdit():text() + LOCAL lFound := .f. + + DEFAULT lWarn TO .t. + + IF ! empty( cText ) + nFlags := 0 + nFlags += iif( ::oUI:q_checkMatchCase:isChecked(), QTextDocument_FindCaseSensitively, 0 ) + nFlags += iif( ::oUI:q_radioUp:isChecked(), QTextDocument_FindBackward, 0 ) + + IF ! ( lFound := ::oEM:getEditObjectCurrent():findEx( cText, nFlags ) ) .AND. lWarn + qFocus := ::oUI:focusWidget() + hbide_showWarning( "Cannot find : " + cText ) + qFocus:setFocus( 0 ) + ENDIF + ENDIF + + RETURN lFound + +/*----------------------------------------------------------------------*/ + METHOD IdeFindReplace:onClickReplace() ::updateFindReplaceData( "replace" ) @@ -518,17 +599,16 @@ METHOD IdeFindReplace:replaceSelection( cReplWith ) DEFAULT cReplWith TO "" qCursor := ::qCurEdit:textCursor() - IF qCursor:hasSelection() .and. !empty( cBuffer := qCursor:selectedText() ) + IF qCursor:hasSelection() .and. ! empty( cBuffer := qCursor:selectedText() ) nL := len( cBuffer ) nB := qCursor:position() - nL qCursor:beginEditBlock() qCursor:removeSelectedText() qCursor:insertText( cReplWith ) - qCursor:setPosition( nB ) - qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_KeepAnchor, len( cReplWith ) ) + qCursor:setPosition( nB + len( cReplWith ) ) ::qCurEdit:setTextCursor( qCursor ) - qCursor:endEditBlock() + ::oEM:getEditObjectCurrent():clearSelection() ENDIF RETURN Self @@ -564,72 +644,17 @@ METHOD IdeFindReplace:replace() /*----------------------------------------------------------------------*/ -METHOD IdeFindReplace:onClickFind() - LOCAL lFound, nPos, qCursor - - ::updateFindReplaceData( "find" ) - - IF ::oUI:q_radioEntire:isChecked() - ::oUI:q_radioFromCursor:setChecked( .t. ) - qCursor := ::qCurEdit:textCursor() - nPos := qCursor:position() - - qCursor:setPosition( 0 ) - ::qCurEdit:setTextCursor( qCursor ) - IF !( lFound := ::find() ) - qCursor:setPosition( nPos ) - ::qCurEdit:setTextCursor( qCursor ) - ENDIF - ELSE - lFound := ::find() - ENDIF - - IF lFound - ::oUI:q_buttonReplace:setEnabled( .t. ) - ::oUI:q_checkGlobal:setEnabled( .t. ) - ::oUI:q_checkNoPrompting:setEnabled( .t. ) - ELSE - ::oUI:q_buttonReplace:setEnabled( .f. ) - ::oUI:q_checkGlobal:setEnabled( .f. ) - ::oUI:q_checkNoPrompting:setEnabled( .f. ) - ::oUI:q_buttonFind:activateWindow() - ::oUI:q_buttonFind:setFocus() - ENDIF - - RETURN Self - -/*----------------------------------------------------------------------*/ - -METHOD IdeFindReplace:find( lWarn ) - LOCAL nFlags - LOCAL cText := ::oUI:q_comboFindWhat:lineEdit():text() - LOCAL lFound := .f. - - DEFAULT lWarn TO .t. - - IF !empty( cText ) - nFlags := 0 - nFlags += iif( ::oUI:q_checkMatchCase:isChecked(), QTextDocument_FindCaseSensitively, 0 ) - nFlags += iif( ::oUI:q_radioUp:isChecked(), QTextDocument_FindBackward, 0 ) - - IF !( lFound := ::oEM:getEditObjectCurrent():findEx( cText, nFlags ) ) .AND. lWarn - hbide_showWarning( "Cannot find : " + cText ) - ENDIF - ENDIF - - RETURN lFound - -/*----------------------------------------------------------------------*/ - METHOD IdeFindReplace:updateFindReplaceData( cMode ) - LOCAL cData + LOCAL cData, nIndex IF cMode == "find" cData := ::oUI:q_comboFindWhat:lineEdit():text() - IF !empty( cData ) - IF ascan( ::oINI:aFind, {|e| e == cData } ) == 0 + IF ! empty( cData ) + IF ( nIndex := ascan( ::oINI:aFind, {|e| e == cData } ) ) == 0 hb_ains( ::oINI:aFind, 1, cData, .t. ) ::oUI:q_comboFindWhat:insertItem( 0, cData ) + ELSE + ::oUI:q_comboFindWhat:setCurrentIndex( nIndex - 1 ) ENDIF ENDIF //