Files
Ebitor/os9term.h
T
Brian Holman 53bf6abdd5 Import Ebitor 0.1.1 upstream source snapshot
Original author: Pierre Sarrazin.
Source: http://sarrazip.com/dev/ebitor-0.1.1.tar.gz
Archive SHA-256: 6911a9d2ee80925622f1d82db1b77710a1f896865e63d29a04dc16489b150e83
2026-11-09 23:45:41 -07:00

112 lines
3.7 KiB
C

/* os9term.h - OS-9 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.
*/
#ifndef _H_os9term
#define _H_os9term
#include "Window.h"
// Returns the address of the 32x16 screen buffer is standard out
// is current in that mode. Otherwise, returns NULL.
//
byte *os9term_get32x16ScreenBuffer(void);
// Returns an OS-9 error code upon failure, or 0 upon success
// (*screenTypeCode is then 1, 2 or 5..8).
// Suitable to be called when the terminal uses a GIME mode.
// Returns error code 208 when run in a 32x16 terminal.
//
byte os9term_getGIMEScreenType(byte *screenTypeCode);
// Defines a window in an OS-9 terminal.
//
// Assumes that there is an extra row below the designated window.
// For example, on a 40x25 screen, the window would be (40, 24, 0, 0),
// and the 25th row would be the status line.
//
// Does NOT clear the window (see os9term_clear()).
//
// width, height: Dimensions in characters of the window.
// winLeftCol, winTopRow: Zero-based coordinates of the top left of the window.
// waitKeyFuncPtr: Pointer to a function that waits until a key is pressed and
// returns its ASCII code, e.g., 65 for 'A', 12 for the up arrow.
// waitKeyFuncCookie: Value to be passed to (*waitKeyFuncPtr)().
//
// Returns 0 upon success, or an error code upon failure:
// 1: Terminal type not supported (e.g., the current terminal is 32x16).
// 2: Failed to determine is the screen is a GIME text screen.
// 3: The screen is in a GIME mode but not in a 40- or 80-column mode.
//
byte os9term_init(byte width, byte height,
byte winLeftCol, byte winTopRow,
byte (*waitKeyFuncPtr)(void *), void *waitKeyFuncCookie);
// Must be called before leaving the process.
//
void os9term_shutdown(void);
// Fills the window defined by os9term_init() with spaces.
// Does not move the cursor.
//
void os9term_clear(void);
// column, row: Coordinates relative to the window defined by os9term_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 os9term_locate(byte column, byte row);
// column, row: Receive coordinates relative to the window defined by os9term_init().
//
void os9term_getCursorPos(byte *column, byte *row);
// Returns FALSE the string could not be printed entirely because the printing reached end of window.
//
BOOL os9term_print(const char *str);
// Returns FALSE the string could not be printed entirely because the printing reached end of window.
//
BOOL os9term_printPrefix(const char *str, size_t prefixLength);
// Use inverted colors for the next print operations.
//
void os9term_invertColors(void);
void os9term_clrtoeol(void);
void os9term_scrollWindowUp(byte numRows);
void os9term_scrollWindowDown(byte numRows);
// Fills the line where the cursor is with spaces and puts the cursor at the start of this line.
//
void os9term_eraseCurrentLine(void);
// Returns an ASCII code or an ebitor_KEY_* code.
//
word os9term_waitEditorKey(void);
#endif /* _H_os9term */