Skip to content

Commit

Permalink
wreadln: convert to awaitable
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Sep 10, 2024
1 parent 199b1cb commit 30452c3
Show file tree
Hide file tree
Showing 15 changed files with 562 additions and 594 deletions.
1 change: 0 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,6 @@ ncmpc = executable('ncmpc',
'src/CustomColors.cxx',
'src/Styles.cxx',
'src/charset.cxx',
'src/wreadln.cxx',
'src/Completion.cxx',
'src/strfsong.cxx',
'src/time_format.cxx',
Expand Down
7 changes: 4 additions & 3 deletions src/ChatPage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#include "ChatPage.hxx"
#include "PageMeta.hxx"
#include "screen.hxx"
#include "screen_utils.hxx"
#include "screen_status.hxx"
#include "mpdclient.hxx"
#include "i18n.h"
#include "charset.hxx"
#include "Command.hxx"
#include "Options.hxx"
#include "page/TextPage.hxx"
#include "dialogs/TextInputDialog.hxx"
#include "util/StringAPI.hxx"

#include <mpd/idle.h>
Expand Down Expand Up @@ -150,8 +150,9 @@ ChatPage::SendMessage(struct mpdclient &c, const char *msg) noexcept
inline Co::InvokeTask
ChatPage::EnterMessage(struct mpdclient &c)
{
auto message = screen_readln(screen, _("Your message"),
nullptr, nullptr, nullptr);
const auto message = co_await TextInputDialog{
screen, _("Your message"),
};

/* the user entered an empty line */
if (message.empty())
Expand Down
6 changes: 4 additions & 2 deletions src/OutputsPage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#include "screen.hxx"
#include "screen_status.hxx"
#include "Command.hxx"
#include "screen_utils.hxx"
#include "i18n.h"
#include "mpdclient.hxx"
#include "page/ListPage.hxx"
#include "dialogs/TextInputDialog.hxx"
#include "ui/ListRenderer.hxx"
#include "ui/paint.hxx"
#include "util/FNVHash.hxx"
Expand Down Expand Up @@ -167,7 +167,9 @@ OutputsPage::CreateNewPartition(struct mpdclient &c) noexcept
if (!c.IsConnected())
co_return;

auto name = screen_readln(screen, _("Name"), nullptr, nullptr, nullptr);
const auto name = co_await TextInputDialog{
screen, _("Name"),
};
if (name.empty())
co_return;

Expand Down
12 changes: 8 additions & 4 deletions src/QueuePage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "screen_utils.hxx"
#include "db_completion.hxx"
#include "page/ListPage.hxx"
#include "dialogs/TextInputDialog.hxx"
#include "ui/ListRenderer.hxx"
#include "ui/ListText.hxx"
#include "event/CoarseTimerEvent.hxx"
Expand Down Expand Up @@ -300,10 +301,13 @@ handle_add_to_playlist(ScreenManager &screen, struct mpdclient &c)
#endif

/* get path */
auto path = screen_readln(screen, _("Add"),
nullptr,
nullptr,
completion);
const auto path = co_await TextInputDialog{
screen,
_("Add"),
{},
nullptr,
completion,
};

/* add the path to the playlist */
if (!path.empty()) {
Expand Down
11 changes: 6 additions & 5 deletions src/SearchPage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#include "GlobalBindings.hxx"
#include "charset.hxx"
#include "mpdclient.hxx"
#include "screen_utils.hxx"
#include "FileListPage.hxx"
#include "filelist.hxx"
#include "dialogs/TextInputDialog.hxx"
#include "ui/TextListRenderer.hxx"
#include "lib/fmt/ToSpan.hxx"
#include "util/StringAPI.hxx"
Expand Down Expand Up @@ -414,10 +414,11 @@ SearchPage::Start(struct mpdclient &c)

Clear(true);

pattern = screen_readln(screen, _("Search"),
nullptr,
&search_history,
nullptr);
pattern = co_await TextInputDialog{
screen, _("Search"),
{},
&search_history,
};

if (pattern.empty()) {
lw.Reset();
Expand Down
Loading

0 comments on commit 30452c3

Please sign in to comment.