<commit_before>package imgui.imgui.demo.showExampleApp

import glm_.c
import glm_.f
import glm_.i
import glm_.vec2.Vec2
import glm_.vec4.Vec4
import imgui.*
import imgui.ImGui.beginTabBar
import imgui.ImGui.beginTabItem
import imgui.ImGui.bulletText
import imgui.ImGui.button
import imgui.ImGui.checkbox
import imgui.ImGui.colorEditVec4
import imgui.ImGui.combo
import imgui.ImGui.cursorScreenPos
import imgui.ImGui.dragFloat
import imgui.ImGui.dummy
import imgui.ImGui.endTabBar
import imgui.ImGui.endTabItem
import imgui.ImGui.fontSize
import imgui.ImGui.image
import imgui.ImGui.inputFloat
import imgui.ImGui.io
import imgui.ImGui.isMouseHoveringRect
import imgui.ImGui.logFinish
import imgui.ImGui.logText
import imgui.ImGui.logToClipboard
import imgui.ImGui.popFont
import imgui.ImGui.popId
import imgui.ImGui.popItemWidth
import imgui.ImGui.pushFont
import imgui.ImGui.pushId
import imgui.ImGui.pushItemWidth
import imgui.ImGui.radioButton
import imgui.ImGui.sameLine
import imgui.ImGui.separator
import imgui.ImGui.setWindowFontScale
import imgui.ImGui.showFontSelector
import imgui.ImGui.showStyleSelector
import imgui.ImGui.sliderFloat
import imgui.ImGui.sliderVec2
import imgui.ImGui.style
import imgui.ImGui.text
import imgui.ImGui.textUnformatted
import imgui.ImGui.treeNode
import imgui.ImGui.treePop
import imgui.ImGui.windowDrawList
import imgui.ImGui.windowWidth
import imgui.functionalProgramming.button
import imgui.functionalProgramming.smallButton
import imgui.functionalProgramming.treeNode
import imgui.functionalProgramming.withChild
import imgui.functionalProgramming.withId
import imgui.functionalProgramming.withItemWidth
import imgui.functionalProgramming.withTooltip
import imgui.imgui.imgui_demoDebugInformations.Companion.showHelpMarker
import kotlin.math.sqrt
import imgui.ColorEditFlag as Cef
import imgui.InputTextFlag as Itf
import imgui.SelectableFlag as Sf
import imgui.TreeNodeFlag as Tnf
import imgui.WindowFlag as Wf

object StyleEditor {

    var init = true
    var refSavedStyle: Style? = null
    // Default Styles Selector
    var styleIdx = 0

    var windowBorder = false
    var frameBorder = false
    var popupBorder = false

    var outputDest = 0
    var outputOnlyModified = true
    var alphaFlags: ColorEditFlags = 0
    val filter = TextFilter()
    var windowScale = 1f

