SynEdit: implemented option for not overwriting none-persistent blocks

git-svn-id: trunk@20994 -
This commit is contained in:
martin 2009-07-28 15:40:48 +00:00
parent 0b32b2d284
commit a74da44672
6 changed files with 47 additions and 13 deletions

View File

@ -203,7 +203,7 @@ type
eoKeepCaretX, // When moving through lines w/o Cursor Past EOL, keeps the X position of the cursor
eoNoCaret, // Makes it so the caret is never visible
eoNoSelection, // Disables selecting text
eoRightMouseMovesCursor, // Deprecated, now controlled vie MouseActions
eoRightMouseMovesCursor, // DEPRECATED, now controlled vie MouseActions
// When clicking with the right mouse for a popup menu, move the cursor to that location
eoScrollByOneLess, // Forces scrolling to be one less
eoScrollHintFollows, //TODO The scroll hint follows the mouse when scrolling vertically
@ -234,7 +234,8 @@ type
eoAlwaysVisibleCaret, // Move caret to be always visible when scrolling
eoEnhanceEndKey, // end key jumps to visual/hard line end whichever is nearer
eoFoldedCopyPaste, // Remember folds in copy/paste operations
eoPersistentBlock // Keep block if caret moves away or text is edited
eoPersistentBlock, // Keep block if caret moves away or text is edited
eoOverwriteBlock // Non persitent block, gets overwritten on insert/del
);
TSynEditorOptions2 = set of TSynEditorOption2;
@ -265,7 +266,8 @@ const
{$IFDEF SYN_LAZARUS}
SYNEDIT_DEFAULT_OPTIONS2 = [
eoFoldedCopyPaste
eoFoldedCopyPaste,
eoOverwriteBlock
];
{$ENDIF}
@ -842,7 +844,7 @@ type
procedure WndProc(var Msg: TMessage); override;
public
procedure InsertTextAtCaret(aText: String);
property BlockBegin: TPoint read GetBlockBegin write SetBlockBegin;
property BlockBegin: TPoint read GetBlockBegin write SetBlockBegin; // Set Blockbegin. For none persistent also sets Blockend. Setting Caret may undo this and should be done before setting block
property BlockEnd: TPoint read GetBlockEnd write SetBlockEnd;
property FoldState: String read GetFoldState write SetFoldState;
property CanPaste: Boolean read GetCanPaste;
@ -927,7 +929,7 @@ type
property MouseSelActions: TSynEditMouseActions // Mouseactions, if mouse is over selection => fallback to normal
read FMouseSelActions write SetMouseSelActions;
property MaxUndo: Integer read GetMaxUndo write SetMaxUndo default 1024;
property Options: TSynEditorOptions read fOptions write SetOptions
property Options: TSynEditorOptions read fOptions write SetOptions // See SYNEDIT_UNIMPLEMENTED_OPTIONS for deprecated Values
default SYNEDIT_DEFAULT_OPTIONS;
{$IFDEF SYN_LAZARUS}
property Options2: TSynEditorOptions2 read fOptions2 write SetOptions2
@ -3703,7 +3705,7 @@ begin
exit;
Result := True;
if SelAvail and not FBlockSelection.Persistent then
if SelAvail and (not FBlockSelection.Persistent) and (eoOverwriteBlock in fOptions2) then
FBlockSelection.SelText := '';
InsStart := FCaret.LineBytePos;
FInternalBlockSelection.StartLineBytePos := InsStart;
@ -5592,7 +5594,7 @@ begin
{begin} //mh 2000-10-30
ecDeleteLastChar:
if not ReadOnly then begin
if SelAvail and not FBlockSelection.Persistent then
if SelAvail and (not FBlockSelection.Persistent) and (eoOverwriteBlock in fOptions2) then
SetSelTextExternal('')
else begin
Temp := LineText;
@ -5632,7 +5634,7 @@ begin
end;
ecDeleteChar:
if not ReadOnly then begin
if SelAvail and not FBlockSelection.Persistent then
if SelAvail and (not FBlockSelection.Persistent) and (eoOverwriteBlock in fOptions2) then
SetSelTextExternal('')
else begin
Temp := LineText;
@ -5708,9 +5710,8 @@ begin
if not ReadOnly then begin
if FTheLinesView.Count = 0 then
FTheLinesView.Add('');
if SelAvail and not FBlockSelection.Persistent then begin
if SelAvail and (not FBlockSelection.Persistent) and (eoOverwriteBlock in fOptions2) then
SetSelTextExternal('');
end;
Temp := LineText;
LogCaretXY:=PhysicalToLogicalPos(CaretXY);
Len := Length(Temp);
@ -5740,7 +5741,7 @@ begin
FindMatchingBracket;
ecChar:
if not ReadOnly and (AChar >= #32) and (AChar <> #127) then begin
if SelAvail and not FBlockSelection.Persistent then begin
if SelAvail and (not FBlockSelection.Persistent) and (eoOverwriteBlock in fOptions2) then begin
SetSelTextExternal(AChar);
end else begin
try
@ -5788,7 +5789,7 @@ begin
// Insert a linebreak, but do not apply any other functionality (such as indent)
if FTheLinesView.Count = 0 then
FTheLinesView.Add('');
if SelAvail and not FBlockSelection.Persistent then
if SelAvail and (not FBlockSelection.Persistent) and (eoOverwriteBlock in fOptions2) then
SetSelTextExternal('');
LogCaretXY:=PhysicalToLogicalPos(CaretXY);
FTheLinesView.EditLineBreak(LogCaretXY.X, LogCaretXY.Y);

View File

@ -2157,6 +2157,8 @@ begin
SynEditOptName := 'FoldedCopyPaste';
eoPersistentBlock:
SynEditOptName := 'PersistentBlock';
eoOverwriteBlock:
SynEditOptName := 'OverwriteBlock';
else
SynEditOptName := '';
end;
@ -2423,6 +2425,8 @@ begin
SynEditOptName := 'FoldedCopyPaste';
eoPersistentBlock:
SynEditOptName := 'PersistentBlock';
eoOverwriteBlock:
SynEditOptName := 'OverwriteBlock';
else
SynEditOptName := '';
end;

View File

@ -628,4 +628,17 @@ inherited EditorGeneralOptionsFrame: TEditorGeneralOptionsFrame
OnChange = PersistentBlockCheckBoxChange
TabOrder = 21
end
object OverwriteBlockCheckBox: TCheckBox[44]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = BlockGroupLabel
AnchorSideTop.Side = asrBottom
Left = 230
Height = 19
Top = 411
Width = 152
BorderSpacing.Left = 230
Caption = 'OverwriteBlockCheckBox'
OnChange = OverwriteBlockCheckBoxChange
TabOrder = 22
end
end

View File

@ -233,5 +233,10 @@ LazarusResources.Add('TEditorGeneralOptionsFrame','FORMDATA',[
+#7#15'BlockGroupLabel'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#6#6'H'
+'eight'#2#19#3'Top'#3#155#1#5'Width'#3#152#0#18'BorderSpacing.Left'#2#6#7'Ca'
+'ption'#6#23'PersistentBlockCheckBox'#8'OnChange'#7#29'PersistentBlockCheckB'
+'oxChange'#8'TabOrder'#2#21#0#0#0
+'oxChange'#8'TabOrder'#2#21#0#0#242#2','#9'TCheckBox'#22'OverwriteBlockCheck'
+'Box'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#15'B'
+'lockGroupLabel'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#3#230#0#6'Hei'
+'ght'#2#19#3'Top'#3#155#1#5'Width'#3#152#0#18'BorderSpacing.Left'#3#230#0#7
+'Caption'#6#22'OverwriteBlockCheckBox'#8'OnChange'#7#28'OverwriteBlockCheckB'
+'oxChange'#8'TabOrder'#2#22#0#0#0
]);

View File

@ -54,6 +54,7 @@ type
BlockGroupLabel: TLabel;
EndKeyJumpsToNearestStartCheckBox: TCheckBox;
KeepCursorXCheckBox: TCheckBox;
OverwriteBlockCheckBox: TCheckBox;
PersistentCursorCheckBox: TCheckBox;
AlwaysVisibleCursorCheckBox: TCheckBox;
CursorSkipsSelectionCheckBox: TCheckBox;
@ -91,6 +92,7 @@ type
procedure HalfPageScrollCheckBoxChange(Sender: TObject);
procedure HomeKeyJumpsToNearestStartCheckBoxChange(Sender: TObject);
procedure KeepCursorXCheckBoxChange(Sender: TObject);
procedure OverwriteBlockCheckBoxChange(Sender: TObject);
procedure PersistentBlockCheckBoxChange(Sender: TObject);
procedure PersistentCursorCheckBoxChange(Sender: TObject);
procedure ScrollByOneLessCheckBoxChange(Sender: TObject);
@ -170,6 +172,7 @@ begin
// Block
BlockGroupLabel.Caption := dlgBlockGroupOptions;
PersistentBlockCheckBox.Caption := dlgPersistentBlock;
OverwriteBlockCheckBox.Caption := dlgOverwriteBlock;
end;
procedure TEditorGeneralOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
@ -212,6 +215,7 @@ begin
// block
PersistentBlockCheckBox.Checked := eoPersistentBlock in SynEditOptions2;
OverwriteBlockCheckBox.Checked := eoOverwriteBlock in SynEditOptions2;
for i := Low(PreviewEdits) to High(PreviewEdits) do
if PreviewEdits[i] <> nil then
@ -292,6 +296,7 @@ begin
// block
UpdateOptionFromBool(PersistentBlockCheckBox.Checked, eoPersistentBlock);
UpdateOptionFromBool(OverwriteBlockCheckBox.Checked, eoOverwriteBlock);
end;
end;
@ -416,6 +421,11 @@ begin
SetPreviewOption(KeepCursorXCheckBox.Checked, eoKeepCaretX);
end;
procedure TEditorGeneralOptionsFrame.OverwriteBlockCheckBoxChange(Sender: TObject);
begin
SetPreviewOption(KeepCursorXCheckBox.Checked, eoOverwriteBlock);
end;
procedure TEditorGeneralOptionsFrame.PersistentBlockCheckBoxChange(Sender: TObject);
begin
SetPreviewOption(PersistentBlockCheckBox.Checked, eoPersistentBlock);

View File

@ -1149,6 +1149,7 @@ resourcestring
dlgKeepCursorX = 'Keep cursor X position';
dlgPersistentCursor = 'Persistent cursor';
dlgPersistentBlock = 'Persistent Block';
dlgOverwriteBlock = 'Overwrite Block';
dlgCursorSkipsSelection = 'Cursor skips selection';
dlgScrollByOneLess = 'Scroll by one less';
dlgScrollPastEndFile = 'Scroll past end of file';