Giter Club home page Giter Club logo

scintilla.net's Introduction

Scintilla.NET

.Build validate .NET NuGet Release NuGet

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

Note

I updated the Nuget package name to Scintilla5.NET for those searching the gallery.

"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

Scintilla.NET can also be used with WPF using the WindowsFormsHost. For Linux, see the Scintilla.NET.Gtk.

Utility assemblies

Project Status

This project is continuing from the abandoned ScintillaNET by Jacob Slusser and transferred from VPKSoft who has done an incredible job of updating and extending the original project.

Scintilla.NET 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. NOTE: I don't read the issues posted to the main fork - so if your issue is about this project, post it here.

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 2022.

Technical notes

Versions before v.5.3.1.1: Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017, 2019, and 2022 is required for the component to work, see #16.

Scintilla library version = 5.5.0

Lexilla library version = 5.3.2

Background

For more information about the history and background information, look at the wiki here.

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.

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.

scintilla.net's People

Contributors

ahmad45123 avatar ahmetsait avatar brisingraerowing avatar darssy avatar desjarlais avatar frychnavskycvs avatar huberhans avatar jacobslusser avatar jarlob avatar jmairboeck avatar martinrotter avatar msarson avatar nonpi-mattias avatar pabs84 avatar ptyork avatar robswdev avatar stumpii avatar suvjunmd avatar tarobun avatar theryan722 avatar toehead2001 avatar vpksoft 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

scintilla.net's Issues

is json lexer broken ? WPF

to verify:
WPF + WindowsFormsHost application
.Net 6
Scintilla.NET v5.3.2.9

<Window x:Class="WpfApp1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WpfApp1" xmlns:ScintillaNET="clr-namespace:ScintillaNET;assembly=Scintilla.NET" mc:Ignorable="d" Title="MainWindow" Height="450" Width="800"> <Grid> <WindowsFormsHost> <ScintillaNET:Scintilla x:Name="Text" Margin="10,31,10,10"> </ScintillaNET:Scintilla> </WindowsFormsHost> </Grid> </Window>

`using ScintillaNET;
using System.Windows;

namespace WpfApp1
{
///


/// Interaction logic for MainWindow.xaml
///

public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();

        Text.StyleResetDefault();
        Text.Styles[ScintillaNET.Style.Default].Font = "Consolas";
        Text.Styles[ScintillaNET.Style.Default].Size = 10;
        Text.Styles[ScintillaNET.Style.Default].ForeColor = System.Drawing.Color.Black;
        Text.StyleClearAll();

        Text.Lexer = Lexer.Json;
        Text.Styles[ScintillaNET.Style.Json.Default].ForeColor = System.Drawing.Color.Black;
        Text.Styles[ScintillaNET.Style.Json.Number].ForeColor = System.Drawing.Color.Blue;
        Text.Styles[ScintillaNET.Style.Json.String].ForeColor = System.Drawing.Color.Blue;
        Text.Styles[ScintillaNET.Style.Json.StringEol].ForeColor = System.Drawing.Color.Purple;
        Text.Styles[ScintillaNET.Style.Json.PropertyName].ForeColor = System.Drawing.Color.Brown;
        Text.Styles[ScintillaNET.Style.Json.EscapeSequence].ForeColor = System.Drawing.Color.Red;
        Text.Styles[ScintillaNET.Style.Json.LineComment].ForeColor = System.Drawing.Color.DarkGreen;
        Text.Styles[ScintillaNET.Style.Json.BlockComment].ForeColor = System.Drawing.Color.DarkGreen;
        Text.Styles[ScintillaNET.Style.Json.Operator].ForeColor = System.Drawing.Color.LightGray;
        Text.Styles[ScintillaNET.Style.Json.Uri].ForeColor = System.Drawing.Color.LightGray;
        Text.Styles[ScintillaNET.Style.Json.CompactIRI].ForeColor = System.Drawing.Color.LightGray;
        Text.Styles[ScintillaNET.Style.Json.Keyword].ForeColor = System.Drawing.Color.LightGray;
        Text.Styles[ScintillaNET.Style.Json.LdKeyword].ForeColor = System.Drawing.Color.LightGray;
        Text.Styles[ScintillaNET.Style.Json.Error].ForeColor = System.Drawing.Color.Red;

        Text.Text = "[{ \"hello\":\"world\",\"lexer error\":true},{ \":)\":false}]";
    }
}

}
`

