Current line index
Posted: 23 Apr 2015 22:09
Hello!
How can I get the current line index in pascal script?
How can I get the current line index in pascal script?
Code: Select all
var
y: Integer;
begin
y := Document.CursorY;
ShowMessage(y);
end.
Code: Select all
var y = Document.CursorY;
Document.CursorDocEnd(false);
var maxY = Document.CursorY;
for (var i = y; i < maxY; i++) {
Document.Lines[i] = Document.Lines[i + 1];
}
Document.Lines[maxY] = "";
Code: Select all
var y = Document.CursorY;
Document.Lines[y] = "";
Document.DeleteBlankLines();
Code: Select all
var y = Document.CursorY;
Document.Lines[y] = "";
Document.JoinLines();
Code: Select all
//Pascal
var
y: integer;
list: TStringList;
begin
Document.BeginUpdate();
Document.Wordwrap:= False;
y:= Document.CursorY; //Current line
list:= TStringList.Create;
list.Text:= Document.Text;
list.Delete(y);
Document.Text:= list.Text; //after paste cursor is in the end of the document
Document.CursorY:=y; //set cursor in start position
list.free;
Document.Wordwrap:= True;
Document.EndUpdate();
end;
Code: Select all
...
Document.SelectCurrentLine;
Document.SelText := '';
...
But in this case we delete only content of the line. And I need to delete full line with move up. In other words I need to delete the char #13 in the end of line.Rickard Johansson wrote:A simpler way to delete the current line would be add:Just sayingCode: Select all
... Document.SelectCurrentLine; Document.SelText := ''; ...
Code: Select all
...
y := Document.CursorY;
if (y < Document.LineCount - 1) then
Document.SetSelection(0, y, 0 , y+1)
else
Document.SetSelection(Length(Document.Lines[y-1]), y-1, Length(Document.Lines[y]), y);
Document.SelText := '';
...