Overwrite selection block

This commit is contained in:
Margers 2024-09-01 20:43:13 +00:00 committed by Michael Van Canneyt
parent 660836e027
commit 5ded9e3cb3
4 changed files with 36 additions and 9 deletions

View File

@ -598,6 +598,7 @@ resourcestring menu_local_gotosource = '~G~oto source';
label_editor_usetabcharacters = '~U~se tab characters';
label_editor_backspaceunindents = '~B~ackspace unindents';
label_editor_persistentblocks = '~P~ersistent blocks';
label_editor_overwriteblocks = '~O~verwrite blocks';
label_editor_syntaxhighlight = '~S~yntax highlight';
label_editor_blockinsertcursor = 'B~l~ock insert cursor';
label_editor_verticalblocks = '~V~ertical blocks';
@ -1087,7 +1088,7 @@ begin
StdStatusKeys(
NewStatusKey('~Cursor~ Move', kbNoKey, 65535,
NewStatusKey('~Shift+Cursor~ Size', kbNoKey, 65535,
NewStatusKey('~'#17'ÄŮ~ Done', kbNoKey, 65535, {#17 = left arrow}
NewStatusKey('~'#17'<EFBFBD><EFBFBD>~ Done', kbNoKey, 65535, {#17 = left arrow}
NewStatusKey('~Esc~ Cancel', kbNoKey, 65535,
nil)))))),
NewStatusDef(hcStackWindow, hcStackWindow,

View File

@ -1156,8 +1156,8 @@ begin
if (EFlags and efUseTabCharacters )<>0 then EFValue:=EFValue or (1 shl 3);
if (EFlags and efBackSpaceUnindents)<>0 then EFValue:=EFValue or (1 shl 4);
if (EFlags and efPersistentBlocks )<>0 then EFValue:=EFValue or (1 shl 5);
if (EFlags and efSyntaxHighlight )<>0 then EFValue:=EFValue or (1 shl 6);
if (EFlags and efBlockInsCursor )<>0 then EFValue:=EFValue or (1 shl 7);
if (EFlags and efOverwriteBlocks )<>0 then EFValue:=EFValue or (1 shl 6);
if (EFlags and efSyntaxHighlight )<>0 then EFValue:=EFValue or (1 shl 7);
if (EFlags and efVerticalBlocks )<>0 then EFValue:=EFValue or (1 shl 8);
if (EFlags and efHighlightColumn )<>0 then EFValue:=EFValue or (1 shl 9);
if (EFlags and efHighlightRow )<>0 then EFValue:=EFValue or (1 shl 10);
@ -1165,6 +1165,7 @@ begin
if (EFlags and efKeepTrailingSpaces)<>0 then EFValue:=EFValue or (1 shl 12);
if (EFlags and efCodeComplete )<>0 then EFValue:=EFValue or (1 shl 13);
if (EFlags and efFolds )<>0 then EFValue:=EFValue or (1 shl 14);
if (EFlags and efBlockInsCursor )<>0 then EFValue:=EFValue or (1 shl 15);
R.Assign(0,0,66,20);
New(D, Init(R, Title));
@ -1180,8 +1181,8 @@ begin
NewSItem(label_editor_usetabcharacters,
NewSItem(label_editor_backspaceunindents,
NewSItem(label_editor_persistentblocks,
NewSItem(label_editor_overwriteblocks,
NewSItem(label_editor_syntaxhighlight,
NewSItem(label_editor_blockinsertcursor,
NewSItem(label_editor_verticalblocks,
NewSItem(label_editor_highlightcolumn,
NewSItem(label_editor_highlightrow,
@ -1189,7 +1190,8 @@ begin
NewSItem(label_editor_keeptrailingspaces,
NewSItem(label_editor_codecomplete,
NewSItem(label_editor_folds,
nil)))))))))))))))));
NewSItem(label_editor_blockinsertcursor,
nil))))))))))))))))));
CB^.Value:=EFValue;
Insert(CB);
R2.Move(0,-1); R2.B.Y:=R2.A.Y+1;
@ -1237,8 +1239,8 @@ begin
if (CB^.Value and (1 shl 3))<>0 then EFlags:=EFlags or efUseTabCharacters;
if (CB^.Value and (1 shl 4))<>0 then EFlags:=EFlags or efBackSpaceUnindents;
if (CB^.Value and (1 shl 5))<>0 then EFlags:=EFlags or efPersistentBlocks;
if (CB^.Value and (1 shl 6))<>0 then EFlags:=EFlags or efSyntaxHighlight;
if (CB^.Value and (1 shl 7))<>0 then EFlags:=EFlags or efBlockInsCursor;
if (CB^.Value and (1 shl 6))<>0 then EFlags:=EFlags or efOverwriteBlocks;
if (CB^.Value and (1 shl 7))<>0 then EFlags:=EFlags or efSyntaxHighlight;
if (CB^.Value and (1 shl 8))<>0 then EFlags:=EFlags or efVerticalBlocks;
if (CB^.Value and (1 shl 9))<>0 then EFlags:=EFlags or efHighlightColumn;
if (CB^.Value and (1 shl 10))<>0 then EFlags:=EFlags or efHighlightRow;
@ -1246,6 +1248,7 @@ begin
if (CB^.Value and (1 shl 12))<>0 then EFlags:=EFlags or efKeepTrailingSpaces;
if (CB^.Value and (1 shl 13))<>0 then EFlags:=EFlags or efCodeComplete;
if (CB^.Value and (1 shl 14))<>0 then EFlags:=EFlags or efFolds;
if (CB^.Value and (1 shl 15))<>0 then EFlags:=EFlags or efBlockInsCursor;
TabSize:=StrToInt(ILTab^.Data^);
IndentSize:=StrToInt(ILIdent^.Data^);
if Editor=nil then

