FindCurrentWordStart() public method

public FindCurrentWordStart ( int offset ) : int
offset int
return int
        string TextImplementor.GetTextAfterOffset(int offset, TextBoundary boundary_type, out int start_offset, out int end_offset)
        {
            LineSegment line;

            switch (boundary_type)
            {
            case Atk.TextBoundary.Char:
                start_offset = offset;
                end_offset   = offset + 1;
                break;

            case Atk.TextBoundary.SentenceEnd:
            case Atk.TextBoundary.LineEnd:
                line         = Document.GetLineByOffset(offset);
                start_offset = offset;
                end_offset   = line.Offset + line.EditableLength;
                break;

            case Atk.TextBoundary.SentenceStart:
            case Atk.TextBoundary.LineStart:
                line         = Document.GetLineByOffset(offset);
                start_offset = line.Offset;
                end_offset   = offset;
                break;

            case Atk.TextBoundary.WordEnd:
                start_offset = offset;
                end_offset   = TextEditorData.FindCurrentWordEnd(offset);
                break;

            case Atk.TextBoundary.WordStart:
                start_offset = TextEditorData.FindCurrentWordStart(offset);
                end_offset   = offset;
                break;

            default:
                start_offset = end_offset = offset;
                break;
            }
            start_offset = System.Math.Min(start_offset, offset);
            return(Document.GetTextBetween(start_offset, end_offset));
        }
        private TextSegment FindSegment(double x, double y, TextEditorData editor)
        {
            var xWithMarginOffset = x - editor.Parent.TextViewMargin.XOffset;

            var location = editor.Parent.PointToLocation(xWithMarginOffset, y);
            var offset = editor.Parent.LocationToOffset(location);
            
            var startWord = editor.FindCurrentWordStart(offset);
            var endWord = editor.FindCurrentWordEnd(offset);
            return new TextSegment(startWord, endWord - startWord);
        }
Exemplo n.º 3
0
 public static CommandRange CurrentWord(TextEditorData editor)
 {
     var start = editor.FindCurrentWordStart(editor.Caret.Offset);
     var end = editor.FindCurrentWordEnd(editor.Caret.Offset);
     return new CommandRange(start, end);
 }
Exemplo n.º 4
0
 public static void InnerWord(TextEditorData data)
 {
     var start = data.FindCurrentWordStart (data.Caret.Offset);
     var end = data.FindCurrentWordEnd (data.Caret.Offset);
     data.SelectionRange = new TextSegment(start, end - start);
 }
Exemplo n.º 5
0
 public static void WordStart(TextEditorData data)
 {
     data.Caret.Offset = data.FindCurrentWordStart (data.Caret.Offset);
 }