Exemple #1
0
        public virtual InlineSpan getSpanForPosition(TextPosition position)
        {
            D.assert(debugAssertIsValid());
            Accumulator offset = new Accumulator();
            InlineSpan  result = null;

            visitChildren((InlineSpan span) => {
                result = span.getSpanForPositionVisitor(position, offset);
                return(result == null);
            });
            return(result);
        }
Exemple #2
0
        public int?codeUnitAt(int index)
        {
            if (index < 0)
            {
                return(null);
            }
            Accumulator offset = new Accumulator();
            int?        result = null;

            visitChildren((InlineSpan span) => {
                result = span.codeUnitAtVisitor(index, offset);
                return(result == null);
            });
            return(result);
        }
Exemple #3
0
        protected override int?codeUnitAtVisitor(int index, Accumulator offset)
        {
            if (text == null)
            {
                return(null);
            }

            if (index - offset.value < text.Length)
            {
                return(text[index - offset.value]);
            }

            offset.increment(text.Length);
            return(null);
        }
Exemple #4
0
 protected abstract int?codeUnitAtVisitor(int index, Accumulator offset);
Exemple #5
0
 protected abstract InlineSpan getSpanForPositionVisitor(TextPosition position, Accumulator offset);
Exemple #6
0
        protected override InlineSpan getSpanForPositionVisitor(TextPosition position, Accumulator offset)
        {
            if (text == null)
            {
                return(null);
            }

            TextAffinity affinity     = position.affinity;
            int          targetOffset = position.offset;
            int          endOffset    = offset.value + text.Length;

            if (offset.value == targetOffset && affinity == TextAffinity.downstream ||
                offset.value < targetOffset && targetOffset < endOffset ||
                endOffset == targetOffset && affinity == TextAffinity.upstream)
            {
                return(this);
            }

            offset.increment(text.Length);
            return(null);
        }