Skip to content

Missing captures in xw::output #278

@AntoinePrv

Description

@AntoinePrv

A number of c++ printing function outputs are not capture by xw::output. In fact it seems that only std::cout+std::flush (<< std::endl is equivalent to << '\n' << std::flush) is captured.

The issue may come from xeus or xeus-cpp itself.
For std::cout I believe we must force a std::flush (otherwise that is most surprising to the user).

Here is a reproducer.

Cell 1

#include <iostream>
#include <print>

#include <xcpp/xdisplay.hpp>
#include <xwidgets/xall.hpp>

Cell 2

auto out = xw::output();
xcpp::display(out);

Cell 3

{
    auto g = out.guard();
    xcpp::clear_output();

    std::cout << "Cout flushed\n" << std::flush;
    std::cout << "Cout not flushed\n";
    std::print("Print\n");
    std::println("Println");
    std::puts("Puts");
    std::printf("Printf\n");    
}

Observed output
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions