Quantcast
Channel: ScintillaNET Forum Rss Feed
Viewing all 296 articles
Browse latest View live

New Post: Autocomplete with underscore bugs

$
0
0
Hello,

the Autocompletion seems to bug for words that contain an underscore. If I have the following list:

test
test_2
testvar

and I enter "testv" then the Autocompletion list gets closed because no entry is found (AutoHide is enabled).

I allready checked Lexing.WordChars, here the underscore char is included correctly. Also AutoComplete.FillUpCharacters only contains ".([" and AutoComplete.StopCharacters doesn't contain any value, so it should work, right? Also AutoComplete.IsCaseSensitive is set to false.

The strange thing is that it sometimes does work, but I couldn't find out any regularity under which circumstances this happens.

Anyone knows how to fix this bug?

Greetings,
2mQ

New Post: Autocomplete with underscore bugs

$
0
0
This sounds like a legitimate bug, have you filed it as a bug report?

New Post: Autocomplete with underscore bugs

New Post: Autocomplete with underscore bugs

$
0
0
Sorry I couldn't help more, my computer's graphics card drivers have gone awry and I can no longer launch Visual Studio on my main laptop.

New Post: Jump to start/end of block (code fold)

$
0
0
Hi,

I can't find any built in support for this, but perhaps I'm just missing something.

Any idea how to support jumping to the start/end of a block, e.g. if on the opening brace of an "if" block, it would jump to the closing bracket?

Thanks


John

New Post: Only highlight keywords within a certain range

$
0
0
Hello,

I wounder if it is possible to highlight keywords only within a certain range (dynamically)? If I have something like this text for example:
private class myClass
{
    // Within this class, myInt should be highlighted
    static int myInt = 1;

}

// Outside the class not
I have already implemented all the logic neccessary to do something like this and it works in theory - I only need to know how I can limit the highlighting to a certain range.

Is this possible?

Greetings,
2mQ

New Post: [Solved] How to do fold / unfold all actions?

$
0
0
I found a solution:
void FoldAll(string target)
{
    foreach(ScintillaNET.Line linear in ActiveDocument.Scintilla.Lines)
    {
        if(linear.IsFoldPoint && linear.FoldExpanded && linear.Text.Contains(target))
        {
            linear.ToggleFoldExpanded();
        }
    }
}

void UnfoldAll(string target)
{
    foreach(ScintillaNET.Line linear in ActiveDocument.Scintilla.Lines)
    {
        if(linear.IsFoldPoint && !linear.FoldExpanded && linear.Text.Contains(target))
        {
            linear.ToggleFoldExpanded();
        }
    }
}

New Post: Color of selection while window is inactive

$
0
0
I know that we can change the color of selected text but only if the window is active.
When the window is inactive the color of the selection will change (depending on the theme in windows I think) to gray.
In Windows Notepad the color of the selection will not change. Here is a screenshot where both Notepad and ScintillaNET windows are inactive:

Image

Is it possible to keep the selection color in ScintillaNET while the window is inactive?

New Post: Color of selection while window is inactive

$
0
0
I believe the properties you're looking for are called Scintilla.Selection.BackColorUnfocused and Scintilla.Selection.ForeColorUnfocused.

Jacob

New Post: Color of selection while window is inactive

$
0
0
Oh, how could I miss that.
Thanks :)

New Post: How to keep up with the location of a range when text changes

$
0
0
Please bear with me while I explain what I'm doing...

I'm using ScintillaNet in a tabbed editor. My find-replace tool includes a "Find in All Open Docs" function. When used this opens a list (DataGridView) at the bottom of the main window similar to the error list in Visual Studio. Each row displays a match from the search. I want to be able to double-click a row in the list and have the program jump to the proper tab and text position. Each match is a ScintillaNet.Range object created from the index and length of the Regex match. They're marked by setting a style to change the background color.

This works fine, except that when text is edited above the match the position of the range is no longer valid. Is there a built-in method to have the ranges react to changes in the text, or is this something I'll need to do manually?

New Post: How to keep up with the location of a range when text changes

