mirror of https://gitlab.com/basile.b/dexed.git
editor, comment ident, hansle spaces at ident boundaries
This commit is contained in:
parent
d0358546d3
commit
310c5a51af
|
|
@ -1156,19 +1156,58 @@ end;
|
||||||
procedure TCESynMemo.commentIdentifier;
|
procedure TCESynMemo.commentIdentifier;
|
||||||
var
|
var
|
||||||
str: string;
|
str: string;
|
||||||
comment: boolean = true;
|
x, x0, x1: integer;
|
||||||
tkType, st: Integer;
|
comBeg: boolean = false;
|
||||||
|
comEnd: boolean = false;
|
||||||
|
comment:boolean = true;
|
||||||
attrib: TSynHighlighterAttributes;
|
attrib: TSynHighlighterAttributes;
|
||||||
begin
|
begin
|
||||||
if not GetHighlighterAttriAtRowColEx(CaretXY, str, tkType, st, attrib) then
|
if not GetHighlighterAttriAtRowColEx(CaretXY, str, x0, x, attrib) then
|
||||||
exit;
|
exit;
|
||||||
if str.isEmpty then
|
if str.isEmpty then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
if (str.length > 1) and ((str[1..2] = '/*') or
|
str := LineText;
|
||||||
(str[str.length-1..str.length] = '*/')) then
|
x := LogicalCaretXY.X;
|
||||||
comment := false;
|
|
||||||
|
|
||||||
|
ExecuteCommand(ecWordEndRight, #0, nil);
|
||||||
|
x1 := LogicalCaretXY.X;
|
||||||
|
while true do
|
||||||
|
begin
|
||||||
|
if (str[x1] in ['*', '+']) and (x1 < str.length) and (str[x1+1] = '/') then
|
||||||
|
begin
|
||||||
|
comEnd:=true;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
if not isBlank(str[x1]) then
|
||||||
|
break;
|
||||||
|
ExecuteCommand(ecRight, #0, nil);
|
||||||
|
x1 += 1;
|
||||||
|
if x1 = str.length then
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
|
||||||
|
LogicalCaretXY := point(x, LogicalCaretXY.Y);
|
||||||
|
ExecuteCommand(ecWordLeft, #0, nil);
|
||||||
|
x0 := LogicalCaretXY.X - 1;
|
||||||
|
if (x0 > 1) then while true do
|
||||||
|
begin
|
||||||
|
if (x0 > 1) and (str[x0] in ['*', '+']) and (str[x0-1] = '/') then
|
||||||
|
begin
|
||||||
|
x0 -= 1;
|
||||||
|
comBeg:=true;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
if not isBlank(str[x0]) then
|
||||||
|
break;
|
||||||
|
ExecuteCommand(ecLeft, #0, nil);
|
||||||
|
x0 -= 1;
|
||||||
|
if x0 = 1 then
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
|
||||||
|
comment := not comBeg and not comEnd;
|
||||||
|
LogicalCaretXY := point(x, LogicalCaretXY.Y);
|
||||||
if comment then
|
if comment then
|
||||||
begin
|
begin
|
||||||
BeginUndoBlock;
|
BeginUndoBlock;
|
||||||
|
|
@ -1180,23 +1219,14 @@ begin
|
||||||
ExecuteCommand(ecChar, '/', nil);
|
ExecuteCommand(ecChar, '/', nil);
|
||||||
EndUndoBlock;
|
EndUndoBlock;
|
||||||
end else
|
end else
|
||||||
//TODO-ceditor: handle spaces between ident and comment beg end.
|
|
||||||
begin
|
begin
|
||||||
BeginUndoBlock;
|
BeginUndoBlock;
|
||||||
if str[1..2] = '/*' then
|
LogicalCaretXY := point(x1, LogicalCaretXY.Y);
|
||||||
begin
|
ExecuteCommand(ecDeleteChar, '', nil);
|
||||||
ExecuteCommand(ecWordLeft, '', nil);
|
ExecuteCommand(ecDeleteChar, '', nil);
|
||||||
ExecuteCommand(ecLeft, '', nil);
|
LogicalCaretXY := point(x0, LogicalCaretXY.Y);
|
||||||
ExecuteCommand(ecLeft, '', nil);
|
ExecuteCommand(ecDeleteChar, '', nil);
|
||||||
ExecuteCommand(ecDeleteChar, '', nil);
|
ExecuteCommand(ecDeleteChar, '', nil);
|
||||||
ExecuteCommand(ecDeleteChar, '', nil);
|
|
||||||
end;
|
|
||||||
if str[str.length-1..str.length] = '*/' then
|
|
||||||
begin
|
|
||||||
ExecuteCommand(ecWordEndRight, '', nil);
|
|
||||||
ExecuteCommand(ecDeleteChar, '', nil);
|
|
||||||
ExecuteCommand(ecDeleteChar, '', nil);
|
|
||||||
end;
|
|
||||||
EndUndoBlock;
|
EndUndoBlock;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue