SynEdit: Syncro-Edit, fixed interference with trim space

git-svn-id: trunk@33158 -
This commit is contained in:
martin 2011-10-29 22:44:58 +00:00
parent cd8bcdaa55
commit fafe5534bc
2 changed files with 28 additions and 16 deletions

View File

@ -219,7 +219,8 @@ type
procedure DoSelectionChanged(Sender: TObject);
procedure DoScanSelection(Data: PtrInt);
procedure DoOnDeactivate; override;
procedure DoBeforeEdit(aX, aY, aCount, aLineBrkCnt: Integer; aUndoRedo: Boolean); override;
procedure DoPreActiveEdit(aX, aY, aCount, aLineBrkCnt: Integer; aUndoRedo: Boolean);
override;
function MaybeHandleMouseAction(var AnInfo: TSynEditMouseActionInfo;
HandleActionProc: TSynEditMouseActionHandler): Boolean;
@ -1023,6 +1024,7 @@ begin
if FWordIndex.MultiWordCount = 0 then exit;
Mode := spseEditing;
Active := True;
AreaMarkupEnabled := True;
SetUndoStart;
@ -1100,7 +1102,7 @@ begin
If (not SelectionObj.SelAvail) or (SelectionObj.ActiveSelectionMode = smColumn) then begin
FLastSelStart := Point(-1,-1);
FLastSelEnd := Point(-1,-1);
if Active then begin
if Active or PreActive then begin
FWordIndex.Clear;
Editor.Invalidate;
Active := False;
@ -1116,7 +1118,7 @@ begin
Cells.Clear;
AreaMarkupEnabled := False;
MarkupEnabled := False;
Active := True;
PreActive := True;
end;
Mode := spseSelecting;
Markup.GlyphAtLine := -1;
@ -1237,15 +1239,12 @@ begin
inherited DoOnDeactivate;
end;
procedure TSynPluginSyncroEdit.DoBeforeEdit(aX, aY, aCount, aLineBrkCnt: Integer; aUndoRedo: Boolean);
procedure TSynPluginSyncroEdit.DoPreActiveEdit(aX, aY, aCount, aLineBrkCnt: Integer;
aUndoRedo: Boolean);
begin
if (Mode = spseSelecting) then begin
FWordIndex.Clear;
Active := False;
Mode := spseInvalid;
end
else
inherited DoBeforeEdit(aX, aY, aCount, aLineBrkCnt, aUndoRedo);
end;
function TSynPluginSyncroEdit.MaybeHandleMouseAction(var AnInfo: TSynEditMouseActionInfo;
@ -1253,7 +1252,7 @@ function TSynPluginSyncroEdit.MaybeHandleMouseAction(var AnInfo: TSynEditMouseAc
var
r: TRect;
begin
Result := Active and
Result := (Active or PreActive) and
( ((Mode = spseSelecting) and (MarkupEnabled = True)) or
(Mode = spseEditing) );
if not Result then exit;
@ -1323,7 +1322,7 @@ procedure TSynPluginSyncroEdit.TranslateKey(Sender: TObject; Code: word; SState:
var
keys: TSynEditKeyStrokes;
begin
if (not Active) or Handled then
if (not (Active or PreActive)) or Handled then
exit;
keys := nil;
@ -1367,7 +1366,7 @@ procedure TSynPluginSyncroEdit.ProcessSynCommand(Sender: TObject; AfterProcessin
var
Cmd: TSynEditorCommand;
begin
if Handled or AfterProcessing or not Active then exit;
if Handled or AfterProcessing or not (Active or PreActive) then exit;
if Mode = spseSelecting then begin
// todo: finish word-hash calculations / check if any cells exist

View File

@ -179,6 +179,7 @@ type
fMarkupInfoArea: TSynSelectedColor;
FOnActivate: TNotifyEvent;
FOnDeactivate: TNotifyEvent;
FPreActive: Boolean;
function GetActive: Boolean;
procedure SetActive(const AValue: Boolean);
@ -195,6 +196,7 @@ type
procedure DoLinesEdited(Sender: TSynEditStrings; aLinePos, aBytePos, aCount,
aLineBrkCnt: Integer; aText: String);
procedure ApplyChangeList;
procedure DoPreActiveEdit(aX, aY, aCount, aLineBrkCnt: Integer; aUndoRedo: Boolean); virtual;
procedure DoBeforeEdit(aX, aY, aCount, aLineBrkCnt: Integer; aUndoRedo: Boolean); virtual;
procedure DoAfterEdit(aX, aY: Integer; aUndoRedo: Boolean); virtual;
procedure DoPaintLockStarted; virtual;
@ -216,6 +218,7 @@ type
procedure Clear;
property Enabled: Boolean read FEnabled write SetEnabled;
property Active: Boolean read GetActive write SetActive;
property PreActive: Boolean read FPreActive write FPreActive; // e.g. collecting words => Reacts to LinesEdited
property MarkupInfo: TSynSelectedColor read FMarkupInfo;
property MarkupInfoCurrent: TSynSelectedColor read FMarkupInfoCurrent;
@ -753,7 +756,7 @@ begin
FMarkup := CreateMarkup;
FMarkup.Cells := FCells;
FMarkup.CurrentCell := FCurrentCell;
FMarkup.Enabled := Active;
FMarkup.Enabled := (Active or PreActive) and FMarkupEnabled;
TSynEditMarkupManager(MarkupMgr).AddMarkUp(FMarkup);
FMarkupArea := TSynPluginSyncronizedEditMarkupArea.Create(Editor);
FMarkupArea.Cells := FCells;
@ -789,7 +792,7 @@ begin
IsActive := Active;
FEnabled := AValue;
if FMarkup <> nil then
FMarkup.Enabled := Active and FMarkupEnabled;
FMarkup.Enabled := (Active or PreActive) and FMarkupEnabled;
if FMarkupArea <> nil then
FMarkupArea.Enabled := Active and FAreaMarkupEnabled;
if IsActive <> Active then begin
@ -804,7 +807,7 @@ begin
if FMarkupEnabled = AValue then exit;
FMarkupEnabled := AValue;
if FMarkup <> nil then
FMarkup.Enabled := Active and FMarkupEnabled;
FMarkup.Enabled := (Active or PreActive) and FMarkupEnabled;
end;
procedure TSynPluginSyncronizedEditBase.MarkupChanged(AMarkup: TObject);
@ -834,8 +837,9 @@ var
begin
IsActive := Active;
FActive := AValue;
PreActive := False; // change in active, always disables PreActive
if FMarkup <> nil then
FMarkup.Enabled := Active and FMarkupEnabled;
FMarkup.Enabled := (Active or PreActive) and FMarkupEnabled;
if FMarkupArea <> nil then
FMarkupArea.Enabled := Active and FAreaMarkupEnabled;
if IsActive <> Active then begin
@ -886,7 +890,10 @@ var
edit: Boolean;
CellAtPos: Integer;
begin
if not Active then exit;
if not Active then begin
if PreActive then DoPreActiveEdit(aBytePos, aLinePos, aCount, aLineBrkCnt, IsUndoing or IsRedoing);
exit;
end;
Pos := Point(aBytePos, aLinePos);
Pos2 := Pos;
if not FEditing then
@ -992,6 +999,12 @@ begin
FChangeList.Clear;
end;
procedure TSynPluginSyncronizedEditBase.DoPreActiveEdit(aX, aY, aCount, aLineBrkCnt: Integer;
aUndoRedo: Boolean);
begin
//
end;
procedure TSynPluginSyncronizedEditBase.DoBeforeEdit(aX, aY, aCount, aLineBrkCnt: Integer; aUndoRedo: Boolean);
begin
(* Do Nothing *);