mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-05 01:08:12 +02:00
IDE, SynEdit: add ecDeleteLineKeepX
This commit is contained in:
parent
84a59bc88a
commit
e05279af09
@ -7362,16 +7362,19 @@ begin
|
||||
FCaret.LineBytePos := WP;
|
||||
end;
|
||||
end;
|
||||
ecDeleteLine:
|
||||
ecDeleteLine, ecDeleteLineKeepX:
|
||||
if not ReadOnly
|
||||
then begin
|
||||
CY := FCaret.LinePos;
|
||||
if (Cy < FTheLinesView.Count) then
|
||||
FTheLinesView.EditLinesDelete(CaretY, 1)
|
||||
FTheLinesView.EditLinesDelete(CY, 1)
|
||||
else
|
||||
if (Cy = FTheLinesView.Count) and (FTheLinesView[CY-1] <> '') then
|
||||
FTheLinesView.EditDelete(1, Cy, length(FTheLinesView[Cy-1]));
|
||||
CaretXY := Point(1, CaretY); // like seen in the Delphi editor
|
||||
if Command = ecDeleteLineKeepX then
|
||||
FCaret.ValidateXPos
|
||||
else
|
||||
CaretXY := Point(1, CY); // like seen in the Delphi editor
|
||||
end;
|
||||
ecClearAll:
|
||||
begin
|
||||
|
@ -251,6 +251,7 @@ const
|
||||
ecChar = 511; // Insert a character at current position
|
||||
ecSmartUnindent = 512; // NOT regocniced as command, used for group-undo, set by beautifier
|
||||
ecDeleteCharNoCrLf= 513; // Delete char at cursor (i.e. delete key), but do not join lines
|
||||
ecDeleteLineKeepX = 514; // Delete current line
|
||||
|
||||
ecImeStr = 550; // Insert character(s) from IME
|
||||
|
||||
@ -436,7 +437,7 @@ implementation
|
||||
{ Command mapping routines }
|
||||
|
||||
const
|
||||
EditorCommandStrs: array[0..183] of TIdentMapEntry = (
|
||||
EditorCommandStrs: array[0..184] of TIdentMapEntry = (
|
||||
(Value: ecNone; Name: 'ecNone'),
|
||||
(Value: ecLeft; Name: 'ecLeft'),
|
||||
(Value: ecRight; Name: 'ecRight'),
|
||||
@ -516,6 +517,7 @@ const
|
||||
(Value: ecDeleteBOL; Name: 'ecDeleteBOL'),
|
||||
(Value: ecDeleteEOL; Name: 'ecDeleteEOL'),
|
||||
(Value: ecDeleteLine; Name: 'ecDeleteLine'),
|
||||
(Value: ecDeleteLineKeepX; Name: 'ecDeleteLineKeepX'),
|
||||
(Value: ecClearAll; Name: 'ecClearAll'),
|
||||
(Value: ecLineBreak; Name: 'ecLineBreak'),
|
||||
(Value: ecInsertLine; Name: 'ecInsertLine'),
|
||||
|
@ -380,6 +380,7 @@ type
|
||||
procedure DecAutoMoveOnEdit;
|
||||
procedure ChangeOnTouch;
|
||||
procedure Touch(aChangeOnTouch: Boolean = False);
|
||||
procedure ValidateXPos;
|
||||
|
||||
function WasAtLineChar(aPoint: TPoint): Boolean;
|
||||
function WasAtLineByte(aPoint: TPoint): Boolean;
|
||||
@ -1654,6 +1655,11 @@ begin
|
||||
FTouched := True;
|
||||
end;
|
||||
|
||||
procedure TSynEditCaret.ValidateXPos;
|
||||
begin
|
||||
InternalSetLineCharPos(FLinePos, FCharPos, [scuForceSet]);
|
||||
end;
|
||||
|
||||
|
||||
function TSynEditCaret.WasAtLineChar(aPoint: TPoint): Boolean;
|
||||
begin
|
||||
|
@ -2666,7 +2666,7 @@ begin
|
||||
|
||||
case Command of
|
||||
// TODO: delete and smColumn -- only delete once
|
||||
ecDeleteLastChar..ecDeleteLine, ecDeleteCharNoCrLf,
|
||||
ecDeleteLastChar..ecDeleteLine, ecDeleteCharNoCrLf, ecDeleteLineKeepX,
|
||||
ecLineBreak..ecChar:
|
||||
begin
|
||||
StartEditing;
|
||||
|
@ -518,6 +518,7 @@ begin
|
||||
ecDeleteBOL : Result:= srkmecDeleteBOL;
|
||||
ecDeleteEOL : Result:= srkmecDeleteEOL;
|
||||
ecDeleteLine : Result:= srkmecDeleteLine;
|
||||
ecDeleteLineKeepX : Result:= srkmecDeleteLineKeepX;
|
||||
ecClearAll : Result:= srkmecClearAll;
|
||||
ecLineBreak : Result:= srkmecLineBreak;
|
||||
ecInsertLine : Result:= srkmecInsertLine;
|
||||
@ -2978,6 +2979,7 @@ begin
|
||||
AddDefault(C, 'Delete to beginning of line', srkmecDeleteBOL, ecDeleteBOL);
|
||||
AddDefault(C, 'Delete to end of line', srkmecDeleteEOL, ecDeleteEOL);
|
||||
AddDefault(C, 'Delete current line', srkmecDeleteLine, ecDeleteLine);
|
||||
AddDefault(C, 'Delete current line keep x', srkmecDeleteLineKeepX, ecDeleteLineKeepX);
|
||||
AddDefault(C, 'Delete whole text', srkmecClearAll, ecClearAll);
|
||||
AddDefault(C, 'Break line and move cursor', srkmecLineBreak, ecLineBreak);
|
||||
AddDefault(C, 'Break line, leave cursor', srkmecInsertLine, ecInsertLine);
|
||||
|
@ -3110,6 +3110,7 @@ resourcestring
|
||||
srkmecDeleteBOL = 'Delete to beginning of line';
|
||||
srkmecDeleteEOL = 'Delete to end of line';
|
||||
srkmecDeleteLine = 'Delete current line';
|
||||
srkmecDeleteLineKeepX = 'Delete current line (keep X pos)';
|
||||
srkmecClearAll = 'Delete whole text';
|
||||
srkmecLineBreak = 'Break line and move cursor';
|
||||
srkmecInsertLine = 'Break line, leave cursor';
|
||||
|
Loading…
Reference in New Issue
Block a user