gemini
gemini copied to clipboard
How to get CodeEditor's Text
Hello guys, sorry for the question but how can I access the content of the CodeEditor? For example after opening a cs file.
I mean in detail if you open a cs file for example, an editor opens. Them youll be able to input some content to the Texteditor. I gonna work with this content, for example parsing the text. But I really dont know how to get the text out of it.
Hello, you need to create your own module, with ViewModel class inherites from the PersistedDocument class. Combine two examples Gemini.Demo.TextEditor module with Gemini.Demo.Home HelixViewModel/View that uses codeeditor.
For example if you add .cs extension in _extensions list in file Gemini.Demo.Modules.TextEditor.EditorProvider.cs
private readonly List
.cs files will be open by Gemini.Demo.Modules.TextEditor module in TextBox (see TextEditor.View.EditorView.xaml)
You need to replace TextBox with an CodeEditor, you can see how it's done in Gemini.Demo.Home HelixViewModel/View
Hey and thank you for the quick feedback. Btw I tried adding a custom module and I exported it. One of the problems is now, that anytime I open a file using the menu or the toolbar, it opens it by using the original IEditorProvider instead of my custom one ?
Do you add your required extension to List
Yes, for example, if I add a new file extension like "*.test", this is shown in the file list on the menu. Afterwards I try to get an instance of EditorProvider which will always return null. It finds only a CodeEditorProvider instance. Btw I also dont know how to get the Text of the text box inside another module. For example to do some compiling stuff etc.