[DEVELOPMENT ENVIRONMENT]
* NEW: Modify the behaviour of the "Replace" command. Now the text is searched only if it has not been just replaced. git-svn-id: svn://localhost/gambas/trunk@5176 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
cf5a5d8c8f
commit
a707a2cb8e
2 changed files with 69 additions and 52 deletions
|
@ -422,7 +422,7 @@ msgstr ""
|
|||
#: FPasteTable.form:107 FPropertyComponent.form:221 FPropertyProject.form:745
|
||||
#: FProxy.form:57 FReportBorderChooser.form:48 FReportBrushChooser.form:34
|
||||
#: FReportCoordChooser.form:26 FReportPaddingChooser.form:75 FSave.form:28
|
||||
#: FSaveProjectAs.form:76 FSearch.class:847 FSelectExtraFile.form:43
|
||||
#: FSaveProjectAs.form:76 FSearch.class:864 FSelectExtraFile.form:43
|
||||
#: FSelectIcon.form:86 FSnippet.form:57 FTableChooser.form:68 FText.form:41
|
||||
#: FTextEditor.class:597 FTranslate.class:627 Project.module:440
|
||||
msgid "Cancel"
|
||||
|
@ -1336,7 +1336,7 @@ msgstr ""
|
|||
msgid "Show search window"
|
||||
msgstr ""
|
||||
|
||||
#: FDebugInfo.form:303 FSearch.class:468 FTranslate.class:588
|
||||
#: FDebugInfo.form:303 FSearch.class:485 FTranslate.class:588
|
||||
msgid "Search string cannot be found."
|
||||
msgstr ""
|
||||
|
||||
|
@ -4042,23 +4042,23 @@ msgstr ""
|
|||
msgid "Replace &all"
|
||||
msgstr ""
|
||||
|
||||
#: FSearch.class:470
|
||||
#: FSearch.class:487
|
||||
msgid "Search string replaced once."
|
||||
msgstr ""
|
||||
|
||||
#: FSearch.class:472
|
||||
#: FSearch.class:489
|
||||
msgid "Search string replaced &1 times."
|
||||
msgstr ""
|
||||
|
||||
#: FSearch.class:717
|
||||
#: FSearch.class:734
|
||||
msgid "One match"
|
||||
msgstr ""
|
||||
|
||||
#: FSearch.class:719
|
||||
#: FSearch.class:736
|
||||
msgid "&1 matches"
|
||||
msgstr ""
|
||||
|
||||
#: FSearch.class:847
|
||||
#: FSearch.class:864
|
||||
msgid "Do you really want to replace every string?"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -392,6 +392,7 @@ Private Sub Run(iAction As Integer)
|
|||
Dim iTry As Integer
|
||||
Dim nReplace As Integer
|
||||
Dim hEditor As FEditor
|
||||
Dim iLastPos As Integer
|
||||
|
||||
If InitSearch() Then Return
|
||||
ResetBrowse
|
||||
|
@ -404,62 +405,78 @@ Private Sub Run(iAction As Integer)
|
|||
Endif
|
||||
|
||||
aResult = GrepFile($hCurrent)
|
||||
|
||||
DO_IT_AGAIN:
|
||||
|
||||
iCurrentPos = $hCurrent.GetPosition()
|
||||
|
||||
If iAction And DO_REPLACE And If nReplace = 0 Then
|
||||
If iAction And GO_BACKWARD Then
|
||||
Inc iCurrentPos
|
||||
Else
|
||||
Dec iCurrentPos
|
||||
Endif
|
||||
Endif
|
||||
|
||||
If aResult.Count Then
|
||||
|
||||
For iTry = 1 To aResult.Count
|
||||
If iAction And DO_REPLACE And If iAction And DO_ALL Then
|
||||
|
||||
Try $hCurrent.Editor.Begin
|
||||
While aResult.Count
|
||||
If $hCurrent.SetPosition(aResult[0], False) Then Break
|
||||
Inc nReplace
|
||||
$hCurrent.Replace(ReplaceString)
|
||||
DoReplace(aResult, 0, ReplaceString)
|
||||
Wend
|
||||
Try $hCurrent.Editor.End
|
||||
|
||||
Else
|
||||
|
||||
iCurrentPos = $hCurrent.GetPosition()
|
||||
iLastPos = iCurrentPos
|
||||
|
||||
If Not $hCurrent.GetSelection() Or If iAction And DO_REPLACE Then
|
||||
If iAction And GO_BACKWARD Then
|
||||
|
||||
For iInd = aResult.Max To 0 Step -1
|
||||
iPos = aResult[iInd].Pos
|
||||
If iPos < iCurrentPos Then Break
|
||||
Next
|
||||
|
||||
If iPos >= iCurrentPos Then
|
||||
iInd = aResult.Max
|
||||
iPos = aResult[iInd].Pos
|
||||
Endif
|
||||
|
||||
Inc iCurrentPos
|
||||
Else
|
||||
|
||||
For iInd = 0 To aResult.Max
|
||||
iPos = aResult[iInd].Pos
|
||||
If iPos > iCurrentPos Then Break
|
||||
Next
|
||||
|
||||
If iPos <= iCurrentPos Then
|
||||
iInd = 0
|
||||
iPos = aResult[iInd].Pos
|
||||
Endif
|
||||
|
||||
Dec iCurrentPos
|
||||
Endif
|
||||
Endif
|
||||
|
||||
If aResult.Count Then
|
||||
|
||||
If Not $hCurrent.SetPosition(aResult[iInd], False) Then
|
||||
If iAction And DO_REPLACE Then
|
||||
For iTry = 1 To aResult.Count
|
||||
|
||||
If iAction And GO_BACKWARD Then
|
||||
|
||||
For iInd = aResult.Max To 0 Step -1
|
||||
iPos = aResult[iInd].Pos
|
||||
If iPos < iCurrentPos Then Break
|
||||
Next
|
||||
|
||||
If iPos >= iCurrentPos Then
|
||||
iInd = aResult.Max
|
||||
iPos = aResult[iInd].Pos
|
||||
Endif
|
||||
|
||||
Else
|
||||
|
||||
For iInd = 0 To aResult.Max
|
||||
iPos = aResult[iInd].Pos
|
||||
If iPos > iCurrentPos Then Break
|
||||
Next
|
||||
|
||||
If iPos <= iCurrentPos Then
|
||||
iInd = 0
|
||||
iPos = aResult[iInd].Pos
|
||||
Endif
|
||||
|
||||
Endif
|
||||
|
||||
If $hCurrent.SetPosition(aResult[iInd], False) Then Goto FIND_NEXT
|
||||
|
||||
If iAction And DO_REPLACE And If iPos = iLastPos Then
|
||||
$hCurrent.Replace(ReplaceString)
|
||||
DoReplace(aResult, iInd, ReplaceString)
|
||||
iAction = iAction And Not DO_REPLACE
|
||||
Else
|
||||
Return
|
||||
Endif
|
||||
Inc nReplace
|
||||
If (iAction And DO_ALL) = 0 Then Return
|
||||
Goto DO_IT_AGAIN
|
||||
Endif
|
||||
|
||||
FIND_NEXT:
|
||||
|
||||
iCurrentPos = iPos
|
||||
iCurrentPos = iPos
|
||||
|
||||
Next
|
||||
|
||||
Next
|
||||
Endif
|
||||
|
||||
Endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue