Skip to content

Commit

Permalink
btdu.ui.curses: Fail gracefully when failing to initialize ncurses
Browse files Browse the repository at this point in the history
Previously, we would just show no output at all, as if running headless.
  • Loading branch information
CyberShadow committed Dec 14, 2024
1 parent 4ceccf7 commit 91a3a75
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions source/btdu/ui/curses.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Vladimir Panteleev <btdu@cy.md>
* Copyright (C) 2023, 2024 Vladimir Panteleev <btdu@cy.md>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
Expand Down Expand Up @@ -77,7 +77,12 @@ struct Curses

inputFile.fdopen(inputFD, "rb");
outputFile.fdopen(outputFD, "wb");
newterm(getenv("TERM"), outputFile.getFP(), inputFile.getFP());
auto screen = newterm(getenv("TERM"), outputFile.getFP(), inputFile.getFP());
enforce(screen,
"Could not create the ncurses screen object. " ~
"Are terminfo files installed for your terminal? " ~
"Perhaps try running with \"TERM=xterm\"."
);

stdinSocket = new Socket(cast(socket_t)inputFD, AddressFamily.UNSPEC);
stdinSocket.blocking = false;
Expand Down

0 comments on commit 91a3a75

Please sign in to comment.