diff --git a/tutorials/editor_basics.md b/tutorials/editor_basics.md index 42647db6b..0fa1f0d25 100644 --- a/tutorials/editor_basics.md +++ b/tutorials/editor_basics.md @@ -124,7 +124,27 @@ inserting and deleting symbols and strings, and manipulating with text blocks, a [EditorModificationUtil.java] (https://github.com/JetBrains/intellij-community/blob/master/platform/platform-api/src/com/intellij/openapi/editor/EditorModificationUtil.java) #Editor coordinates system. Positions and offsets. -**TODO** +Every caret in the editor has a set of properties describing it's coordinates. These properties can be accessed by obtaining a +[caret model instance] (https://github.com/JetBrains/intellij-community/blob/master/platform/editor-ui-api/src/com/intellij/openapi/editor/CaretModel.java). + +##Logical position +[LogicalPosition.java] (https://github.com/JetBrains/intellij-community/blob/master/platform/editor-ui-api/src/com/intellij/openapi/editor/LogicalPosition.java) +represents a line and a column of the current logical position of the caret. Logical positions ignore folding - +for example, if the top 10 lines of the document are folded, the 10th line in the document will have the line number 10 in its logical position. +Logical position may store additional parameters that define its mapping to +[VisualPosition.java] (https://github.com/JetBrains/intellij-community/blob/master/platform/editor-ui-api/src/com/intellij/openapi/editor/VisualPosition.java). +Rationale is that single logical pair matches soft wrap-introduced virtual space, i.e. different visual positions +correspond to the same logical position. It's convenient to store exact visual location details within the logical +position in order to relief further 'logical position' -> 'visual position' mapping. + +##Visual position +[VisualPosition.java] (https://github.com/JetBrains/intellij-community/blob/master/platform/editor-ui-api/src/com/intellij/openapi/editor/VisualPosition.java) +represent a visual position and may very from the corresponding logical position. +Visual positions take folding into account - for example, if the top 10 lines of the document are folded, the 10th line in the document will have the line number 1 in its visual position. + +##Offset +An absolute offset for a given caret position is accessible by calling +```int offset = caretModel.getOffset();``` **TODO** [Link to threading issue]