Exemplo n.º 1
0
        //updates the block list by selecting the block for the statement for the token the caret is in
        private void UpdateBlockListSelectedToken()
        {
            //get selection start
            int selectionStart = rtSource.SelectionStart;

            if (_currentTokens.Count > 0)
            {
                //get the first token
                VisualiserToken tokenCaretIsIn = _currentTokens[0];
                //if the position of the token is beyond the caret position, the previous token was the right one
                foreach (VisualiserToken aToken in _currentTokens)
                {
                    if (aToken.Position > selectionStart)
                    {
                        foreach (VisualiserBlock aBlock in _currentBlocks)
                        {
                            if (aBlock.Tokens.Contains <TokenBase>(aToken.BaseToken))
                            {
                                if (lstBlockList.SelectedItem.Equals(aBlock))
                                {
                                    MarkBlockInSource(aBlock);
                                }
                                else
                                {
                                    lstBlockList.SelectedItem = aBlock;
                                }
                            }
                        }
                    }
                    else
                    {
                        tokenCaretIsIn = aToken;
                    }
                }
            }
        }
Exemplo n.º 2
0
 //marks the text of the specified token in the source
 private void MarkTokenInSource(VisualiserToken token)
 {
     rtSource.Select(token.Position, token.Content.Length);
     rtSource.Focus();
 }