]> git.tuebingen.mpg.de Git - paraslash.git/commit - gui.c
gui: Get rid of do_select()'s mode parameter and call it only once.
authorAndre Noll <maan@systemlinux.org>
Sat, 29 Mar 2014 12:48:03 +0000 (13:48 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 4 May 2014 13:48:54 +0000 (15:48 +0200)
commit5f511d41a111aa04189b32fd77d02e16f90ff2cc
tree0df3b9218db5a92033d85ea0b975c28f88b2596f
parente5d3cf2538f6fcb6a6f5271736c5e5b3dea4e7b1
gui: Get rid of do_select()'s mode parameter and call it only once.

The current code calls do_select() from three different locations. The
mode parameter indicates whether a command is currently running
and if it is a display command or an external command (where curses
is disabled).  This is unnecessarily complex as we can tell from the
values of the command_fd[] array and the cmd_pid variable which mode
we are in.

This commit introduces get_select_mode() which looks at these variables
and returns the current mode. This allows to get rid of the mode
parameter of do_select() and to call do_select() only once at startup
from main(). It now runs in an endless loop, checking the current mode
in each iteration. The other two call sites, exec_and_display_cmd()
and external_cmd(), don't need to call do_select() any more.

This change removes more lines than it adds and makes the logic
of para_gui much simpler to follow. It is also the last big step
to replace the do_select() loop in favor of the standard paraslash
scheduler.
gui.c