ChangeLog 2000-06-12 16:55 UTC+0100
This commit is contained in:
@@ -1,3 +1,20 @@
|
||||
2000-06-12 16:55 UTC+0100 Ryszard Glab <rglab@imid.med.pl>
|
||||
|
||||
*source/rtl/run.c
|
||||
*source/rtl/gtsln/Makefile
|
||||
*source/rtl/gtsln/gtsln.c
|
||||
*source/rtl/gtsln/kbsln.c
|
||||
*source/rtl/gtsln/keytrans.c
|
||||
*added more slang support - thanks to Marek Paliwoda
|
||||
|
||||
*source/rtl/gtcrs/gtcrs.c
|
||||
*source/rtl/gtdos/gtdos.c
|
||||
*source/rtl/gtos2/gtos2.c
|
||||
*source/rtl/gtpca/gtpca.c
|
||||
*source/rtl/gtstd/gtstd.c
|
||||
*source/rtl/gtwin/gtwin.c
|
||||
*added dummy hb_gt_Suspend()/hb_gt_Resume()
|
||||
|
||||
2000-06-12 16:00 UTC+0100 Ryszard Glab <rglab@imid.med.pl>
|
||||
|
||||
*source/compiler/harbour.y
|
||||
|
||||
@@ -744,3 +744,13 @@ USHORT hb_gt_VertLine( USHORT uiCol, USHORT uiTop, USHORT uiBottom, BYTE byChar,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL hb_gt_Suspend()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL hb_gt_Resume()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1394,3 +1394,13 @@ BOOL hb_gt_SetMode( USHORT uiRows, USHORT uiCols )
|
||||
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
BOOL hb_gt_Suspend()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL hb_gt_Resume()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -947,3 +947,13 @@ USHORT hb_gt_VertLine( USHORT uiCol, USHORT uiTop, USHORT uiBottom, BYTE byChar,
|
||||
hb_gt_xPutch( uRow++, uiCol, byAttr, byChar );
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL hb_gt_Suspend()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL hb_gt_Resume()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -563,3 +563,13 @@ USHORT hb_gt_VertLine( USHORT uiCol, USHORT uiTop, USHORT uiBottom, BYTE byChar,
|
||||
hb_gt_xPutch( uRow++, uiCol, byAttr, byChar );
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL hb_gt_Suspend()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL hb_gt_Resume()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ ROOT = ../../../
|
||||
|
||||
C_SOURCES=\
|
||||
gtsln.c \
|
||||
kbsln.c \
|
||||
mousesln.c \
|
||||
|
||||
LIBNAME=gtsln
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Video subsystem based on ncurses.
|
||||
* Video subsystem based on Slang screen library.
|
||||
*
|
||||
* Copyright 1999 Gonzalo Diethelm <gonzalo.diethelm@iname.com>
|
||||
* Copyright 2000 Marek Paliwoda <paliwoda@inetia.pl>
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -35,47 +31,181 @@
|
||||
|
||||
/* NOTE: User programs should never call this layer directly! */
|
||||
|
||||
#include <slang.h>
|
||||
#ifdef __linux__
|
||||
#include <slang/slang.h>
|
||||
#else
|
||||
#include <slang.h>
|
||||
#endif
|
||||
/* missing defines in previous versions of Slang - this was not TESTED !! */
|
||||
#if SLANG_VERSION < 10401
|
||||
typedef unsigned short SLsmg_Char_Type;
|
||||
#define SLSMG_EXTRACT_CHAR(x) ((x) & 0xFF)
|
||||
#define SLSMG_EXTRACT_COLOR(x) (((x)>>8)&0xFF)
|
||||
#define SLSMG_BUILD_CHAR(ch,color) (((SLsmg_Char_Type)(unsigned char)(ch))|((color)<<8))
|
||||
#define SLSMG_BOARD_CHAR 'h'
|
||||
#define SLSMG_BLOCK_CHAR '0'
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include "hbapigt.h"
|
||||
#include "inkey.ch"
|
||||
|
||||
static USHORT s_uiDispCount;
|
||||
#ifdef IBMPC_SYSTEM
|
||||
int SLtt_Has_Alt_Charset = 1;
|
||||
char *SLtt_Graphics_Char_Pairs = "";
|
||||
#endif
|
||||
|
||||
extern int hb_gt_Init_Terminal(int phase);
|
||||
static void hb_gt_build_conv_tabs();
|
||||
|
||||
static USHORT uiDispCount;
|
||||
/* on Unix systems always assume cursor is visible on startup - look later */
|
||||
static int cursorVisible = 1;
|
||||
static int linuxConsole = 0;
|
||||
static int underXTerm = 0;
|
||||
/* indicate if we are currently running a command from system */
|
||||
static int uiSuspended = 0;
|
||||
|
||||
/* to convert high characters (mostly graphics and control chars) */
|
||||
static unsigned char convHighChars[ 256 ];
|
||||
/* to convert colors to Clipper mode */
|
||||
static char *colorNames[] =
|
||||
{
|
||||
"black" ,
|
||||
"blue" ,
|
||||
"green" ,
|
||||
"cyan" ,
|
||||
"red" ,
|
||||
"magenta" ,
|
||||
"brown" ,
|
||||
"lightgray" ,
|
||||
"gray" ,
|
||||
"brightblue" ,
|
||||
"brightgreen" ,
|
||||
"brightcyan" ,
|
||||
"brightred" ,
|
||||
"brightmagenta",
|
||||
"yellow" ,
|
||||
"white"
|
||||
};
|
||||
|
||||
volatile int Screen_Size_Changed = 0;
|
||||
#ifndef IBMPC_SYSTEM
|
||||
/* window resize handler */
|
||||
static void sigwinch_handler (int sig)
|
||||
{
|
||||
Screen_Size_Changed = 1;
|
||||
SLsignal (SIGWINCH, sigwinch_handler);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* I think this function should not be void. It should be BOOL */
|
||||
void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr )
|
||||
{
|
||||
int gt_Inited = 0;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Init()"));
|
||||
|
||||
s_uiDispCount = 0;
|
||||
uiDispCount = 0;
|
||||
|
||||
SLtt_get_terminfo();
|
||||
SLkp_init();
|
||||
SLang_init_tty(34, /* Ctrl-G */
|
||||
0, /* no flow-control */
|
||||
0); /* no output processing */
|
||||
SLang_set_abort_signal(NULL);
|
||||
SLsmg_init_smg ();
|
||||
/* read a terminal descripion from a terminfo database */
|
||||
SLtt_get_terminfo ();
|
||||
/* initialize higher-level Slang routines */
|
||||
if ( SLkp_init() != (-1) )
|
||||
{
|
||||
/* initialize a terminal stuff and a Slang
|
||||
keyboard subsystem for the first time
|
||||
*/
|
||||
if ( hb_gt_Init_Terminal( 0 ) )
|
||||
{
|
||||
/* initialize a screen handling subsytem */
|
||||
if ( SLsmg_init_smg () != (-1) )
|
||||
{
|
||||
#ifndef IBMPC_SYSTEM
|
||||
/* install window resize handler */
|
||||
SLsignal (SIGWINCH, sigwinch_handler);
|
||||
#endif
|
||||
|
||||
/* do not indicate USER_BREAK in SLang_Error - ??? */
|
||||
SLang_Ignore_User_Abort = 1;
|
||||
|
||||
/* default abort procesing */
|
||||
SLang_set_abort_signal(NULL);
|
||||
|
||||
/* NOTE: this is incompatible with CLIPPER
|
||||
but under Unix we should assume cursor is
|
||||
visible on startup because we cannot figure
|
||||
out a current cursor state
|
||||
*/
|
||||
/* turn on a cursor visibility */
|
||||
if ( SLtt_set_cursor_visibility(1) != (-1) )
|
||||
{
|
||||
hb_gt_SetCursorStyle( 1 );
|
||||
cursorVisible = 1;
|
||||
}
|
||||
else
|
||||
cursorVisible = -1;
|
||||
|
||||
/* an uncertain way to check if we run under linux console */
|
||||
linuxConsole = ( !strncmp ( getenv("TERM"), "linux", 5 ) );
|
||||
/* an uncertain way to check if we run under xterm */
|
||||
underXTerm = ( strstr( getenv("TERM"), "xterm" ) != NULL );
|
||||
|
||||
/* NOTE: this driver is implemented in a way that it is
|
||||
imposible to get intensity/blinking background mode
|
||||
under Slang, due to a way Slang is written. This is
|
||||
incompatible with Clipper.
|
||||
*/
|
||||
#ifndef IBMPC_SYSTEM
|
||||
SLtt_Blink_Mode = 0;
|
||||
SLtt_Use_Blink_For_ACS = 0;
|
||||
#endif
|
||||
|
||||
/* initialize conversion tables */
|
||||
hb_gt_build_conv_tabs();
|
||||
|
||||
/* NOTE: due to a work of a Slang library which do not
|
||||
prepare its internal screen buffer properly, a screen
|
||||
must be cleared before normal work. This is not
|
||||
compatible with Clipper
|
||||
*/
|
||||
#ifndef IBMPC_SYSTEM
|
||||
/* ensure we are in a normal chars set */
|
||||
SLtt_set_alt_char_set( 0 );
|
||||
#endif
|
||||
SLtt_cls();
|
||||
SLsmg_set_color( 7 );
|
||||
gt_Inited = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !gt_Inited )
|
||||
{
|
||||
/* something went wrong - restore default settings */
|
||||
SLang_reset_tty();
|
||||
/* NOTE: an error should be generated here ! */
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void hb_gt_Exit( void )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Exit()"));
|
||||
|
||||
/*
|
||||
NOTE: This is incompatible with Clipper
|
||||
- on exit leave a cursor visible
|
||||
|
||||
if ( cursorVisible != (-1) )
|
||||
hb_gt_SetCursorStyle( 1 );
|
||||
*/
|
||||
SLsmg_refresh();
|
||||
SLsmg_reset_smg ();
|
||||
SLang_reset_tty();
|
||||
}
|
||||
|
||||
int hb_gt_ReadKey( HB_inkey_enum eventmask )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_ReadKey(%d)", (int) eventmask));
|
||||
|
||||
HB_SYMBOL_UNUSED( eventmask );
|
||||
|
||||
/* TODO: */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL hb_gt_AdjustPos( BYTE * pStr, ULONG ulLen )
|
||||
{
|
||||
USHORT row = SLsmg_get_row();
|
||||
@@ -103,6 +233,7 @@ BOOL hb_gt_AdjustPos( BYTE * pStr, ULONG ulLen )
|
||||
break;
|
||||
|
||||
case HB_CHAR_LF:
|
||||
col = 0;
|
||||
if( row < SLtt_Screen_Rows - 1 )
|
||||
row++;
|
||||
break;
|
||||
@@ -130,8 +261,7 @@ BOOL hb_gt_IsColor( void )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_IsColor()"));
|
||||
|
||||
/* TODO: How to detect this? */
|
||||
return TRUE;
|
||||
return SLtt_Use_Ansi_Colors;
|
||||
}
|
||||
|
||||
USHORT hb_gt_GetScreenWidth( void )
|
||||
@@ -176,31 +306,33 @@ USHORT hb_gt_GetCursorStyle( void )
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetCursorStyle()"));
|
||||
|
||||
/* example from the dos driver */
|
||||
/*
|
||||
hb_gt_GetCursorSize( &start, &end )
|
||||
if( cursorVisible == 0 )
|
||||
uiStyle = SC_NONE;
|
||||
|
||||
if( start == 32 && end == 32 )
|
||||
uiStyle = SC_NONE;
|
||||
else if( cursorVisible == 1 )
|
||||
uiStyle = SC_NORMAL;
|
||||
|
||||
else if( start == 6 && end == 7 )
|
||||
uiStyle = SC_NORMAL;
|
||||
else if( cursorVisible == 2 )
|
||||
uiStyle = SC_INSERT;
|
||||
|
||||
else if( start == 4 && end == 7 )
|
||||
uiStyle = SC_INSERT;
|
||||
else if( cursorVisible == 3 )
|
||||
uiStyle = SC_SPECIAL1;
|
||||
|
||||
else if( start == 0 && end == 7 )
|
||||
uiStyle = SC_SPECIAL1;
|
||||
else if( cursorVisible == 4 )
|
||||
uiStyle = SC_SPECIAL2;
|
||||
|
||||
else
|
||||
/* if we don't know a cursor state - assume visible */
|
||||
uiStyle = SC_NORMAL;
|
||||
|
||||
else if( start == 0 && end == 3 )
|
||||
uiStyle = SC_SPECIAL2;
|
||||
}
|
||||
*/
|
||||
return uiStyle;
|
||||
}
|
||||
|
||||
void hb_gt_SetCursorStyle( USHORT uiStyle )
|
||||
{
|
||||
/* keyseq to define cursor shape under linux console */
|
||||
char cursDefseq[] = { 27, '[', '?', '1', 'c', 0 };
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetCursorStyle(%hu)", uiStyle));
|
||||
|
||||
/* TODO: How to set the shape of the cursor? */
|
||||
@@ -208,16 +340,55 @@ void hb_gt_SetCursorStyle( USHORT uiStyle )
|
||||
switch( uiStyle )
|
||||
{
|
||||
case SC_NONE:
|
||||
/* TODO: turn it off */
|
||||
if ( cursorVisible != (-1) )
|
||||
{
|
||||
SLtt_set_cursor_visibility(0);
|
||||
cursorVisible = 0;
|
||||
if ( linuxConsole )
|
||||
{
|
||||
cursDefseq[3] = '1';
|
||||
SLtt_write_string( cursDefseq );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SC_NORMAL:
|
||||
if ( cursorVisible != (-1) )
|
||||
{
|
||||
SLtt_set_cursor_visibility(1);
|
||||
cursorVisible = 1;
|
||||
if ( linuxConsole )
|
||||
{
|
||||
cursDefseq[3] = '2';
|
||||
SLtt_write_string( cursDefseq );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SC_INSERT:
|
||||
if ( cursorVisible != (-1) )
|
||||
{
|
||||
SLtt_set_cursor_visibility(1);
|
||||
cursorVisible = 2;
|
||||
if ( linuxConsole )
|
||||
{
|
||||
cursDefseq[3] = '4';
|
||||
SLtt_write_string( cursDefseq );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SC_SPECIAL1:
|
||||
if ( cursorVisible != (-1) )
|
||||
{
|
||||
SLtt_set_cursor_visibility(1);
|
||||
cursorVisible = 3;
|
||||
if ( linuxConsole )
|
||||
{
|
||||
cursDefseq[3] = '8';
|
||||
SLtt_write_string( cursDefseq );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SC_SPECIAL2:
|
||||
@@ -230,102 +401,193 @@ void hb_gt_SetCursorStyle( USHORT uiStyle )
|
||||
|
||||
static void hb_gt_xPutch( USHORT uiRow, USHORT uiCol, BYTE byAttr, BYTE byChar )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_xPutch(%hu, %hu, %d, %i)", uiRow, uiCol, (int) byAttr, byChar));
|
||||
{
|
||||
BYTE tmp[ 2 ];
|
||||
SLsmg_Char_Type SLchar;
|
||||
|
||||
/* TOFIX: add correct support for a single byte instead of a string
|
||||
*/
|
||||
tmp[ 0 ] = byChar;
|
||||
tmp[ 1 ] = 0;
|
||||
SLsmg_gotorc(uiRow, uiCol);
|
||||
SLsmg_write_nchars(tmp, 1);
|
||||
}
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_xPutch(%hu, %hu, %d, %i)", uiRow, uiCol, (int) byAttr, byChar));
|
||||
|
||||
/* build Slang converted char - note we are clearing a high bit of color */
|
||||
SLchar = SLSMG_BUILD_CHAR( convHighChars[ byChar ], byAttr & 0x7F );
|
||||
|
||||
/* alternate char set */
|
||||
if ( byChar > 127 )
|
||||
SLchar |= 0x8000;
|
||||
|
||||
SLsmg_gotorc(uiRow, uiCol);
|
||||
SLsmg_write_raw( &SLchar, 1 );
|
||||
}
|
||||
|
||||
void hb_gt_Puts( USHORT uiRow, USHORT uiCol, BYTE byAttr, BYTE * pbyStr, ULONG ulLen )
|
||||
{
|
||||
ULONG i;
|
||||
BYTE byChar;
|
||||
SLsmg_Char_Type SLchar, *pScr;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Puts(%hu, %hu, %d, %p, %lu)", uiRow, uiCol, (int) byAttr, pbyStr, ulLen));
|
||||
|
||||
pScr = (SLsmg_Char_Type *)hb_xgrab( (ulLen+1) * sizeof( SLsmg_Char_Type ) );
|
||||
|
||||
for ( i=0; i<ulLen; i++ )
|
||||
{
|
||||
/* next char to process */
|
||||
byChar = *pbyStr++;
|
||||
|
||||
/* build Slang converted char - note we are clearing a high bit of color */
|
||||
SLchar = SLSMG_BUILD_CHAR( convHighChars[ byChar ], byAttr & 0x7F );
|
||||
|
||||
/* alternate char set */
|
||||
if ( byChar > 127 )
|
||||
SLchar |= 0x8000;
|
||||
|
||||
*(pScr+i) = SLchar;
|
||||
}
|
||||
|
||||
SLsmg_gotorc(uiRow, uiCol);
|
||||
SLsmg_write_nchars(pbyStr, ulLen);
|
||||
|
||||
if ( ulLen > 0 )
|
||||
SLsmg_write_raw( pScr, ulLen );
|
||||
|
||||
hb_xfree( ( BYTE * )pScr );
|
||||
|
||||
if( uiDispCount == 0 )
|
||||
SLsmg_refresh();
|
||||
}
|
||||
|
||||
int hb_gt_RectSize( USHORT rows, USHORT cols )
|
||||
{
|
||||
return rows * cols * 2;
|
||||
return rows * cols * sizeof( SLsmg_Char_Type );
|
||||
}
|
||||
|
||||
void hb_gt_GetText( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE * pbyDst )
|
||||
{
|
||||
int Cols;
|
||||
SLsmg_Char_Type *pBuf = (SLsmg_Char_Type *)pbyDst;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetText(%hu, %hu, %hu, %hu, %p)", uiTop, uiLeft, uiBottom, uiRight, pbyDst));
|
||||
|
||||
HB_SYMBOL_UNUSED( uiTop );
|
||||
HB_SYMBOL_UNUSED( uiLeft );
|
||||
HB_SYMBOL_UNUSED( uiBottom );
|
||||
HB_SYMBOL_UNUSED( uiRight );
|
||||
HB_SYMBOL_UNUSED( pbyDst );
|
||||
Cols = uiRight - uiLeft + 1;
|
||||
while( uiTop <= uiBottom )
|
||||
{
|
||||
SLsmg_gotorc( uiTop, uiLeft );
|
||||
SLsmg_read_raw( pBuf, Cols );
|
||||
pBuf += Cols;
|
||||
++uiTop;
|
||||
}
|
||||
}
|
||||
|
||||
void hb_gt_PutText( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE * pbySrc )
|
||||
{
|
||||
int Cols;
|
||||
SLsmg_Char_Type *pBuf = (SLsmg_Char_Type *)pbySrc;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_PutText(%hu, %hu, %hu, %hu, %p)", uiTop, uiLeft, uiBottom, uiRight, pbySrc));
|
||||
|
||||
HB_SYMBOL_UNUSED( uiTop );
|
||||
HB_SYMBOL_UNUSED( uiLeft );
|
||||
HB_SYMBOL_UNUSED( uiBottom );
|
||||
HB_SYMBOL_UNUSED( uiRight );
|
||||
HB_SYMBOL_UNUSED( pbySrc );
|
||||
Cols = uiRight - uiLeft + 1;
|
||||
while( uiTop <= uiBottom )
|
||||
{
|
||||
SLsmg_gotorc( uiTop, uiLeft );
|
||||
SLsmg_write_raw( pBuf, Cols );
|
||||
pBuf +=Cols;
|
||||
++uiTop;
|
||||
}
|
||||
|
||||
if( uiDispCount == 0 )
|
||||
SLsmg_refresh();
|
||||
}
|
||||
|
||||
void hb_gt_SetAttribute( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE byAttr )
|
||||
{
|
||||
int Rows, Cols;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("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.
|
||||
*/
|
||||
Rows = uiBottom - uiTop + 1;
|
||||
Cols = uiRight - uiLeft + 1;
|
||||
|
||||
HB_SYMBOL_UNUSED( uiTop );
|
||||
HB_SYMBOL_UNUSED( uiLeft );
|
||||
HB_SYMBOL_UNUSED( uiBottom );
|
||||
HB_SYMBOL_UNUSED( uiRight );
|
||||
HB_SYMBOL_UNUSED( byAttr );
|
||||
/* note we are clearing a high bit of color */
|
||||
SLsmg_set_color_in_region( byAttr & 0x7F, uiTop, uiLeft, Rows, Cols );
|
||||
|
||||
if( uiDispCount == 0 )
|
||||
SLsmg_refresh();
|
||||
}
|
||||
|
||||
void hb_gt_Scroll( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE byAttr, SHORT iRows, SHORT iCols )
|
||||
void hb_gt_Scroll( USHORT usTop, USHORT usLeft, USHORT usBottom, USHORT usRight, BYTE byAttr, SHORT iRows, SHORT iCols )
|
||||
{
|
||||
/* this work is based on gtdos.c, but changed to get scroll
|
||||
worked well when scrolling horizontally. Clipper behaves
|
||||
strange here.
|
||||
*/
|
||||
SHORT usSaveRow, usSaveCol;
|
||||
USHORT uiSize; /* gtRectSize returns int */
|
||||
|
||||
int iLength = ( usRight - usLeft ) + 1;
|
||||
int iCount, iColOld, iColNew, iColSize;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Scroll(%hu, %hu, %hu, %hu, %d, %hd, %hd)", uiTop, uiLeft, uiBottom, uiRight, (int) byAttr, iRows, iCols));
|
||||
|
||||
HB_SYMBOL_UNUSED( uiTop );
|
||||
HB_SYMBOL_UNUSED( uiLeft );
|
||||
HB_SYMBOL_UNUSED( uiBottom );
|
||||
HB_SYMBOL_UNUSED( uiRight );
|
||||
HB_SYMBOL_UNUSED( iRows );
|
||||
HB_SYMBOL_UNUSED( iCols );
|
||||
hb_gtGetPos( &usSaveRow, &usSaveCol );
|
||||
|
||||
if( hb_gtRectSize( usTop, usLeft, usBottom, usRight, &uiSize ) == 0 )
|
||||
{
|
||||
unsigned char * fpBlank = ( unsigned char * ) hb_xgrab( iLength );
|
||||
unsigned char * fpBuff = ( unsigned char * ) hb_xgrab( iLength * sizeof( SLsmg_Char_Type ) );
|
||||
|
||||
memset( fpBlank, ' ', iLength );
|
||||
|
||||
iColOld = iColNew = usLeft;
|
||||
if( iCols >= 0 )
|
||||
{
|
||||
iColOld += iCols;
|
||||
iColSize = ( int ) ( usRight - usLeft );
|
||||
iColSize -= iCols;
|
||||
}
|
||||
else
|
||||
{
|
||||
iColNew -= iCols;
|
||||
iColSize = ( int ) ( usRight - usLeft );
|
||||
iColSize += iCols;
|
||||
}
|
||||
|
||||
for( iCount = ( iRows >= 0 ? usTop : usBottom );
|
||||
( iRows >= 0 ? iCount <= usBottom : iCount >= usTop );
|
||||
( iRows >= 0 ? iCount++ : iCount-- ) )
|
||||
{
|
||||
int iRowPos = iCount + iRows;
|
||||
|
||||
/* Read the text to be scrolled into the current row */
|
||||
if( ( iRows || iCols ) && iRowPos <= usBottom && iRowPos >= usTop )
|
||||
hb_gt_GetText( iRowPos, iColOld, iRowPos, iColOld + iColSize, fpBuff );
|
||||
|
||||
/* Blank the scroll region in the current row */
|
||||
hb_gt_Puts( iCount, usLeft, byAttr, fpBlank, iLength );
|
||||
|
||||
/* Write the scrolled text to the current row */
|
||||
if( ( iRows || iCols ) && iRowPos <= usBottom && iRowPos >= usTop )
|
||||
hb_gt_PutText( iCount, iColNew, iCount, iColNew + iColSize, fpBuff );
|
||||
}
|
||||
|
||||
hb_xfree( fpBlank );
|
||||
hb_xfree( fpBuff );
|
||||
|
||||
hb_gtSetPos( usSaveRow, usSaveCol );
|
||||
|
||||
if( uiDispCount == 0 )
|
||||
SLsmg_refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void hb_gt_DispBegin( void )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_DispBegin()"));
|
||||
|
||||
++s_uiDispCount;
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
++uiDispCount;
|
||||
}
|
||||
|
||||
void hb_gt_DispEnd()
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_DispEnd()"));
|
||||
|
||||
--s_uiDispCount;
|
||||
|
||||
/* TODO: here we flush the buffer, and restore normal screen writes */
|
||||
if ( --uiDispCount == 0)
|
||||
SLsmg_refresh();
|
||||
}
|
||||
|
||||
BOOL hb_gt_SetMode( USHORT uiRows, USHORT uiCols )
|
||||
@@ -336,18 +598,14 @@ BOOL hb_gt_SetMode( USHORT uiRows, USHORT uiCols )
|
||||
HB_SYMBOL_UNUSED( uiCols );
|
||||
|
||||
/* TODO: How to change the size of the screen? */
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL hb_gt_GetBlink()
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetBlink()"));
|
||||
|
||||
/* TODO: under dos, the background 'intensity' bit can be switched
|
||||
from intensity to 'blinking'
|
||||
does this work under your platform?
|
||||
*/
|
||||
/* TODO: current implementation disables blinking/intensity */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -368,6 +626,7 @@ void hb_gt_Tone( double dFrequency, double dDuration )
|
||||
|
||||
HB_SYMBOL_UNUSED( dFrequency );
|
||||
HB_SYMBOL_UNUSED( dDuration );
|
||||
SLtt_beep();
|
||||
}
|
||||
|
||||
char * hb_gt_Version( void )
|
||||
@@ -377,17 +636,39 @@ char * hb_gt_Version( void )
|
||||
|
||||
USHORT hb_gt_DispCount()
|
||||
{
|
||||
return s_uiDispCount;
|
||||
return uiDispCount;
|
||||
}
|
||||
|
||||
void hb_gt_Replicate( USHORT uiRow, USHORT uiCol, BYTE byAttr, BYTE byChar, ULONG nLength )
|
||||
void hb_gt_Replicate( USHORT uiRow, USHORT uiCol, BYTE byAttr, BYTE byChar, ULONG ulLen )
|
||||
{
|
||||
ULONG i;
|
||||
SLsmg_Char_Type SLchar, *pScr;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Replicate(%hu, %hu, %i, %i, %lu)", uiRow, uiCol, byAttr, byChar, nLength));
|
||||
|
||||
pScr = (SLsmg_Char_Type *)hb_xgrab( (ulLen+1) * sizeof( SLsmg_Char_Type ) );
|
||||
|
||||
for ( i=0; i<ulLen; i++ )
|
||||
{
|
||||
while( nLength-- )
|
||||
hb_gt_xPutch( uiRow, uiCol++, byAttr, byChar );
|
||||
/* build Slang converted char - note we are clearing a high bit of color */
|
||||
SLchar = SLSMG_BUILD_CHAR( convHighChars[ byChar ], byAttr & 0x7F );
|
||||
|
||||
/* alternate char set */
|
||||
if ( byChar > 127 )
|
||||
SLchar |= 0x8000;
|
||||
|
||||
*(pScr+i) = SLchar;
|
||||
}
|
||||
|
||||
SLsmg_gotorc(uiRow, uiCol);
|
||||
|
||||
if ( ulLen > 0 )
|
||||
SLsmg_write_raw( pScr, ulLen );
|
||||
|
||||
hb_xfree( (BYTE *)pScr );
|
||||
|
||||
if( uiDispCount == 0 )
|
||||
SLsmg_refresh();
|
||||
}
|
||||
|
||||
USHORT hb_gt_Box( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight,
|
||||
@@ -503,3 +784,141 @@ USHORT hb_gt_VertLine( USHORT uiCol, USHORT uiTop, USHORT uiBottom, BYTE byChar,
|
||||
hb_gt_xPutch( uRow++, uiCol, byAttr, byChar );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
/* NOTE: these two are for prepare Slang to temporary
|
||||
finish its work. They should be called from run.c.
|
||||
They are not re-enrant ???.
|
||||
*/
|
||||
BOOL hb_gt_Suspend()
|
||||
{
|
||||
if ( !uiSuspended )
|
||||
if ( SLsmg_suspend_smg() != (-1) )
|
||||
{
|
||||
SLang_reset_tty();
|
||||
uiSuspended = 1;
|
||||
}
|
||||
return uiSuspended;
|
||||
}
|
||||
|
||||
BOOL hb_gt_Resume()
|
||||
{
|
||||
if ( uiSuspended )
|
||||
if ( SLsmg_resume_smg() != (-1) )
|
||||
/* reinitialize a terminal */
|
||||
if ( hb_gt_Init_Terminal( 1 ) != (-1) )
|
||||
uiSuspended = 0;
|
||||
|
||||
return uiSuspended;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
static void hb_gt_build_conv_tabs()
|
||||
{
|
||||
int i, fg, bg;
|
||||
#ifndef IBMPC_SYSTEM
|
||||
int len;
|
||||
char *p, ch;
|
||||
#endif
|
||||
|
||||
/* COMPATIBILITY: Slang uses bit 0x8000 as an alternate
|
||||
char mask so it leaves us only 128 possible fgbg colors.
|
||||
(see Notes in Slang sources). This is incompatible with
|
||||
Clipper.
|
||||
*/
|
||||
/* TOFIX: Slang uses color 0 as a current color
|
||||
and color 1 as a reverse one. This can cause
|
||||
some problems.
|
||||
*/
|
||||
/* init colors */
|
||||
for( i=0; i<256; i++ )
|
||||
{
|
||||
fg = ( i & 0x0F );
|
||||
bg = ( i >> 4 ) & 0x07; /* bit 7 is a blinking attribute - not used here */
|
||||
|
||||
SLtt_set_color ( i, (char *)NULL, colorNames[fg], colorNames[bg] );
|
||||
}
|
||||
|
||||
|
||||
/* build alternate chars table */
|
||||
for ( i=0; i<32; i++ )
|
||||
/* under Unix control-chars are not visible in a general meaning */
|
||||
convHighChars[ i ] = '.';
|
||||
for ( i=32; i<256; i++ )
|
||||
convHighChars[ i ] = i;
|
||||
|
||||
|
||||
#ifndef IBMPC_SYSTEM
|
||||
/* init an alternate chars table */
|
||||
if ( ( p = SLtt_Graphics_Char_Pairs ) )
|
||||
{
|
||||
len = strlen( p );
|
||||
for ( i=0; i<len; i++ )
|
||||
{
|
||||
ch = *p++;
|
||||
ch &= 0x7F;
|
||||
|
||||
switch ( ch )
|
||||
{
|
||||
case SLSMG_HLINE_CHAR : convHighChars[ 196 ] = *p; break;
|
||||
case SLSMG_VLINE_CHAR : convHighChars[ 179 ] = *p; break;
|
||||
case SLSMG_ULCORN_CHAR : convHighChars[ 218 ] = *p; break;
|
||||
case SLSMG_URCORN_CHAR : convHighChars[ 191 ] = *p; break;
|
||||
case SLSMG_LLCORN_CHAR : convHighChars[ 192 ] = *p; break;
|
||||
case SLSMG_LRCORN_CHAR : convHighChars[ 217 ] = *p; break;
|
||||
case SLSMG_CKBRD_CHAR : convHighChars[ 176 ] = *p; break;
|
||||
case SLSMG_RTEE_CHAR : convHighChars[ 180 ] = *p; break;
|
||||
case SLSMG_LTEE_CHAR : convHighChars[ 195 ] = *p; break;
|
||||
case SLSMG_UTEE_CHAR : convHighChars[ 194 ] = *p; break;
|
||||
case SLSMG_DTEE_CHAR : convHighChars[ 193 ] = *p; break;
|
||||
case SLSMG_PLUS_CHAR : convHighChars[ 197 ] = *p; break;
|
||||
|
||||
/* TODO: need some smart here */
|
||||
/*
|
||||
case SLSMG_DIAMOND_CHAR : convHighChars[ ] = *p; break;
|
||||
case SLSMG_DEGREE_CHAR; : convHighChars[ ] = *p; break;
|
||||
case SLSMG_PLMINUS_CHAR : convHighChars[ ] = *p; break;
|
||||
case SLSMG_BULLET_CHAR : convHighChars[ ] = *p; break;
|
||||
case SLSMG_LARROW_CHAR : convHighChars[ ] = *p; break;
|
||||
case SLSMG_RARROW_CHAR : convHighChars[ ] = *p; break;
|
||||
case SLSMG_DARROW_CHAR : convHighChars[ ] = *p; break;
|
||||
case SLSMG_UARROW_CHAR : convHighChars[ ] = *p; break;
|
||||
*/
|
||||
case SLSMG_BOARD_CHAR : convHighChars[ 178 ] = *p; break;
|
||||
case SLSMG_BLOCK_CHAR : convHighChars[ 219 ] = *p; break;
|
||||
}
|
||||
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
/* QUESTION: do we have dobule, single-double, ... frames under xterm ? */
|
||||
if ( underXTerm )
|
||||
{
|
||||
/* frames of all Clipper type are _B_SINBLE under xterm */
|
||||
convHighChars[ 205 ] = convHighChars[ 196 ];
|
||||
convHighChars[ 186 ] = convHighChars[ 179 ];
|
||||
convHighChars[ 201 ] = convHighChars[ 218 ];
|
||||
convHighChars[ 214 ] = convHighChars[ 218 ];
|
||||
convHighChars[ 213 ] = convHighChars[ 218 ];
|
||||
convHighChars[ 187 ] = convHighChars[ 191 ];
|
||||
convHighChars[ 183 ] = convHighChars[ 191 ];
|
||||
convHighChars[ 184 ] = convHighChars[ 191 ];
|
||||
convHighChars[ 200 ] = convHighChars[ 192 ];
|
||||
convHighChars[ 211 ] = convHighChars[ 192 ];
|
||||
convHighChars[ 212 ] = convHighChars[ 192 ];
|
||||
convHighChars[ 188 ] = convHighChars[ 217 ];
|
||||
convHighChars[ 189 ] = convHighChars[ 217 ];
|
||||
convHighChars[ 190 ] = convHighChars[ 217 ];
|
||||
convHighChars[ 185 ] = convHighChars[ 118 ];
|
||||
convHighChars[ 204 ] = convHighChars[ 195 ];
|
||||
convHighChars[ 203 ] = convHighChars[ 194 ];
|
||||
convHighChars[ 202 ] = convHighChars[ 193 ];
|
||||
convHighChars[ 206 ] = convHighChars[ 197 ];
|
||||
}
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
441
harbour/source/rtl/gtsln/kbsln.c
Normal file
441
harbour/source/rtl/gtsln/kbsln.c
Normal file
@@ -0,0 +1,441 @@
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Video subsystem based on Slang screen library.
|
||||
*
|
||||
* Copyright 2000 Marek Paliwoda <paliwoda@inetia.pl>
|
||||
* 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/).
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: User programs should never call this layer directly! */
|
||||
|
||||
|
||||
#ifdef __linux__
|
||||
# include <slang/slang.h>
|
||||
#else
|
||||
# include <slang.h>
|
||||
#endif
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#ifdef M_UNIX
|
||||
# include <sys/termio.h>
|
||||
# include <sys/vtkd.h>
|
||||
#endif
|
||||
|
||||
#ifndef IBMPC_SYSTEM
|
||||
# include <termios.h> /* we're assuming target has termios - should be better done */
|
||||
#endif
|
||||
|
||||
#include "hbapigt.h"
|
||||
#include "inkey.ch"
|
||||
|
||||
/* ----------------------------------------------- */
|
||||
|
||||
/* abort key is Ctrl+C on Unix (arbitrary chosen), on Dos it works as Alt+C (strange !) */
|
||||
#ifdef OS_UNIX_COMPATIBLE
|
||||
# define CTRL_C 3
|
||||
#else
|
||||
# define CTRL_C 46
|
||||
#endif
|
||||
#define HB_GT_ABORT_KEY CTRL_C
|
||||
|
||||
/* 2/10 of a second waiting for the next char after ESC */
|
||||
#define ESC_TIMEOUT 2
|
||||
|
||||
/* keyboard states - these should be taken
|
||||
from system includes, not be hard coded
|
||||
*/
|
||||
#if defined(__linux__)
|
||||
# define SHIFT_PRESSED 1
|
||||
# define ALTR_PRESSED 2
|
||||
# define CONTROL_PRESSED 4
|
||||
# define ALTL_PRESSED 8
|
||||
# define ALT_PRESSED (ALTL_PRESSED || ALTR_PRESSED)
|
||||
#elif defined(M_UNIX) /* SCO */
|
||||
# define SHIFT_PRESSED 1
|
||||
# define ALTR_PRESSED 8
|
||||
# define CONTROL_PRESSED 2
|
||||
# define ALTL_PRESSED 4
|
||||
# define ALT_PRESSED (ALTL_PRESSED || ALTR_PRESSED)
|
||||
#else /* we don't know how to do this */
|
||||
# define SHIFT_PRESSED 0
|
||||
# define ALTR_PRESSED 0
|
||||
# define CONTROL_PRESSED 0
|
||||
# define ALTL_PRESSED 0
|
||||
# define ALT_PRESSED (ALTL_PRESSED || ALTR_PRESSED)
|
||||
#endif
|
||||
|
||||
/* extra keysyms definitions */
|
||||
#define SL_KEY_MAX 1000
|
||||
#define SL_KEY_ESC SL_KEY_MAX + 1
|
||||
#define SL_KEY_ALT_L( ch ) ( SL_KEY_MAX + ( ( unsigned int )ch ) )
|
||||
|
||||
/* indicates that screen size has changed */
|
||||
extern int Screen_Size_Changed;
|
||||
|
||||
static int linuxConsole = 0;
|
||||
static int underXTerm = 0;
|
||||
|
||||
int hb_gt_Kbd_State();
|
||||
|
||||
/* key translations tables - notice problems with compilation after changes */
|
||||
#include "keytrans.c"
|
||||
|
||||
static void hb_gt_Init_KeyTranslat()
|
||||
{
|
||||
char ch, keyname[ SLANG_MAX_KEYMAP_KEY_SEQ + 1 ];
|
||||
int keynum, i;
|
||||
|
||||
#ifdef IBMPC_SYSTEM
|
||||
keynum = 11;
|
||||
keyname[ 0 ] = '^';
|
||||
keyname[ 1 ] = '@';
|
||||
keyname[ 3 ] = 0;
|
||||
|
||||
/* define Shft/Ctrl/Alt+Fn on DOS - these are hard coded in Slang */
|
||||
for ( ch = 0x54; ch <= 0x71; ch++ )
|
||||
{
|
||||
keyname[ 2 ] = ch;
|
||||
SLkp_define_keysym( keyname, SL_KEY_F(keynum) );
|
||||
keynum++;
|
||||
}
|
||||
|
||||
/* define Alt+Key on DOS - these are hard coded in Slang */
|
||||
i = 0;
|
||||
while ( i < sizeof( transDosScanCodeTab ) )
|
||||
{
|
||||
i++;
|
||||
if ( transDosScanCodeTab[i] < 32 )
|
||||
{
|
||||
keyname[ 2 ] = '^';
|
||||
keyname[ 3 ] = transDosScanCodeTab[i]+'A'-1;
|
||||
keyname[ 4 ] = 0;
|
||||
}
|
||||
/*
|
||||
else if ( transDosScanCodeTab[i] >= 127 )
|
||||
{
|
||||
sprintf( &keyname[ 2 ], "\\x%02X", transDosScanCodeTab[i] );
|
||||
keyname[ 6 ] = 0;
|
||||
}
|
||||
*/
|
||||
else
|
||||
{
|
||||
keyname[ 2 ] = transDosScanCodeTab[i];
|
||||
keyname[ 3 ] = 0;
|
||||
}
|
||||
SLkp_define_keysym( keyname, SL_KEY_ALT_L( transDosScanCodeTab[i-1] ) );
|
||||
i++;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
char *keyseq;
|
||||
|
||||
/* on Unix systems ESC is a special key so let
|
||||
assume ESC is also a doble pressed ESCkey
|
||||
*/
|
||||
SLkp_define_keysym( "^[^[", SL_KEY_ESC );
|
||||
|
||||
/* try to define Shft-Fn and Ctrl-Fn keys.
|
||||
Because we assume terminal has only 10 Fkeys
|
||||
so F11-F30 is generated with Shift & Ctrl.
|
||||
This is not guaranteed to work in all cases
|
||||
*/
|
||||
keynum = 11;
|
||||
keyname[ 0 ] = 'F';
|
||||
keyname[ 2 ] = 0;
|
||||
|
||||
/* Shft & Ctrl FKeys definition takes place in two
|
||||
phases : from '1' to '9' and from 'A' to 'K'
|
||||
*/
|
||||
for ( i=1; i<=2; i++ )
|
||||
for ( ch = ( i==1 ? '1' : 'A' ); ch <= ( i==1 ? '9' : 'K' ); ch++ )
|
||||
{
|
||||
keyname[ 1 ] = ch;
|
||||
keyseq = SLtt_tgetstr( keyname );
|
||||
if ( (keyseq != NULL) && (keyseq[0] != 0) )
|
||||
{
|
||||
if ( (keyseq != NULL) && (keyseq[0] != 0) )
|
||||
SLkp_define_keysym( keyseq, SL_KEY_F(keynum) );
|
||||
}
|
||||
keynum++;
|
||||
}
|
||||
|
||||
/* if we are on linux console pressing Alt generates ^[ before sequence */
|
||||
if ( linuxConsole || underXTerm )
|
||||
{
|
||||
keyname[ 0 ] = 033;
|
||||
keyname[ 2 ] = 0;
|
||||
|
||||
/* Alt+Letter & Alt+digit definition takes place in
|
||||
two phases : from '0' to '9' and from 'A' to 'Z'
|
||||
*/
|
||||
for ( i=1; i<=2; i++ )
|
||||
for ( ch = ( i==1 ? '0' : 'A' ); ch <= ( i==1 ? '9' : 'Z' ); ch++ )
|
||||
{
|
||||
keyname[ 1 ] = ch;
|
||||
/* QUESTION: why Slang reports error for defining Alt+O ???.
|
||||
Have I any error in key definitiions ???
|
||||
*/
|
||||
if ( ch != 'O' )
|
||||
SLkp_define_keysym( keyname, SL_KEY_ALT_L( ch ) );
|
||||
|
||||
keyname[ 1 ] = (ch+' ');
|
||||
SLkp_define_keysym( keyname, SL_KEY_ALT_L( ch+' ' ) );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int hb_gt_Init_Terminal(int phase)
|
||||
{
|
||||
#ifndef IBMPC_SYSTEM
|
||||
struct termios newTTY;
|
||||
#endif
|
||||
int ret = 0;
|
||||
|
||||
/* Ctrl-C to abort, no flow-control, no output processing */
|
||||
if ( SLang_init_tty(HB_GT_ABORT_KEY, 0, 0) != (-1) )
|
||||
{
|
||||
#ifndef IBMPC_SYSTEM
|
||||
/* do missing disable of start/stop processing */
|
||||
if ( tcgetattr( SLang_TT_Read_FD, &newTTY ) == 0 )
|
||||
{
|
||||
newTTY.c_cc[VSTOP] = 255; /* disable ^S start/stop processing */
|
||||
newTTY.c_cc[VSTART] = 255; /* disable ^Q start/stop processing */
|
||||
newTTY.c_cc[VSUSP] = 255; /* disable ^Z suspend processing */
|
||||
|
||||
if ( tcsetattr( SLang_TT_Read_FD, TCSADRAIN, &newTTY ) == 0 )
|
||||
/* everything looks ok so far */
|
||||
#endif
|
||||
ret = 1;
|
||||
#ifndef IBMPC_SYSTEM
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* first time init phase - we don't want this
|
||||
after return from system command ( see run.c )
|
||||
*/
|
||||
if ( ret && (phase == 0) )
|
||||
{
|
||||
/* an uncertain way to check if we run under linux console */
|
||||
linuxConsole = ( !strncmp ( getenv("TERM"), "linux", 5 ) );
|
||||
/* an uncertain way to check if we run under xterm */
|
||||
underXTerm = ( strstr( getenv("TERM"), "xterm" ) != NULL );
|
||||
|
||||
/* define keyboard translations */
|
||||
hb_gt_Init_KeyTranslat();
|
||||
}
|
||||
|
||||
return ( ret );
|
||||
}
|
||||
|
||||
#undef DO_LOCAL_DEBUG
|
||||
|
||||
int hb_gt_ReadKey( HB_inkey_enum eventmask )
|
||||
{
|
||||
unsigned int ch, kbdflags;
|
||||
#ifdef DO_LOCAL_DEBUG
|
||||
USHORT savy, savx;
|
||||
#endif
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_ReadKey(%d)", (int) eventmask));
|
||||
|
||||
HB_SYMBOL_UNUSED( eventmask );
|
||||
|
||||
/* user AbortKey break */
|
||||
if ( SLKeyBoard_Quit == 1 )
|
||||
return HB_BREAK_FLAG;
|
||||
|
||||
/* has screen size changed ? */
|
||||
if (Screen_Size_Changed)
|
||||
{
|
||||
Screen_Size_Changed = 0;
|
||||
SLtt_get_screen_size();
|
||||
#if SLANG_VERSION > 10202
|
||||
SLsmg_reinit_smg();
|
||||
#endif
|
||||
/* TODO: we need here some kind of screen redrawing */
|
||||
//SLsmg_refresh ();
|
||||
}
|
||||
|
||||
if ( SLang_input_pending( 0 ) > 0 )
|
||||
{
|
||||
kbdflags = hb_gt_Kbd_State();
|
||||
|
||||
/* ------- one key ESC key handling ----------------- */
|
||||
|
||||
/* NOTE: This will probably not work on slow terminals
|
||||
or on a very busy lines (i.e. modem lines )
|
||||
*/
|
||||
ch = SLang_getkey ();
|
||||
|
||||
if (ch == 033) /* escape */
|
||||
{
|
||||
if (0 == SLang_input_pending (ESC_TIMEOUT))
|
||||
return 033;
|
||||
}
|
||||
|
||||
SLang_ungetkey (ch);
|
||||
|
||||
/* ------------------------------------------------- */
|
||||
|
||||
ch = SLkp_getkey();
|
||||
|
||||
if ( ch != SL_KEY_ERR )
|
||||
{
|
||||
int i;
|
||||
|
||||
#ifdef DO_LOCAL_DEBUG
|
||||
hb_gtGetPos( &savy, &savx );
|
||||
SLsmg_gotorc( 23, 0 );
|
||||
SLsmg_printf( "%d %d ", ch, kbdflags );
|
||||
SLsmg_gotorc( savy, savx );
|
||||
#endif
|
||||
|
||||
/* user AbortKey break */
|
||||
if ( ch == HB_GT_ABORT_KEY )
|
||||
return ( HB_BREAK_FLAG );
|
||||
|
||||
if ( ch < 32 ) /* control characters - simply return */
|
||||
return ( ch );
|
||||
|
||||
else if ( ( ch >= 32 ) && ( ch < 256 ) )/* normal characters ? */
|
||||
{
|
||||
if ( kbdflags & ALT_PRESSED )
|
||||
{
|
||||
/* lower to upper case */
|
||||
if ( (ch >= 'a') && (ch <= 'z') )
|
||||
ch -= ' ';
|
||||
|
||||
/* alt + letter */
|
||||
if ( (ch >= 'A') && (ch <= 'Z') )
|
||||
/* returned value is next in a table */
|
||||
return ( transAltKeyLetterTab[ (ch-'A')*2+1 ] );
|
||||
|
||||
/* alt + digit */
|
||||
if ( (ch >= '0') && (ch <= '9') )
|
||||
/* returned value is next in a table */
|
||||
return ( transAltKeyDigitTab[ (ch-'0')*2+1 ] );
|
||||
}
|
||||
|
||||
return ( ch );
|
||||
}
|
||||
|
||||
/* standard Slang keys */
|
||||
else if ( ( ch >= 256 ) && ( ch <= SL_KEY_ESC ) )
|
||||
{
|
||||
for( i = 0; i < ( sizeof( transKeyFunTab ) / sizeof( int ) ); i++ )
|
||||
if( transKeyFunTab[ i++ ] == ch )
|
||||
return ( transKeyFunTab[ i ] );
|
||||
}
|
||||
|
||||
/* Linux/Dos Alt+A-Z keys */
|
||||
else if ( ( ch >= SL_KEY_ALT_L( 'A' ) ) && ( ch <= SL_KEY_ALT_L( 'Z' ) ) )
|
||||
/* returned value is next in a table */
|
||||
return ( transAltKeyLetterTab[ (ch-SL_KEY_MAX-'A')*2+1 ] );
|
||||
|
||||
/* Linux Alt+a-z keys - lower to upper conersion */
|
||||
else if ( ( ch >= SL_KEY_ALT_L( 'a' ) ) && ( ch <= SL_KEY_ALT_L( 'z' ) ) )
|
||||
/* returned value is next in a table */
|
||||
return ( transAltKeyLetterTab[ (ch-SL_KEY_MAX-(' ')-('A'))*2+1 ] );
|
||||
|
||||
/* Linux/Dos Alt+0-9 keys */
|
||||
else if ( ( ch >= SL_KEY_ALT_L( '0' ) ) && ( ch <= SL_KEY_ALT_L( '9' ) ) )
|
||||
/* returned value is next in a table */
|
||||
return ( transAltKeyDigitTab[ (ch-SL_KEY_MAX-'0')*2+1 ] );
|
||||
|
||||
return (ch);
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int hb_gt_try_get_Kbd_State()
|
||||
{
|
||||
#if defined(__linux__)
|
||||
|
||||
unsigned char modifiers = 6;
|
||||
|
||||
if (ioctl (0, TIOCLINUX, &modifiers) < 0)
|
||||
return 0;
|
||||
|
||||
return (int) modifiers;
|
||||
|
||||
#elif defined(M_UNIX)
|
||||
|
||||
int modifiers = 0;
|
||||
int IOcommand = 0;
|
||||
|
||||
if (ioctl(0, TCGETSC, &modifiers) >= 0)
|
||||
{
|
||||
if (modifiers == KB_XSCANCODE)
|
||||
{
|
||||
IOcommand = KB_ISSCANCODE;
|
||||
if (ioctl(0, TCSETSC, &IOcommand) >= 0)
|
||||
{
|
||||
if (ioctl(0, KDGKBSTATE, &modifiers) < 0)
|
||||
modifiers = 0;
|
||||
}
|
||||
else modifiers = 0;
|
||||
|
||||
IOcommand = KB_XSCANCODE;
|
||||
if (ioctl(0, TCSETSC, &IOcommand) < 0)
|
||||
modifiers = 0;
|
||||
}
|
||||
else
|
||||
if (ioctl(0, KDGKBSTATE, &modifiers) < 0)
|
||||
modifiers = 0;
|
||||
|
||||
return modifiers;
|
||||
}
|
||||
#endif
|
||||
|
||||
return (int)0;
|
||||
}
|
||||
|
||||
int hb_gt_Shft_Pressed()
|
||||
{
|
||||
return( (hb_gt_try_get_Kbd_State() & SHIFT_PRESSED) != 0 );
|
||||
}
|
||||
|
||||
int hb_gt_Ctrl_Pressed()
|
||||
{
|
||||
return( (hb_gt_try_get_Kbd_State() & CONTROL_PRESSED) != 0 );
|
||||
}
|
||||
|
||||
int hb_gt_Alt_Pressed()
|
||||
{
|
||||
return( (hb_gt_try_get_Kbd_State() & ALT_PRESSED) != 0 );
|
||||
}
|
||||
|
||||
int hb_gt_Kbd_State()
|
||||
{
|
||||
return ( hb_gt_try_get_Kbd_State() );
|
||||
}
|
||||
|
||||
127
harbour/source/rtl/gtsln/keytrans.c
Normal file
127
harbour/source/rtl/gtsln/keytrans.c
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Video subsystem based on Slang screen library.
|
||||
*
|
||||
* Copyright 2000 Marek Paliwoda <paliwoda@inetia.pl>
|
||||
* 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/).
|
||||
*
|
||||
*/
|
||||
|
||||
/* a table of function keys translation */
|
||||
static int transKeyFunTab[] =
|
||||
{
|
||||
SL_KEY_DOWN, K_DOWN,
|
||||
SL_KEY_UP, K_UP,
|
||||
SL_KEY_LEFT, K_LEFT,
|
||||
SL_KEY_RIGHT, K_RIGHT,
|
||||
SL_KEY_HOME, K_HOME,
|
||||
SL_KEY_END, K_END,
|
||||
SL_KEY_BACKSPACE, K_BS,
|
||||
SL_KEY_IC, K_INS,
|
||||
SL_KEY_DELETE, K_DEL,
|
||||
SL_KEY_NPAGE, K_PGDN,
|
||||
SL_KEY_PPAGE, K_PGUP,
|
||||
SL_KEY_ESC, K_ESC,
|
||||
SL_KEY_F(1), K_F1,
|
||||
SL_KEY_F(2), K_F2,
|
||||
SL_KEY_F(3), K_F3,
|
||||
SL_KEY_F(4), K_F4,
|
||||
SL_KEY_F(5), K_F5,
|
||||
SL_KEY_F(6), K_F6,
|
||||
SL_KEY_F(7), K_F7,
|
||||
SL_KEY_F(8), K_F8,
|
||||
SL_KEY_F(9), K_F9,
|
||||
SL_KEY_F(10), K_F10,
|
||||
SL_KEY_F(11), K_SH_F1,
|
||||
SL_KEY_F(12), K_SH_F2,
|
||||
SL_KEY_F(13), K_SH_F3,
|
||||
SL_KEY_F(14), K_SH_F4,
|
||||
SL_KEY_F(15), K_SH_F5,
|
||||
SL_KEY_F(16), K_SH_F6,
|
||||
SL_KEY_F(17), K_SH_F7,
|
||||
SL_KEY_F(18), K_SH_F8,
|
||||
SL_KEY_F(19), K_SH_F9,
|
||||
SL_KEY_F(20), K_SH_F10,
|
||||
SL_KEY_F(21), K_CTRL_F1,
|
||||
SL_KEY_F(22), K_CTRL_F2,
|
||||
SL_KEY_F(23), K_CTRL_F3,
|
||||
SL_KEY_F(24), K_CTRL_F4,
|
||||
SL_KEY_F(25), K_CTRL_F5,
|
||||
SL_KEY_F(26), K_CTRL_F6,
|
||||
SL_KEY_F(27), K_CTRL_F7,
|
||||
SL_KEY_F(28), K_CTRL_F8,
|
||||
SL_KEY_F(29), K_CTRL_F9,
|
||||
SL_KEY_F(30), K_CTRL_F10,
|
||||
SL_KEY_F(31), K_ALT_F1,
|
||||
SL_KEY_F(32), K_ALT_F2,
|
||||
SL_KEY_F(33), K_ALT_F3,
|
||||
SL_KEY_F(34), K_ALT_F4,
|
||||
SL_KEY_F(35), K_ALT_F5,
|
||||
SL_KEY_F(36), K_ALT_F6,
|
||||
SL_KEY_F(37), K_ALT_F7,
|
||||
SL_KEY_F(38), K_ALT_F8,
|
||||
SL_KEY_F(39), K_ALT_F9,
|
||||
SL_KEY_F(40), K_ALT_F10
|
||||
};
|
||||
|
||||
/* a table of alt+letter translation */
|
||||
static int transAltKeyLetterTab[] =
|
||||
{
|
||||
'A' , K_ALT_A , 'B' , K_ALT_B , 'C' , K_ALT_C ,
|
||||
'D' , K_ALT_D , 'E' , K_ALT_E , 'F' , K_ALT_F ,
|
||||
'G' , K_ALT_G , 'H' , K_ALT_H , 'I' , K_ALT_I ,
|
||||
'J' , K_ALT_J , 'K' , K_ALT_K , 'L' , K_ALT_L ,
|
||||
'M' , K_ALT_M , 'N' , K_ALT_N , 'O' , K_ALT_O ,
|
||||
'P' , K_ALT_P , 'Q' , K_ALT_Q , 'R' , K_ALT_R ,
|
||||
'S' , K_ALT_S , 'T' , K_ALT_T , 'U' , K_ALT_U ,
|
||||
'V' , K_ALT_V , 'W' , K_ALT_W , 'X' , K_ALT_X ,
|
||||
'Y' , K_ALT_Y , 'Z' , K_ALT_Z
|
||||
};
|
||||
|
||||
/* a table of alt+digit translation */
|
||||
static int transAltKeyDigitTab[] =
|
||||
{
|
||||
'0' , K_ALT_0 , '1' , K_ALT_1 ,
|
||||
'2' , K_ALT_2 , '3' , K_ALT_3 ,
|
||||
'4' , K_ALT_4 , '5' , K_ALT_5 ,
|
||||
'6' , K_ALT_6 , '7' , K_ALT_7 ,
|
||||
'8' , K_ALT_8 , '9' , K_ALT_9
|
||||
};
|
||||
|
||||
#ifdef IBMPC_SYSTEM
|
||||
/* a table of Dos ScanCode translation - hard coded in Slang */
|
||||
static unsigned char transDosScanCodeTab[] =
|
||||
{
|
||||
'A' , 0x1e , 'B' , 0x30 , 'C' , 0x2e , 'D' , 0x20 , 'E' , 0x12 ,
|
||||
'F' , 0x21 , 'G' , 0x22 , 'H' , 0x23 , 'I' , 0x17 , 'J' , 0x24 ,
|
||||
'K' , 0x25 , 'L' , 0x26 , 'M' , 0x32 , 'N' , 0x31 , 'O' , 0x18 ,
|
||||
'P' , 0x19 , 'Q' , 0x10 , 'R' , 0x13 , 'S' , 0x1f , 'T' , 0x14 ,
|
||||
'U' , 0x16 , 'V' , 0x2f , 'W' , 0x11 , 'X' , 0x2d , 'Y' , 0x15 ,
|
||||
'Z' , 0x2c , '1' , 0x78 , '2' , 0x79 , '3' , 0x7a , '4' , 0x7b ,
|
||||
'5' , 0x7c , '6' , 0x7d , '7' , 0x7e , '8' , 0x7f , '9' , 0x80 ,
|
||||
'0' , 0x81
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -530,3 +530,13 @@ USHORT hb_gt_VertLine( USHORT uiCol, USHORT uiTop, USHORT uiBottom, BYTE byChar,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL hb_gt_Suspend()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL hb_gt_Resume()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1357,3 +1357,13 @@ USHORT hb_gt_VertLine( USHORT uiCol, USHORT uiTop, USHORT uiBottom, BYTE byChar,
|
||||
hb_gt_xPutch( uRow++, uiCol, byAttr, byChar );
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL hb_gt_Suspend()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL hb_gt_Resume()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,9 @@
|
||||
#include "hbapi.h"
|
||||
#include "hbapierr.h"
|
||||
|
||||
extern BOOL hb_gt_Suspend();
|
||||
extern BOOL hb_gt_Resume();
|
||||
|
||||
/* TOFIX: The screen buffer handling is not right for all platforms (Win32)
|
||||
The output of the launched (DOS?) app is not visible. */
|
||||
|
||||
@@ -43,7 +46,16 @@ HB_FUNC( __RUN )
|
||||
{
|
||||
#if defined(__TURBOC__) || defined(__BORLANDC__) || defined(_MSC_VER) || defined(__IBMCPP__) || defined(__GNUC__)
|
||||
if( ISCHAR( 1 ) )
|
||||
system( hb_parc( 1 ) );
|
||||
{
|
||||
if ( hb_gt_Suspend() )
|
||||
{
|
||||
system( hb_parc( 1 ) );
|
||||
if ( hb_gt_Resume() )
|
||||
{
|
||||
/* indicate internal error here */
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
hb_errRT_BASE_Ext1( EG_UNSUPPORTED, 9999, NULL, "__RUN", 0, EF_CANDEFAULT );
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user