Original author: Pierre Sarrazin. Source: http://sarrazip.com/dev/ebitor-0.1.1.tar.gz Archive SHA-256: 6911a9d2ee80925622f1d82db1b77710a1f896865e63d29a04dc16489b150e83
147 lines
4.6 KiB
C
147 lines
4.6 KiB
C
/* gimeterm.h - CoCo 3 GIME hardware text mode terminal functions.
|
|
|
|
Copyright (C) 2021-2025 Pierre Sarrazin <http://sarrazip.com/>
|
|
|
|
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/>.
|
|
*/
|
|
|
|
/*
|
|
These functions implement a terminal compliant with the specs in Ebitor.h.
|
|
|
|
Each screen cell is a character byte followed by an attribute byte,
|
|
i.e., 2 bytes per screen character.
|
|
*/
|
|
|
|
#ifndef _H_gimeterm
|
|
#define _H_gimeterm
|
|
|
|
#include "Window.h"
|
|
|
|
|
|
typedef struct gimeterm_Window
|
|
{
|
|
ebitor_Window window;
|
|
|
|
// Default text attribute used by functions that put characters on the screen.
|
|
// See gimeterm_setTextAttribute().
|
|
//
|
|
byte textAttribute;
|
|
|
|
// Attribute to use to show characters with inverted colors.
|
|
// See gimeterm_setInvertedTextAttribute().
|
|
//
|
|
byte invertedTextAttribute;
|
|
|
|
} gimeterm_Window;
|
|
|
|
|
|
// Defines a window in a GIME hardware text screen.
|
|
// Does NOT clear the window.
|
|
// Does NOT change the video mode.
|
|
//
|
|
// screenBuffer: Address of the screen.
|
|
// screenMode: 40, 64 or 80.
|
|
// window: Initial window in the given screen.
|
|
// inkeyFuncPtr: Must return 0 (and not block) if no key pressed.
|
|
// inkeyFuncCookie: Will be passed to inkeyFuncPtr.
|
|
// timerPtr: Address of an unsigned 16-bit integer that gets incremented 60 times per second.
|
|
//
|
|
void gimeterm_init(void *screenBuffer, byte screenMode,
|
|
const gimeterm_Window *window,
|
|
byte (*inkeyFuncPtr)(void *cookie), void *inkeyFuncCookie,
|
|
word *timerPtr);
|
|
|
|
// Changes the current window.
|
|
//
|
|
void gimeterm_setWindow(const gimeterm_Window *state);
|
|
|
|
// Copies the state of the current window into the designated object.
|
|
//
|
|
void gimeterm_getWindow(gimeterm_Window *dest);
|
|
|
|
// Fills the window defined by gimeterm_init() with spaces and the 'textAttribute'
|
|
// passed to gimeterm_init().
|
|
// Does not move the cursor.
|
|
//
|
|
void gimeterm_clear(void);
|
|
|
|
// column, row: Coordinates relative to the window defined by gimeterm_init().
|
|
// Does not check if the parameters are valid.
|
|
// This may be useful to write outside the window, as long as no carriage return is written.
|
|
//
|
|
void gimeterm_locate(byte column, byte row);
|
|
|
|
// column, row: Receive coordinates relative to the window defined by gimeterm_init().
|
|
//
|
|
void gimeterm_getCursorPos(byte *column, byte *row);
|
|
|
|
// CAUTION: This function does NOT scroll when it reaches the end of the window.
|
|
// Character 13 does a carriage return and line feed AND clears
|
|
// the rest of the row it is applied to (with spaces and gimeterm_textAttribute).
|
|
// No other control code is supported.
|
|
//
|
|
// Returns FALSE if the cursor has fallen off the bottom of the window.
|
|
// The caller should scroll the window up and reposition the cursor.
|
|
//
|
|
BOOL gimeterm_putchar(int c);
|
|
|
|
// Returns FALSE the string could not be printed entirely because the printing reached end of window.
|
|
//
|
|
BOOL gimeterm_print(const char *str);
|
|
|
|
// Returns FALSE the string could not be printed entirely because the printing reached end of window.
|
|
//
|
|
BOOL gimeterm_printPrefix(const char *str, size_t prefixLength);
|
|
|
|
// Returns FALSE if the cursor has fallen off the bottom of the window.
|
|
// The caller should scroll the window up and reposition the cursor.
|
|
//
|
|
BOOL gimeterm_newline(void);
|
|
|
|
// Use inverted colors for the next print operations.
|
|
//
|
|
void gimeterm_invertColors(void);
|
|
|
|
void gimeterm_clrtoeol(void);
|
|
void gimeterm_scrollWindowUp(byte numRows);
|
|
void gimeterm_scrollWindowDown(byte numRows);
|
|
|
|
// Fills the line where the cursor is with spaces and puts the cursor at the start of this line.
|
|
//
|
|
void gimeterm_eraseCurrentLine(void);
|
|
|
|
// Animates a cursor while waiting.
|
|
// Returns an ASCII code or an ebitor_KEY_* code.
|
|
//
|
|
word gimeterm_waitEditorKey(void);
|
|
|
|
|
|
// The following functions are not part of the Ebitor terminal function set.
|
|
|
|
|
|
byte gimeterm_waitKey(void);
|
|
|
|
|
|
// Returns the attribute used up to now.
|
|
//
|
|
byte gimeterm_setTextAttribute(byte newAttribute);
|
|
|
|
|
|
// Returns the inverted text attribute used up to now.
|
|
//
|
|
byte gimeterm_setInvertedTextAttribute(byte newAttribute);
|
|
|
|
|
|
#endif /* _H_gimeterm */
|