Logo Search packages:      
Sourcecode: tcd version File versions  Download package

ui.h

/**
 * This module defines helper routines for ncurses.
 */

#ifndef TCD_UI_H
#define TCD_UI_H

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#if defined(HAVE_NCURSES_H)
# include <ncurses.h>
#elif defined(HAVE_CURSES_H)
# include <curses.h>
#endif

#define C_BLACK         COLOR_PAIR(0)
#define C_RED           COLOR_PAIR(1)
#define C_GREEN         COLOR_PAIR(2)
#define C_YELLOW  COLOR_PAIR(3)
#define C_BLUE          COLOR_PAIR(4)
#define C_MAGENTA COLOR_PAIR(5)
#define C_CYAN          COLOR_PAIR(6)
#define C_WHITE         COLOR_PAIR(7)

/**
 * Coordinates of a box on the screen.
 */
00030 struct coords {
    int top, left, bottom, right, height, width;
};

/**
 * Calculate all fields of a box from the arguments.
 */
extern void set_coords(struct coords *co, int top, int left, int bottom, int right);

/**
 * Draw a horizontal line with tee endpoints.
 */
extern void mvwhsplit(WINDOW *win, int y, int x, int len);
#define mvhsplit(m_y, m_x, m_len) \
        mvwhsplit(stdscr, m_y, m_x, m_len)

/**
 * Draw a vertical line with tee endpoints.
 */
extern void mvwvsplit(WINDOW *win, int y, int x, int len);
#define mvvsplit(m_y, m_x, m_len) \
        mvwvsplit(stdscr, m_y, m_x, m_len)

/**
 * Draw a (possibly long) string in a window. If the string is too long
 * to fit, the last three characters are replaced with "...".
 */
extern void mvwaddlstr(WINDOW *win, int y, int x, const char *s, int maxlen);
#define mvaddlstr(m_y, m_x, m_s, m_maxlen) \
        mvwaddlstr(stdscr, m_y, m_x, m_s, m_maxlen)

/**
 * Draws a box using the given coordinates.
 */
extern void mvwbox(WINDOW *win, const struct coords *coord, const char *title);
#define mvbox(m_coord, m_title) \
        mvwbox(stdscr, m_coord, m_title)

/**
 * Show a nice input box for the user.
 * Returns 0 on success, -1 on error.
 */
extern int ui_inputbox(char *buf, size_t bufsize, const char *title);

/**
 * Reads a key from the user. If /delay/ is positive, the timeout
 * is set to /delay/ deciseconds. If it is negative, input is blocking.
 */
extern int ui_readkey(int delay);

/**
 * Initializes the user interface. This procedure must be called
 * once at startup.
 */
extern void ui_init(void);

/**
 * Cleanly shuts down the user interface.
 */
extern void ui_shutdown(void);

#endif

Generated by  Doxygen 1.6.0   Back to index