public void Do () { if (Region.Selection.SelectedToken is TextToken) { if (Region.Selection.Position > 0) { Region.Selection.Position--; return; } Region.Selection.Type = SelectionType.Right; } var previos = new SelectionTreeBuilder (SelectionType.Right).Build (Region.Root) .TakeWhile (t => !(t.Token == Region.Selection.SelectedToken && t.Type == Region.Selection.Type)) .Reverse ().FirstOrDefault (); if (previos != null) { Region.Selection.SelectedToken = previos.Token; Region.Selection.Type = previos.Type; if (Region.Selection.SelectedToken is TextToken) { var textToken = Region.Selection.SelectedToken as TextToken; Region.Selection.Position = string.IsNullOrEmpty (textToken.Text) ? 0 : textToken.Text.Length; } } }
public void Do () { if (Region.Selection.SelectedToken is TextToken) { var textToken = Region.Selection.SelectedToken as TextToken; var lenght = string.IsNullOrEmpty (textToken.Text) ? 0 : textToken.Text.Length; if (Region.Selection.Position < lenght) { Region.Selection.Position++; return; } Region.Selection.Type = SelectionType.Left; } var next = new SelectionTreeBuilder (SelectionType.Left).Build (Region.Root) .SkipWhile (t => !(t.Token == Region.Selection.SelectedToken && t.Type == Region.Selection.Type)) .Skip (1).FirstOrDefault (); if (next != null) { Region.Selection.SelectedToken = next.Token; Region.Selection.Type = next.Type; } }