Giter VIP home page Giter VIP logo

scintillanet's Introduction

ScintillaNET

ScintillaNET is a Windows Forms control, wrapper, and bindings for the versatile Scintilla source code editing component.

"As well as features found in standard text editing components, Scintilla includes features especially useful when editing and debugging source code. These include support for syntax styling, error indicators, code completion and call tips. The selection margin can contain markers like those used in debuggers to indicate breakpoints and the current line. Styling choices are more open than with many editors, allowing the use of proportional fonts, bold and italics, multiple foreground and background colours and multiple fonts." -- scintilla.org

ScintillaNET can also be used with WPF using the WindowsFormsHost.

Project Status

ScintillaNET is in active development. If you find any issues or just have a question feel free to use the Issues feature at our GitHub page.

Compiled versions which are production ready can be downloaded from NuGet or the Releases page.

For the latest and greatest you can build the Master branch from source using Visual Studio 2015.

Related Projects

A fairly vibrant ScintillaNET community exists here on GitHub. We specifically recommend you look at the following projects:

  • The ScintillaNET.Demo project to see ScintillaNET used in an easy to understand, well-documented text editor (thanks to @robinrodricks)
  • The ScintillaNET-Kitchen project for seeing the effect of some of ScintillaNET's features in real time and generating boilerplate code for configuring styles (thanks to @uuf6429)
  • The ScintillaNET-FindReplaceDialog project for adding a Find/Replace dialog to ScintillaNET (thanks to @Stumpii)
  • The SintillaNetPrinting project for adding printer support to ScintillaNET (thanks to @poloab).

Additional projects and user-submitted code are tracked in the User Submitted Recipes page of the wiki.

Background

This project is a rewrite of the ScintillaNET project hosted at CodePlex and maintained by myself and others. After many years of contributing to that project I decided to think differently about the API we had created and felt I could make better one if I was willing to go back to a blank canvas. Thus, this project is the spiritual successor to the original ScintillaNET but has been written from scratch.

First Class Characters

One of the issues that ScintillaNET has historically suffered from is the fact that the native Scintilla control operates on bytes, not characters. Prior versions of ScintillaNET did not account for this, and when you're dealing with Unicode, one byte doesn't always equal one character. The result was an API that sometimes expected byte offsets and at other times expected character offsets. Sometimes things would work as expected and other times random failures and out-of-range exceptions would occur.

No more. One of the major focuses of this rewrite was to give ScintillaNET an understanding of Unicode from the ground up. Every API now consistently works with character-based offsets and ranges just like .NET developers expect. Internally we maintain a mapping of character to byte offsets (and vice versa) and do all the translation for you so you never need to worry about it. No more out-of-range exceptions. No more confusion. No more pain. It just works.

One Library

The second most popular ScintillaNET issue was confusion distributing the ScintillaNET DLL and its native component, the SciLexer DLL. ScintillaNET is a wrapper. Without the SciLexer.dll containing the core Scintilla functionality it is nothing. As a native component, SciLexer.dll has to be compiled separately for 32 and 64-bit versions of Windows. So it was actually three DLLs that developers had to ship with their applications.

This proved a pain point because developers often didn't want to distribute so many libraries or wanted to place them in alternate locations which would break the DLL loading mechanisms used by PInvoke and ScintillaNET. It also causes headaches during design-time in Visual Studio for the same reasons.

To address this ScintillaNET now embeds a 32 and 64-bit version of SciLexer.dll in the ScintillaNET DLL. Everything you need to run ScintillaNET in one library. In addition to soothing the pain mentioned above this now makes it possible for us to create a ScintillaNET NuGet package.

Keeping it Consistent

