paraslash Paraslash Audio Streaming
About   News   Download   Documentation   Development

Macros | Enumerations | Functions | Variables
gui.c File Reference

Curses-based interface for paraslash. More...

#include <regex.h>
#include <signal.h>
#include <sys/types.h>
#include <curses.h>
#include <locale.h>
#include <sys/time.h>
#include <lopsub.h>
#include "gui.lsg.h"
#include "para.h"
#include "gui.h"
#include "lsu.h"
#include "string.h"
#include "ringbuffer.h"
#include "fd.h"
#include "error.h"
#include "list.h"
#include "sched.h"
#include "version.h"

Macros

#define CMD_PTR   (lls_cmd(0, gui_suite))
 
#define OPT_RESULT(_name)   (lls_opt_result(LSG_GUI_PARA_GUI_OPT_ ## _name, lpr))
 
#define OPT_GIVEN(_name)   (lls_opt_given(OPT_RESULT(_name)))
 
#define OPT_STRING_VAL(_name)   (lls_string_val(0, OPT_RESULT(_name)))
 
#define OPT_UINT32_VAL(_name)   (lls_uint32_val(0, OPT_RESULT(_name)))
 
#define FOR_EACH_KEY_MAP(_i)   for (_i = 0; _i < OPT_GIVEN(KEY_MAP); _i++)
 
#define RINGBUFFER_SIZE   512
 How many lines of output to remember. More...
 
#define GUI_COMMANDS
 
#define GUI_COMMAND(_c, _k, _d)    static void com_ ## _c(void);
 
#define GUI_COMMAND(_c, _k, _d)
 
#define COMMAND_BUF_SIZE   32768
 Stdout/stderr of the executing process is read in chunks of this size. More...
 
#define NUM_LINES(len)   (1 + (len) / get_num_cols(&bot))
 Number of lines of the window are occupied by an output line. More...
 

Enumerations

enum  exec_status { EXEC_IDLE, EXEC_DCMD, EXEC_XCMD }
 Type of the process currently being executed. More...
 
enum  gui_color_pair {
  COLOR_STATUSBAR = NUM_STAT_ITEMS + 1, COLOR_COMMAND, COLOR_OUTPUT, COLOR_MSG,
  COLOR_ERRMSG, COLOR_SEPARATOR, COLOR_TOP, COLOR_BOT
}
 Codes for various colors. More...
 

Functions

int main (int argc, char *argv[])
 The main function of para_gui. More...
 

Variables

 DEFINE_PARA_ERRLIST
 Array of error strings. More...
 
__printf_2_3 void(* para_log )(int, const char *,...) = curses_log
 The log function of para_gui, always set to curses_log(). More...
 

Detailed Description

Curses-based interface for paraslash.

Macro Definition Documentation

◆ CMD_PTR

#define CMD_PTR   (lls_cmd(0, gui_suite))

◆ OPT_RESULT

#define OPT_RESULT (   _name)    (lls_opt_result(LSG_GUI_PARA_GUI_OPT_ ## _name, lpr))

◆ OPT_GIVEN

#define OPT_GIVEN (   _name)    (lls_opt_given(OPT_RESULT(_name)))

◆ OPT_STRING_VAL

#define OPT_STRING_VAL (   _name)    (lls_string_val(0, OPT_RESULT(_name)))

◆ OPT_UINT32_VAL

#define OPT_UINT32_VAL (   _name)    (lls_uint32_val(0, OPT_RESULT(_name)))

◆ FOR_EACH_KEY_MAP

#define FOR_EACH_KEY_MAP (   _i)    for (_i = 0; _i < OPT_GIVEN(KEY_MAP); _i++)

◆ RINGBUFFER_SIZE

#define RINGBUFFER_SIZE   512

How many lines of output to remember.

◆ GUI_COMMANDS

#define GUI_COMMANDS
Value:
GUI_COMMAND(help, "?", "print help") \
GUI_COMMAND(enlarge_top_win, "+", "enlarge the top window") \
GUI_COMMAND(shrink_top_win, "-", "shrink the top window") \
GUI_COMMAND(reread_conf, "r", "reread configuration file") \
GUI_COMMAND(quit, "q", "exit para_gui") \
GUI_COMMAND(refresh, "^L", "redraw the screen") \
GUI_COMMAND(next_theme, ".", "switch to next theme") \
GUI_COMMAND(prev_theme, ",", "switch to previous theme") \
GUI_COMMAND(ll_incr, ">", "increase loglevel (decreases verbosity)") \
GUI_COMMAND(ll_decr, "<", "decrease loglevel (increases verbosity)") \
GUI_COMMAND(version, "V", "show the para_gui version") \
GUI_COMMAND(scroll_up, "<up>", "scroll up one line") \
GUI_COMMAND(scroll_down, "<down>", "scroll_down") \
GUI_COMMAND(page_up, "<ppage>", "scroll up one page") \
GUI_COMMAND(page_down, "<npage>", "scroll down one page") \
GUI_COMMAND(scroll_top, "<home>", "scroll to top of buffer") \
GUI_COMMAND(cancel_scroll, "<end>", "deactivate scroll mode") \

◆ GUI_COMMAND [1/2]

#define GUI_COMMAND (   _c,
  _k,
  _d 
)     static void com_ ## _c(void);

◆ GUI_COMMAND [2/2]

#define GUI_COMMAND (   _c,
  _k,
  _d 
)
Value:
{ \
.key = _k, \
.name = #_c, \
.description = _d, \
.handler = com_ ## _c \
},

◆ COMMAND_BUF_SIZE

#define COMMAND_BUF_SIZE   32768

Stdout/stderr of the executing process is read in chunks of this size.

◆ NUM_LINES

#define NUM_LINES (   len)    (1 + (len) / get_num_cols(&bot))

Number of lines of the window are occupied by an output line.

Enumeration Type Documentation

◆ exec_status

enum static enum exec_status exec_status ( void  )

Type of the process currently being executed.

Enumerator
EXEC_IDLE 

No process running.

EXEC_DCMD 

para or display process running.

EXEC_XCMD 

External process running.

◆ gui_color_pair

Codes for various colors.

Each status item has its own color pair. The ones defined here start at a higher number so that they do not overlap with these.

Enumerator
COLOR_STATUSBAR 
COLOR_COMMAND 
COLOR_OUTPUT 
COLOR_MSG 
COLOR_ERRMSG 
COLOR_SEPARATOR 
COLOR_TOP 
COLOR_BOT 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

The main function of para_gui.

Parameters
argcUsual argument count.
argvUsual argument vector.

After initialization para_gui registers the following tasks to the paraslash scheduler: status, exec, signal, input.

The status task executes the para_audioc stat command to obtain the status of para_server and para_audiod, and displays this information in the top window of para_gui.

The exec task is responsible for printing the output of the currently running executable to the bottom window.

The signal task performs various actions according to signals received. For example, it reloads the configuration file on SIGUSR1, and it shuts down the curses system on SIGTERM to restore the terminal settings before exit.

The input task reads single key strokes from stdin. For each key pressed, it executes the command handler associated with this key.

Returns
EXIT_SUCCESS or EXIT_FAILURE.

References CMD_PTR, and lls().

Variable Documentation

◆ DEFINE_PARA_ERRLIST

DEFINE_PARA_ERRLIST

Array of error strings.

◆ para_log

__printf_2_3 void(* para_log) (int, const char *,...) = curses_log

The log function of para_gui, always set to curses_log().

GUI_COMMAND
#define GUI_COMMAND(_c, _k, _d)
Definition: gui.c:120