Text-editor-component and text-editor-presenter class functions?


#1

Hello. I’m trying to understand the underlying text editor system in Atom. The docs and comments pretty clearly say that text-editor is responsible for the state and test-editor-element is responsible for the display or view. Could someone please explain what the logical function of the text-editor-component and text-editor-presenter classes are?

I saw that in the “Rendering Improvements” blog post, the presenter class was described as a facade in front of the other text editor classes. Can someone please briefly explain the relationship between these classes and how they’re used by the application?

Thanks. Merry holidays.

Andrew


#2

Can someone please briefly explain the relationship between these classes and how they’re used by the application?

TextEditorComponent is the class used to put together all pieces of a text editor view (the gutter, the lines, the scroll bars, etc.). It’s also responsible for maintaining the state of the text editor view (ie. the scroll position) and for handling the various events happening in the editor (inputs, clicks, scroll, etc.). I think it was introduced with the switch to React and then refactored to get rid of React later.

The TextEditorPresenter is responsible for the editor’s content layout, it takes care of measurements, tiles, decorations and everything that depends on or affects how lines are rendered. It itself relies on several other small utilities to deal with more specific aspect (like measuring lines, building and maintaining lines and tiles, etc.).

Hope it helps


#3

Perfect. Thanks!