you can see this result:

Lexer

the boolean will be parsed as ScintillaNET.Style.Json.Error and will continue until a new line is found :(

Scintilla.Net 5.3.1.3 don't work when Devexpress libraries added to project

Hi!

Github issue from original branch

jacobslusser/ScintillaNET#526

Step-by-step reproduction

  • Create blank WinForms app (Net 7)
  • Install Scintilla.Net 5.3.1.3 nuget package
  • Put Scintilla.Net control on form from toolbox
  • All works fine
  • Add Devexpress libraries to project (via open DevExpress Project Settings and click Add Libraries)
  • Try to open Form In Design mode
  • Scintilla control disappear.
  • Try to put Scintilla control on form again - we get the following error
Request failures: DesignerHosts/CreateComponent.
                       Microsoft.DotNet.DesignTools.Client.DesignToolsServerException: Method not found: 'Void System.Security.AccessControl.MutexAccessRule..ctor(System.Security.Principal.IdentityReference, System.Security.AccessControl.MutexRights, System.Security.AccessControl.AccessControlType)'.

                       For information on how to troubleshoot the designer refer to the guide at https://aka.ms/winforms/designer/troubleshooting.
  • Remove Devexpress package from project - all works fine now

Detailed description of problem from Devexpress

https://supportcenter.devexpress.com/ticket/details/t1133409/scintilla-net-5-3-1-3-don-t-work-when-devexpress-libraries-added-to-project

I understand that you do not use commercial libraries, but please see what you can do

Thanks!

Customize the location and filename of the native DLLs

I'd like to request the ability to customize modulePathScintilla and modulePathLexilla

Right now this isn't possible because the relevant parts in Scintilla.cs are marked as private (not protected)

Another option could be to allow us to define some configuration options, or just expose the statics and make them writeable

Looking for a new maintainer

Discussed in #78

Originally posted by VPKSoft September 8, 2023
Hi,
I'm looking for someone to take over this project. I'm just currently too busy and my interests are elsewhere to keep maintaining this.
This also applies to the satellite assemblies:

It has been fun for over three years with this project after continuing from the original, which was abandoned after Oct 31, 2018. That is why I wish to transfer the ownerships of these projects rather than leaving them unmaintained in silence.

Please reply to this message in public if you wish to continue with the project or some of these satellite assemblies πŸ‘

Changing style doens't effect text

Hi, I'm trying to change the style to highlight some words in color and bold. So I use the code below. Color is changing fine, but words aren't bold.

scintilla1.Styles[ScintillaNET.Style.Sql.Identifier].ForeColor = Color.LightGray;
scintilla1.Styles[ScintillaNET.Style.Sql.Identifier].Bold = true;

I did further testing and bold, italic and size properties aren't changing visuals of the text. Am I doing something wrong or is it a bug?

scintilla1.Styles[ScintillaNET.Style.Sql.Identifier].Italic = true;
scintilla1.Styles[ScintillaNET.Style.Sql.Identifier].Size = 100;

Minor Bug in set Scintilla.LexerName

If SetLexerByName(value) fails, then lexerName is not yet set, and so not reported (or the previous version is reported) in the exception message.

            set
            {
                if (string.IsNullOrWhiteSpace(value))
                {
                    lexerName = value;

                    return;
                }

                #if SCINTILLA5
                if (!SetLexerByName(value))
                {
                    throw new InvalidOperationException(@$"Lexer with the name of '{lexerName}' was not found.");
                }
                #elif SCINTILLA4
                if (NativeMethods.NameConstantMap.ContainsValue(value))
                {
                    Lexer = (ScintillaNET.Lexer) NativeMethods.NameConstantMap.First(f => f.Value == value)
                        .Key;
                }
                #endif

                lexerName = value;
            }

Regular TextBox control influenced by Scintilla contro

I have noticed that in some cases regular win forms TextBox control is influenced by Scintilla.Net control in way that caret on TextBox control is jumping back and forth just by moving the mouse over the text box control. This happens when on single forms TextBox, Scintilla and TabControl are placed.

To Reproduce
Create simple windows forms app, .Net 8, add text box control, scintilla control and tab control. Run it, type some text in textbox and observe caret behavior when mouse is moved over it. There are no events assigned, just simple placing controls on the forms and run it.

It noticed two workarounds so far that removes this behavior:

  1. When in forms.designer.cs I comment out following line: scintilla1.UseRightToLeftReadingLayout = false;
  2. Or if I type something into scintilla control and press enter, the it stops. Adding text with the code, does not help -it has to by typed in

Expected behavior
There should not be any influence on regular textBox control in any way.

Screenshots
2023-12-15 19_04_50-Form1

Desktop (please complete the following information):

  • Windows 11, .Net8, Visual Studio 17.8.3

Thx
Ivan

SetLexerByName does not cache the lexer created, instead it creates a new one each time.

Describe the bug
SetLexerByName does not cache the lexer created, instead it creates a new one each time.

To Reproduce
call SetLexerByName(valid_lexer_name) multiple times, each time a new handle is created

Expected behavior
call SetLexerByName(valid_lexer_name) multiple times, only the first time a new handle is created, this avoid a memory leakage in lexilla

a Dictionary<string, IntPtr>lexerName to Handle might be necessary.

this behavior is particularly important for applications dynamically selecting the lexer

Unable to add ScintillaNET control from Toolbox for v5.3.2.4 and newer in WinForms (.NET Framework)

Describe the bug
When you try to add the ScintillaNet control to a Form in a WinForms app (.NET Framework 4.5+) you get an exception instead of the control being added.

Error Message
Failed to create component 'Scintilla'. The error message follows:

'System.ComponentModel.Win32Exception (0x80004005): Could not load the Scintilla module at the path 'C:\Users<UserName>\AppData\Local\Microsoft\VisualStudio\17.0_877463f4\ProjectAssemblies\pa0jc1fh.tmw01....\build\x64\Scintilla.dll'. ---> System.ComponentModel.Win32Exception (0x80004005): The specified module could not be found

at ScintillaNET.Scintilla.get_CreateParams()

at System.Windows.Forms.Control..ctor(Boolean autoInstallSyncContext)

at ScintillaNET.Scintilla..ctor()'

To Reproduce

  • Create a .NET Framework WinForms app
  • Add the ScintillaNET Nuget package with version 5.3.2.4 or newer
  • try to add a ScintillaNET control to a Form and an exception is thrown

Expected behavior
The control is added to the form without any exception. This is the case with version 5.3.2.3 and older

Environment:

  • Windows 11
  • Visual Studio 2022
  • .NET Framework 4.5+

Undo and Redo

I'm trying to implement an undo/redo for Scintilla.NET. I have implemented the undo ... but for the life of me I cannot implement the redo.

Scintilla.NET has a built-in undo, but its Redo() does not work and CanRedo is read-only and set to false when I test for it.

Anyone have any ideas on how to implement/activate the redo?

(Yes, I have done a Google search and here for this issue and found nothing.)

Text does not style completely unless scrolled

When we have a textbox with custom styling. The style does not get applied completely even though it is visible. (look at lines 26 onward)
image

I like to render the full text once it is visible, not the parts that are hidden.

Any idea how to achieve this?

Setting e.Handled=true in the KeyDown event handler has no effect

Well I'm trying to activate (show) the autocomplete list box always when the user hits CTRL+SPACE in the Scintilla edit control, independent of what was actually typed so far. (I'm using V5.3.2.9)

