Esempio n. 1
0
        static IEnumerable <LineScrollInfo> GetBufferZippedWithScrollPositions(IEnumerable <SourceBuffer> bufs, IEnumerable <DisplayLine> lines)
        {
            var currentIndices = bufs.ToDictionary(b => b.Source, b => new Ref <int>());

            Func <LineScrollInfo> calcScrollPosHelper = () =>
            {
                var ret = new LineScrollInfo();

                foreach (var buf in bufs)
                {
                    int currentIndex = currentIndices[buf.Source].Value;
                    if (currentIndex < buf.Count)
                    {
                        var dl          = buf.Get(currentIndex);
                        var msgBeginPos = buf.Source.MapPositionToScrollPosition(dl.Message.Position);
                        ret.ScrollPositionBegin += msgBeginPos + dl.LineOffsetBegin;
                        ret.ScrollPositionEnd   += msgBeginPos + dl.LineOffsetEnd;
                    }
                    else
                    {
                        var bufEnd = buf.Source.MapPositionToScrollPosition(buf.EndPosition);
                        ret.ScrollPositionBegin += bufEnd;
                        ret.ScrollPositionEnd   += bufEnd;
                    }
                }

                return(ret);
            };

            foreach (var m in lines)
            {
                var source   = m.Source;
                var lineInfo = calcScrollPosHelper();
                lineInfo.Index = m.Index;
                yield return(lineInfo);

                currentIndices[source].Value++;
            }
        }
Esempio n. 2
0
        private LineScrollInfo CalcScrollPosHelper()
        {
            var ret = new LineScrollInfo();

            foreach (var buf in buffers.Values)
            {
                if (buf.CurrentIndex < buf.Count)
                {
                    var dl          = buf.Get(buf.CurrentIndex);
                    var msgBeginPos = buf.Source.MapPositionToScrollPosition(dl.Message.Position);
                    ret.ScrollPositionBegin += msgBeginPos + dl.LineOffsetBegin;
                    ret.ScrollPositionEnd   += msgBeginPos + dl.LineOffsetEnd;
                }
                else
                {
                    var bufEnd = buf.Source.MapPositionToScrollPosition(buf.EndPosition);
                    ret.ScrollPositionBegin += bufEnd;
                    ret.ScrollPositionEnd   += bufEnd;
                }
            }

            return(ret);
        }