|
|
I've noticed that with extremely long lines (in this case an entry from the WordNet db), text near the end of the line is corrupt. Max line length appears to be 10,000. I'm dealing with some very long lines - the line in question is 12,970 chrs. How do I
increase the max line length to avoid corrupting the text?
Also, I'm attempting to force the Hscrollbar size to auto adjust. To do this I've been getting the length of the longest line and multiplying it by the font width (using MeasureString). But this results in the Scrolling.HorizontalWidth property being much
to large. I'd really appreciate a suggestion in this regard. The code is below (using a class derived from ScintillaNet):
Private Function GetMaxLineLen()
Dim maxLen As Integer = 2000
Dim lineNum As Integer = 0
For ll As Integer = 0 To Me.Lines.Count - 1
If Me.Lines(ll).Text.Length > maxLen Then
maxLen = Me.Lines(ll).Text.Length
lineNum = ll
End If
Next
Try
' Set up string.
Dim measureString As String = Me.Lines(lineNum).Text
Dim gr As Graphics = Me.CreateGraphics
' Set string format.
Dim newStringFormat As New StringFormat
newStringFormat.FormatFlags = StringFormatFlags.NoClip
' Measure string.
Dim np As New Point(0, 0)
Dim stringSize As New SizeF
stringSize = gr.MeasureString(measureString, Me.Font, np, newStringFormat)
'-------------------------------
Me.Scrolling.HorizontalWidth = maxLen * stringSize.Width
Catch ex As Exception
End Try
Return Nothing
End Function
|
|
Coordinator
Jan 31, 2010 at 7:40 PM
|
You're not the first to hit the limit of Scintilla's line length. Unfortunately there is nothing we can do about it. That is the behavior of the underlying control that ScintillaNET wraps. Still I find it pretty amazing that a single line can be as much
as 10,000 chars because that is dang long.
Rather than trying to measure the line length yourself (which is bound to be error prone), you can try using the SCI_SETSCROLLWIDTHTRACKING message which is intended to automatically increase the horizontal scroll width as necessary. This message somehow
got missed in the current ScintillaNET release (2.2 as of this writing), but the component still supports it. You might try something like this after you've created your control:
const uint SCI_SETSCROLLWIDTHTRACKING = 2516;
scintilla.NativeInterface.SendMessageDirect(SCI_SETSCROLLWIDTHTRACKING, true);
Thanks,
Jacob
|
|
|
|
I was afraid of that. It's never been an issue before but there are some huge entries in the WordNet db. I'll have to do those entries manually (creating a thesaurus and dictionary), but there aren't that many of them. Thanks for the code. I was wondering
why SCI_SETSCROLLWIDTHTRACKING didn't show up with Intellisense.
Alan
|
|
|
|
Jacob, I just cannot understand why notepad++ accepts very long lines and ScintillaNET does not.
If you download notepad++ you can check that long lines (>10.000 chars) works great in this program.
Maybe we can check notepad++ source code and understand how did they do that!
|
|