Here's my code:

        private void edScintillaSql_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Control && e.KeyCode == Keys.Space && sender is Scintilla sc)
            {
                string s = "Some|Prepared|Entries";
                if (!string.IsNullOrEmpty(s))
                    sc.AutoCShow(-1, s);
                 e.Handled = true;
            }
        }

This actually already works fine. But when the user hits that key combination (Control+Space), a space character is still inserted, even though I try to suppress it by setting e.Handled = true. When the user then picks an entry from the list that space is removed again. But if he/she doesn't, the space input remains in the text.

How can I make it so the the space doesn't get instered at all?

Thanks

Scintilla control not visible on form designer

I downloaded latest available source code. Took sample application provided within the repo, add Scintilla.Net control source code as project reference to solution. Program compiles fine and runs, but when in designer mode Scintilla control not visible neither on the form nor control toolbox. Usually I get it through nuget and no issues theres, only in this case when source code is used as part of solution.

Additional issue/request: by default current row is highlighted in black color, meaning you can not see what you type (as font by default is also black), neither caret is visible. Can be confusing for beginners, like it confused also me when switched to this project version - i thought something is wrong with control.

2023-12-26 18_22_14-Scintilla NET - Microsoft Visual Studio
2023-12-26 18_22_56-ScintillaNET TestApp  Β© desjarlais 2023

