Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resize ScreenInteractive::TerminalOutput() on SIGWINCH issue #951

Open
dangooddd opened this issue Nov 10, 2024 · 5 comments · May be fixed by #952
Open

Resize ScreenInteractive::TerminalOutput() on SIGWINCH issue #951

dangooddd opened this issue Nov 10, 2024 · 5 comments · May be fixed by #952

Comments

@dangooddd
Copy link

Hi!
I got problem with terminal resizing and ScreenInteractive::TerminalOutput component. This issue appears not only in tmux, but also in plain terminal (tested on Kitty, Alacritty, Foot and Konsole). Redrawing works well when fullscreen.

How can I solve this? Compiled with clang 19, version of ftxui is 5.0.0

I am new to the TUI thing and this community, so sorry if this issue well known, I can't find anything about this.

redrawing_issue.webm
@dangooddd
Copy link
Author

dangooddd commented Nov 10, 2024

Code is almost identical to menu example from repo

#include "embf/directory.hpp"
#include "ftxui/component/component.hpp"
#include "ftxui/component/component_options.hpp"
#include "ftxui/component/screen_interactive.hpp"
#include "ftxui/dom/elements.hpp"
#include "ftxui/screen/screen.hpp"
#include <ftxui/dom/elements.hpp>
#include <iostream>

int main(int argc, char *argv[]) {
    using namespace ftxui;
    auto screen = ScreenInteractive::TerminalOutput();

    std::vector<std::string> entries = {
        "entry 1",
        "entry 2",
        "entry 3",
    };
    int selected = 0;

    MenuOption option;
    option.on_enter = screen.ExitLoopClosure();
    auto menu = Menu(&entries, &selected, option) | borderLight;

    screen.Loop(menu);

    std::cout << "Selected element = " << selected << std::endl;

    return 0;
}

@ArthurSonzogni
Copy link
Owner

Hello,
Line wrapping are implemented by the terminal emulator. I don't think I know any solution against this.

If you used ScreenInteractive::Fullscreen we would draw over the whole area, on an alternate screen, which would avoid seeing all the garbage.

If you know about any other solution, I would happily implement it.

@dangooddd
Copy link
Author

dangooddd commented Nov 11, 2024

I see that fzf does this, but only when resize left/right. I guess that after sigwinch it redraws window at top of terminal, so it becomes fullscreen-like. See video below.

I think that is not a bad solution, because anyway output of terminal becomes crap, so why not to clear it? What do you think about this?

fzf_resizing.webm

@ArthurSonzogni
Copy link
Owner

ArthurSonzogni commented Nov 12, 2024

clearing the terminal during a screen width change looks like a good idea! Do you want to try submitting a PR?

@dangooddd
Copy link
Author

I think I can try, will open draft PR soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants