public class LogicalPosition extends java.lang.Object implements java.lang.Comparable<LogicalPosition>
Document
. Column value counts characters from the beginning of the logical line (tab character can occupy
multiple columns - up to the tab size set for editor, surrogate pairs of characters are counted as one column). Positions beyond the end
of line can be represented (in this case column number will be larger than the number of characters in the line).
Logical position corresponds to a boundary between two characters and can be associated with either a preceding or succeeding character
(see leansForward
). This association makes a difference in a bidirectional text, where a mapping from logical to visual position
is not continuous.
Logical position of caret in current editor is displayed in IDE's status bar (displayed line and column values are one-based, so they are incremented before showing).
Note: two objects of this class are considered equal if their logical line and column are equal. I.e. all logical positions
for soft wrap-introduced virtual space and the first document symbol after soft wrap are considered to be equal. Value of
leansForward
flag doesn't impact the equality of logical positions.
Modifier and Type | Field and Description |
---|---|
int |
column |
boolean |
leansForward
If
true , this position is associated with succeeding character (in logical order), otherwise it's associated with
preceding character. |
int |
line |
Constructor and Description |
---|
LogicalPosition(int line,
int column) |
LogicalPosition(int line,
int column,
boolean leansForward) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(LogicalPosition position) |
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
LogicalPosition |
leanForward(boolean value)
Constructs a new
LogicalPosition instance with a given value of leansForward flag. |
java.lang.String |
toString() |
public final int line
public final int column
public final boolean leansForward
true
, this position is associated with succeeding character (in logical order), otherwise it's associated with
preceding character. This can make difference in bidirectional text, where logical positions which differ only in this flag's value
can have different visual positions.
This field has no impact on equality and comparison relationships between LogicalPosition
instances.
public LogicalPosition(int line, int column) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public LogicalPosition(int line, int column, boolean leansForward) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public LogicalPosition leanForward(boolean value)
LogicalPosition
instance with a given value of leansForward
flag.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public int compareTo(LogicalPosition position)
compareTo
in interface java.lang.Comparable<LogicalPosition>