No relation between Document and View

SyntaxEditor for Windows Forms Forum

Posted 19 years ago by Stephan Ziep
Avatar
Hello,

Currently I'm developing a multi tabbed Debugging IDE, with a single SyntaxEditor Control, that is shared by the tab pages. Each tab page contains a SyntaxEditor.Document. If a tab is activated, the SyntaxEditor is added to it and the tabs Document is assigned to the SyntaxEditor. I designed it that way, because i fear that creating a whole syntax editor for every tab page might be a resource hog.

Now if i want to save a Documents data, such as Indicator positions, current line, caret etc, i need access to the selected EditorView. But the only way to get this Document related data from the View is to assign the tabs Document to SyntaxEditor and then querying the selected View.

Is there a better way to get the data? Why is there no relation between a Document and the View? Do you have any suggestion on how to improve the Design?

Thank you in advance,
Stephan Ziep

Comments (4)

Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
This is all by design because we wanted to separate out the user interface (SyntaxEditor control and views) from the text engine (Document). This allows you to load a Document, and have full parsing capabilities while not loading any resources needed for supporting a user interface.

What you're doing is ok. If I were you, I'd create a small class that can store things like the selection range and maybe the first visible display line. Before a tab change occurs, I would store that information for the current view in one of your class instances and store it with your document. Then after the tab change (a new Document now), restore the selection and first visible display line data that you had previously set for this new Document.

Hope that helps.


Actipro Software Support

Posted 19 years ago by Stephan Ziep
Avatar
Ok I'll try that out.
Thank you for your fast response.
Posted 19 years ago by Stephan Ziep
Avatar
One dumb question: How do I restore the Document line?
SyntaxEditor.SelectedView.CurrentDocumentLine is readonly. Do I have to calculate the Line from the Selection properties of the view?
Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
No you want to use the FirstVisibleDisplayLineIndex property. Remember that document lines are physical text lines with line breaks while one or more display line (used in the UI) can represent a single document line if word wrapping is active.


Actipro Software Support

The latest build of this product (v24.1.1) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.