Struct CellRange
Represents a text selection range in a cell grid defined by an anchor (mouse-down) and active (current mouse) position. Provides normalized Start/End accessors that always return positions in document order regardless of selection direction.
Implements
Inherited Members
Namespace: Scylla.TextMode
Assembly: ScyllaTextMode.dll
Syntax
public readonly struct CellRange : IEquatable<CellRange>
Constructors
CellRange(CellPosition, CellPosition)
Creates a new cell range from anchor and active positions.
Declaration
public CellRange(CellPosition anchor, CellPosition active)
Parameters
| Type | Name | Description |
|---|---|---|
| CellPosition | anchor | The anchor (start) position. |
| CellPosition | active | The active (end) position. |
Fields
Active
The active position where the selection currently ends (current mouse point).
Declaration
public readonly CellPosition Active
Field Value
| Type | Description |
|---|---|
| CellPosition |
Anchor
The anchor position where the selection started (mouse-down point).
Declaration
public readonly CellPosition Anchor
Field Value
| Type | Description |
|---|---|
| CellPosition |
Properties
End
Gets the later position in document order (bottom-right of selection).
Declaration
public CellPosition End { get; }
Property Value
| Type | Description |
|---|---|
| CellPosition |
IsEmpty
Gets whether the selection is empty (anchor equals active).
Declaration
public bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsReversed
Gets whether the selection direction is reversed (active comes before anchor in document order).
Declaration
public bool IsReversed { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Start
Gets the earlier position in document order (top-left of selection).
Declaration
public CellPosition Start { get; }
Property Value
| Type | Description |
|---|---|
| CellPosition |
Methods
CellCount(int)
Gets the total number of cells in this selection.
Declaration
public int CellCount(int columns)
Parameters
| Type | Name | Description |
|---|---|---|
| int | columns | Number of columns in the grid. Must be greater than zero. |
Returns
| Type | Description |
|---|---|
| int | Number of selected cells, or 0 if empty or columns is not positive. |
Contains(CellPosition, int)
Tests whether a cell position falls within this selection range using flat index comparison.
Declaration
public bool Contains(CellPosition position, int columns)
Parameters
| Type | Name | Description |
|---|---|---|
| CellPosition | position | The position to test. |
| int | columns | Number of columns in the grid. Must be greater than zero. |
Returns
| Type | Description |
|---|---|
| bool | True if the position is within the selection range. False if columns is not positive. |
Equals(CellRange)
Determines whether this range equals another range. Comparison is direction-sensitive: ranges covering the same cells but with different anchor/active positions are not equal. Use Start/End for direction-independent comparison.
Declaration
public bool Equals(CellRange other)
Parameters
| Type | Name | Description |
|---|---|---|
| CellRange | other | The other range. |
Returns
| Type | Description |
|---|---|
| bool | True if anchor and active positions are identical. |
Equals(object)
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
GetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |
Overrides
ToString()
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |
Overrides
Operators
operator ==(CellRange, CellRange)
Equality operator.
Declaration
public static bool operator ==(CellRange left, CellRange right)
Parameters
| Type | Name | Description |
|---|---|---|
| CellRange | left | |
| CellRange | right |
Returns
| Type | Description |
|---|---|
| bool |
operator !=(CellRange, CellRange)
Inequality operator.
Declaration
public static bool operator !=(CellRange left, CellRange right)
Parameters
| Type | Name | Description |
|---|---|---|
| CellRange | left | |
| CellRange | right |
Returns
| Type | Description |
|---|---|
| bool |