From db38a8239b6f3997ca5b0343ec1c077cecc12e51 Mon Sep 17 00:00:00 2001 From: "David G. Holm" Date: Mon, 22 Jan 2001 18:18:16 +0000 Subject: [PATCH] See ChangeLog entry 2001-01-22 13:15 UTC-0500 David G. Holm --- harbour/ChangeLog | 8 ++ harbour/doc/en/gtslang.txt | 136 +++++++++++++++++++++++++++++++ harbour/source/rtl/gtsln/gtsln.c | 83 +++++++++++-------- harbour/source/rtl/gtsln/kbsln.c | 3 - 4 files changed, 192 insertions(+), 38 deletions(-) create mode 100644 harbour/doc/en/gtslang.txt diff --git a/harbour/ChangeLog b/harbour/ChangeLog index ef2277e6ed..e83ca87b99 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,11 @@ +2001-01-22 13:15 UTC-0500 David G. Holm + + doc/en/gtslang.txt + + New file provided by Marek Paliwoda + * source/rtl/gtsln/gtsln.c + * Enhancements provided by Marek Paliwoda + * source/rtl/gtsln/kbsln.c + * Enhancements provided by Marek Paliwoda + 2001-01-22 00:50 UTC-0800 Ron Pinkas * contrib/dot/pp.prg * source/pp/ppcore.c diff --git a/harbour/doc/en/gtslang.txt b/harbour/doc/en/gtslang.txt new file mode 100644 index 0000000000..d7bc63309a --- /dev/null +++ b/harbour/doc/en/gtslang.txt @@ -0,0 +1,136 @@ +/* + * $Id$ + */ + + Marek Paliwoda + + + + Gt slang driver + + +A gt slang driver for Harbour (gtsln) is based on a S-Lang library written +by John E. Davis. It was developed using Slang version 1.41, although prior +versions of Slang up to 1.38 should also work. It was reported that even +Slang 1.22 was succesfully used but I've not tested it. + +The main OS it is developed to be used on is Linux. Although Slang was +ported to other OSes, my tests on SCO OpenServer 5.0.2 show that a library +does not work perfectly on such systems. I've also successfully compiled and +testd gtsln under DOS but I don't think it makes any sense to use it on that +system instead of gtdos, due to its limitations and incompatibilities with +Clipper (see below). + +A gt slang driver is a second driver which can be used on Linux based OSes. +The first one is a gt driver based on a curses library (gtcrs). Due to the +fact that curses is a standard library on Unix like systems, gtcrs should +be considerd as a primary gt driver for such OSes. + +Compiling a gt slang driver ... + +The driver should be automaticly compiled when you build Harbour from +source, regardless of what gt driver you've chosen by setting HB_GT_LIB. +Succesfull compilation requires Slang library and Slang header files +properly installed on your system. + +To build programs (by using a bld.sh script from Harbour sources), which +will use a gtsln, you need to : + - have a Slang library properly installed + - set an environment variable HB_GT_LIB set to gtsln + - modify bld.sh by adding -lslang to a link command + +Generally you always need to add -lgtsln -lslang to your link libraries to +build programs which are supposed to use a gt slang driver. + +Limitations, incomatibilities with Clipper, errors ... + +The driver is rather limited in comparison to other Harbour gt drivers and has +many incompatibilities with Clipper. Some of those limitations and incompati- +bilities are caused by an Unix behavior, others are caused by a Slang imple- +mentation. There are also some caused by a gt layer design. Not to mention +that there are probably some caused by my lack of knowledge. + +Here is a (probably not complete) list of them : + + - a driver allows only 126 combinations of FgBg colors. It means you can + use 16 colors for Fg, 8 colors for Bg. 16*8 gives 128 but last two (126 + and 127) are reserved by Slang + + - you can't get intensity/blinking background mode working (this is in + fact the previous problem, just worded differently) + + - you can't display characters with values below 32 (control characters). + It is a very important limitation because you can't use many usefull + chars which you used under Clipper. This is an OS limitation which + Slang also inherits + + - displaying chars above 128 widely depends on terminal posibilities. + Because of this on xterm I set all frame chars to a single frame (this + means - double and mixed frames are shown as a single frame). You should + not expect to see chars above 128 shown properly in all cases. + + - a screen is automaticly cleared on program's startup (you can't inherit + it from system) and a cursor is set at 0,0 + + - when you run external programs a screen is restored after execution so + there is no possibility to interact with screen handling between two + programs + + - you can't expect cursor hiding and cursor style changing to work at + all. Although on a textmode Linux console it works, this is a Linux + textmode hack only and it is hardcoded. For example on xterm only cur- + sor hiding works well. + + - it is not guaranteed that programs which use DispBegin() and DispEnd() + will work well in all cases + + - a screen size change does not work at all. There is a big problem on + an xterm where you can change a window's size at your request. Doing + this confuses a Harbour program + + - Clipper programs which utilized PC hardware specifications about screen + construction (an array of char+attr) (for example to make quick shadow + on a screen) will not work, although this can be easily emulated if + required + + - there is currently no support for Tone() function. This is a TODO item + + - keyboard handling is VERY VERY LIMITED. Generally you should not expect + ALT+key, CTRL+F and CTRL+ combinations to work at all + although they work on a textmode Linux console. This is a VERY BIG + PROBLEM and at least any solution should be developed to emulate this + + - abort key is CTRL+C not ALT+C on Linux + + - to get an ESC key you have to press ESC twice. This is an issue related + to OS behavior where ESC begins a control sequence + + - currently there is no mouse support. This is a TODO item + + - OutStd() does not work well. This is caused by a design of a gt layer + where writing directly to stdout is done outside Slang, so Slang can't + maintain screen changes properly. Also redirecting OutStd() to a file + results in writing control chars which were supposed to initialize a + terminal, to that file + +Terminfo database ... + +Slang gt driver is based on a terminfo database so it is very important to +have it properly set. Most problems are related to a broken terminfo file. +I don't have general advice about that. You are supposed to help yourself. +The only thing you should know is that you must not have sequences for F11 +and F12 function keys set in a terminfo file if you want to use SHFT+F +and CTRL+F keys (of course they all should be defined there). + +Why use gt slang driver ... + +Well, personaly I find only two reasons. When Clipper compatibility and +current limitations are not a problem, gtsln is a little bit faster than +gtcrs and my experiences show that sometimes it works a little bit better +than gtcrs on real terminals (tested on wy60 where gtcrs did not handle the +keyboard well). + +Marek Paliwoda + +PS. I want to appologize for any english errors and any technical errors in +this text. \ No newline at end of file diff --git a/harbour/source/rtl/gtsln/gtsln.c b/harbour/source/rtl/gtsln/gtsln.c index 09acb3144c..8cf4da0554 100644 --- a/harbour/source/rtl/gtsln/gtsln.c +++ b/harbour/source/rtl/gtsln/gtsln.c @@ -41,7 +41,7 @@ #include #endif /* missing defines in previous versions of Slang - this was not TESTED !! */ -#if SLANG_VERSION < 10401 +#if SLANG_VERSION < 10400 typedef unsigned short SLsmg_Char_Type; #define SLSMG_EXTRACT_CHAR( x ) ( ( x ) & 0xFF ) #define SLSMG_EXTRACT_COLOR( x ) ( ( ( x ) >> 8 ) & 0xFF ) @@ -50,6 +50,7 @@ #define SLSMG_BLOCK_CHAR '0' #endif +#include #include #include "hbapigt.h" @@ -190,13 +191,15 @@ void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr ) } hb_mouse_Init(); - + if( ! gt_Inited ) { + char * errmsg = '\r'+'\n'+"Internal error : screen driver initialization failure"+'\r'+'\n'+( char )0; /* something went wrong - restore default settings */ SLang_reset_tty(); - /* NOTE: an error should be generated here ! */ - return; + /* NOTE: a standard Harbour error should be generated here ! */ + write( iFilenoStderr, errmsg , strlen( errmsg ) ); + exit( 20 ); } } @@ -210,7 +213,7 @@ void hb_gt_Exit( void ) */ hb_mouse_Exit(); - + if( s_sCursorStyle != SC_UNAVAIL ) hb_gt_SetCursorStyle( SC_NORMAL ); @@ -229,7 +232,7 @@ BOOL hb_gt_AdjustPos( BYTE * pStr, ULONG ulLen ) for( ulCount = 0; ulCount < ulLen; ulCount++ ) { - switch( *pStr++ ) + switch( *pStr++ ) { case HB_CHAR_BEL: break; @@ -247,6 +250,11 @@ BOOL hb_gt_AdjustPos( BYTE * pStr, ULONG ulLen ) case HB_CHAR_LF: col = 0; + /* This is a hack. OutStd() is done outside Slang and it + can't be tracked currently by Slang. This should be + changed in console.c + */ + SLtt_write_string( "\r" ); if( row < SLtt_Screen_Rows - 1 ) row++; break; @@ -298,9 +306,9 @@ void hb_gt_SetPos( SHORT iRow, SHORT iCol, SHORT iMethod ) HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetPos(%hd, %hd, %hd)", iRow, iCol, iMethod)); HB_SYMBOL_UNUSED( iMethod ); - + SLsmg_gotorc( iRow, iCol ); - SLtt_goto_rc( iRow, iCol ); /* ??? */ + /* SLtt_goto_rc( iRow, iCol ); */ /* ??? */ if( s_uiDispCount == 0 ) SLsmg_refresh(); @@ -344,7 +352,7 @@ void hb_gt_SetCursorStyle( USHORT uiStyle ) /* see ..\..\..\tests\working\cursrtst.prg for an explanation */ if( s_sCursorStyle == SC_UNAVAIL ) return; - + if( ( s_sCursorStyle >= SC_NONE ) && ( s_sCursorStyle <= SC_SPECIAL2 ) ) { s_sCursorStyle = uiStyle; @@ -357,21 +365,23 @@ void hb_gt_SetCursorStyle( USHORT uiStyle ) case SC_NONE: cursDefseq[ 3 ] = '1'; break; - + case SC_NORMAL: cursDefseq[ 3 ] = '2'; break; - + case SC_INSERT: cursDefseq[ 3 ] = '4'; break; - + case SC_SPECIAL1: cursDefseq[ 3 ] = '8'; break; - + case SC_SPECIAL2: - /* TODO: find a proper sequqnce to set a cursor under Linux console */ + /* TODO: find a proper sequqnce to set a cursor + to SC_SPECIAL2 under Linux console + */ cursDefseq[ 3 ] = '4'; break; } @@ -391,8 +401,8 @@ 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)); /* build a Slang converted char - note we are clearing a high bit of color */ - SLchar = SLSMG_BUILD_CHAR( s_convHighChars[ byChar ], - ( byAttr + SLANG_RESERVED_COLORS ) & 0x7F ); + SLchar = SLSMG_BUILD_CHAR( s_convHighChars[ byChar ], + ( (int)byAttr + SLANG_RESERVED_COLORS ) & 0x7F ); /* alternate char set */ if( byChar > 127 ) @@ -418,8 +428,8 @@ void hb_gt_Puts( USHORT uiRow, USHORT uiCol, BYTE byAttr, BYTE * pbyStr, ULONG u byChar = *pbyStr++; /* build a Slang converted char - note we are clearing a high bit of color */ - SLchar = SLSMG_BUILD_CHAR( s_convHighChars[ byChar ], - ( byAttr + SLANG_RESERVED_COLORS ) & 0x7F ); + SLchar = SLSMG_BUILD_CHAR( s_convHighChars[ byChar ], + ( (int)byAttr + SLANG_RESERVED_COLORS ) & 0x7F ); /* alternate char set */ if( byChar > 127 ) @@ -438,8 +448,8 @@ void hb_gt_Puts( USHORT uiRow, USHORT uiCol, BYTE byAttr, BYTE * pbyStr, ULONG u if( s_uiDispCount == 0 ) SLsmg_refresh(); */ - hb_gt_SetPos( uiRow, uiCol + ulLen, HB_GT_SET_POS_AFTER ); - + hb_gt_SetPos( uiRow, uiCol + ulLen, HB_GT_SET_POS_AFTER ); + hb_xfree( ( BYTE * )pScr ); } @@ -491,7 +501,7 @@ void hb_gt_PutText( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight if( s_uiDispCount == 0 ) SLsmg_refresh(); */ - hb_gt_SetPos( usSavRow, usSavCol, HB_GT_SET_POS_AFTER ); + hb_gt_SetPos( usSavRow, usSavCol, HB_GT_SET_POS_AFTER ); } void hb_gt_SetAttribute( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE byAttr ) @@ -504,7 +514,7 @@ void hb_gt_SetAttribute( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT ui Cols = uiRight - uiLeft + 1; /* note: we are clearing a high bit of color */ - SLsmg_set_color_in_region( ( byAttr + SLANG_RESERVED_COLORS ) & 0x7F, + SLsmg_set_color_in_region( ( (int)byAttr + SLANG_RESERVED_COLORS ) & 0x7F, uiTop, uiLeft, Rows, Cols ); if( s_uiDispCount == 0 ) @@ -652,8 +662,8 @@ void hb_gt_Replicate( USHORT uiRow, USHORT uiCol, BYTE byAttr, BYTE byChar, ULON for( i = 0; i < ulLen; i++ ) { /* build a Slang converted char - note we are clearing a high bit of color */ - SLchar = SLSMG_BUILD_CHAR( s_convHighChars[ byChar ], - ( byAttr + SLANG_RESERVED_COLORS ) & 0x7F ); + SLchar = SLSMG_BUILD_CHAR( s_convHighChars[ byChar ], + ( (int)byAttr + SLANG_RESERVED_COLORS ) & 0x7F ); /* alternate char set */ if( byChar > 127 ) @@ -669,7 +679,7 @@ void hb_gt_Replicate( USHORT uiRow, USHORT uiCol, BYTE byAttr, BYTE byChar, ULON SLsmg_write_raw( pScr, ulLen ); /* this should not be needed here. - hb_gtRepChar() should set this for us + hb_gtRepChar() should set this for us */ /* SLsmg_gotorc( uiRow, uiCol + ulLen ); @@ -677,7 +687,7 @@ void hb_gt_Replicate( USHORT uiRow, USHORT uiCol, BYTE byAttr, BYTE byChar, ULON if( s_uiDispCount == 0 ) SLsmg_refresh(); */ - hb_gt_SetPos( uiRow, uiCol + ulLen, HB_GT_SET_POS_AFTER ); + hb_gt_SetPos( uiRow, uiCol + ulLen, HB_GT_SET_POS_AFTER ); } hb_xfree( ( BYTE * ) pScr ); @@ -803,7 +813,7 @@ USHORT hb_gt_VertLine( USHORT uiCol, USHORT uiTop, USHORT uiBottom, BYTE byChar, if( s_uiDispCount == 0 ) SLsmg_refresh(); */ - hb_gt_SetPos( uiBottom + 1, uiCol, HB_GT_SET_POS_AFTER ); + hb_gt_SetPos( uiBottom + 1, uiCol, HB_GT_SET_POS_AFTER ); return 0; } @@ -830,9 +840,10 @@ BOOL hb_gt_Suspend() BOOL hb_gt_Resume() { - if( s_bSuspended && + if( s_bSuspended && SLsmg_resume_smg() != -1 && hb_gt_Init_Terminal( 1 ) != -1 ) /* reinitialize a terminal */ + SLsmg_refresh(); { s_bSuspended = FALSE; } @@ -865,12 +876,12 @@ static void hb_gt_build_conv_tabs() char mask so it leaves us only 128 possible fgbg colors. (see Notes in Slang sources). This is incompatible with Clipper. Slang uses color 0 as a normal color and a - color 1 as a reverse one, leaving us only 126 fgbg. + color 1 as a reverse one, leaving us only 126 fgbg. */ - /* init colors - color 0 and 1 are normal and - reverse color in Slang. We can't use them + /* init colors - color 0 and 1 are normal and + reverse color in Slang. We can't use them */ - for( i = 0; i < 256 - 2; i++ ) + for( i = 0; i < 256 - SLANG_RESERVED_COLORS; i++ ) { fg = ( i & 0x0F ); bg = ( i >> 4 ) & 0x07; /* bit 7 is a blinking attribute - not used here */ @@ -878,9 +889,11 @@ static void hb_gt_build_conv_tabs() /* leave 0 and 1 for Slang library. Shift color number by 2 */ SLtt_set_color( i + SLANG_RESERVED_COLORS, ( char * ) NULL, s_colorNames[ fg ], s_colorNames[ bg ] ); } + /* Slang normal and reverse color */ + SLtt_set_color( 0, ( char * ) NULL, s_colorNames[ 7 ], s_colorNames[ 0 ] ); + SLtt_set_color( 1, ( char * ) NULL, s_colorNames[ 0 ], s_colorNames[ 7 ] ); - - /* build alternate chars table */ + /* build an alternate chars table */ for( i = 0; i < 32; i++ ) /* under Unix control-chars are not visible in a general meaning */ s_convHighChars[ i ] = '.'; @@ -931,7 +944,7 @@ static void hb_gt_build_conv_tabs() } } - /* QUESTION: do we have dobule, single-double, ... frames under xterm ? */ + /* QUESTION: do we have double, single-double, ... frames under xterm ? */ if( s_underXTerm ) { /* frames of all Clipper type are _B_SINBLE under xterm */ diff --git a/harbour/source/rtl/gtsln/kbsln.c b/harbour/source/rtl/gtsln/kbsln.c index a5fdb89198..b3647840cd 100644 --- a/harbour/source/rtl/gtsln/kbsln.c +++ b/harbour/source/rtl/gtsln/kbsln.c @@ -184,10 +184,7 @@ static void hb_gt_Init_KeyTranslat() 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++; } }