SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Extend Snippet Compiler Sample

Last post 05-29-2009 6:44 PM by NenadMarkovic. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 11-24-2008 12:32 PM

    Extend Snippet Compiler Sample

    Hi, I'm trying to integrate the code developer window into my application, essentially a more specialised for of the sample SnippetCompiler. What I would like to know is is it possible to display only a section of the source code rather than the whole file? I want to be able to open multiple views of the same file with each view having only the source code of a specific method; I current display the whole file which is not preferable. A good second might be to make sections of the file read only perhaps!?!

    Thanks for any help / suggestions.

     

    Ps. Well done on creating such an amazing application; it's rare to see such a complete and featured open source project. Well done! 

     

  • 11-24-2008 7:32 PM In reply to

    Re: Extend Snippet Compiler Sample

    There's nothing out of the box. The TextEditor has a split view mode but that is not what you want. You could use read-only sections and scroll to the correct area. The full text is still on display though.

    I would probably have some code that loads the file and parses it for methods and then displays them in individual text editor windows. Then when you save the document you stitch these text sections back together again.

  • 11-25-2008 3:25 PM In reply to

    Re: Extend Snippet Compiler Sample

    Firstly thank you for the responce and help....

     

     

    MattWard:
    You could use read-only sections

    How do I define sections as read only? This sounds the most likely workable solution.

     

     

    MattWard:
    would probably have some code that loads the file and parses it for methods and then displays them in individual text editor windows.

    That's more or less exactly the effect I would like to do; in fact the source code originates from an xml file which already has the methods seperate. However this causes a big problem; I would have to make separate classes for each method (as I intend to only ever edit a single method per view) resulting in lots of classes with the same name (thus compiling won't work and hence I cannot display error information), and secondly because the files are all broken up the auto complete would not work.

  • 11-25-2008 7:44 PM In reply to

    Re: Extend Snippet Compiler Sample

    To create a read-only section create a text marker and set its IsReadOnly property to true. Here's a snippet that Daniel wrote from the CommandPromptControl class to give you an idea.

            protected void MakeReadOnly()
            {
                if (this.Document.TextLength == 0)
                    return;
                this.ActiveTextAreaControl.Caret.Position = this.Document.OffsetToPosition(this.Document.TextLength);
                if (readOnlyMarker == null) {
                    readOnlyMarker = new TextMarker(0, this.Document.TextLength, TextMarkerType.Invisible) { IsReadOnly = true };
                    this.Document.MarkerStrategy.AddMarker(readOnlyMarker);
                }
                readOnlyMarker.Offset = 0;
                readOnlyMarker.Length = this.Document.TextLength;

         }  

  • 11-26-2008 12:03 PM In reply to

    Re: Extend Snippet Compiler Sample

    That's fantastic, thank you. I'm going to try that at lunch.

  • 11-26-2008 6:15 PM In reply to

    Re: Extend Snippet Compiler Sample

    Hi, I gave that a try at lunch but it didn't work for me. I confirmed the region specified was correct by using TextMarkerType.SolidBlock and it confirmed the region as the whole document marked in solid red, however at no stage was the code non-editable. Any suggestions would be greatly appreciated.

  • 11-26-2008 6:26 PM In reply to

    Re: Extend Snippet Compiler Sample

    You need to set TextEditorProperties.SupportReadOnlySegments to true.

    It's false by default for performance reasons; currently large numbers of text markers aren't handled efficiently.

  • 11-27-2008 11:57 AM In reply to

    Re: Extend Snippet Compiler Sample

    That worked a treat.

    Thank you for all the help, greatly appreciated.

  • 05-29-2009 6:44 PM In reply to

    Re: Extend Snippet Compiler Sample

     Hello Daniel ,

    I have implemented this ReadOnlySegments funcionality with code snipet ( MakeReadOnly() ) you provided in your post .

    But i have noticed "small bug" .. Here is how to reproduce it :

    1. type some text in more than one line , for example four lines of text .. then apply MakeReadOnly() .. and that code/text become ReadOnly , but No, here is the problem :

    2. Go to the line before/above last line in our case this is third line , and set caret at the end of line

    3. and try to type in some text ; result ; one (exectly one) caracter appears at the end of line (bug ?)

    Nenad Markovic

Page 1 of 1 (9 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.