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

New Post: BUG: scintilla.CurrentPos and scintilla.Caret.Position bugged

$
0
0
Unfortunatly that explanations don't help much.

jacobslusser wrote:
Everything you are describing can easily be explained....

What event are you using to trigger the update of your cursor position text box? You weren't specific... but you would definitely need to be using one. The CurrentPos and/or Caret.Position properties aren't going to notify you of changes, and as a result, the value displayed there could be stale.
I wasn't specific on the event because it shouldn't matter. As long as the event reacts in an approproite way (namely after the TextChange happened), the CurrentPos should be correct. But to specify this, I used both the TextChanged and the SelectionChanged Event as well as the suggested NativeScintilla.UpdateUI Event. Both the TextChanged and SelectionChanged Events do get fired.

Especially annoying is the fact that if I type in a space (which triggers the TextChanged Event in any case) it only doesn't work on the first space after a letter - after that it does work, so this can only be a bug.

jacobslusser wrote:
As for the position value being off when you use Unicode characters such as ü', 'ä' or 'ö'... that is because those properties tell you the current byte offset, not the character offset. As you may know Unicode characters can often require more than one byte of storage. This problem is a limitation of the native Scintilla component and has been well documented in these forums. https://www.google.com/#q=Unicode+site%3Ahttp%3A%2F%2Fscintillanet.codeplex.com%2Fdiscussions%2F


At this point, hopefully the bells are starting to go off and I won't need to explain why your code sample could throw an exception.


Jacob
The GetColumn method doesn't do what I am looking for, as it gets reset after every new line. But I need the absolute position of the caret in the text.

I also looked through the posted link and found this workaround (posted by you). But unfortunatly it is also not reliable. Same problem as above, but here for all kind of chars. The first (and only the first) entered char after a letter doesn't change the reverse engineered Position. The method also bugs for inserted Text via CnP.

So, what to do? Such a simple thing should be possible somehow, right?

2mQ

New Post: BUG: scintilla.CurrentPos and scintilla.Caret.Position bugged

$
0
0
Works for me...
// Update the text box when the caret moves
scintilla.NativeInterface.UpdateUI += (s, e) =>
{
    int byteOffset = scintilla.CurrentPos;

    // TODO Cache this and get creative or this will slow down your application
    Range range = scintilla.GetRange(0, byteOffset);
    int charOffset = range.Text.Length;

    textBox.Text = "Byte: " + byteOffset + "; Character: " + charOffset;
};
Jacob

New Post: can not add Controls to winforms

$
0
0
Good Evening all, i have downloaded the new dll's added the reference to my VB.NET project, i have put SciLexer.dll in SysWOW64 folder, i have SciLexer64.dll in my debug folder.

i CAN add Scintilla Control ok and it shows on my forum and that works fine.

i CAN NOT add SnippetChooser to my form?

Image

above is a screen shot of the error im getting when trying to add the snippetChooser to my form.

Hope some one can help.

Also is there a way to add snippets to this as a auto complete if i can not use SnippetChooser? i have a game i'm adding content to and this is going to make life a lot easier to make the files we need.

Thanks
Kev

New Post: BUG: scintilla.CurrentPos and scintilla.Caret.Position bugged

$
0
0
Hm,

ok I only checked this Event and the workaround seperatly (the workaround only with TextChanged and SelectionChanged). Both together do work. I don't understand how thats possible but ok.

Thank you very much for your detailed answers and this solution.

Just one more question, what do you mean with "TODO Cache this and get creative or this will slow down your application"? Didn't you already cache the position in the local variable charOffset?

2mQ

New Post: BUG: scintilla.CurrentPos and scintilla.Caret.Position bugged

$
0
0
Glad you got things worked out...

My suggestion to cache the character offset is because the approach I showed you is expensive. Under the hood, ScintillaNET is copying the bytes of the selected range out of the native Scintilla control and into managed memory. From there it converts the bytes from UTF-8 format used by Scintilla into a .NET compatible UTF-16 string format. That's a lot of memory copying, and if you plan on doing that every time the caret changes position I have no doubt you will see the performance hit. My suggestion is to cache it so you don't do that every time the cursor changes position. For example, you might:

• Store the last position (or several) in a byte-to-character mapping table and, assuming the document contents haven't changed, just lookup your pre-calculated value. Or if you get creative, detect what type of document change occurred and only update the rows in your table that need to be re-computed.

