2012-01-24 18:00 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
* contrib/hbide/idefindreplace.prg
* contrib/hbide/idesources.prg
+ Implemented: <Replace> option in <Find in Files> protocol.
Please test and forward your suggessions as to what can be
improved hereunder.
This commit is contained in:
@@ -16,6 +16,13 @@
|
||||
The license applies to all entries newer than 2009-04-28.
|
||||
*/
|
||||
|
||||
2012-01-24 18:00 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
|
||||
* contrib/hbide/idefindreplace.prg
|
||||
* contrib/hbide/idesources.prg
|
||||
+ Implemented: <Replace> option in <Find in Files> protocol.
|
||||
Please test and forward your suggessions as to what can be
|
||||
improved hereunder.
|
||||
|
||||
2012-01-24 15:19 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
|
||||
* contrib/hbide/idedocks.prg
|
||||
* contrib/hbide/idemain.prg
|
||||
|
||||
@@ -203,7 +203,7 @@ METHOD IdeUpDown:destroy()
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
//
|
||||
// IdeSearchReplace - Extended Window at the bottom
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
CLASS IdeSearchReplace INHERIT IdeObject
|
||||
@@ -420,7 +420,7 @@ CLASS IdeFindReplace INHERIT IdeObject
|
||||
METHOD create( oIde )
|
||||
METHOD destroy()
|
||||
METHOD show()
|
||||
METHOD onClickReplace()
|
||||
METHOD onClickReplace( nFrom )
|
||||
METHOD replaceSelection( cReplWith )
|
||||
METHOD replace()
|
||||
METHOD onClickFind( nFrom )
|
||||
@@ -470,21 +470,20 @@ METHOD IdeFindReplace:create( oIde )
|
||||
|
||||
::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() } )
|
||||
::oUI:q_comboFindWhat:connect( "editTextChanged(QString)", {|| ::oUI:q_radioEntire:setChecked( .t. ) } )
|
||||
::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() } )
|
||||
::oUI:q_comboFindWhat:connect( "editTextChanged(QString)" , {| | ::oUI:q_radioEntire:setChecked( .t. ) } )
|
||||
::oUI:q_comboFindWhat:connect( "currentIndexChanged(QString)", {|p| ::oIde:oSBar:getItem( SB_PNL_SEARCH ):caption := "FIND: " + p } )
|
||||
::oUI:q_checkListOnly:connect( "stateChanged(int)", {|p| ;
|
||||
::oUI:q_comboReplaceWith:setEnabled( p == 0 ), ;
|
||||
iif( p == 1, ::oUI:q_buttonReplace:setEnabled( .f. ), NIL ) } )
|
||||
::oUI:q_checkListOnly:connect( "stateChanged(int)" , {|p| ::oUI:q_comboReplaceWith:setEnabled( p == 0 ), ;
|
||||
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 ) } )
|
||||
::qLineEdit:setText( ::cText ) ), ::cText := "", ::onClickFind( 1 ) } )
|
||||
|
||||
::qReplaceEdit := ::oUI:q_comboReplaceWith:lineEdit()
|
||||
::qReplaceEdit:connect( "returnPressed()", {|| ::onClickReplace() } )
|
||||
::qReplaceEdit:connect( "returnPressed()", {|| ::onClickReplace( 1 ) } )
|
||||
|
||||
RETURN Self
|
||||
|
||||
@@ -581,9 +580,12 @@ METHOD IdeFindReplace:find( lWarn )
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeFindReplace:onClickReplace()
|
||||
METHOD IdeFindReplace:onClickReplace( nFrom )
|
||||
|
||||
::updateFindReplaceData( "replace" )
|
||||
DEFAULT nFrom TO 0 // Click on Find Button
|
||||
IF nFrom == 0
|
||||
::updateFindReplaceData( "replace" )
|
||||
ENDIF
|
||||
|
||||
IF ::oUI:q_comboReplaceWith:isEnabled()
|
||||
::replace()
|
||||
@@ -609,6 +611,7 @@ METHOD IdeFindReplace:replaceSelection( cReplWith )
|
||||
qCursor:setPosition( nB + len( cReplWith ) )
|
||||
::qCurEdit:setTextCursor( qCursor )
|
||||
::oEM:getEditObjectCurrent():clearSelection()
|
||||
qCursor:endEditBlock()
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
@@ -741,6 +744,7 @@ CLASS IdeFindInFiles INHERIT IdeObject
|
||||
METHOD execEvent( cEvent, p )
|
||||
METHOD execContextMenu( p )
|
||||
METHOD buildUI()
|
||||
METHOD replaceAll()
|
||||
|
||||
ENDCLASS
|
||||
|
||||
@@ -899,6 +903,7 @@ METHOD IdeFindInFiles:execEvent( cEvent, p )
|
||||
EXIT
|
||||
|
||||
CASE "buttonRepl"
|
||||
::replaceAll()
|
||||
EXIT
|
||||
|
||||
CASE "buttonStop"
|
||||
@@ -960,6 +965,75 @@ METHOD IdeFindInFiles:execEvent( cEvent, p )
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeFindInFiles:replaceAll()
|
||||
LOCAL nL, nB, qCursor, aFind
|
||||
LOCAL isOpen := .f.
|
||||
LOCAL isModified := .f.
|
||||
LOCAL cSource := ""
|
||||
|
||||
IF empty( ::cReplWith := ::oUI:q_comboRepl:currentText() )
|
||||
RETURN Self
|
||||
ENDIF
|
||||
nL := len( ::cReplWith )
|
||||
|
||||
IF ! hbide_getYesNo( "Starting REPLACE operation", "No way to interrupt", "Critical" )
|
||||
RETURN Self
|
||||
ENDIF
|
||||
|
||||
FOR EACH aFind IN ::aInfo
|
||||
IF aFind[ 1 ] == -2
|
||||
IF ! ( cSource == aFind[ 2 ] )
|
||||
IF ! empty( cSource )
|
||||
IF ! isOpen
|
||||
::oSM:closeSource( , .f., .f., .f. )
|
||||
ELSE
|
||||
IF ! isModified
|
||||
::oSM:saveSource()
|
||||
ENDIF
|
||||
ENDIF
|
||||
ENDIF
|
||||
cSource := aFind[ 2 ]
|
||||
IF ( isOpen := ::oEM:isOpen( cSource ) )
|
||||
::oEM:setSourceVisible( cSource )
|
||||
isModified := ::oEM:getEditorCurrent():qDocument:isModified()
|
||||
ELSE
|
||||
::oSM:editSource( cSource, 0, 0, 0, NIL, NIL, .f., .t. )
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
qCursor := ::oIde:qCurEdit:textCursor()
|
||||
qCursor:setPosition( 0 )
|
||||
qCursor:movePosition( QTextCursor_Down, QTextCursor_MoveAnchor, aFind[ 3 ] - 1 )
|
||||
qCursor:movePosition( QTextCursor_Right, QTextCursor_MoveAnchor, aFind[ 4 ] - 1 )
|
||||
qCursor:movePosition( QTextCursor_Right, QTextCursor_KeepAnchor, len( aFind[ 5 ] ) )
|
||||
::qCurEdit:setTextCursor( qCursor )
|
||||
|
||||
nB := qCursor:position()
|
||||
|
||||
qCursor:beginEditBlock()
|
||||
qCursor:removeSelectedText()
|
||||
qCursor:insertText( ::cReplWith )
|
||||
qCursor:setPosition( nB + nL )
|
||||
::qCurEdit:setTextCursor( qCursor )
|
||||
::oEM:getEditObjectCurrent():clearSelection()
|
||||
qCursor:endEditBlock()
|
||||
ENDIF
|
||||
NEXT
|
||||
|
||||
IF ! empty( cSource )
|
||||
IF ! isOpen
|
||||
::oSM:closeSource( , .f., .f., .f. )
|
||||
ELSE
|
||||
IF ! isModified
|
||||
::oSM:saveSource()
|
||||
ENDIF
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeFindInFiles:execContextMenu( p )
|
||||
LOCAL nLine, qCursor, qMenu, qAct, cAct, cFind
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ CLASS IdeSourcesManager INHERIT IdeObject
|
||||
METHOD saveSource( nTab, lCancel, lAs )
|
||||
METHOD saveNamedSource( cSource )
|
||||
METHOD editSource( cSourceFile, nPos, nHPos, nVPos, cTheme, cView, lAlert, lVisible, aBookMarks )
|
||||
METHOD closeSource( nTab, lCanCancel, lCanceled )
|
||||
METHOD closeSource( nTab, lCanCancel, lCanceled, lAsk )
|
||||
METHOD closeAllSources( lCanCancel )
|
||||
METHOD closeAllOthers( nTab )
|
||||
METHOD saveAllSources()
|
||||
@@ -215,7 +215,7 @@ METHOD IdeSourcesManager:saveSource( nTab, lCancel, lAs )
|
||||
LOCAL oEdit, lNew, cBuffer, qDocument, nIndex, cSource, cFileTemp
|
||||
LOCAL cFileToSave, cFile, cExt, cNewFile, oItem
|
||||
|
||||
DEFAULT nTab TO ::EM:getTabCurrent()
|
||||
DEFAULT nTab TO ::oEM:getTabCurrent()
|
||||
DEFAULT lAs TO .F.
|
||||
|
||||
lCancel := .F.
|
||||
@@ -293,11 +293,12 @@ METHOD IdeSourcesManager:saveSource( nTab, lCancel, lAs )
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeSourcesManager:closeSource( nTab, lCanCancel, lCanceled )
|
||||
METHOD IdeSourcesManager:closeSource( nTab, lCanCancel, lCanceled, lAsk )
|
||||
LOCAL lSave, n, oEditor
|
||||
|
||||
DEFAULT nTab TO ::oEM:getTabCurrent()
|
||||
|
||||
DEFAULT lAsk TO .t.
|
||||
|
||||
IF !empty( oEditor := ::oEM:getEditorByTabPosition( nTab ) )
|
||||
|
||||
DEFAULT lCanCancel TO .F.
|
||||
@@ -314,8 +315,11 @@ METHOD IdeSourcesManager:closeSource( nTab, lCanCancel, lCanceled )
|
||||
lSave := ( n == QMessageBox_Yes )
|
||||
|
||||
ELSE
|
||||
lSave := hbide_getYesNo( oEditor:oTab:Caption, "has been modified, save this source?", 'Save?' )
|
||||
|
||||
IF lAsk
|
||||
lSave := hbide_getYesNo( oEditor:oTab:Caption, "has been modified, save this source?", 'Save?' )
|
||||
ELSE
|
||||
lSave := .t.
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
IF lSave .AND. !( ::saveSource( nTab, @lCanceled ) )
|
||||
|
||||
Reference in New Issue
Block a user