Another goal of the rewrite was to accept the original Scintilla API for what it is and not try to coerce it into a .NET-style API when it should not or could not be. A good example of this is how ScintillaNET uses indexers to access lines, but not treat them as a .NET collection. Lines in a Scintilla control are not items in a collection. There is no API to Add, Insert, or Remove a line in Scintilla and thus we don't try to create one in ScintillaNET. These deviations from .NET convention are rare, but are done to keep any native Scintilla documentation relevant to the managed wrapper and to avoid situations where trying to force the original API into a more familiar one is more detrimental than helpful.

NOTE: This is not to say that ScintillaNET cannot add, insert, or remove lines. Those operations, however, are handled as text changes, not line changes.

Documentation

Complete API documentation is included with all of our packages. In addition there is extensive documentation at the project Wiki which has recipes for common tasks and questions. If you're new to ScintillaNET, the Wiki is a good place to get started.

As previously noted in the project charter, great effort has been made to keep the ScintillaNET API consist with the native Scintilla API. As such, the native Scintilla documentation continues to be a valuable resource for learning some of the deeper features.

Conventions

Generally speaking, their API will map to ours in the following ways:

  • A call that has an associated 'get' and 'set' such as SCI_GETTEXT and SCI_SETTEXT(value), will map to a similarly named property such as Text.
  • A call that requires a number argument to access an item in a 'collection' such as SCI_INDICSETFORE(indicatorNumber, ...) or SCI_STYLEGETSIZE(styleNumber, ...), will be accessed through an indexer such as Indicators[0].ForeColor or Styles[0].Size.

The native Scintilla control has a habit of clamping input values to within acceptable ranges rather than throwing exceptions and so we've kept that behavior in ScintillaNET. For example, the GotoPosition method requires a character position argument. If that value is less than zero or past the end of the document it will be clamped to either 0 or the TextLength rather than throw an OutOfRangeException. This tends to result in less exceptions, but the same desired outcome.

License

The MIT License (MIT)

Copyright (c) 2017, Jacob Slusser, https://github.com/jacobslusser

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

scintillanet's People

Contributors

ahmad45123 avatar brisingraerowing avatar jacobslusser avatar jarlob avatar martinrotter avatar nonpi-mattias avatar ptyork avatar stumpii avatar suvjunmd avatar tarobun avatar theryan722 avatar toehead2001 avatar yoann-arseneau avatar zereges avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scintillanet's Issues

Decrease size of ScintillaNET DLL

Compressing the SciLexer DLLs using gzip will decrease their size by about half and hence reduce the size of the final DLL. Implementing this requires gzipped files to be embedded and a minor change to the code, line 862 in Scintilla.cs:GetModulePath()

                            var resource = string.Format(CultureInfo.InvariantCulture, "ScintillaNET.{0}.SciLexer.dll.gz", (IntPtr.Size == 4 ? "x86" : "x64"));
                            var resourceStream = typeof(Scintilla).Assembly.GetManifestResourceStream(resource); // Don't close the resource stream
                            using (var gzipStream = new System.IO.Compression.GZipStream(resourceStream, System.IO.Compression.CompressionMode.Decompress))
                            using (var fileStream = File.Create(modulePath))
                                gzipStream.CopyTo(fileStream);

Migrate the read me to wiki.

Hey,

I am creating an IDE and I want to underline wrong variables that don't exit with a red line.

So is there a way I can access the coloring list and modify it ?

I hope you understand me, If not tell me.

SetSavePoint not marking document as unmodified

The document still reports being modified even when you call SetSavePoint. I even tested to make sure the SavePointReached event was firing, which it was. Am I doing something wrong here?

Support for standard Click, DoubleClick events

Would it be possible to hook into the native Scintilla events and raise the default WinForms events from those?

e.g. SCN_DOUBLECLICK -> DoubleClick event.

Overriding/Adding events to the control would be necessary, as Scintilla has, e.g. SCN_*CLICK events for different items.

SQL Lexer Bug?

I am incorporating the SQL lexer and i came across what I believe is a bug in the styling.

I set the Style.String for SQL and noticed that for it to work the string has to be surrounded by double quotes. This is incorrect.

