From a74da4467205a0ee70ad809bfde22cddde019f5d Mon Sep 17 00:00:00 2001 From: martin Date: Tue, 28 Jul 2009 15:40:48 +0000 Subject: [PATCH] SynEdit: implemented option for not overwriting none-persistent blocks git-svn-id: trunk@20994 - --- components/synedit/synedit.pp | 25 +++++++++++++------------ ide/editoroptions.pp | 4 ++++ ide/frames/editor_general_options.lfm | 13 +++++++++++++ ide/frames/editor_general_options.lrs | 7 ++++++- ide/frames/editor_general_options.pas | 10 ++++++++++ ide/lazarusidestrconsts.pas | 1 + 6 files changed, 47 insertions(+), 13 deletions(-) diff --git a/components/synedit/synedit.pp b/components/synedit/synedit.pp index 72e5bb73c7..cab7b2c8ca 100644 --- a/components/synedit/synedit.pp +++ b/components/synedit/synedit.pp @@ -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); diff --git a/ide/editoroptions.pp b/ide/editoroptions.pp index 8ba51737bf..19dd01cd00 100644 --- a/ide/editoroptions.pp +++ b/ide/editoroptions.pp @@ -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; diff --git a/ide/frames/editor_general_options.lfm b/ide/frames/editor_general_options.lfm index d9a09b7c2e..49e305c136 100644 --- a/ide/frames/editor_general_options.lfm +++ b/ide/frames/editor_general_options.lfm @@ -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 diff --git a/ide/frames/editor_general_options.lrs b/ide/frames/editor_general_options.lrs index 988a236b05..e60434e180 100644 --- a/ide/frames/editor_general_options.lrs +++ b/ide/frames/editor_general_options.lrs @@ -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 ]); diff --git a/ide/frames/editor_general_options.pas b/ide/frames/editor_general_options.pas index cf71af48b5..7f1f676bde 100644 --- a/ide/frames/editor_general_options.pas +++ b/ide/frames/editor_general_options.pas @@ -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); diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index 6c68fad144..64f203f5e9 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -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';