$
0
0
Okay, figured that out. Indicators. Duh.

New Post: default Python lexer not supporting line comment coloring?

$
0
0
Just checking to see if I'm overlooking something silly here... I've selected Python as my lexer and I'd assume out of the box # would be treated as a line comment and it'd show up as green - other syntax highlighting is working ok, brace matching etc...

I tried setting the line comment prefix to "#" manually and even added

scintillaCode.Styles[scintillaCode.Lexing.StyleNameMap["LINECOMMENT"]].ForeColor = System.Drawing.Color.Green;

just to be sure my assumption about color settings wasn't wrong - however nothing I do causes lines that start with # to be colored green.

Am I overlooking something simple?

(using latest bins downloaded this afternoon, BTW)

New Post: default Python lexer not supporting line comment coloring?

$
0
0
Sorry, but I think the comment prefix character is hardcoded into the native C++ scintilla control. You could 1) try writing a custom lexer or 2) download the scintilla source (http://www.scintilla.org/) and modify and recompile Scintilla.DLL and SciLexer.dll to support your new comments.

New Post: Problem dragging text with version 2.5.2

$
0
0
With version 2.5.0 I could select and drag text without issue. But I can't seem to make it work with version 2.5.2. What do I need to do to get it working?

New Post: Problem dragging text with version 2.5.2

$
0
0
The same question was already discussed on this thread:

http://scintillanet.codeplex.com/discussions/437175

It would seem that in an effort to fix file drag and drop, we messed up drag and drop of text within the control. Some possible workarounds are presented in the discussion thread.



Thanks,
Jacob

New Post: Prototype Lexer/Highlighter Available

$
0
0
I'm using a Modified for of PwerLexer converted to VB

Dragging the Virtical Scroll Bar Freezes the Application till it catches up... Arrow Keys,MouseWheel and Scroll Buttons are smooth scrolling.

Is there any way To Fix the Scroll Drag so its smoother?
Imports System.Text
Imports System.Drawing
Imports System.Text.RegularExpressions
Imports ScintillaNET
Imports DSeX.ConfigStructs
Public Class PwrLexer

    Private Shared Lock As Boolean = False
    ' Origional Thread for this class
    'http://scintillanet.codeplex.com/discussions/42949
    Private Const ST_DEFAULT As Integer = 32
    Private Const ST_STRING_VAR As Integer = 11
    Private Const ST_NUM_VAR As Integer = 12
    Private Const ST_STRING As Integer = 13
    Private Const ST_ID As Integer = 14
    Private Const ST_NUMBER As Integer = 15
    Private Const ST_COMMENT As Integer = 16
    Private Const ST_HEADER As Integer = 17

    Private Shared HEADER As String = KeysIni.GetKeyValue("MS-General", "Header")
    Private Shared RegWhiteSpace As New Regex("^\s+") '\s+
    Private Shared RegStrVar As New Regex("^~([A-Za-z0-9_]+)", RegexOptions.IgnoreCase)
    Private Shared RegNumVar As New Regex("^%([A-Za-z0-9_]+)", RegexOptions.IgnoreCase)
    Private Shared RegString As New Regex("^\{(.*?)\}")
    Private Shared RegLineID As New Regex("^\(([0-9]*)\:([0-9]*)\)")
    Private Shared RegNumber As New Regex("^([0-9#]+)")
    Private Shared RegHeader As New Regex("^(" + HEADER + ")", RegexOptions.IgnoreCase)

    Public Shared Sub Init(scintilla As Scintilla)
        scintilla.Indentation.SmartIndentType = SmartIndent.None
        scintilla.ConfigurationManager.Language = [String].Empty
        scintilla.Lexing.LexerName = "container"
        scintilla.Lexing.Lexer = Lexer.Container

        scintilla.Styles(ST_DEFAULT).ForeColor = Color.Black
        scintilla.Styles(ST_STRING_VAR).ForeColor = EditSettings.StringVariableColor
        scintilla.Styles(ST_NUM_VAR).ForeColor = EditSettings.VariableColor
        scintilla.Styles(ST_STRING).ForeColor = EditSettings.StringColor
        scintilla.Styles(ST_COMMENT).ForeColor = EditSettings.CommentColor
        scintilla.Styles(ST_ID).ForeColor = EditSettings.IDColor
        scintilla.Styles(ST_NUMBER).ForeColor = EditSettings.NumberColor
        scintilla.Styles(ST_HEADER).ForeColor = Color.Green
        scintilla.Styles(ST_HEADER).Bold = True
    End Sub

    Public Shared Sub StyleNeeded(ByRef scintilla As Scintilla, ByRef range As Range)

        Dim start As Integer = range.StartingLine.StartPosition
        Dim [end] As Integer = start
        Dim max As Integer = scintilla.Lines(scintilla.Lines.Count - 1).StartPosition + scintilla.Lines(scintilla.Lines.Count - 1).Length
        Debug.Print("StyleNeededEventArgs()")
        'we'll get the whole update range at once
        'we also get the maximum editor range, incase a new comment goes to the end of the file
        'Dim curr As Line = range.StartingLine
        'While curr.Number <= range.EndingLine.Number
        '    [end] += curr.Length
        '    curr = curr.[Next]
        'End While
        Dim test As String = range.Text
        [end] += test.Length
        StyleSection(scintilla, start, [end], max, test)

    End Sub

    Public Shared Sub StyleSection(ByRef scintilla As Scintilla, ByRef start As Integer, ByRef [end] As Integer, ByRef max As Integer, ByRef Txt As String)
        Dim pos As Integer = start
        Dim i As Integer = 0
        While pos < [end]

            Dim curr As String = scintilla.GetRange(pos, [end]).Text

            'make a couple of direct checks for special handling (comments/string literals) pass the rest to a RegEx handler
            'If (curr.Length > 1)' AndAlso (curr(0) = "*"c) Then
            ' pos += StyleCommentSingle(scintilla, pos, [end], max)
            If RegHeader.IsMatch(curr) Then
                pos += StyleRegExWhole(scintilla, curr, RegHeader, ST_HEADER, pos, [end], max)

                'ElseIf (curr(0) = "{"c) Then
                '    pos += StyleString(scintilla, curr, pos, [end], max)

                'ElseIf RegStrVar.IsMatch(curr) Then
                '    pos += StyleRegExWhole(scintilla, curr, RegStrVar, ST_STRING_VAR, pos, [end], max)

                'ElseIf RegNumVar.IsMatch(curr) Then
                '    pos += StyleRegExWhole(scintilla, curr, RegNumVar, ST_NUM_VAR, pos, [end], max)

                'ElseIf RegLineID.IsMatch(curr) Then
                '    pos += StyleRegExWhole(scintilla, curr, RegLineID, ST_ID, pos, [end], max)

                'ElseIf RegNumber.IsMatch(curr) Then
                '    pos += StyleRegExWhole(scintilla, curr, RegNumber, ST_NUMBER, pos, [end], max)

                'ElseIf RegWhiteSpace.IsMatch(curr) Then
                '    pos += StyleRegExWhole(scintilla, curr, RegWhiteSpace, ST_DEFAULT, pos, [end], max)
            Else

                Select Case curr(0)
                    'Case vbLf
                    '    pos += 1
                    'Case vbCr
                    '    pos += 1
                    Case "*"c
                        i = StyleCommentSingle(scintilla, pos, [end], max)
                    Case "("c
                        i = StyleRegExWhole(scintilla, curr, RegLineID, ST_ID, pos, [end], max)

                    Case "%"c
                        i = StyleRegExWhole(scintilla, curr, RegNumVar, ST_STRING_VAR, pos, [end], max)

                    Case "0"c To "9"c
                        i = StyleRegExWhole(scintilla, curr, RegNumber, ST_NUMBER, pos, [end], max)
                    Case "{"c
                        i = StyleString(scintilla, curr, pos, [end], max)
                    Case "~"c
                        i = StyleRegExWhole(scintilla, curr, RegStrVar, ST_STRING_VAR, pos, [end], max)

                    Case Else
                        i = 0
                End Select
                If i = 0 Then
                    DirectCast(scintilla, INativeScintilla).StartStyling(pos, &H1F)
                    DirectCast(scintilla, INativeScintilla).SetStyling(1, ST_DEFAULT)
                    pos += 1
                Else
                    pos += i
                End If
            End If
        End While
    End Sub

    Public Shared Function StyleHeader(ByRef scintilla As Scintilla, ByRef start As Integer, ByRef [end] As Integer, ByRef max As Integer) As Integer
        Dim full As String = scintilla.GetRange(start, max).Text.ToUpper()
        Dim offset As Integer = 0
        While (full(offset) <> ControlChars.Cr) AndAlso (full(offset) <> ControlChars.Lf) AndAlso (start + offset < max)
            offset += 1
        End While
        DirectCast(scintilla, INativeScintilla).StartStyling(start, &H1F)
        DirectCast(scintilla, INativeScintilla).SetStyling(offset, ST_HEADER)
        Return offset
    End Function
    Public Shared Function StyleCommentSingle(ByRef scintilla As Scintilla, ByRef start As Integer, ByRef [end] As Integer, ByRef max As Integer) As Integer
        Dim full As String = scintilla.GetRange(start, max).Text.ToUpper()
        Dim offset As Integer = 0
        While (full(offset) <> ControlChars.Cr) AndAlso (full(offset) <> ControlChars.Lf) AndAlso (start + offset < max - 1)
            offset += 1
        End While
        DirectCast(scintilla, INativeScintilla).StartStyling(start, &H1F)
        DirectCast(scintilla, INativeScintilla).SetStyling(offset, ST_COMMENT)
        Return offset
    End Function

    Public Shared Function StyleString(ByRef scintilla As Scintilla, ByRef text As String, ByRef start As Integer, ByRef [end] As Integer, ByRef max As Integer) As Integer
        Dim full As String = scintilla.GetRange(start, max).Text.ToUpper()
        Dim offset As Integer = 1
        While (full(offset) <> ControlChars.Cr) AndAlso (full(offset) <> ControlChars.Lf) AndAlso (full(offset) <> "}"c) AndAlso (start + offset < max - 1)
            offset += 1
        End While
        offset += 1
        DirectCast(scintilla, INativeScintilla).StartStyling(start, &H1F)
        DirectCast(scintilla, INativeScintilla).SetStyling(offset, ST_STRING)
        Return offset
    End Function

    Public Shared Function StyleRegExWhole(ByRef scintilla As Scintilla, ByRef text As String, ByRef reg As Regex, ByRef style As Integer, ByRef start As Integer, ByRef [end] As Integer, _
     ByRef max As Integer) As Integer
        'match & style an entire regex
        Dim match As String = reg.Match(text).Value
        DirectCast(scintilla, INativeScintilla).StartStyling(start, &H1F)
        DirectCast(scintilla, INativeScintilla).SetStyling(match.Length, style)
        Return match.Length
    End Function

    Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, value As T) As T
        target = value
        Return value
    End Function
End Class

New Post: Prototype Lexer/Highlighter Available

$
0
0
@Gerolkae,

Your "scrolling performance" issue is really a "lexer performance" issue. To successively attempt to match regular expressions against the unstyled content will simply take too long. In short, that approach doesn't scale... and a quick scroll on a long document makes that obvious.

This thread is old and we have better examples now on how to write a custom lexer. You should check out @blah38621's WPF branch. The WPF portions of it are irrelevant for you, but the custom lexer implementations show best practices. He also details some of his work in this thread:

https://scintillanet.codeplex.com/discussions/435975#post1012843


Cheers,
Jacob

New Post: Prototype Lexer/Highlighter Available

New Post: Custom Lexer Unicode

$
0
0
I'm Building a custom lexer around the winforms CustomLexer class and I've noticed ConsumeString Doesn't account for Unicode Bytes...

ConsumeString(STYLE_STRING, '\0', false, false, '}'); Has Coloring a few characters before the {} brackets I'm using to Delimt strings

How would I compensate for the Byte Size and character Indexing?
Viewing all 296 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>