• Calculate the character position of the text up to the line above where the caret currently is. Then you would only have to calculate it from the start of the current line to the caret position and add it to your already calculated value.

• Scintilla does also provide some more advance ways of getting direct access to the internal memory buffer. You might look into accessing the bytes directly and doing your own conversion from UTF-8 to speed up the process and eliminate an intermediate copy.

• Change your application so it doesn't have to update the current position in real-time. :)

• Etc...


Jacob

New Post: Publishing a program that uses ScintillaNET

$
0
0
I'm building a program now that uses ScintillaNET. My question is, does the end user need the scintilla .dll files locally on their machines to run the program?

New Post: Publishing a program that uses ScintillaNET

$
0
0
Yes. Without the native Scintilla(64).dll, the ScintillaNET control would not work.

Jacob

New Post: can not add Controls to winforms

$
0
0
What's funny is I've never used the SnippetChooser control before--and I'm a ScintillaNET developer... But, what I think is happening is that the SnippetChooser control is not something meant to be added to your form. It is used by ScintillaNET automatically to display snippets. You don't need to create the control yourself.

We should probably hide it from the toolbox....


Jacob

New Post: Publishing a program that uses ScintillaNET

New Post: Intellisense in scintillaNET

$
0
0
Is there a way to have my scintillaNET text editor use Intellisense much like in Visual Basic when writing code?

New Post: Intellisense in scintillaNET

New Post: Intellisense in scintillaNET

$
0
0
I just can't seem to find a way to start this. Do I need to fill in the ListString? If so with what?

New Post: Intellisense in scintillaNET

$
0
0
BWSanders, do you still need help? I have a working IntelliSense system though along the way I discovered that there are quite a few oddities with the native Scintilla control.

Have you gotten the AutoComplete popup to show with your items? Please post your code and I will take a look.

New Post: LineCommentPrefix doesnt work

$
0
0
The LineCommentPrefix doenst work. Why?
editor.Lexing.Lexer = ScintillaNET.Lexer.Cpp;
        editor.Lexing.Keywords[0] = "for while do stock public forward if else return new break continue false true stock case enum switch sizeof goto default";
        editor.Lexing.Keywords[1] = "Float bool";
        editor.Lexing.LineCommentPrefix = "//";
        editor.Lexing.StreamCommentPrefix = "/*"; editor.Lexing.StreamCommentSufix = "*/";
        editor.Styles[editor.Lexing.StyleNameMap["DOCUMENT_DEFAULT"]].ForeColor = System.Drawing.Color.Black;  // DEFAULT CHAR
        editor.Styles[editor.Lexing.StyleNameMap["NUMBER"]].ForeColor = System.Drawing.Color.SteelBlue; // NUMBER
        editor.Styles[editor.Lexing.StyleNameMap["WORD"]].ForeColor = System.Drawing.Color.Blue; editor.Styles[editor.Lexing.StyleNameMap["WORD"]].Bold = true; // new usw.
        editor.Styles[editor.Lexing.StyleNameMap["WORD2"]].ForeColor = System.Drawing.Color.Purple; // Flaot, Bool
        editor.Styles[editor.Lexing.StyleNameMap["STRING"]].ForeColor = System.Drawing.Color.Red; // String
        editor.Styles[editor.Lexing.StyleNameMap["CHARACTER"]].ForeColor = System.Drawing.Color.Red; // Char
        editor.Styles[editor.Lexing.StyleNameMap["PREPROCESSOR"]].ForeColor = System.Drawing.Color.Brown; // #define usw
        editor.Styles[editor.Lexing.StyleNameMap["OPERATOR"]].ForeColor = System.Drawing.Color.Black;  // + - / *
        editor.Styles[editor.Lexing.StyleNameMap["IDENTIFIER"]].ForeColor = System.Drawing.Color.Black;
        editor.Styles[editor.Lexing.StyleNameMap["COMMENT"]].ForeColor = System.Drawing.Color.Green; 
It dont't geht marked green. Please help me. - Timo

New Post: LineCommentPrefix doesnt work

$
0
0
This is hardcoded into the native C++ lexer. If you need to change it, you will have to get the Scintilla source code, modify it to your needs then recompile and replace the files that come with ScintillaNET.

Here is a link to the Scintilla source: http://sourceforge.net/projects/scintilla/

