예제 #1
0
        void AddFarHistory(GetHistoryArgs args)
        {
            var items = Far.Api.History.GetHistory(args);

            foreach (var item in items)
            {
                if (!_latestRecords.TryGetValue(item.Name, out Record record) || item.Time - record.Time > _smallSpan)
                {
                    _records.Add(new Record(item.Time, Record.NOOP, item.Name));
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Creates the instance with data ready for analyses.
        /// </summary>
        /// <param name="mode">History (0) or Folders (1).</param>
        /// <param name="store">The store path. Empty/null is the default.</param>
        /// <param name="noHistory">Tells to exclude Far folder history.</param>
        public Actor(int mode, string store, bool noHistory = false)
        {
            switch (mode)
            {
            case 0:
                _comparer       = StringComparer.OrdinalIgnoreCase;
                _comparisonType = StringComparison.OrdinalIgnoreCase;
                break;

            case 1:
                _comparer       = StringComparer.OrdinalIgnoreCase;
                _comparisonType = StringComparison.OrdinalIgnoreCase;
                break;

            case 2:
                _comparer       = StringComparer.Ordinal;
                _comparisonType = StringComparison.Ordinal;
                break;

            default:
                throw new ArgumentException("Invalid mode.", "mode");
            }

            _mode    = mode;
            _store   = store ?? VesselHost.LogPath[mode];
            _limit0  = Settings.Default.Limit0;
            _records = Store.Read(_store).ToList();

            if (noHistory)
            {
                _records.Reverse();
            }
            else
            {
                // original latest records by paths (assuming ascending order in the log)
                _latestRecords = new Dictionary <string, Record>(_comparer);
                foreach (var record in _records)
                {
                    _latestRecords[record.Path] = record;
                }

                var args = new GetHistoryArgs()
                {
                    Last = Settings.Default.MaximumFileCountFromFar
                };
                if (mode == 0)
                {
                    // add missing and later records from Far editor history
                    args.Kind = HistoryKind.Editor;
                    AddFarHistory(args);

                    // add missing and later records from Far viewer history
                    args.Kind = HistoryKind.Viewer;
                    AddFarHistory(args);
                }
                else if (mode == 1)
                {
                    // add missing and later records from Far folder history
                    args.Kind = HistoryKind.Folder;
                    AddFarHistory(args);
                }
                else
                {
                    // add missing and later records from Far command history
                    args.Kind = HistoryKind.Command;
                    AddFarHistory(args);
                }
            }

            // get sorted
            _records = new List <Record>(_records.OrderByDescending(x => x.Time));
        }