scroll_indicator.cpp
algorithm
memory
string
utility
ftxui/dom/elements.hpp
ftxui/dom/node.hpp
ftxui/dom/node_decorator.hpp
ftxui/dom/requirement.hpp
ftxui/screen/box.hpp
ftxui/screen/screen.hpp
ftxui/dom/canvas.hpp
ftxui/dom/deprecated.hpp
ftxui/dom/direction.hpp
ftxui/dom/elements.hpp
ftxui/dom/flexbox_config.hpp
ftxui/dom/linear_gradient.hpp
ftxui/dom/node.hpp
ftxui/dom/requirement.hpp
ftxui/dom/selection.hpp
ftxui/screen/box.hpp
ftxui/screen/color.hpp
ftxui/screen/image.hpp
ftxui/screen/pixel.hpp
ftxui/screen/screen.hpp
ftxui/screen/string.hpp
ftxui/screen/terminal.hpp
ftxui/util/autoreset.hpp
ftxui/util/ref.hpp
ftxui/dom/node_decorator.hpp
src/ftxui/dom/scroll_indicator.cpp
algorithm
cstddef
cstdint
ftxui/dom/take_any_args.hpp
functional
memory
optional
sstream
string
unordered_map
utility
variant
vector
ftxui

    //Copyright2021ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include<algorithm>//formax
    #include<memory>//formake_shared,__shared_ptr_access
    #include<string>//forstring
    #include<utility>//formove

    #include"ftxui/dom/elements.hpp"//forElement,vscroll_indicator,hscroll_indicator
    #include"ftxui/dom/node.hpp"//forNode,Elements
    #include"ftxui/dom/node_decorator.hpp"//forNodeDecorator
    #include"ftxui/dom/requirement.hpp"//forRequirement
    #include"ftxui/screen/box.hpp"//forBox
    #include"ftxui/screen/screen.hpp"//forScreen,Pixel

    namespaceftxui{

    ///@briefDisplayaverticalscrollbartotheright.
    ///colors.
    ///@ingroupdom
    Elementvscroll_indicator(Elementchild){
    classImpl:publicNodeDecorator{
    usingNodeDecorator::NodeDecorator;

    voidComputeRequirement()override{
    NodeDecorator::ComputeRequirement();
    requirement_=children_[0]->requirement();
    requirement_.min_x++;
    }

    voidSetBox(Boxbox)override{
    box_=box;
    box.x_max--;
    children_[0]->SetBox(box);
    }

    voidRender(Screen&screen)final{
    NodeDecorator::Render(screen);

    constBox&stencil=screen.stencil;

    constintsize_inner=box_.y_max-box_.y_min;
    if(size_inner<=0){
    return;
    }
    constintsize_outter=stencil.y_max-stencil.y_min+1;
    if(size_outter>=size_inner){
    return;
    }

    intsize=2*size_outter*size_outter/size_inner;
    size=std::max(size,1);

    constintstart_y=
    2*stencil.y_min+//
    2*(stencil.y_min-box_.y_min)*size_outter/size_inner;

    constintx=stencil.x_max;
    for(inty=stencil.y_min;y<=stencil.y_max;++y){
    constinty_up=2*y+0;
    constinty_down=2*y+1;
    constboolup=(start_y<=y_up)&&(y_up<=start_y+size);
    constbooldown=(start_y<=y_down)&&(y_down<=start_y+size);

    constchar*c=up?(down?"┃":"╹"):(down?"╻":"");//NOLINT
    screen.PixelAt(x,y).character=c;
    }
    }
    };
    returnstd::make_shared<Impl>(std::move(child));
    }

    ///@briefDisplayanhorizontalscrollbartothebottom.
    ///colors.
    ///@ingroupdom
    Elementhscroll_indicator(Elementchild){
    classImpl:publicNodeDecorator{
    usingNodeDecorator::NodeDecorator;

    voidComputeRequirement()override{
    NodeDecorator::ComputeRequirement();
    requirement_=children_[0]->requirement();
    requirement_.min_y++;
    }

    voidSetBox(Boxbox)override{
    box_=box;
    box.y_max--;
    children_[0]->SetBox(box);
    }

    voidRender(Screen&screen)final{
    NodeDecorator::Render(screen);

    constBox&stencil=screen.stencil;

    constintsize_inner=box_.x_max-box_.x_min;
    if(size_inner<=0){
    return;
    }
    constintsize_outter=stencil.x_max-stencil.x_min+1;
    if(size_outter>=size_inner){
    return;
    }

    intsize=2*size_outter*size_outter/size_inner;
    size=std::max(size,1);

    constintstart_x=
    2*stencil.x_min+//
    2*(stencil.x_min-box_.x_min)*size_outter/size_inner;

    constinty=stencil.y_max;
    for(intx=stencil.x_min;x<=stencil.x_max;++x){
    constintx_left=2*x+0;
    constintx_right=2*x+1;
    constboolleft=(start_x<=x_left)&&(x_left<=start_x+size);
    constboolright=(start_x<=x_right)&&(x_right<=start_x+size);

    constchar*c=
    left?(right?"─":"╴"):(right?"╶":"");//NOLINT
    screen.PixelAt(x,y).character=c;
    }
    }
    };
    returnstd::make_shared<Impl>(std::move(child));
    }

    }//namespaceftxui