From e8cb16e17a2e57adc378a6682f42c405b00406da Mon Sep 17 00:00:00 2001 From: "Gonzalo A. Diethelm" Date: Thu, 21 Oct 1999 17:23:21 +0000 Subject: [PATCH] ChangeLogTag:Thu Oct 21 14:09:07 1999 Gonzalo A. Diethelm --- harbour/ChangeLog | 8 + harbour/source/rtl/gt/gtlin.c | 301 ++++++++++++++++++++++++++++++++++ 2 files changed, 309 insertions(+) create mode 100644 harbour/source/rtl/gt/gtlin.c diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 1170018728..ff61f0edb2 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,11 @@ +Thu Oct 21 14:09:07 1999 Gonzalo A. Diethelm + + * source/rtl/gt/gtlin.c: + A first, very basic, implementation of GT for Linux using + curses. At this point, all I have tested is that tests/hello.prg + works acceptably well when compiled with -DHARBOUR_USE_LIN_GTAPI. + There are LOTS of functionality missing still. + Thu Oct 21 14:02:53 1999 Gonzalo A. Diethelm * config/linux/gcc.cf: diff --git a/harbour/source/rtl/gt/gtlin.c b/harbour/source/rtl/gt/gtlin.c new file mode 100644 index 0000000000..8abd0b6c13 --- /dev/null +++ b/harbour/source/rtl/gt/gtlin.c @@ -0,0 +1,301 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Video subsystem for Linux (based on ncurses). + * + * Copyright 1999 Gonzalo Diethelm + * + * www - http://www.harbour-project.org + * + * 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 2 of the License, or + * (at your option) any later version, with one exception: + * + * The exception is that if you link the Harbour Runtime Library (HRL) + * and/or the Harbour Virtual Machine (HVM) with other files to produce + * an executable, this does not by itself cause the resulting executable + * to be covered by the GNU General Public License. Your use of that + * executable is in no way restricted on account of linking the HRL + * and/or HVM code into it. + * + * 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit + * their web site at http://www.gnu.org/). + * + */ + +#include + +#include "gtapi.h" + +static void gt_GetMaxRC(int* r, int* c); +static void gt_GetRC(int* r, int* c); +static void gt_SetRC(int r, int c); + + +void hb_gt_Init( void ) +{ + HB_TRACE(("hb_gt_Init()")); + + initscr(); + cbreak(); + noecho(); + nodelay(stdscr, 1); +} + +void hb_gt_Done( void ) +{ + HB_TRACE(("hb_gt_Done()")); + + refresh(); + endwin(); +} + +int hb_gt_ReadKey( void ) +{ + int ch; + + HB_TRACE(("hb_gt_ReadKey()")); + + ch = getch(); + if (ch == ERR) { + ch = 0; + } + + return ch; +} + +BOOL hb_gt_IsColor( void ) +{ + HB_TRACE(("hb_gt_IsColor()")); + + /* TODO: How to detect this? */ + return TRUE; +} + +USHORT hb_gt_GetScreenWidth( void ) +{ + int r, c; + + HB_TRACE(("hb_gt_GetScreenWidth()")); + + gt_GetMaxRC(&r, &c); + return c; +} + +USHORT hb_gt_GetScreenHeight( void ) +{ + int r, c; + + HB_TRACE(("hb_gt_GetScreenHeight()")); + + gt_GetMaxRC(&r, &c); + return r; +} + +void hb_gt_SetPos( USHORT uiRow, USHORT uiCol ) +{ + HB_TRACE(("hb_gt_SetPos(%hu, %hu)", uiRow, uiCol)); + + gt_SetRC(uiRow, uiCol); +} + +USHORT hb_gt_Col( void ) +{ + int r, c; + + HB_TRACE(("hb_gt_Col()")); + + gt_GetRC(&r, &c); + return c; +} + +USHORT hb_gt_Row( void ) +{ + int r, c; + + HB_TRACE(("hb_gt_Row()")); + + gt_GetRC(&r, &c); + return r; +} + +USHORT hb_gt_GetCursorStyle( void ) +{ + HB_TRACE(("hb_gt_GetCursorStyle()")); + + /* TODO: What shape is the cursor? */ + return 0; +} + +void hb_gt_SetCursorStyle( USHORT uiStyle ) +{ + HB_TRACE(("hb_gt_SetCursorStyle(%hu)", uiStyle)); + + /* TODO: How to set the cursor shape? */ +} + +void hb_gt_Puts( USHORT uiRow, + USHORT uiCol, + BYTE byAttr, + BYTE * pbyStr, + ULONG ulLen ) +{ + ULONG i; + + HB_TRACE(("hb_gt_Puts(%hu, %hu, %d, %p, %lu)", uiRow, uiCol, (int) byAttr, pbyStr, ulLen)); + + move(uiRow, uiCol); + for (i = 0; i < ulLen; ++i) { + addch(pbyStr[i]); + } +} + +void hb_gt_GetText( USHORT uiTop, + USHORT uiLeft, + USHORT uiBottom, + USHORT uiRight, + BYTE * pbyDst ) +{ + HB_TRACE(("hb_gt_GetText(%hu, %hu, %hu, %hu, %p)", uiTop, uiLeft, uiBottom, uiRight, pbyDst)); + + /* TODO */ +} + +void hb_gt_PutText( USHORT uiTop, + USHORT uiLeft, + USHORT uiBottom, + USHORT uiRight, + BYTE * pbySrc ) +{ + HB_TRACE(("hb_gt_PutText(%hu, %hu, %hu, %hu, %p)", uiTop, uiLeft, uiBottom, uiRight, pbySrc)); + + /* TODO */ +} + +void hb_gt_SetAttribute( USHORT uiTop, + USHORT uiLeft, + USHORT uiBottom, + USHORT uiRight, + BYTE byAttr ) +{ + HB_TRACE(("hb_gt_SetAttribute(%hu, %hu, %hu, %hu, %d)", uiTop, uiLeft, uiBottom, uiRight, (int) byAttr)); + + /* TODO: we want to take a screen that is say bright white on blue, + and change the attributes only for a section of the screen + to white on black. + */ +} + +void hb_gt_DrawShadow( USHORT uiTop, + USHORT uiLeft, + USHORT uiBottom, + USHORT uiRight, + BYTE byAttr ) +{ + HB_TRACE(("hb_gt_DrawShadow(%hu, %hu, %hu, %hu, %d)", uiTop, uiLeft, uiBottom, uiRight, (int) byAttr)); + + /* TODO: similar to above - see gtwin.c for an idea */ +} + +void hb_gt_Scroll( USHORT uiTop, + USHORT uiLeft, + USHORT uiBottom, + USHORT uiRight, + BYTE byAttr, + SHORT iRows, + SHORT iCols ) +{ + HB_TRACE(("hb_gt_Scroll(%hu, %hu, %hu, %hu, %d, %hd, %hd)", uiTop, uiLeft, uiBottom, uiRight, (int) byAttr, iRows, iCols)); + + /* TODO */ +} + +void hb_gt_DispBegin( void ) +{ + HB_TRACE(("hb_gt_DispBegin()")); + + /* TODO: Is there a way to change screen buffers? + ie: can we write somewhere without it going to the screen + and then update the screen from this buffer at a later time? + We will initially want to copy the current screen to this buffer. + */ +} + +void hb_gt_DispEnd() +{ + HB_TRACE(("hb_gt_DispEnd()")); + + /* TODO: here we flush the buffer, and restore normal screen writes */ +} + +BOOL hb_gt_SetMode( USHORT uiRows, USHORT uiCols ) +{ + HB_TRACE(("hb_gt_SetMode(%hu, %hu)", uiRows, uiCols)); + + /* TODO: How to change the size of the screen? */ + return TRUE; +} + +void hb_gt_Replicate( BYTE byChar, ULONG ulLen ) +{ + HB_TRACE(("hb_gt_Replicate(%d, %lu)", (int) byChar, ulLen)); + + /* TODO: this will write character c nlength times to the screen. + Note that it is not used yet + If there is no native function that supports this, it is + already handled in a generic way by higher level functions. + */ + +} + +BOOL hb_gt_GetBlink() +{ + HB_TRACE(("hb_gt_GetBlink()")); + + /* TODO: under dos, the background 'intensity' bit can be switched + from intensity to 'blinking' + does this work under your platform? + */ + return FALSE; +} + +void hb_gt_SetBlink( BOOL bBlink ) +{ + HB_TRACE(("hb_gt_SetBlink(%d)", (int) bBlink)); + + /* TODO: set the bit if it's supported */ +} + + +static void gt_GetMaxRC(int* r, int* c) +{ + int y, x; + getmaxyx(stdscr, y, x); + *r = y; + *c = x; +} + +static void gt_GetRC(int* r, int* c) +{ + int y, x; + getyx(stdscr, y, x); + *r = y; + *c = x; +} + +static void gt_SetRC(int r, int c) +{ + move(r, c); + refresh(); +}