<commit_before>﻿using System;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using BCad.EventArguments;
using BCad.Helpers;
using BCad.Services;
using Input = System.Windows.Input;

namespace BCad.UI.Consoles
{
    /// <summary>
    /// Interaction logic for InputConsole.xaml
    /// </summary>
    [ExportConsole("Default")]
    public partial class InputConsole : ConsoleControl, IPartImportsSatisfiedNotification
    {
        public InputConsole()
        {
            InitializeComponent();
            //inputLine.AddHandler(TextBox.KeyDownEvent, new KeyEventHandler(InputKeyDown), true);
        }

        public void OnImportsSatisfied()
        {
            InputService.PromptChanged += HandlePromptChanged;
            InputService.LineWritten += HandleLineWritten;
        }

        private void HandlePromptChanged(object sender, PromptChangedEventArgs e)
        {
            Dispatcher.BeginInvoke((Action)(() => prompt.Content = e.Prompt));
        }

        private void HandleLineWritten(object sender, WriteLineEventArgs e)
        {
            Dispatcher.BeginInvoke((Action)(() =>
            {
                history.AppendText(e.Line + Environment.NewLine);
                history.ScrollToEnd();
            }));
        }

        public UserControl Control { get { return this; } }

        [Import]
        private IInputService InputService = null;

        [Import]
        private IView View = null;

        private void InputKeyDown(object sender, Input.KeyEventArgs e)
        {
            switch (e.Key)
            {
                case Input.Key.Enter:
                case Input.Key.LineFeed:
                    SubmitValue();
                    break;
                case Input.Key.Space:
                    if (InputService.AllowedInputTypes.HasFlag(InputType.Command))
                        e.Handled = true;
                    SubmitValue();
                    break;
                case Input.Key.Escape:
                    SubmitCancel();
                    break;
                default:<commit_msg>fixing input line bug<commit_after>﻿using System;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using BCad.EventArguments;
using BCad.Helpers;
using BCad.Services;
using Input = System.Windows.Input;

namespace BCad.UI.Consoles
{
    /// <summary>
    /// Interaction logic for InputConsole.xaml
    /// </summary>
    [ExportConsole("Default")]
    public partial class InputConsole : ConsoleControl, IPartImportsSatisfiedNotification
    {
        public InputConsole()
        {
            InitializeComponent();
            //inputLine.AddHandler(TextBox.KeyDownEvent, new KeyEventHandler(InputKeyDown), true);
        }

        public void OnImportsSatisfied()
        {
            InputService.PromptChanged += HandlePromptChanged;
            InputService.LineWritten += HandleLineWritten;
            Workspace.CommandExecuted += WorkspaceCommandExecuted;
        }

        private void HandlePromptChanged(object sender, PromptChangedEventArgs e)
        {
            Dispatcher.BeginInvoke((Action)(() =>
            {
                inputLine.Text = "";
                prompt.Content = e.Prompt;
            }));
        }

        private void HandleLineWritten(object sender, WriteLineEventArgs e)
        {
            Dispatcher.BeginInvoke((Action)(() =>
            {
                history.AppendText(e.Line + Environment.NewLine);
                history.ScrollToEnd();
            }));
        }

        private void WorkspaceCommandExecuted(object sender, CommandExecutedEventArgs e)
        {
            Dispatcher.BeginInvoke((Action)(() =>
            {
                inputLine.Text = "";
            }));
        }

        public UserControl Control { get { return this; } }

        [Import]
        private IInputService InputService = null;

        [Import]
        private IView View = null;

        [Import]
        private IWorkspace Workspace = null;

        private void InputKeyDown(object sender, Input.KeyEventArgs e)
        {
            switch (e.Key)
            {
                case Input.Key.Enter:
                case Input.Key.LineFeed:
                    SubmitValue();
                    break;
                case Input.Key.Space:
                    if (InputService.AllowedInputTypes.HasFlag(InputType.Command))
                        e.Handled = true;
                    SubmitValue();
                    break;
                case Input.Key.Escape:
                    SubmitCancel();
                    break;
                default:
{'fraction_non_alphanumeric': 0.0885547201336675, 'fraction_numerical': 0.0, 'mean_word_length': 1.7318881916714204, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 12, 'https://': 0, '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': '5433686', 'n_tokens_mistral': 1200, 'n_tokens_neox': 1137, 'n_words': 242}