    operator fun invoke(ref_: Style? = null) {

        /*  You can pass in a reference ImGuiStyle structure to compare to, revert to and save to
            (else it compares to the default style)         */

        // Default to using internal storage as reference
        if (init && ref_ == null) refSavedStyle = Style(style)
        init = false
        var ref = ref_ ?: refSavedStyle

        pushItemWidth(windowWidth * 0.55f)
        if (showStyleSelector("Colors##Selector"))
            refSavedStyle = Style(style)

        showFontSelector("Fonts##Selector")

        // Simplified Settings
        if (sliderFloat("FrameRounding", style::frameRounding, 0f, 12f, "%.0f"))
            style.grabRounding = style.frameRounding    // Make GrabRounding always the same value as FrameRounding
        run {
            windowBorder = style.windowBorderSize > 0f
            if (checkbox("WindowBorder", ::windowBorder)) style.windowBorderSize = if (windowBorder) 1f else 0f
        }
        sameLine()
        run {
            frameBorder = style.frameBorderSize > 0f
            if (checkbox("FrameBorder", ::frameBorder)) style.frameBorderSize = if (frameBorder) 1f else 0f
        }
        sameLine()
        run {
            popupBorder = style.popupBorderSize > 0f
            if (checkbox("PopupBorder", ::popupBorder)) style.popupBorderSize = if (popupBorder) 1f else 0f
        }

        // Save/Revert button
        button("Save Ref") {
            refSavedStyle = Style(style)
            ref = style
        }
        sameLine()
        if (button("Revert Ref")) g.style = ref!!
        sameLine()
        showHelpMarker("Save/Revert in local non-persistent storage. Default Colors definition are not affected. Use \"Export Colors\" below to save them somewhere.")

        separator()

        if (beginTabBar("##tabs", TabBarFlag.None.i)) {

            if (beginTabItem("Sizes")) {
                text("Main")
                sliderVec2("WindowPadding", style.windowPadding, 0f, 20f, "%.0f")
                sliderVec2("FramePadding", style.framePadding, 0f, 20f, "%.0f")
                sliderVec2("ItemSpacing", style.itemSpacing, 0f, 20f, "%.0f")
                sliderVec2("ItemInnerSpacing", style.itemInnerSpacing, 0f, 20f, "%.0f")
                sliderVec2("TouchExtraPadding", style.touchExtraPadding, 0f, 10f, "%.0f")
                sliderFloat("IndentSpacing", style::indentSpacing, 0f, 30f, "%.0f")
                sliderFloat("ScrollbarSize", style::scrollbarSize, 1f, 20f, "%.0f")
                sliderFloat("GrabMinSize", style::grabMinSize, 1f, 20f, "%.0f")
                text("Borders")
                sliderFloat("WindowBorderSize", style::windowBorderSize, 0f, 1f, "%.0f")
                sliderFloat("ChildBorderSize", style::childBorderSize, 0f, 1f, "%.0f")
                sliderFloat("PopupBorderSize", style::popupBorderSize, 0f, 1f, "%.0f")
                sliderFloat("FrameBorderSize", style::frameBorderSize, 0f, 1f, "%.0f")
                sliderFloat("TabBorderSize", style::tabBorderSize, 0f, 1f, "%.0f")
                text("Rounding")
                sliderFloat("WindowRounding", style::windowRounding, 0f, 12f, "%.0f")
                sliderFloat("ChildRounding", style::childRounding, 0f, 12f, "%.0f")
                sliderFloat("FrameRounding", style::frameRounding, 0f, 12f, "%.0f")
                sliderFloat("PopupRounding", style::popupRounding, 0f, 16f, "%.0f")
                sliderFloat("ScrollbarRounding", style::scrollbarRounding, 0f, 12f, "%.0f")
                sliderFloat("GrabRounding", style::grabRounding, 0f, 12f, "%.0f")
                sliderFloat("TabRounding", style::tabRounding, 0f, 12f, "%.0f")
                text("Alignment")
                sliderVec2("WindowTitleAlign", style.windowTitleAlign, 0f, 1f, "%.2f")
                sliderVec2("ButtonTextAlign", style.buttonTextAlign, 0f, 1f, "%.2f"); sameLine(); showHelpMarker("Alignment applies when a button is larger than its text content.")
                text("Safe Area Padding"); sameLine(); showHelpMarker("Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured).")
                sliderVec2("DisplaySafeAreaPadding", style.displaySafeAreaPadding, 0f, 30f, "%.0f")
                endTabItem()
            }

            if (beginTabItem("Colors")) {

                button("Export Unsaved") {
                    if (outputDest == 0)
                        logToClipboard()
                    else
                        TODO() //logToTTY()
                    logText("val colors = ImGui.style.colors\n")
                    for (i in Col.values()) {
                        val col = style.colors[i]
                        val name = i.name
                        if (!outputOnlyModified || col != ref!!.colors[i])
                            logText("colors[Col.%s.i] = Vec4(%.2f, %.2f, %.2f, %.2f)\n", name, col.x, col.y, col.z, col.w)
                    }
                    logFinish()
                }
                sameLine()
                withItemWidth(120f) { combo("##output_type", ::outputDest, "To Clipboard\u0000To TTY\u0000") }
                sameLine()
                checkbox("Only Modified Colors", ::outputOnlyModified)

                text("Tip: Left-click on colored square to open color picker,\nRight-click to open edit options menu.")

                filter.draw("Filter colors", fontSize * 16)

                radioButton("Opaque", ::alphaFlags, 0); sameLine()
                radioButton("Alpha", ::alphaFlags, Cef.AlphaPreview.i); sameLine()
                radioButton("Both", ::alphaFlags, Cef.AlphaPreviewHalf.i); sameLine()
                showHelpMarker("In the color list:\nLeft-click on colored square to open color picker,\nRight-click to open edit options menu.");

                withChild("#colors", Vec2(), true, Wf.AlwaysVerticalScrollbar or Wf.AlwaysHorizontalScrollbar or Wf.NavFlattened) {
                    withItemWidth(-160) {
                        for (i in 0 until Col.COUNT) {
                            val name = Col.values()[i].name
                            if (!filter.passFilter(name)) // TODO fix bug
                                continue
                            withId(i) {
                                colorEditVec4("##color", style.colors[i], Cef.AlphaBar or alphaFlags)
                                if (style.colors[i] != ref!!.colors[i]) {
                                    /*  Tips: in a real user application, you may want to merge and use an icon font into
                                        the main font, so instead of "Save"/"Revert" you'd use icons.
                                        Read the FAQ and misc/fonts/README.txt about using icon fonts. It's really easy
                                        and super convenient!  */
                                    sameLine(0f, style.itemInnerSpacing.x)
                                    if (button("Save")) ref!!.colors[i] = Vec4(style.colors[i])
                                    sameLine(0f, style.itemInnerSpacing.x)
                                    if (button("Revert")) style.colors[i] = Vec4(ref!!.colors[i])
                                }
                                sameLine(0f, style.itemInnerSpacing.x)
                                textUnformatted(name)
                            }
                        }
                    }
                }

                endTabItem()
            }
<commit_msg>Filter is fixed<commit_after>package imgui.imgui.demo.showExampleApp

import glm_.c
import glm_.f
import glm_.i
import glm_.vec2.Vec2
import glm_.vec4.Vec4
import imgui.*
import imgui.ImGui.beginTabBar
import imgui.ImGui.beginTabItem
import imgui.ImGui.bulletText
import imgui.ImGui.button
import imgui.ImGui.checkbox
import imgui.ImGui.colorEditVec4
import imgui.ImGui.combo
import imgui.ImGui.cursorScreenPos
import imgui.ImGui.dragFloat
import imgui.ImGui.dummy
import imgui.ImGui.endTabBar
import imgui.ImGui.endTabItem
import imgui.ImGui.fontSize
import imgui.ImGui.image
import imgui.ImGui.inputFloat
import imgui.ImGui.io
import imgui.ImGui.isMouseHoveringRect
import imgui.ImGui.logFinish
import imgui.ImGui.logText
import imgui.ImGui.logToClipboard
import imgui.ImGui.popFont
import imgui.ImGui.popId
import imgui.ImGui.popItemWidth
import imgui.ImGui.pushFont
import imgui.ImGui.pushId
import imgui.ImGui.pushItemWidth
import imgui.ImGui.radioButton
import imgui.ImGui.sameLine
import imgui.ImGui.separator
import imgui.ImGui.setWindowFontScale
import imgui.ImGui.showFontSelector
import imgui.ImGui.showStyleSelector
import imgui.ImGui.sliderFloat
import imgui.ImGui.sliderVec2
import imgui.ImGui.style
import imgui.ImGui.text
import imgui.ImGui.textUnformatted
import imgui.ImGui.treeNode
import imgui.ImGui.treePop
import imgui.ImGui.windowDrawList
import imgui.ImGui.windowWidth
import imgui.functionalProgramming.button
import imgui.functionalProgramming.smallButton
import imgui.functionalProgramming.treeNode
import imgui.functionalProgramming.withChild
import imgui.functionalProgramming.withId
import imgui.functionalProgramming.withItemWidth
import imgui.functionalProgramming.withTooltip
import imgui.imgui.imgui_demoDebugInformations.Companion.showHelpMarker
import kotlin.math.sqrt
import imgui.ColorEditFlag as Cef
import imgui.InputTextFlag as Itf
import imgui.SelectableFlag as Sf
import imgui.TreeNodeFlag as Tnf
import imgui.WindowFlag as Wf

object StyleEditor {

    var init = true
    var refSavedStyle: Style? = null
    // Default Styles Selector
    var styleIdx = 0

    var windowBorder = false
    var frameBorder = false
    var popupBorder = false

    var outputDest = 0
    var outputOnlyModified = true
    var alphaFlags: ColorEditFlags = 0
    val filter = TextFilter()
    var windowScale = 1f

    operator fun invoke(ref_: Style? = null) {

        /*  You can pass in a reference ImGuiStyle structure to compare to, revert to and save to
            (else it compares to the default style)         */

        // Default to using internal storage as reference
        if (init && ref_ == null) refSavedStyle = Style(style)
        init = false
        var ref = ref_ ?: refSavedStyle

        pushItemWidth(windowWidth * 0.55f)
        if (showStyleSelector("Colors##Selector"))
            refSavedStyle = Style(style)

        showFontSelector("Fonts##Selector")

        // Simplified Settings
        if (sliderFloat("FrameRounding", style::frameRounding, 0f, 12f, "%.0f"))
            style.grabRounding = style.frameRounding    // Make GrabRounding always the same value as FrameRounding
        run {
            windowBorder = style.windowBorderSize > 0f
            if (checkbox("WindowBorder", ::windowBorder)) style.windowBorderSize = if (windowBorder) 1f else 0f
        }
        sameLine()
        run {
            frameBorder = style.frameBorderSize > 0f
            if (checkbox("FrameBorder", ::frameBorder)) style.frameBorderSize = if (frameBorder) 1f else 0f
        }
        sameLine()
        run {
            popupBorder = style.popupBorderSize > 0f
            if (checkbox("PopupBorder", ::popupBorder)) style.popupBorderSize = if (popupBorder) 1f else 0f
        }

        // Save/Revert button
        button("Save Ref") {
            refSavedStyle = Style(style)
            ref = style
        }
        sameLine()
        if (button("Revert Ref")) g.style = ref!!
        sameLine()
        showHelpMarker("Save/Revert in local non-persistent storage. Default Colors definition are not affected. Use \"Export Colors\" below to save them somewhere.")

        separator()

        if (beginTabBar("##tabs", TabBarFlag.None.i)) {

            if (beginTabItem("Sizes")) {
                text("Main")
                sliderVec2("WindowPadding", style.windowPadding, 0f, 20f, "%.0f")
                sliderVec2("FramePadding", style.framePadding, 0f, 20f, "%.0f")
                sliderVec2("ItemSpacing", style.itemSpacing, 0f, 20f, "%.0f")
                sliderVec2("ItemInnerSpacing", style.itemInnerSpacing, 0f, 20f, "%.0f")
                sliderVec2("TouchExtraPadding", style.touchExtraPadding, 0f, 10f, "%.0f")
                sliderFloat("IndentSpacing", style::indentSpacing, 0f, 30f, "%.0f")
                sliderFloat("ScrollbarSize", style::scrollbarSize, 1f, 20f, "%.0f")
                sliderFloat("GrabMinSize", style::grabMinSize, 1f, 20f, "%.0f")
                text("Borders")
                sliderFloat("WindowBorderSize", style::windowBorderSize, 0f, 1f, "%.0f")
                sliderFloat("ChildBorderSize", style::childBorderSize, 0f, 1f, "%.0f")
                sliderFloat("PopupBorderSize", style::popupBorderSize, 0f, 1f, "%.0f")
                sliderFloat("FrameBorderSize", style::frameBorderSize, 0f, 1f, "%.0f")
                sliderFloat("TabBorderSize", style::tabBorderSize, 0f, 1f, "%.0f")
                text("Rounding")
                sliderFloat("WindowRounding", style::windowRounding, 0f, 12f, "%.0f")
                sliderFloat("ChildRounding", style::childRounding, 0f, 12f, "%.0f")
                sliderFloat("FrameRounding", style::frameRounding, 0f, 12f, "%.0f")
                sliderFloat("PopupRounding", style::popupRounding, 0f, 16f, "%.0f")
                sliderFloat("ScrollbarRounding", style::scrollbarRounding, 0f, 12f, "%.0f")
                sliderFloat("GrabRounding", style::grabRounding, 0f, 12f, "%.0f")
                sliderFloat("TabRounding", style::tabRounding, 0f, 12f, "%.0f")
                text("Alignment")
                sliderVec2("WindowTitleAlign", style.windowTitleAlign, 0f, 1f, "%.2f")
                sliderVec2("ButtonTextAlign", style.buttonTextAlign, 0f, 1f, "%.2f"); sameLine(); showHelpMarker("Alignment applies when a button is larger than its text content.")
                text("Safe Area Padding"); sameLine(); showHelpMarker("Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured).")
                sliderVec2("DisplaySafeAreaPadding", style.displaySafeAreaPadding, 0f, 30f, "%.0f")
                endTabItem()
            }

            if (beginTabItem("Colors")) {

                button("Export Unsaved") {
                    if (outputDest == 0)
                        logToClipboard()
                    else
                        TODO() //logToTTY()
                    logText("val colors = ImGui.style.colors\n")
                    for (i in Col.values()) {
                        val col = style.colors[i]
                        val name = i.name
                        if (!outputOnlyModified || col != ref!!.colors[i])
                            logText("colors[Col.%s.i] = Vec4(%.2f, %.2f, %.2f, %.2f)\n", name, col.x, col.y, col.z, col.w)
                    }
                    logFinish()
                }
                sameLine()
                withItemWidth(120f) { combo("##output_type", ::outputDest, "To Clipboard\u0000To TTY\u0000") }
                sameLine()
                checkbox("Only Modified Colors", ::outputOnlyModified)

                text("Tip: Left-click on colored square to open color picker,\nRight-click to open edit options menu.")

                filter.draw("Filter colors", fontSize * 16)

                radioButton("Opaque", ::alphaFlags, 0); sameLine()
                radioButton("Alpha", ::alphaFlags, Cef.AlphaPreview.i); sameLine()
                radioButton("Both", ::alphaFlags, Cef.AlphaPreviewHalf.i); sameLine()
                showHelpMarker("In the color list:\nLeft-click on colored square to open color picker,\nRight-click to open edit options menu.");

                withChild("#colors", Vec2(), true, Wf.AlwaysVerticalScrollbar or Wf.AlwaysHorizontalScrollbar or Wf.NavFlattened) {
                    withItemWidth(-160) {
                        for (i in 0 until Col.COUNT) {
                            val name = Col.values()[i].name
                            if (!filter.passFilter(name))
                                continue
                            withId(i) {
                                colorEditVec4("##color", style.colors[i], Cef.AlphaBar or alphaFlags)
                                if (style.colors[i] != ref!!.colors[i]) {
                                    /*  Tips: in a real user application, you may want to merge and use an icon font into
                                        the main font, so instead of "Save"/"Revert" you'd use icons.
                                        Read the FAQ and misc/fonts/README.txt about using icon fonts. It's really easy
                                        and super convenient!  */
                                    sameLine(0f, style.itemInnerSpacing.x)
                                    if (button("Save")) ref!!.colors[i] = Vec4(style.colors[i])
                                    sameLine(0f, style.itemInnerSpacing.x)
                                    if (button("Revert")) style.colors[i] = Vec4(ref!!.colors[i])
                                }
                                sameLine(0f, style.itemInnerSpacing.x)
                                textUnformatted(name)
                            }
                        }
                    }
                }

                endTabItem()
            }

{'fraction_non_alphanumeric': 0.10390402602684018, 'fraction_numerical': 0.015250101667344449, 'mean_word_length': 2.1152810768012666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3108155', 'n_tokens_mistral': 5895, 'n_tokens_neox': 5434, 'n_words': 1343}