New Post: ScintillaNET.dll as a single dll (with SciLexer.dll and SciLexer64.dll as embedded resource)

$
0
0
Hi,

In order to avoid multiple dll's that needs to be shipped with ScintillaNET library, I made a changes in ScintillaNET project and embed SciLexer dll's as ScitntillaNET resource files. I used DynamicNativeLibrary class from Microsoft.WinAny.Helper library to load SciLexer dll's from the memory ( resource / byte array ).

So, SciLexer dll's are now embedded as resource files and loaded from the resource based on the running process ( 32-bit or 64-bit ).

This also fixes UI designer problem when SciLexer dll's could not be found / loaded.

Just to make clear, DynamicNativeLibrary acts like LoadLibrary, but instead of the path, it loads a library from the memory byte array.

Link to the modified: ScintillaNET source code: ScintillaNET-source.zip
Link to the sample binaries: ScintillaNET-binaries.zip

Changes that i made was:
  1. Added Microsoft.WinAny.Helper folder with code files to the ScintillaNET project ( you can get them in source code from the link above )
  2. Added SciLexer.dll and SciLexer64.dll as resource files. (also shown in source from the link)
  3. Changed Scintilla.cs:
// added required namespace
using Microsoft.WinAny.Interop;

// added static variable
private static DynamicNativeLibrary _dynamicModule;

// removed as not needed any more
//private static IntPtr _moduleHandle;

// changed completely
private static void LoadModule()
{
    if (_dynamicModule == null)
    {
        if (IntPtr.Size == 4)
        {
            _dynamicModule = new DynamicNativeLibrary(global::ScintillaNET.Properties.Resources.SciLexer);
        }
        else
        {
            _dynamicModule = new DynamicNativeLibrary(global::ScintillaNET.Properties.Resources.SciLexer64);
        }
    }

    if (_sciFunction == null)
    {
        _sciFunction = _dynamicModule.GetDelegateForFunction("Scintilla_DirectFunction", 
            typeof(NativeMethods.Scintilla_DirectFunction)) as NativeMethods.Scintilla_DirectFunction;
    }
}

public static void SetModuleName(string moduleName)
{
    const string paramName = "moduleName";

    if (moduleName == null)
        throw new ArgumentNullException(paramName);

    if (moduleName.Length == 0)
        throw new ArgumentException(string.Format(Resources.Culture, Resources.Exception_EmptyStringArgument, paramName), paramName);

    // earlier here was _moduleHandle checking, now it's _dynamicModule
    if (_dynamicModule != null)
        throw new InvalidOperationException(Resources.Exception_ModuleAlreadyLoaded);

    _moduleName = moduleName;
}

New Post: LineCommentPrefix doesnt work

$
0
0
But why can I change the multiline comments and not the singleline comments?
And which file do I have to decompile? ScintillaNET.dll oder SciLexer.dll?

New Post: Intellisense in scintillaNET

$
0
0
yes, i could definitely use a hand getting it set up. I believe i have autocomplete configured correctly but it's not really working out.

New Post: Intellisense in scintillaNET

$
0
0
i configured it through the properties of my scintilla text box. are you saying that I need or should be doing through code?

New Post: ScintillaNET.dll as a single dll (with SciLexer.dll and SciLexer64.dll as embedded resource)

$
0
0
Wow!

That someone actually wrote a library to emulate the PE loader and dynamic linker in Windows is incredible. I remember researching this topic a year or two ago as a way of packing the native Scintilla DLL with our managed package but abandoned the idea because it was too much work. It's cool to know that is possible.

However, I can't comfortably make this an approach we use for official distributions. I did a little digging and found the Microsoft.WinAny.Helper library and DynamicNativeLibrary implementation are ports of the C MemoryModule library:
http://www.joachim-bauch.de/tutorials/loading-a-dll-from-memory/
https://github.com/fancycode/MemoryModule

Digging through the outstanding issues reported on GitHub for this project it appears that the emulated PE loader has issues with Structured Exception Handling in native C/C++ libraries... the particular issue being that catch blocks in native libraries don't execute and instead terminate the process:
https://github.com/fancycode/MemoryModule/issues/4

A cursory glance at the native Scintilla C/C++ code reveals that try/catch blocks are used throughout and so there is the potential that loading the DLL this way could cause application instability.


Jacob
Viewing all 296 articles
Browse latest View live


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