Environment is Win11, VS 17.8.3

Thx
Ivan

Function segmentation and Accolade

If I want to segment a part of the code between two brackets or a function, is there a Regex or Property that I can set? And is it the same in different lexers?
Also, how can I close automatically when a bracket, parenthesis, brace, tag is written in html and xml?

Untitled

Autocomplete for .NET 4.5.2...

I am upgrading a .NET 4.5.2 project from the old CodePlex Scintilla.NET v2.5.2 to VPKSoft ScintillaNET v5.3.1.3. I've got everything working except the autocomplete. The main problem that I'm running in to is that the old component had and AutoCompleteList property, and I can't find a corresponding property on the new component.

Looking at your wiki, I saw the link to the AutoCompleteMenu-ScintillaNET project. However, when I tried to install that package, I found that it only supports .NET 4.6.1.

Is there an autocomplete solution that I can use for .NET 4.5.2?

ANSI Escape Codes Seemingly not Working

Hi! I'd like to use Scintilla.NET to be able to show colored git diff results.
TortoiseGit uses scintilla to that effort so it should be possible in theory.

In SciTE, after adding a lexer.errorlist.escape.sequences=1 property in an options file, and setting the lexer to Errorlist via the Language menu, the escape codes are parsed fine.
git diff --color=always.txt
image

However, despite setting the property to 1 and using errorlist as our lexer, the escape codes are still shown as is, instead of being interpreted.
image
image

Am I missing something or is there something that could be improved to make them work?

GetTextRange wide character inconsistency

Describe the bug
The length parameter of the GetTextRange method is not consistent with the TextLength property and other length/positional properties of Scintilla.NET.

To Reproduce

var text = "😁😁😁";
Assert.AreEqual(6, text.Length); // Succeeds, because each 😁 is 2 characters wide
Assert.AreEqual("😁", text.Substring(0, 2)); // Succeeds

scintilla1.Text = text;
Assert.AreEqual(6, scintilla1.TextLength); // Succeeds
Assert.AreEqual(6, scintilla1.Lines[0].EndPosition); // Succeeds
Assert.AreEqual("😁", scintilla1.GetTextRange(0, 2)); // Fails, as GetTextRange returns "😁😁"

