Subversion Repositories fastphp

Rev

Rev 83 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 83 Rev 88
Line 151... Line 151...
151
 
151
 
152
procedure TSynEditFindReplace.DoReplace(dialog: TReplaceDialog; direction: TFindDirection);
152
procedure TSynEditFindReplace.DoReplace(dialog: TReplaceDialog; direction: TFindDirection);
153
var
153
var
154
  opt: TSynSearchOptions;
154
  opt: TSynSearchOptions;
155
  numReplacements: integer;
155
  numReplacements: integer;
-
 
156
  bakSelLenght: Integer;
-
 
157
  stmp: string;
-
 
158
  bakSelStart: Integer;
156
begin
159
begin
157
  try
160
  try
158
    if direction = sdDefault then direction := GetDirection(dialog);
161
    if direction = sdDefault then direction := GetDirection(dialog);
159
 
162
 
160
    opt := [];
163
    opt := [];
Line 177... Line 180...
177
    end;
180
    end;
178
 
181
 
179
    fEditor.BeginUpdate; // TODO: geht nicht?
182
    fEditor.BeginUpdate; // TODO: geht nicht?
180
    //fEditor.BeginUndoBlock;
183
    //fEditor.BeginUndoBlock;
181
    try
184
    try
-
 
185
      bakSelLenght := 0; // avoid compiler warning
-
 
186
      if ssoReplaceAll in opt then
-
 
187
      begin
-
 
188
        // Remember the selection length
-
 
189
        bakSelLenght := fEditor.SelLength;
-
 
190
        //bakSelStart := fEditor.SelStart;
-
 
191
 
-
 
192
        // Remember the selection start (we don't backup fEditor.SelStart, since the replacement might change the location)!
-
 
193
        // We assume that character #1 will not be in a text file!
-
 
194
        stmp := fEditor.Text;
-
 
195
        Insert(chr(1), stmp, fEditor.SelStart+1);
-
 
196
        //showmessage(inttostr(ord(stmp[fEditor.SelStart-1])));
-
 
197
        //showmessage(inttostr(ord(stmp[fEditor.SelStart])));
-
 
198
        //showmessage(inttostr(ord(stmp[fEditor.SelStart+1])));
-
 
199
        fEditor.Text := stmp;
-
 
200
 
-
 
201
        // When the user presses "Replace all", then we want to replace from the very beginning!
-
 
202
        fEditor.SelStart := 0;
-
 
203
        fEditor.SelLength := 0;
-
 
204
      end;
-
 
205
 
182
      numReplacements := fEditor.SearchReplace(dialog.FindText, dialog.ReplaceText, opt);
206
      numReplacements := fEditor.SearchReplace(dialog.FindText, dialog.ReplaceText, opt);
-
 
207
 
-
 
208
      if ssoReplaceAll in opt then
-
 
209
      begin
-
 
210
        stmp := fEditor.Text;
-
 
211
        bakSelStart := AnsiPos(chr(1), stmp)-1;
-
 
212
        Delete(stmp, bakSelStart+1, 1);
-
 
213
        fEditor.Text := stmp;
-
 
214
 
-
 
215
        fEditor.SelStart := bakSelStart;
-
 
216
        fEditor.SelLength := bakSelLenght;
-
 
217
 
-
 
218
        // TODO: The SelStart and SelLength were kept, but the scrollposition did not. What can we do?
-
 
219
      end;
183
    finally
220
    finally
184
      //fEditor.EndUndoBlock;
221
      //fEditor.EndUndoBlock;
185
      fEditor.EndUpdate;
222
      fEditor.EndUpdate;
186
    end;
223
    end;
187
 
224