Me.txtQuery.Styles(ScintillaNET.Style.Sql.String).ForeColor = Color.Red

The proper SQL syntax for strings is a single quote or apostrophe.

Can this be changed on your end or not?

Help with FindPrevious

Hello, I successfully implemented a FindNext method, but am having trouble implementing a FindPrevious method, all of my attempts have failed. Any ideas? Here is what I have for the FindNext method:

txt is the string to search for, and sf is the SearchFlags.

public int FindNext(string txt, int sf)
{
    Scintilla1.TargetStart = 0;
    Scintilla1.TargetEnd = Scintilla1.TextLength;
    Scintilla1.SearchFlags = sf;

    if (Scintilla1.SearchInTarget(txt) != -1) {
        Scintilla1.TargetStart = Scintilla1.CurrentPosition;
        Scintilla1.TargetEnd = Scintilla1.TextLength;
        Scintilla1.SearchFlags = sf;
        if (Scintilla1.SearchInTarget(txt) != -1) {
            Scintilla1.SetSelection(Scintilla1.TargetEnd, Scintilla1.TargetStart);
            Scintilla1.TargetStart = Scintilla1.TargetEnd;
            Scintilla1.TargetEnd = Scintilla1.TextLength;
            return Scintilla1.TargetStart;
        } else {
            Scintilla1.TargetStart = 0;
            Scintilla1.TargetEnd = Scintilla1.TextLength;
            if (Scintilla1.SearchInTarget(txt) != -1) {
                Scintilla1.SetSelection(Scintilla1.TargetEnd, Scintilla1.TargetStart);
                Scintilla1.TargetStart = Scintilla1.TargetEnd;
                Scintilla1.TargetEnd = Scintilla1.TextLength;
                return Scintilla1.TargetStart;
            } else {
                return -1;
            }

        }
    } else {
        return -1;
    }
}

Styles for other languages?

Hello, what you have done is incredible here, so thank you.

I see that there are styles for a few languages, what if I want to set a style for a language such as Ada? Do I have to modify and recompile ScintillaNET myself to add Ada to ScintillaNET.Style?

While the CPP style works for several languages, my editor has to support a lot of languages, and not all have "//" as the comment delineation.

Thanks.

Bug with highlighting end of lines with wrapped text?

My project is a 'Regex helper' program. I may have found a bug when highlighting the end of a paragraph of text in wrapped mode.

Basically, lines are wrapped as expected, but when I highlight the end of the line/paragraph, Scintilla seems to think that the 'fake' newlines that make up the paragraph are also newlines. When in fact, they're just wrapped text. An image is worth a thousand words, so take a look at this:

http://www.skytopia.com/stuff/wildgem-bug.png

I know it's not a bug with my program, since only one match is found as expected (whereas the screenshot looks as though it matches 9!). It doesn't seem like very 'desired' behaviour from Scintilla, so could this be a bug? If not, is there a workaround?

Identify if text is multi line

Hi,

Thank you for continuing the development of this great control! I am in the process of updating the control from 2 to 3 and have encountered numerous changes (most of which I have corrected).

I do have a bit of code that I cannot find a solution for. I would like to know if the selected text is multiline.

Here is my old code:

Dim rng As ScintillaNET.Range = ActiveDocument.txtQuery.Selection.Range

        If rng.IsMultiLine Then
            rng.Text = "/*" & rng.Text & "*/"
        Else
            rng.Text = "--" & rng.Text
        End If

Unfortunately, version 3 does not have a Range object or a isMultiLine property.

Is there a solution for this in version 3?

SQL Lexer Style Question

Continuing the SQL Style conversation...I notice that the default style isn't working (or maybe i'm doing something wrong)...

Me.txtQuery.StyleResetDefault()
Me.txtQuery.Styles(ScintillaNET.Style.Default).Font = "Consolas"
Me.txtQuery.Styles(ScintillaNET.Style.Default).Size = "10"
Me.txtQuery.StyleClearAll()