Expected behavior
GetTextRange should have consistent behavior with the other length/position properties and methods of Scintilla.NET. The inconsistency is illustrated above. Alternatively, there should be another method or an optional parameter that lets us specify how wide characters should be handled.

Appearance bug in designer

@lgaudouen wrote:

Appearance in design mode related to the CaretLineVisible, CaretLineVisibleAlways, CaretLineBackColor and CaretLineBackColorAlpha properties. When inserting a Scintilla.NET control, the name of the control appears clearly and the values of the CaretLineVisible, CaretLineVisibleAlways properties are set to False by default. If you close the form designer and reopen it, the CaretLineVisible property automatically changes to True.

TextLength doesnt return valid result

Describe the bug
For some reason, TextLength is not reporting a valid result. I set Text property with a string consisting of 95 characters, and yet, TextLength reports 158!

To Reproduce
var s = "MyProductName5 version 1.2.0.0\r\nΒ© 2022 Name of Developer, [email protected]\r\n\r\ninput 1 >\r\n";
this.Text = s;
var n1 = s.Length; // 95
var n2 = this.TextLength; // 158

Expected behavior
TextLength should have reported 158 given the string passed.

Desktop (please complete the following information):

  • OS: Windows 11 running on 64-bit

CSS files visualization problem

After days of unsuccessful attempts to use the VPK package Scintilla.NET for CSS files, I found the VPK project ScintillaLexers-v.1.1.15 which was to bring me the solution to the configuration of Scintilla and the Css lexer (with in addition the recovery of Notepad++ parameters).
Unfortunately, the display of a css file by TestLexer is incorrect (see image).
Would you have the solution?

cssIssue

Framework 4.8 Unable to place control

As mentioned, I'm using Framework 4.8 on Windows 10 but this is also happening with 4.5.2.

I added Scintilla to a project with framework 4.5 however I need to update the framework to at least 4.5.2 and figured since I'm updating it, might as well update all the way up to modern day (sort of). Everything else updated fine however I'm getting an issue with Scintilla where it broke the form in the designer so I created a new project and tried to add it again and I'm met with an error message:

---------------------------
Microsoft Visual Studio
---------------------------
Failed to create component 'Scintilla'.  The error message follows:

 'System.ComponentModel.Win32Exception (0x80004005): Could not load the Scintilla module at the path 'C:\Users\USERNAME\AppData\Local\Microsoft\VisualStudio\16.0_a4ee1e43\ProjectAssemblies\l7qy_paq01\..\..\build\x86\Scintilla.dll'. ---> System.ComponentModel.Win32Exception (0x80004005): The specified module could not be found

   at ScintillaNET.Scintilla.get_CreateParams()

   at System.Windows.Forms.Control..ctor(Boolean autoInstallSyncContext)

   at System.Windows.Forms.Control..ctor()

   at ScintillaNET.Scintilla..ctor()'
---------------------------
OK   
---------------------------

I've tired a couple different versions and still nothing. I might be missing something simple but I feel like I've exhuasted all of my ideas.

Steps to Reproduce

  1. Create a new VB Framework project.
  2. Download Scintilla.NET 5.3.2.4 from NuGet
  3. Open Form1.vb in designer
  4. Find Scintilla in the toolbox under Scintilla.NET
  5. Drag and drop it to the form
  6. Met with an error

Thank you for your good work and support!

EDIT: I should mention that both my main app and test app are both 32bit.

CaretLineBackColor is black by default

Describe the bug
CaretLineBackColor is black by default when adding the control to a form.

To Reproduce

  1. Create a Winfrom app
  2. Add the scintilla5 nuget package
  3. add the scintilla control to the form
  4. build and run the app

Expected behavior
CaretLineBackColor should be white

Wide character issue introduced between 5.3.3.6 and 5.3.3.9

