public ColumnRange GetSelectionAtLine(int lineNumber) { ColumnRange ret = null; //Debug.Write(string.Format("L:{0} ", lineNumber)); if (IsValid && !IsEmpty) { int startLine = Math.Min(StartPosition.Y, EndPosition.Y); int endLine = Math.Max(StartPosition.Y, EndPosition.Y); if (_isRect) { if (startLine <= lineNumber && lineNumber <= endLine) { ret = new ColumnRange(StartPosition.X, EndPosition.X); } } else { if (ret == null && startLine < lineNumber && lineNumber < endLine) { ret = ColumnRange.WHOLE_COLUMN; } if (ret == null && startLine == lineNumber) { LineSegment line = _document.GetLineSegment(startLine); int startColumn = StartPosition.X; int endColumn = endLine == lineNumber ? EndPosition.X : line.Length + 1; ret = new ColumnRange(startColumn, endColumn); } if (ret == null && endLine == lineNumber) { int endColumn = EndPosition.X; ret = new ColumnRange(0, endColumn); } } //Debug.Write(string.Format("L:{0}:{1} ", lineNumber, ret)); } return(ret ?? ColumnRange.NO_COLUMN); }
public ColumnRange GetSelectionAtLine(int lineNumber) { ColumnRange wholeColumn; List <ISelection> .Enumerator enumerator = this.selectionCollection.GetEnumerator(); try { while (enumerator.MoveNext()) { ISelection current = enumerator.Current; int y = current.StartPosition.Y; int num = current.EndPosition.Y; if (y < lineNumber && lineNumber < num) { wholeColumn = ColumnRange.WholeColumn; return(wholeColumn); } else if (y != lineNumber) { if (num != lineNumber) { continue; } wholeColumn = new ColumnRange(0, current.EndPosition.X); return(wholeColumn); } else { LineSegment lineSegment = this.document.GetLineSegment(y); int x = current.StartPosition.X; wholeColumn = new ColumnRange(x, (num == lineNumber ? current.EndPosition.X : lineSegment.Length + 1)); return(wholeColumn); } } return(ColumnRange.NoColumn); } finally { ((IDisposable)enumerator).Dispose(); } return(wholeColumn); }
public ColumnRange GetSelectionAtLine(int lineNumber) { ColumnRange ret = null; //Debug.Write(string.Format("L:{0} ", lineNumber)); if (IsValid && !IsEmpty) { int startLine = Math.Min(StartPosition.Y, EndPosition.Y); int endLine = Math.Max(StartPosition.Y, EndPosition.Y); if (_isRect) { if (startLine <= lineNumber && lineNumber <= endLine) { ret = new ColumnRange(StartPosition.X, EndPosition.X); } } else { if (ret == null && startLine < lineNumber && lineNumber < endLine) { ret = ColumnRange.WHOLE_COLUMN; } if (ret == null && startLine == lineNumber) { LineSegment line = _document.GetLineSegment(startLine); int startColumn = StartPosition.X; int endColumn = endLine == lineNumber ? EndPosition.X : line.Length + 1; ret = new ColumnRange(startColumn, endColumn); } if (ret == null && endLine == lineNumber) { int endColumn = EndPosition.X; ret = new ColumnRange(0, endColumn); } } //Debug.Write(string.Format("L:{0}:{1} ", lineNumber, ret)); } return ret ?? ColumnRange.NO_COLUMN; }
static ColumnRange() { ColumnRange.NoColumn = new ColumnRange(-2, -2); ColumnRange.WholeColumn = new ColumnRange(-1, -1); }