Me.txtQuery.Styles(ScintillaNET.Style.Sql.Default).ForeColor = Color.Blue
Me.txtQuery.Styles(ScintillaNET.Style.Sql.Number).ForeColor = Color.Black
Me.txtQuery.Styles(ScintillaNET.Style.Sql.Operator).ForeColor = Color.Gray
Me.txtQuery.Styles(ScintillaNET.Style.Sql.String).ForeColor = Color.Red

I would expect the default text color to be BLUE...is my thinking incorrect?

Thanks!

Make SelectedText a property

I need to be able to set the selected text, like in the old Scintilla.

Here is my "rough draft" attempt at doing so:

 public unsafe string SelectedText
        {
            get
            {
                // NOTE: For some reason the length returned by this API includes the terminating NULL
                var length = DirectMessage(NativeMethods.SCI_GETSELTEXT).ToInt32() - 1;
                if (length <= 0)
                    return string.Empty;

                var bytes = new byte[length + 1];
                fixed (byte* bp = bytes)
                {
                    DirectMessage(NativeMethods.SCI_GETSELTEXT, IntPtr.Zero, new IntPtr(bp));
                    return Helpers.GetString(new IntPtr(bp), length, Encoding);
                }
            }
            set
            {
                DirectMessage(Constants.SCI_REPLACESEL, IntPtr. Zero,value);
            }
        }

Just wanted to say thank you.

You have cost me over a week of porting, error fixing, and getting my hands dirty, all just to transition from the old scintilla to this one. And it was the best decision I could have made. For once I was forced to view the source code and as a result, as well as through you teaching and helping me, I learned more about Scintilla and various other topics in this week alone then I did from the months of using the old Scintilla.

Thank you, I've already said it, but I will be sticking around to help/contribute in any way I can.

Making scintilla.Styles assignable?

So, let's say you made scintilla.Styles not just readonly? This would allow people to create their own StyleCollection() as an object and then simply assign that object to scintilla.Styles.

Does that sound like a reasonable idea? Is there a major reason that that would be impossible?

If this is doable, my ultimate goal was to take any of the user-rolled themes that may end up in the Wiki (or any I create for my project) and start adding them to a "managed" DLL of styles that someone can simply include in their project through nuGet to have access to predefined styles for different languages without having to copy/paste examples from the wiki if they didn't care about customizing it themselves. In essence, making a "companion" package to Scintilla that has Scintilla has a prereq. And everything would be simpler if I could just assign the resultant StyleCollection to the scintilla.Styles property.

Managed DLL:

namespace Serysoft.ScintillaNET.Syntax
{
    public class Styler
    {
        private Highlighter highlighter;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="language"></param>
        /// <param name="theme"></param>
        public Styler(Languages language, Themes theme)
        {
            switch (language)
            {
                case Languages.Cpp:
                    highlighter = new Cpp(theme);
                    break;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="scintilla"></param>
        public void Set(Scintilla scintilla)
        {
            scintilla.Lexer = highlighter.Lexer;
            scintilla.SetKeywords(0, highlighter.Keywords[0]);
            scintilla.Styles = highlighter.Theme;
        }
    }

    public class Cpp : Highlighter
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="theme"></param>
        public Cpp(Themes theme)
        {
            base.Lexer = Lexer.Cpp;
            base.Keywords = this.Keywords;

            switch (theme)
            {
                case Themes.Light:
                    base.Theme = this.Light;
                    break;

                case Themes.Dark:
                    base.Theme = this.Dark;
                    break;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        private List<string> Keywords
        {
            get
            {
                List<string> list = new List<string>();

                list.Add("keywords");

                return list;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        private StyleCollection Light
        {
            get
            {
                StyleCollection styles = new StyleCollection(new Scintilla());

                styles[Style.Cpp.String].ForeColor = Color.Red;

                return styles;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        private StyleCollection Dark
        {
            get
            {
                throw Exceptions.DarkNotImplemented;
            }
        }
    }
}

Code Implementation:

Styler styler = new Styler(Languages.Cpp, Themes.Light);
styler.Set(code);

Find/Replace methods?

Are these planned to be implemented? I know the Find/Replace dialog is not planned to be implemented as the project is aimed to be kept cross-platform, but what about just the methods so the user could implement their own? Possibly such as Find, Replace, FindAll, etc. and Regex searching?

Adding a TextChangedDelayed Event.

I would like an event called TextChangedDelayed to be added.

It simply gets called when a player stops typing, Unlike TextChanged event which gets called every character entered.

Why ?.. I have a parser that parses the code however, I won't be called the parser every second but I will refresh it every time the user finishes typing. (Meaning raise his hand from the keyboard).

Still don't get it ?

What I mean is that there will be a property called TextChangedDelayedInterval and will have a default value of lets say 1000, So when the user stops typing for 1 second, The event will get fired.

I did my best to explain it... If you still don't get it, Reply.

Custom Keybinding Commands?

Is it possible to use a method as a command? Or do I have to modify ScintillaNET to add them in?

For example I want to create a key binding for my method to display my snippet list. Is this possible?

Sorry for my storm of questions and whatnot.

Assembly generation failed -- Referenced assembly 'ScinetillNet' does not have a strong name

Hello, I'm not sure if this is an issue or not, but with both the 3.2RC and 3.3 versions, I get "Assembly generation failed -- Referenced assembly 'ScintillaNet' does not have a strong name" when building.

I managed to get rid of the error using the steps here: http://www.codeproject.com/Tips/341645/Referenced-assembly-does-not-have-a-strong-name

Is there a way to get the release to have a strong name by default or am I missing a step in my setup? I installed via Nuget.

Thanks for your help!

Set text for specific line

I'm probably skipping over it, but how do you set the text of a specific line? The Scintilla.Lines(#).Text only gets the text.

How to use ReplaceTargetRe

I take it that ReplaceTargetRe is for using Regex, but I'm not sure how to use it, I'm am confused by this and the GetTag method. Thanks.

Demo Application - Update Frequency

I began working on a demo application in both C# and VB. An issue that I ran into was the fact that this project is updated fairly often (good), but that would mean the demo application would be obsolete quite often. What are your thoughts on the update frequency for the demo application?

XML Lexer?

I've used the previous version of ScintillaNET that was on CodePlex for displaying XML in C# WinForms. I downloaded this new version today and am having issues with setting up an XML lexer. Is there a new way to accomplish this?

Thank you

How to add automatic indention.

When you do a { and then press ENTER, The caret will go back to the first of the line.
Ex: (The | means the caret)

{
|
}

Is there is a way to add auto indention.. So it adds a TAB on the start of the line.
Ex: (The | means the caret)

{
    |
}

What I mean here is: Is there an integrated way or I will have to program it myself ?

Lua lexer?

Hi,

As you said you've been implementing lexers on an "as needed basis" I wonder if you would consider adding lua (http://www.lua.org/) to the list? Is this only possible by extending the library itself? I see that there is a custom recipe for python but it uses the Lexer.Python enum for setting everything up. How would one add support for lua without a dedicated lua enum value? Is there a viable option apart from handling StyleNeeded and doing all the lexing manually?

best regards, nagblock

Outlining how you plan on handling highlighting going forward?

So, in the section called: "Automatic Syntax Highlighting", you outline how to setup the syntax highlighting for Cpp. Previously, all of this was contained in ScintillaNET, was it not? Are you now saying that all the time we need to define these "style sets" ourselves? Also, there is no longer support for SQL?

I'm sorry, I'm just confused about how things are going to be going forward and what I will be expected to do versus what Scintilla will be handling for me. Can you please clarify the future of ScintillaNET in this regard? Thanks.

Event timing reports old incorrect values for WrapCount

I have a Scintillia control with lots of text in it. When I add a ClientSizeChanged event, and then maximize the window, when I then check the WrapCount value for all Lines in the document, Scintilla looks at what the old WrapCount values were. It seems as if they aren't updated in time.

Is it a subtle bug with Scintilla? I mean, I expect these kind of issues with events from time to time as the order in which things happen is important. Is there any hack around this?

To try and remedy the problem, I tried all the events out to see if I could find one that happened AFTER the WrapCount values were properly updated. I didn't find any, except possibly the StyleNeeded event. Well, first off, I'm sure the StyleNeeded event wasn't meant for this, and in my case, the event will be repeated needlessly. In any case, the correct WrapCount values are not reported first time around, so any solution along these lines will be a kludge regardless (perhaps allowing it to be called say a quarter of a second after it being first called, but not later than this - I know; sounds kludgy to say the least).

I have simplified the bug to a small sample project if you would like me to post the link to the VS project. Or maybe I could post the full designer code + Form1.cs code directly here.

Multiline comment CPP style ...

Hi,
Testing the .net component i found the multiline comment for a CPP language style it's not working.

/*
Multiline comment ....
*/

Form load c# sample.

scintilla.Lexer = Lexer.Cpp;
scintilla.Styles[Style.Cpp.CommentLine].ForeColor = Color.FromArgb(0x00, 0x7F, 0x00);
scintilla.Styles[Style.Cpp.CommentLine].Italic = true;

scintilla.Styles[Style.Cpp.CommentDoc].ForeColor = Color.FromArgb(0x00, 0x7F, 0x00);
scintilla.Styles[Style.Cpp.CommentDoc].Italic = true;

scintilla.Styles[Style.Cpp.CommentDocKeyword].ForeColor = Color.FromArgb(0x00, 0x7F, 0x00);
scintilla.Styles[Style.Cpp.CommentDocKeyword].Italic = true;

scintilla.Styles[Style.Cpp.CommentDocKeywordError].ForeColor = Color.FromArgb(0x00, 0x7F, 0x00);
scintilla.Styles[Style.Cpp.CommentDocKeywordError].Italic = true;

scintilla.Styles[Style.Cpp.CommentLineDoc].ForeColor = Color.FromArgb(0x00, 0x7F, 0x00);
scintilla.Styles[Style.Cpp.CommentLineDoc].Italic = true;

scintilla.Styles[Style.Cpp.Preprocessor].ForeColor = Color.FromArgb(0x00, 0x7F, 0x00);
scintilla.Styles[Style.Cpp.Preprocessor].Italic = true;

scintilla.Styles[Style.Cpp.PreprocessorComment].ForeColor = Color.FromArgb(0x00, 0x7F, 0x00);
scintilla.Styles[Style.Cpp.PreprocessorComment].Italic = true;

scintilla.Styles[Style.Cpp.PreprocessorCommentDoc].ForeColor = Color.FromArgb(0x00, 0x7F, 0x00);
scintilla.Styles[Style.Cpp.PreprocessorCommentDoc].Italic = true;

Problem about Drag & Drop

Hello,
I use ScintillaNet and I would like to implement a drag & drop between TreeView and Scintilla.

I developed ItemDrag event for TreeView and DragEnter and DragDrop events for ScintillaNet.
I have verified that the "allowdrop" property is true.
But my problem is that the DragDrop event does not fire.
I do not know what to try...

Thank you for your help.

ps : sorry for my English

Optimizing GetStyleAt() ?

After experiencing the various horrors of the RichTextBox when developing my OpalCalc software, I though I'd give ScintillaNET a whirl for my latest project. So far, so good. There aren't any of the flickering issues, and highlighting is a LOT faster. Thank you to the original programmers and of course those who ported this to .NET.

Anyway, even though it's generally fast, I was hoping there may be a way to get GetStyleAt() faster. In theory, it should be able to access the memory as if it were an array, though I suspect there's a reason why things aren't so simple (hmmm... accessing scintilla1.Text[x] is also relatively slow, so perhaps it's not just a simple linear array for the characters?).

My purpose is for my own custom highlighting scheme. I'm aware of the StyleNeeded event, though I need to highlight the (currently visible) page of text arbitrarily, and not simply nearby the text that's currently being typed out by the user. Looking at just the current visual page of text seems to be the simplest way of going about this.

Copy RTF and HTML to Clipboard

I am new to ScintallaNET and maybe I'm just missing a setting that turns this on, but whenever I copy/paste syntax highlighted text, the clipboard doesn't also get the syntax highlighting with it. I know that, essentially, none of that information is saved to the file and so it's just text and that only the presentation of it in the editor is actually where the coloring is being done. But, is there some way to get the syntax highlighting to go with the copy so that it can be pasted into an email to a co-developer so they can read it more easily and not just see black text?

Font assign encoding problem (base Scintilla library update)

From scintilla 3.5.3 all multibyte support(win98 legacy) has been removed. Now styling functions in scintilla receives fontname in UTF-8 encoding, not windows default.

Current ScintillaNET still uses Encoding.Default to assign font names, but it fails when non-ascii named fonts applied. (e.g. CJK language fonts)

Encodings should be changed to UTF-8.

Documentation of changeset since previous releases

I was using a previous release, but suddenly a bunch of functions/properties which I was used to disappeared (ex: GetWordFromPosition, Lexing, AutoComplete), or had its name changed (CurrentPos -> CurrentPosition) and I'm having trouble to figure out whether I will have to code the function or only change the name I was used to.
So it would be great to have a documentation on the changeset, and in the first place why these functions/properties were deprecated?

caret on margins

I'm not sure why I can see caret on margins when moving mouse. See the picture below.
image
When I stop moving, the cursor displays as arrow. But when I'm moving the mouse, it displays as caret. Do you have any opinions about this?
Thanks.

Question about events

What events are identical to DocumentChange and ModifiedChanged of previous versions?

Is there a plan to implement IncrementalSearcher for newer version?

Getting access violation during async file load example

On Win7 64 bit with plenty of memory, SSD, recent i7.

Any CPU build, from WPF (right after a WinForms OpenFileDialog selection of the file name). This is happening consistently.

An unhandled exception of type 'System.AccessViolationException' occurred in ScintillaNET.dll

   at ScintillaNET.Loader.AddData(Char[] data, Int32 length)
   at WpfEditor.BackendStartup.<LoadFileAsync>d__6.MoveNext() in d:\dev\BackendStartup.cs:line 130
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.InvokeMoveNext(Object stateMachine)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run()
   at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.<.cctor>b__6(Object state)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
   at WpfEditor.App.Main() in d:\dev\WpfEditor\obj\Debug\App.g.cs:line 0
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

The simplest way to activate a highlight syntax

Hi,

In older versions, it was necessary only to set:

scintilla.ConfigurationManager.Language = "python";

to have a nice python editor up and running.

As I moved to 3.3 version, initially I tryied to do:

scintilla.Lexer = Lexer.Python;

But anything happened, that is, the editor didn´t show syntax highlighting.

Checking README.md file, I saw an example showing how to configure a C# editor defining all features corresponding to Visual Studio-style editor.

It´s necessary to do those definitions for all languages? That is, there´s no way to define Scintilla as a Python, R or MSSQL only defining a property.

If so, could you find examples for those other languages?

Tks in advance,

Mauro Assis

Documents and custom syntax highlighting

Hello,

I'm using Scintilla to do some custom syntax highlighting for HLASM (that's IBM mainframe assembler), by hosting it in WPF. I can read in my data, display it and highlight, so all is well there. However, I would like to be able to open another data file, read it, display it and highlight it as well.

The doc wasn't exactly very clear on this, so I created a new document, set it to as the new document and release the old one, like so:

var oldDoc = scintilla.Document;
scintilla.Document = new Document();
scintilla.ReleaseDocument(oldDoc);

Once the document is created, I start appending text to the control. However, it seems like either the styleposition or textLength field is not being reset properly, so my syntax highlight blows up in SetStyling() with
ArgumentOutOfRangeException("length", "Position and length must refer to a range within the document.");

Any idea what I am doing wrong here?

Thanks

Native memory stream length may be incorrect after calling Write

The Write method always adds the buffer's length to the stream's length which causes an incorrect value when the position is not at the end of the stream. The fix is to change
length += count;
on line 84 to
length = Math.Max(length, position);

You can test this as follows:

using System;
using System.IO;
using ScintillaNET;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace ScintillaNET.Tests
{
[TestClass]
public class NativeMemoryStreamTests
{
[TestMethod]
public void StreamLengthTest()
{
// the way it ought to work
StreamLengthTest(() => new MemoryStream());
// the way we work
StreamLengthTest(() => new NativeMemoryStream(10));
}

    public void StreamLengthTest(Func<Stream> streamMaker)
    {
        using (var stream = streamMaker())
        {
            var buffer = new byte[] { 2, 3, 4 };
            stream.Write(buffer, 0, 3);
            Assert.AreEqual(3, stream.Length);
            stream.Write(buffer, 0, 3);
            Assert.AreEqual(6, stream.Length);
            stream.Seek(0, SeekOrigin.Begin);
            stream.Write(buffer, 0, 3);
            Assert.AreEqual(6, stream.Length);
            stream.Seek(4, SeekOrigin.Begin);
            stream.Write(buffer, 0, 3);
            Assert.AreEqual(7, stream.Length);
        }
    }
}

}

DLL Initialization fail when Scintilla component is open in multiple studios

I believe this has to do with ScintillaNET trying to extract the Scilexer DLL's to a temp folder. If I have a project in Visual Studio with a ScintillaNET component on it, I can not then open another project in another instance of Visual Studio with the ScintillaNET component, if you try to view the form, it states the DLL has failed to initialize.

The trouble I am having is recreating this issue, it doesn't happen all of the time.

This is obviously a rare case as I don't imagine many people working on 2 projects at the same time with the component.

Create a ScintillaNET demonstration app

Because of an earlier issue where I have had problems with the custom lexer in Scintilla.Net 2.6 [https://scintillanet.codeplex.com/discussions/633010] I've tried to change my project which based on the SCide from Codeplex.net to ScintillaNET 3.3, but it looks like this library is not compatible with the one from codeplex. Is there any container project for the newer ScintillaNET 3.3?

ScintillaNet examples for VB.NET

1st of all thanks for sharing ScintillaNET.
it's a great idea

I am searching an example in vb.net to understand better how to create my own basic editor.
I tried to use ScintillaNet 2, with less difficults because I found and example.
I need to integrate in my project an SQL editor with basic and strong feature like:

  • Highlight code
  • Autocomplete:
    a) SQL keywords
    b) a couple of my own stuff like list databases, list of tables, list of column
    c) I would like add the all words of current text, maybe I have to do it myself or just active a flag because it is a feature already embedded in scintilla?
    d) If it is possible add for each keyword, a description and a prefix. Prefix usefull to group my own keywords. For example if I write #db I would like see the list of databases and when I select one of if I don't include the prefix #db in my text.
  • Maybe the "call tips" can help me refering the above request? I would like an example.

Where i can find an example?
grazie mille
Antonino Migliore

Questions

Will the search/find form be implemented by default again?
Making custom lexer highlights via xml?

BUG
When displaying line numbers and you have alot in the editor, it messes up the numbers and doesn't display them fully. (Lines 1-100 show then 1000+ shows 000 etc)

Horizontal Scrollbar is shown when it shouldn't be

When the HScrollBar property is set to true, it should only display the scrollbar when it is needed but it currently displays it when it is not needed (for example when there is no text in the box or the text width is less than the width of the ScintillaNet control)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.