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