Describe the bug
Hi, first of all, thanks for taking up the job of maintaining Scintilla.NET.
There is some kind of issue in the way which the package deals with wide characters. It affects searching and indicator fills, and probably much more.
I am not well versed in the internals of Scintilla so I will demonstrate with an example.

To Reproduce
Steps to reproduce the behavior:
Create a new project.
Add a Scintilla control and a button.
In Form1_Load, add the following code:

scintilla1.Text = "Γ€ Γ€ Γ€";

Note that Γ€ is encoded as 0xC3 0xA4 in UTF8. I doubt the exact characters matter, the string just has to be of the form "{wide} {wide} {wide}".

In the button's click handler, add the following code:

scintilla1.IndicatorCurrent = (int)8;
scintilla1.IndicatorClearRange(0, scintilla1.TextLength);
scintilla1.IndicatorFillRange(0, 1);
scintilla1.IndicatorFillRange(2, 1);
scintilla1.IndicatorFillRange(4, 1);

The intention here is to underline every "Γ€" when the button is clicked.

Expected behavior
Every Γ€ should have line under it, like so:

5 3 3 6

This is what happens in version 5.3.3.6.

However, starting with version 5.3.3.9, it actually looks like this:

5 3 3 16

It looks the same in 5.3.3.16. It looks like it's just underlining the first Γ€ and the space. It seems very likely that the underlying issue is due to the handling of wide characters.

Desktop (please complete the following information):

  • OS: Windows
  • Version 11

Additional context
Possibly related to #65 ?

version 3.3.3.n not found in NuGet Gallery

It seems that the Scintilla.NET v3.3.3.6 package is not released: the latest one available in the NuGet Gallery is v5.3.2.9.
But version 5.3.2.9 in NuGet Gallery doesn't work anymore either.

Applying styles dynamically and loading from a settings file issue

Hello everyone, i have a small issue that is driving me crazy, i setup my styles like the example below now when i run the app and load a file everything shows ok an i intentionally want the editor font and the line number font to be different now when i change the font from a font dialog and save the value to a settings file i call for those 2 voids to update the fonts of the editor now what happens is both line numbers and editor font change together. so my question is does scintilla1.Styles[Style.Default].Font overwrite the line numbers font and why ?

how things are supposed to be when i first load the app ( excuse the crazy fonts, just to showcase the difference )

image

Here is how it becomes after changing the font

image

public void jsonStyling()

{
// scintilla1.StyleClearAll();

// Configure thejson style

scintilla1.StyleResetDefault();
string? tt = Properties.Settings1.Default.DeFont.OriginalFontName;
scintilla1.Styles[Style.Default].Font = tt;
scintilla1.Styles[Style.Default].SizeF = Properties.Settings1.Default.DeFont.Size;
scintilla1.Styles[Style.Default].Italic = Properties.Settings1.Default.DeFont.Italic;
scintilla1.Styles[Style.Default].Bold = Properties.Settings1.Default.DeFont.Bold;
scintilla1.Styles[Style.Default].ForeColor = Properties.Settings1.Default.Dforecolor;
scintilla1.Styles[Style.Default].BackColor = Properties.Settings1.Default.EditorBC;
cintilla1.StyleClearAll();
scintilla1.LexerName = "json";
scintilla1.SetKeywords(0, "false true");
scintilla1.SetProperty("lexer.json.allow.comments", "1");
scintilla1.SetProperty("lexer.json.escape.sequence", "1");
scintilla1.Styles[Style.Json.Default].ForeColor = Color.Turquoise;
scintilla1.Styles[Style.Json.LineComment].ForeColor = Color.FromArgb(0, 128, 0); // Green
scintilla1.Styles[Style.Json.Number].ForeColor = Color.OrangeRed;
scintilla1.Styles[Style.Json.String].ForeColor = Color.LightSkyBlue;
scintilla1.Styles[Style.Json.EscapeSequence].ForeColor = Color.LightBlue;
//Brackets colors
scintilla1.Styles[Style.Json.Operator].ForeColor = Color.Yellow;
scintilla1.Styles[Style.Json.Operator].Bold = true;
//property name
scintilla1.Styles[Style.Json.PropertyName].ForeColor = Color.AliceBlue;//LightBlue;
scintilla1.Styles[Style.Json.PropertyName].Italic = true;
//Keywords
scintilla1.Styles[Style.Json.Keyword].ForeColor = Color.Green;
//Errors
scintilla1.Styles[Style.Json.Error].ForeColor = Color.Red;
//Braces colors
scintilla1.Styles[Style.BraceLight].ForeColor = Color.Orange;
scintilla1.Styles[Style.BraceBad].ForeColor = Color.Red;
// Set the keywords

}

