<commit_before>/*
    Copyright 2005-2007 Adobe Systems Incorporated
    Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
    or a copy at http://stlab.adobe.com/licenses.html)
*/

/*************************************************************************************************/

#include <GG/adobe/future/widgets/headers/platform_edit_text.hpp>

#include <GG/adobe/controller_concept.hpp>
#include <GG/adobe/placeable_concept.hpp>
#include <GG/adobe/future/widgets/headers/display.hpp>
#include <GG/adobe/future/widgets/headers/platform_label.hpp>
#include <GG/adobe/future/widgets/headers/platform_metrics.hpp>
#include <GG/adobe/future/widgets/headers/platform_widget_utils.hpp>

#include <GG/GUI.h>
#include <GG/MultiEdit.h>
#include <GG/StyleFactory.h>
#include <GG/utf8/checked.h>


/*************************************************************************************************/

namespace {

/*************************************************************************************************/

struct EditHandler
{
    EditHandler(adobe::edit_text_t& edit_text) :
        m_edit_text(&edit_text)
        {}

    void operator()(const std::string& text)
        {
            m_edit_text->value_m = text;
            m_edit_text->post_edit_proc_m(text);
        }

    adobe::edit_text_t* m_edit_text;
};

/*************************************************************************************************/

const int gap = 4;

} // namespace

/*************************************************************************************************/

namespace adobe {

namespace implementation {

/*************************************************************************************************/

class EditTextFilter :
    public GG::Wnd
{
public:
    EditTextFilter(edit_text_t& edit_text) :
        Wnd(GG::X0, GG::Y0, GG::X1, GG::Y1),
        m_edit_text(edit_text)
        {}

    virtual bool EventFilter(GG::Wnd*, const GG::WndEvent& event)
        {
            bool retval = false;
            if (event.Type() == GG::WndEvent::MouseWheel) {
                bool squelch;
                if (event.WheelMove() < 0)
                    m_edit_text.pre_edit_proc_m(std::string(30, 1), squelch);
                else if (0 < event.WheelMove())
                    m_edit_text.pre_edit_proc_m(std::string(31, 1), squelch);
                retval = true;
            } else if (event.Type() == GG::WndEvent::KeyPress) {
                bool nontext =
                    event.GetKey() == GG::GGK_HOME ||
                    event.GetKey() == GG::GGK_LEFT ||
                    event.GetKey() == GG::GGK_RIGHT ||
                    event.GetKey() == GG::GGK_END ||
                    event.GetKey() == GG::GGK_PAGEUP ||
                    event.GetKey() == GG::GGK_PAGEDOWN ||
                    event.GetKey() == GG::GGK_BACKSPACE ||
                    event.GetKey() == GG::GGK_DELETE ||
                    event.GetKey() == GG::GGK_RETURN ||
                    event.GetKey() == GG::GGK_KP_ENTER;

                if (nontext)
                    return false;

                const std::string& text = m_edit_text.control_m->Text();

                bool squelch =
                    m_edit_text.rows_m == 1 &&
                    0 < m_edit_text.max_cols_m &&<commit_msg>Fixed broken up/down arrows and mouse wheel increments/decrements in edit_text.<commit_after>/*
    Copyright 2005-2007 Adobe Systems Incorporated
    Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
    or a copy at http://stlab.adobe.com/licenses.html)
*/

/*************************************************************************************************/

#include <GG/adobe/future/widgets/headers/platform_edit_text.hpp>

#include <GG/adobe/controller_concept.hpp>
#include <GG/adobe/placeable_concept.hpp>
#include <GG/adobe/future/widgets/headers/display.hpp>
#include <GG/adobe/future/widgets/headers/platform_label.hpp>
#include <GG/adobe/future/widgets/headers/platform_metrics.hpp>
#include <GG/adobe/future/widgets/headers/platform_widget_utils.hpp>

#include <GG/GUI.h>
#include <GG/MultiEdit.h>
#include <GG/StyleFactory.h>
#include <GG/utf8/checked.h>


/*************************************************************************************************/

namespace {

/*************************************************************************************************/

struct EditHandler
{
    EditHandler(adobe::edit_text_t& edit_text) :
        m_edit_text(&edit_text)
        {}

    void operator()(const std::string& text)
        {
            m_edit_text->value_m = text;
            m_edit_text->post_edit_proc_m(text);
        }

    adobe::edit_text_t* m_edit_text;
};

/*************************************************************************************************/

const int gap = 4;

} // namespace

/*************************************************************************************************/

namespace adobe {

namespace implementation {

/*************************************************************************************************/

class EditTextFilter :
    public GG::Wnd
{
public:
    EditTextFilter(edit_text_t& edit_text) :
        Wnd(GG::X0, GG::Y0, GG::X1, GG::Y1),
        m_edit_text(edit_text)
        {}

    virtual bool EventFilter(GG::Wnd*, const GG::WndEvent& event)
        {
            bool retval = false;
            if (event.Type() == GG::WndEvent::MouseWheel) {
                bool squelch;
                m_edit_text.pre_edit_proc_m(std::string(1, 0 < event.WheelMove() ? 30 : 31), squelch);
                retval = true;
            } else if (event.Type() == GG::WndEvent::KeyPress) {
                bool nontext =
                    event.GetKey() == GG::GGK_HOME ||
                    event.GetKey() == GG::GGK_LEFT ||
                    event.GetKey() == GG::GGK_RIGHT ||
                    event.GetKey() == GG::GGK_END ||
                    event.GetKey() == GG::GGK_PAGEUP ||
                    event.GetKey() == GG::GGK_PAGEDOWN ||
                    event.GetKey() == GG::GGK_BACKSPACE ||
                    event.GetKey() == GG::GGK_DELETE ||
                    event.GetKey() == GG::GGK_RETURN ||
                    event.GetKey() == GG::GGK_KP_ENTER;

                if (nontext)
                    return false;

                if (event.GetKey() == GG::GGK_UP || event.GetKey() == GG::GGK_DOWN) {
                    bool squelch;
                    m_edit_text.pre_edit_proc_m(std::string(1, event.GetKey() == GG::GGK_UP ? 30 : 31), squelch);
                    return true;
                }

                const std::string& text = m_edit_text.control_m->Text();

                bool squelch =
                    m_edit_text.rows_m == 1 &&
                    0 < m_edit_text.max_cols_m &&
{'fraction_non_alphanumeric': 0.28021015761821366, 'fraction_numerical': 0.008318739054290718, 'mean_word_length': 2.6355437665782495, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 31, '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': '1367960', 'n_tokens_mistral': 2068, 'n_tokens_neox': 1864, 'n_words': 311}