desjarlais/Scintilla.NET

How can I get the number of lines of content currently displayed, with wrapMode is not WrapMode.None

Z-orz opened this issue · 4 comments

Z-orz commented

Describe the bug
When I use WrapMode.Word, scintilla.Lines.Count is not lines of content currently displayed.

Hi,
Could you give some more information on the issue, screenshot, e.g.
I'm trying to guess here:
a) scintilla.Lines.Count has an incorrect value
b) The text of the Scintilla control is not displayed correctly

Z-orz commented

just like this
image
I hope Lines.Count is two, but it is one.
It is my code

private void Form1_Load(object sender, EventArgs e)
        {
            scintilla1.TextChanged += Scintilla1_TextChanged;
            scintilla1.WrapMode = ScintillaNET.WrapMode.Char;
            scintilla1.AppendText("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
        }

        private void Scintilla1_TextChanged(object sender, EventArgs e)
        {
            label1.Text = $"Lines.Count = {scintilla1.Lines.Count}";
        }

Hi,
Clearly the wrapping doesn't change the reported line count as the line count does not actually change.
The wrapping just modifies the behavior how the Scintilla control displays the text.
The reported line count is the correct one as the text in the control doesn't contain any line terminators such as carriage return (\r == 0x0D) or line feed (\n == 0x0A).

To append a line try:

scintilla1.AppendText("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + Environment.NewLine);
Z-orz commented

OK, thank you.