and

public void UiStyling()
{
scintilla1.CaretStyle = ScintillaNET.CaretStyle.Line;

string caretStyleValue = Properties.Settings1.Default.CaretStyle; // Get the value from the settings

switch (caretStyleValue)
{
    case "Line":
        scintilla1.CaretStyle = ScintillaNET.CaretStyle.Line;
        break;

    case "Block":
        scintilla1.CaretStyle = ScintillaNET.CaretStyle.Block;
        break;

    case "Invisible":
        scintilla1.CaretStyle = ScintillaNET.CaretStyle.Invisible;
        break;

    default:
        scintilla1.CaretStyle = ScintillaNET.CaretStyle.Line; // Handle the case where the value is none of the expected options
        break;
}

scintilla1.Margins[1].BackColor = Properties.Settings1.Default.MarginBackcolor;
scintilla1.Margins[0].Type = MarginType.Number;
scintilla1.Margins[0].BackColor = Properties.Settings1.Default.MarginBackcolor;
scintilla1.Styles[Style.LineNumber].BackColor = Properties.Settings1.Default.uLineNumBc; //Color.FromArgb(12, 12, 12);
scintilla1.Styles[Style.LineNumber].ForeColor = Properties.Settings1.Default.uLineNumFc; //Color.Red;
scintilla1.Styles[Style.LineNumber].Font = "Algerian";    //Properties.Settings1.Default.DeFont.OriginalFontName;
scintilla1.Styles[Style.LineNumber].SizeF = 16;
scintilla1.Styles[Style.IndentGuide].ForeColor = Color.Aquamarine;

}

Error adding control in .NET Framework

Describe the bug
Error attempting to add control to .NET Framework project "Failed to create component 'Scintilla'."

To Reproduce

  1. Create or Open a .NET Framework project
  2. Install the Scintilla5.net nuget package
  3. Open the Toolbox and attempt to drag or draw the control to the form

Expected behavior
The control is added to the form

'Scintilla.Lexer' is obsolete

I am recieiving the following warning in project using Scintilla.NET 5.3.2.9, the latest version.
warning CS0618: 'Scintilla.Lexer' is obsolete: 'This property will get more obsolete as time passes as the Scintilla v.5+ now uses strings to define lexers. Please use the LexerName property instead.'

I cant find any documentation on what the valid Lexername values are.
On the page Automatic Syntax Highlighting it still shows the example scintilla.Lexer = Lexer.Cpp;

Container Lexer not selectable in 5.3.3.15

        public string LexerName
        {
            get => lexerName;

            set
            {
                if (string.IsNullOrWhiteSpace(value))
                {
                    lexerName = value;

                    return;
                }

                if (!SetLexerByName(value))
                {
                    throw new InvalidOperationException(@$"Lexer with the name of '{value}' was not found.");
                }

                lexerName = value;
            }
        }

the line testing for if (string.IsNullOrWhiteSpace(value)) prevent from SetLexerByName being passed an empty string

All fields been impacted by setting margin of line number.

Describe the bug

To Reproduce
Steps to reproduce the behavior:
when I set the line number margin as scintilla.Margins[0].Width= 20;
the cursor start position of all the text fields in the form move to 20 px from the left

