<commit_before>! Copyright (C) 2006, 2009 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs classes combinators
combinators.short-circuit compiler.units debugger fry hashtables
help help.apropos help.crossref help.home help.markup
help.stylesheet help.topics io.styles kernel locals make models
namespaces sequences sets ui ui.commands ui.gadgets
ui.gadgets.borders ui.gadgets.editors ui.gadgets.glass
ui.gadgets.labels ui.gadgets.panes ui.gadgets.scrollers
ui.gadgets.status-bar ui.gadgets.theme ui.gadgets.toolbar
ui.gadgets.tracks ui.gadgets.viewports ui.gadgets.worlds
ui.gestures ui.pens.solid ui.tools.browser.history
ui.tools.browser.popups ui.tools.common vocabs ;
IN: ui.tools.browser

TUPLE: browser-gadget < tool history scroller search-field popup ;

{ 650 700 } browser-gadget set-tool-dim

M: browser-gadget history-value
    [ control-value ] [ scroller>> scroll-position ]
    bi 2array ;

M: browser-gadget set-history-value
    [ first2 ] dip
    [ set-control-value ] [ scroller>> set-scroll-position ]
    bi-curry bi* ;

: show-help ( link browser-gadget -- )
    [ >link ] dip
    [
        2dup control-value =
        [ 2drop ] [ [ add-recent ] [ history>> add-history ] bi* ] if
    ]
    [ set-control-value ]
    2bi ;

CONSTANT: prev -1
CONSTANT: next 1

: add-navigation-arrow ( str direction -- str )
    prev = [ "<" prefix ] [ ">" suffix ] if ;

: $navigation-arrow ( content element direction -- )
    [ prefix 1array ] dip add-navigation-arrow , ;

:: ($navigation) ( topic direction -- )
    topic [
        direction prev/next-article
        [ 1array \ $long-link direction $navigation-arrow ] when*
    ] { } make [ ($navigation-table) ] unless-empty ;

: $navigation ( topic direction -- )
    title-style get [
        help-path-style get [
            ($navigation)
        ] with-style
    ] with-style ;

: $title ( topic -- )
    title-style get
    help-header-background page-color associate
    assoc-union dup
    [
        [<commit_msg>ui.tools.browser: better to remove page-color than change it.<commit_after>! Copyright (C) 2006, 2009 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs classes combinators
combinators.short-circuit compiler.units debugger fry help
help.apropos help.crossref help.home help.markup help.stylesheet
help.topics io.styles kernel locals make models namespaces
sequences sets ui ui.commands ui.gadgets ui.gadgets.borders
ui.gadgets.editors ui.gadgets.glass ui.gadgets.labels
ui.gadgets.panes ui.gadgets.scrollers ui.gadgets.status-bar
ui.gadgets.theme ui.gadgets.toolbar ui.gadgets.tracks
ui.gadgets.viewports ui.gadgets.worlds ui.gestures ui.pens.solid
ui.tools.browser.history ui.tools.browser.popups ui.tools.common
vocabs ;
IN: ui.tools.browser

TUPLE: browser-gadget < tool history scroller search-field popup ;

{ 650 700 } browser-gadget set-tool-dim

M: browser-gadget history-value
    [ control-value ] [ scroller>> scroll-position ]
    bi 2array ;

M: browser-gadget set-history-value
    [ first2 ] dip
    [ set-control-value ] [ scroller>> set-scroll-position ]
    bi-curry bi* ;

: show-help ( link browser-gadget -- )
    [ >link ] dip
    [
        2dup control-value =
        [ 2drop ] [ [ add-recent ] [ history>> add-history ] bi* ] if
    ]
    [ set-control-value ]
    2bi ;

CONSTANT: prev -1
CONSTANT: next 1

: add-navigation-arrow ( str direction -- str )
    prev = [ "<" prefix ] [ ">" suffix ] if ;

: $navigation-arrow ( content element direction -- )
    [ prefix 1array ] dip add-navigation-arrow , ;

:: ($navigation) ( topic direction -- )
    topic [
        direction prev/next-article
        [ 1array \ $long-link direction $navigation-arrow ] when*
    ] { } make [ ($navigation-table) ] unless-empty ;

: $navigation ( topic direction -- )
    title-style get [
        help-path-style get [
            ($navigation)
        ] with-style
    ] with-style ;

: $title ( topic -- )
    title-style get clone page-color over delete-at dup
    [
        [
{'fraction_non_alphanumeric': 0.11974428325547086, 'fraction_numerical': 0.011310548315711827, 'mean_word_length': 2.9077809798270895, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, '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': '6523853', 'n_tokens_mistral': 1359, 'n_tokens_neox': 1314, 'n_words': 324}