From a13480fa598b6058a29db96936f7e9dc5fd2571b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Tue, 1 Oct 2013 16:43:38 +0200 Subject: [PATCH] 2013-10-01 16:43 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/rtl/gttrm/gttrm.c ! fixed terminal ISO mode auto detection (broken in previous patch) % use position from UTF8/ISO mode detection instead of double asking terminal cursor position. With the minor cost of unknown initial column position we have faster start on slow connections. --- ChangeLog.txt | 7 +++++++ src/rtl/gttrm/gttrm.c | 20 +++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 132dec1250..77a34b412a 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,13 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2013-10-01 16:43 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * src/rtl/gttrm/gttrm.c + ! fixed terminal ISO mode auto detection (broken in previous patch) + % use position from UTF8/ISO mode detection instead of double asking + terminal cursor position. With the minor cost of unknown initial + column position we have faster start on slow connections. + 2013-09-24 16:59 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * include/hbvm.h * src/vm/hvm.c diff --git a/src/rtl/gttrm/gttrm.c b/src/rtl/gttrm/gttrm.c index 1aa5a96623..4d5f09ae38 100644 --- a/src/rtl/gttrm/gttrm.c +++ b/src/rtl/gttrm/gttrm.c @@ -2130,20 +2130,20 @@ static HB_BOOL hb_trm_isUTF8( PHB_GTTRM pTerm ) if( pTerm->fPosAnswer ) { - int iRow = 0, iCol = 0; - hb_gt_trm_termOut( pTerm, "\005\r\303\255", 4 ); - fUTF8 = pTerm->GetCursorPos( pTerm, &iRow, &iCol, "\r \r" ) && - iCol == 1; - pTerm->iCol = 0; + if( pTerm->GetCursorPos( pTerm, &pTerm->iRow, &pTerm->iCol, "\r \r" ) ) + { + fUTF8 = pTerm->iCol == 1; + pTerm->iCol = 0; + } } if( hb_trm_Param( "UTF8" ) || hb_trm_Param( "UTF-8" ) ) return HB_TRUE; else if( hb_trm_Param( "ISO" ) ) return HB_FALSE; - else if( fUTF8 ) - return HB_TRUE; + else if( pTerm->fPosAnswer ) + return fUTF8; szLang = getenv( "LANG" ); return szLang && strstr( szLang, "UTF-8" ) != NULL; @@ -3117,9 +3117,15 @@ static void hb_gt_trm_Init( PHB_GT pGT, HB_FHANDLE hFilenoStdin, HB_FHANDLE hFil HB_GTSELF_SETFLAG( pGT, HB_GTI_STDERRCON, pTerm->fStderrTTY && pTerm->fOutTTY ); pTerm->Init( pTerm ); pTerm->SetTermMode( pTerm, 0 ); +#ifdef HB_GTTRM_CHK_EXACT_POS if( pTerm->GetCursorPos( pTerm, &pTerm->iRow, &pTerm->iCol, NULL ) ) HB_GTSELF_SETPOS( pGT, pTerm->iRow, pTerm->iCol ); pTerm->fUTF8 = hb_trm_isUTF8( pTerm ); +#else + pTerm->fUTF8 = hb_trm_isUTF8( pTerm ); + if( pTerm->fPosAnswer ) + HB_GTSELF_SETPOS( pGT, pTerm->iRow, pTerm->iCol ); +#endif if( ! pTerm->fUTF8 ) { #ifndef HB_GT_UNICODE_BUF