Exit if stdin is closed
This commit is contained in:
1
NEWS
1
NEWS
@@ -11,6 +11,7 @@ ncmpcpp-0.8 (????-??-??)
|
|||||||
* libcurl dependency is no longer optional.
|
* libcurl dependency is no longer optional.
|
||||||
* When an attempt to write tags fails, show detailed error message.
|
* When an attempt to write tags fails, show detailed error message.
|
||||||
* Support for fetching lyrics for selected items in background was added.
|
* Support for fetching lyrics for selected items in background was added.
|
||||||
|
* Application will now exit if stdin is closed.
|
||||||
|
|
||||||
ncmpcpp-0.7.7 (2016-10-31)
|
ncmpcpp-0.7.7 (2016-10-31)
|
||||||
* Fixed compilation on 32bit platforms.
|
* Fixed compilation on 32bit platforms.
|
||||||
|
|||||||
@@ -474,6 +474,7 @@ bool BindingsConfiguration::read(const std::string &file)
|
|||||||
void BindingsConfiguration::generateDefaults()
|
void BindingsConfiguration::generateDefaults()
|
||||||
{
|
{
|
||||||
NC::Key::Type k = NC::Key::None;
|
NC::Key::Type k = NC::Key::None;
|
||||||
|
bind(NC::Key::EoF, Actions::Type::Quit);
|
||||||
if (notBound(k = stringToKey("mouse")))
|
if (notBound(k = stringToKey("mouse")))
|
||||||
bind(k, Actions::Type::MouseEvent);
|
bind(k, Actions::Type::MouseEvent);
|
||||||
if (notBound(k = stringToKey("up")))
|
if (notBound(k = stringToKey("up")))
|
||||||
@@ -743,9 +744,6 @@ void BindingsConfiguration::generateDefaults()
|
|||||||
bind(k, Actions::Type::SetSelectedItemsPriority);
|
bind(k, Actions::Type::SetSelectedItemsPriority);
|
||||||
if (notBound(k = stringToKey("q")))
|
if (notBound(k = stringToKey("q")))
|
||||||
bind(k, Actions::Type::Quit);
|
bind(k, Actions::Type::Quit);
|
||||||
|
|
||||||
if (notBound(k = stringToKey("-")))
|
|
||||||
bind(k, Actions::Type::VolumeDown);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Command *BindingsConfiguration::findCommand(const std::string &name)
|
const Command *BindingsConfiguration::findCommand(const std::string &name)
|
||||||
|
|||||||
@@ -1062,29 +1062,37 @@ Key::Type Window::readKey()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd_set fdset;
|
fd_set fds_read;
|
||||||
FD_ZERO(&fdset);
|
FD_ZERO(&fds_read);
|
||||||
FD_SET(STDIN_FILENO, &fdset);
|
FD_SET(STDIN_FILENO, &fds_read);
|
||||||
timeval timeout = { m_window_timeout/1000, (m_window_timeout%1000)*1000 };
|
timeval timeout = { m_window_timeout/1000, (m_window_timeout%1000)*1000 };
|
||||||
|
|
||||||
int fd_max = STDIN_FILENO;
|
int fd_max = STDIN_FILENO;
|
||||||
for (FDCallbacks::const_iterator it = m_fds.begin(); it != m_fds.end(); ++it)
|
for (const auto &fd : m_fds)
|
||||||
{
|
{
|
||||||
if (it->first > fd_max)
|
if (fd.first > fd_max)
|
||||||
fd_max = it->first;
|
fd_max = fd.first;
|
||||||
FD_SET(it->first, &fdset);
|
FD_SET(fd.first, &fds_read);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (select(fd_max+1, &fdset, 0, 0, m_window_timeout < 0 ? 0 : &timeout) > 0)
|
auto tv_addr = m_window_timeout < 0 ? nullptr : &timeout;
|
||||||
|
int res = select(fd_max+1, &fds_read, nullptr, nullptr, tv_addr);
|
||||||
|
if (res > 0)
|
||||||
{
|
{
|
||||||
if (FD_ISSET(STDIN_FILENO, &fdset))
|
if (FD_ISSET(STDIN_FILENO, &fds_read))
|
||||||
result = getInputChar(wgetch(m_window));
|
{
|
||||||
|
int key = wgetch(m_window);
|
||||||
|
if (key == EOF)
|
||||||
|
result = Key::EoF;
|
||||||
|
else
|
||||||
|
result = getInputChar(key);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
result = Key::None;
|
result = Key::None;
|
||||||
|
|
||||||
for (FDCallbacks::const_iterator it = m_fds.begin(); it != m_fds.end(); ++it)
|
for (const auto &fd : m_fds)
|
||||||
if (FD_ISSET(it->first, &fdset))
|
if (FD_ISSET(fd.first, &fds_read))
|
||||||
it->second();
|
fd.second();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
result = Key::None;
|
result = Key::None;
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ const Type F10 = Special | 275;
|
|||||||
const Type F11 = Special | 276;
|
const Type F11 = Special | 276;
|
||||||
const Type F12 = Special | 277;
|
const Type F12 = Special | 277;
|
||||||
const Type Mouse = Special | 278;
|
const Type Mouse = Special | 278;
|
||||||
|
const Type EoF = Special | 279;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user