View File

@ -251,7 +251,7 @@ function DefUseTabsPattern(Editor: PFileEditor): boolean;
const
DefaultCodeEditorFlags : longint =
efBackupFiles+efInsertMode+efAutoIndent+efPersistentBlocks+
efBackupFiles+efInsertMode+efAutoIndent+efPersistentBlocks+efOverwriteBlocks+
{efUseTabCharacters+}efBackSpaceUnindents+efSyntaxHighlight+
efExpandAllTabs+efCodeComplete{+efFolds};
DefaultTabSize : integer = 8;

View File

@ -90,6 +90,7 @@ const
efFolds = $00008000;
efNoIndent = $00010000;
efKeepLineAttr = $00020000;
efOverwriteBlocks = $00040000;
efStoreContent = $80000000;
attrAsm = 1;
@ -508,6 +509,7 @@ type
{a}function GetInsertMode: boolean; virtual;
{a}procedure SetInsertMode(InsertMode: boolean); virtual;
procedure SetCurPtr(X,Y: sw_integer); virtual;
function InSelectionArea:boolean; {CurPos in selection area}
procedure GetSelectionArea(var StartP,EndP: TPoint); virtual;
procedure SetSelection(A, B: TPoint); virtual;
procedure SetHighlight(A, B: TPoint); virtual;
@ -2967,6 +2969,8 @@ begin
OK:=(Editor^.SelStart.X<>Editor^.SelEnd.X) or (Editor^.SelStart.Y<>Editor^.SelEnd.Y);
if OK then
begin
if not (Clipboard=@Self) and IsFlagSet(efOverwriteBlocks) and InSelectionArea then
DelSelect; {delete selection before paste}
StartPos:=CurPos; DestPos:=CurPos;
EPos:=CurPos;
VerticalBlock:=Editor^.IsFlagSet(efVerticalBlocks);
@ -5709,8 +5713,9 @@ var S,SC,TabS: string;
HoldUndo : boolean;
begin
if IsReadOnly then Exit;
Lock;
if not (Clipboard=@Self) and IsFlagSet(efOverwriteBlocks) and InSelectionArea then
DelSelect; {delete selection before}
SP:=CurPos;
HoldUndo:=GetStoreUndo;
SetStoreUndo(false);
@ -5850,6 +5855,8 @@ begin
if l>500 then
PushInfo(msg_readingwinclipboard);
AddGroupedAction(eaPasteWin);
if not (Clipboard=@Self) and IsFlagSet(efOverwriteBlocks) and InSelectionArea then
DelSelect; {delete selection before paste}
p2:=p;
len:=strlen(p2);
// issue lines ((#13)#10 terminated) of maximally "linelimit" chars.
@ -6703,6 +6710,22 @@ begin
SetHighlight(CurPos,CurPos);
end;
function TCustomCodeEditor.InSelectionArea:boolean; {CurPos in selection area}
begin
InSelectionArea:=false;
if ((SelStart.X<>SelEnd.X) or (SelStart.Y<>SelEnd.Y)) then {there is selection}
begin
if (SelStart.Y = SelEnd.Y) and (CurPos.X>=min(SelStart.X,SelEnd.X)) and (CurPos.X<=max(SelStart.X,SelEnd.X)) then
InSelectionArea:=true {select in one line}
else if (CurPos.Y>min(SelStart.Y,SelEnd.Y)) and (CurPos.Y<max(SelStart.Y,SelEnd.Y)) then
InSelectionArea:=true {between first and last selected line}
else if (SelStart.Y < SelEnd.Y) and ( ((SelStart.Y=CurPos.Y) and (SelStart.X<=CurPos.X)) or ((SelEnd.Y=CurPos.Y) and (SelEnd.X>=CurPos.X))) then
InSelectionArea:=true {in first line or last line}
else if (SelStart.Y > SelEnd.Y) and ( ((SelStart.Y=CurPos.Y) and (SelStart.X>=CurPos.X)) or ((SelEnd.Y=CurPos.Y) and (SelEnd.X<=CurPos.X))) then
InSelectionArea:=true; {in first line or last line (selection Start and End revers)}
end;
end;
procedure TCustomCodeEditor.GetSelectionArea(var StartP,EndP: TPoint);
begin
StartP:=SelStart; EndP:=SelEnd;