Expected behavior
scintilla configuration should not impact to other components.

Screenshots
image

Desktop (please complete the following information):

  • OS: windows
  • Version 11

Additional context
hope you can help to resolve this issue.

Support for SCI_SETSELECTIONLAYER in order to streamline current line highlighting?

@VPKSoft
Terve!

I would like to ask if it would be possible to add support for the SCI_SETSELECTIONLAYER native method. I was trying to make current line highlighting to work and I used this:

scintillaEditor.CaretLineVisible = true;
scintillaEditor.CaretLineBackColor = Color.Black;
scintillaEditor.CaretLineBackColorAlpha = 255;

The problem was that the line was painted full black over the text! After some trial and error I realized that SCI_SETSELECTIONLAYER could do the trick. More details in scintilla documentation here. I searched for something similar in Scintilla.cs and NativeMethods.cs but I couldn't find anything so I suppose it's not implemented. For me it was as easy to get the desired result by writing

private const int SCI_SETCARETLINELAYER = 2765;
...
scintillaEditor.DirectMessage(SCI_SETCARETLINELAYER, new IntPtr(1), IntPtr.Zero);

But it might be more streamlined if the SC_LAYER_xyz constants were an enum and there was a respective property to set.

I might be wrong though as I am really new to Scintilla(.net) and I might be missing something.

PS: If I'm right though, I could open a pull request if you lack the time.

Lexer is obsolete

Context
As ScintillaNET (https://github.com/jacobslusser/ScintillaNET) is archived and not supported anymore, I upgrade to Scintilla.NET. And Lexer.Container is not supported since scintilla 5.0+ and with no default, lexer Null is accepted only.

With that, when I defined my own language, Styules and set Lexer.Null I do not get StyleNeeded notification anymore.

** Project info:

  • TargetFramework: .net8.0
  • WinForms
  • OS: Windows

Unhandled exception of type 'System.AccessViolationException' occurred in Scintilla.NET.dll

I get this exception in" VisualStudio 2015" and a crash in "Visual Studio 2022" after changing the property "RightToLeft" (Me.Scintilla1.RightToLeft = System.Windows.Forms.RightToLeft.Yes).

In Windows EventViewer i get these entries:

Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
at ScintillaNET.Scintilla.DirectMessage(IntPtr, Int32, IntPtr, IntPtr)
at ScintillaNET.Scintilla.DirectMessage(Int32, IntPtr, IntPtr)
at ScintillaNET.Scintilla.DirectMessage(Int32, IntPtr)
at ScintillaNET.Scintilla.InitDocument(ScintillaNET.Eol, Boolean, Int32, Int32)
at ScintillaNET.Scintilla.OnHandleCreated(System.EventArgs)
at System.Windows.Forms.Control.WmCreate(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)
at ScintillaNET.Scintilla.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Design.ControlDesigner+DesignerWindowTarget.DefWndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Design.ControlDesigner.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Design.ControlDesigner+DesignerWindowTarget.OnMessage(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr, Int32, IntPtr, IntPtr)

Name der fehlerhaften Anwendung: devenv.exe, Version: 14.0.25420.1, Zeitstempel: 0x57685d85
Name des fehlerhaften Moduls: unknown, Version: 0.0.0.0, Zeitstempel: 0x00000000
Ausnahmecode: 0xc0000005
Fehleroffset: 0x0000016a
ID des fehlerhaften Prozesses: 0x3af8
Startzeit der fehlerhaften Anwendung: 0x01d84fc6e411fb12
Pfad der fehlerhaften Anwendung: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe
Pfad des fehlerhaften Moduls: unknown
Berichtskennung: 2b4225c9-eb61-447d-8e05-6a952d6fdb6f
VollstΓ€ndiger Name des fehlerhaften Pakets:
Anwendungs-ID, die relativ zum fehlerhaften Paket ist:

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.