mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-28 01:07:49 +08:00
[md] Editor area coordinates
This commit is contained in:
parent
36c0759bf0
commit
6982a40a7f
@ -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]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user