<commit_before>﻿// Copyright (c) 2007-2017 ppy Pty Ltd <<EMAIL>>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE

using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Caching;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input;
using osu.Framework.MathUtils;
using osu.Framework.Threading;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Configuration;
using osu.Framework.Graphics.Colour;
using osu.Framework.Platform;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Bindings;
using osu.Framework.Timing;

namespace osu.Framework.Graphics.UserInterface
{
    public class TextBox : TabbableContainer, IHasCurrentValue<string>
    {
        protected FillFlowContainer TextFlow;
        protected Box Background;
        protected Drawable Caret;
        protected Container TextContainer;

        /// <summary>
        /// Padding to be used within the TextContainer. Requires special handling due to the sideways scrolling of text content.
        /// </summary>
        protected virtual float LeftRightPadding => 5;

        private const float caret_move_time = 60;

        public int? LengthLimit;

        public virtual bool AllowClipboardExport => true;

        //represents the left/right selection coordinates of the word double clicked on when dragging
        private int[] doubleClickWord;

        private AudioManager audio;

        /// <summary>
        /// Should this TextBox accept arrow keys for navigation?
        /// </summary>
        public bool HandleLeftRightArrows = true;

        protected virtual Color4 BackgroundCommit => new Color4(249, 90, 255, 200);
        protected virtual Color4 BackgroundFocused => new Color4(100, 100, 100, 255);
        protected virtual Color4 BackgroundUnfocused => new Color4(100, 100, 100, 120);

        public bool ReadOnly;

        public bool ReleaseFocusOnCommit = true;

        private ITextInputSource textInput;
        private Clipboard clipboard;

        public delegate void OnCommitHandler(TextBox sender, bool newText);

        public OnCommitHandler OnCommit;

        private readonly Scheduler textUpdateScheduler = new Scheduler();

        public TextBox()
        {
            // TextBoxes currently require their own top-level PlatformInputManager, as InputManagers
            // will not propagate events through other InputManagers.
            // Once this restriction has been addressed, we can utilise a single instance of PlatformInputManager
            // at the Game level, and TextBoxes need only implement IKeyBindingHandler<PlatformAction>.
            Child = new PlatformInputManager
            {
                Masking = true,
                CornerRadius = 3,
                RelativeSizeAxes = Axes.Both,
                Children = new Drawable[]
                {
                    Background = new Box
                    {
                        Colour = BackgroundUnfocused,
                        RelativeSizeAxes = Axes.Both,
                    },
                    TextContainer = new KeyBindingContainer(this)
                    {
                        AutoSizeAxes = Axes.X,
                        RelativeSizeAxes = Axes.Y,<commit_msg>Fix textbox regression<commit_after>﻿// Copyright (c) 2007-2017 ppy Pty Ltd <<EMAIL>>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE

using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Caching;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input;
using osu.Framework.MathUtils;
using osu.Framework.Threading;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Configuration;
using osu.Framework.Graphics.Colour;
using osu.Framework.Platform;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Bindings;
using osu.Framework.Timing;

namespace osu.Framework.Graphics.UserInterface
{
    public class TextBox : TabbableContainer, IHasCurrentValue<string>
    {
        protected FillFlowContainer TextFlow;
        protected Box Background;
        protected Drawable Caret;
        protected Container TextContainer;

        /// <summary>
        /// Padding to be used within the TextContainer. Requires special handling due to the sideways scrolling of text content.
        /// </summary>
        protected virtual float LeftRightPadding => 5;

        private const float caret_move_time = 60;

        public int? LengthLimit;

        public virtual bool AllowClipboardExport => true;

        //represents the left/right selection coordinates of the word double clicked on when dragging
        private int[] doubleClickWord;

        private AudioManager audio;

        /// <summary>
        /// Should this TextBox accept arrow keys for navigation?
        /// </summary>
        public bool HandleLeftRightArrows = true;

        protected virtual Color4 BackgroundCommit => new Color4(249, 90, 255, 200);
        protected virtual Color4 BackgroundFocused => new Color4(100, 100, 100, 255);
        protected virtual Color4 BackgroundUnfocused => new Color4(100, 100, 100, 120);

        public bool ReadOnly;

        public bool ReleaseFocusOnCommit = true;

        private ITextInputSource textInput;
        private Clipboard clipboard;

        public delegate void OnCommitHandler(TextBox sender, bool newText);

        public OnCommitHandler OnCommit;

        private readonly Scheduler textUpdateScheduler = new Scheduler();

        public TextBox()
        {
            Masking = true;
            CornerRadius = 3;
            // TextBoxes currently require their own top-level PlatformInputManager, as InputManagers
            // will not propagate events through other InputManagers.
            // Once this restriction has been addressed, we can utilise a single instance of PlatformInputManager
            // at the Game level, and TextBoxes need only implement IKeyBindingHandler<PlatformAction>.
            Child = new PlatformInputManager
            {
                RelativeSizeAxes = Axes.Both,
                Children = new Drawable[]
                {
                    Background = new Box
                    {
                        Colour = BackgroundUnfocused,
                        RelativeSizeAxes = Axes.Both,
                    },
                    TextContainer = new KeyBindingContainer(this)
                    {
                        AutoSizeAxes = Axes.X,
                        RelativeSizeAxes = Axes.Y,
{'fraction_non_alphanumeric': 0.06934893928310168, 'fraction_numerical': 0.015508412582297001, 'mean_word_length': 2.3658296405711474, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 29, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '667630', 'n_tokens_mistral': 1809, 'n_tokens_neox': 1639, 'n_words': 537}