2011-07-02 00:53:45 -04:00
|
|
|
/************************************************************************
|
|
|
|
* *
|
|
|
|
* Star Traders: A Game of Interstellar Trading *
|
|
|
|
* Copyright (C) 1990-2011, John Zaitseff *
|
|
|
|
* *
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
Author: John Zaitseff <J.Zaitseff@zap.org.au>
|
|
|
|
$Id$
|
|
|
|
|
|
|
|
This file, intf.h, contains function declarations for basic text input/
|
|
|
|
output routines for Star Traders.
|
|
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see http://www.gnu.org/licenses/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef included_INTF_H
|
|
|
|
#define included_INTF_H 1
|
|
|
|
|
|
|
|
|
2011-07-02 07:25:57 -04:00
|
|
|
#include "system.h"
|
|
|
|
|
|
|
|
|
2011-07-02 00:53:45 -04:00
|
|
|
/************************************************************************
|
|
|
|
* Constants and type declarations *
|
|
|
|
************************************************************************/
|
|
|
|
|
2011-07-04 05:15:38 -04:00
|
|
|
// Visibility of the cursor in Curses
|
|
|
|
typedef enum curs_type {
|
|
|
|
CURS_INVISIBLE = 0,
|
|
|
|
CURS_NORMAL = 1,
|
|
|
|
CURS_VISIBLE = 2
|
|
|
|
} curs_type_t;
|
|
|
|
|
2011-07-04 08:02:01 -04:00
|
|
|
#define CURS_OFF (CURS_INVISIBLE)
|
|
|
|
#define CURS_ON (CURS_VISIBLE)
|
|
|
|
|
|
|
|
|
|
|
|
// Keycodes
|
|
|
|
#define KEY_TAB (011)
|
|
|
|
#define KEY_RETURN (012)
|
|
|
|
#define KEY_ESC (033)
|
|
|
|
|
2011-07-02 00:53:45 -04:00
|
|
|
|
2011-07-02 09:19:40 -04:00
|
|
|
/*
|
|
|
|
This version of Star Traders only utilises WIN_COLS x WIN_LINES of a
|
|
|
|
terminal window. COL_OFFSET and LINE_OFFSET define offsets that should
|
|
|
|
be added to each newwin() call to position the window correctly.
|
|
|
|
*/
|
|
|
|
|
2011-07-04 05:15:38 -04:00
|
|
|
#define MIN_LINES (24) /* Minimum number of lines in terminal */
|
|
|
|
#define MIN_COLS (80) /* Minimum number of columns in terminal */
|
|
|
|
|
2011-07-02 09:19:40 -04:00
|
|
|
#define WIN_LINES MIN_LINES /* Number of lines in main windows */
|
2011-07-04 03:54:30 -04:00
|
|
|
#define WIN_COLS MIN_COLS /* Number of columns in main windows */
|
2011-07-02 09:19:40 -04:00
|
|
|
|
2011-07-04 03:54:30 -04:00
|
|
|
#define LINE_OFFSET (0) /* Window offsets */
|
|
|
|
#define COL_OFFSET ((COLS - WIN_COLS) / 2)
|
|
|
|
#define COL_CENTER(x) ((COLS - (x)) / 2)
|
2011-07-02 09:19:40 -04:00
|
|
|
|
2011-07-02 07:25:57 -04:00
|
|
|
|
2011-07-04 04:22:24 -04:00
|
|
|
// Colour and non-colour attribute selection
|
|
|
|
#define ATTR(color, nocolor) (has_colors() ? (color) : (nocolor))
|
|
|
|
|
|
|
|
|
2011-07-02 07:25:57 -04:00
|
|
|
// Colour pairs used in Star Traders
|
|
|
|
enum color_pairs {
|
|
|
|
DEFAULT_COLORS = 0,
|
|
|
|
WHITE_ON_BLACK,
|
|
|
|
WHITE_ON_BLUE,
|
|
|
|
WHITE_ON_RED,
|
2011-07-04 08:02:01 -04:00
|
|
|
YELLOW_ON_BLACK,
|
|
|
|
YELLOW_ON_BLUE,
|
2011-07-02 07:25:57 -04:00
|
|
|
YELLOW_ON_CYAN,
|
|
|
|
BLACK_ON_WHITE,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-07-03 22:41:30 -04:00
|
|
|
/************************************************************************
|
|
|
|
* Global variable declarations *
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
extern WINDOW *curwin; // Top-most (current) window
|
|
|
|
|
|
|
|
|
2011-07-02 07:25:57 -04:00
|
|
|
/************************************************************************
|
|
|
|
* Basic text input/output function declarations *
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
extern void init_screen (void);
|
|
|
|
extern void end_screen (void);
|
|
|
|
|
2011-07-03 22:41:30 -04:00
|
|
|
// Simplified panel-like window functions
|
2011-07-04 05:41:55 -04:00
|
|
|
|
2011-07-03 22:41:30 -04:00
|
|
|
extern WINDOW *newtxwin (int nlines, int ncols, int begin_y, int begin_x);
|
|
|
|
extern int deltxwin (void);
|
|
|
|
extern int delalltxwin (void);
|
|
|
|
extern int txrefresh (void);
|
|
|
|
|
2011-07-04 05:41:55 -04:00
|
|
|
// Output routines
|
|
|
|
|
2011-07-04 03:54:30 -04:00
|
|
|
extern int center (WINDOW *win, int y, const bool clrline,
|
|
|
|
const char *format, ...)
|
|
|
|
__attribute__((format (printf, 4, 5)));
|
2011-07-02 07:25:57 -04:00
|
|
|
|
2011-07-04 05:41:55 -04:00
|
|
|
extern int attrpr (WINDOW *win, int attr_start, int attr_end,
|
|
|
|
const char *format, ...)
|
|
|
|
__attribute__((format (printf, 4, 5)));
|
|
|
|
|
2011-07-04 08:02:01 -04:00
|
|
|
// Input routines
|
|
|
|
|
|
|
|
extern int gettxchar (WINDOW *win);
|
|
|
|
extern bool getanswer (WINDOW *win);
|
|
|
|
|
2011-07-02 00:53:45 -04:00
|
|
|
|
|
|
|
#endif /* included_INTF_H */
|