From fca19513caf6f3deebb70859f56e1c5d2093fcb6 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 1 Oct 2012 17:15:48 +0000 Subject: [PATCH] 2012-10-01 19:13 UTC+0200 Viktor Szakats (harbour syenar.net) * include/harbour.hbx * src/rtl/Makefile + src/rtl/cdpbox.prg + added HB_UTF8TOSTRBOX( ) -> It's needed because HB_UTF8TOSTR() will convert to main CP, but box drawing CP can be setup differently with HB_GTI_BOXCP, that function call will take that into account. * contrib/hbnf/aredit.prg * contrib/hbnf/clrsel.prg * contrib/hbnf/dispmsg.prg * contrib/hbnf/menu1.prg * contrib/hbnf/pegs.prg * contrib/hbnf/pickday.prg * contrib/hbnf/popadder.prg * contrib/hbnf/tbwhile.prg * contrib/hbnf/vertmenu.prg * tests/db_brows.prg * tests/gtchars.prg * tests/testbrw.prg * extras/gtwvw/tests/prog0.prg * extras/gtwvw/tests/prog1.prg * extras/gtwvw/tests/prog2.prg ! fixed drawing chars to display properly regardless of HB_GTI_BOXCP setting. ! some related minor fixes * tests/tb1.prg ! fixed to compile and build using Clipper after recent UTF8 compatibility updates (not tested though) ; TOFIX: Pad*() function handle 3rd parameter as binary string, so it doesn't work properly in UTF8 mode. --- harbour/ChangeLog | 35 +++++++++++++++++ harbour/contrib/hbnf/aredit.prg | 22 +++++------ harbour/contrib/hbnf/clrsel.prg | 21 ++++++----- harbour/contrib/hbnf/dispmsg.prg | 4 +- harbour/contrib/hbnf/menu1.prg | 4 +- harbour/contrib/hbnf/pegs.prg | 6 +-- harbour/contrib/hbnf/pickday.prg | 2 +- harbour/contrib/hbnf/popadder.prg | 6 +-- harbour/contrib/hbnf/tbwhile.prg | 6 +-- harbour/contrib/hbnf/vertmenu.prg | 2 +- harbour/extras/gtwvw/tests/prog0.prg | 12 +++--- harbour/extras/gtwvw/tests/prog1.prg | 8 ++-- harbour/extras/gtwvw/tests/prog2.prg | 8 ++-- harbour/include/harbour.hbx | 1 + harbour/src/rtl/Makefile | 1 + harbour/src/rtl/cdpbox.prg | 56 ++++++++++++++++++++++++++++ harbour/tests/db_brows.prg | 8 ++-- harbour/tests/gtchars.prg | 10 ++--- harbour/tests/tb1.prg | 44 ++++++++++++++++------ harbour/tests/testbrw.prg | 8 ++-- 20 files changed, 191 insertions(+), 73 deletions(-) create mode 100644 harbour/src/rtl/cdpbox.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 5d7b936efd..f1bf43e6ae 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,41 @@ The license applies to all entries newer than 2009-04-28. */ +2012-10-01 19:13 UTC+0200 Viktor Szakats (harbour syenar.net) + * include/harbour.hbx + * src/rtl/Makefile + + src/rtl/cdpbox.prg + + added HB_UTF8TOSTRBOX( ) -> + It's needed because HB_UTF8TOSTR() will convert to main CP, + but box drawing CP can be setup differently with HB_GTI_BOXCP, + that function call will take that into account. + + * contrib/hbnf/aredit.prg + * contrib/hbnf/clrsel.prg + * contrib/hbnf/dispmsg.prg + * contrib/hbnf/menu1.prg + * contrib/hbnf/pegs.prg + * contrib/hbnf/pickday.prg + * contrib/hbnf/popadder.prg + * contrib/hbnf/tbwhile.prg + * contrib/hbnf/vertmenu.prg + * tests/db_brows.prg + * tests/gtchars.prg + * tests/testbrw.prg + * extras/gtwvw/tests/prog0.prg + * extras/gtwvw/tests/prog1.prg + * extras/gtwvw/tests/prog2.prg + ! fixed drawing chars to display properly regardless of HB_GTI_BOXCP + setting. + ! some related minor fixes + + * tests/tb1.prg + ! fixed to compile and build using Clipper after recent + UTF8 compatibility updates (not tested though) + + ; TOFIX: Pad*() function handle 3rd parameter as binary string, + so it doesn't work properly in UTF8 mode. + 2012-10-01 11:33 UTC+0200 Viktor Szakats (harbour syenar.net) ! ChangeLog ! deleted UTF-8 char. (Maybe its time to switch to diff --git a/harbour/contrib/hbnf/aredit.prg b/harbour/contrib/hbnf/aredit.prg index d2e0ca491a..8a037afd70 100644 --- a/harbour/contrib/hbnf/aredit.prg +++ b/harbour/contrib/hbnf/aredit.prg @@ -42,25 +42,25 @@ #include "inkey.ch" // Default heading, column, footer separators -#define DEF_HSEP hb_UTF8ToStr( "═╤═" ) -#define DEF_CSEP hb_UTF8ToStr( " │ " ) -#define DEF_FSEP hb_UTF8ToStr( "═╧═" ) +#define DEF_HSEP hb_UTF8ToStrBox( "═╤═" ) +#define DEF_CSEP hb_UTF8ToStrBox( " │ " ) +#define DEF_FSEP hb_UTF8ToStrBox( "═╧═" ) // Default info for tb_methods section #define KEY_ELEM 1 #define BLK_ELEM 2 +// ANYTYPE[] ar - Array to browse +// NUMERIC nElem - Element In Array +// CHARACTER[] aHeadings - Array of Headings for each column +// BLOCK[] aBlocks - Array containing code block for each column. +// CODE BLOCK bGetFunc - Code Block For Special Get Processing +// NOTE: When evaluated a code block is passed the array element to +// be edited + FUNCTION FT_ArEdit( nTop, nLeft, nBot, nRight, ; ar, nElem, aHeadings, aBlocks, bGetFunc ) - // ANYTYPE[] ar - Array to browse - // NUMERIC nElem - Element In Array - // CHARACTER[] aHeadings - Array of Headings for each column - // BLOCK[] aBlocks - Array containing code block for each column. - // CODE BLOCK bGetFunc - Code Block For Special Get Processing - // NOTE: When evaluated a code block is passed the array element to - // be edited - LOCAL exit_requested, nKey, meth_no LOCAL cSaveWin, i, b, column LOCAL nDim, cType, cVal diff --git a/harbour/contrib/hbnf/clrsel.prg b/harbour/contrib/hbnf/clrsel.prg index 784e91a3b6..5ccc1cd7c3 100644 --- a/harbour/contrib/hbnf/clrsel.prg +++ b/harbour/contrib/hbnf/clrsel.prg @@ -63,11 +63,11 @@ #define C_CHAR 4 #translate Single( , , , ) =>; - @ , , , BOX hb_UTF8ToStr( "┌─┐│┘─└│" ) + @ , , , BOX hb_UTF8ToStrBox( "┌─┐│┘─└│" ) #translate Double( , , , ) =>; - @ , , , BOX hb_UTF8ToStr( "╔═╗║╝═╚║" ) + @ , , , BOX hb_UTF8ToStrBox( "╔═╗║╝═╚║" ) #translate ClearS( , , , ) =>; @ , CLEAR TO , @@ -281,7 +281,7 @@ STATIC FUNCTION _ftColours( aOpt, aClrPal, lColour ) //.... allow change to specific part of colour string IF !( aOpt[ C_TYPE ] == "T" ) Single( nT, nL + 1, nB, nR - 1 ) - @ nT, nL + 2 SAY PadC( " " + aOpt[C_NAME] + " ", nR - nL - 3, hb_UTF8ToStr( "─" ) ) + @ nT, nL + 2 SAY PadC( " " + aOpt[ C_NAME ] + " ", nR - nL - 3, hb_UTF8ToStr( "─" ) ) ENDIF cClr := _ftClrSel( aClrPal, cClr, nChoice, aOpt ) // selection routine aClrs[ nChoice ] := cClr // put colour back in array @@ -317,7 +317,7 @@ STATIC FUNCTION _ftShowIt( aOpt ) CASE aOpt[ C_TYPE ] == "D" // Desktop Background SetColor( aClr[ 1 ] ) - BkGrnd( 19, 43, 22, 64, aOpt[ C_CHAR ] ) + BkGrnd( 19, 43, 22, 64, hb_UTF8ToStrBox( aOpt[ C_CHAR ] ) ) CASE aOpt[ C_TYPE ] == "T" // Title SetColor( aClr[ 1 ] ) @@ -325,7 +325,7 @@ STATIC FUNCTION _ftShowIt( aOpt ) CASE aOpt[ C_TYPE ] == "M" // Menus SetColor( "W/N" ) - BkGrnd( 19, 41, 23, 66, hb_UTF8ToStr( "▒" ) ) + BkGrnd( 19, 41, 23, 66, hb_UTF8ToStrBox( "▒" ) ) SetColor( aClr[ 1 ] ) Single( 19, 43, 22, 60 ) @ 18, 41 SAY " Report Inquiry Quit " @@ -429,10 +429,13 @@ STATIC FUNCTION _ftClrSel( aClrPal, cClr, nElem, aOpt ) FOR nR := 1 TO nDim FOR nC := 1 TO nDim IF aClrPal[ nR, nC ] == AllTrim( cClr ) - lFound := .T. ; EXIT + lFound := .T. + EXIT ENDIF NEXT - IF lFound ; EXIT ; ENDIF + IF lFound + EXIT + ENDIF NEXT IF ! lFound @@ -497,7 +500,7 @@ STATIC FUNCTION _ftClrPut( cClrStr, nElem, cClr ) STATIC FUNCTION _ftDeskChar( aOpt ) - LOCAL aChar := { " ", hb_UTF8ToStr( "░" ), hb_UTF8ToStr( "▒" ), hb_UTF8ToStr( "▓" ) } + LOCAL aChar := { " ", "░", "▒", "▓" } LOCAL cChar := aOpt[ C_CHAR ] LOCAL cClr := aOpt[ C_CLR ] LOCAL nElem := AScan( aChar, cChar ) @@ -511,7 +514,7 @@ STATIC FUNCTION _ftDeskChar( aOpt ) //.... draw the choices on the screen SetColor( cClr ) FOR n := 1 TO Len( aChar ) - @ n + 18, 29 SAY REPLICATE( aChar[ n ], 10 ) + @ n + 18, 29 SAY Replicate( hb_UTF8ToStr( aChar[ n ] ), 10 ) NEXT n := nElem + 18 diff --git a/harbour/contrib/hbnf/dispmsg.prg b/harbour/contrib/hbnf/dispmsg.prg index 53bc20acc1..2e2375754b 100644 --- a/harbour/contrib/hbnf/dispmsg.prg +++ b/harbour/contrib/hbnf/dispmsg.prg @@ -93,9 +93,9 @@ FUNCTION FT_DispMsg( aInfo, cKey, nBoxTop, nBoxLeft, cnBoxString, lShadow ) // consistent with DISPBOX() IF cnBoxString == NIL .OR. cnBoxString == 2 - cnBoxString := hb_UTF8ToStr( "╔═╗║╝═╚║ " ) + cnBoxString := hb_UTF8ToStrBox( "╔═╗║╝═╚║ " ) ELSEIF cnBoxString == 1 - cnBoxString := hb_UTF8ToStr( "┌─┐│┘─└│ " ) + cnBoxString := hb_UTF8ToStrBox( "┌─┐│┘─└│ " ) ENDIF lShadow := iif( lShadow == NIL, .T. , lShadow ) diff --git a/harbour/contrib/hbnf/menu1.prg b/harbour/contrib/hbnf/menu1.prg index 3a3e7c8af5..0f884524ef 100644 --- a/harbour/contrib/hbnf/menu1.prg +++ b/harbour/contrib/hbnf/menu1.prg @@ -139,7 +139,7 @@ FUNCTION FT_MENU1( aBar, aOptions, aColors, nTopRow, lShadow ) hb_Shadow( nTopRow + 1, aBoxLoc[ t_nHPos ], Len( t_aChoices[ t_nHPos, 1 ] ) + nTopRow + 2, aBarWidth[ t_nHPos ] + 3 + aBoxLoc[ t_nHPos ] ) ENDIF SetColor( cBorder ) - @ nTopRow + 1, aBoxLoc[ t_nHPos ], Len( t_aChoices[ t_nHPos, 1 ] ) + nTopRow + 2, aBarWidth[ t_nHPos ] + 3 + aBoxLoc[ t_nHPos ] BOX hb_UTF8ToStr( "╔═╗║╝═╚║ " ) + @ nTopRow + 1, aBoxLoc[ t_nHPos ], Len( t_aChoices[ t_nHPos, 1 ] ) + nTopRow + 2, aBarWidth[ t_nHPos ] + 3 + aBoxLoc[ t_nHPos ] BOX hb_UTF8ToStrBox( "╔═╗║╝═╚║ " ) SetColor( cBox + "," + cCurrent + ",,," + cUnselec ) t_nVPos := AChoice( nTopRow + 2, aBoxLoc[ t_nHPos ] + 2, Len( t_aChoices[ t_nHPos, 1 ] ) + nTopRow + 2, aBarWidth[ t_nHPos ] + 1 + aBoxLoc[ t_nHPos ], t_aChoices[ t_nHPos, 1 ], t_aChoices[ t_nHPos, 3 ], "__ftAcUdf", aLastSel[ t_nHPos ] ) DO CASE @@ -216,7 +216,7 @@ STATIC FUNCTION _ftBailOut( cBorder, cBox ) sOldScreen := SaveScreen( t_nMaxRow / 2 - 1, 24, t_nMaxRow / 2 + 2, 55 ) cOldColor := SetColor( cBorder ) hb_Shadow( t_nMaxRow / 2 - 1, 24, t_nMaxRow / 2 + 2, 55 ) - @ t_nMaxRow / 2 - 1, 24, t_nMaxRow/2 + 2, 55 BOX hb_UTF8ToStr( "╔═╗║╝═╚║ " ) + @ t_nMaxRow / 2 - 1, 24, t_nMaxRow/2 + 2, 55 BOX hb_UTF8ToStrBox( "╔═╗║╝═╚║ " ) SetColor( cBox ) @ t_nMaxRow / 2, 26 SAY "Press ESCape To Confirm Exit" @ t_nMaxRow / 2 + 1, 27 SAY "Or Any Other Key To Resume" diff --git a/harbour/contrib/hbnf/pegs.prg b/harbour/contrib/hbnf/pegs.prg index 32b5b24736..0659d6a1b8 100644 --- a/harbour/contrib/hbnf/pegs.prg +++ b/harbour/contrib/hbnf/pegs.prg @@ -32,9 +32,9 @@ #include "setcurs.ch" #translate SINGLEBOX( , , , ) => ; - @ , , , BOX hb_UTF8ToStr( "┌─┐│┘─└│ " ) + @ , , , BOX hb_UTF8ToStrBox( "┌─┐│┘─└│ " ) #translate DOUBLEBOX( , , , ) => ; - @ , , , BOX hb_UTF8ToStr( "╔═╗║╝═╚║ " ) + @ , , , BOX hb_UTF8ToStrBox( "╔═╗║╝═╚║ " ) MEMVAR GetList /* @@ -164,7 +164,7 @@ STATIC FUNCTION DrawBox( nelement ) SetColor( iif( t_board_[ nelement ][ 4 ], "+w/rb", "w/n" ) ) @ t_board_[ nelement ][ 1, 1 ], t_board_[ nelement ][ 1, 2 ], t_board_[ nelement ][ 1, 3 ], ; - t_board_[ nelement ][ 1, 4 ] BOX hb_UTF8ToStr( "┌─┐│┘─└│ " ) + t_board_[ nelement ][ 1, 4 ] BOX hb_UTF8ToStrBox( "┌─┐│┘─└│ " ) DevPos( t_board_[ nelement ][ 1, 1 ] + 1, t_board_[ nelement ][ 1, 2 ] + 2 ) DevOut( hb_ntos( nelement ) ) diff --git a/harbour/contrib/hbnf/pickday.prg b/harbour/contrib/hbnf/pickday.prg index ee035666ae..7f4ed7d7f7 100644 --- a/harbour/contrib/hbnf/pickday.prg +++ b/harbour/contrib/hbnf/pickday.prg @@ -31,7 +31,7 @@ FUNCTION FT_PICKDAY() LOCAL sel := 0 LOCAL oldscrn := SaveScreen( 8, 35, 16, 45 ), oldcolor := SetColor( "+w/r" ) - @ 8, 35, 16, 45 BOX hb_UTF8ToStr( "┌─┐│┘─└│ " ) + @ 8, 35, 16, 45 BOX hb_UTF8ToStrBox( "┌─┐│┘─└│ " ) /* do not allow user to Esc out, which would cause array access error */ DO WHILE sel == 0 sel := AChoice( 9, 36, 15, 44, days ) diff --git a/harbour/contrib/hbnf/popadder.prg b/harbour/contrib/hbnf/popadder.prg index 45038bf281..56421ea16d 100644 --- a/harbour/contrib/hbnf/popadder.prg +++ b/harbour/contrib/hbnf/popadder.prg @@ -54,8 +54,8 @@ #define STD_VARIABLE 6 #define STD_BORDER 7 -#define B_DOUBLE hb_UTF8ToStr( "╔═╗║╝═╚║ " ) -#define B_SINGLE "+-+|+-+| " +#define B_DOUBLE hb_UTF8ToStrBox( "╔═╗║╝═╚║ " ) +#define B_SINGLE "+-+|+-+| " #define nTotTran Len( aTrans ) @@ -358,7 +358,7 @@ STATIC FUNCTION _ftAddScreen( aAdder ) @ 8 + nTopOS, nCol SAY "-" @ 13 + nTopOS, nCol SAY "+" @ 18 + nTopOS, nCol SAY "=" - @ 19 + nTopOS, nCol SAY "" + @ 19 + nTopOS, nCol SAY hb_UTF8ToStr( "♦" ) _ftSetWinColor( W_CURR, W_PROMPT ) @ 3 + nTopOS, 6 + nAddSpace, 5 + nTopOS, 27 + nAddSpace BOX B_DOUBLE diff --git a/harbour/contrib/hbnf/tbwhile.prg b/harbour/contrib/hbnf/tbwhile.prg index 9290eacf27..a79d9e6350 100644 --- a/harbour/contrib/hbnf/tbwhile.prg +++ b/harbour/contrib/hbnf/tbwhile.prg @@ -89,9 +89,9 @@ FUNCTION FT_BRWSWHL( aFields, bWhileCond, cKey, nFreeze, lSaveScrn, ; b := TBRowseDb( nTop, nLeft, nBottom, nRight ) /* default heading and column separators */ - b:headSep := hb_UTF8ToStr( "═╤═" ) - b:colSep := hb_UTF8ToStr( " │ " ) - b:footSep := hb_UTF8ToStr( "═╧═" ) + b:headSep := hb_UTF8ToStrBox( "═╤═" ) + b:colSep := hb_UTF8ToStrBox( " │ " ) + b:footSep := hb_UTF8ToStrBox( "═╧═" ) /* add custom 'TbSkipWhil' (to handle passed condition) */ b:skipBlock := {| x | TbSkipWhil( x, bWhileCond ) } diff --git a/harbour/contrib/hbnf/vertmenu.prg b/harbour/contrib/hbnf/vertmenu.prg index cb2c0ca28b..5cec09e641 100644 --- a/harbour/contrib/hbnf/vertmenu.prg +++ b/harbour/contrib/hbnf/vertmenu.prg @@ -58,7 +58,7 @@ FUNCTION ft_menu2( aMenuInfo, cColors ) cOldscreen := SaveScreen( nTop, nLeft - 1, nTop + nOptions + 1, nLeft + nMaxwidth ) - @ nTop, nLeft - 1, nTop + nOptions + 1, nLeft + nMaxwidth BOX hb_UTF8ToStr( "┌─┐│┘─└│ " ) + @ nTop, nLeft - 1, nTop + nOptions + 1, nLeft + nMaxwidth BOX hb_UTF8ToStrBox( "┌─┐│┘─└│ " ) DevPos( nTop, nLeft ) FOR x := 1 TO Len( aMenuInfo ) IF Len( aMenuInfo[ x ] ) > 1 .AND. aMenuInfo[ x, 2 ] != NIL diff --git a/harbour/extras/gtwvw/tests/prog0.prg b/harbour/extras/gtwvw/tests/prog0.prg index 49651870ed..87e3e08a77 100644 --- a/harbour/extras/gtwvw/tests/prog0.prg +++ b/harbour/extras/gtwvw/tests/prog0.prg @@ -64,7 +64,7 @@ local lDone := .f. local getlist := {} local oldCurs := setcursor(SC_NORMAL) - nWin := znewwindow( hb_UTF8ToStr( "┌─┐│┘─└│" ),10,20,22,59,"Some Window") + nWin := znewwindow( hb_UTF8ToStrBox( "┌─┐│┘─└│" ),10,20,22,59,"Some Window") //@ 21,21 say "Inside the window" color "R/W" //@ 23,0 say "Outside the window" color "R/W" @@ -107,8 +107,8 @@ FUNCTION xBrowse1() SetColor( 'N/W*,N/GR*,,,N/W* ' ) oBrowse := TBrowseNew( nTop + 1, nLeft + 1, nBottom - 1, nRight - 1 ) - oBrowse:ColSep := hb_UTF8ToStr( "│" ) - oBrowse:HeadSep := hb_UTF8ToStr( "─" ) + oBrowse:ColSep := hb_UTF8ToStrBox( "│" ) + oBrowse:HeadSep := hb_UTF8ToStrBox( "─" ) oBrowse:GoTopBlock := { || dbGoTop() } oBrowse:GoBottomBlock := { || dbGoBottom() } oBrowse:SkipBlock := { | nSkip | dbSkipBlock( nSkip,oBrowse ) } @@ -120,7 +120,7 @@ FUNCTION xBrowse1() oBrowse:configure() - nWin := znewwindow( hb_UTF8ToStr( "┌─┐│┘─└│" ),nTop,nLeft,nBottom,nRight, "test.dbf") + nWin := znewwindow( hb_UTF8ToStrBox( "┌─┐│┘─└│" ),nTop,nLeft,nBottom,nRight, "test.dbf") While !lEnd oBrowse:ForceStable() @@ -246,7 +246,7 @@ local oldColor := setcolor(s_cStdColor) nRight := nLeft + nWidth + 1 * open window - nWinNum := znewwindow( hb_UTF8ToStr( "┌─┐│┘─└│" ), nTopLine, nLeft, nBotLine, nRight, cMsg) + nWinNum := znewwindow( hb_UTF8ToStrBox( "┌─┐│┘─└│" ), nTopLine, nLeft, nBotLine, nRight, cMsg) @ nTopLine+1, nLeft+1 PROMPT padr("Yes", nWidth) @ nTopLine+2, nLeft+1 PROMPT padr("No", nWidth) @@ -288,7 +288,7 @@ local oldColor := setcolor(s_cStdColor) nRight := nLeft + nMaxWidth + 1 * open window - nWinNum := znewwindow( hb_UTF8ToStr( "┌─┐│┘─└│" ), nTopLine, nLeft, nBotLine, nRight, cTitle) + nWinNum := znewwindow( hb_UTF8ToStrBox( "┌─┐│┘─└│" ), nTopLine, nLeft, nBotLine, nRight, cTitle) DISPBEGIN() for i := 1 to nNumLines cAline := MEMOLINE(cMsg, nWidth, i) diff --git a/harbour/extras/gtwvw/tests/prog1.prg b/harbour/extras/gtwvw/tests/prog1.prg index cfa38e735d..fd32d97ac1 100644 --- a/harbour/extras/gtwvw/tests/prog1.prg +++ b/harbour/extras/gtwvw/tests/prog1.prg @@ -88,7 +88,7 @@ local lDone := .f. local getlist := {} local oldCurs := setcursor(SC_NORMAL) - nWin := znewwindow( hb_UTF8ToStr( "┌─┐│┘─└│" ),10,20,22,59,"Some Window") + nWin := znewwindow( hb_UTF8ToStrBox( "┌─┐│┘─└│" ),10,20,22,59,"Some Window") //@ 21,21 say "Inside the window" color "R/W" //@ 23,0 say "Outside the window" color "R/W" @@ -144,7 +144,7 @@ FUNCTION xBrowse1() oBrowse:configure() - nWin := znewwindow( hb_UTF8ToStr( "┌─┐│┘─└│" ),nTop,nLeft,nBottom,nRight, "test.dbf") + nWin := znewwindow( hb_UTF8ToStrBox( "┌─┐│┘─└│" ),nTop,nLeft,nBottom,nRight, "test.dbf") While !lEnd oBrowse:ForceStable() @@ -270,7 +270,7 @@ local oldColor := setcolor(s_cStdColor) nRight := nLeft + nWidth + 1 * open window - nWinNum := znewwindow( hb_UTF8ToStr( "┌─┐│┘─└│" ), nTopLine, nLeft, nBotLine, nRight, cMsg) + nWinNum := znewwindow( hb_UTF8ToStrBox( "┌─┐│┘─└│" ), nTopLine, nLeft, nBotLine, nRight, cMsg) @ nTopLine+1, nLeft+1 PROMPT padr("Yes", nWidth) @ nTopLine+2, nLeft+1 PROMPT padr("No", nWidth) @@ -312,7 +312,7 @@ local oldColor := setcolor(s_cStdColor) nRight := nLeft + nMaxWidth + 1 * open window - nWinNum := znewwindow( hb_UTF8ToStr( "┌─┐│┘─└│" ), nTopLine, nLeft, nBotLine, nRight, cTitle) + nWinNum := znewwindow( hb_UTF8ToStrBox( "┌─┐│┘─└│" ), nTopLine, nLeft, nBotLine, nRight, cTitle) DISPBEGIN() for i := 1 to nNumLines cAline := MEMOLINE(cMsg, nWidth, i) diff --git a/harbour/extras/gtwvw/tests/prog2.prg b/harbour/extras/gtwvw/tests/prog2.prg index 18e51bf8e6..5449362675 100644 --- a/harbour/extras/gtwvw/tests/prog2.prg +++ b/harbour/extras/gtwvw/tests/prog2.prg @@ -92,7 +92,7 @@ local oldCurs := setcursor(SC_NORMAL) MEMVAR __temp__ #ENDIF - nWin := znewwindow( hb_UTF8ToStr( "┌─┐│┘─└│" ),10,20,22,59,"Some Window") + nWin := znewwindow( hb_UTF8ToStrBox( "┌─┐│┘─└│" ),10,20,22,59,"Some Window") #IFDEF __GTWVW__ AddMiscObjects( nWin, {|nWindow| __temp__:= nWindow, aEval( GetList, {|oGet| WVW_DrawBoxGet( __temp__, oGet:Row, oGet:Col, Len( Transform( oGet:VarGet(), oGet:Picture ) ) ) } ) } ) @@ -161,7 +161,7 @@ FUNCTION xBrowse1() oBrowse:configure() - nWin := znewwindow( hb_UTF8ToStr( "┌─┐│┘─└│" ),nTop,nLeft,nBottom,nRight, "test.dbf") + nWin := znewwindow( hb_UTF8ToStrBox( "┌─┐│┘─└│" ),nTop,nLeft,nBottom,nRight, "test.dbf") #IFDEF __GTWVW__ Wvw_SetPen( 0, 0, rgb( 210,1210,210 ) ) @@ -311,7 +311,7 @@ local oldColor := setcolor(s_cStdColor) nRight := nLeft + nWidth + 1 * open window - nWinNum := znewwindow( hb_UTF8ToStr( "┌─┐│┘─└│" ), nTopLine, nLeft, nBotLine, nRight, cMsg) + nWinNum := znewwindow( hb_UTF8ToStrBox( "┌─┐│┘─└│" ), nTopLine, nLeft, nBotLine, nRight, cMsg) @ nTopLine+1, nLeft+1 PROMPT padr("Yes", nWidth) @ nTopLine+2, nLeft+1 PROMPT padr("No", nWidth) @@ -353,7 +353,7 @@ local oldColor := setcolor(s_cStdColor) nRight := nLeft + nMaxWidth + 1 * open window - nWinNum := znewwindow( hb_UTF8ToStr( "┌─┐│┘─└│" ), nTopLine, nLeft, nBotLine, nRight, cTitle) + nWinNum := znewwindow( hb_UTF8ToStrBox( "┌─┐│┘─└│" ), nTopLine, nLeft, nBotLine, nRight, cTitle) DISPBEGIN() for i := 1 to nNumLines cAline := MEMOLINE(cMsg, nWidth, i) diff --git a/harbour/include/harbour.hbx b/harbour/include/harbour.hbx index cb405943f3..db8d7e9cef 100644 --- a/harbour/include/harbour.hbx +++ b/harbour/include/harbour.hbx @@ -868,6 +868,7 @@ DYNAMIC hb_utf8StrTran DYNAMIC hb_utf8Stuff DYNAMIC hb_utf8SubStr DYNAMIC hb_UTF8ToStr +DYNAMIC hb_UTF8ToStrBox DYNAMIC hb_ValToExp DYNAMIC hb_ValToStr DYNAMIC hb_Version diff --git a/harbour/src/rtl/Makefile b/harbour/src/rtl/Makefile index a45edef6d7..1c9390217b 100644 --- a/harbour/src/rtl/Makefile +++ b/harbour/src/rtl/Makefile @@ -218,6 +218,7 @@ PRG_SOURCES := \ altd.prg \ browdb.prg \ browse.prg \ + cdpbox.prg \ cdpdet.prg \ checkbox.prg \ color53.prg \ diff --git a/harbour/src/rtl/cdpbox.prg b/harbour/src/rtl/cdpbox.prg new file mode 100644 index 0000000000..afd83bc1b7 --- /dev/null +++ b/harbour/src/rtl/cdpbox.prg @@ -0,0 +1,56 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Internal support for CP agnostic box drawing chars + * + * Copyright 2012 Viktor Szakats (harbour syenar.net) + * www - http://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, 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 software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries 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 Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + +#include "hbgtinfo.ch" + +FUNCTION hb_UTF8ToStrBox( cString ) + RETURN hb_Translate( cString, "UTF8", hb_gtInfo( HB_GTI_BOXCP ) ) diff --git a/harbour/tests/db_brows.prg b/harbour/tests/db_brows.prg index 7518341b7d..d4b4e353dd 100644 --- a/harbour/tests/db_brows.prg +++ b/harbour/tests/db_brows.prg @@ -144,7 +144,7 @@ FUNCTION DBFLIST( mslist, x1, y1, x2, y2, title, maskey ) mslist := InitList() ENDIF IF !( Type( "str_bar" ) == "C" ) - PRIVATE str_bar := hb_UTF8ToStr( "-■" ) + PRIVATE str_bar := "-v^o" ENDIF LI_Y1 := y1 LI_X1 := x1 @@ -195,7 +195,7 @@ FUNCTION DBFLIST( mslist, x1, y1, x2, y2, title, maskey ) ENDIF oldcolors := SetColor() SetColor( LI_CLR ) - @ LI_Y1, LI_X1, LI_Y2, LI_X2 BOX hb_UTF8ToStr( "┌─┐│┘─└│ " ) + @ LI_Y1, LI_X1, LI_Y2, LI_X2 BOX hb_UTF8ToStrBox( "┌─┐│┘─└│ " ) IF title != Nil @ LI_Y1, ( LI_X2 - LI_X1 - 1 - Len( title ) ) / 2 + LI_X1 SAY " " + title + " " ENDIF @@ -242,8 +242,8 @@ FUNCTION DBFLIST( mslist, x1, y1, x2, y2, title, maskey ) // #ifdef RDD_AX @ LI_Y1 + 2, LI_X2, LI_Y2 - 2, LI_X2 BOX Left( str_bar, 1 ) - @ LI_Y1 + 1, LI_X2 SAY SubStr( str_bar, 2, 1 ) - @ LI_Y2 - 1, LI_X2 SAY SubStr( str_bar, 2, 1 ) + @ LI_Y1 + 1, LI_X2 SAY SubStr( str_bar, 2, 1 ) + @ LI_Y2 - 1, LI_X2 SAY SubStr( str_bar, 2, 1 ) @ LI_Y1 + 2 + Int( iif( LI_PRFLT, LI_TEKZP, Ax_Keyno() ) * ( LI_Y2 - LI_Y1 - 4 ) / iif( LI_PRFLT, LI_KOLZ, Ax_KeyCount() ) ), LI_X2 SAY Right( str_bar, 1 ) #else IF ! ( Type( "Sx_Keyno()" ) == "U" ) diff --git a/harbour/tests/gtchars.prg b/harbour/tests/gtchars.prg index 2db184e000..9f2e3432e5 100644 --- a/harbour/tests/gtchars.prg +++ b/harbour/tests/gtchars.prg @@ -65,11 +65,11 @@ PROCEDURE Main( cTermCP, cHostCP, lBoxChar ) ? NEXT Inkey( 0 ) - ?; dspboxch( hb_UTF8ToStr( "┌─┬─┐ ╔═╦═╗ ╒═╤═╕ ╓─╥─╖ ▄▄▄ ░▒▓█ ░ ▒ ▓ █" ) ) - ?; dspboxch( hb_UTF8ToStr( "│ │ │ ║ ║ ║ ├─┼─┤ ╟─╫─╢ ▌■▐" ) ) - ?; dspboxch( hb_UTF8ToStr( "├─┼─┤ ╠═╬═╣ │ │ │ ║ ║ ║ ▌█▐ █■█" ) ) - ?; dspboxch( hb_UTF8ToStr( "│ │ │ ║ ║ ║ ╞═╪═╡ ╠═╬═╣ ▌■▐" ) ) - ?; dspboxch( hb_UTF8ToStr( "└─┴─┘ ╚═╩═╝ ╘═╧═╛ ╙─╨─╜ ▀▀▀ √ « »" ) ) + ?; dspboxch( hb_UTF8ToStrBox( "┌─┬─┐ ╔═╦═╗ ╒═╤═╕ ╓─╥─╖ ▄▄▄ ░▒▓█ ░ ▒ ▓ █" ) ) + ?; dspboxch( hb_UTF8ToStrBox( "│ │ │ ║ ║ ║ ├─┼─┤ ╟─╫─╢ ▌■▐" ) ) + ?; dspboxch( hb_UTF8ToStrBox( "├─┼─┤ ╠═╬═╣ │ │ │ ║ ║ ║ ▌█▐ █■█" ) ) + ?; dspboxch( hb_UTF8ToStrBox( "│ │ │ ║ ║ ║ ╞═╪═╡ ╠═╬═╣ ▌■▐" ) ) + ?; dspboxch( hb_UTF8ToStrBox( "└─┴─┘ ╚═╩═╝ ╘═╧═╛ ╙─╨─╜ ▀▀▀ √ « »" ) ) ? ? "ISO-8859-2: say[ " + POL_ISO + " ]"; dspboxch( ", box[ " + POL_ISO + " ]" ) ? " Mazovia: say[ " + POL_MAZ + " ]"; dspboxch( ", box[ " + POL_MAZ + " ]" ) diff --git a/harbour/tests/tb1.prg b/harbour/tests/tb1.prg index cb5f62aae7..54115e81ca 100644 --- a/harbour/tests/tb1.prg +++ b/harbour/tests/tb1.prg @@ -18,6 +18,28 @@ #include "setcurs.ch" #include "box.ch" +#ifdef __HARBOUR__ + #define _DRAW_1 hb_UTF8ToStr( "├" ) + #define _DRAW_2 hb_UTF8ToStr( "┤" ) + #define _DRAW_3 hb_UTF8ToStr( "┐ ┌─" ) + #define _DRAW_4 hb_UTF8ToStr( "┘ └─" ) + #define _DRAW_5 hb_UTF8ToStr( "│ │" ) + #define _DRAW_6 hb_UTF8ToStr( "┐ ┌─┤HIDE├─" ) + #define _DRAW_7 hb_UTF8ToStr( "╖ ╓─┤HIDE├─" ) + #define _DRAW_8 hb_UTF8ToStr( "╜ ╙─" ) + #define _DRAW_9 hb_UTF8ToStr( "║ ║" ) +#else + #define _DRAW_1 Chr( 195 ) + #define _DRAW_2 Chr( 180 ) + #define _DRAW_3 Chr( 191 ) + " " + Chr( 218 ) + Chr( 196 ) + #define _DRAW_4 Chr( 217 ) + " " + Chr( 192 ) + Chr( 196 ) + #define _DRAW_5 Chr( 179 ) + " " + Chr( 179 ) + #define _DRAW_6 Chr( 191 ) + " " + Chr( 218 ) + Chr( 196 ) + "HIDE" + Chr( 195 ) + Chr( 196 ) + #define _DRAW_7 Chr( 183 ) + " " + Chr( 214 ) + Chr( 196 ) + "HIDE" + Chr( 195 ) + Chr( 196 ) + #define _DRAW_8 Chr( 189 ) + " " + Chr( 211 ) + Chr( 196 ) + #define _DRAW_9 Chr( 186 ) + " " + Chr( 186 ) +#endif + PROCEDURE Main() STATIC s_nCount := 0 @@ -48,15 +70,15 @@ PROCEDURE Main() CLS DispBox( nTop, nLeft, nBottom, nRight, B_DOUBLE_SINGLE, cColor ) oBrw := TBRowseNew( nTop + 1, nLeft + 1, nBottom - 1, nRight - 1 ) - DispOutAt( nTop + 3, nLeft, hb_UTF8ToStr( "├" ), cColor ) - DispOutAt( nTop + 3, nRight, hb_UTF8ToStr( "┤" ), cColor ) - DispOutAt( nBottom - 2, nLeft, hb_UTF8ToStr( "├" ), cColor ) - DispOutAt( nBottom - 2, nRight, hb_UTF8ToStr( "┤" ), cColor ) + DispOutAt( nTop + 3, nLeft, _DRAW_1, cColor ) + DispOutAt( nTop + 3, nRight, _DRAW_2, cColor ) + DispOutAt( nBottom - 2, nLeft, _DRAW_1, cColor ) + DispOutAt( nBottom - 2, nRight, _DRAW_2, cColor ) oBrw:colorSpec( cColor ) - oBrw:headSep := hb_UTF8ToStr( "┐ ┌─" ) - oBrw:footSep := hb_UTF8ToStr( "┘ └─" ) - oBrw:colSep := hb_UTF8ToStr( "│ │" ) + oBrw:headSep := _DRAW_3 + oBrw:footSep := _DRAW_4 + oBrw:colSep := _DRAW_5 oBrw:SkipBlock := {| n | hb_idleSleep( 0.2 ), ; n := iif( n < 0, Max( n, 1 - s_nPos ), ; @@ -73,15 +95,15 @@ PROCEDURE Main() oCol2 := TBColumnNew( "COL;2", {|| s_nCount++ } ) oCol2:defColor := { 3, 4, 5, 6 } oCol2:footing := "counter" - oCol2:headSep := hb_UTF8ToStr( "┐ ┌─┤HIDE├─" ) + oCol2:headSep := _DRAW_6 oCol3 := TBColumnNew( "COL 3", {|| s_nPos % 3 == 0 } ) oCol3:defColor := { 5, 6, 2, 3 } oCol3:footing := "logical" oCol3:picture := "@YR [Y]" // Clipper wrongly calculate the size here - oCol3:headSep := hb_UTF8ToStr( "╖ ╓─┤HIDE├─" ) - oCol3:footSep := hb_UTF8ToStr( "╜ ╙─" ) - oCol3:colSep := hb_UTF8ToStr( "║ ║" ) + oCol3:headSep := _DRAW_7 + oCol3:footSep := _DRAW_8 + oCol3:colSep := _DRAW_9 oCol4 := TBColumnNew( " SHOW; ALL", {|| Date() - s_nPos } ) oCol4:defColor := { 6, 3, 4, 2 } diff --git a/harbour/tests/testbrw.prg b/harbour/tests/testbrw.prg index 18494520a8..8c402945e7 100644 --- a/harbour/tests/testbrw.prg +++ b/harbour/tests/testbrw.prg @@ -26,9 +26,9 @@ PROCEDURE Main() #endif oBrowse:colorSpec := "W+/B, N/BG" - oBrowse:ColSep := hb_UTF8ToStr( "│" ) - oBrowse:HeadSep := hb_UTF8ToStr( "╤═" ) - oBrowse:FootSep := hb_UTF8ToStr( "╧═" ) + oBrowse:ColSep := hb_UTF8ToStrBox( "│" ) + oBrowse:HeadSep := hb_UTF8ToStrBox( "╤═" ) + oBrowse:FootSep := hb_UTF8ToStrBox( "╧═" ) oBrowse:GoTopBlock := {|| n := 1 } oBrowse:GoBottomBlock := {|| n := Len( aTest0 ) } oBrowse:SkipBlock := {| nSkip, nPos | nPos := n, ; @@ -60,7 +60,7 @@ PROCEDURE Main() cColor := SetColor( "W+/B" ) nRow := Row() nCol := Col() - @ 4, 4, 17, 31 BOX hb_UTF8ToStr( "┌─┐│┘─└│ " ) + @ 4, 4, 17, 31 BOX hb_UTF8ToStrBox( "┌─┐│┘─└│ " ) #ifdef HB_COMPAT_C53 oBrowse:SetKey( 0, {| ob, nkey | Defproc( ob, nKey ) } ) WHILE .T.