frame.cpp
algorithm
memory
utility
ftxui/dom/elements.hpp
ftxui/dom/node.hpp
ftxui/dom/requirement.hpp
ftxui/screen/box.hpp
ftxui/screen/screen.hpp
ftxui/util/autoreset.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
src/ftxui/dom/frame.cpp
algorithm
cstddef
cstdint
ftxui/dom/take_any_args.hpp
functional
memory
optional
sstream
string
unordered_map
utility
variant
vector
ftxui

    //Copyright2020ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include<algorithm>//formax,min
    #include<memory>//formake_shared,__shared_ptr_access
    #include<utility>//formove

    #include"ftxui/dom/elements.hpp"//forElement,unpack,Elements,focus,frame,select,xframe,yframe
    #include"ftxui/dom/node.hpp"//forNode,Elements
    #include"ftxui/dom/requirement.hpp"//forRequirement
    #include"ftxui/screen/box.hpp"//forBox
    #include"ftxui/screen/screen.hpp"//forScreen,Screen::Cursor
    #include"ftxui/util/autoreset.hpp"//forAutoReset

    namespaceftxui{

    namespace{
    classFocus:publicNode{
    public:
    explicitFocus(Elementschildren):Node(std::move(children)){}

    voidComputeRequirement()override{
    Node::ComputeRequirement();
    requirement_=children_[0]->requirement();
    requirement_.focused.enabled=true;
    requirement_.focused.node=this;
    requirement_.focused.box.x_min=0;
    requirement_.focused.box.y_min=0;
    requirement_.focused.box.x_max=requirement_.min_x-1;
    requirement_.focused.box.y_max=requirement_.min_y-1;
    }

    voidSetBox(Boxbox)override{
    Node::SetBox(box);
    children_[0]->SetBox(box);
    }
    };

    classFrame:publicNode{
    public:
    Frame(Elementschildren,boolx_frame,booly_frame)
    :Node(std::move(children)),x_frame_(x_frame),y_frame_(y_frame){}

    voidSetBox(Boxbox)override{
    Node::SetBox(box);
    auto&focused_box=requirement_.focused.box;
    Boxchildren_box=box;

    if(x_frame_){
    constintexternal_dimx=box.x_max-box.x_min;
    constintinternal_dimx=std::max(requirement_.min_x,external_dimx);
    constintfocused_dimx=focused_box.x_max-focused_box.x_min;
    intdx=focused_box.x_min-external_dimx/2+focused_dimx/2;
    dx=std::max(0,std::min(internal_dimx-external_dimx-1,dx));
    children_box.x_min=box.x_min-dx;
    children_box.x_max=box.x_min+internal_dimx-dx;
    }

    if(y_frame_){
    constintexternal_dimy=box.y_max-box.y_min;
    constintinternal_dimy=std::max(requirement_.min_y,external_dimy);
    constintfocused_dimy=focused_box.y_max-focused_box.y_min;
    intdy=focused_box.y_min-external_dimy/2+focused_dimy/2;
    dy=std::max(0,std::min(internal_dimy-external_dimy-1,dy));
    children_box.y_min=box.y_min-dy;
    children_box.y_max=box.y_min+internal_dimy-dy;
    }

    children_[0]->SetBox(children_box);
    }

    voidRender(Screen&screen)override{
    constAutoReset<Box>stencil(&screen.stencil,
    Box::Intersection(box_,screen.stencil));
    children_[0]->Render(screen);
    }

    private:
    boolx_frame_;
    booly_frame_;
    };

    classFocusCursor:publicFocus{
    public:
    FocusCursor(Elementschildren,Screen::Cursor::Shapeshape)
    :Focus(std::move(children)),shape_(shape){}

    private:
    voidComputeRequirement()override{
    Focus::ComputeRequirement();//NOLINT
    requirement_.focused.cursor_shape=shape_;
    }
    Screen::Cursor::Shapeshape_;
    };

    }//namespace

    ///@briefSetthe`child`tobetheonefocusedamongitssiblings.
    ///@paramchildTheelementtobefocused.
    ///@ingroupdom
    Elementfocus(Elementchild){
    returnstd::make_shared<Focus>(unpack(std::move(child)));
    }

    ///Thisisdeprecated.Use`focus`instead.
    ///@briefSetthe`child`tobetheonefocusedamongitssiblings.
    ///@paramchildTheelementtobefocused.
    Elementselect(Elementchild){
    returnfocus(std::move(child));
    }

    ///@briefAllowanelementtobedisplayedinsidea'virtual'area.Itsizecan
    ///belargerthanitscontainer.Inthiscaseonlyasmallerportionis
    ///displayed.Theviewisscrollabletomakethefocusedelementvisible.
    ///@seeframe
    ///@seexframe
    ///@seeyframe
    Elementframe(Elementchild){
    returnstd::make_shared<Frame>(unpack(std::move(child)),true,true);
    }

    ///@briefSameas`frame`,butonlyonthex-axis.
    ///@seeframe
    ///@seexframe
    ///@seeyframe
    Elementxframe(Elementchild){
    returnstd::make_shared<Frame>(unpack(std::move(child)),true,false);
    }

    ///@briefSameas`frame`,butonlyonthey-axis.
    ///@seeframe
    ///@seexframe
    ///@seeyframe
    Elementyframe(Elementchild){
    returnstd::make_shared<Frame>(unpack(std::move(child)),false,true);
    }

    ///@briefSameas`focus`,butsetthecursorshapetobeastillblock.
    ///@seefocus
    ///@seefocusCursorBlock
    ///@seefocusCursorBlockBlinking
    ///@seefocusCursorBar
    ///@seefocusCursorBarBlinking
    ///@seefocusCursorUnderline
    ///@seefocusCursorUnderlineBlinking
    ///@ingroupdom
    ElementfocusCursorBlock(Elementchild){
    returnstd::make_shared<FocusCursor>(unpack(std::move(child)),
    Screen::Cursor::Block);
    }

    ///@briefSameas`focus`,butsetthecursorshapetobeablinkingblock.
    ///@seefocus
    ///@seefocusCursorBlock
    ///@seefocusCursorBlockBlinking
    ///@seefocusCursorBar
    ///@seefocusCursorBarBlinking
    ///@seefocusCursorUnderline
    ///@seefocusCursorUnderlineBlinking
    ///@ingroupdom
    ElementfocusCursorBlockBlinking(Elementchild){
    returnstd::make_shared<FocusCursor>(unpack(std::move(child)),
    Screen::Cursor::BlockBlinking);
    }

    ///@briefSameas`focus`,butsetthecursorshapetobeastillblock.
    ///@seefocus
    ///@seefocusCursorBlock
    ///@seefocusCursorBlockBlinking
    ///@seefocusCursorBar
    ///@seefocusCursorBarBlinking
    ///@seefocusCursorUnderline
    ///@seefocusCursorUnderlineBlinking
    ///@ingroupdom
    ElementfocusCursorBar(Elementchild){
    returnstd::make_shared<FocusCursor>(unpack(std::move(child)),
    Screen::Cursor::Bar);
    }

    ///@briefSameas`focus`,butsetthecursorshapetobeablinkingbar.
    ///@seefocus
    ///@seefocusCursorBlock
    ///@seefocusCursorBlockBlinking
    ///@seefocusCursorBar
    ///@seefocusCursorBarBlinking
    ///@seefocusCursorUnderline
    ///@seefocusCursorUnderlineBlinking
    ///@ingroupdom
    ElementfocusCursorBarBlinking(Elementchild){
    returnstd::make_shared<FocusCursor>(unpack(std::move(child)),
    Screen::Cursor::BarBlinking);
    }

    ///@briefSameas`focus`,butsetthecursorshapetobeastillunderline.
    ///@seefocus
    ///@seefocusCursorBlock
    ///@seefocusCursorBlockBlinking
    ///@seefocusCursorBar
    ///@seefocusCursorBarBlinking
    ///@seefocusCursorUnderline
    ///@seefocusCursorUnderlineBlinking
    ///@ingroupdom
    ElementfocusCursorUnderline(Elementchild){
    returnstd::make_shared<FocusCursor>(unpack(std::move(child)),
    Screen::Cursor::Underline);
    }

    ///@briefSameas`focus`,butsetthecursorshapetobeablinkingunderline.
    ///@seefocus
    ///@seefocusCursorBlock
    ///@seefocusCursorBlockBlinking
    ///@seefocusCursorBar
    ///@seefocusCursorBarBlinking
    ///@seefocusCursorUnderline
    ///@seefocusCursorUnderlineBlinking
    ///@ingroupdom
    ElementfocusCursorUnderlineBlinking(Elementchild){
    returnstd::make_shared<FocusCursor>(unpack(std::move(child)),
    Screen::Cursor::UnderlineBlinking);
    }

    }//namespaceftxui