using System;

namespace eagle {
    public class GeneratedTextListener : IClientTextListener {
        private readonly string textId;
        private readonly string prefix;
        private readonly string suffix;
        private readonly int index;
        private readonly Action<int, string> onTextUpdate;

        public void OnTextUpdate(string text, bool completed) {
            onTextUpdate(index, $"{prefix}{text}{suffix}");
        }

        public string TextId() { return textId; }

        public GeneratedTextListener(
                string textId,
                string prefix,
                string suffix,
                int index,
                Action<int, string> callback) {
            this.textId = textId;
            this.prefix = prefix;
            this.suffix = suffix;
            this.index = index;
            this.onTextUpdate = callback;
        }
    }
}