<commit_before>! Copyright (C) 2021 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs classes kernel math.rectangles
models models.arrow namespaces sequences ui ui.gadgets
ui.gadgets.buttons ui.gadgets.glass ui.gadgets.labeled
ui.gadgets.presentations ui.gadgets.search-tables
ui.gadgets.labels ui.gadgets.tables ui.gadgets.worlds
ui.gadgets.wrappers ui.gestures ui.theme ui.tools.browser.popups
ui.tools.common ;
FROM: ui.gadgets.wrappers => wrapper ;
IN: ui.tools.button-list

TUPLE: button-list-popup < wrapper ;

MIXIN: clickable
INSTANCE: button clickable

SYMBOL: active-buttons
active-buttons [ H{ } ] initialize

: label-from-button ( button -- str/f )
    children>> [ label? ] find swap [ text>> ] [ drop f ] if ;

: world-buttons ( -- assoc )
    world get active-buttons get [ drop H{ } clone ] cache ;

: store-labelled-button ( button -- str/f )
    dup label-from-button [ [ world-buttons set-at ] keep ] [ drop f ] if* ;

: remove-labelled-button ( button -- str/f )
    label-from-button [ dup world-buttons delete-at ] [ f ] if* ;

M: clickable graft*
    [ store-labelled-button drop ] [ call-next-method ] bi ;<commit_msg>ui.tools.button-list: use linked-assocs to keep buttons in order<commit_after>! Copyright (C) 2021 <NAME>.
! See http://factorcode.org/license.txt for BSD license.

USING: accessors arrays assocs classes kernel linked-assocs
math.rectangles models models.arrow namespaces sequences ui
ui.gadgets ui.gadgets.buttons ui.gadgets.glass
ui.gadgets.labeled ui.gadgets.presentations
ui.gadgets.search-tables ui.gadgets.labels ui.gadgets.tables
ui.gadgets.worlds ui.gadgets.wrappers ui.gestures ui.theme
ui.tools.browser.popups ui.tools.common ;

FROM: ui.gadgets.wrappers => wrapper ;
IN: ui.tools.button-list

TUPLE: button-list-popup < wrapper ;

MIXIN: clickable
INSTANCE: button clickable

SYMBOL: active-buttons
active-buttons [ H{ } ] initialize

: label-from-button ( button -- str/f )
    children>> [ label? ] find swap [ text>> ] [ drop f ] if ;

: world-buttons ( -- assoc )
    world get active-buttons get [ drop LH{ } clone ] cache ;

: store-labelled-button ( button -- str/f )
    dup label-from-button [ [ world-buttons set-at ] keep ] [ drop f ] if* ;

: remove-labelled-button ( button -- str/f )
    label-from-button [ dup world-buttons delete-at ] [ f ] if* ;

M: clickable graft*
    [ store-labelled-button drop ] [ call-next-method ] bi ;
{'fraction_non_alphanumeric': 0.1276595744680851, 'fraction_numerical': 0.0032733224222585926, 'mean_word_length': 3.595864661654135, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '3097590', 'n_tokens_mistral': 835, 'n_tokens_neox': 815, 'n_words': 212}