This project is read-only.

Split view using two Scintilla controls?

Topics: Developer Forum, Project Management Forum, User Forum
Aug 24, 2014 at 10:37 AM
Edited Dec 27, 2014 at 8:13 PM
Hi!
I want to create a split view with two ScintillaNET controls.
I've tried different codes to get it to work, such as "Scintilla1.Text = Scintilla2.Text" (and vice versa), or making a For loop to check if their lines are the same, and if not, replace the other control's line(s) with the current one(s).

The best working solution was making "(Other control).Text = (Current control).Text". The only problem with it, is that it is scrolling the other Scintilla control to the top wen it's text is changed programatically.

Anyone have any ideas?
Code in Visual Basic or Visual C# is appreciated.

//Visual Vincent
Dec 27, 2014 at 8:19 PM
I have tried so many things, but I have not yet gotten the perfect answer.
So there's nobody out there that knows?

Sorry for bumping, but I've been waiting for so long. :)
Dec 27, 2014 at 8:26 PM
I believe the best solution would be to copy the text of the two controls onto each other, but save the cursor and scroll positions before doing that copy, and restore those positions after.
Dec 28, 2014 at 6:24 PM
blah38621 wrote:
I believe the best solution would be to copy the text of the two controls onto each other, but save the cursor and scroll positions before doing that copy, and restore those positions after.
I tried that before. And suddenly when rewriting my code, it works. :D
It's a bit laggy though.

I also tried to make a new setting for the Scintilla control. Sadly it didn't work.
I see you're a developer. Can you recognize this problem?
(Translation: Method not found)
Image

Here's the change in the source:
private bool EnableOnTextChangedEvent = true;

(... further down in the code ...)

        private void ScnModified(ref ScintillaNET.Internal.NativeMethods.SCNotification scn)
        {
            bool flag = false;
            flag |= (scn.modificationType & 1) == 1;
            flag |= (scn.modificationType & 2) == 2;
            if (this.EnableOnTextChangedEvent) //This 'if'-statement is new. Not the code inside it. I made it so that it wouldn't raise the OnTextChanged event, so that it wouldn't scroll.
            {
                this.OnTextChanged(EventArgs.Empty);
            } //End of new
            if ((scn.modificationType & 0x20000) == 0x20000)
            {
                AnnotationChangedEventArgs e = new AnnotationChangedEventArgs(scn.line, scn.annotationLinesAdded);
                this.OnAnnotationChanged(e);
            }
        }

(... even further down in the code ...)

        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public bool EnableTextChangedEvent
        {
            get
            {
                return this.EnableOnTextChangedEvent;
            }
            set
            {
                this.EnableOnTextChangedEvent = value;
            }
        }
And then when you use it, the error will occur. (I use Visual Basic 2010 for my application.)
ScintillaBox2.EnableTextChangedEvent = False 'Disable raising the event.
ScintillaBox2.Text = ScintillaBox1.Text
ScintillaBox2.EnableTextChangedEvent = True
May 18, 2015 at 1:48 AM
If you're still interested in this topic, Scintilla supports multiple views for the same document out-of-the-box. No need to roll your own approach.

Since v2.x is no longer supported, you should first upgrade to v3.x at the new GitHub repo:
https://github.com/jacobslusser/ScintillaNET

In the project documentation you'll find an explanation of how to do this under the topic "Documents".


Jacob
Oct 20, 2015 at 5:06 AM
Hello jacobslusser,

can you provide a vb.net code for documents module in https://github.com/jacobslusser/ScintillaNET? Thanks
Jan 16, 2016 at 7:05 PM
Edited Jan 16, 2016 at 8:37 PM
Okay, after all this time I've found out that there actually is a way to use split view with the old 2.x Scintilla.
I just did this and it seems to work perfectly:
Scintilla2.DocumentHandler.Current = Scintilla1.DocumentHandler.Current
Quadruple-view (full size: http://www.mydoomsite.com/Bilder/ScriptexerQuadSplitView.png)
Image
Marked as answer by Visual_Vincent on 1/16/2016 at 11:06 AM