2012-04-20 17:52 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* harbour/include/hbdefs.h
* moved HB_WCHAR definition from hbapicdp.h to hbdefs.h
* harbour/include/hbapicdp.h
* harbour/include/hbcdpreg.h
* harbour/src/rtl/cdpapi.c
* harbour/src/rtl/cdpapihb.c
+ added support for custom sorting redirected from HVM
+ added support for custom character indexes in strings
+ added support for custom character flags (upper, lower, alpha, digit)
+ added support for custom upper/lower conversions
+ added support for CPs using unicode character values instead of
ASCII ones
+ added new CP functions which respects custom CP settings:
hb_cdpUpperWC(), hb_cdpTextLen(), hb_cdpTextPos(),
hb_cdpTextPosEx(), hb_cdpTextGetU16(), hb_cdpTextPutU16(),
hb_cdpCharEq(), hb_cdpCharCaseEq()
+ added new conversion functions:
hb_cdpGetUC(), hb_cdpGetWC(), hb_cdpGetU16Ctrl()
+ added macros to detect codepage parameters:
HB_CDP_ISBINSORT() - codepage uses simple binary sorting
HB_CDP_ISCUSTOM() - codepage uses custom string decoding
HB_CDP_ISCHARIDX() - codepage use character indexes instead
of bytes ones
HB_CDP_ISCHARUNI() - CHR(), ASC() and similar functions operates
on Unicode values instead of bytes
HB_CDP_ISUTF8() - codepage uses UTF-8 encoding
* harbour/include/inkey.ch
- removed HB_INKEY_EXTENDED - it was not used in Harbour
+ added new flag HB_INKEY_EXT - it allows to used different
event encoding system with automatic translation to
standard Clipper values. It will be used in the future
as base for low level GTs code. Now it's possible to
selectively switch to the new system. New codes are
unique and do not interacts with Clipper.
+ added HB_INKEY_ALL macro - it's similar to INKEY_ALL but
enables also GTEVENT keys.
* harbour/include/hbgtcore.h
* harbour/src/rtl/hbgtcore.c
* changed character values in internal screen buffer to unicode.
Warning: this modification interacts with SAVESCREE()/RESTSCREEN()
data. Now all GTs uses extended definition. If somene
has code which needs VGA like screen buffers returned
by SAVESCREE() then it can be forced by
hb_gtInfo( HB_GTI_COMPATBUFFER, .t. )
Anyhow it will for to use only one CP in output.
+ added new GT methods which operated on HB_WCHAR values
* modified existing methods using HB_WCHAR/HB_USHORT parameters
to operate on HB_WCHAR values
+ added codepage conversion code directly to core code so it can
be eliminated from low level GT drivers which do not need some
special operations on it.
+ added support for extended inkey codes, they allow to encoded
unicode values, mouse events with flags, keyboard events with
modifier flags (shift,alt,ctrl,...), etc.
Now in low level GT code only unicode key values are used but
I plan to updated all GTs and switch to new code - it should
resolve many small problems inheriting with Clipper inkey codes.
* harbour/include/hbapifs.h
* moved hb_fsNameConvU16() definition from hbapicdp.h to hbapifs.h
* harbour/include/hbxvm.h
- removed comment copied by mistake from GT header file
* harbour/include/hbwinuni.h
* changed HB_CHARDUP() and HB_CHARDUPN() macros - now they
operate on functions which can be used without active HVM.
In such case ANSI CP is used as source encoding.
+ added new macros: HB_OSSTRDUP() and HB_OSSTRDUP2().
They make conversions from OS encoding to HVM one.
They can be used without active HVM and in such case ANSI CP
is used as destination encoding.
* harbour/include/hbapi.h
* harbour/src/vm/cmdarg.c
+ added new function hb_cmdargProgName()
It returns application name with path or NULL if not set,
caller must free returned value with hb_xfree() if not NULL.
The string is in HVM encoding so it does not need any additional
encodings.
* modified hb_cmdargString() to return strings in HVM encoding.
% some small code optimizations
; NOTE: parameters passed to MS-WINDOWS GUI programs which use
WinMain() instead of main() as startup entry are translated
to ANSICP before they can be accessed by application.
This can be eliminated though not for console programs
using where C compiler makes such translation to main()
parameters.
in all systems parameters are passed to application
startup and init functions before programmer can set OS CP.
This can be resolved by adding:
INIT PROC CLIPINIT()
SET( _SET_CODEPAGE, <userCP> )
SET( _SET_OSCODEPAGE, <systemCP> )
RETURN
to linked code. INIT procedures called CLIPINIT() are
executed before any other ones.
* harbour/include/hbapi.h
* harbour/src/vm/set.c
+ added new functions for CP converisons which can be used with
and without active HVM:
hb_osStrEncode(), hb_osStrEncodeN(),
hb_osStrDecode(), hb_osStrDecode2(),
hb_osStrU16Encode(), hb_osStrU16EncodeN(),
hb_osStrU16Decode(), hb_osStrU16Decode2(),
* harbour/include/hbvm.h
* harbour/src/vm/hvm.c
+ added new function hb_vmIsReady() - it's similar to hb_vmActive()
but it also checks if current thread has active HVM stack.
* moved hb_cdpReleaseAll() to the end of HVM cleanup code so
CP conversions are longer active.
* harbour/include/hbcomp.h
* harbour/src/compiler/cmdcheck.c
* harbour/src/compiler/hbusage.c
* harbour/src/common/expropt2.c
+ added new compiler switch:
-ku - strings in user encoding
Now it informs compiler that strings use custom encoding so some
optimizations which are byte oriented cannot be used.
It's possible that in the future we will change above definition
to sth like: "strings in UTF8 encoding" but now I would like to
keep more general.
* harbour/src/vm/macro.c
* inform macrocompiler about custom CPs using own character indexes
to disable byte oriented optimizations.
* harbour/include/hbapigt.h
* harbour/src/rtl/gtapi.c
* harbour/src/rtl/inkeyapi.c
+ added HB_B_*_W macros with unicode box character definitions
+ added HB_MBUTTON_* macros
+ added new GT functions: hb_gtHostCP() and hb_gtBoxCP() which
allows to extract CPs used in translations by GTs.
+ added new function hb_inkeyKeyString() - it converts inkey value
to corresponding string
+ added new function hb_inkeyKeyStd() - it converts new extended
key value to standard Clipper one.
* harbour/include/hbapifs.h
* harbour/src/common/hbffind.c
* moved OS codepage translations fully to hb_fsFind*() functions.
It fixes few problems which existed before, i.e. double CP
conversions in MS-Windows builds and simplifies upper level code.
* harbour/src/pp/hbpp.c
* harbour/src/rtl/direct.c
* harbour/src/rtl/fssize.c
* harbour/src/rtl/file.c
* harbour/contrib/hbct/files.c
* eliminated not longer necessary CP conversions in code calling
hb_fsFind*() functions.
* harbour/src/common/hbgete.c
* moved OS codepage translations to hb_getenv(), hb_getenv_buffer()
and hb_setenv() functions. It fixes few problems which existed
before, i.e. double CP conversions in MS-Windows builds and
simplifies upper level code.
* harbour/src/rtl/net.c
* harbour/src/rtl/gete.c
* eliminated not longer necessary CP conversions in code calling
hb_getenv()/hb_setenv() functions.
; NOTE: additional parameters in HB_GETENV() and HB_SETENV() which
disabled CP conversions are not longer supported.
They were strictly platform dependent and ignored in chosen
cases (i.e. in MS-Windows UNICODE builds we always have to
convert strings transferred between HVM and OS. If someone
needs old functionality for other platform then he should
temporary disable _SET_OSCODEPAGE.
* harbour/src/common/hbver.c
* harbour/src/common/hbfsapi.c
* harbour/src/rtl/fstemp.c
* harbour/src/rtl/fslink.c
* eliminated HB_TCHAR_*() macros
* harbour/src/common/strwild.c
+ added supprot for custom CPs using own character indexes in:
hb_strMatchWild(),
hb_strMatchWildExact(),
hb_strMatchCaseWildExact()
* harbour/src/nortl/nortl.c
+ added new dummy function replacement for binaries which are not
linked with HVM.
* harbour/src/rtl/filesys.c
! fixed double CP conversions in MS-Windows builds of hb_fsCurDirBuff()
* use hb_vmIsReady() instead of hb_stackId() in file name conversions.
* use hb_cmdargProgName() in hb_fsBaseDirBuff()
* harbour/src/rtl/philes.c
* use hb_cmdargProgName() in HB_PROGNAME() function.
* harbour/src/rtl/gtcgi/gtcgi.c
* harbour/src/rtl/gtstd/gtstd.c
* harbour/src/rtl/gtpca/gtpca.c
* harbour/src/rtl/gtdos/gtdos.c
* harbour/src/rtl/gtos2/gtos2.c
* harbour/src/rtl/gtwin/gtwin.c
* harbour/src/rtl/gtwvt/gtwvt.h
* harbour/src/rtl/gtwvt/gtwvt.c
* harbour/src/rtl/gttrm/gttrm.c
* harbour/src/rtl/gtcrs/gtcrs.c
* harbour/src/rtl/gtsln/gtsln.c
* harbour/src/rtl/gtsln/kbsln.c
* harbour/src/rtl/gtsln/gtsln.h
* harbour/src/rtl/gtxwc/gtxwc.h
* harbour/src/rtl/gtxwc/gtxwc.c
* harbour/contrib/gtwvg/gtwvg.c
* harbour/contrib/gtwvg/gtwvg.h
* harbour/contrib/gtalleg/gtalleg.c
* harbour/contrib/hbqt/gtqtc/gtqtc.cpp
* harbour/contrib/hbqt/gtqtc/gtqtc.h
* updated to work with new unicode GT API
please make tests with different GTs - I'm not able to test
all of them, i.e. I do not have any OS2 machine.
* harbour/src/rtl/box.c
* harbour/src/rtl/oldbox.c
* harbour/src/rtl/scroll.c
* harbour/src/rtl/console.c
* updated to work with new unicode GT API and
CPs using custom character indexes
* harbour/src/rtl/at.c
* harbour/src/rtl/ati.c
* harbour/src/rtl/rat.c
* harbour/src/rtl/len.c
* harbour/src/rtl/transfrm.c
* harbour/src/rtl/left.c
* harbour/src/rtl/right.c
* harbour/src/rtl/substr.c
* harbour/src/rtl/stuff.c
* harbour/src/rtl/padc.c
* harbour/src/rtl/padl.c
* harbour/src/rtl/padr.c
* updated to work with CPs using custom character indexes
* harbour/src/rtl/chrasc.c
+ added support for HB_CDP_ISCHARUNI() CPs.
* harbour/src/rtl/mlcfunc.c
* rewritten from scratch to work with CPs using custom character
indexes
* harbour/src/rtl/accept.c
* updated to work with unicode inkey values and
CPs using custom character indexes
* harbour/src/rtl/strmatch.c
% small optimization
* harbour/src/rtl/Makefile
+ harbour/src/rtl/chruni.c
+ added new PRG functions which allows to make byte/binary and
unicode/character operations on strings:
HB_UCHAR( <nCode> ) -> <cText>
return string with U+nCode character in HVM CP encoding
HB_BCHAR( <nCode> ) -> <cText>
return 1 byte string with <nCode> value
HB_UCODE( <cText> ) -> <nCode>
return unicode value of 1-st character (not byte) in given string
HB_BCODE( <cText> ) -> <nCode>
return value of 1-st byte in given string
HB_ULEN( <cText> ) -> <nChars>
return string length in characters
HB_BLEN( <cText> ) -> <nBytes>
return string length in bytes
HB_UPEEK( <cText>, <n> ) -> <nCode>
return unicode value of <n>-th character in given string
HB_BPEEK( <cText>, <n> ) -> <nCode>
return value of <n>-th byte in given string
HB_UPOKE( [@]<cText>, <n>, <nVal> ) -> <cText>
change <n>-th character in given string to unicode <nVal> one and
return modified text
HB_BPOKE( [@]<cText>, <n>, <nVal> ) -> <cText>
change <n>-th byte in given string to <nVal> and return modified
text
* harbour/src/rtl/hbdoc.prg
* harbour/src/rtl/memvarhb.prg
* use HB_BCHAR() for binary string definitions
* harbour/src/rtl/hbi18n2.prg
* use hb_utf8CHR( 0xFEFF ) instead of hardcoded binary sting and
HB_BLEN() instead of LEN()
* harbour/src/rtl/inkey.c
+ added new functions:
HB_KEYCHAR( <nKey> ) -> <cChar>
HB_KEYSTD( <nExtKey> ) -> <nClipKey>
! use HB_INKEY_ALL instead of INKEY_ALL in LASTKEY()
* harbour/src/rtl/achoice.prg
* harbour/src/rtl/browse.prg
* harbour/src/rtl/menuto.prg
* harbour/src/rtl/tgetlist.prg
* harbour/src/rtl/teditor.prg
* harbour/src/rtl/tlabel.prg
* harbour/src/rtl/tpopup.prg
* harbour/src/rtl/radiobtn.prg
* harbour/src/rtl/radiogrp.prg
* harbour/src/rtl/wait.prg
* updated to work with unicode inkey() values
* harbour/src/rtl/listbox.prg
* use box.ch macros instead of explicit CHR(...) definitions
* harbour/src/rtl/ttopbar.prg
* updated to work with different type of CPs
* harbour/src/rtl/scrollbr.prg
* formatting
* harbour/src/rtl/mouse53.c
* use HB_MBUTTON_* macros instead of local ones
* harbour/src/codepage/cp_utf8.c
+ harbour/src/codepage/uc16def.c
+ harbour/src/codepage/utf8sort.c
* replaced UTF8ASC with new CP: UTF8EX
This CP uses character indexes instead of bytes one
and operates on unicode characters flags.
Tables for upper/lower conversions and upper/lower/alpha/digit
flags were generated automatically from
http://www.unicode.org/Public/UNIDATA/UnicodeData.txt
It also uses custom collation rules. It's very simple one
level sorting based on UTF8 C collation.
If someone needs some advanced sorting rules, then it's enough
to create copy of this cp with user custom version of UTF8_cmp()
and UTF8_cmpi() functions, i.e. they can be redirected to some
external library like ICU (icu-project.org).
* harbour/contrib/hbct/ctwin.c
* harbour/contrib/hbct/ctwin.h
* harbour/contrib/hbct/ctwfunc.c
* added support for new unicode GT API
* harbour/contrib/xhb/xhbfunc.c
* redirected HB_CMDARGARGV() to HB_PROGNAME()
* harbour/contrib/hbnf/origin.c
* redirected FT_ORIGIN() to HB_PROGNAME()
* harbour/contrib/hbnf/getenvrn.c
! windows version of FT_GETE() fully rewritten - it should
fix well known problems reported to the devel list. Please test.
% small optimization for other systems
* harbour/contrib/hbfship/exec.c
* use hb_cmdargProgName() in EXECNAME()
+ harbour/tests/uc16_gen.prg
+ added code which generates tables with unicode character flags
from http://www.unicode.org/Public/UNIDATA/UnicodeData.txt.
harbour/src/codepage/uc16def.c was generated by this code.
* harbour/tests/inkeytst.prg
* harbour/tests/wvtext.prg
* harbour/tests/gtkeys.prg
* use HB_INKEY_ALL
* harbour/include/harbour.hbx
* harbour/include/hbcpage.hbx
* harbour/include/hblang.hbx
* regenerated
; It was quite big peace of modifications and for sure not everything
is well tested so please make test and report problems you will find.
; This is basic version which introduce to HVM CPs with custom encodings.
Some contrib code has to be updated to work correctly with it.
I hope that developers interesting in will make necessary updates.
I haven't touched GTWVW code at all - sorry but it needs very serious
work to make it production ready and fix all existing problems.
; Special thanks to OTC - this firm sponsored adding basic UTF8 support
to HVM.
This commit is contained in:
@@ -16,6 +16,392 @@
|
||||
The license applies to all entries newer than 2009-04-28.
|
||||
*/
|
||||
|
||||
2012-04-20 17:52 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||
* harbour/include/hbdefs.h
|
||||
* moved HB_WCHAR definition from hbapicdp.h to hbdefs.h
|
||||
|
||||
* harbour/include/hbapicdp.h
|
||||
* harbour/include/hbcdpreg.h
|
||||
* harbour/src/rtl/cdpapi.c
|
||||
* harbour/src/rtl/cdpapihb.c
|
||||
+ added support for custom sorting redirected from HVM
|
||||
+ added support for custom character indexes in strings
|
||||
+ added support for custom character flags (upper, lower, alpha, digit)
|
||||
+ added support for custom upper/lower conversions
|
||||
+ added support for CPs using unicode character values instead of
|
||||
ASCII ones
|
||||
+ added new CP functions which respects custom CP settings:
|
||||
hb_cdpUpperWC(), hb_cdpTextLen(), hb_cdpTextPos(),
|
||||
hb_cdpTextPosEx(), hb_cdpTextGetU16(), hb_cdpTextPutU16(),
|
||||
hb_cdpCharEq(), hb_cdpCharCaseEq()
|
||||
+ added new conversion functions:
|
||||
hb_cdpGetUC(), hb_cdpGetWC(), hb_cdpGetU16Ctrl()
|
||||
+ added macros to detect codepage parameters:
|
||||
HB_CDP_ISBINSORT() - codepage uses simple binary sorting
|
||||
HB_CDP_ISCUSTOM() - codepage uses custom string decoding
|
||||
HB_CDP_ISCHARIDX() - codepage use character indexes instead
|
||||
of bytes ones
|
||||
HB_CDP_ISCHARUNI() - CHR(), ASC() and similar functions operates
|
||||
on Unicode values instead of bytes
|
||||
HB_CDP_ISUTF8() - codepage uses UTF-8 encoding
|
||||
|
||||
* harbour/include/inkey.ch
|
||||
- removed HB_INKEY_EXTENDED - it was not used in Harbour
|
||||
+ added new flag HB_INKEY_EXT - it allows to used different
|
||||
event encoding system with automatic translation to
|
||||
standard Clipper values. It will be used in the future
|
||||
as base for low level GTs code. Now it's possible to
|
||||
selectively switch to the new system. New codes are
|
||||
unique and do not interacts with Clipper.
|
||||
+ added HB_INKEY_ALL macro - it's similar to INKEY_ALL but
|
||||
enables also GTEVENT keys.
|
||||
|
||||
* harbour/include/hbgtcore.h
|
||||
* harbour/src/rtl/hbgtcore.c
|
||||
* changed character values in internal screen buffer to unicode.
|
||||
Warning: this modification interacts with SAVESCREE()/RESTSCREEN()
|
||||
data. Now all GTs uses extended definition. If somene
|
||||
has code which needs VGA like screen buffers returned
|
||||
by SAVESCREE() then it can be forced by
|
||||
hb_gtInfo( HB_GTI_COMPATBUFFER, .t. )
|
||||
Anyhow it will for to use only one CP in output.
|
||||
+ added new GT methods which operated on HB_WCHAR values
|
||||
* modified existing methods using HB_WCHAR/HB_USHORT parameters
|
||||
to operate on HB_WCHAR values
|
||||
+ added codepage conversion code directly to core code so it can
|
||||
be eliminated from low level GT drivers which do not need some
|
||||
special operations on it.
|
||||
+ added support for extended inkey codes, they allow to encoded
|
||||
unicode values, mouse events with flags, keyboard events with
|
||||
modifier flags (shift,alt,ctrl,...), etc.
|
||||
Now in low level GT code only unicode key values are used but
|
||||
I plan to updated all GTs and switch to new code - it should
|
||||
resolve many small problems inheriting with Clipper inkey codes.
|
||||
|
||||
* harbour/include/hbapifs.h
|
||||
* moved hb_fsNameConvU16() definition from hbapicdp.h to hbapifs.h
|
||||
|
||||
* harbour/include/hbxvm.h
|
||||
- removed comment copied by mistake from GT header file
|
||||
|
||||
* harbour/include/hbwinuni.h
|
||||
* changed HB_CHARDUP() and HB_CHARDUPN() macros - now they
|
||||
operate on functions which can be used without active HVM.
|
||||
In such case ANSI CP is used as source encoding.
|
||||
+ added new macros: HB_OSSTRDUP() and HB_OSSTRDUP2().
|
||||
They make conversions from OS encoding to HVM one.
|
||||
They can be used without active HVM and in such case ANSI CP
|
||||
is used as destination encoding.
|
||||
|
||||
* harbour/include/hbapi.h
|
||||
* harbour/src/vm/cmdarg.c
|
||||
+ added new function hb_cmdargProgName()
|
||||
It returns application name with path or NULL if not set,
|
||||
caller must free returned value with hb_xfree() if not NULL.
|
||||
The string is in HVM encoding so it does not need any additional
|
||||
encodings.
|
||||
* modified hb_cmdargString() to return strings in HVM encoding.
|
||||
% some small code optimizations
|
||||
; NOTE: parameters passed to MS-WINDOWS GUI programs which use
|
||||
WinMain() instead of main() as startup entry are translated
|
||||
to ANSICP before they can be accessed by application.
|
||||
This can be eliminated though not for console programs
|
||||
using where C compiler makes such translation to main()
|
||||
parameters.
|
||||
in all systems parameters are passed to application
|
||||
startup and init functions before programmer can set OS CP.
|
||||
This can be resolved by adding:
|
||||
INIT PROC CLIPINIT()
|
||||
SET( _SET_CODEPAGE, <userCP> )
|
||||
SET( _SET_OSCODEPAGE, <systemCP> )
|
||||
RETURN
|
||||
to linked code. INIT procedures called CLIPINIT() are
|
||||
executed before any other ones.
|
||||
|
||||
* harbour/include/hbapi.h
|
||||
* harbour/src/vm/set.c
|
||||
+ added new functions for CP converisons which can be used with
|
||||
and without active HVM:
|
||||
hb_osStrEncode(), hb_osStrEncodeN(),
|
||||
hb_osStrDecode(), hb_osStrDecode2(),
|
||||
hb_osStrU16Encode(), hb_osStrU16EncodeN(),
|
||||
hb_osStrU16Decode(), hb_osStrU16Decode2(),
|
||||
|
||||
* harbour/include/hbvm.h
|
||||
* harbour/src/vm/hvm.c
|
||||
+ added new function hb_vmIsReady() - it's similar to hb_vmActive()
|
||||
but it also checks if current thread has active HVM stack.
|
||||
* moved hb_cdpReleaseAll() to the end of HVM cleanup code so
|
||||
CP conversions are longer active.
|
||||
|
||||
* harbour/include/hbcomp.h
|
||||
* harbour/src/compiler/cmdcheck.c
|
||||
* harbour/src/compiler/hbusage.c
|
||||
* harbour/src/common/expropt2.c
|
||||
+ added new compiler switch:
|
||||
-ku - strings in user encoding
|
||||
Now it informs compiler that strings use custom encoding so some
|
||||
optimizations which are byte oriented cannot be used.
|
||||
It's possible that in the future we will change above definition
|
||||
to sth like: "strings in UTF8 encoding" but now I would like to
|
||||
keep more general.
|
||||
|
||||
* harbour/src/vm/macro.c
|
||||
* inform macrocompiler about custom CPs using own character indexes
|
||||
to disable byte oriented optimizations.
|
||||
|
||||
* harbour/include/hbapigt.h
|
||||
* harbour/src/rtl/gtapi.c
|
||||
* harbour/src/rtl/inkeyapi.c
|
||||
+ added HB_B_*_W macros with unicode box character definitions
|
||||
+ added HB_MBUTTON_* macros
|
||||
+ added new GT functions: hb_gtHostCP() and hb_gtBoxCP() which
|
||||
allows to extract CPs used in translations by GTs.
|
||||
+ added new function hb_inkeyKeyString() - it converts inkey value
|
||||
to corresponding string
|
||||
+ added new function hb_inkeyKeyStd() - it converts new extended
|
||||
key value to standard Clipper one.
|
||||
|
||||
* harbour/include/hbapifs.h
|
||||
* harbour/src/common/hbffind.c
|
||||
* moved OS codepage translations fully to hb_fsFind*() functions.
|
||||
It fixes few problems which existed before, i.e. double CP
|
||||
conversions in MS-Windows builds and simplifies upper level code.
|
||||
|
||||
* harbour/src/pp/hbpp.c
|
||||
* harbour/src/rtl/direct.c
|
||||
* harbour/src/rtl/fssize.c
|
||||
* harbour/src/rtl/file.c
|
||||
* harbour/contrib/hbct/files.c
|
||||
* eliminated not longer necessary CP conversions in code calling
|
||||
hb_fsFind*() functions.
|
||||
|
||||
* harbour/src/common/hbgete.c
|
||||
* moved OS codepage translations to hb_getenv(), hb_getenv_buffer()
|
||||
and hb_setenv() functions. It fixes few problems which existed
|
||||
before, i.e. double CP conversions in MS-Windows builds and
|
||||
simplifies upper level code.
|
||||
|
||||
* harbour/src/rtl/net.c
|
||||
* harbour/src/rtl/gete.c
|
||||
* eliminated not longer necessary CP conversions in code calling
|
||||
hb_getenv()/hb_setenv() functions.
|
||||
; NOTE: additional parameters in HB_GETENV() and HB_SETENV() which
|
||||
disabled CP conversions are not longer supported.
|
||||
They were strictly platform dependent and ignored in chosen
|
||||
cases (i.e. in MS-Windows UNICODE builds we always have to
|
||||
convert strings transferred between HVM and OS. If someone
|
||||
needs old functionality for other platform then he should
|
||||
temporary disable _SET_OSCODEPAGE.
|
||||
|
||||
* harbour/src/common/hbver.c
|
||||
* harbour/src/common/hbfsapi.c
|
||||
* harbour/src/rtl/fstemp.c
|
||||
* harbour/src/rtl/fslink.c
|
||||
* eliminated HB_TCHAR_*() macros
|
||||
|
||||
* harbour/src/common/strwild.c
|
||||
+ added supprot for custom CPs using own character indexes in:
|
||||
hb_strMatchWild(),
|
||||
hb_strMatchWildExact(),
|
||||
hb_strMatchCaseWildExact()
|
||||
|
||||
* harbour/src/nortl/nortl.c
|
||||
+ added new dummy function replacement for binaries which are not
|
||||
linked with HVM.
|
||||
|
||||
* harbour/src/rtl/filesys.c
|
||||
! fixed double CP conversions in MS-Windows builds of hb_fsCurDirBuff()
|
||||
* use hb_vmIsReady() instead of hb_stackId() in file name conversions.
|
||||
* use hb_cmdargProgName() in hb_fsBaseDirBuff()
|
||||
|
||||
* harbour/src/rtl/philes.c
|
||||
* use hb_cmdargProgName() in HB_PROGNAME() function.
|
||||
|
||||
* harbour/src/rtl/gtcgi/gtcgi.c
|
||||
* harbour/src/rtl/gtstd/gtstd.c
|
||||
* harbour/src/rtl/gtpca/gtpca.c
|
||||
* harbour/src/rtl/gtdos/gtdos.c
|
||||
* harbour/src/rtl/gtos2/gtos2.c
|
||||
* harbour/src/rtl/gtwin/gtwin.c
|
||||
* harbour/src/rtl/gtwvt/gtwvt.h
|
||||
* harbour/src/rtl/gtwvt/gtwvt.c
|
||||
* harbour/src/rtl/gttrm/gttrm.c
|
||||
* harbour/src/rtl/gtcrs/gtcrs.c
|
||||
* harbour/src/rtl/gtsln/gtsln.c
|
||||
* harbour/src/rtl/gtsln/kbsln.c
|
||||
* harbour/src/rtl/gtsln/gtsln.h
|
||||
* harbour/src/rtl/gtxwc/gtxwc.h
|
||||
* harbour/src/rtl/gtxwc/gtxwc.c
|
||||
* harbour/contrib/gtwvg/gtwvg.c
|
||||
* harbour/contrib/gtwvg/gtwvg.h
|
||||
* harbour/contrib/gtalleg/gtalleg.c
|
||||
* harbour/contrib/hbqt/gtqtc/gtqtc.cpp
|
||||
* harbour/contrib/hbqt/gtqtc/gtqtc.h
|
||||
* updated to work with new unicode GT API
|
||||
please make tests with different GTs - I'm not able to test
|
||||
all of them, i.e. I do not have any OS2 machine.
|
||||
|
||||
* harbour/src/rtl/box.c
|
||||
* harbour/src/rtl/oldbox.c
|
||||
* harbour/src/rtl/scroll.c
|
||||
* harbour/src/rtl/console.c
|
||||
* updated to work with new unicode GT API and
|
||||
CPs using custom character indexes
|
||||
|
||||
* harbour/src/rtl/at.c
|
||||
* harbour/src/rtl/ati.c
|
||||
* harbour/src/rtl/rat.c
|
||||
* harbour/src/rtl/len.c
|
||||
* harbour/src/rtl/transfrm.c
|
||||
* harbour/src/rtl/left.c
|
||||
* harbour/src/rtl/right.c
|
||||
* harbour/src/rtl/substr.c
|
||||
* harbour/src/rtl/stuff.c
|
||||
* harbour/src/rtl/padc.c
|
||||
* harbour/src/rtl/padl.c
|
||||
* harbour/src/rtl/padr.c
|
||||
* updated to work with CPs using custom character indexes
|
||||
|
||||
* harbour/src/rtl/chrasc.c
|
||||
+ added support for HB_CDP_ISCHARUNI() CPs.
|
||||
|
||||
* harbour/src/rtl/mlcfunc.c
|
||||
* rewritten from scratch to work with CPs using custom character
|
||||
indexes
|
||||
|
||||
* harbour/src/rtl/accept.c
|
||||
* updated to work with unicode inkey values and
|
||||
CPs using custom character indexes
|
||||
|
||||
* harbour/src/rtl/strmatch.c
|
||||
% small optimization
|
||||
|
||||
* harbour/src/rtl/Makefile
|
||||
+ harbour/src/rtl/chruni.c
|
||||
+ added new PRG functions which allows to make byte/binary and
|
||||
unicode/character operations on strings:
|
||||
HB_UCHAR( <nCode> ) -> <cText>
|
||||
return string with U+nCode character in HVM CP encoding
|
||||
HB_BCHAR( <nCode> ) -> <cText>
|
||||
return 1 byte string with <nCode> value
|
||||
HB_UCODE( <cText> ) -> <nCode>
|
||||
return unicode value of 1-st character (not byte) in given string
|
||||
HB_BCODE( <cText> ) -> <nCode>
|
||||
return value of 1-st byte in given string
|
||||
HB_ULEN( <cText> ) -> <nChars>
|
||||
return string length in characters
|
||||
HB_BLEN( <cText> ) -> <nBytes>
|
||||
return string length in bytes
|
||||
HB_UPEEK( <cText>, <n> ) -> <nCode>
|
||||
return unicode value of <n>-th character in given string
|
||||
HB_BPEEK( <cText>, <n> ) -> <nCode>
|
||||
return value of <n>-th byte in given string
|
||||
HB_UPOKE( [@]<cText>, <n>, <nVal> ) -> <cText>
|
||||
change <n>-th character in given string to unicode <nVal> one and
|
||||
return modified text
|
||||
HB_BPOKE( [@]<cText>, <n>, <nVal> ) -> <cText>
|
||||
change <n>-th byte in given string to <nVal> and return modified
|
||||
text
|
||||
|
||||
* harbour/src/rtl/hbdoc.prg
|
||||
* harbour/src/rtl/memvarhb.prg
|
||||
* use HB_BCHAR() for binary string definitions
|
||||
|
||||
* harbour/src/rtl/hbi18n2.prg
|
||||
* use hb_utf8CHR( 0xFEFF ) instead of hardcoded binary sting and
|
||||
HB_BLEN() instead of LEN()
|
||||
|
||||
* harbour/src/rtl/inkey.c
|
||||
+ added new functions:
|
||||
HB_KEYCHAR( <nKey> ) -> <cChar>
|
||||
HB_KEYSTD( <nExtKey> ) -> <nClipKey>
|
||||
! use HB_INKEY_ALL instead of INKEY_ALL in LASTKEY()
|
||||
|
||||
* harbour/src/rtl/achoice.prg
|
||||
* harbour/src/rtl/browse.prg
|
||||
* harbour/src/rtl/menuto.prg
|
||||
* harbour/src/rtl/tgetlist.prg
|
||||
* harbour/src/rtl/teditor.prg
|
||||
* harbour/src/rtl/tlabel.prg
|
||||
* harbour/src/rtl/tpopup.prg
|
||||
* harbour/src/rtl/radiobtn.prg
|
||||
* harbour/src/rtl/radiogrp.prg
|
||||
* harbour/src/rtl/wait.prg
|
||||
* updated to work with unicode inkey() values
|
||||
|
||||
* harbour/src/rtl/listbox.prg
|
||||
* use box.ch macros instead of explicit CHR(...) definitions
|
||||
|
||||
* harbour/src/rtl/ttopbar.prg
|
||||
* updated to work with different type of CPs
|
||||
|
||||
* harbour/src/rtl/scrollbr.prg
|
||||
* formatting
|
||||
|
||||
* harbour/src/rtl/mouse53.c
|
||||
* use HB_MBUTTON_* macros instead of local ones
|
||||
|
||||
* harbour/src/codepage/cp_utf8.c
|
||||
+ harbour/src/codepage/uc16def.c
|
||||
+ harbour/src/codepage/utf8sort.c
|
||||
* replaced UTF8ASC with new CP: UTF8EX
|
||||
This CP uses character indexes instead of bytes one
|
||||
and operates on unicode characters flags.
|
||||
Tables for upper/lower conversions and upper/lower/alpha/digit
|
||||
flags were generated automatically from
|
||||
http://www.unicode.org/Public/UNIDATA/UnicodeData.txt
|
||||
It also uses custom collation rules. It's very simple one
|
||||
level sorting based on UTF8 C collation.
|
||||
If someone needs some advanced sorting rules, then it's enough
|
||||
to create copy of this cp with user custom version of UTF8_cmp()
|
||||
and UTF8_cmpi() functions, i.e. they can be redirected to some
|
||||
external library like ICU (icu-project.org).
|
||||
|
||||
* harbour/contrib/hbct/ctwin.c
|
||||
* harbour/contrib/hbct/ctwin.h
|
||||
* harbour/contrib/hbct/ctwfunc.c
|
||||
* added support for new unicode GT API
|
||||
|
||||
* harbour/contrib/xhb/xhbfunc.c
|
||||
* redirected HB_CMDARGARGV() to HB_PROGNAME()
|
||||
|
||||
* harbour/contrib/hbnf/origin.c
|
||||
* redirected FT_ORIGIN() to HB_PROGNAME()
|
||||
|
||||
* harbour/contrib/hbnf/getenvrn.c
|
||||
! windows version of FT_GETE() fully rewritten - it should
|
||||
fix well known problems reported to the devel list. Please test.
|
||||
% small optimization for other systems
|
||||
|
||||
* harbour/contrib/hbfship/exec.c
|
||||
* use hb_cmdargProgName() in EXECNAME()
|
||||
|
||||
+ harbour/tests/uc16_gen.prg
|
||||
+ added code which generates tables with unicode character flags
|
||||
from http://www.unicode.org/Public/UNIDATA/UnicodeData.txt.
|
||||
harbour/src/codepage/uc16def.c was generated by this code.
|
||||
|
||||
* harbour/tests/inkeytst.prg
|
||||
* harbour/tests/wvtext.prg
|
||||
* harbour/tests/gtkeys.prg
|
||||
* use HB_INKEY_ALL
|
||||
|
||||
* harbour/include/harbour.hbx
|
||||
* harbour/include/hbcpage.hbx
|
||||
* harbour/include/hblang.hbx
|
||||
* regenerated
|
||||
|
||||
; It was quite big peace of modifications and for sure not everything
|
||||
is well tested so please make test and report problems you will find.
|
||||
; This is basic version which introduce to HVM CPs with custom encodings.
|
||||
Some contrib code has to be updated to work correctly with it.
|
||||
I hope that developers interesting in will make necessary updates.
|
||||
I haven't touched GTWVW code at all - sorry but it needs very serious
|
||||
work to make it production ready and fix all existing problems.
|
||||
; Special thanks to OTC - this firm sponsored adding basic UTF8 support
|
||||
to HVM.
|
||||
|
||||
2012-04-20 08:14 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||
* harbour/src/common/hbffind.c
|
||||
! fixed stupid typo in my previous commit which caused
|
||||
|
||||
@@ -1061,7 +1061,7 @@ static void hb_gt_alleg_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
{
|
||||
int iColor;
|
||||
HB_BYTE bAttr;
|
||||
HB_USHORT usChar;
|
||||
HB_UCHAR uc;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_alleg_Redraw(%p,%d,%d,%d)", pGT, iRow, iCol, iSize ) );
|
||||
|
||||
@@ -1077,10 +1077,10 @@ static void hb_gt_alleg_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
|
||||
while( iSize-- )
|
||||
{
|
||||
if( ! HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol++, &iColor, &bAttr, &usChar ) )
|
||||
if( ! HB_GTSELF_GETSCRUC( pGT, iRow, iCol++, &iColor, &bAttr, &uc, HB_TRUE ) )
|
||||
break;
|
||||
al_draw_rect_fill( s_bmp, iPosX, iPosY, iPosX + s_byFontWidth - 1, iPosY + s_byFontSize - 1, s_pClr[ ( iColor >> 4 ) & 0x0F ] );
|
||||
ssfDrawChar( s_bmp, &s_ssfDefaultFont, ( char ) usChar, iPosX, iPosY, s_pClr[ iColor & 0x0F ] );
|
||||
ssfDrawChar( s_bmp, &s_ssfDefaultFont, uc, iPosX, iPosY, s_pClr[ iColor & 0x0F ] );
|
||||
iPosX += s_byFontWidth;
|
||||
}
|
||||
}
|
||||
@@ -1090,10 +1090,10 @@ static void hb_gt_alleg_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
|
||||
while( iSize-- )
|
||||
{
|
||||
if( ! HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol++, &iColor, &bAttr, &usChar ) )
|
||||
if( ! HB_GTSELF_GETSCRUC( pGT, iRow, iCol++, &iColor, &bAttr, &uc, HB_TRUE ) )
|
||||
break;
|
||||
|
||||
if( iColor != iDefColor || usChar != ' ' )
|
||||
if( iColor != iDefColor || uc != ' ' )
|
||||
{
|
||||
s_fMakeInit = HB_TRUE;
|
||||
break;
|
||||
|
||||
@@ -458,17 +458,6 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, HINSTANCE hInstance, int iCmdShow )
|
||||
pWVT->pPP->bRowCols = HB_FALSE;
|
||||
pWVT->pPP->iWndType = 0;
|
||||
|
||||
#if defined( UNICODE )
|
||||
/* pWVT->hostCDP = pWVT->inCDP = hb_vmCDP(); */
|
||||
pWVT->boxCDP = hb_cdpFind( "EN" );
|
||||
#else
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < 256; ++i )
|
||||
pWVT->chrTransTbl[ i ] = pWVT->keyTransTbl[ i ] = ( HB_BYTE ) i;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* GUI Related members initialized */
|
||||
hb_wvt_gtCreateObjects( pWVT );
|
||||
|
||||
@@ -879,7 +868,7 @@ static HB_BOOL hb_gt_wvt_FitSize( PHB_GTWVT pWVT )
|
||||
tm.tmAveCharWidth >= 3 &&
|
||||
tm.tmHeight >= 4 )
|
||||
{
|
||||
#if ! defined( UNICODE )
|
||||
#if !defined( UNICODE )
|
||||
if( pWVT->hFontBox && pWVT->hFontBox != pWVT->hFont )
|
||||
DeleteObject( pWVT->hFontBox );
|
||||
|
||||
@@ -1029,7 +1018,7 @@ static void hb_gt_wvt_ResetWindowSize( PHB_GTWVT pWVT )
|
||||
DeleteObject( pWVT->hFont );
|
||||
pWVT->hFont = hFont;
|
||||
|
||||
#if ! defined( UNICODE )
|
||||
#if !defined( UNICODE )
|
||||
if( pWVT->hFontBox )
|
||||
DeleteObject( pWVT->hFontBox );
|
||||
if( pWVT->CodePage == pWVT->boxCodePage )
|
||||
@@ -1271,9 +1260,13 @@ static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, L
|
||||
RedrawWindow( pWVT->hWnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW );
|
||||
|
||||
{
|
||||
HB_SIZE ulSize;
|
||||
#if !defined( UNICODE )
|
||||
PHB_CODEPAGE cdpHost = HB_GTSELF_HOSTCP( pWVT->pGT ),
|
||||
cdpBox = HB_GTSELF_BOXCP( pWVT->pGT );
|
||||
#endif
|
||||
TCHAR * sBuffer;
|
||||
HB_SIZE nSize;
|
||||
int irow, icol, j, top, left, bottom, right;
|
||||
char * sBuffer;
|
||||
RECT rect = { 0, 0, 0, 0 };
|
||||
RECT colrowRC = { 0, 0, 0, 0 };
|
||||
|
||||
@@ -1289,8 +1282,8 @@ static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, L
|
||||
right = colrowRC.right;
|
||||
bottom = colrowRC.bottom;
|
||||
|
||||
ulSize = ( ( bottom - top + 1 ) * ( right - left + 1 + 2 ) );
|
||||
sBuffer = ( char * ) hb_xgrab( ulSize + 1 );
|
||||
nSize = ( ( bottom - top + 1 ) * ( right - left + 1 + 2 ) );
|
||||
sBuffer = ( TCHAR * ) hb_xgrab( nSize * sizeof( TCHAR ) + 1 );
|
||||
|
||||
for( j = 0, irow = top; irow <= bottom; irow++ )
|
||||
{
|
||||
@@ -1302,28 +1295,36 @@ static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, L
|
||||
|
||||
if( !HB_GTSELF_GETSCRCHAR( pWVT->pGT, irow, icol, &iColor, &bAttr, &usChar ) )
|
||||
break;
|
||||
|
||||
sBuffer[ j++ ] = ( char ) usChar;
|
||||
#if defined( UNICODE )
|
||||
usChar = hb_cdpGetU16Ctrl( usChar );
|
||||
#else
|
||||
usChar = hb_cdpGetUC( bAttr & HB_GT_ATTR_BOX ? cdpBox : cdpHost, usChar, '?' );
|
||||
#endif
|
||||
sBuffer[ j++ ] = ( TCHAR ) usChar;
|
||||
}
|
||||
|
||||
sBuffer[ j++ ] = '\r';
|
||||
sBuffer[ j++ ] = '\n';
|
||||
}
|
||||
sBuffer[ j ] = '\0';
|
||||
|
||||
#if defined( UNICODE )
|
||||
if( j > 0 )
|
||||
{
|
||||
PHB_ITEM pItem = hb_itemPutStrLenU16( NULL, HB_CDP_ENDIAN_NATIVE, sBuffer, j );
|
||||
hb_gt_winapi_setClipboard( CF_UNICODETEXT, pItem );
|
||||
hb_itemRelease( pItem );
|
||||
}
|
||||
hb_xfree( sBuffer );
|
||||
#else
|
||||
if( j > 0 )
|
||||
{
|
||||
PHB_ITEM pItem = hb_itemPutCLPtr( NULL, sBuffer, j );
|
||||
#if defined( UNICODE )
|
||||
hb_gt_winapi_setClipboard( CF_UNICODETEXT, pItem );
|
||||
#else
|
||||
hb_gt_winapi_setClipboard( pWVT->CodePage == OEM_CHARSET ?
|
||||
CF_OEMTEXT : CF_TEXT, pItem );
|
||||
#endif
|
||||
hb_itemRelease( pItem );
|
||||
}
|
||||
else
|
||||
hb_xfree( sBuffer );
|
||||
#endif
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1639,16 +1640,16 @@ static HB_BOOL hb_gt_wvt_KeyEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam,
|
||||
break;
|
||||
default:
|
||||
#if defined( UNICODE )
|
||||
c = hb_cdpGetChar( pWVT->inCDP ? pWVT->inCDP : hb_vmCDP(),
|
||||
( HB_WCHAR ) c );
|
||||
if( c >= 127 )
|
||||
c = HB_INKEY_NEW_UNICODE( c );
|
||||
#else
|
||||
if( pWVT->fKeyTrans )
|
||||
{
|
||||
if( c > 0 && c <= 255 && pWVT->keyTransTbl[ c ] )
|
||||
c = pWVT->keyTransTbl[ c ];
|
||||
int u = HB_GTSELF_KEYTRANS( pWVT->pGT, c );
|
||||
if( u )
|
||||
c = HB_INKEY_NEW_UNICODE( u );
|
||||
else if( pWVT->CodePage == OEM_CHARSET )
|
||||
c = hb_gt_wvt_key_ansi_to_oem( c );
|
||||
}
|
||||
else if( pWVT->CodePage == OEM_CHARSET )
|
||||
c = hb_gt_wvt_key_ansi_to_oem( c );
|
||||
#endif
|
||||
hb_gt_wvt_AddCharToInputQueue( pWVT, c );
|
||||
break;
|
||||
@@ -1824,12 +1825,9 @@ static void hb_gt_wvt_PaintText( PHB_GTWVT pWVT, RECT updateRect )
|
||||
int iRow, iCol, startCol, len;
|
||||
int iColor, iOldColor = 0;
|
||||
HB_BYTE bAttr;
|
||||
#if defined( UNICODE )
|
||||
PHB_CODEPAGE hostCDP;
|
||||
#else
|
||||
#if !defined( UNICODE )
|
||||
HFONT hFont, hOldFont = NULL;
|
||||
#endif
|
||||
HB_USHORT usChar;
|
||||
TCHAR text[ WVT_MAX_ROWS ];
|
||||
|
||||
if( pWVT->bGui && pWVT->bKillFocus )
|
||||
@@ -1886,7 +1884,6 @@ static void hb_gt_wvt_PaintText( PHB_GTWVT pWVT, RECT updateRect )
|
||||
|
||||
#if defined( UNICODE )
|
||||
SelectObject( hdc, pWVT->hFont );
|
||||
hostCDP = pWVT->hostCDP ? pWVT->hostCDP : hb_vmCDP();
|
||||
#endif
|
||||
|
||||
for( iRow = rcRect.top; iRow <= rcRect.bottom; ++iRow )
|
||||
@@ -1896,12 +1893,13 @@ static void hb_gt_wvt_PaintText( PHB_GTWVT pWVT, RECT updateRect )
|
||||
|
||||
while( iCol <= rcRect.right )
|
||||
{
|
||||
#if defined( UNICODE )
|
||||
HB_USHORT usChar;
|
||||
if( !HB_GTSELF_GETSCRCHAR( pWVT->pGT, iRow, iCol, &iColor, &bAttr, &usChar ) )
|
||||
break;
|
||||
usChar = hb_cdpGetU16Ctrl( usChar );
|
||||
|
||||
iColor &= 0xff;
|
||||
#if defined( UNICODE )
|
||||
usChar = hb_cdpGetU16Disp( bAttr & HB_GT_ATTR_BOX ? pWVT->boxCDP : hostCDP, ( HB_BYTE ) usChar );
|
||||
if( len == 0 )
|
||||
{
|
||||
iOldColor = iColor;
|
||||
@@ -1913,8 +1911,11 @@ static void hb_gt_wvt_PaintText( PHB_GTWVT pWVT, RECT updateRect )
|
||||
startCol = iCol;
|
||||
len = 0;
|
||||
}
|
||||
text[ len++ ] = ( TCHAR ) usChar;
|
||||
#else
|
||||
usChar = pWVT->chrTransTbl[ usChar & 0xFF ];
|
||||
HB_UCHAR uc;
|
||||
if( !HB_GTSELF_GETSCRUC( pWVT->pGT, iRow, iCol, &iColor, &bAttr, &uc, HB_TRUE ) )
|
||||
break;
|
||||
hFont = ( bAttr & HB_GT_ATTR_BOX ) ? pWVT->hFontBox : pWVT->hFont;
|
||||
if( len == 0 )
|
||||
{
|
||||
@@ -1937,8 +1938,8 @@ static void hb_gt_wvt_PaintText( PHB_GTWVT pWVT, RECT updateRect )
|
||||
startCol = iCol;
|
||||
len = 0;
|
||||
}
|
||||
text[ len++ ] = ( TCHAR ) uc;
|
||||
#endif
|
||||
text[ len++ ] = ( TCHAR ) usChar;
|
||||
iCol++;
|
||||
}
|
||||
if( len > 0 )
|
||||
@@ -3253,17 +3254,8 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
|
||||
}
|
||||
break;
|
||||
|
||||
#if !defined( UNICODE )
|
||||
case HB_GTI_BOXCP:
|
||||
#if defined( UNICODE )
|
||||
pInfo->pResult = hb_itemPutC( pInfo->pResult,
|
||||
pWVT->boxCDP ? pWVT->boxCDP->id : NULL );
|
||||
if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING )
|
||||
{
|
||||
PHB_CODEPAGE cdpBox = hb_cdpFind( hb_itemGetCPtr( pInfo->pNewVal ) );
|
||||
if( cdpBox )
|
||||
pWVT->boxCDP = cdpBox;
|
||||
}
|
||||
#else
|
||||
pInfo->pResult = hb_itemPutNI( pInfo->pResult, pWVT->boxCodePage );
|
||||
if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC )
|
||||
{
|
||||
@@ -3298,8 +3290,8 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
|
||||
case HB_GTI_ICONFILE:
|
||||
{
|
||||
@@ -4226,105 +4218,6 @@ static void hb_gt_wvt_Refresh( PHB_GT pGT )
|
||||
}
|
||||
}
|
||||
|
||||
/* ********************************************************************** */
|
||||
|
||||
static HB_BOOL hb_gt_wvt_SetDispCP( PHB_GT pGT, const char * pszTermCDP, const char * pszHostCDP, HB_BOOL fBox )
|
||||
{
|
||||
HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox );
|
||||
|
||||
# if defined( UNICODE )
|
||||
/*
|
||||
* We are displaying text in U16 so pszTermCDP is unimportant.
|
||||
* We only have to know what is the internal application codepage
|
||||
* to make proper translation
|
||||
*/
|
||||
if( !pszHostCDP || !*pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
|
||||
if( pszHostCDP && *pszHostCDP )
|
||||
{
|
||||
PHB_CODEPAGE cdpHost = hb_cdpFind( pszHostCDP );
|
||||
if( cdpHost )
|
||||
{
|
||||
PHB_GTWVT pWVT = HB_GTWVT_GET( pGT );
|
||||
|
||||
pWVT->hostCDP = cdpHost;
|
||||
pWVT->boxCDP = fBox ? cdpHost : hb_cdpFind( "EN" );
|
||||
}
|
||||
}
|
||||
# else
|
||||
{
|
||||
PHB_GTWVT pWVT = HB_GTWVT_GET( pGT );
|
||||
PHB_CODEPAGE cdpTerm, cdpHost;
|
||||
int i;
|
||||
|
||||
if( !pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
|
||||
if( !pszTermCDP )
|
||||
pszTermCDP = pszHostCDP;
|
||||
|
||||
cdpTerm = hb_cdpFind( pszTermCDP );
|
||||
cdpHost = hb_cdpFind( pszHostCDP );
|
||||
|
||||
for( i = 0; i < 256; i++ )
|
||||
{
|
||||
pWVT->chrTransTbl[ i ] = ( HB_BYTE )
|
||||
hb_cdpTranslateDispChar( i, cdpHost, cdpTerm );
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
static HB_BOOL hb_gt_wvt_SetKeyCP( PHB_GT pGT, const char * pszTermCDP, const char * pszHostCDP )
|
||||
{
|
||||
HB_GTSUPER_SETKEYCP( pGT, pszTermCDP, pszHostCDP );
|
||||
|
||||
# if defined( UNICODE )
|
||||
/*
|
||||
* We are receiving WM_CHAR events in U16 so pszTermCDP is unimportant.
|
||||
* We only have to know what is the internal application codepage
|
||||
* to make proper translation
|
||||
*/
|
||||
if( !pszHostCDP || !*pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
|
||||
if( pszHostCDP && *pszHostCDP )
|
||||
{
|
||||
PHB_CODEPAGE cdpHost = hb_cdpFind( pszHostCDP );
|
||||
if( cdpHost )
|
||||
HB_GTWVT_GET( pGT )->inCDP = cdpHost;
|
||||
}
|
||||
# else
|
||||
{
|
||||
PHB_GTWVT pWVT = HB_GTWVT_GET( pGT );
|
||||
PHB_CODEPAGE cdpTerm, cdpHost;
|
||||
int i;
|
||||
|
||||
if( !pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
|
||||
if( !pszTermCDP )
|
||||
pszTermCDP = pszHostCDP;
|
||||
|
||||
cdpTerm = hb_cdpFind( pszTermCDP );
|
||||
cdpHost = hb_cdpFind( pszHostCDP );
|
||||
|
||||
for( i = 0; i < 256; i++ )
|
||||
{
|
||||
pWVT->keyTransTbl[ i ] = ( HB_BYTE )
|
||||
hb_cdpTranslateChar( i, cdpTerm, cdpHost );
|
||||
}
|
||||
pWVT->fKeyTrans = HB_TRUE;
|
||||
}
|
||||
# endif
|
||||
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* ********************************************************************** */
|
||||
|
||||
static HB_BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable )
|
||||
@@ -4339,8 +4232,6 @@ static HB_BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable )
|
||||
pFuncTable->Version = hb_gt_wvt_Version;
|
||||
pFuncTable->Tone = hb_gt_wvt_Tone;
|
||||
pFuncTable->Info = hb_gt_wvt_Info;
|
||||
pFuncTable->SetDispCP = hb_gt_wvt_SetDispCP;
|
||||
pFuncTable->SetKeyCP = hb_gt_wvt_SetKeyCP;
|
||||
|
||||
pFuncTable->PutChar = hb_gt_wvt_PutChar;
|
||||
|
||||
|
||||
@@ -363,19 +363,6 @@ typedef struct
|
||||
HWND hWnd; /* the window handle */
|
||||
HB_BOOL fInit; /* logical variable indicating that window should be open */
|
||||
|
||||
#if defined( UNICODE )
|
||||
PHB_CODEPAGE inCDP; /* Host/HVM CodePage for unicode input translations */
|
||||
PHB_CODEPAGE hostCDP; /* Host/HVM CodePage for unicode output translations */
|
||||
PHB_CODEPAGE boxCDP; /* CodePage for legacy drawing chars: IBM437 */
|
||||
#else
|
||||
HB_BOOL fKeyTrans; /* logical variable indicating that CP key translation is enabled */
|
||||
#endif
|
||||
|
||||
#if !defined( UNICODE )
|
||||
HB_BYTE keyTransTbl[ 256 ];
|
||||
HB_BYTE chrTransTbl[ 256 ];
|
||||
#endif
|
||||
|
||||
HICON hIcon; /* Title Bar and Task List icon. Can be NULL. */
|
||||
HB_BOOL bIconToFree; /* Do we need to free this icon when it's not NULL? */
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapigt.h"
|
||||
#include "hbapistr.h"
|
||||
#include "ctwin.h"
|
||||
|
||||
static int hb_ctColorParam( int iParam, int iDefault )
|
||||
@@ -97,11 +98,17 @@ HB_FUNC( SETCLEARB )
|
||||
HB_USHORT usNew;
|
||||
|
||||
if( HB_ISNUM( 1 ) )
|
||||
usNew = ( HB_USHORT ) hb_parni( 1 );
|
||||
{
|
||||
int iChar = hb_parni( 1 );
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
if( !HB_CDP_ISCHARUNI( cdp ) )
|
||||
iChar = hb_cdpGetU16( cdp, ( HB_UCHAR ) iChar );
|
||||
usNew = ( HB_USHORT ) iChar;
|
||||
}
|
||||
else if( HB_ISCHAR( 1 ) )
|
||||
usNew = ( HB_USHORT ) hb_parc( 1 )[0];
|
||||
usNew = hb_cdpTextGetU16( hb_vmCDP(), hb_parc( 1 ), hb_parclen( 1 ) );
|
||||
else
|
||||
usNew = 255;
|
||||
usNew = ' '; /* CT uses 255 => U+00A0 in CP437 */
|
||||
|
||||
hb_gtSetClearChar( usNew );
|
||||
|
||||
@@ -110,7 +117,17 @@ HB_FUNC( SETCLEARB )
|
||||
|
||||
HB_FUNC( GETCLEARB )
|
||||
{
|
||||
hb_retni( hb_gtGetClearChar() );
|
||||
int iChar = hb_gtGetClearChar();
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
|
||||
if( !HB_CDP_ISCHARUNI( cdp ) )
|
||||
{
|
||||
HB_UCHAR uc = hb_cdpGetUC( cdp, ( HB_WCHAR ) iChar, 0 );
|
||||
if( uc )
|
||||
iChar = uc;
|
||||
}
|
||||
|
||||
hb_retni( iChar );
|
||||
}
|
||||
|
||||
HB_FUNC( WSETSHADOW )
|
||||
@@ -185,34 +202,35 @@ HB_FUNC( WNUM )
|
||||
|
||||
HB_FUNC( WBOX )
|
||||
{
|
||||
static const char * pWBoxFrames[] = {
|
||||
_B_DOUBLE, /* 0 WB_DOUBLE_CLEAR */
|
||||
_B_SINGLE, /* 1 WB_SINGLE_CLEAR */
|
||||
_B_DOUBLE_SINGLE, /* 2 WB_DOUBLE_SINGLE_CLEAR */
|
||||
_B_SINGLE_DOUBLE, /* 3 WB_SINGLE_DOUBLE_CLEAR */
|
||||
static const HB_WCHAR s_pWBoxFrames[ 16 ][ 9 ] = {
|
||||
HB_B_DOUBLE_W, /* 0 WB_DOUBLE_CLEAR */
|
||||
HB_B_SINGLE_W, /* 1 WB_SINGLE_CLEAR */
|
||||
HB_B_DOUBLE_SINGLE_W, /* 2 WB_DOUBLE_SINGLE_CLEAR */
|
||||
HB_B_SINGLE_DOUBLE_W, /* 3 WB_SINGLE_DOUBLE_CLEAR */
|
||||
|
||||
_B_DOUBLE, /* 4 WB_DOUBLE */
|
||||
_B_SINGLE, /* 5 WB_SINGLE */
|
||||
_B_DOUBLE_SINGLE, /* 6 WB_DOUBLE_SINGLE */
|
||||
_B_SINGLE_DOUBLE, /* 7 WB_SINGLE_DOUBLE */
|
||||
HB_B_DOUBLE_W, /* 4 WB_DOUBLE */
|
||||
HB_B_SINGLE_W, /* 5 WB_SINGLE */
|
||||
HB_B_DOUBLE_SINGLE_W, /* 6 WB_DOUBLE_SINGLE */
|
||||
HB_B_SINGLE_DOUBLE_W, /* 7 WB_SINGLE_DOUBLE */
|
||||
|
||||
"ÛßÛÛÛÜÛÛ", /* 8 WB_HALF_FULL_CLEAR */
|
||||
"ÞßÝÝÝÜÞÞ", /* 9 WB_HALF_CLEAR */
|
||||
"ÞÛÝÝÝÛÞÞ", /* 10 WB_FULL_HALF_CLEAR */
|
||||
"ÛÛÛÛÛÛÛÛ", /* 11 WB_FULL_CLEAR */
|
||||
HB_B_HALF_FULL_W, /* 8 WB_HALF_FULL_CLEAR */
|
||||
HB_B_HALF_W, /* 9 WB_HALF_CLEAR */
|
||||
HB_B_FULL_HALF_W, /* 10 WB_FULL_HALF_CLEAR */
|
||||
HB_B_FULL_W, /* 11 WB_FULL_CLEAR */
|
||||
|
||||
"ÛßÛÛÛÜÛÛ", /* 12 WB_HALF_FULL */
|
||||
"ÞßÝÝÝÜÞÞ", /* 13 WB_HALF */
|
||||
"ÞÛÝÝÝÛÞÞ", /* 14 WB_FULL_HALF */
|
||||
"ÛÛÛÛÛÛÛÛ" }; /* 15 WB_FULL */
|
||||
HB_B_HALF_FULL_W, /* 12 WB_HALF_FULL */
|
||||
HB_B_HALF_W, /* 13 WB_HALF */
|
||||
HB_B_FULL_HALF_W, /* 14 WB_FULL_HALF */
|
||||
HB_B_FULL_W }; /* 15 WB_FULL */
|
||||
|
||||
const char * szBox;
|
||||
char szBoxBuf[ 10 ];
|
||||
HB_WCHAR szBoxBuf[ 10 ];
|
||||
PHB_ITEM pBoxFrame = hb_param( 1, HB_IT_STRING );
|
||||
int iColor;
|
||||
|
||||
if( HB_ISCHAR( 1 ) )
|
||||
if( pBoxFrame )
|
||||
{
|
||||
szBox = hb_parc( 1 );
|
||||
hb_itemCopyStrU16( pBoxFrame, HB_CDP_ENDIAN_NATIVE, szBoxBuf, HB_SIZEOFARRAY( szBoxBuf ) );
|
||||
szBoxBuf[ HB_SIZEOFARRAY( szBoxBuf ) - 1 ] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -220,17 +238,14 @@ HB_FUNC( WBOX )
|
||||
|
||||
if( iFrame < 0 || iFrame > 15 )
|
||||
iFrame = 0;
|
||||
memcpy( szBoxBuf, pWBoxFrames[ iFrame ], 9 );
|
||||
memcpy( szBoxBuf, s_pWBoxFrames[ iFrame ], 9 * sizeof( HB_WCHAR ) );
|
||||
if( ( iFrame & 4 ) == 0 )
|
||||
{
|
||||
szBoxBuf[ 8 ] = ( char ) hb_gtGetClearChar();
|
||||
}
|
||||
szBoxBuf[ 8 ] = hb_gtGetClearChar();
|
||||
szBoxBuf[ 9 ] = '\0';
|
||||
szBox = szBoxBuf;
|
||||
}
|
||||
|
||||
iColor = hb_ctColorParam( 2, -1 ); /* Harbour extension */
|
||||
hb_retni( hb_ctwAddWindowBox( hb_ctwCurrentWindow(), szBox, iColor ) );
|
||||
hb_retni( hb_ctwAddWindowBox( hb_ctwCurrentWindow(), szBoxBuf, iColor ) );
|
||||
}
|
||||
|
||||
HB_FUNC( WFORMAT )
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
#include "hbstack.h"
|
||||
#include "hbinit.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapistr.h"
|
||||
|
||||
#include "ctwin.h"
|
||||
|
||||
@@ -167,6 +168,8 @@ typedef struct
|
||||
|
||||
} HB_GTCTW, * PHB_GTCTW;
|
||||
|
||||
static const HB_WCHAR s_szFrameW[] = HB_B_SINGLE_W;
|
||||
|
||||
static int hb_ctw_CalcShadowWidth( int iRows, int iCols )
|
||||
{
|
||||
if( iRows + iRows >= iCols )
|
||||
@@ -1032,11 +1035,11 @@ static int hb_ctw_GetFormatCords( PHB_GTCTW pCTW, int iWindow, HB_BOOL fRelative
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int hb_ctw_AddWindowBox( PHB_GTCTW pCTW, int iWindow, const char * szBox, int iColor )
|
||||
static int hb_ctw_AddWindowBox( PHB_GTCTW pCTW, int iWindow, const HB_WCHAR * szBoxW, int iColor )
|
||||
{
|
||||
int iMaxRow, iMaxCol;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_AddWindowBox(%p,%d,%p,%d)", pCTW, iWindow, szBox, iColor));
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_AddWindowBox(%p,%d,%p,%d)", pCTW, iWindow, szBoxW, iColor));
|
||||
|
||||
iMaxRow = HB_GTSELF_MAXROW( pCTW->pGT );
|
||||
iMaxCol = HB_GTSELF_MAXCOL( pCTW->pGT );
|
||||
@@ -1045,7 +1048,7 @@ static int hb_ctw_AddWindowBox( PHB_GTCTW pCTW, int iWindow, const char * szBox,
|
||||
{
|
||||
if( iColor < 0 )
|
||||
iColor = HB_GTSELF_GETCOLOR( pCTW->pGT );
|
||||
HB_GTSELF_BOX( pCTW->pGT, 0, 0, iMaxRow, iMaxCol, szBox, iColor );
|
||||
HB_GTSELF_BOXW( pCTW->pGT, 0, 0, iMaxRow, iMaxCol, szBoxW, iColor );
|
||||
if( iWindow > 0 && iWindow <= pCTW->iOpenWindows &&
|
||||
pCTW->windows[ iWindow ] != NULL )
|
||||
{
|
||||
@@ -1063,7 +1066,7 @@ static int hb_ctw_AddWindowBox( PHB_GTCTW pCTW, int iWindow, const char * szBox,
|
||||
|
||||
static int hb_ctw_SwapWindows( PHB_GTCTW pCTW, int iWindow1, int iWindow2 )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_AddWindowBox(%p,%d,%d)", pCTW, iWindow1, iWindow2));
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_SwapWindows(%p,%d,%d)", pCTW, iWindow1, iWindow2));
|
||||
|
||||
if( iWindow1 > 0 && iWindow1 <= pCTW->iOpenWindows &&
|
||||
pCTW->windows[ iWindow1 ] != NULL &&
|
||||
@@ -1318,15 +1321,18 @@ static int hb_ctw_gt_MaxRow( PHB_GT pGT )
|
||||
*/
|
||||
#define WRITECON_BUFFER_SIZE 512
|
||||
|
||||
static void hb_ctw_gt_WriteCon( PHB_GT pGT, const char * pText, HB_SIZE nLength )
|
||||
static void hb_ctw_gt_WriteCon( PHB_GT pGT, const char * szText, HB_SIZE nLength )
|
||||
{
|
||||
int iLen = 0;
|
||||
HB_BOOL bDisp = HB_FALSE;
|
||||
HB_BOOL bBell = HB_FALSE;
|
||||
int iRow, iCol, iMaxRow, iMaxCol;
|
||||
char szString[ WRITECON_BUFFER_SIZE ];
|
||||
HB_WCHAR szString[ WRITECON_BUFFER_SIZE ];
|
||||
PHB_CODEPAGE cdp = HB_GTSELF_HOSTCP( pGT );
|
||||
HB_SIZE nIndex = 0;
|
||||
HB_WCHAR wc;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_WriteCon(%p,%p,%" HB_PFS "u)", pGT, pText, nLength));
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_WriteCon(%p,%p,%" HB_PFS "u)", pGT, szText, nLength));
|
||||
|
||||
iMaxRow = HB_GTSELF_MAXROW( pGT );
|
||||
iMaxCol = HB_GTSELF_MAXCOL( pGT );
|
||||
@@ -1350,11 +1356,9 @@ static void hb_ctw_gt_WriteCon( PHB_GT pGT, const char * pText, HB_SIZE nLength
|
||||
HB_GTSELF_SETPOS( pGT, iRow, iCol );
|
||||
}
|
||||
|
||||
while( nLength-- )
|
||||
while( HB_CDPCHAR_GET( cdp, szText, nLength, &nIndex, &wc ) )
|
||||
{
|
||||
char ch = *pText++;
|
||||
|
||||
switch( ch )
|
||||
switch( wc )
|
||||
{
|
||||
case HB_CHAR_BEL:
|
||||
bDisp = bBell = HB_TRUE;
|
||||
@@ -1392,17 +1396,16 @@ static void hb_ctw_gt_WriteCon( PHB_GT pGT, const char * pText, HB_SIZE nLength
|
||||
|
||||
case HB_CHAR_CR:
|
||||
iCol = 0;
|
||||
if( *pText == HB_CHAR_LF )
|
||||
if( nIndex < nLength && szText[ nIndex ] == HB_CHAR_LF )
|
||||
{
|
||||
++iRow;
|
||||
++pText;
|
||||
--nLength;
|
||||
++nIndex;
|
||||
}
|
||||
bDisp = HB_TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
szString[ iLen++ ] = ch;
|
||||
szString[ iLen++ ] = wc;
|
||||
if( ++iCol > iMaxCol )
|
||||
{
|
||||
iCol = 0;
|
||||
@@ -1413,10 +1416,135 @@ static void hb_ctw_gt_WriteCon( PHB_GT pGT, const char * pText, HB_SIZE nLength
|
||||
bDisp = HB_TRUE;
|
||||
}
|
||||
|
||||
if( bDisp || nLength == 0 )
|
||||
if( bDisp || nIndex == nLength )
|
||||
{
|
||||
if( iLen )
|
||||
HB_GTSELF_WRITE( pGT, szString, iLen );
|
||||
HB_GTSELF_WRITEW( pGT, szString, iLen );
|
||||
|
||||
iLen = 0;
|
||||
if( iRow > iMaxRow )
|
||||
{
|
||||
HB_GTSELF_SCROLL( pGT, 0, 0, iMaxRow, iMaxCol,
|
||||
HB_GTSELF_GETCOLOR( pGT ),
|
||||
HB_GTSELF_GETCLEARCHAR( pGT ),
|
||||
iRow - iMaxRow, 0 );
|
||||
iRow = iMaxRow;
|
||||
iCol = 0;
|
||||
}
|
||||
HB_GTSELF_SETPOS( pGT, iRow, iCol );
|
||||
bDisp = HB_FALSE;
|
||||
|
||||
/* To emulate scrolling */
|
||||
HB_GTSELF_FLUSH( pGT );
|
||||
|
||||
if( bBell )
|
||||
{
|
||||
HB_GTSELF_BELL( pGT );
|
||||
bBell = HB_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void hb_ctw_gt_WriteConW( PHB_GT pGT, const HB_WCHAR * szText, HB_SIZE nLength )
|
||||
{
|
||||
int iLen = 0;
|
||||
HB_BOOL bDisp = HB_FALSE;
|
||||
HB_BOOL bBell = HB_FALSE;
|
||||
int iRow, iCol, iMaxRow, iMaxCol;
|
||||
HB_WCHAR szString[ WRITECON_BUFFER_SIZE ];
|
||||
HB_SIZE nIndex = 0;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_WriteConW(%p,%p,%" HB_PFS "u)", pGT, szText, nLength));
|
||||
|
||||
iMaxRow = HB_GTSELF_MAXROW( pGT );
|
||||
iMaxCol = HB_GTSELF_MAXCOL( pGT );
|
||||
|
||||
/* small hack for scrolling console output when client area is set */
|
||||
{
|
||||
PHB_GTCTW pCTW = HB_GTCTW_GET( pGT );
|
||||
int iWindow = HB_CTW_GETCURRENT( pCTW );
|
||||
if( iWindow > 0 && pCTW->windows[ iWindow ]->fClip )
|
||||
iMaxRow = pCTW->windows[ iWindow ]->iCliBottom;
|
||||
}
|
||||
|
||||
HB_GTSELF_GETPOS( pGT, &iRow, &iCol );
|
||||
|
||||
if( iRow > iMaxRow || iCol > iMaxCol )
|
||||
{
|
||||
if( iRow > iMaxRow )
|
||||
iRow = iMaxRow;
|
||||
if( iCol > iMaxCol )
|
||||
iCol = iMaxCol;
|
||||
HB_GTSELF_SETPOS( pGT, iRow, iCol );
|
||||
}
|
||||
|
||||
while( nIndex < nLength )
|
||||
{
|
||||
HB_WCHAR wc = szText[ nIndex++ ];
|
||||
|
||||
switch( wc )
|
||||
{
|
||||
case HB_CHAR_BEL:
|
||||
bDisp = bBell = HB_TRUE;
|
||||
break;
|
||||
|
||||
case HB_CHAR_BS:
|
||||
if( iCol > 0 )
|
||||
{
|
||||
--iCol;
|
||||
bDisp = HB_TRUE;
|
||||
}
|
||||
else if( iRow > 0 )
|
||||
{
|
||||
iCol = iMaxCol;
|
||||
--iRow;
|
||||
bDisp = HB_TRUE;
|
||||
}
|
||||
if( bDisp )
|
||||
{
|
||||
if( iLen )
|
||||
szString[ iLen - 1 ] = ' ';
|
||||
else
|
||||
{
|
||||
HB_GTSELF_SETPOS( pGT, iRow, iCol );
|
||||
szString[ iLen++ ] = ' ';
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case HB_CHAR_LF:
|
||||
iCol = 0;
|
||||
++iRow;
|
||||
bDisp = HB_TRUE;
|
||||
break;
|
||||
|
||||
case HB_CHAR_CR:
|
||||
iCol = 0;
|
||||
if( nIndex < nLength && szText[ nIndex ] == HB_CHAR_LF )
|
||||
{
|
||||
++iRow;
|
||||
++nIndex;
|
||||
}
|
||||
bDisp = HB_TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
szString[ iLen++ ] = wc;
|
||||
if( ++iCol > iMaxCol )
|
||||
{
|
||||
iCol = 0;
|
||||
++iRow;
|
||||
bDisp = HB_TRUE;
|
||||
}
|
||||
else if( iLen >= WRITECON_BUFFER_SIZE )
|
||||
bDisp = HB_TRUE;
|
||||
}
|
||||
|
||||
if( bDisp || nIndex == nLength )
|
||||
{
|
||||
if( iLen )
|
||||
HB_GTSELF_WRITEW( pGT, szString, iLen );
|
||||
|
||||
iLen = 0;
|
||||
if( iRow > iMaxRow )
|
||||
@@ -1674,6 +1802,41 @@ static HB_BOOL hb_ctw_gt_GetScrChar( PHB_GT pGT, int iRow, int iCol,
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
static HB_BOOL hb_ctw_gt_GetScrUC( PHB_GT pGT, int iRow, int iCol,
|
||||
int * piColor, HB_BYTE * pbAttr,
|
||||
HB_UCHAR * puChar, HB_BOOL fTerm )
|
||||
{
|
||||
HB_USHORT usChar;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_GetScrUC(%p,%d,%d,%p,%p,%p,%d)", pGT, iRow, iCol, piColor, pbAttr, puChar, fTerm));
|
||||
|
||||
if( hb_ctw_gt_GetScrChar( pGT, iRow, iCol, piColor, pbAttr, &usChar ) )
|
||||
{
|
||||
HB_UCHAR uc = 0;
|
||||
if( usChar )
|
||||
{
|
||||
if( fTerm && pGT->cdpTerm )
|
||||
uc = hb_cdpGetUC( pGT->cdpTerm, usChar, 0 );
|
||||
if( uc == 0 )
|
||||
{
|
||||
if( pGT->cdpBox && ( !fTerm || pGT->cdpBox != pGT->cdpTerm ) &&
|
||||
pGT->cdpBox != pGT->cdpHost && ( *pbAttr & HB_GT_ATTR_BOX ) )
|
||||
uc = hb_cdpGetUC( pGT->cdpBox, usChar, 0 );
|
||||
if( uc == 0 )
|
||||
{
|
||||
if( pGT->cdpHost && pGT->cdpTerm != pGT->cdpHost )
|
||||
uc = hb_cdpGetUC( pGT->cdpHost, usChar, 0 );
|
||||
if( uc == 0 )
|
||||
uc = hb_cdpGetUC( hb_vmCDP(), usChar, '?' );
|
||||
}
|
||||
}
|
||||
}
|
||||
*puChar = uc;
|
||||
return HB_TRUE;
|
||||
}
|
||||
return HB_FALSE;
|
||||
}
|
||||
|
||||
static HB_BOOL hb_ctw_gt_GetChar( PHB_GT pGT, int iRow, int iCol,
|
||||
int * piColor, HB_BYTE * pbAttr, HB_USHORT * pusChar )
|
||||
{
|
||||
@@ -1686,7 +1849,6 @@ static HB_BOOL hb_ctw_gt_GetChar( PHB_GT pGT, int iRow, int iCol,
|
||||
pCTW = HB_GTCTW_GET( pGT );
|
||||
iWindow = HB_CTW_GETCURRENT( pCTW );
|
||||
if( iWindow == 0 )
|
||||
/* TODO: it may badly interacts with character translations */
|
||||
return HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol, piColor, pbAttr, pusChar );
|
||||
|
||||
pWnd = pCTW->windows[ iWindow ];
|
||||
@@ -1918,16 +2080,20 @@ static int hb_ctw_gt_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions,
|
||||
if( fScreen )
|
||||
{
|
||||
PHB_GTCTW pCTW = HB_GTCTW_GET( pGT );
|
||||
HB_UINT ulWidth = 0, ulCurrWidth = 0, ul = 0, ul2, ulMaxWidth, ulLast;
|
||||
HB_UINT ulWidth = 0, ulCurrWidth = 0, ulMsg = 0, ul2, ulMaxWidth, ulLast;
|
||||
char szKey[ HB_MAX_CHAR_LEN ];
|
||||
HB_SIZE nChar;
|
||||
int iKey, iDspCount, iLines = 0, iTop, iLeft, iBottom, iRight,
|
||||
iMnuCol, iPos, iClr, iWnd, iPrevWnd, i;
|
||||
const char * szMessage = hb_itemGetCPtr( pMessage );
|
||||
HB_UINT ulLen = ( HB_UINT ) hb_itemGetCLen( pMessage );
|
||||
HB_SIZE nLen, nOptLen;
|
||||
void * hMessage, * hOpt;
|
||||
const HB_WCHAR * szMessageW = hb_itemGetStrU16( pMessage, HB_CDP_ENDIAN_NATIVE, &hMessage, &nLen ),
|
||||
* szOptW;
|
||||
|
||||
ulMaxWidth = iCols - 4;
|
||||
while( ul < ulLen )
|
||||
while( ulMsg < nLen )
|
||||
{
|
||||
if( szMessage[ ul ] == '\n' )
|
||||
if( szMessageW[ ulMsg ] == '\n' )
|
||||
{
|
||||
++iLines;
|
||||
if( ulCurrWidth > ulWidth )
|
||||
@@ -1936,7 +2102,7 @@ static int hb_ctw_gt_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions,
|
||||
}
|
||||
else
|
||||
++ulCurrWidth;
|
||||
++ul;
|
||||
++ulMsg;
|
||||
}
|
||||
if( ulCurrWidth )
|
||||
++iLines;
|
||||
@@ -1945,7 +2111,8 @@ static int hb_ctw_gt_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions,
|
||||
ulCurrWidth = 0;
|
||||
for( i = 1; i <= iOptions; ++i )
|
||||
{
|
||||
ulCurrWidth += ( HB_UINT ) hb_arrayGetCLen( pOptions, i ) + ( i > 1 ? 3 : 0 );
|
||||
nOptLen = hb_itemCopyStrU16( hb_arrayGetItemPtr( pOptions, i ), HB_CDP_ENDIAN_NATIVE, NULL, 0 );
|
||||
ulCurrWidth += ( HB_UINT ) nOptLen + ( i > 1 ? 3 : 0 );
|
||||
}
|
||||
if( ulCurrWidth > ulWidth )
|
||||
ulWidth = ulCurrWidth;
|
||||
@@ -1968,35 +2135,36 @@ static int hb_ctw_gt_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions,
|
||||
|
||||
iPrevWnd = hb_ctw_CurrentWindow( pCTW );
|
||||
iWnd = hb_ctw_CreateWindow( pCTW, iTop, iLeft, iBottom, iRight, HB_TRUE, iClrNorm, HB_TRUE );
|
||||
hb_ctw_AddWindowBox( pCTW, iWnd, _B_SINGLE, iClrNorm );
|
||||
hb_ctw_AddWindowBox( pCTW, iWnd, s_szFrameW, iClrNorm );
|
||||
HB_GTSELF_SETCURSORSTYLE( pGT, SC_NONE );
|
||||
ulLast = 0;
|
||||
i = 0;
|
||||
for( ul = 0; ul < ulLen; ++ul )
|
||||
for( ulMsg = 0; ulMsg < nLen; ++ulMsg )
|
||||
{
|
||||
if( szMessage[ ul ] == '\n' )
|
||||
if( szMessageW[ ulMsg ] == '\n' )
|
||||
{
|
||||
if( ul > ulLast )
|
||||
if( ulMsg > ulLast )
|
||||
{
|
||||
ul2 = ul - ulLast;
|
||||
ul2 = ulMsg - ulLast;
|
||||
if( ul2 > ulWidth )
|
||||
ul2 = ulWidth;
|
||||
HB_GTSELF_PUTTEXT( pGT, i, ( ( ulWidth - ul2 + 1 ) >> 1 ) + 1, iClrNorm,
|
||||
szMessage + ulLast, ul2 );
|
||||
HB_GTSELF_PUTTEXTW( pGT, i, ( ( ulWidth - ul2 + 1 ) >> 1 ) + 1, iClrNorm,
|
||||
szMessageW + ulLast, ul2 );
|
||||
}
|
||||
ulLast = ul + 1;
|
||||
ulLast = ulMsg + 1;
|
||||
if( ++i >= iLines )
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( ul > ulLast && i < iLines )
|
||||
if( ulMsg > ulLast && i < iLines )
|
||||
{
|
||||
ul2 = ul - ulLast;
|
||||
ul2 = ulMsg - ulLast;
|
||||
if( ul2 > ulWidth )
|
||||
ul2 = ulWidth;
|
||||
HB_GTSELF_PUTTEXT( pGT, i, ( ( ulWidth - ul2 + 1 ) >> 1 ) + 1, iClrNorm,
|
||||
szMessage + ulLast, ul2 );
|
||||
HB_GTSELF_PUTTEXTW( pGT, i, ( ( ulWidth - ul2 + 1 ) >> 1 ) + 1, iClrNorm,
|
||||
szMessageW + ulLast, ul2 );
|
||||
}
|
||||
hb_strfree( hMessage );
|
||||
|
||||
iPos = 1;
|
||||
while( iRet == 0 )
|
||||
@@ -2006,16 +2174,16 @@ static int hb_ctw_gt_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions,
|
||||
for( i = 1; i <= iOptions; ++i )
|
||||
{
|
||||
iClr = i == iPos ? iClrHigh : iClrNorm;
|
||||
ulLen = ( HB_UINT ) hb_arrayGetCLen( pOptions, i );
|
||||
HB_GTSELF_PUTTEXT( pGT, iLines + 1, iMnuCol, iClr,
|
||||
hb_arrayGetCPtr( pOptions, i ), ulLen );
|
||||
iMnuCol += ulLen + 3;
|
||||
szOptW = hb_arrayGetStrU16( pOptions, i, HB_CDP_ENDIAN_NATIVE, &hOpt, &nLen );
|
||||
HB_GTSELF_PUTTEXTW( pGT, iLines + 1, iMnuCol, iClr, szOptW, nLen );
|
||||
hb_strfree( hOpt );
|
||||
iMnuCol += nLen + 3;
|
||||
}
|
||||
while( HB_GTSELF_DISPCOUNT( pGT ) )
|
||||
HB_GTSELF_DISPEND( pGT );
|
||||
HB_GTSELF_REFRESH( pGT );
|
||||
|
||||
iKey = HB_GTSELF_INKEYGET( pGT, HB_TRUE, dDelay, INKEY_ALL );
|
||||
iKey = HB_GTSELF_INKEYGET( pGT, HB_TRUE, dDelay, INKEY_ALL | HB_INKEY_EXT );
|
||||
/* TODO: add support for SET KEY blocks */
|
||||
|
||||
if( iKey == K_ESC )
|
||||
@@ -2046,27 +2214,32 @@ static int hb_ctw_gt_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions,
|
||||
iMnuCol = ( ( ulWidth - ulCurrWidth ) >> 1 ) + 1;
|
||||
for( i = 1; i <= iOptions; ++i )
|
||||
{
|
||||
ulLen = ( HB_UINT ) hb_arrayGetCLen( pOptions, i );
|
||||
if( iMCol >= iMnuCol && iMCol < iMnuCol + ( int ) ulLen )
|
||||
nLen = hb_itemCopyStrU16( hb_arrayGetItemPtr( pOptions, i ), HB_CDP_ENDIAN_NATIVE, NULL, 0 );
|
||||
if( iMCol >= iMnuCol && iMCol < iMnuCol + ( int ) nLen )
|
||||
{
|
||||
iRet = i;
|
||||
break;
|
||||
}
|
||||
iMnuCol += ulLen + 3;
|
||||
iMnuCol += ( int ) nLen + 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else if( iKey >= 32 && iKey <= 255 )
|
||||
else if( ( nChar = hb_inkeyKeyString( iKey, szKey, sizeof( szKey ) ) ) > 0 )
|
||||
{
|
||||
int iUp = hb_charUpper( iKey );
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
for( i = 1; i <= iOptions; ++i )
|
||||
{
|
||||
const char *szValue = hb_arrayGetCPtr( pOptions, i );
|
||||
if( szValue && iUp == hb_charUpper( *szValue ) )
|
||||
HB_SIZE nOptLen = hb_arrayGetCLen( pOptions, i );
|
||||
if( nOptLen > 0 )
|
||||
{
|
||||
iRet = i;
|
||||
break;
|
||||
HB_SIZE nIdx1 = 0, nIdx2 = 0;
|
||||
if( hb_cdpCharCaseEq( cdp, szKey, nChar, &nIdx1,
|
||||
hb_arrayGetCPtr( pOptions, i ), nOptLen, &nIdx2 ) )
|
||||
{
|
||||
iRet = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2421,13 +2594,13 @@ int hb_ctwCenterWindow( int iWindow, HB_BOOL fCenter )
|
||||
return iResult;
|
||||
}
|
||||
|
||||
int hb_ctwAddWindowBox( int iWindow, const char * szBox, int iColor )
|
||||
int hb_ctwAddWindowBox( int iWindow, const HB_WCHAR * szBoxW, int iColor )
|
||||
{
|
||||
int iResult = -1;
|
||||
PHB_GTCTW pCTW = hb_ctw_base();
|
||||
if( pCTW )
|
||||
{
|
||||
iResult = hb_ctw_AddWindowBox( pCTW, iWindow, szBox, iColor );
|
||||
iResult = hb_ctw_AddWindowBox( pCTW, iWindow, szBoxW, iColor );
|
||||
HB_GTSELF_FLUSH( pCTW->pGT );
|
||||
hb_gt_BaseFree( pCTW->pGT );
|
||||
}
|
||||
@@ -2495,6 +2668,7 @@ static HB_BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable )
|
||||
pFuncTable->GetPos = hb_ctw_gt_GetPos;
|
||||
pFuncTable->SetPos = hb_ctw_gt_SetPos;
|
||||
pFuncTable->WriteCon = hb_ctw_gt_WriteCon;
|
||||
pFuncTable->WriteConW = hb_ctw_gt_WriteConW;
|
||||
pFuncTable->GetCursorStyle = hb_ctw_gt_GetCursorStyle;
|
||||
pFuncTable->SetCursorStyle = hb_ctw_gt_SetCursorStyle;
|
||||
pFuncTable->GetColorStr = hb_ctw_gt_GetColorStr;
|
||||
@@ -2504,6 +2678,7 @@ static HB_BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable )
|
||||
pFuncTable->GetColorData = hb_ctw_gt_GetColorData;
|
||||
pFuncTable->GetScrCursor = hb_ctw_gt_GetScrCursor;
|
||||
pFuncTable->GetScrChar = hb_ctw_gt_GetScrChar;
|
||||
pFuncTable->GetScrUC = hb_ctw_gt_GetScrUC;
|
||||
pFuncTable->GetChar = hb_ctw_gt_GetChar;
|
||||
pFuncTable->PutChar = hb_ctw_gt_PutChar;
|
||||
pFuncTable->Resize = hb_ctw_gt_Resize;
|
||||
|
||||
@@ -89,7 +89,7 @@ extern HB_EXPORT int hb_ctwGetWindowCords( int iWindow, HB_BOOL fCenter, int
|
||||
extern HB_EXPORT int hb_ctwGetFormatCords( int iWindow, HB_BOOL fRelative, int * piTop, int * piLeft, int * piBottom, int * piRight );
|
||||
extern HB_EXPORT int hb_ctwMoveWindow( int iWindow, int iRow, int iCol );
|
||||
extern HB_EXPORT int hb_ctwCenterWindow( int iWindow, HB_BOOL fCenter );
|
||||
extern HB_EXPORT int hb_ctwAddWindowBox( int iWindow, const char * szBox, int iColor );
|
||||
extern HB_EXPORT int hb_ctwAddWindowBox( int iWindow, const HB_WCHAR * szBoxW, int iColor );
|
||||
extern HB_EXPORT int hb_ctwSwapWindows( int iWindow1, int iWindow2 );
|
||||
extern HB_EXPORT int hb_ctwGetPosWindow( int iRow, int iCol );
|
||||
extern HB_EXPORT int hb_ctwLastKey( int * piNewKey );
|
||||
|
||||
@@ -109,7 +109,6 @@ static PHB_FFIND _hb_fileStart( HB_BOOL fNext, HB_FATTR ulAttr )
|
||||
if( hb_pcount() > 0 )
|
||||
{
|
||||
const char * szFile = hb_parc( 1 );
|
||||
char * pszFree;
|
||||
|
||||
if( pFFData->ffind )
|
||||
{
|
||||
@@ -119,13 +118,10 @@ static PHB_FFIND _hb_fileStart( HB_BOOL fNext, HB_FATTR ulAttr )
|
||||
|
||||
if( szFile )
|
||||
{
|
||||
szFile = hb_fsNameConv( szFile, &pszFree );
|
||||
if( HB_ISNUM( 2 ) )
|
||||
ulAttr = ( HB_FATTR ) hb_parnl( 2 );
|
||||
pFFData->ulAttr = hb_parl( 3 ) ? ulAttr : HB_FA_ALL;
|
||||
pFFData->ffind = hb_fsFindFirst( szFile, ulAttr );
|
||||
if( pszFree )
|
||||
hb_xfree( pszFree );
|
||||
while( pFFData->ffind && pFFData->ulAttr &&
|
||||
pFFData->ffind->attr != pFFData->ulAttr )
|
||||
{
|
||||
@@ -245,20 +241,19 @@ HB_FUNC( FILEDELETE )
|
||||
|
||||
if( HB_ISCHAR( 1 ) )
|
||||
{
|
||||
const char * pDirSpec;
|
||||
const char * pszDirSpec;
|
||||
PHB_FFIND ffind;
|
||||
HB_FATTR ulAttr = HB_FA_ALL;
|
||||
char * pszFree;
|
||||
|
||||
pDirSpec = hb_fsNameConv( hb_parc( 1 ), &pszFree );
|
||||
pszDirSpec = hb_parc( 1 );
|
||||
if( HB_ISNUM( 2 ) )
|
||||
ulAttr = hb_parnl( 2 );
|
||||
|
||||
if( ( ffind = hb_fsFindFirst( pDirSpec, ulAttr ) ) != NULL )
|
||||
if( ( ffind = hb_fsFindFirst( pszDirSpec, ulAttr ) ) != NULL )
|
||||
{
|
||||
PHB_FNAME pFilepath;
|
||||
|
||||
pFilepath = hb_fsFNameSplit( pDirSpec );
|
||||
pFilepath = hb_fsFNameSplit( pszDirSpec );
|
||||
pFilepath->szExtension = NULL;
|
||||
|
||||
do
|
||||
@@ -276,8 +271,6 @@ HB_FUNC( FILEDELETE )
|
||||
hb_xfree( pFilepath );
|
||||
hb_fsFindClose( ffind );
|
||||
}
|
||||
if( pszFree )
|
||||
hb_xfree( pszFree );
|
||||
}
|
||||
|
||||
hb_retl( bReturn );
|
||||
|
||||
@@ -66,27 +66,24 @@
|
||||
|
||||
HB_FUNC( EXECNAME )
|
||||
{
|
||||
const char * szBaseName = hb_cmdargARGVN( 0 );
|
||||
char * pszBaseName = hb_cmdargProgName();
|
||||
|
||||
if( szBaseName )
|
||||
if( pszBaseName )
|
||||
{
|
||||
/* Convert from OS codepage */
|
||||
char * pszFree = NULL;
|
||||
|
||||
szBaseName = hb_osDecodeCP( szBaseName, &pszFree, NULL );
|
||||
if( ! hb_parl( 1 ) )
|
||||
{
|
||||
PHB_FNAME pFileName = hb_fsFNameSplit( szBaseName );
|
||||
PHB_FNAME pFileName = hb_fsFNameSplit( pszBaseName );
|
||||
|
||||
pszFree = hb_xstrcpy( NULL, pFileName->szName,
|
||||
pFileName->szExtension, NULL );
|
||||
if( pFileName->szPath )
|
||||
{
|
||||
hb_xfree( pszBaseName );
|
||||
pszBaseName = hb_xstrcpy( NULL, pFileName->szName,
|
||||
pFileName->szExtension, NULL );
|
||||
}
|
||||
hb_xfree( pFileName );
|
||||
}
|
||||
|
||||
if( pszFree )
|
||||
hb_retc_buffer( pszFree );
|
||||
else
|
||||
hb_retc( szBaseName );
|
||||
hb_retc_buffer( pszBaseName );
|
||||
}
|
||||
else
|
||||
hb_retc_null();
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
*/
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapiitm.h"
|
||||
|
||||
#if defined( HB_OS_UNIX )
|
||||
# include <unistd.h>
|
||||
@@ -40,7 +41,8 @@ extern char **environ;
|
||||
#elif defined( HB_OS_DOS )
|
||||
# define environ _environ
|
||||
extern char **_environ;
|
||||
#elif defined( HB_OS_WIN )
|
||||
#elif defined( HB_OS_WIN ) && ! defined( HB_OS_WIN_CE )
|
||||
# include "hbwinuni.h"
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
@@ -56,12 +58,8 @@ HB_FUNC( FT_GETE )
|
||||
char *buffer = NULL;
|
||||
int x;
|
||||
int buffsize = 0;
|
||||
int rettype = NORETURN;
|
||||
|
||||
if( HB_ISCHAR( 1 ) )
|
||||
rettype = CHARTYPE;
|
||||
if( HB_ISARRAY( 1 ) )
|
||||
rettype = ARRAYTYPE;
|
||||
int rettype = HB_ISARRAY( 1 ) ? ARRAYTYPE :
|
||||
( HB_ISCHAR( 1 ) && HB_ISBYREF( 1 ) ? CHARTYPE : NORETURN );
|
||||
|
||||
/* scan strings first and add up total size */
|
||||
if( rettype == CHARTYPE )
|
||||
@@ -99,8 +97,8 @@ HB_FUNC( FT_GETE )
|
||||
if( rettype == CHARTYPE )
|
||||
{
|
||||
/* return buffer to app and free memory */
|
||||
hb_storc( buffer, 1 );
|
||||
hb_xfree( buffer );
|
||||
if( !hb_storclen_buffer( buffer, strlen( buffer ), 1 ) )
|
||||
hb_xfree( buffer );
|
||||
}
|
||||
|
||||
/* return number of strings found */
|
||||
@@ -108,80 +106,67 @@ HB_FUNC( FT_GETE )
|
||||
}
|
||||
#elif defined( HB_OS_WIN ) && ! defined( HB_OS_WIN_CE )
|
||||
{
|
||||
char *buffer = NULL;
|
||||
LPTCH lpEnviron = GetEnvironmentStrings();
|
||||
char *sCurEnv;
|
||||
int x;
|
||||
HB_ISIZ buffsize = 0;
|
||||
int rettype = NORETURN;
|
||||
LPTCH lpEnviron = GetEnvironmentStrings(), lpEnv;
|
||||
LPTSTR lpResult = NULL, lpDst;
|
||||
HB_SIZE nSize = 0, nCount = 0;
|
||||
PHB_ITEM pArray = NULL;
|
||||
int rettype = HB_ISARRAY( 1 ) ? ARRAYTYPE :
|
||||
( HB_ISCHAR( 1 ) && HB_ISBYREF( 1 ) ? CHARTYPE : NORETURN );
|
||||
|
||||
char * szEnviron = HB_TCHAR_CONVFROM( lpEnviron );
|
||||
|
||||
if( HB_ISCHAR( 1 ) )
|
||||
rettype = CHARTYPE;
|
||||
if( HB_ISARRAY( 1 ) )
|
||||
rettype = ARRAYTYPE;
|
||||
|
||||
if( rettype == CHARTYPE )
|
||||
/* scan strings first and add up total size */
|
||||
if( lpEnviron )
|
||||
{
|
||||
for( sCurEnv = szEnviron; *sCurEnv; sCurEnv++ )
|
||||
if( rettype == CHARTYPE )
|
||||
{
|
||||
if( !*sCurEnv )
|
||||
/* null string, we're done */
|
||||
break;
|
||||
|
||||
/* add length of this string plus 2 for the crlf */
|
||||
buffsize += ( strlen( ( char * ) sCurEnv ) + 2 );
|
||||
|
||||
while( *sCurEnv )
|
||||
sCurEnv++;
|
||||
for( lpEnv = lpEnviron; *lpEnv; lpEnv++ )
|
||||
{
|
||||
while( *++lpEnv )
|
||||
++nSize;
|
||||
nSize += 3;
|
||||
}
|
||||
if( nSize > 0 )
|
||||
lpResult = ( LPTSTR ) hb_xgrab( ( nSize + 1 ) * sizeof( TCHAR ) );
|
||||
}
|
||||
/* add 1 more byte for final nul character */
|
||||
buffsize++;
|
||||
else if( rettype == ARRAYTYPE )
|
||||
pArray = hb_param( 1, HB_IT_ARRAY );
|
||||
|
||||
/* now allocate that much memory and make sure 1st byte is a nul */
|
||||
buffer = ( char * ) hb_xgrab( buffsize + 1 );
|
||||
buffer[0] = '\0';
|
||||
}
|
||||
x = 0;
|
||||
for( sCurEnv = szEnviron; *sCurEnv; sCurEnv++ )
|
||||
{
|
||||
if( !*sCurEnv )
|
||||
/* null string, we're done */
|
||||
break;
|
||||
for( lpEnv = lpEnviron, lpDst = lpResult; *lpEnv; lpEnv++ )
|
||||
{
|
||||
nCount++;
|
||||
if( rettype == CHARTYPE )
|
||||
{
|
||||
do
|
||||
*lpDst++ = *lpEnv++;
|
||||
while( *lpEnv );
|
||||
*lpDst++ = '\r';
|
||||
*lpDst++ = '\n';
|
||||
}
|
||||
else if( rettype == ARRAYTYPE )
|
||||
{
|
||||
nSize = 0;
|
||||
while( lpEnv[ ++nSize ] );
|
||||
HB_ARRAYSETSTRLEN( pArray, nCount, lpEnv, nSize - 1 );
|
||||
lpEnv += nSize;
|
||||
}
|
||||
}
|
||||
|
||||
FreeEnvironmentStrings( lpEnviron );
|
||||
|
||||
if( rettype == CHARTYPE )
|
||||
{
|
||||
/* tack string onto end of buffer */
|
||||
hb_strncat( buffer, ( char * ) sCurEnv, buffsize );
|
||||
/* add crlf at end of each string */
|
||||
hb_strncat( buffer, CRLF, buffsize );
|
||||
PHB_ITEM pItem = HB_ITEMPUTSTRLEN( NULL, lpResult, nSize );
|
||||
if( !hb_itemParamStoreRelease( 1, pItem ) )
|
||||
hb_itemRelease( pItem );
|
||||
hb_xfree( lpResult );
|
||||
}
|
||||
|
||||
if( rettype == ARRAYTYPE )
|
||||
/* store string to next array element */
|
||||
hb_storvc( ( char * ) sCurEnv, 1, x + 1 );
|
||||
x++;
|
||||
while( *sCurEnv )
|
||||
sCurEnv++;
|
||||
}
|
||||
else if( rettype == CHARTYPE )
|
||||
hb_storc( NULL, 1 );
|
||||
|
||||
if( rettype == CHARTYPE )
|
||||
{
|
||||
/* return buffer to app and free memory */
|
||||
hb_storc( buffer, 1 );
|
||||
hb_xfree( buffer );
|
||||
}
|
||||
|
||||
/* return number of strings found */
|
||||
hb_retni( x );
|
||||
|
||||
HB_TCHAR_FREE( szEnviron );
|
||||
FreeEnvironmentStrings( ( LPTSTR ) lpEnviron );
|
||||
hb_retns( nCount );
|
||||
}
|
||||
#else
|
||||
hb_storc( NULL, 1 );
|
||||
if( HB_ISCHAR( 1 ) )
|
||||
hb_storc( NULL, 1 );
|
||||
hb_retni( 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -24,7 +24,4 @@
|
||||
|
||||
#include "hbapi.h"
|
||||
|
||||
HB_FUNC( FT_ORIGIN )
|
||||
{
|
||||
hb_retc( hb_cmdargARGV()[ 0 ] );
|
||||
}
|
||||
HB_FUNC_TRANSLATE( FT_ORIGIN, HB_PROGNAME )
|
||||
|
||||
@@ -184,7 +184,6 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, int iCmdShow )
|
||||
pWVT->keyLast = 0;
|
||||
|
||||
pWVT->CenterWindow = HB_TRUE; /* Default is to always display window in centre of screen */
|
||||
pWVT->CodePage = 255; /* GetACP(); - set code page to default system */
|
||||
|
||||
pWVT->AltF4Close = HB_FALSE;
|
||||
pWVT->fInit = HB_FALSE;
|
||||
@@ -202,12 +201,6 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, int iCmdShow )
|
||||
pWVT->bResizing = HB_FALSE;
|
||||
pWVT->bAlreadySizing = HB_FALSE;
|
||||
|
||||
#ifndef HB_CDP_SUPPORT_OFF
|
||||
pWVT->hostCDP = hb_vmCDP();
|
||||
pWVT->inCDP = hb_vmCDP();
|
||||
pWVT->boxCDP = hb_cdpFind( "EN" );
|
||||
#endif
|
||||
|
||||
return pWVT;
|
||||
}
|
||||
|
||||
@@ -508,13 +501,9 @@ static bool hb_gt_wvt_CreateConsoleWindow( PHB_GTWVT pWVT )
|
||||
#endif
|
||||
|
||||
/* Set default window title */
|
||||
{
|
||||
PHB_FNAME pFileName = hb_fsFNameSplit( hb_cmdargARGV()[ 0 ] );
|
||||
pWVT->qWnd->setWindowTitle( "Harbour-QT Console" );
|
||||
pWVT->qWnd->_drawingArea->resetWindowSize();
|
||||
pWVT->qWnd->setWindowSize();
|
||||
hb_xfree( pFileName );
|
||||
}
|
||||
pWVT->qWnd->setWindowTitle( "Harbour-QT Console" );
|
||||
pWVT->qWnd->_drawingArea->resetWindowSize();
|
||||
pWVT->qWnd->setWindowSize();
|
||||
|
||||
return HB_TRUE;
|
||||
}
|
||||
@@ -714,57 +703,6 @@ static void hb_gt_wvt_Tone( PHB_GT pGT, double dFrequency, double dDuration )
|
||||
|
||||
/* ********************************************************************** */
|
||||
|
||||
static HB_BOOL hb_gt_wvt_SetDispCP( PHB_GT pGT, const char * pszTermCDP, const char * pszHostCDP, HB_BOOL fBox )
|
||||
{
|
||||
HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox );
|
||||
|
||||
/*
|
||||
* We are displaying text in U16 so pszTermCDP is unimportant.
|
||||
* We only have to know what is the internal application codepage
|
||||
* to make proper translation
|
||||
*/
|
||||
if( !pszHostCDP || !*pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
|
||||
if( pszHostCDP && *pszHostCDP )
|
||||
{
|
||||
PHB_CODEPAGE cdpHost = hb_cdpFind( pszHostCDP );
|
||||
if( cdpHost )
|
||||
{
|
||||
PHB_GTWVT pWVT = HB_GTWVT_GET( pGT );
|
||||
|
||||
pWVT->hostCDP = cdpHost;
|
||||
pWVT->boxCDP = fBox ? cdpHost : hb_cdpFind( "EN" );
|
||||
}
|
||||
}
|
||||
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
static HB_BOOL hb_gt_wvt_SetKeyCP( PHB_GT pGT, const char * pszTermCDP, const char * pszHostCDP )
|
||||
{
|
||||
HB_GTSUPER_SETKEYCP( pGT, pszTermCDP, pszHostCDP );
|
||||
|
||||
/*
|
||||
* We are receiving WM_CHAR events in U16 so pszTermCDP is unimportant.
|
||||
* We only have to know what is the internal application codepage
|
||||
* to make proper translation
|
||||
*/
|
||||
if( !pszHostCDP || !*pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
|
||||
if( pszHostCDP && *pszHostCDP )
|
||||
{
|
||||
PHB_CODEPAGE cdpHost = hb_cdpFind( pszHostCDP );
|
||||
if( cdpHost )
|
||||
HB_GTWVT_GET( pGT )->inCDP = cdpHost;
|
||||
}
|
||||
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
/* ********************************************************************** */
|
||||
|
||||
static HB_BOOL hb_gt_wvt_mouse_IsPresent( PHB_GT pGT )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_wvt_mouse_IsPresent(%p)", pGT));
|
||||
@@ -949,29 +887,6 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
|
||||
}
|
||||
break;
|
||||
|
||||
case HB_GTI_CODEPAGE:
|
||||
pInfo->pResult = hb_itemPutNI( pInfo->pResult, pWVT->CodePage );
|
||||
if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC )
|
||||
{
|
||||
iVal = hb_itemGetNI( pInfo->pNewVal );
|
||||
if( iVal != pWVT->CodePage )
|
||||
{
|
||||
pWVT->CodePage = iVal;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case HB_GTI_BOXCP:
|
||||
pInfo->pResult = hb_itemPutC( pInfo->pResult,
|
||||
pWVT->boxCDP ? pWVT->boxCDP->id : NULL );
|
||||
if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING )
|
||||
{
|
||||
PHB_CODEPAGE cdpBox = hb_cdpFind( hb_itemGetCPtr( pInfo->pNewVal ) );
|
||||
if( cdpBox )
|
||||
pWVT->boxCDP = cdpBox;
|
||||
}
|
||||
break;
|
||||
|
||||
case HB_GTI_ICONFILE:
|
||||
if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING )
|
||||
{
|
||||
@@ -1434,7 +1349,7 @@ void DrawingArea::redrawBuffer( const QRect & rect )
|
||||
if( !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol, &bColor, &bAttr, &usChar ) )
|
||||
break;
|
||||
|
||||
usChar = hb_cdpGetU16Disp( bAttr & HB_GT_ATTR_BOX ? pWVT->boxCDP : pWVT->hostCDP, ( HB_BYTE ) usChar );
|
||||
usChar = hb_cdpGetU16Ctrl( usChar );
|
||||
#if 1
|
||||
if( bAttr & HB_GT_ATTR_BOX )
|
||||
{
|
||||
@@ -1556,7 +1471,7 @@ void DrawingArea::displayCell( int iRow, int iCol )
|
||||
|
||||
if( HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol, &bColor, &bAttr, &usChar ) )
|
||||
{
|
||||
usChar = hb_cdpGetU16Disp( bAttr & HB_GT_ATTR_BOX ? pWVT->boxCDP : pWVT->hostCDP, ( HB_BYTE ) usChar );
|
||||
usChar = hb_cdpGetU16Ctrl( usChar );
|
||||
|
||||
painter.setPen( QPen( _COLORS[ bColor & 0x0F ] ) );
|
||||
painter.setBackground( QBrush( _COLORS[ bColor >> 4 ] ) );
|
||||
|
||||
@@ -195,14 +195,9 @@ typedef struct
|
||||
|
||||
bool fInit; /* logical variable indicating that window should be open */
|
||||
|
||||
PHB_CODEPAGE hostCDP; /* Host/HVM CodePage for unicode output translations */
|
||||
PHB_CODEPAGE inCDP; /* Host/HVM CodePage for unicode input translations */
|
||||
PHB_CODEPAGE boxCDP; /* CodePage for legacy drawing chars: IBM437 */
|
||||
|
||||
QIcon qIcon; /* Title Bar and Task List icon. Can be NULL. */
|
||||
bool bIconToFree; /* Do we need to free this icon when it's not NULL? */
|
||||
|
||||
int CodePage; /* Code page to use for display characters */
|
||||
bool AltF4Close; /* Can use Alt+F4 to close application */
|
||||
bool CenterWindow; /* True if window is to be Reset into centre of window */
|
||||
|
||||
@@ -219,9 +214,6 @@ typedef struct
|
||||
bool bResizing;
|
||||
bool bAlreadySizing;
|
||||
|
||||
HB_BYTE keyTransTbl[ 256 ];
|
||||
HB_BYTE chrTransTbl[ 256 ];
|
||||
|
||||
} HB_GTWVT, * PHB_GTWVT;
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
@@ -103,9 +103,15 @@ HB_FUNC( HB_STRING2POINTER )
|
||||
|
||||
#endif
|
||||
|
||||
HB_FUNC_EXTERN( HB_PROGNAME );
|
||||
|
||||
HB_FUNC( HB_CMDARGARGV )
|
||||
{
|
||||
hb_retc( hb_cmdargARGVN( 0 ) );
|
||||
/* xHarbour really returns:
|
||||
* hb_retc( hb_cmdargARGVN( 0 ) );
|
||||
* probably typo - replicated here by HB_PROGNAME()
|
||||
*/
|
||||
HB_FUNC_EXEC( HB_PROGNAME );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_VMMODE )
|
||||
|
||||
@@ -310,6 +310,8 @@ DYNAMIC hb_ATokens
|
||||
DYNAMIC hb_AtX
|
||||
DYNAMIC hb_base64Decode
|
||||
DYNAMIC hb_base64Encode
|
||||
DYNAMIC HB_BCHAR
|
||||
DYNAMIC HB_BCODE
|
||||
DYNAMIC hb_bitAnd
|
||||
DYNAMIC hb_bitNot
|
||||
DYNAMIC hb_bitOr
|
||||
@@ -318,9 +320,12 @@ DYNAMIC hb_bitSet
|
||||
DYNAMIC hb_bitShift
|
||||
DYNAMIC hb_bitTest
|
||||
DYNAMIC hb_bitXor
|
||||
DYNAMIC HB_BLEN
|
||||
DYNAMIC hb_blowfishDecrypt
|
||||
DYNAMIC hb_blowfishEncrypt
|
||||
DYNAMIC hb_blowfishKey
|
||||
DYNAMIC HB_BPEEK
|
||||
DYNAMIC HB_BPOKE
|
||||
DYNAMIC hb_BuildDate
|
||||
DYNAMIC hb_ByteSwapI
|
||||
DYNAMIC hb_ByteSwapL
|
||||
@@ -615,11 +620,13 @@ DYNAMIC hb_isSymbol
|
||||
DYNAMIC hb_isTimeStamp
|
||||
DYNAMIC hb_jsonDecode
|
||||
DYNAMIC hb_jsonEncode
|
||||
DYNAMIC HB_KEYCHAR
|
||||
DYNAMIC hb_KeyClear
|
||||
DYNAMIC hb_KeyIns
|
||||
DYNAMIC hb_KeyLast
|
||||
DYNAMIC hb_KeyNext
|
||||
DYNAMIC hb_KeyPut
|
||||
DYNAMIC HB_KEYSTD
|
||||
DYNAMIC hb_langErrMsg
|
||||
DYNAMIC hb_langMessage
|
||||
DYNAMIC hb_langName
|
||||
@@ -819,6 +826,11 @@ DYNAMIC hb_TToC
|
||||
DYNAMIC hb_TToD
|
||||
DYNAMIC hb_TToN
|
||||
DYNAMIC hb_TToS
|
||||
DYNAMIC HB_UCHAR
|
||||
DYNAMIC HB_UCODE
|
||||
DYNAMIC HB_ULEN
|
||||
DYNAMIC HB_UPEEK
|
||||
DYNAMIC HB_UPOKE
|
||||
DYNAMIC hb_UserLang
|
||||
DYNAMIC hb_UserName
|
||||
DYNAMIC hb_UTCOffset
|
||||
|
||||
@@ -947,18 +947,21 @@ extern HB_EXPORT HB_BOOL hb_strEmpty( const char * szText, HB_SIZE nLen ); /*
|
||||
extern HB_EXPORT void hb_strDescend( char * szStringTo, const char * szStringFrom, HB_SIZE nLen ); /* copy a string to a buffer, inverting each character */
|
||||
extern HB_EXPORT HB_SIZE hb_strAt( const char * szSub, HB_SIZE nSubLen, const char * szText, HB_SIZE nLen ); /* returns an index to a sub-string within another string */
|
||||
extern HB_EXPORT HB_ISIZ hb_strAtTBM( const char * needle, HB_ISIZ m, const char * haystack, HB_ISIZ n );
|
||||
|
||||
/* Warning: this functions works only with byte oriented CPs */
|
||||
extern HB_EXPORT char * hb_strUpper( char * szText, HB_SIZE nLen ); /* convert an existing string buffer to upper case */
|
||||
extern HB_EXPORT char * hb_strLower( char * szText, HB_SIZE nLen ); /* convert an existing string buffer to lower case */
|
||||
extern HB_EXPORT HB_BOOL hb_charIsDigit( int iChar );
|
||||
extern HB_EXPORT HB_BOOL hb_charIsAlpha( int iChar );
|
||||
extern HB_EXPORT HB_BOOL hb_charIsLower( int iChar );
|
||||
extern HB_EXPORT HB_BOOL hb_charIsUpper( int iChar );
|
||||
extern HB_EXPORT int hb_charUpper( int iChar ); /* converts iChar to upper case */
|
||||
extern HB_EXPORT int hb_charLower( int iChar ); /* converts iChar to lower case */
|
||||
|
||||
extern HB_EXPORT HB_BOOL hb_strIsDigit( const char * szChar );
|
||||
extern HB_EXPORT HB_BOOL hb_strIsAlpha( const char * szChar );
|
||||
extern HB_EXPORT HB_BOOL hb_strIsLower( const char * szChar );
|
||||
extern HB_EXPORT HB_BOOL hb_strIsUpper( const char * szChar );
|
||||
extern HB_EXPORT int hb_charUpper( int iChar ); /* converts iChar to upper case */
|
||||
extern HB_EXPORT int hb_charLower( int iChar ); /* converts iChar to lower case */
|
||||
extern HB_EXPORT char * hb_strncpy( char * pDest, const char * pSource, HB_SIZE nLen ); /* copy at most nLen bytes from string buffer to another buffer and _always_ set 0 in destin buffer */
|
||||
extern HB_EXPORT char * hb_strncat( char * pDest, const char * pSource, HB_SIZE nLen ); /* copy at most nLen-strlen(pDest) bytes from string buffer to another buffer and _always_ set 0 in destin buffer */
|
||||
extern HB_EXPORT char * hb_strncpyTrim( char * pDest, const char * pSource, HB_SIZE nLen );
|
||||
@@ -1030,6 +1033,7 @@ extern HB_EXPORT int hb_cmdargARGC( void ); /* retrieve command line a
|
||||
extern HB_EXPORT char ** hb_cmdargARGV( void ); /* retrieve command line argument buffer pointer */
|
||||
extern HB_EXPORT const char * hb_cmdargARGVN( int argc ); /* retrieve given command line argument */
|
||||
extern HB_EXPORT HB_BOOL hb_cmdargIsInternal( const char * szArg, int * piLen ); /* determine if a string is an internal setting */
|
||||
extern HB_EXPORT char * hb_cmdargProgName( void ); /* return application name with path or NULL if not set, caller must free returned value with hb_xfree() if not NULL */
|
||||
extern void hb_cmdargUpdate( void ); /* update arguments after HVM initialization */
|
||||
extern HB_BOOL hb_cmdargCheck( const char * pszName ); /* Check if a given internal switch (like //INFO) was set */
|
||||
extern char * hb_cmdargString( const char * pszName ); /* Returns the string value of an internal switch (like //TEMPPATH:"C:\") */
|
||||
@@ -1178,6 +1182,17 @@ extern HB_EXPORT HB_BOOL hb_osUseCP( void ); /* Is OS<->Harbour codepage co
|
||||
extern HB_EXPORT const char * hb_osEncodeCP( const char * szName, char ** pszFree, HB_SIZE * pnSize ); /* Convert a string sent to a system call, from Harbour codepage. */
|
||||
extern HB_EXPORT const char * hb_osDecodeCP( const char * szName, char ** pszFree, HB_SIZE * pnSize ); /* Convert a string received from a system call, to Harbour codepage. */
|
||||
|
||||
extern HB_EXPORT char * hb_osStrEncode( const char * pszName );
|
||||
extern HB_EXPORT char * hb_osStrEncodeN( const char * pszName, HB_SIZE nLen );
|
||||
extern HB_EXPORT char * hb_osStrDecode( const char * pszName );
|
||||
extern HB_EXPORT char * hb_osStrDecode2( const char * pszName, char * pszBuffer, HB_SIZE nSize );
|
||||
#if defined( HB_OS_WIN )
|
||||
extern HB_EXPORT HB_WCHAR * hb_osStrU16Encode( const char * pszName );
|
||||
extern HB_EXPORT HB_WCHAR * hb_osStrU16EncodeN( const char * pszName, HB_SIZE nLen );
|
||||
extern HB_EXPORT char * hb_osStrU16Decode( const HB_WCHAR * pszNameW );
|
||||
extern HB_EXPORT char * hb_osStrU16Decode2( const HB_WCHAR * pszNameW, char * pszBuffer, HB_SIZE nSize );
|
||||
#endif
|
||||
|
||||
/* environment variables access */
|
||||
extern HB_EXPORT HB_BOOL hb_getenv_buffer( const char * szName, char * szBuffer, int nSize );
|
||||
/* WARNING: This returned pointer must be freed if not NULL using hb_xfree( ptr ); */
|
||||
|
||||
@@ -71,21 +71,19 @@ HB_EXTERN_BEGIN
|
||||
#define HB_CODEPAGE_ANNOUNCE_( id ) HB_FUNC( HB_CODEPAGE_##id ) {}
|
||||
|
||||
|
||||
#if defined( HB_OS_WIN )
|
||||
typedef wchar_t HB_WCHAR;
|
||||
#else
|
||||
typedef unsigned short HB_WCHAR;
|
||||
#endif
|
||||
|
||||
|
||||
/* forward declaration */
|
||||
struct _HB_CODEPAGE;
|
||||
|
||||
#define HB_CODEPAGE_PTR struct _HB_CODEPAGE *
|
||||
|
||||
#define HB_CDPCHAR_GET( c, s, n, i, w ) (c)->wcharGet( c, s, n, i, w )
|
||||
#define HB_CDPCHAR_PUT( c, s, n, i, w ) (c)->wcharPut( c, s, n, i, w )
|
||||
#define HB_CDPCHAR_LEN( c, w ) (c)->wcharLen( c, w )
|
||||
#define HB_CDPCHAR_GET( c, s, n, i, w ) (c)->wcharGet( c, s, n, i, w )
|
||||
#define HB_CDPCHAR_PUT( c, s, n, i, w ) (c)->wcharPut( c, s, n, i, w )
|
||||
#define HB_CDPCHAR_LEN( c, w ) (c)->wcharLen( c, w )
|
||||
#define HB_CDPCHAR_UPPER( c, w ) (c)->wcharUpper( c, w )
|
||||
#define HB_CDPCHAR_LOWER( c, w ) (c)->wcharLower( c, w )
|
||||
#define HB_CDPCHAR_FLAGS( c, w ) (c)->wcharFlags( c, w )
|
||||
#define HB_CDPCHAR_CMP( c, s1, n1, s2, n2, e ) (c)->wcharCmp( c, s1, n1, s2, n2, e )
|
||||
#define HB_CDPCHAR_CMPI( c, s1, n1, s2, n2, e ) (c)->wcharCmpI( c, s1, n1, s2, n2, e )
|
||||
|
||||
#define HB_CDP_GET_FUNC( func ) HB_BOOL func( HB_CODEPAGE_PTR cdp, const char * pSrc, HB_SIZE nLen, HB_SIZE * pnIndex, HB_WCHAR * wc )
|
||||
typedef HB_CDP_GET_FUNC( ( * PHB_CDP_GET_FUNC ) );
|
||||
@@ -96,6 +94,18 @@ typedef HB_CDP_PUT_FUNC( ( * PHB_CDP_PUT_FUNC ) );
|
||||
#define HB_CDP_LEN_FUNC( func ) int func( HB_CODEPAGE_PTR cdp, HB_WCHAR wc )
|
||||
typedef HB_CDP_LEN_FUNC( ( * PHB_CDP_LEN_FUNC ) );
|
||||
|
||||
#define HB_CDP_UPPER_FUNC( func ) int func( HB_CODEPAGE_PTR cdp, HB_WCHAR wc )
|
||||
typedef HB_CDP_UPPER_FUNC( ( * PHB_CDP_UPPER_FUNC ) );
|
||||
|
||||
#define HB_CDP_LOWER_FUNC( func ) int func( HB_CODEPAGE_PTR cdp, HB_WCHAR wc )
|
||||
typedef HB_CDP_LOWER_FUNC( ( * PHB_CDP_LOWER_FUNC ) );
|
||||
|
||||
#define HB_CDP_FLAGS_FUNC( func ) int func( HB_CODEPAGE_PTR cdp, HB_WCHAR wc )
|
||||
typedef HB_CDP_FLAGS_FUNC( ( * PHB_CDP_FLAGS_FUNC ) );
|
||||
|
||||
#define HB_CDP_CMP_FUNC( func ) int func( HB_CODEPAGE_PTR cdp, const char * szFirst, HB_SIZE nLenFirst, const char * szSecond, HB_SIZE nLenSecond, HB_BOOL fExact )
|
||||
typedef HB_CDP_CMP_FUNC( ( * PHB_CDP_CMP_FUNC ) );
|
||||
|
||||
|
||||
typedef struct _HB_UNITABLE
|
||||
{
|
||||
@@ -126,10 +136,15 @@ typedef struct _HB_CODEPAGE
|
||||
const HB_UCHAR * sort;
|
||||
const HB_UCHAR * acc;
|
||||
int nACSort;
|
||||
HB_BOOL fCustom;
|
||||
int type;
|
||||
PHB_CDP_GET_FUNC wcharGet;
|
||||
PHB_CDP_PUT_FUNC wcharPut;
|
||||
PHB_CDP_LEN_FUNC wcharLen;
|
||||
PHB_CDP_UPPER_FUNC wcharUpper;
|
||||
PHB_CDP_LOWER_FUNC wcharLower;
|
||||
PHB_CDP_FLAGS_FUNC wcharFlags;
|
||||
PHB_CDP_CMP_FUNC wcharCmp;
|
||||
PHB_CDP_CMP_FUNC wcharCmpI;
|
||||
int nMulti;
|
||||
int nMultiUC;
|
||||
PHB_MULTICHAR multi;
|
||||
@@ -375,8 +390,33 @@ extern HB_EXPORT void hb_vmSetCDP( PHB_CODEPAGE pCDP );
|
||||
#define HB_CDP_ENDIAN_LITTLE 1
|
||||
#define HB_CDP_ENDIAN_BIG 2
|
||||
|
||||
#define HB_CDP_ISBINSORT(cdp) ( ( cdp )->sort == NULL )
|
||||
#define HB_CDP_ISCUSTOM(cdp) ( ( cdp )->fCustom )
|
||||
/* codepage types */
|
||||
#define HB_CDP_TYPE_CUSTOM 0x0001
|
||||
#define HB_CDP_TYPE_CHARIDX 0x0002
|
||||
#define HB_CDP_TYPE_CHARUNI 0x0004
|
||||
#define HB_CDP_TYPE_BINSORT 0x0008
|
||||
#define HB_CDP_TYPE_UTF8 0x0010
|
||||
|
||||
/* maximal size of unicode character in 'char' representation for buffers
|
||||
* To encode all ISO 10646 Universal Character Set (UCS) values (characters
|
||||
* can en encoded in 31-bit code space) in UTF-8 we need 6 bytes.
|
||||
* UC2 characters (16bytes) encoded in UTF8 needs 3 bytes.
|
||||
* 8 seems to be a little bit redundant and large enough for all encodings.
|
||||
* In theory some other encodings may need more bytes but I do not know any
|
||||
* one used in practice. [druzus]
|
||||
*/
|
||||
#define HB_MAX_CHAR_LEN 8
|
||||
|
||||
/* codepage uses simple binary sorting */
|
||||
#define HB_CDP_ISBINSORT(cdp) ( ( ( cdp )->type & HB_CDP_TYPE_BINSORT ) != 0 )
|
||||
/* codepage uses custom string decoding */
|
||||
#define HB_CDP_ISCUSTOM(cdp) ( ( ( cdp )->type & HB_CDP_TYPE_CUSTOM ) != 0 )
|
||||
/* codepage use character indexes instead of bytes ones */
|
||||
#define HB_CDP_ISCHARIDX(cdp) ( ( ( cdp )->type & HB_CDP_TYPE_CHARIDX ) != 0 )
|
||||
/* CHR(), ASC() and similar functions operates on Unicode values instead of bytes */
|
||||
#define HB_CDP_ISCHARUNI(cdp) ( ( ( cdp )->type & HB_CDP_TYPE_CHARUNI ) != 0 )
|
||||
/* codepage uses UTF-8 encoding */
|
||||
#define HB_CDP_ISUTF8(cdp) ( ( ( cdp )->type & HB_CDP_TYPE_UTF8 ) != 0 )
|
||||
|
||||
extern HB_EXPORT HB_BOOL hb_cdpRegisterRaw( PHB_CODEPAGE cdp );
|
||||
extern HB_EXPORT HB_BOOL hb_cdpRegisterNew( const char * id,
|
||||
@@ -396,10 +436,12 @@ extern HB_EXPORT PHB_CODEPAGE hb_cdpFind( const char * id );
|
||||
extern HB_EXPORT PHB_CODEPAGE hb_cdpFindExt( const char * id );
|
||||
extern HB_EXPORT const char ** hb_cdpList( void ); /* Caller must release the pointer */
|
||||
|
||||
|
||||
extern HB_EXPORT HB_BOOL hb_cdpIsDigit( PHB_CODEPAGE cdp, int iChar );
|
||||
extern HB_EXPORT HB_BOOL hb_cdpIsAlpha( PHB_CODEPAGE cdp, int iChar );
|
||||
extern HB_EXPORT HB_BOOL hb_cdpIsLower( PHB_CODEPAGE cdp, int iChar );
|
||||
extern HB_EXPORT HB_BOOL hb_cdpIsUpper( PHB_CODEPAGE cdp, int iChar );
|
||||
|
||||
extern HB_EXPORT int hb_cdpcmp( const char * szFirst, HB_SIZE nLenFirst, const char * szSecond, HB_SIZE nLenSecond, PHB_CODEPAGE cdp, HB_BOOL fExact );
|
||||
extern HB_EXPORT int hb_cdpicmp( const char * szFirst, HB_SIZE nLenFirst, const char * szSecond, HB_SIZE nLenSecond, PHB_CODEPAGE cdp, HB_BOOL fExact );
|
||||
extern HB_EXPORT const HB_UCHAR * hb_cdpGetSortTab( PHB_CODEPAGE cdp );
|
||||
@@ -417,14 +459,19 @@ extern HB_EXPORT char * hb_cdpnDupLower( PHB_CODEPAGE cdp, const char * ps
|
||||
extern HB_EXPORT HB_SIZE hb_cdpnDup2Upper( PHB_CODEPAGE cdp, const char * pszText, HB_SIZE nSize, char * buffer, HB_SIZE nBuffLen );
|
||||
extern HB_EXPORT HB_SIZE hb_cdpnDup2Lower( PHB_CODEPAGE cdp, const char * pszText, HB_SIZE nSize, char * buffer, HB_SIZE nBuffLen );
|
||||
|
||||
extern HB_EXPORT int hb_cdpTranslateChar( int iChar, PHB_CODEPAGE cdpIn, PHB_CODEPAGE cdpOut );
|
||||
extern HB_EXPORT int hb_cdpTranslateDispChar( int iChar, PHB_CODEPAGE cdpIn, PHB_CODEPAGE cdpOut );
|
||||
extern HB_EXPORT HB_SIZE hb_cdpTransLen( const char * pSrc, HB_SIZE nSrc, HB_SIZE nMax, PHB_CODEPAGE cdpIn, PHB_CODEPAGE cdpOut );
|
||||
extern HB_EXPORT HB_SIZE hb_cdpTransTo( const char * pSrc, HB_SIZE nSrc, char * pDst, HB_SIZE nDst, PHB_CODEPAGE cdpIn, PHB_CODEPAGE cdpOut );
|
||||
|
||||
extern HB_EXPORT HB_WCHAR hb_cdpGetU16( PHB_CODEPAGE cdp, HB_UCHAR ch );
|
||||
extern HB_EXPORT HB_WCHAR hb_cdpGetU16Disp( PHB_CODEPAGE cdp, HB_UCHAR ch );
|
||||
extern HB_EXPORT HB_SIZE hb_cdpStrToUTF8Disp( PHB_CODEPAGE cdp, const char * pSrc, HB_SIZE nSrc, char * pDst, HB_SIZE nDst );
|
||||
extern HB_EXPORT int hb_cdpTranslateDispChar( int iChar, PHB_CODEPAGE cdpIn, PHB_CODEPAGE cdpOut );
|
||||
extern HB_EXPORT int hb_cdpTranslateChar( int iChar, PHB_CODEPAGE cdpIn, PHB_CODEPAGE cdpOut );
|
||||
|
||||
extern HB_EXPORT HB_UCHAR hb_cdpGetChar( PHB_CODEPAGE cdp, HB_WCHAR wc );
|
||||
extern HB_EXPORT HB_WCHAR hb_cdpGetU16( PHB_CODEPAGE cdp, HB_UCHAR ch );
|
||||
extern HB_EXPORT HB_UCHAR hb_cdpGetUC( PHB_CODEPAGE cdp, HB_WCHAR wc, HB_UCHAR ucDef );
|
||||
extern HB_EXPORT HB_WCHAR hb_cdpGetWC( PHB_CODEPAGE cdp, HB_UCHAR ch, HB_WCHAR wcDef );
|
||||
|
||||
extern HB_EXPORT HB_BOOL hb_cdpGetFromUTF8( PHB_CODEPAGE cdp, HB_UCHAR ch, int * n, HB_WCHAR * pwc );
|
||||
|
||||
extern HB_EXPORT HB_SIZE hb_cdpUTF8StringLength( const char * pSrc, HB_SIZE nLen );
|
||||
@@ -436,7 +483,6 @@ extern HB_EXPORT HB_SIZE hb_cdpUTF8AsStrLen( PHB_CODEPAGE cdp, const char *
|
||||
extern HB_EXPORT HB_SIZE hb_cdpUTF8ToStr( PHB_CODEPAGE cdp, const char * pSrc, HB_SIZE nSrc, char * pDst, HB_SIZE nDst );
|
||||
extern HB_EXPORT HB_SIZE hb_cdpStrAsUTF8Len( PHB_CODEPAGE cdp, const char * pSrc, HB_SIZE nSrc, HB_SIZE nMax );
|
||||
extern HB_EXPORT HB_SIZE hb_cdpStrToUTF8( PHB_CODEPAGE cdp, const char * pSrc, HB_SIZE nSrc, char * pDst, HB_SIZE nDst );
|
||||
extern HB_EXPORT HB_SIZE hb_cdpStrToUTF8Disp( PHB_CODEPAGE cdp, const char * pSrc, HB_SIZE nSrc, char * pDst, HB_SIZE nDst );
|
||||
|
||||
extern HB_EXPORT HB_SIZE hb_cdpU16AsStrLen( PHB_CODEPAGE cdp, const HB_WCHAR * pSrc, HB_SIZE nSrc, HB_SIZE nMax );
|
||||
extern HB_EXPORT HB_SIZE hb_cdpU16ToStr( PHB_CODEPAGE cdp, int iEndian, const HB_WCHAR * pSrc, HB_SIZE nSrc, char * pDst, HB_SIZE nDst );
|
||||
@@ -446,16 +492,29 @@ extern HB_EXPORT HB_WCHAR * hb_cdpStrDupU16( PHB_CODEPAGE cdp, int iEndian, co
|
||||
extern HB_EXPORT HB_WCHAR * hb_cdpStrDupnU16( PHB_CODEPAGE cdp, int iEndian, const char * pSrc, HB_SIZE nSrc );
|
||||
extern HB_EXPORT HB_WCHAR * hb_cdpnStrDupU16( PHB_CODEPAGE cdp, int iEndian, const char * pSrc, HB_SIZE nSrc, HB_SIZE * pnDst );
|
||||
|
||||
extern HB_EXPORT HB_WCHAR hb_cdpGetU16Ctrl( HB_WCHAR wc );
|
||||
|
||||
extern HB_EXPORT int hb_cdpUTF8CharSize( HB_WCHAR wc );
|
||||
extern HB_EXPORT int hb_cdpU16CharToUTF8( char * szUTF8, HB_WCHAR wc );
|
||||
extern HB_EXPORT HB_BOOL hb_cdpUTF8ToU16NextChar( HB_UCHAR ucChar, int * n, HB_WCHAR * pwc );
|
||||
|
||||
|
||||
extern HB_EXPORT PHB_ITEM hb_itemDeserializeCP( const char ** pBufferPtr, HB_SIZE * pnSize, PHB_CODEPAGE cdpIn, PHB_CODEPAGE cdpOut );
|
||||
extern HB_EXPORT char * hb_itemSerializeCP( PHB_ITEM pItem, HB_BOOL fNumSize, PHB_CODEPAGE cdpIn, PHB_CODEPAGE cdpOut, HB_SIZE * pnSize );
|
||||
|
||||
#if defined( HB_OS_WIN )
|
||||
extern HB_EXPORT HB_WCHAR * hb_fsNameConvU16( const char * szFileName );
|
||||
#endif
|
||||
extern HB_EXPORT HB_WCHAR hb_cdpUpperWC( PHB_CODEPAGE cdp, HB_WCHAR wc );
|
||||
|
||||
/* functions operating on character indexes */
|
||||
extern HB_EXPORT HB_SIZE hb_cdpTextLen( PHB_CODEPAGE cdp, const char * pText, HB_SIZE nSize );
|
||||
extern HB_EXPORT HB_SIZE hb_cdpTextPos( PHB_CODEPAGE cdp, const char * pText, HB_SIZE nSize, HB_SIZE nIndex );
|
||||
extern HB_EXPORT HB_SIZE hb_cdpTextPosEx( PHB_CODEPAGE cdp, const char * pText, HB_SIZE nSize, HB_SIZE * pnIndex );
|
||||
|
||||
extern HB_EXPORT HB_WCHAR hb_cdpTextGetU16( PHB_CODEPAGE cdp, const char * szText, HB_SIZE nLen );
|
||||
extern HB_EXPORT HB_SIZE hb_cdpTextPutU16( PHB_CODEPAGE cdp, char * szText, HB_SIZE nSize, HB_WCHAR wc );
|
||||
extern HB_EXPORT HB_BOOL hb_cdpCharEq( PHB_CODEPAGE cdp, const char * szText1, HB_SIZE nLen1, HB_SIZE * pnPos1,
|
||||
const char * szText2, HB_SIZE nLen2, HB_SIZE * pnPos2 );
|
||||
extern HB_EXPORT HB_BOOL hb_cdpCharCaseEq( PHB_CODEPAGE cdp, const char * szText1, HB_SIZE nLen1, HB_SIZE * pnPos1,
|
||||
const char * szText2, HB_SIZE nLen2, HB_SIZE * pnPos2 );
|
||||
|
||||
HB_EXTERN_END
|
||||
|
||||
|
||||
@@ -262,6 +262,7 @@ typedef struct
|
||||
const char * pszFileMask;
|
||||
HB_FATTR attrmask;
|
||||
HB_BOOL bFirst;
|
||||
char * pszFree;
|
||||
|
||||
void * info; /* Pointer to the platform specific find info */
|
||||
#endif
|
||||
@@ -293,6 +294,9 @@ extern HB_EXPORT char * hb_fsAttrDecode( HB_FATTR ulAttr, char * szAttr );
|
||||
|
||||
extern HB_EXPORT HB_BOOL hb_fsMaxFilesError( void );
|
||||
extern HB_EXPORT const char * hb_fsNameConv( const char * szFileName, char ** pszFree );
|
||||
#if defined( HB_OS_WIN )
|
||||
extern HB_EXPORT HB_WCHAR * hb_fsNameConvU16( const char * szFileName );
|
||||
#endif
|
||||
|
||||
/* Harbour file functions with shared file handles and locks
|
||||
* (buffers in the future)
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
#define HB_APIGT_H_
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapicdp.h"
|
||||
|
||||
HB_EXTERN_BEGIN
|
||||
|
||||
@@ -123,6 +124,16 @@ HB_EXTERN_BEGIN
|
||||
#define HB_B_DOUBLE_V '\xBA'
|
||||
#define HB_B_DOUBLE_H '\xCD'
|
||||
|
||||
#define HB_B_SINGLE_W { 0x250C, 0x2500, 0x2510, 0x2502, 0x2518, 0x2500, 0x2514, 0x2502, 0x0000 }
|
||||
#define HB_B_DOUBLE_W { 0x2554, 0x2550, 0x2557, 0x2551, 0x255D, 0x2550, 0x255A, 0x2551, 0x0000 }
|
||||
#define HB_B_SINGLE_DOUBLE_W { 0x2553, 0x2500, 0x2556, 0x2551, 0x255C, 0x2500, 0x2559, 0x2551, 0x0000 }
|
||||
#define HB_B_DOUBLE_SINGLE_W { 0x2552, 0x2550, 0x2555, 0x2502, 0x255B, 0x2550, 0x2558, 0x2502, 0x0000 }
|
||||
#define HB_B_HALF_FULL_W { 0x2588, 0x2580, 0x2588, 0x2588, 0x2588, 0x2584, 0x2588, 0x2588, 0x0000 }
|
||||
#define HB_B_HALF_W { 0x2590, 0x2580, 0x258C, 0x258C, 0x258C, 0x2584, 0x2590, 0x2590, 0x0000 }
|
||||
#define HB_B_FULL_HALF_W { 0x2590, 0x2588, 0x258C, 0x258C, 0x258C, 0x2588, 0x2590, 0x2590, 0x0000 }
|
||||
#define HB_B_FULL_W { 0x2588, 0x2588, 0x2588, 0x2588, 0x2588, 0x2588, 0x2588, 0x2588, 0x0000 }
|
||||
|
||||
|
||||
#if defined( HB_COMPAT_C53 ) && !defined( HB_CLP_STRICT )
|
||||
# define HB_DEFAULT_INKEY_BUFSIZE 50
|
||||
#else
|
||||
@@ -218,6 +229,8 @@ extern HB_EXPORT HB_ERRCODE hb_gtOutStd( const char * szStr, HB_SIZE nLen );
|
||||
extern HB_EXPORT HB_ERRCODE hb_gtOutErr( const char * szStr, HB_SIZE nLen );
|
||||
extern HB_EXPORT HB_ERRCODE hb_gtSetDispCP( const char * pszTermCDP, const char * pszHostCDP, HB_BOOL fBox );
|
||||
extern HB_EXPORT HB_ERRCODE hb_gtSetKeyCP( const char * pszTermCDP, const char * pszHostCDP );
|
||||
extern HB_EXPORT PHB_CODEPAGE hb_gtHostCP( void );
|
||||
extern HB_EXPORT PHB_CODEPAGE hb_gtBoxCP( void );
|
||||
extern HB_EXPORT HB_ERRCODE hb_gtInfo( int iType, PHB_GT_INFO pInfo );
|
||||
extern HB_EXPORT int hb_gtAlert( PHB_ITEM pMessage, PHB_ITEM pOptions, int iClrNorm, int iClrHigh, double dDelay );
|
||||
extern HB_EXPORT int hb_gtSetFlag( int iType, int iNewValue );
|
||||
@@ -299,6 +312,12 @@ extern HB_EXPORT HB_ERRCODE hb_gtSetBorder( HB_GT_RGB * color );
|
||||
Clipper has no key code 256, so it may as well be
|
||||
used for all the Harbour builds that need it */
|
||||
|
||||
/* mouse buttons */
|
||||
#define HB_MBUTTON_LEFT 0
|
||||
#define HB_MBUTTON_RIGHT 1
|
||||
#define HB_MBUTTON_MIDDLE 2
|
||||
|
||||
|
||||
/* Harbour keyboard support functions */
|
||||
extern HB_EXPORT int hb_inkey( HB_BOOL bWait, double dSeconds, int iEvenMask ); /* Wait for keyboard input */
|
||||
extern HB_EXPORT void hb_inkeyPut( int ch ); /* Inserts an inkey code into the keyboard buffer */
|
||||
@@ -312,6 +331,9 @@ extern HB_EXPORT void hb_inkeySetText( const char * szText, HB_SIZE nLen )
|
||||
extern HB_EXPORT int hb_inkeySetLast( int iKey ); /* Set new LASTKEY() value, return previous one */
|
||||
extern HB_EXPORT void hb_inkeyExit( void ); /* reset inkey pool to default state and free any allocated resources */
|
||||
|
||||
extern HB_EXPORT HB_SIZE hb_inkeyKeyString( int iKey, char * buffer, HB_SIZE nSize ); /* convert key value to string */
|
||||
extern HB_EXPORT int hb_inkeyKeyStd( int iKey ); /* convert Harbour extended key code to cl*pper inkey code */
|
||||
|
||||
HB_EXTERN_END
|
||||
|
||||
#endif /* HB_APIGT_H_ */
|
||||
|
||||
@@ -61,13 +61,15 @@ HB_CALL_ON_STARTUP_BEGIN( HB_MACRONAME_JOIN( _hb_codepage_Init_, HB_CP_ID ) )
|
||||
#endif
|
||||
|
||||
#if defined( HB_CP_RAW )
|
||||
#if !defined( HB_CP_CUSTOM )
|
||||
#if defined( HB_CP_CUSTOM )
|
||||
#define HB_CP_TP_CUSTOM HB_CDP_TYPE_CUSTOM
|
||||
#else
|
||||
#if defined( HB_CP_GET_FUNC ) && \
|
||||
defined( HB_CP_PUT_FUNC ) && \
|
||||
defined( HB_CP_LEN_FUNC )
|
||||
#define HB_CP_CUSTOM HB_TRUE
|
||||
#define HB_CP_TP_CUSTOM HB_CDP_TYPE_CUSTOM
|
||||
#else
|
||||
#define HB_CP_CUSTOM HB_FALSE
|
||||
#define HB_CP_TP_CUSTOM 0
|
||||
#define HB_CP_GET_FUNC NULL
|
||||
#define HB_CP_PUT_FUNC NULL
|
||||
#define HB_CP_LEN_FUNC NULL
|
||||
@@ -82,7 +84,29 @@ HB_CALL_ON_STARTUP_BEGIN( HB_MACRONAME_JOIN( _hb_codepage_Init_, HB_CP_ID ) )
|
||||
#ifndef HB_CP_CMP_FUNC
|
||||
#define HB_CP_CMP_FUNC NULL
|
||||
#endif
|
||||
#ifndef HB_CP_CMPI_FUNC
|
||||
#define HB_CP_CMPI_FUNC NULL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined( HB_CP_CHARIDX )
|
||||
#define HB_CP_TP_CHARIDX HB_CDP_TYPE_CHARIDX
|
||||
#else
|
||||
#define HB_CP_TP_CHARIDX 0
|
||||
#endif
|
||||
|
||||
#if defined( HB_CP_CHARUNI )
|
||||
#define HB_CP_TP_CHARUNI HB_CDP_TYPE_CHARUNI
|
||||
#else
|
||||
#define HB_CP_TP_CHARUNI 0
|
||||
#endif
|
||||
|
||||
#if defined( HB_CP_UTF8 )
|
||||
#define HB_CP_TP_UTF8 HB_CDP_TYPE_UTF8
|
||||
#else
|
||||
#define HB_CP_TP_UTF8 0
|
||||
#endif
|
||||
|
||||
static HB_CODEPAGE s_codePage =
|
||||
{
|
||||
HB_MACRO2STRING( HB_CP_ID ),
|
||||
@@ -94,10 +118,15 @@ HB_CALL_ON_STARTUP_BEGIN( HB_MACRONAME_JOIN( _hb_codepage_Init_, HB_CP_ID ) )
|
||||
s_sort,
|
||||
NULL,
|
||||
HB_CDP_ACSORT_NONE,
|
||||
HB_CP_CUSTOM,
|
||||
( HB_CP_TP_CUSTOM | HB_CP_TP_CHARIDX | HB_CP_TP_CHARUNI | HB_CP_TP_UTF8 ),
|
||||
HB_CP_GET_FUNC,
|
||||
HB_CP_PUT_FUNC,
|
||||
HB_CP_LEN_FUNC,
|
||||
HB_CP_UPPER_FUNC,
|
||||
HB_CP_LOWER_FUNC,
|
||||
HB_CP_FLAGS_FUNC,
|
||||
HB_CP_CMP_FUNC,
|
||||
HB_CP_CMPI_FUNC,
|
||||
0,
|
||||
0,
|
||||
NULL,
|
||||
|
||||
@@ -383,6 +383,7 @@ extern const HB_BYTE hb_comp_pcode_len[];
|
||||
#define HB_COMPFLAG_OPTJUMP 0x0100 /* -kj turn off jump optimalization */
|
||||
#define HB_COMPFLAG_HB_INLINE 0x0200 /* -ki hb_inLine(...) { ... } support */
|
||||
#define HB_COMPFLAG_MACROTEXT 0x0400 /* -kM turn off macrotext substitution */
|
||||
#define HB_COMPFLAG_USERCP 0x0800 /* -kU strings in user encoding */
|
||||
|
||||
#define HB_COMP_ISSUPPORTED(flag) ( HB_COMP_PARAM->supported & (flag) )
|
||||
|
||||
@@ -391,6 +392,7 @@ extern const HB_BYTE hb_comp_pcode_len[];
|
||||
#define HB_SUPPORT_ARRSTR ( HB_COMP_ISSUPPORTED(HB_COMPFLAG_ARRSTR) )
|
||||
#define HB_SUPPORT_EXTOPT ( HB_COMP_ISSUPPORTED(HB_COMPFLAG_EXTOPT) )
|
||||
#define HB_SUPPORT_MACROTEXT ( HB_COMP_ISSUPPORTED(HB_COMPFLAG_MACROTEXT) )
|
||||
#define HB_SUPPORT_USERCP ( HB_COMP_ISSUPPORTED(HB_COMPFLAG_USERCP) )
|
||||
|
||||
#if defined( HB_MACRO_SUPPORT )
|
||||
# define HB_MACRO_GENFLAGS HB_COMPFLAG_RT_MACRO
|
||||
|
||||
@@ -122,7 +122,7 @@ DYNAMIC HB_CODEPAGE_UA866
|
||||
DYNAMIC HB_CODEPAGE_UAKOI8
|
||||
DYNAMIC HB_CODEPAGE_UTF16LE
|
||||
DYNAMIC HB_CODEPAGE_UTF8
|
||||
DYNAMIC HB_CODEPAGE_UTF8ASC
|
||||
DYNAMIC HB_CODEPAGE_UTF8EX
|
||||
|
||||
#if defined( __HBEXTREQ__ ) .OR. defined( __HBEXTERN__HBCPAGE__REQUEST )
|
||||
#uncommand DYNAMIC <fncs,...> => EXTERNAL <fncs>
|
||||
|
||||
@@ -608,6 +608,12 @@ typedef HB_U32 HB_FATTR;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined( HB_OS_WIN )
|
||||
typedef wchar_t HB_WCHAR;
|
||||
#else
|
||||
typedef unsigned short HB_WCHAR;
|
||||
#endif
|
||||
|
||||
/* maximum length of double number in decimal representation:
|
||||
log10(2^1024) ~ 308.25 */
|
||||
#define HB_MAX_DOUBLE_LENGTH 320
|
||||
|
||||
@@ -154,6 +154,7 @@ typedef struct
|
||||
void (* GetScrCursor) ( HB_GT_PTR, int *, int *, int * );
|
||||
HB_BOOL (* GetScrChar) ( HB_GT_PTR, int, int, int *, HB_BYTE *, HB_USHORT * );
|
||||
HB_BOOL (* PutScrChar) ( HB_GT_PTR, int, int, int, HB_BYTE, HB_USHORT );
|
||||
HB_BOOL (* GetScrUC) ( HB_GT_PTR, int, int, int *, HB_BYTE *, HB_UCHAR *, HB_BOOL );
|
||||
void (* DispBegin) ( HB_GT_PTR );
|
||||
void (* DispEnd) ( HB_GT_PTR );
|
||||
int (* DispCount) ( HB_GT_PTR );
|
||||
@@ -162,16 +163,21 @@ typedef struct
|
||||
long (* RectSize) ( HB_GT_PTR, int, int, int, int );
|
||||
void (* Save) ( HB_GT_PTR, int, int, int, int, void * );
|
||||
void (* Rest) ( HB_GT_PTR, int, int, int, int, const void * );
|
||||
void (* PutText) ( HB_GT_PTR, int, int, int, const char *, HB_SIZE );
|
||||
int (* PutText) ( HB_GT_PTR, int, int, int, const char *, HB_SIZE );
|
||||
int (* PutTextW) ( HB_GT_PTR, int, int, int, const HB_WCHAR *, HB_SIZE );
|
||||
void (* Replicate) ( HB_GT_PTR, int, int, int, HB_BYTE, HB_USHORT, HB_SIZE );
|
||||
void (* WriteAt) ( HB_GT_PTR, int, int, const char *, HB_SIZE );
|
||||
void (* WriteAtW) ( HB_GT_PTR, int, int, const HB_WCHAR *, HB_SIZE );
|
||||
void (* Write) ( HB_GT_PTR, const char *, HB_SIZE );
|
||||
void (* WriteW) ( HB_GT_PTR, const HB_WCHAR *, HB_SIZE );
|
||||
void (* WriteCon) ( HB_GT_PTR, const char *, HB_SIZE );
|
||||
void (* WriteConW) ( HB_GT_PTR, const HB_WCHAR *, HB_SIZE );
|
||||
void (* SetAttribute) ( HB_GT_PTR, int, int, int, int, int );
|
||||
void (* DrawShadow) ( HB_GT_PTR, int, int, int, int, int );
|
||||
void (* Scroll) ( HB_GT_PTR, int, int, int, int, int, HB_USHORT, int, int );
|
||||
void (* ScrollUp) ( HB_GT_PTR, int, int, HB_USHORT );
|
||||
void (* Box) ( HB_GT_PTR, int, int, int, int, const char *, int );
|
||||
void (* BoxW) ( HB_GT_PTR, int, int, int, int, const HB_WCHAR *, int );
|
||||
void (* BoxD) ( HB_GT_PTR, int, int, int, int, const char *, int );
|
||||
void (* BoxS) ( HB_GT_PTR, int, int, int, int, const char *, int );
|
||||
void (* HorizLine) ( HB_GT_PTR, int, int, int, HB_USHORT, int );
|
||||
@@ -308,6 +314,8 @@ typedef struct _HB_GT_BASE
|
||||
HB_BOOL fDispTrans;
|
||||
PHB_CODEPAGE cdpTerm;
|
||||
PHB_CODEPAGE cdpHost;
|
||||
PHB_CODEPAGE cdpBox;
|
||||
PHB_CODEPAGE cdpIn;
|
||||
|
||||
int iColorIndex;
|
||||
int iColorCount;
|
||||
@@ -349,6 +357,19 @@ extern HB_EXPORT void hb_gt_gcMark( void );
|
||||
|
||||
#define HB_GTLOCAL(g) (g)->pGTData[*HB_GTID_PTR]
|
||||
|
||||
#define HB_GTSELF_TERMCP(g) ((g)->cdpTerm ? (g)->cdpTerm : HB_GTSELF_HOSTCP(g))
|
||||
#define HB_GTSELF_HOSTCP(g) ((g)->cdpHost ? (g)->cdpHost : hb_vmCDP())
|
||||
#define HB_GTSELF_BOXCP(g) ((g)->cdpBox ? (g)->cdpBox : HB_GTSELF_HOSTCP(g))
|
||||
#define HB_GTSELF_INCP(g) ((g)->cdpIn ? (g)->cdpIn : hb_vmCDP())
|
||||
|
||||
#define HB_GTSELF_CPTERM(g) ((g)->cdpTerm)
|
||||
#define HB_GTSELF_CPHOST(g) ((g)->cdpHost)
|
||||
#define HB_GTSELF_CPBOX(g) ((g)->cdpBox)
|
||||
#define HB_GTSELF_CPIN(g) ((g)->cdpIn)
|
||||
|
||||
#define HB_GTSELF_KEYTRANS(g,k) (((k)>=127 && (k)<=255 && (g)->cdpIn) ? hb_cdpGetWC((g)->cdpIn,(HB_UCHAR)(k),0) : (k))
|
||||
|
||||
|
||||
#define HB_GTSELF_LOCK(g) (g)->pFuncTable->Lock(g)
|
||||
#define HB_GTSELF_UNLOCK(g) (g)->pFuncTable->Unlock(g)
|
||||
#define HB_GTSELF_INIT(g,i,o,e) (g)->pFuncTable->Init(g,i,o,e)
|
||||
@@ -392,6 +413,7 @@ extern HB_EXPORT void hb_gt_gcMark( void );
|
||||
#define HB_GTSELF_GETSCRCURSOR(g,pr,pc,ps) (g)->pFuncTable->GetScrCursor(g,pr,pc,ps)
|
||||
#define HB_GTSELF_GETSCRCHAR(g,r,c,pm,pa,pc) (g)->pFuncTable->GetScrChar(g,r,c,pm,pa,pc)
|
||||
#define HB_GTSELF_PUTSCRCHAR(g,r,c,m,a,u) (g)->pFuncTable->PutScrChar(g,r,c,m,a,u)
|
||||
#define HB_GTSELF_GETSCRUC(g,r,c,pm,pa,pc,f) (g)->pFuncTable->GetScrUC(g,r,c,pm,pa,pc,f)
|
||||
#define HB_GTSELF_DISPBEGIN(g) (g)->pFuncTable->DispBegin(g)
|
||||
#define HB_GTSELF_DISPEND(g) (g)->pFuncTable->DispEnd(g)
|
||||
#define HB_GTSELF_DISPCOUNT(g) (g)->pFuncTable->DispCount(g)
|
||||
@@ -401,15 +423,20 @@ extern HB_EXPORT void hb_gt_gcMark( void );
|
||||
#define HB_GTSELF_SAVE(g,t,l,b,r,p) (g)->pFuncTable->Save(g,t,l,b,r,p)
|
||||
#define HB_GTSELF_REST(g,t,l,b,r,p) (g)->pFuncTable->Rest(g,t,l,b,r,p)
|
||||
#define HB_GTSELF_PUTTEXT(g,r,c,m,s,l) (g)->pFuncTable->PutText(g,r,c,m,s,l)
|
||||
#define HB_GTSELF_PUTTEXTW(g,r,c,m,s,l) (g)->pFuncTable->PutTextW(g,r,c,m,s,l)
|
||||
#define HB_GTSELF_REPLICATE(g,r,c,m,a,u,l) (g)->pFuncTable->Replicate(g,r,c,m,a,u,l)
|
||||
#define HB_GTSELF_WRITEAT(g,r,c,s,l) (g)->pFuncTable->WriteAt(g,r,c,s,l)
|
||||
#define HB_GTSELF_WRITEATW(g,r,c,s,l) (g)->pFuncTable->WriteAtW(g,r,c,s,l)
|
||||
#define HB_GTSELF_WRITE(g,s,l) (g)->pFuncTable->Write(g,s,l)
|
||||
#define HB_GTSELF_WRITEW(g,s,l) (g)->pFuncTable->WriteW(g,s,l)
|
||||
#define HB_GTSELF_WRITECON(g,s,l) (g)->pFuncTable->WriteCon(g,s,l)
|
||||
#define HB_GTSELF_WRITECONW(g,s,l) (g)->pFuncTable->WriteConW(g,s,l)
|
||||
#define HB_GTSELF_SETATTRIBUTE(g,t,l,b,r,m) (g)->pFuncTable->SetAttribute(g,t,l,b,r,m)
|
||||
#define HB_GTSELF_DRAWSHADOW(g,t,l,b,r,m) (g)->pFuncTable->DrawShadow(g,t,l,b,r,m)
|
||||
#define HB_GTSELF_SCROLL(g,t,l,b,r,m,u,v,h) (g)->pFuncTable->Scroll(g,t,l,b,r,m,u,v,h)
|
||||
#define HB_GTSELF_SCROLLUP(g,r,m,u) (g)->pFuncTable->ScrollUp(g,r,m,u)
|
||||
#define HB_GTSELF_BOX(g,t,l,b,r,f,m) (g)->pFuncTable->Box(g,t,l,b,r,f,m)
|
||||
#define HB_GTSELF_BOXW(g,t,l,b,r,f,m) (g)->pFuncTable->BoxW(g,t,l,b,r,f,m)
|
||||
#define HB_GTSELF_BOXD(g,t,l,b,r,f,m) (g)->pFuncTable->BoxD(g,t,l,b,r,f,m)
|
||||
#define HB_GTSELF_BOXS(g,t,l,b,r,f,m) (g)->pFuncTable->BoxS(g,t,l,b,r,f,m)
|
||||
#define HB_GTSELF_HORIZLINE(g,h,l,r,u,m) (g)->pFuncTable->HorizLine(g,h,l,r,u,m)
|
||||
@@ -516,6 +543,7 @@ extern HB_EXPORT void hb_gt_gcMark( void );
|
||||
#define HB_GTSUPER_GETSCRCURSOR(g,pr,pc,ps) (HB_GTSUPERTABLE(g))->GetScrCursor(g,pr,pc,ps)
|
||||
#define HB_GTSUPER_GETSCRCHAR(g,r,c,pm,pa,pc) (HB_GTSUPERTABLE(g))->GetScrChar(g,r,c,pm,pa,pc)
|
||||
#define HB_GTSUPER_PUTSCRCHAR(g,r,c,m,a,u) (HB_GTSUPERTABLE(g))->PutScrChar(g,r,c,m,a,u)
|
||||
#define HB_GTSUPER_GETSCRUC(g,r,c,pm,pa,pc,f) (HB_GTSUPERTABLE(g))->GetScrUC(g,r,c,pm,pa,pc,f)
|
||||
#define HB_GTSUPER_DISPBEGIN(g) (HB_GTSUPERTABLE(g))->DispBegin(g)
|
||||
#define HB_GTSUPER_DISPEND(g) (HB_GTSUPERTABLE(g))->DispEnd(g)
|
||||
#define HB_GTSUPER_DISPCOUNT(g) (HB_GTSUPERTABLE(g))->DispCount(g)
|
||||
@@ -525,15 +553,20 @@ extern HB_EXPORT void hb_gt_gcMark( void );
|
||||
#define HB_GTSUPER_SAVE(g,t,l,b,r,p) (HB_GTSUPERTABLE(g))->Save(g,t,l,b,r,p)
|
||||
#define HB_GTSUPER_REST(g,t,l,b,r,p) (HB_GTSUPERTABLE(g))->Rest(g,t,l,b,r,p)
|
||||
#define HB_GTSUPER_PUTTEXT(g,r,c,m,s,l) (HB_GTSUPERTABLE(g))->PutText(g,r,c,m,s,l)
|
||||
#define HB_GTSUPER_PUTTEXTW(g,r,c,m,s,l) (HB_GTSUPERTABLE(g))->PutTextW(g,r,c,m,s,l)
|
||||
#define HB_GTSUPER_REPLICATE(g,r,c,m,a,u,l) (HB_GTSUPERTABLE(g))->Replicate(g,r,c,m,a,u,l)
|
||||
#define HB_GTSUPER_WRITEAT(g,r,c,s,l) (HB_GTSUPERTABLE(g))->WriteAt(g,r,c,s,l)
|
||||
#define HB_GTSUPER_WRITEATW(g,r,c,s,l) (HB_GTSUPERTABLE(g))->WriteAtW(g,r,c,s,l)
|
||||
#define HB_GTSUPER_WRITE(g,s,l) (HB_GTSUPERTABLE(g))->Write(g,s,l)
|
||||
#define HB_GTSUPER_WRITEW(g,s,l) (HB_GTSUPERTABLE(g))->WriteW(g,s,l)
|
||||
#define HB_GTSUPER_WRITECON(g,s,l) (HB_GTSUPERTABLE(g))->WriteCon(g,s,l)
|
||||
#define HB_GTSUPER_WRITECONW(g,s,l) (HB_GTSUPERTABLE(g))->WriteConW(g,s,l)
|
||||
#define HB_GTSUPER_SETATTRIBUTE(g,t,l,b,r,m) (HB_GTSUPERTABLE(g))->SetAttribute(g,t,l,b,r,m)
|
||||
#define HB_GTSUPER_DRAWSHADOW(g,t,l,b,r,m) (HB_GTSUPERTABLE(g))->DrawShadow(g,t,l,b,r,m)
|
||||
#define HB_GTSUPER_SCROLL(g,t,l,b,r,m,u,v,h) (HB_GTSUPERTABLE(g))->Scroll(g,t,l,b,r,m,u,v,h)
|
||||
#define HB_GTSUPER_SCROLLUP(g,r,m,u) (HB_GTSUPERTABLE(g))->ScrollUp(g,r,m,u)
|
||||
#define HB_GTSUPER_BOX(g,t,l,b,r,f,m) (HB_GTSUPERTABLE(g))->Box(g,t,l,b,r,f,m)
|
||||
#define HB_GTSUPER_BOXW(g,t,l,b,r,f,m) (HB_GTSUPERTABLE(g))->BoxW(g,t,l,b,r,f,m)
|
||||
#define HB_GTSUPER_BOXD(g,t,l,b,r,f,m) (HB_GTSUPERTABLE(g))->BoxD(g,t,l,b,r,f,m)
|
||||
#define HB_GTSUPER_BOXS(g,t,l,b,r,f,m) (HB_GTSUPERTABLE(g))->BoxS(g,t,l,b,r,f,m)
|
||||
#define HB_GTSUPER_HORIZLINE(g,h,l,r,u,m) (HB_GTSUPERTABLE(g))->HorizLine(g,h,l,r,u,m)
|
||||
@@ -612,6 +645,50 @@ extern HB_EXPORT void hb_gt_winapi_tone( double dFrequency, double dDuration
|
||||
extern int hb_gt_dos_keyCodeTranslate( int iKey );
|
||||
#endif /* HB_OS_DOS || HB_OS_WIN || HB_OS_OS2 */
|
||||
|
||||
/* macros to manipulate Harbour extended key codes */
|
||||
#define HB_INKEY_EXT_MASK 0xF8000000
|
||||
#define HB_INKEY_EXT_BIT 0x40000000
|
||||
#define HB_INKEY_EXT_TYPEMASK 0xFF000000
|
||||
#define HB_INKEY_EXT_VALBITS 16
|
||||
#define HB_INKEY_EXT_VALMASK ( ( 1 << HB_INKEY_EXT_VALBITS ) - 1 )
|
||||
#define HB_INKEY_EXT_FLAGMASK ( 0xFF << HB_INKEY_EXT_VALBITS )
|
||||
#define HB_INKEY_EXT_KEY 0x01000000
|
||||
#define HB_INKEY_EXT_CHAR 0x02000000
|
||||
#define HB_INKEY_EXT_UNICODE 0x03000000
|
||||
#define HB_INKEY_EXT_MOUSEKEY 0x04000000
|
||||
#define HB_INKEY_EXT_MOUSEPOS 0x05000000
|
||||
#define HB_INKEY_EXT_EVENT 0x06000000
|
||||
#define HB_INKEY_EXT_POSBITS 12
|
||||
#define HB_INKEY_EXT_POSMASK ( ( 1 << HB_INKEY_EXT_POSBITS ) - 1 )
|
||||
|
||||
#define HB_INKEY_ISEXT( n ) ( ( ( n ) & HB_INKEY_EXT_MASK ) == HB_INKEY_EXT_BIT )
|
||||
#define HB_INKEY_TYPE( n ) ( ( ( n ) ^ HB_INKEY_EXT_BIT ) & HB_INKEY_EXT_TYPEMASK )
|
||||
#define HB_INKEY_ISKEY( n ) ( HB_INKEY_TYPE( n ) == HB_INKEY_EXT_KEY )
|
||||
#define HB_INKEY_ISCHAR( n ) ( HB_INKEY_TYPE( n ) == HB_INKEY_EXT_CHAR )
|
||||
#define HB_INKEY_ISUNICODE( n ) ( HB_INKEY_TYPE( n ) == HB_INKEY_EXT_UNICODE )
|
||||
#define HB_INKEY_ISMOUSEKEY( n ) ( HB_INKEY_TYPE( n ) == HB_INKEY_EXT_MOUSEKEY )
|
||||
#define HB_INKEY_ISMOUSEPOS( n ) ( HB_INKEY_TYPE( n ) == HB_INKEY_EXT_MOUSEPOS )
|
||||
#define HB_INKEY_ISEVENT( n ) ( HB_INKEY_TYPE( n ) == HB_INKEY_EXT_EVENT )
|
||||
|
||||
#define HB_INKEY_NEW_VALF( v, f ) ( ( ( v ) & HB_INKEY_EXT_VALMASK ) | \
|
||||
( ( ( f ) << HB_INKEY_EXT_VALBITS ) & HB_INKEY_EXT_FLAGMASK ) )
|
||||
|
||||
#define HB_INKEY_NEW_MKEY( b, f ) ( HB_INKEY_NEW_VALF( b, f ) | HB_INKEY_EXT_BIT | HB_INKEY_EXT_MOUSEKEY )
|
||||
#define HB_INKEY_NEW_KEY( k, f ) ( HB_INKEY_NEW_VALF( k, f ) | HB_INKEY_EXT_BIT | HB_INKEY_EXT_KEY )
|
||||
#define HB_INKEY_NEW_CHAR( b ) ( ( b ) | ( HB_INKEY_EXT_BIT | HB_INKEY_EXT_CHAR ) )
|
||||
#define HB_INKEY_NEW_UNICODE( b ) ( ( b ) | ( HB_INKEY_EXT_BIT | HB_INKEY_EXT_UNICODE ) )
|
||||
|
||||
#define HB_INKEY_NEW_MPOS( x, y ) ( ( ( ( y ) & HB_INKEY_EXT_POSMASK ) << HB_INKEY_EXT_POSBITS ) | \
|
||||
( ( x ) & HB_INKEY_EXT_POSMASK ) | \
|
||||
( HB_INKEY_EXT_BIT | HB_INKEY_EXT_MOUSEPOS ) )
|
||||
|
||||
#define HB_INKEY_MOUSEPOSX( n ) ( ( n ) & HB_INKEY_EXT_POSMASK )
|
||||
#define HB_INKEY_MOUSEPOSY( n ) ( ( ( n ) >> HB_INKEY_EXT_POSBITS ) & HB_INKEY_EXT_POSMASK )
|
||||
|
||||
#define HB_INKEY_VALUE( n ) ( ( n ) & HB_INKEY_EXT_VALMASK )
|
||||
#define HB_INKEY_FLAGS( n ) ( ( ( n ) & HB_INKEY_EXT_FLAGMASK ) >> HB_INKEY_EXT_VALBITS )
|
||||
|
||||
|
||||
HB_EXTERN_END
|
||||
|
||||
#endif /* HB_GTCORE_H_ */
|
||||
|
||||
@@ -59,6 +59,7 @@ DYNAMIC HB_LANG_HRWIN
|
||||
DYNAMIC HB_LANG_HU852
|
||||
DYNAMIC HB_LANG_HUCWI
|
||||
DYNAMIC HB_LANG_HUISO
|
||||
DYNAMIC HB_LANG_HUUTF
|
||||
DYNAMIC HB_LANG_HUWIN
|
||||
DYNAMIC HB_LANG_ID
|
||||
DYNAMIC HB_LANG_IS850
|
||||
|
||||
@@ -132,6 +132,7 @@ extern HB_EXPORT void hb_vmRequestRestore( void );
|
||||
extern HB_EXPORT HB_BOOL hb_vmRequestReenterExt( void );
|
||||
|
||||
extern HB_EXPORT HB_BOOL hb_vmIsActive( void );
|
||||
extern HB_EXPORT HB_BOOL hb_vmIsReady( void );
|
||||
|
||||
/* Return values of hb_vmRequestQuery() */
|
||||
#define HB_QUIT_REQUESTED 1 /* immediately quit the application */
|
||||
|
||||
@@ -85,8 +85,10 @@
|
||||
#define HB_STRCMP( s1, s2 ) hb_wstrcmp( s1, s2 )
|
||||
#define HB_STRNCMP( s1, s2, len ) hb_wstrncmp( s1, s2, len )
|
||||
#define HB_FSNAMECONV( fname, pfree ) ( ( LPCTSTR ) ( *(pfree) = hb_fsNameConvU16( fname ) ) )
|
||||
#define HB_CHARDUP( str ) hb_cdpStrDupU16( hb_vmCDP(), HB_CDP_ENDIAN_NATIVE, str )
|
||||
#define HB_CHARDUPN( str, len ) hb_cdpStrDupnU16( hb_vmCDP(), HB_CDP_ENDIAN_NATIVE, str, len )
|
||||
#define HB_CHARDUP( str ) hb_osStrU16Encode( str )
|
||||
#define HB_CHARDUPN( str, len ) hb_osStrU16EncodeN( str, len )
|
||||
#define HB_OSSTRDUP( str ) hb_osStrU16Decode( str )
|
||||
#define HB_OSSTRDUP2( str, buf, len ) hb_osStrU16Decode2( str, buf, len )
|
||||
#else
|
||||
#define HB_PARSTR( n, h, len ) hb_parstr( n, hb_setGetOSCP(), h, len )
|
||||
#define HB_PARSTRDEF( n, h, len ) hb_strnull( hb_parstr( n, hb_setGetOSCP(), h, len ) )
|
||||
@@ -113,8 +115,10 @@
|
||||
#define HB_STRCMP( s1, s2 ) strcmp( s1, s2 )
|
||||
#define HB_STRNCMP( s1, s2, len ) strncmp( s1, s2, len )
|
||||
#define HB_FSNAMECONV( fname, pfree ) hb_fsNameConv( fname, pfree )
|
||||
#define HB_CHARDUP( str ) hb_cdpDup( str, hb_vmCDP(), hb_setGetOSCP() )
|
||||
#define HB_CHARDUPN( str, len ) hb_cdpDupn( str, len, hb_vmCDP(), hb_setGetOSCP() )
|
||||
#define HB_CHARDUP( str ) hb_osStrEncode( str )
|
||||
#define HB_CHARDUPN( str, len ) hb_osStrEncodeN( str, len )
|
||||
#define HB_OSSTRDUP( str ) hb_osStrDecode( str )
|
||||
#define HB_OSSTRDUP2( str, buf, len ) hb_osStrDecode2( str, buf, len )
|
||||
#endif
|
||||
|
||||
#endif /* HB_OS_WIN */
|
||||
|
||||
@@ -50,11 +50,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: The declaration of hb_gtSetPos(), hb_gtGetPos(), hb_gtWrite(),
|
||||
hb_gtWriteAt(), hb_gtRepChar(), hb_gtBox(), hb_gtBoxS(), hb_gtBoxD()
|
||||
hb_gtInit() differs in parameter types from the original CA-Cl*pper
|
||||
versions. [vszakats] */
|
||||
|
||||
#ifndef HB_XVM_H_
|
||||
#define HB_XVM_H_
|
||||
|
||||
|
||||
@@ -71,8 +71,10 @@
|
||||
#define INKEY_ALL 255
|
||||
|
||||
#define HB_INKEY_RAW 256 /* Harbour extension */
|
||||
#define HB_INKEY_EXTENDED 512 /* Harbour extension */
|
||||
#define HB_INKEY_GTEVENT 1024 /* Harbour extension */
|
||||
#define HB_INKEY_EXT 2048 /* Harbour extension */
|
||||
|
||||
#define HB_INKEY_ALL ( INKEY_ALL + HB_INKEY_GTEVENT )
|
||||
|
||||
/* Mouse events */
|
||||
|
||||
|
||||
@@ -50,9 +50,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#define HB_UTF8EX_SORT
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapicdp.h"
|
||||
|
||||
#include "uc16def.c"
|
||||
|
||||
#ifdef HB_UTF8EX_SORT
|
||||
# include "utf8sort.c"
|
||||
#endif
|
||||
|
||||
static HB_CDP_GET_FUNC( UTF8_get )
|
||||
{
|
||||
HB_SIZE nIndex = *pnIndex;
|
||||
@@ -101,6 +109,149 @@ static HB_CDP_LEN_FUNC( UTF8_len )
|
||||
return hb_cdpUTF8CharSize( wc );
|
||||
}
|
||||
|
||||
static HB_CDP_UPPER_FUNC( UTF8_upper )
|
||||
{
|
||||
HB_WCHAR wcUP;
|
||||
|
||||
HB_SYMBOL_UNUSED( cdp );
|
||||
|
||||
wcUP = s_uc_upper( wc );
|
||||
return wcUP ? wcUP : wc;
|
||||
}
|
||||
|
||||
static HB_CDP_LOWER_FUNC( UTF8_lower )
|
||||
{
|
||||
HB_WCHAR wcLO;
|
||||
|
||||
HB_SYMBOL_UNUSED( cdp );
|
||||
|
||||
wcLO = s_uc_lower( wc );
|
||||
return wcLO ? wcLO : wc;
|
||||
}
|
||||
|
||||
static HB_CDP_FLAGS_FUNC( UTF8_flags )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( cdp );
|
||||
|
||||
return s_uc_flags( wc );
|
||||
}
|
||||
|
||||
static HB_CDP_CMP_FUNC( UTF8_cmp )
|
||||
{
|
||||
int iRet;
|
||||
|
||||
#ifdef HB_UTF8EX_SORT
|
||||
|
||||
HB_SIZE nPos1 = 0, nPos2 = 0;
|
||||
HB_WCHAR wc1, wc2;
|
||||
|
||||
iRet = 0;
|
||||
for( ;; )
|
||||
{
|
||||
if( !HB_CDPCHAR_GET( cdp, szSecond, nLenSecond, &nPos2, &wc2 ) )
|
||||
{
|
||||
if( fExact && HB_CDPCHAR_GET( cdp, szFirst, nLenFirst, &nPos1, &wc1 ) )
|
||||
iRet = 1;
|
||||
break;
|
||||
}
|
||||
if( !HB_CDPCHAR_GET( cdp, szFirst, nLenFirst, &nPos1, &wc1 ) )
|
||||
{
|
||||
iRet = -1;
|
||||
break;
|
||||
}
|
||||
if( wc1 != wc2 )
|
||||
{
|
||||
HB_USHORT us1 = s_uniSort[ wc1 ], us2 = s_uniSort[ wc2 ];
|
||||
if( us1 != us2 )
|
||||
{
|
||||
iRet = us1 < us2 ? -1 : 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
HB_SIZE nLen = nLenFirst < nLenSecond ? nLenFirst : nLenSecond;
|
||||
|
||||
HB_SYMBOL_UNUSED( cdp );
|
||||
|
||||
iRet = memcmp( szFirst, szSecond, nLen );
|
||||
if( iRet == 0 )
|
||||
{
|
||||
if( nLenSecond > nLenFirst )
|
||||
iRet = -1;
|
||||
else if( fExact && nLenSecond < nLenFirst )
|
||||
iRet = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
static HB_CDP_CMP_FUNC( UTF8_cmpi )
|
||||
{
|
||||
int iRet = 0;
|
||||
|
||||
#ifdef HB_UTF8EX_SORT
|
||||
|
||||
HB_SIZE nPos1 = 0, nPos2 = 0;
|
||||
HB_WCHAR wc1, wc2;
|
||||
|
||||
iRet = 0;
|
||||
for( ;; )
|
||||
{
|
||||
if( !HB_CDPCHAR_GET( cdp, szSecond, nLenSecond, &nPos2, &wc2 ) )
|
||||
{
|
||||
if( fExact && HB_CDPCHAR_GET( cdp, szFirst, nLenFirst, &nPos1, &wc1 ) )
|
||||
iRet = 1;
|
||||
break;
|
||||
}
|
||||
if( !HB_CDPCHAR_GET( cdp, szFirst, nLenFirst, &nPos1, &wc1 ) )
|
||||
{
|
||||
iRet = -1;
|
||||
break;
|
||||
}
|
||||
if( wc1 != wc2 )
|
||||
{
|
||||
HB_USHORT us1 = s_uniSort[ HB_CDPCHAR_UPPER( cdp, wc1 ) ],
|
||||
us2 = s_uniSort[ HB_CDPCHAR_UPPER( cdp, wc2 ) ];
|
||||
if( us1 != us2 )
|
||||
{
|
||||
iRet = us1 < us2 ? -1 : 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
HB_SIZE nLen = nLenFirst < nLenSecond ? nLenFirst : nLenSecond;
|
||||
|
||||
while( nLen-- )
|
||||
{
|
||||
HB_UCHAR u1 = cdp->upper[ ( HB_UCHAR ) * szFirst++ ],
|
||||
u2 = cdp->upper[ ( HB_UCHAR ) * szSecond++ ];
|
||||
if( u1 != u2 )
|
||||
{
|
||||
iRet = ( u1 < u2 ) ? -1 : 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( iRet == 0 )
|
||||
{
|
||||
if( nLenSecond > nLenFirst )
|
||||
iRet = -1;
|
||||
else if( fExact && nLenSecond < nLenFirst )
|
||||
iRet = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
|
||||
static void hb_cp_init( PHB_CODEPAGE cdp )
|
||||
{
|
||||
HB_UCHAR * flags, * upper, * lower;
|
||||
@@ -129,19 +280,27 @@ static void hb_cp_init( PHB_CODEPAGE cdp )
|
||||
|
||||
#define HB_CP_RAW
|
||||
|
||||
#define HB_CP_ID UTF8ASC
|
||||
#define HB_CP_INFO "UTF-8 ASCII letters"
|
||||
#define HB_CP_ID UTF8EX
|
||||
#define HB_CP_INFO "UTF-8 extended"
|
||||
#define HB_CP_UNITB HB_UNITB_437
|
||||
|
||||
/* use character indexes instead of bytes ones */
|
||||
#define HB_CP_CHARIDX
|
||||
/* CHR(), ASC() and similar functions operates on Unicode values instead of bytes */
|
||||
#define HB_CP_CHARUNI
|
||||
/* UTF-8 string encoding */
|
||||
#define HB_CP_UTF8
|
||||
|
||||
#define HB_CP_GET_FUNC UTF8_get
|
||||
#define HB_CP_PUT_FUNC UTF8_put
|
||||
#define HB_CP_LEN_FUNC UTF8_len
|
||||
|
||||
#define HB_CP_FLAGS_FUNC NULL
|
||||
#define HB_CP_UPPER_FUNC NULL
|
||||
#define HB_CP_LOWER_FUNC NULL
|
||||
#define HB_CP_FLAGS_FUNC UTF8_flags
|
||||
#define HB_CP_UPPER_FUNC UTF8_upper
|
||||
#define HB_CP_LOWER_FUNC UTF8_lower
|
||||
|
||||
#define HB_CP_CMP_FUNC NULL
|
||||
#define HB_CP_CMP_FUNC UTF8_cmp
|
||||
#define HB_CP_CMPI_FUNC UTF8_cmpi
|
||||
|
||||
#define s_flags NULL
|
||||
#define s_upper NULL
|
||||
|
||||
1177
harbour/src/codepage/uc16def.c
Normal file
1177
harbour/src/codepage/uc16def.c
Normal file
File diff suppressed because it is too large
Load Diff
8249
harbour/src/codepage/utf8sort.c
Normal file
8249
harbour/src/codepage/utf8sort.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1930,7 +1930,8 @@ HB_BOOL hb_compExprReduceAT( HB_EXPR_PTR pSelf, HB_COMP_DECL )
|
||||
HB_EXPR_PTR pText = pSub->pNext;
|
||||
HB_EXPR_PTR pReduced;
|
||||
|
||||
if( pSub->ExprType == HB_ET_STRING && pText->ExprType == HB_ET_STRING )
|
||||
if( pSub->ExprType == HB_ET_STRING && pText->ExprType == HB_ET_STRING &&
|
||||
!HB_SUPPORT_USERCP )
|
||||
{
|
||||
/* NOTE: CA-Cl*pper has a bug in AT("",cText) compile time
|
||||
* optimization and always set 1 as result in such cses.
|
||||
@@ -1965,11 +1966,25 @@ HB_BOOL hb_compExprReduceAT( HB_EXPR_PTR pSelf, HB_COMP_DECL )
|
||||
|
||||
HB_BOOL hb_compExprReduceCHR( HB_EXPR_PTR pSelf, HB_COMP_DECL )
|
||||
{
|
||||
HB_BOOL fDoOpt = HB_FALSE;
|
||||
HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms;
|
||||
HB_EXPR_PTR pArg = pParms->value.asList.pExprList;
|
||||
|
||||
/* try to change it into a string */
|
||||
if( pArg->ExprType == HB_ET_NUMERIC )
|
||||
{
|
||||
if( HB_SUPPORT_USERCP )
|
||||
{
|
||||
int iVal = pArg->value.asNum.NumType == HB_ET_LONG ?
|
||||
( int ) pArg->value.asNum.val.l :
|
||||
( int ) pArg->value.asNum.val.d;
|
||||
fDoOpt = iVal >= 0 && iVal <= 127;
|
||||
}
|
||||
else
|
||||
fDoOpt = HB_TRUE;
|
||||
}
|
||||
|
||||
/* try to change it into a string */
|
||||
if( fDoOpt )
|
||||
{
|
||||
/* NOTE: CA-Cl*pper's compiler optimizer will be wrong for those
|
||||
* CHR() cases where the passed parameter is a constant which
|
||||
@@ -2027,7 +2042,8 @@ HB_BOOL hb_compExprReduceLEN( HB_EXPR_PTR pSelf, HB_COMP_DECL )
|
||||
HB_EXPR_PTR pArg = pParms->value.asList.pExprList;
|
||||
|
||||
/* TOFIX: do not optimize when array/hash args have user expressions */
|
||||
if( pArg->ExprType == HB_ET_STRING || pArg->ExprType == HB_ET_ARRAY ||
|
||||
if( ( pArg->ExprType == HB_ET_STRING && !HB_SUPPORT_USERCP ) ||
|
||||
pArg->ExprType == HB_ET_ARRAY ||
|
||||
pArg->ExprType == HB_ET_HASH )
|
||||
{
|
||||
HB_EXPR_PTR pExpr = hb_compExprNewLong( pArg->ExprType == HB_ET_HASH ?
|
||||
@@ -2110,7 +2126,9 @@ HB_BOOL hb_compExprReduceASC( HB_EXPR_PTR pSelf, HB_COMP_DECL )
|
||||
HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms;
|
||||
HB_EXPR_PTR pArg = pParms->value.asList.pExprList;
|
||||
|
||||
if( pArg->ExprType == HB_ET_STRING )
|
||||
if( pArg->ExprType == HB_ET_STRING &&
|
||||
( !HB_SUPPORT_USERCP ||
|
||||
( HB_UCHAR ) pArg->value.asString.string[0] <= 127 ) )
|
||||
{
|
||||
HB_EXPR_PTR pExpr = hb_compExprNewLong(
|
||||
( HB_UCHAR ) pArg->value.asString.string[0], HB_COMP_PARAM );
|
||||
|
||||
@@ -127,6 +127,7 @@
|
||||
#elif defined( HB_OS_WIN )
|
||||
|
||||
#include <windows.h>
|
||||
#include "hbwinuni.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -571,39 +572,45 @@ static HB_BOOL hb_fsFindNextLow( PHB_FFIND ffind )
|
||||
|
||||
{
|
||||
PHB_FFIND_INFO info = ( PHB_FFIND_INFO ) ffind->info;
|
||||
PHB_FNAME pFileName = NULL;
|
||||
LPTSTR lpFileMask = NULL;
|
||||
|
||||
bFound = HB_FALSE;
|
||||
|
||||
#if !defined( HB_OS_WIN_CE )
|
||||
if( ( ffind->attrmask & HB_FA_LABEL ) != 0 && !info->fLabelDone )
|
||||
{
|
||||
TCHAR szName[ HB_PATH_MAX ];
|
||||
const char * mask = NULL;
|
||||
TCHAR lpVolName[ HB_PATH_MAX ];
|
||||
LPTSTR lpFileMask = NULL;
|
||||
char * mask = NULL;
|
||||
|
||||
info->fLabelDone = HB_TRUE;
|
||||
|
||||
if( ffind->pszFileMask && *ffind->pszFileMask )
|
||||
{
|
||||
pFileName = hb_fsFNameSplit( ffind->pszFileMask );
|
||||
mask = pFileName->szName;
|
||||
PHB_FNAME pFileName = hb_fsFNameSplit( ffind->pszFileMask );
|
||||
if( pFileName->szName && pFileName->szName[ 0 ] )
|
||||
mask = hb_strdup( pFileName->szName );
|
||||
if( pFileName->szPath && pFileName->szPath[ 0 ] &&
|
||||
( pFileName->szPath[ 1 ] ||
|
||||
pFileName->szPath[ 0 ] != HB_OS_PATH_DELIM_CHR ) )
|
||||
lpFileMask = HB_TCHAR_CONVTO( pFileName->szPath );
|
||||
lpFileMask = HB_CHARDUP( pFileName->szPath );
|
||||
hb_xfree( pFileName );
|
||||
}
|
||||
bFound = GetVolumeInformation( lpFileMask, szName, sizeof( szName ),
|
||||
NULL, NULL, NULL, NULL, 0 );
|
||||
bFound = GetVolumeInformation( lpFileMask, lpVolName,
|
||||
HB_SIZEOFARRAY( lpVolName ),
|
||||
NULL, NULL, NULL, NULL, 0 ) != 0;
|
||||
if( bFound )
|
||||
{
|
||||
HB_TCHAR_COPYFROM( ffind->szName, szName, sizeof( ffind->szName ) - 1 );
|
||||
HB_OSSTRDUP2( lpVolName, ffind->szName, sizeof( ffind->szName ) - 1 );
|
||||
if( mask && *mask && ! hb_strMatchFile( ffind->szName, mask ) )
|
||||
{
|
||||
ffind->szName[ 0 ] = '\0';
|
||||
bFound = HB_FALSE;
|
||||
}
|
||||
}
|
||||
if( lpFileMask )
|
||||
hb_xfree( lpFileMask );
|
||||
if( mask )
|
||||
hb_xfree( mask );
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -613,12 +620,11 @@ static HB_BOOL hb_fsFindNextLow( PHB_FFIND ffind )
|
||||
{
|
||||
if( ffind->bFirst )
|
||||
{
|
||||
LPTSTR lpFileMask = HB_CHARDUP( ffind->pszFileMask );
|
||||
ffind->bFirst = HB_FALSE;
|
||||
if( lpFileMask )
|
||||
HB_TCHAR_FREE( lpFileMask );
|
||||
lpFileMask = HB_TCHAR_CONVTO( ffind->pszFileMask );
|
||||
info->hFindFile = FindFirstFile( lpFileMask, &info->pFindFileData );
|
||||
info->dwAttr = ( DWORD ) hb_fsAttrToRaw( ffind->attrmask );
|
||||
info->hFindFile = FindFirstFile( lpFileMask, &info->pFindFileData );
|
||||
hb_xfree( lpFileMask );
|
||||
|
||||
if( ( info->hFindFile != INVALID_HANDLE_VALUE ) && _HB_WIN_MATCH() )
|
||||
bFound = HB_TRUE;
|
||||
@@ -640,7 +646,7 @@ static HB_BOOL hb_fsFindNextLow( PHB_FFIND ffind )
|
||||
|
||||
if( bFound )
|
||||
{
|
||||
HB_TCHAR_COPYFROM( ffind->szName, info->pFindFileData.cFileName, sizeof( ffind->szName ) - 1 );
|
||||
HB_OSSTRDUP2( info->pFindFileData.cFileName, ffind->szName, sizeof( ffind->szName ) - 1 );
|
||||
|
||||
if( info->pFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
|
||||
ffind->size = 0;
|
||||
@@ -680,11 +686,6 @@ static HB_BOOL hb_fsFindNextLow( PHB_FFIND ffind )
|
||||
}
|
||||
}
|
||||
hb_fsSetIOError( bFound, 0 );
|
||||
|
||||
if( pFileName )
|
||||
hb_xfree( pFileName );
|
||||
if( lpFileMask )
|
||||
HB_TCHAR_FREE( lpFileMask );
|
||||
}
|
||||
|
||||
#elif defined( HB_OS_UNIX )
|
||||
@@ -809,6 +810,7 @@ static HB_BOOL hb_fsFindNextLow( PHB_FFIND ffind )
|
||||
/* Do the conversions common for all platforms */
|
||||
ffind->szName[ sizeof( ffind->szName ) - 1 ] = '\0';
|
||||
|
||||
#if !defined( HB_OS_WIN )
|
||||
/* Convert from OS codepage */
|
||||
{
|
||||
char * pszFree = NULL;
|
||||
@@ -821,7 +823,7 @@ static HB_BOOL hb_fsFindNextLow( PHB_FFIND ffind )
|
||||
hb_xfree( pszFree );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
ffind->attr = hb_fsAttrFromRaw( raw_attr );
|
||||
|
||||
ffind->lDate = hb_dateEncode( iYear, iMonth, iDay );
|
||||
@@ -847,7 +849,12 @@ PHB_FFIND hb_fsFindFirst( const char * pszFileMask, HB_FATTR attrmask )
|
||||
memset( ffind->info, 0, sizeof( HB_FFIND_INFO ) );
|
||||
|
||||
/* Store search parameters */
|
||||
#if defined( HB_OS_WIN )
|
||||
ffind->pszFileMask = pszFileMask;
|
||||
#else
|
||||
/* Convert to OS codepage */
|
||||
ffind->pszFileMask = hb_fsNameConv( pszFileMask, &ffind->pszFree );
|
||||
#endif
|
||||
ffind->attrmask = attrmask;
|
||||
ffind->bFirst = HB_TRUE;
|
||||
|
||||
@@ -888,6 +895,9 @@ void hb_fsFindClose( PHB_FFIND ffind )
|
||||
{
|
||||
if( ffind )
|
||||
{
|
||||
if( ffind->pszFree )
|
||||
hb_xfree( ffind->pszFree );
|
||||
|
||||
/* Do platform dependant cleanup */
|
||||
|
||||
if( ffind->info )
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
|
||||
#if defined( HB_OS_WIN )
|
||||
#include <windows.h>
|
||||
#include "hbwinuni.h"
|
||||
#if !defined( INVALID_FILE_ATTRIBUTES )
|
||||
#define INVALID_FILE_ATTRIBUTES ( ( DWORD ) -1 )
|
||||
#endif
|
||||
@@ -292,85 +293,64 @@ char * hb_fsFNameMerge( char * pszFileName, PHB_FNAME pFileName )
|
||||
|
||||
HB_BOOL hb_fsNameExists( const char * pszFileName )
|
||||
{
|
||||
HB_BOOL fExist;
|
||||
char * pszFree = NULL;
|
||||
HB_BOOL fExist = HB_FALSE;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_fsNameExists(%p)", pszFileName));
|
||||
|
||||
if( pszFileName == NULL )
|
||||
return HB_FALSE;
|
||||
|
||||
pszFileName = hb_fsNameConv( pszFileName, &pszFree );
|
||||
|
||||
#if defined( HB_OS_DOS )
|
||||
if( pszFileName != NULL )
|
||||
{
|
||||
#if defined( __DJGPP__ ) || defined( __BORLANDC__ )
|
||||
fExist = _chmod( pszFileName, 0, 0 ) != -1;
|
||||
#else
|
||||
unsigned int iAttr = 0;
|
||||
fExist = _dos_getfileattr( pszFileName, &iAttr ) == 0;
|
||||
#endif
|
||||
}
|
||||
#elif defined( HB_OS_WIN )
|
||||
{
|
||||
LPTSTR lpFileName = HB_TCHAR_CONVTO( pszFileName );
|
||||
#if defined( HB_OS_WIN )
|
||||
LPTSTR lpFree;
|
||||
LPCTSTR lpFileName = HB_FSNAMECONV( pszFileName, &lpFree );
|
||||
|
||||
fExist = ( GetFileAttributes( lpFileName ) != INVALID_FILE_ATTRIBUTES );
|
||||
|
||||
HB_TCHAR_FREE( lpFileName );
|
||||
}
|
||||
#elif defined( HB_OS_OS2 )
|
||||
{
|
||||
FILESTATUS3 fs3;
|
||||
fExist = DosQueryPathInfo( ( PCSZ ) pszFileName, FIL_STANDARD,
|
||||
&fs3, sizeof( fs3 ) ) == NO_ERROR;
|
||||
}
|
||||
#elif defined( HB_OS_UNIX )
|
||||
{
|
||||
struct stat statbuf;
|
||||
|
||||
fExist = stat( pszFileName, &statbuf ) == 0;
|
||||
}
|
||||
if( lpFree )
|
||||
hb_xfree( lpFree );
|
||||
#else
|
||||
{
|
||||
int iTODO; /* To force warning */
|
||||
char * pszFree = NULL;
|
||||
|
||||
fExist = HB_FALSE;
|
||||
}
|
||||
pszFileName = hb_fsNameConv( pszFileName, &pszFree );
|
||||
|
||||
{
|
||||
# if defined( HB_OS_DOS )
|
||||
# if defined( __DJGPP__ ) || defined( __BORLANDC__ )
|
||||
fExist = _chmod( pszFileName, 0, 0 ) != -1;
|
||||
# else
|
||||
unsigned int iAttr = 0;
|
||||
fExist = _dos_getfileattr( pszFileName, &iAttr ) == 0;
|
||||
# endif
|
||||
# elif defined( HB_OS_OS2 )
|
||||
FILESTATUS3 fs3;
|
||||
fExist = DosQueryPathInfo( ( PCSZ ) pszFileName, FIL_STANDARD,
|
||||
&fs3, sizeof( fs3 ) ) == NO_ERROR;
|
||||
# elif defined( HB_OS_UNIX )
|
||||
struct stat statbuf;
|
||||
fExist = stat( pszFileName, &statbuf ) == 0;
|
||||
# else
|
||||
int iTODO; /* To force warning */
|
||||
# endif
|
||||
}
|
||||
|
||||
if( pszFree )
|
||||
hb_xfree( pszFree );
|
||||
#endif
|
||||
|
||||
if( pszFree )
|
||||
hb_xfree( pszFree );
|
||||
}
|
||||
|
||||
return fExist;
|
||||
}
|
||||
|
||||
HB_BOOL hb_fsFileExists( const char * pszFileName )
|
||||
{
|
||||
HB_BOOL fExist;
|
||||
char * pszFree = NULL;
|
||||
HB_BOOL fExist = HB_FALSE;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_fsFileExists(%p)", pszFileName));
|
||||
|
||||
if( pszFileName == NULL )
|
||||
return HB_FALSE;
|
||||
|
||||
pszFileName = hb_fsNameConv( pszFileName, &pszFree );
|
||||
|
||||
#if defined( HB_OS_DOS )
|
||||
if( pszFileName != NULL )
|
||||
{
|
||||
#if defined( __DJGPP__ ) || defined( __BORLANDC__ )
|
||||
int iAttr = _chmod( pszFileName, 0, 0 );
|
||||
fExist = iAttr != -1 && ( iAttr & 0x10 ) == 0;
|
||||
#else
|
||||
unsigned int iAttr = 0;
|
||||
fExist = _dos_getfileattr( pszFileName, &iAttr ) == 0 &&
|
||||
( iAttr & 0x10 ) == 0;
|
||||
#endif
|
||||
}
|
||||
#elif defined( HB_OS_WIN )
|
||||
{
|
||||
LPTSTR lpFileName = HB_TCHAR_CONVTO( pszFileName );
|
||||
#if defined( HB_OS_WIN )
|
||||
LPTSTR lpFree;
|
||||
LPCTSTR lpFileName = HB_FSNAMECONV( pszFileName, &lpFree );
|
||||
DWORD dwAttr;
|
||||
|
||||
dwAttr = GetFileAttributes( lpFileName );
|
||||
@@ -378,94 +358,98 @@ HB_BOOL hb_fsFileExists( const char * pszFileName )
|
||||
( dwAttr & ( FILE_ATTRIBUTE_DIRECTORY |
|
||||
FILE_ATTRIBUTE_DEVICE ) ) == 0;
|
||||
|
||||
HB_TCHAR_FREE( lpFileName );
|
||||
}
|
||||
#elif defined( HB_OS_OS2 )
|
||||
{
|
||||
FILESTATUS3 fs3;
|
||||
fExist = DosQueryPathInfo( ( PCSZ ) pszFileName, FIL_STANDARD,
|
||||
&fs3, sizeof( fs3 ) ) == NO_ERROR &&
|
||||
( fs3.attrFile & FILE_DIRECTORY ) == 0;
|
||||
}
|
||||
#elif defined( HB_OS_UNIX )
|
||||
{
|
||||
struct stat statbuf;
|
||||
|
||||
fExist = stat( pszFileName, &statbuf ) == 0 &&
|
||||
S_ISREG( statbuf.st_mode );
|
||||
}
|
||||
if( lpFree )
|
||||
hb_xfree( lpFree );
|
||||
#else
|
||||
{
|
||||
int iTODO; /* To force warning */
|
||||
char * pszFree = NULL;
|
||||
|
||||
fExist = HB_FALSE;
|
||||
}
|
||||
pszFileName = hb_fsNameConv( pszFileName, &pszFree );
|
||||
|
||||
{
|
||||
# if defined( HB_OS_DOS )
|
||||
# if defined( __DJGPP__ ) || defined( __BORLANDC__ )
|
||||
int iAttr = _chmod( pszFileName, 0, 0 );
|
||||
fExist = iAttr != -1 && ( iAttr & 0x10 ) == 0;
|
||||
# else
|
||||
unsigned int iAttr = 0;
|
||||
fExist = _dos_getfileattr( pszFileName, &iAttr ) == 0 &&
|
||||
( iAttr & 0x10 ) == 0;
|
||||
# endif
|
||||
# elif defined( HB_OS_OS2 )
|
||||
FILESTATUS3 fs3;
|
||||
fExist = DosQueryPathInfo( ( PCSZ ) pszFileName, FIL_STANDARD,
|
||||
&fs3, sizeof( fs3 ) ) == NO_ERROR &&
|
||||
( fs3.attrFile & FILE_DIRECTORY ) == 0;
|
||||
# elif defined( HB_OS_UNIX )
|
||||
struct stat statbuf;
|
||||
|
||||
fExist = stat( pszFileName, &statbuf ) == 0 &&
|
||||
S_ISREG( statbuf.st_mode );
|
||||
# else
|
||||
int iTODO; /* To force warning */
|
||||
# endif
|
||||
}
|
||||
|
||||
if( pszFree )
|
||||
hb_xfree( pszFree );
|
||||
#endif
|
||||
|
||||
if( pszFree )
|
||||
hb_xfree( pszFree );
|
||||
}
|
||||
|
||||
return fExist;
|
||||
}
|
||||
|
||||
HB_BOOL hb_fsDirExists( const char * pszDirName )
|
||||
{
|
||||
HB_BOOL fExist;
|
||||
char * pszFree = NULL;
|
||||
HB_BOOL fExist = HB_FALSE;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_fsDirExists(%p)", pszDirName));
|
||||
|
||||
if( pszDirName == NULL )
|
||||
return HB_FALSE;
|
||||
|
||||
pszDirName = hb_fsNameConv( pszDirName, &pszFree );
|
||||
|
||||
#if defined( HB_OS_DOS )
|
||||
if( pszDirName != NULL )
|
||||
{
|
||||
#if defined( __DJGPP__ ) || defined( __BORLANDC__ )
|
||||
int iAttr = _chmod( pszDirName, 0, 0 );
|
||||
fExist = iAttr != -1 && ( iAttr & 0x10 ) != 0;
|
||||
#else
|
||||
unsigned int iAttr = 0;
|
||||
fExist = _dos_getfileattr( pszDirName, &iAttr ) == 0 &&
|
||||
( iAttr & 0x10 ) != 0;
|
||||
#endif
|
||||
}
|
||||
#elif defined( HB_OS_WIN )
|
||||
{
|
||||
LPTSTR lpDirName = HB_TCHAR_CONVTO( pszDirName );
|
||||
#if defined( HB_OS_WIN )
|
||||
LPTSTR lpFree;
|
||||
LPCTSTR lpDirName = HB_FSNAMECONV( pszDirName, &lpFree );
|
||||
DWORD dwAttr;
|
||||
|
||||
dwAttr = GetFileAttributes( lpDirName );
|
||||
fExist = ( dwAttr != INVALID_FILE_ATTRIBUTES ) &&
|
||||
( dwAttr & FILE_ATTRIBUTE_DIRECTORY );
|
||||
|
||||
HB_TCHAR_FREE( lpDirName );
|
||||
}
|
||||
#elif defined( HB_OS_OS2 )
|
||||
{
|
||||
FILESTATUS3 fs3;
|
||||
fExist = DosQueryPathInfo( ( PCSZ ) pszDirName, FIL_STANDARD,
|
||||
&fs3, sizeof( fs3 ) ) == NO_ERROR &&
|
||||
( fs3.attrFile & FILE_DIRECTORY ) != 0;
|
||||
}
|
||||
#elif defined( HB_OS_UNIX )
|
||||
{
|
||||
struct stat statbuf;
|
||||
|
||||
fExist = stat( pszDirName, &statbuf ) == 0 &&
|
||||
S_ISDIR( statbuf.st_mode );
|
||||
}
|
||||
if( lpFree )
|
||||
hb_xfree( lpFree );
|
||||
#else
|
||||
{
|
||||
int iTODO; /* To force warning */
|
||||
char * pszFree = NULL;
|
||||
|
||||
fExist = HB_FALSE;
|
||||
}
|
||||
pszDirName = hb_fsNameConv( pszDirName, &pszFree );
|
||||
|
||||
{
|
||||
# if defined( HB_OS_DOS )
|
||||
# if defined( __DJGPP__ ) || defined( __BORLANDC__ )
|
||||
int iAttr = _chmod( pszDirName, 0, 0 );
|
||||
fExist = iAttr != -1 && ( iAttr & 0x10 ) != 0;
|
||||
# else
|
||||
unsigned int iAttr = 0;
|
||||
fExist = _dos_getfileattr( pszDirName, &iAttr ) == 0 &&
|
||||
( iAttr & 0x10 ) != 0;
|
||||
# endif
|
||||
# elif defined( HB_OS_OS2 )
|
||||
FILESTATUS3 fs3;
|
||||
fExist = DosQueryPathInfo( ( PCSZ ) pszDirName, FIL_STANDARD,
|
||||
&fs3, sizeof( fs3 ) ) == NO_ERROR &&
|
||||
( fs3.attrFile & FILE_DIRECTORY ) != 0;
|
||||
# elif defined( HB_OS_UNIX )
|
||||
struct stat statbuf;
|
||||
fExist = stat( pszDirName, &statbuf ) == 0 &&
|
||||
S_ISDIR( statbuf.st_mode );
|
||||
# else
|
||||
int iTODO; /* To force warning */
|
||||
# endif
|
||||
}
|
||||
|
||||
if( pszFree )
|
||||
hb_xfree( pszFree );
|
||||
#endif
|
||||
|
||||
if( pszFree )
|
||||
hb_xfree( pszFree );
|
||||
}
|
||||
|
||||
return fExist;
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
|
||||
#if defined( HB_OS_WIN )
|
||||
#include <windows.h>
|
||||
#include "hbwinuni.h"
|
||||
#if defined( HB_OS_WIN_CE )
|
||||
#include "hbwince.h"
|
||||
#endif
|
||||
@@ -78,43 +79,42 @@ char * hb_getenv( const char * szName )
|
||||
char * pszBuffer = NULL;
|
||||
|
||||
#if defined( HB_OS_WIN )
|
||||
|
||||
{
|
||||
LPTSTR lpName = HB_TCHAR_CONVTO( szName );
|
||||
LPTSTR lpName = HB_CHARDUP( szName );
|
||||
DWORD size = GetEnvironmentVariable( lpName, NULL, 0 );
|
||||
|
||||
if( size != 0 )
|
||||
{
|
||||
LPTSTR lpBuffer = ( LPTSTR ) hb_xgrab( size * sizeof( TCHAR ) );
|
||||
GetEnvironmentVariable( lpName, lpBuffer, size );
|
||||
#if defined( UNICODE )
|
||||
pszBuffer = hb_wctomb( lpBuffer );
|
||||
pszBuffer = HB_OSSTRDUP( lpBuffer );
|
||||
hb_xfree( lpBuffer );
|
||||
#else
|
||||
pszBuffer = lpBuffer;
|
||||
#endif
|
||||
}
|
||||
HB_TCHAR_FREE( lpName );
|
||||
hb_xfree( lpName );
|
||||
}
|
||||
|
||||
#elif defined( HB_OS_OS2 )
|
||||
|
||||
{
|
||||
PSZ EnvValue = ( PSZ ) "";
|
||||
char * pszNameFree = NULL;
|
||||
|
||||
szName = hb_osEncodeCP( szName, &pszNameFree, NULL );
|
||||
if( DosScanEnv( ( PCSZ ) szName, &EnvValue ) == NO_ERROR )
|
||||
pszBuffer = hb_strdup( ( char * ) EnvValue );
|
||||
pszBuffer = hb_osStrDecode( ( char * ) EnvValue );
|
||||
if( pszNameFree )
|
||||
hb_xfree( pszNameFree );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
{
|
||||
char * pszTemp = getenv( szName );
|
||||
char * pszTemp, * pszNameFree = NULL;
|
||||
|
||||
szName = hb_osEncodeCP( szName, &pszNameFree, NULL );
|
||||
pszTemp = getenv( szName );
|
||||
if( pszNameFree )
|
||||
hb_xfree( pszNameFree );
|
||||
|
||||
if( pszTemp != NULL )
|
||||
pszBuffer = hb_strdup( pszTemp );
|
||||
pszBuffer = hb_osStrDecode( pszTemp );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return pszBuffer;
|
||||
@@ -127,61 +127,53 @@ HB_BOOL hb_getenv_buffer( const char * szName, char * szBuffer, int nSize )
|
||||
|
||||
#if defined( HB_OS_WIN )
|
||||
{
|
||||
#if defined( UNICODE )
|
||||
TCHAR name[ 128 ];
|
||||
TCHAR buffer[ 128 ];
|
||||
LPTSTR lpName, lpBuffer;
|
||||
HB_SIZE nLen = strlen( szName ) + 1;
|
||||
LPTSTR lpName = HB_CHARDUP( szName ), lpBuffer;
|
||||
|
||||
if( nLen <= HB_SIZEOFARRAY( name ) )
|
||||
lpName = name;
|
||||
else
|
||||
lpName = ( LPTSTR ) hb_xgrab( nLen * sizeof( TCHAR ) );
|
||||
|
||||
hb_mbntowccpy( lpName, szName, nLen - 1 );
|
||||
|
||||
if( szBuffer == NULL )
|
||||
lpBuffer = NULL;
|
||||
else if( nSize <= ( int ) HB_SIZEOFARRAY( buffer ) )
|
||||
lpBuffer = buffer;
|
||||
else
|
||||
if( szBuffer != NULL || nSize > 0 )
|
||||
lpBuffer = ( LPTSTR ) hb_xgrab( nSize * sizeof( TCHAR ) );
|
||||
else
|
||||
lpBuffer = NULL;
|
||||
|
||||
fRetVal = GetEnvironmentVariable( lpName, lpBuffer, nSize ) != 0;
|
||||
lpBuffer[ nSize - 1 ] = L'\0';
|
||||
|
||||
hb_wcntombcpy( szBuffer, lpBuffer, nSize - 1 );
|
||||
|
||||
if( lpName != name )
|
||||
hb_xfree( lpName );
|
||||
if( lpBuffer && lpBuffer != buffer )
|
||||
if( lpBuffer )
|
||||
{
|
||||
if( fRetVal )
|
||||
{
|
||||
lpBuffer[ nSize - 1 ] = TEXT( '\0' );
|
||||
HB_OSSTRDUP2( lpBuffer, szBuffer, nSize - 1 );
|
||||
}
|
||||
hb_xfree( lpBuffer );
|
||||
#else
|
||||
fRetVal = GetEnvironmentVariable( szName, szBuffer, nSize ) != 0;
|
||||
#endif
|
||||
}
|
||||
hb_xfree( lpName );
|
||||
}
|
||||
#elif defined( HB_OS_OS2 )
|
||||
{
|
||||
PSZ EnvValue = ( PSZ ) "";
|
||||
char * pszNameFree = NULL;
|
||||
|
||||
if( DosScanEnv( ( PCSZ ) szName, &EnvValue ) == NO_ERROR )
|
||||
{
|
||||
fRetVal = HB_TRUE;
|
||||
if( szBuffer != NULL && nSize != 0 )
|
||||
hb_strncpy( szBuffer, ( char * ) EnvValue, nSize - 1 );
|
||||
}
|
||||
else
|
||||
fRetVal = HB_FALSE;
|
||||
szName = hb_osEncodeCP( szName, &pszNameFree, NULL );
|
||||
fRetVal = DosScanEnv( ( PCSZ ) szName, &EnvValue ) == NO_ERROR;
|
||||
if( pszNameFree )
|
||||
hb_xfree( pszNameFree );
|
||||
|
||||
if( fRetVal && szBuffer != NULL && nSize != 0 )
|
||||
hb_osStrDecode2( ( char * ) EnvValue, szBuffer, nSize - 1 );
|
||||
}
|
||||
#else
|
||||
{
|
||||
char * pszTemp = getenv( szName );
|
||||
char * pszTemp, * pszNameFree = NULL;
|
||||
|
||||
szName = hb_osEncodeCP( szName, &pszNameFree, NULL );
|
||||
pszTemp = getenv( szName );
|
||||
if( pszNameFree )
|
||||
hb_xfree( pszNameFree );
|
||||
|
||||
if( pszTemp != NULL )
|
||||
{
|
||||
fRetVal = HB_TRUE;
|
||||
if( szBuffer != NULL && nSize != 0 )
|
||||
hb_strncpy( szBuffer, pszTemp, nSize - 1 );
|
||||
hb_osStrDecode2( pszTemp, szBuffer, nSize - 1 );
|
||||
}
|
||||
else
|
||||
fRetVal = HB_FALSE;
|
||||
@@ -204,15 +196,14 @@ HB_BOOL hb_setenv( const char * szName, const char * szValue )
|
||||
|
||||
#if defined( HB_OS_WIN )
|
||||
{
|
||||
LPTSTR lpName = HB_TCHAR_CONVTO( szName );
|
||||
LPTSTR lpValue = szValue ? HB_TCHAR_CONVTO( szValue ) : NULL;
|
||||
HB_BOOL bResult = ( SetEnvironmentVariable( lpName, lpValue ) != 0 );
|
||||
LPTSTR lpName = HB_CHARDUP( szName );
|
||||
LPTSTR lpValue = szValue ? HB_CHARDUP( szValue ) : NULL;
|
||||
HB_BOOL fResult = ( SetEnvironmentVariable( lpName, lpValue ) != 0 );
|
||||
if( lpValue )
|
||||
HB_TCHAR_FREE( lpValue );
|
||||
HB_TCHAR_FREE( lpName );
|
||||
return bResult;
|
||||
hb_xfree( lpValue );
|
||||
hb_xfree( lpName );
|
||||
return fResult;
|
||||
}
|
||||
|
||||
#elif defined( _BSD_SOURCE ) || _POSIX_C_SOURCE >= 200112L || \
|
||||
_XOPEN_SOURCE >= 600 || \
|
||||
defined( __WATCOMC__ ) || defined( __DJGPP__ ) || \
|
||||
@@ -221,31 +212,44 @@ HB_BOOL hb_setenv( const char * szName, const char * szValue )
|
||||
defined( HB_OS_QNX ) || defined( HB_OS_VXWORKS ) || \
|
||||
defined( HB_OS_CYGWIN ) || defined( HB_OS_MINIX ) || \
|
||||
defined( HB_OS_ANDROID )
|
||||
|
||||
if( szValue )
|
||||
return setenv( szName, szValue, 1 ) == 0;
|
||||
else
|
||||
{
|
||||
HB_BOOL fResult;
|
||||
char * pszNameFree = NULL, * pszValueFree = NULL;
|
||||
|
||||
szName = hb_osEncodeCP( szName, &pszNameFree, NULL );
|
||||
if( szValue )
|
||||
{
|
||||
szValue = hb_osEncodeCP( szValue, &pszValueFree, NULL );
|
||||
fResult = setenv( szName, szValue, 1 ) == 0;
|
||||
if( pszValueFree )
|
||||
hb_xfree( pszValueFree );
|
||||
}
|
||||
else
|
||||
{
|
||||
# if ( defined( __DJGPP__ ) && \
|
||||
( __DJGPP__ < 2 || ( __DJGPP__ == 2 && __DJGPP_MINOR__ < 4 ) ) ) || \
|
||||
defined( __WATCOMC__ )
|
||||
szValue = getenv( szName );
|
||||
if( szValue && *szValue )
|
||||
return setenv( szName, "", 1 ) == 0;
|
||||
else
|
||||
return HB_TRUE;
|
||||
szValue = getenv( szName );
|
||||
if( szValue && *szValue )
|
||||
fResult = setenv( szName, "", 1 ) == 0;
|
||||
else
|
||||
fResult = HB_TRUE;
|
||||
# elif defined( __OpenBSD__ ) || defined( HB_OS_QNX ) || \
|
||||
( defined( __FreeBSD_version ) && __FreeBSD_version < 700050 )
|
||||
unsetenv( szName );
|
||||
return HB_TRUE;
|
||||
unsetenv( szName );
|
||||
fResult = HB_TRUE;
|
||||
# else
|
||||
return unsetenv( szName ) == 0;
|
||||
fResult = unsetenv( szName ) == 0;
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
if( pszNameFree )
|
||||
hb_xfree( pszNameFree );
|
||||
|
||||
return fResult;
|
||||
}
|
||||
#elif defined( _HB_NO_SETENV_ )
|
||||
|
||||
HB_SYMBOL_UNUSED( szName );
|
||||
HB_SYMBOL_UNUSED( szValue );
|
||||
|
||||
return HB_FALSE;
|
||||
@@ -259,7 +263,6 @@ HB_BOOL hb_setenv( const char * szName, const char * szValue )
|
||||
|
||||
int iTODO;
|
||||
|
||||
HB_SYMBOL_UNUSED( szName );
|
||||
HB_SYMBOL_UNUSED( szValue );
|
||||
|
||||
return HB_FALSE;
|
||||
|
||||
@@ -78,6 +78,7 @@
|
||||
#if defined( HB_OS_WIN )
|
||||
|
||||
#include <windows.h>
|
||||
#include "hbwinuni.h"
|
||||
#if defined( HB_OS_WIN_CE )
|
||||
#include "hbwince.h"
|
||||
#endif
|
||||
@@ -471,7 +472,7 @@ char * hb_verPlatform( void )
|
||||
|
||||
if( osVer.szCSDVersion )
|
||||
{
|
||||
char * pszCSDVersion = HB_TCHAR_CONVFROM( osVer.szCSDVersion );
|
||||
char * pszCSDVersion = HB_OSSTRDUP( osVer.szCSDVersion );
|
||||
int i;
|
||||
|
||||
/* Skip the leading spaces (Win95B, Win98) */
|
||||
@@ -482,8 +483,7 @@ char * hb_verPlatform( void )
|
||||
hb_strncat( pszPlatform, " ", PLATFORM_BUF_SIZE );
|
||||
hb_strncat( pszPlatform, pszCSDVersion + i, PLATFORM_BUF_SIZE );
|
||||
}
|
||||
|
||||
HB_TCHAR_FREE( pszCSDVersion );
|
||||
hb_xfree( pszCSDVersion );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
*/
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapicdp.h"
|
||||
|
||||
#if defined( HB_OS_UNIX ) && !defined( HB_NO_FNMATCH )
|
||||
# include <fnmatch.h>
|
||||
@@ -58,26 +59,30 @@
|
||||
|
||||
#define HB_MAX_WILDPATTERN 256
|
||||
|
||||
HB_BOOL hb_strMatchWild( const char *szString, const char *szPattern )
|
||||
static HB_BOOL hb_strMatchWildRaw( const char *szString, const char *szPattern,
|
||||
HB_BOOL fExact, HB_BOOL fCase )
|
||||
{
|
||||
HB_BOOL fMatch = HB_TRUE, fAny = HB_FALSE;
|
||||
HB_SIZE pnBufPosP[ HB_MAX_WILDPATTERN ], pnBufPosV[ HB_MAX_WILDPATTERN ],
|
||||
nBufSize = HB_MAX_WILDPATTERN;
|
||||
HB_SIZE * nAnyPosP = pnBufPosP, * nAnyPosV = pnBufPosV,
|
||||
nSize, nLen, nAny, i, j;
|
||||
nSize, nLen, nAny, nPosP, nPosV;
|
||||
|
||||
i = j = nAny = 0;
|
||||
nPosP = nPosV = nAny = 0;
|
||||
nLen = strlen( szString );
|
||||
nSize = strlen( szPattern );
|
||||
while( i < nSize )
|
||||
while( nPosP < nSize || ( fExact && !fAny && nPosV < nLen ) )
|
||||
{
|
||||
if( szPattern[i] == '*' )
|
||||
if( nPosP < nSize && szPattern[ nPosP ] == '*' )
|
||||
{
|
||||
fAny = HB_TRUE;
|
||||
i++;
|
||||
nPosP++;
|
||||
}
|
||||
else if( j < nLen &&
|
||||
( szPattern[i] == '?' || szPattern[i] == szString[j] ) )
|
||||
else if( nPosV < nLen && nPosP < nSize &&
|
||||
( szPattern[ nPosP ] == '?' ||
|
||||
( ! fCase ? szPattern[ nPosP ] == szString[ nPosV ] :
|
||||
( hb_charUpper( szPattern[ nPosP ] ) ==
|
||||
hb_charUpper( szString[ nPosV ] ) ) ) ) )
|
||||
{
|
||||
if( fAny )
|
||||
{
|
||||
@@ -96,23 +101,23 @@ HB_BOOL hb_strMatchWild( const char *szString, const char *szPattern )
|
||||
nAnyPosV = ( HB_SIZE * ) hb_xrealloc( nAnyPosV, nBufSize * sizeof( HB_SIZE ) );
|
||||
}
|
||||
}
|
||||
nAnyPosP[ nAny ] = i;
|
||||
nAnyPosV[ nAny ] = j;
|
||||
nAnyPosP[ nAny ] = nPosP;
|
||||
nAnyPosV[ nAny ] = nPosV;
|
||||
nAny++;
|
||||
fAny = HB_FALSE;
|
||||
}
|
||||
j++;
|
||||
i++;
|
||||
nPosV++;
|
||||
nPosP++;
|
||||
}
|
||||
else if( fAny && j < nLen )
|
||||
else if( fAny && nPosV < nLen )
|
||||
{
|
||||
j++;
|
||||
nPosV++;
|
||||
}
|
||||
else if( nAny > 0 )
|
||||
{
|
||||
nAny--;
|
||||
i = nAnyPosP[ nAny ];
|
||||
j = nAnyPosV[ nAny ] + 1;
|
||||
nPosP = nAnyPosP[ nAny ];
|
||||
nPosV = nAnyPosV[ nAny ] + 1;
|
||||
fAny = HB_TRUE;
|
||||
}
|
||||
else
|
||||
@@ -129,147 +134,136 @@ HB_BOOL hb_strMatchWild( const char *szString, const char *szPattern )
|
||||
return fMatch;
|
||||
}
|
||||
|
||||
static HB_BOOL hb_strMatchWildCDP( const char *szString, const char *szPattern,
|
||||
HB_BOOL fExact, HB_BOOL fCase,
|
||||
PHB_CODEPAGE cdp )
|
||||
{
|
||||
HB_BOOL fMatch = HB_TRUE, fAny = HB_FALSE;
|
||||
HB_SIZE pnBufPosP[ HB_MAX_WILDPATTERN ], pnBufPosV[ HB_MAX_WILDPATTERN ],
|
||||
nBufSize = HB_MAX_WILDPATTERN;
|
||||
HB_SIZE * nAnyPosP = pnBufPosP, * nAnyPosV = pnBufPosV,
|
||||
nSize, nLen, nAny, nPosP, nPosV;
|
||||
|
||||
nPosP = nPosV = nAny = 0;
|
||||
nLen = strlen( szString );
|
||||
nSize = strlen( szPattern );
|
||||
while( nPosP < nSize || ( fExact && !fAny && nPosV < nLen ) )
|
||||
{
|
||||
if( nPosP < nSize && szPattern[ nPosP ] == '*' )
|
||||
{
|
||||
fAny = HB_TRUE;
|
||||
nPosP++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if( nPosV < nLen && nPosP < nSize )
|
||||
{
|
||||
HB_SIZE nPP = nPosP, nPV = nPosV;
|
||||
|
||||
if( szPattern[ nPosP ] == '?' )
|
||||
{
|
||||
nPosP++;
|
||||
nPosV += hb_cdpTextPos( cdp, szString + nPosV, nLen - nPosV, 1 );
|
||||
}
|
||||
else if( fCase )
|
||||
{
|
||||
if( !hb_cdpCharCaseEq( cdp, szString, nLen, &nPosV,
|
||||
szPattern, nSize, &nPosP ) )
|
||||
{
|
||||
nPosV = nPV;
|
||||
nPosP = nPP;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !hb_cdpCharEq( cdp, szString, nLen, &nPosV,
|
||||
szPattern, nSize, &nPosP ) )
|
||||
{
|
||||
nPosV = nPV;
|
||||
nPosP = nPP;
|
||||
}
|
||||
}
|
||||
if( nPP != nPosP )
|
||||
{
|
||||
if( fAny )
|
||||
{
|
||||
if( nAny >= nBufSize )
|
||||
{
|
||||
if( ( nBufSize <<= 1 ) == ( HB_MAX_WILDPATTERN << 1 ) )
|
||||
{
|
||||
nAnyPosP = ( HB_SIZE * ) hb_xgrab( nBufSize * sizeof( HB_SIZE ) );
|
||||
nAnyPosV = ( HB_SIZE * ) hb_xgrab( nBufSize * sizeof( HB_SIZE ) );
|
||||
memcpy( nAnyPosP, pnBufPosP, HB_MAX_WILDPATTERN * sizeof( HB_SIZE ) );
|
||||
memcpy( nAnyPosV, pnBufPosV, HB_MAX_WILDPATTERN * sizeof( HB_SIZE ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
nAnyPosP = ( HB_SIZE * ) hb_xrealloc( nAnyPosP, nBufSize * sizeof( HB_SIZE ) );
|
||||
nAnyPosV = ( HB_SIZE * ) hb_xrealloc( nAnyPosV, nBufSize * sizeof( HB_SIZE ) );
|
||||
}
|
||||
}
|
||||
nAnyPosP[ nAny ] = nPP;
|
||||
nAnyPosV[ nAny ] = nPosV;
|
||||
nAny++;
|
||||
fAny = HB_FALSE;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if( fAny && nPosV < nLen )
|
||||
{
|
||||
nPosV += hb_cdpTextPos( cdp, szString + nPosV, nLen - nPosV, 1 );
|
||||
}
|
||||
else if( nAny > 0 )
|
||||
{
|
||||
nAny--;
|
||||
nPosP = nAnyPosP[ nAny ];
|
||||
nPosV = nAnyPosV[ nAny ];
|
||||
fAny = HB_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
fMatch = HB_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( nBufSize > HB_MAX_WILDPATTERN )
|
||||
{
|
||||
hb_xfree( nAnyPosP );
|
||||
hb_xfree( nAnyPosV );
|
||||
}
|
||||
return fMatch;
|
||||
}
|
||||
|
||||
HB_BOOL hb_strMatchWild( const char *szString, const char *szPattern )
|
||||
{
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
|
||||
if( cdp && HB_CDP_ISCHARIDX( cdp ) )
|
||||
return hb_strMatchWildCDP( szString, szPattern, HB_FALSE, HB_FALSE, cdp );
|
||||
else
|
||||
return hb_strMatchWildRaw( szString, szPattern, HB_FALSE, HB_FALSE );
|
||||
}
|
||||
|
||||
HB_BOOL hb_strMatchWildExact( const char *szString, const char *szPattern )
|
||||
{
|
||||
HB_BOOL fMatch = HB_TRUE, fAny = HB_FALSE;
|
||||
HB_SIZE pnBufPosP[ HB_MAX_WILDPATTERN ], pnBufPosV[ HB_MAX_WILDPATTERN ],
|
||||
nBufSize = HB_MAX_WILDPATTERN;
|
||||
HB_SIZE * nAnyPosP = pnBufPosP, * nAnyPosV = pnBufPosV,
|
||||
nSize, nLen, nAny, i, j;
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
|
||||
i = j = nAny = 0;
|
||||
nLen = strlen( szString );
|
||||
nSize = strlen( szPattern );
|
||||
while( i < nSize || ( j < nLen && !fAny ) )
|
||||
{
|
||||
if( i < nSize && szPattern[i] == '*' )
|
||||
{
|
||||
fAny = HB_TRUE;
|
||||
i++;
|
||||
}
|
||||
else if( j < nLen && i < nSize &&
|
||||
( szPattern[i] == '?' || szPattern[i] == szString[j] ) )
|
||||
{
|
||||
if( fAny )
|
||||
{
|
||||
if( nAny >= nBufSize )
|
||||
{
|
||||
if( ( nBufSize <<= 1 ) == ( HB_MAX_WILDPATTERN << 1 ) )
|
||||
{
|
||||
nAnyPosP = ( HB_SIZE * ) hb_xgrab( nBufSize * sizeof( HB_SIZE ) );
|
||||
nAnyPosV = ( HB_SIZE * ) hb_xgrab( nBufSize * sizeof( HB_SIZE ) );
|
||||
memcpy( nAnyPosP, pnBufPosP, HB_MAX_WILDPATTERN * sizeof( HB_SIZE ) );
|
||||
memcpy( nAnyPosV, pnBufPosV, HB_MAX_WILDPATTERN * sizeof( HB_SIZE ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
nAnyPosP = ( HB_SIZE * ) hb_xrealloc( nAnyPosP, nBufSize * sizeof( HB_SIZE ) );
|
||||
nAnyPosV = ( HB_SIZE * ) hb_xrealloc( nAnyPosV, nBufSize * sizeof( HB_SIZE ) );
|
||||
}
|
||||
}
|
||||
nAnyPosP[ nAny ] = i;
|
||||
nAnyPosV[ nAny ] = j;
|
||||
nAny++;
|
||||
fAny = HB_FALSE;
|
||||
}
|
||||
j++;
|
||||
i++;
|
||||
}
|
||||
else if( fAny && j < nLen )
|
||||
{
|
||||
j++;
|
||||
}
|
||||
else if( nAny > 0 )
|
||||
{
|
||||
nAny--;
|
||||
i = nAnyPosP[ nAny ];
|
||||
j = nAnyPosV[ nAny ] + 1;
|
||||
fAny = HB_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
fMatch = HB_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( nBufSize > HB_MAX_WILDPATTERN )
|
||||
{
|
||||
hb_xfree( nAnyPosP );
|
||||
hb_xfree( nAnyPosV );
|
||||
}
|
||||
return fMatch;
|
||||
if( cdp && HB_CDP_ISCHARIDX( cdp ) )
|
||||
return hb_strMatchWildCDP( szString, szPattern, HB_TRUE, HB_FALSE, cdp );
|
||||
else
|
||||
return hb_strMatchWildRaw( szString, szPattern, HB_TRUE, HB_FALSE );
|
||||
}
|
||||
|
||||
HB_BOOL hb_strMatchCaseWildExact( const char *szString, const char *szPattern )
|
||||
{
|
||||
HB_BOOL fMatch = HB_TRUE, fAny = HB_FALSE;
|
||||
HB_SIZE pnBufPosP[ HB_MAX_WILDPATTERN ], pnBufPosV[ HB_MAX_WILDPATTERN ],
|
||||
nBufSize = HB_MAX_WILDPATTERN;
|
||||
HB_SIZE * nAnyPosP = pnBufPosP, * nAnyPosV = pnBufPosV,
|
||||
nSize, nLen, nAny, i, j;
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
|
||||
i = j = nAny = 0;
|
||||
nLen = strlen( szString );
|
||||
nSize = strlen( szPattern );
|
||||
while( i < nSize || ( j < nLen && !fAny ) )
|
||||
{
|
||||
if( i < nSize && szPattern[i] == '*' )
|
||||
{
|
||||
fAny = HB_TRUE;
|
||||
i++;
|
||||
}
|
||||
else if( j < nLen && i < nSize &&
|
||||
( szPattern[i] == '?' ||
|
||||
hb_charUpper( szPattern[i] ) == hb_charUpper( szString[j] ) ) )
|
||||
{
|
||||
if( fAny )
|
||||
{
|
||||
if( nAny >= nBufSize )
|
||||
{
|
||||
if( ( nBufSize <<= 1 ) == ( HB_MAX_WILDPATTERN << 1 ) )
|
||||
{
|
||||
nAnyPosP = ( HB_SIZE * ) hb_xgrab( nBufSize * sizeof( HB_SIZE ) );
|
||||
nAnyPosV = ( HB_SIZE * ) hb_xgrab( nBufSize * sizeof( HB_SIZE ) );
|
||||
memcpy( nAnyPosP, pnBufPosP, HB_MAX_WILDPATTERN * sizeof( HB_SIZE ) );
|
||||
memcpy( nAnyPosV, pnBufPosV, HB_MAX_WILDPATTERN * sizeof( HB_SIZE ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
nAnyPosP = ( HB_SIZE * ) hb_xrealloc( nAnyPosP, nBufSize * sizeof( HB_SIZE ) );
|
||||
nAnyPosV = ( HB_SIZE * ) hb_xrealloc( nAnyPosV, nBufSize * sizeof( HB_SIZE ) );
|
||||
}
|
||||
}
|
||||
nAnyPosP[ nAny ] = i;
|
||||
nAnyPosV[ nAny ] = j;
|
||||
nAny++;
|
||||
fAny = HB_FALSE;
|
||||
}
|
||||
j++;
|
||||
i++;
|
||||
}
|
||||
else if( fAny && j < nLen )
|
||||
{
|
||||
j++;
|
||||
}
|
||||
else if( nAny > 0 )
|
||||
{
|
||||
nAny--;
|
||||
i = nAnyPosP[ nAny ];
|
||||
j = nAnyPosV[ nAny ] + 1;
|
||||
fAny = HB_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
fMatch = HB_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( nBufSize > HB_MAX_WILDPATTERN )
|
||||
{
|
||||
hb_xfree( nAnyPosP );
|
||||
hb_xfree( nAnyPosV );
|
||||
}
|
||||
return fMatch;
|
||||
if( cdp && HB_CDP_ISCHARIDX( cdp ) )
|
||||
return hb_strMatchWildCDP( szString, szPattern, HB_TRUE, HB_TRUE, cdp );
|
||||
else
|
||||
return hb_strMatchWildRaw( szString, szPattern, HB_TRUE, HB_TRUE );
|
||||
}
|
||||
|
||||
HB_BOOL hb_strMatchFile( const char * szString, const char * szPattern )
|
||||
|
||||
@@ -444,6 +444,17 @@ static void hb_compChkEnvironVar( HB_COMP_DECL, const char *szSwitch )
|
||||
HB_COMP_PARAM->supported |= HB_COMPFLAG_EXTOPT;
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
case 'U':
|
||||
if( s[i] == '-' )
|
||||
{
|
||||
i++;
|
||||
HB_COMP_PARAM->supported &= ~HB_COMPFLAG_USERCP;
|
||||
}
|
||||
else
|
||||
HB_COMP_PARAM->supported |= HB_COMPFLAG_USERCP;
|
||||
break;
|
||||
|
||||
default:
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
|
||||
break;
|
||||
|
||||
@@ -139,6 +139,7 @@ void hb_compPrintModes( HB_COMP_DECL )
|
||||
"\n r[-] runtime settings enabled",
|
||||
"\n s[-] allow indexed assignment on all types",
|
||||
"\n x[-] extended Xbase++ mode",
|
||||
"\n u[-] strings in user encoding",
|
||||
"\n j[+] turn off jump optimization in pcode",
|
||||
"\n m[+] turn off macrotext substitution",
|
||||
"\n ? this info",
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapifs.h"
|
||||
#include "hbapicdp.h"
|
||||
#include "hbapierr.h"
|
||||
#include "hbset.h"
|
||||
#include "hbvm.h"
|
||||
@@ -372,6 +373,45 @@ int hb_charLower( int iChar )
|
||||
return HB_TOLOWER( iChar );
|
||||
}
|
||||
|
||||
PHB_CODEPAGE hb_vmCDP( void )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HB_SIZE hb_cdpTextPos( PHB_CODEPAGE cdp, const char * pText, HB_SIZE nSize, HB_SIZE nIndex )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( cdp );
|
||||
HB_SYMBOL_UNUSED( pText );
|
||||
|
||||
return nIndex >= nSize ? nSize : nIndex;
|
||||
}
|
||||
|
||||
HB_BOOL hb_cdpCharEq( PHB_CODEPAGE cdp, const char * szText1, HB_SIZE nLen1, HB_SIZE * pnPos1,
|
||||
const char * szText2, HB_SIZE nLen2, HB_SIZE * pnPos2 )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( cdp );
|
||||
|
||||
if( *pnPos1 < nLen1 && *pnPos2 < nLen2 )
|
||||
return szText1[ ( * pnPos1 )++ ] == szText2[ ( * pnPos2 )++ ];
|
||||
else
|
||||
return HB_FALSE;
|
||||
}
|
||||
|
||||
HB_BOOL hb_cdpCharCaseEq( PHB_CODEPAGE cdp, const char * szText1, HB_SIZE nLen1, HB_SIZE * pnPos1,
|
||||
const char * szText2, HB_SIZE nLen2, HB_SIZE * pnPos2 )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( cdp );
|
||||
|
||||
if( *pnPos1 < nLen1 && *pnPos2 < nLen2 )
|
||||
{
|
||||
HB_UCHAR uc1 = szText1[ ( * pnPos1 )++ ],
|
||||
uc2 = szText2[ ( * pnPos2 )++ ];
|
||||
return HB_TOUPPER( uc1 ) == HB_TOUPPER( uc2 );
|
||||
}
|
||||
else
|
||||
return HB_FALSE;
|
||||
}
|
||||
|
||||
const char * hb_osEncodeCP( const char * szName, char ** pszFree, HB_SIZE * pnSize )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( pnSize );
|
||||
@@ -386,6 +426,49 @@ const char * hb_osDecodeCP( const char * szName, char ** pszFree, HB_SIZE * pnSi
|
||||
return szName;
|
||||
}
|
||||
|
||||
char * hb_osStrEncode( const char * pszName )
|
||||
{
|
||||
return hb_strdup( pszName );
|
||||
}
|
||||
|
||||
char * hb_osStrEncodeN( const char * pszName, HB_SIZE nLen )
|
||||
{
|
||||
return hb_strndup( pszName, nLen );
|
||||
}
|
||||
|
||||
char * hb_osStrDecode( const char * pszName )
|
||||
{
|
||||
return hb_strdup( pszName );
|
||||
}
|
||||
|
||||
char * hb_osStrDecode2( const char * pszName, char * pszBuffer, HB_SIZE nSize )
|
||||
{
|
||||
return hb_strncpy( pszBuffer, pszName, nSize );
|
||||
}
|
||||
|
||||
#if defined( HB_OS_WIN )
|
||||
HB_WCHAR * hb_osStrU16Encode( const char * pszName )
|
||||
{
|
||||
return hb_mbtowc( pszName );
|
||||
}
|
||||
|
||||
HB_WCHAR * hb_osStrU16EncodeN( const char * pszName, HB_SIZE nLen )
|
||||
{
|
||||
return hb_mbntowc( pszName, nLen );
|
||||
}
|
||||
|
||||
char * hb_osStrU16Decode( const HB_WCHAR * pszNameW )
|
||||
{
|
||||
return hb_wctomb( pszNameW );
|
||||
}
|
||||
|
||||
char * hb_osStrU16Decode2( const HB_WCHAR * pszNameW, char * pszBuffer, HB_SIZE nSize )
|
||||
{
|
||||
hb_wcntombcpy( pszBuffer, pszNameW, nSize );
|
||||
return pszBuffer;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* HB_TRACE */
|
||||
static HB_TRACEINFO s_traceInfo;
|
||||
@@ -513,6 +596,100 @@ const char * hb_fsNameConv( const char * szFileName, char ** pszFree )
|
||||
return szFileName;
|
||||
}
|
||||
|
||||
#if defined( HB_OS_WIN )
|
||||
HB_WCHAR * hb_fsNameConvU16( const char * szFileName )
|
||||
{
|
||||
char * pszBuffer = NULL;
|
||||
HB_WCHAR * lpwFileName;
|
||||
|
||||
if( s_fFnTrim || s_cDirSep != HB_OS_PATH_DELIM_CHR ||
|
||||
s_iFileCase != HB_SET_CASE_MIXED || s_iDirCase != HB_SET_CASE_MIXED )
|
||||
{
|
||||
PHB_FNAME pFileName;
|
||||
HB_SIZE nLen;
|
||||
|
||||
szFileName = pszBuffer = hb_strncpy( ( char * ) hb_xgrab( HB_PATH_MAX ),
|
||||
szFileName, HB_PATH_MAX - 1 );
|
||||
|
||||
if( s_cDirSep != HB_OS_PATH_DELIM_CHR )
|
||||
{
|
||||
char *p = ( char * ) szFileName;
|
||||
while( *p )
|
||||
{
|
||||
if( *p == s_cDirSep )
|
||||
*p = HB_OS_PATH_DELIM_CHR;
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
pFileName = hb_fsFNameSplit( szFileName );
|
||||
|
||||
/* strip trailing and leading spaces */
|
||||
if( s_fFnTrim )
|
||||
{
|
||||
if( pFileName->szName )
|
||||
{
|
||||
nLen = strlen( pFileName->szName );
|
||||
while( nLen && pFileName->szName[ nLen - 1 ] == ' ' )
|
||||
--nLen;
|
||||
while( nLen && pFileName->szName[ 0 ] == ' ' )
|
||||
{
|
||||
++pFileName->szName;
|
||||
--nLen;
|
||||
}
|
||||
( ( char * ) pFileName->szName )[ nLen ] = '\0';
|
||||
}
|
||||
if( pFileName->szExtension )
|
||||
{
|
||||
nLen = strlen( pFileName->szExtension );
|
||||
while( nLen && pFileName->szExtension[ nLen - 1 ] == ' ' )
|
||||
--nLen;
|
||||
while( nLen && pFileName->szExtension[ 0 ] == ' ' )
|
||||
{
|
||||
++pFileName->szExtension;
|
||||
--nLen;
|
||||
}
|
||||
( ( char * ) pFileName->szExtension )[ nLen ] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
/* FILECASE */
|
||||
if( s_iFileCase == HB_SET_CASE_LOWER )
|
||||
{
|
||||
if( pFileName->szName )
|
||||
hb_strlow( ( char * ) pFileName->szName );
|
||||
if( pFileName->szExtension )
|
||||
hb_strlow( ( char * ) pFileName->szExtension );
|
||||
}
|
||||
else if( s_iFileCase == HB_SET_CASE_UPPER )
|
||||
{
|
||||
if( pFileName->szName )
|
||||
hb_strupr( ( char * ) pFileName->szName );
|
||||
if( pFileName->szExtension )
|
||||
hb_strupr( ( char * ) pFileName->szExtension );
|
||||
}
|
||||
|
||||
/* DIRCASE */
|
||||
if( pFileName->szPath )
|
||||
{
|
||||
if( s_iDirCase == HB_SET_CASE_LOWER )
|
||||
hb_strlow( ( char * ) pFileName->szPath );
|
||||
else if( s_iDirCase == HB_SET_CASE_UPPER )
|
||||
hb_strupr( ( char * ) pFileName->szPath );
|
||||
}
|
||||
|
||||
hb_fsFNameMerge( ( char * ) szFileName, pFileName );
|
||||
hb_xfree( pFileName );
|
||||
}
|
||||
|
||||
lpwFileName = hb_mbtowc( szFileName );
|
||||
if( pszBuffer )
|
||||
hb_xfree( pszBuffer );
|
||||
|
||||
return lpwFileName;
|
||||
}
|
||||
#endif
|
||||
|
||||
int hb_setGetDirSeparator( void )
|
||||
{
|
||||
return s_cDirSep;
|
||||
|
||||
@@ -421,9 +421,7 @@ static int hb_pp_generateVerInfo( char * szVerFile, int iSVNID, char * szChangeL
|
||||
static char * hb_fsFileFind( const char * pszFileMask )
|
||||
{
|
||||
PHB_FFIND ffind;
|
||||
char * pszFree;
|
||||
|
||||
pszFileMask = hb_fsNameConv( pszFileMask, &pszFree );
|
||||
if( ( ffind = hb_fsFindFirst( pszFileMask, HB_FA_ALL ) ) != NULL )
|
||||
{
|
||||
char pszFileName[ HB_PATH_MAX ];
|
||||
@@ -431,13 +429,9 @@ static char * hb_fsFileFind( const char * pszFileMask )
|
||||
pFileName->szName = ffind->szName;
|
||||
hb_fsFNameMerge( pszFileName, pFileName );
|
||||
hb_fsFindClose( ffind );
|
||||
if( pszFree )
|
||||
hb_xfree( pszFree );
|
||||
hb_xfree( pFileName );
|
||||
return hb_strdup( pszFileName );
|
||||
}
|
||||
if( pszFree )
|
||||
hb_xfree( pszFree );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ C_SOURCES := \
|
||||
cdpapi.c \
|
||||
cdpapihb.c \
|
||||
chrasc.c \
|
||||
chruni.c \
|
||||
colorind.c \
|
||||
console.c \
|
||||
copyfile.c \
|
||||
|
||||
@@ -89,8 +89,10 @@ HB_FUNC( __ACCEPTSTR )
|
||||
|
||||
HB_FUNC( __ACCEPT )
|
||||
{
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
char szAcceptResult[ ACCEPT_BUFFER_LEN ];
|
||||
HB_SIZE nLen = 0;
|
||||
char szKey[ HB_MAX_CHAR_LEN ];
|
||||
HB_SIZE nLen = 0, nChar;
|
||||
int input = 0;
|
||||
|
||||
/* cPrompt(s) passed ? */
|
||||
@@ -109,19 +111,28 @@ HB_FUNC( __ACCEPT )
|
||||
case K_LEFT:
|
||||
if( nLen > 0 )
|
||||
{
|
||||
hb_conOutAlt( "\x8", sizeof( char ) ); /* Erase it from the screen. */
|
||||
--nLen; /* Adjust input count to get rid of last character */
|
||||
nChar = hb_cdpTextLen( cdp, szAcceptResult, nLen );
|
||||
if( nChar > 0 )
|
||||
nLen = hb_cdpTextPos( cdp, szAcceptResult, nLen, nChar - 1 );
|
||||
else
|
||||
nLen = 0;
|
||||
szKey[ 0 ] = HB_CHAR_BS;
|
||||
nChar = 1;
|
||||
}
|
||||
else
|
||||
nChar = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
if( nLen < ( ACCEPT_BUFFER_LEN - 1 ) && input >= 32 && input <= 255 )
|
||||
nChar = hb_inkeyKeyString( input, szKey, sizeof( szKey ) );
|
||||
if( nChar > 0 && nLen + nChar < ACCEPT_BUFFER_LEN )
|
||||
{
|
||||
szAcceptResult[ nLen ] = ( char ) input; /* Accept the input */
|
||||
hb_conOutAlt( &szAcceptResult[ nLen ], sizeof( char ) ); /* Then display it */
|
||||
++nLen; /* Then adjust the input count */
|
||||
memcpy( &szAcceptResult[ nLen ], szKey, nChar );
|
||||
nLen += nChar;
|
||||
}
|
||||
}
|
||||
if( nChar > 0 )
|
||||
hb_conOutAlt( szKey, nChar );
|
||||
}
|
||||
|
||||
szAcceptResult[ nLen ] = '\0';
|
||||
@@ -130,5 +141,5 @@ HB_FUNC( __ACCEPT )
|
||||
hb_strncpy( hb_acceptBuffer(), szAcceptResult, ACCEPT_BUFFER_LEN - 1 );
|
||||
#endif
|
||||
|
||||
hb_retc( szAcceptResult );
|
||||
hb_retclen( szAcceptResult, nLen );
|
||||
}
|
||||
|
||||
@@ -155,8 +155,7 @@ FUNCTION AChoice( nTop, nLeft, nBottom, nRight, acItems, xSelect, xUserFunc, nPo
|
||||
|
||||
Eval( bAction, ProcName( 1 ), ProcLine( 1 ), "" )
|
||||
IF Empty( NextKey() )
|
||||
KEYBOARD Chr( 255 )
|
||||
Inkey()
|
||||
hb_setLastKey( 255 )
|
||||
nKey := 0
|
||||
ENDIF
|
||||
|
||||
@@ -207,7 +206,7 @@ FUNCTION AChoice( nTop, nLeft, nBottom, nRight, acItems, xSelect, xUserFunc, nPo
|
||||
nPos := nNewPos
|
||||
DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Ach_Select( alSelect, nPos ), .T., nNumCols )
|
||||
IF nKey == K_LDBLCLK
|
||||
Keyboard( Chr( K_ENTER ) )
|
||||
hb_keyIns( K_ENTER )
|
||||
ENDIF
|
||||
ENDIF
|
||||
ENDIF
|
||||
@@ -466,19 +465,18 @@ FUNCTION AChoice( nTop, nLeft, nBottom, nRight, acItems, xSelect, xUserFunc, nPo
|
||||
nPos := 0
|
||||
lFinished := .T.
|
||||
|
||||
CASE INRANGE( 32, nKey, 255 ) .AND. ( !lUserFunc .OR. nMode == AC_GOTO )
|
||||
|
||||
cKey := Upper( Chr( nKey ) )
|
||||
CASE ( !lUserFunc .OR. nMode == AC_GOTO ) .AND. ;
|
||||
! ( cKey := Upper( hb_keyChar( nKey ) ) ) == ""
|
||||
|
||||
// Find next selectable item
|
||||
FOR nNewPos := nPos + 1 TO nItems
|
||||
IF Ach_Select( alSelect, nNewPos ) .AND. Upper( Left( acItems[ nNewPos ], 1 ) ) == cKey
|
||||
IF Ach_Select( alSelect, nNewPos ) .AND. Upper( Left( acItems[ nNewPos ], Len( cKey ) ) ) == cKey
|
||||
EXIT
|
||||
ENDIF
|
||||
NEXT
|
||||
IF nNewPos == nItems + 1
|
||||
FOR nNewPos := 1 TO nPos - 1
|
||||
IF Ach_Select( alSelect, nNewPos ) .AND. Upper( Left( acItems[ nNewPos ], 1 ) ) == cKey
|
||||
IF Ach_Select( alSelect, nNewPos ) .AND. Upper( Left( acItems[ nNewPos ], Len( cKey ) ) ) == cKey
|
||||
EXIT
|
||||
ENDIF
|
||||
NEXT
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Harbour Project source code:
|
||||
* AT() function
|
||||
*
|
||||
* Copyright 2012 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* Copyright 1999 Antonio Linares <alinares@fivetech.com>
|
||||
* www - http://harbour-project.org
|
||||
*
|
||||
@@ -52,6 +53,7 @@
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapicdp.h"
|
||||
#include "hbapierr.h"
|
||||
|
||||
/* locates a substring in a string */
|
||||
@@ -63,26 +65,54 @@ HB_FUNC( HB_AT )
|
||||
|
||||
if( pText && pSub )
|
||||
{
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
const char * pszText = hb_itemGetCPtr( pText );
|
||||
HB_SIZE nTextLength = hb_itemGetCLen( pText );
|
||||
HB_SIZE nStart = hb_parnsdef( 3, 1 );
|
||||
HB_SIZE nEnd = hb_parnsdef( 4, nTextLength );
|
||||
HB_SIZE nPos;
|
||||
HB_SIZE nStart = hb_parns( 3 );
|
||||
HB_SIZE nFrom, nTo, nPos = 0;
|
||||
|
||||
if( nStart > nTextLength || nEnd < nStart )
|
||||
hb_retns( 0 );
|
||||
if( nStart <= 1 )
|
||||
nStart = nFrom = 0;
|
||||
else if( HB_CDP_ISCHARIDX( cdp ) )
|
||||
nFrom = hb_cdpTextPos( cdp, pszText, nTextLength, --nStart );
|
||||
else
|
||||
nFrom = --nStart;
|
||||
|
||||
if( nFrom < nTextLength )
|
||||
{
|
||||
if( nEnd > nTextLength )
|
||||
nEnd = nTextLength;
|
||||
pszText += nFrom;
|
||||
nTextLength -= nFrom;
|
||||
if( HB_ISNUM( 4 ) )
|
||||
{
|
||||
nTo = hb_parns( 4 );
|
||||
if( nTo <= nStart )
|
||||
nTo = 0;
|
||||
else
|
||||
{
|
||||
nTo -= nStart;
|
||||
if( HB_CDP_ISCHARIDX( cdp ) )
|
||||
nTo = hb_cdpTextPos( cdp, pszText, nTextLength, nTo );
|
||||
if( nTo > nTextLength )
|
||||
nTo = nTextLength;
|
||||
}
|
||||
}
|
||||
else
|
||||
nTo = nTextLength;
|
||||
|
||||
nPos = hb_strAt( hb_itemGetCPtr( pSub ), hb_itemGetCLen( pSub ),
|
||||
hb_itemGetCPtr( pText ) + nStart - 1, nEnd - nStart + 1 );
|
||||
|
||||
if( nPos > 0 )
|
||||
nPos += ( nStart - 1 );
|
||||
|
||||
hb_retns( nPos );
|
||||
if( nTo > 0 )
|
||||
{
|
||||
nPos = hb_strAt( hb_itemGetCPtr( pSub ), hb_itemGetCLen( pSub ),
|
||||
pszText, nTo );
|
||||
if( nPos > 0 )
|
||||
{
|
||||
if( HB_CDP_ISCHARIDX( cdp ) )
|
||||
nPos = hb_cdpTextLen( cdp, pszText, nPos - 1 ) + 1 + nStart;
|
||||
else
|
||||
nPos += nFrom;
|
||||
}
|
||||
}
|
||||
}
|
||||
hb_retns( nPos );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 1108, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
@@ -95,8 +125,15 @@ HB_FUNC( AT )
|
||||
|
||||
if( pText && pSub )
|
||||
{
|
||||
hb_retns( hb_strAt( hb_itemGetCPtr( pSub ), hb_itemGetCLen( pSub ),
|
||||
hb_itemGetCPtr( pText ), hb_itemGetCLen( pText ) ) );
|
||||
HB_SIZE nPos = hb_strAt( hb_itemGetCPtr( pSub ), hb_itemGetCLen( pSub ),
|
||||
hb_itemGetCPtr( pText ), hb_itemGetCLen( pText ) );
|
||||
if( nPos )
|
||||
{
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
if( HB_CDP_ISCHARIDX( cdp ) )
|
||||
nPos = hb_cdpTextLen( cdp, hb_itemGetCPtr( pText ), nPos - 1 ) + 1;
|
||||
}
|
||||
hb_retns( nPos );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 1108, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Harbour Project source code:
|
||||
* HB_ATI() function
|
||||
*
|
||||
* Copyright 2012 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* Copyright 1999-2009 Viktor Szakats (harbour syenar.net)
|
||||
* Copyright 1999 Antonio Linares <alinares@fivetech.com>
|
||||
* www - http://harbour-project.org
|
||||
@@ -53,39 +54,36 @@
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapicdp.h"
|
||||
#include "hbapierr.h"
|
||||
|
||||
static HB_SIZE hb_strAtI( const char * szSub, HB_SIZE nSubLen, const char * szText, HB_SIZE nLen )
|
||||
static HB_SIZE hb_strAtI( PHB_CODEPAGE cdp, const char * szSub, HB_SIZE nSubLen, const char * szText, HB_SIZE nLen )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_strAt(%s, %" HB_PFS "u, %s, %" HB_PFS "u)", szSub, nSubLen, szText, nLen));
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_strAtI(%p, %s, %" HB_PFS "u, %s, %" HB_PFS "u)", cdp, szSub, nSubLen, szText, nLen));
|
||||
|
||||
if( nSubLen > 0 && nLen >= nSubLen )
|
||||
{
|
||||
HB_SIZE nPos = 0;
|
||||
HB_SIZE nSubPos = 0;
|
||||
|
||||
while( nPos < nLen && nSubPos < nSubLen )
|
||||
HB_SIZE nPos = 0, nIndex = 0;
|
||||
do
|
||||
{
|
||||
if( hb_charLower( szText[ nPos ] ) == hb_charLower( szSub[ nSubPos ] ) )
|
||||
HB_SIZE nSubPos = 0, nPrev = nPos;
|
||||
if( hb_cdpCharCaseEq( cdp, szText, nLen, &nPos, szSub, nSubLen, &nSubPos ) )
|
||||
{
|
||||
++nSubPos;
|
||||
++nPos;
|
||||
HB_SIZE nBack = nPos;
|
||||
do
|
||||
{
|
||||
if( nSubPos >= nSubLen )
|
||||
return ( HB_CDP_ISCHARIDX( cdp ) ? nIndex : nPrev ) + 1;
|
||||
}
|
||||
while( hb_cdpCharCaseEq( cdp, szText, nLen, &nPos, szSub, nSubLen, &nSubPos ) );
|
||||
nPos = nBack;
|
||||
}
|
||||
else if( nSubPos )
|
||||
{
|
||||
/* Go back to the first character after the first match,
|
||||
or else tests like "22345" $ "012223456789" will fail. */
|
||||
nPos -= ( nSubPos - 1 );
|
||||
nSubPos = 0;
|
||||
}
|
||||
else
|
||||
++nPos;
|
||||
++nIndex;
|
||||
}
|
||||
|
||||
return ( nSubPos < nSubLen ) ? 0 : ( nPos - nSubLen + 1 );
|
||||
while( nPos < nLen );
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
HB_FUNC( HB_ATI )
|
||||
@@ -95,26 +93,49 @@ HB_FUNC( HB_ATI )
|
||||
|
||||
if( pText && pSub )
|
||||
{
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
const char * pszText = hb_itemGetCPtr( pText );
|
||||
HB_SIZE nTextLength = hb_itemGetCLen( pText );
|
||||
HB_SIZE nStart = hb_parnsdef( 3, 1 );
|
||||
HB_SIZE nEnd = hb_parnsdef( 4, nTextLength );
|
||||
HB_SIZE nPos;
|
||||
HB_SIZE nStart = hb_parns( 3 );
|
||||
HB_SIZE nFrom, nTo, nPos = 0;
|
||||
|
||||
if( nStart > nTextLength || nEnd < nStart )
|
||||
hb_retns( 0 );
|
||||
if( nStart <= 1 )
|
||||
nStart = nFrom = 0;
|
||||
else if( HB_CDP_ISCHARIDX( cdp ) )
|
||||
nFrom = hb_cdpTextPos( cdp, pszText, nTextLength, --nStart );
|
||||
else
|
||||
nFrom = --nStart;
|
||||
|
||||
if( nFrom < nTextLength )
|
||||
{
|
||||
if( nEnd > nTextLength )
|
||||
nEnd = nTextLength;
|
||||
pszText += nFrom;
|
||||
nTextLength -= nFrom;
|
||||
if( HB_ISNUM( 4 ) )
|
||||
{
|
||||
nTo = hb_parns( 4 );
|
||||
if( nTo <= nStart )
|
||||
nTo = 0;
|
||||
else
|
||||
{
|
||||
nTo -= nStart;
|
||||
if( HB_CDP_ISCHARIDX( cdp ) )
|
||||
nTo = hb_cdpTextPos( cdp, pszText, nTextLength, nTo );
|
||||
if( nTo > nTextLength )
|
||||
nTo = nTextLength;
|
||||
}
|
||||
}
|
||||
else
|
||||
nTo = nTextLength;
|
||||
|
||||
nPos = hb_strAtI( hb_itemGetCPtr( pSub ), hb_itemGetCLen( pSub ),
|
||||
hb_itemGetCPtr( pText ) + nStart - 1, nEnd - nStart + 1 );
|
||||
|
||||
if( nPos > 0 )
|
||||
nPos += ( nStart - 1 );
|
||||
|
||||
hb_retns( nPos );
|
||||
if( nTo > 0 )
|
||||
{
|
||||
nPos = hb_strAtI( cdp, hb_itemGetCPtr( pSub ), hb_itemGetCLen( pSub ),
|
||||
pszText, nTo );
|
||||
if( nPos > 0 )
|
||||
nPos += HB_CDP_ISCHARIDX( cdp ) ? nStart : nFrom;
|
||||
}
|
||||
}
|
||||
hb_retns( nPos );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 1108, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
|
||||
@@ -80,7 +80,7 @@ HB_FUNC( DISPBOX )
|
||||
hb_itemGetNI( pLeft),
|
||||
hb_itemGetNI( pBottom ),
|
||||
hb_itemGetNI( pRight ),
|
||||
*pszBox ? pszBox : " ",
|
||||
pszBox,
|
||||
iColor );
|
||||
}
|
||||
else
|
||||
@@ -120,22 +120,15 @@ HB_FUNC( HB_DISPBOX )
|
||||
|
||||
if( pTop && pLeft && pBottom && pRight )
|
||||
{
|
||||
const char * pszBox = hb_parcx( 5 );
|
||||
const char * pszBox = hb_parc( 5 );
|
||||
const char * pszColor = hb_parc( 6 );
|
||||
int iColor;
|
||||
|
||||
if( pszColor )
|
||||
iColor = hb_gtColorToN( pszColor );
|
||||
else if( HB_ISNUM( 6 ) )
|
||||
iColor = hb_parni( 6 );
|
||||
else
|
||||
iColor = -1;
|
||||
int iColor = pszColor ? hb_gtColorToN( pszColor ) : hb_parnidef( 6, -1 );
|
||||
|
||||
hb_gtDrawBox( hb_itemGetNI( pTop ),
|
||||
hb_itemGetNI( pLeft),
|
||||
hb_itemGetNI( pBottom ),
|
||||
hb_itemGetNI( pRight ),
|
||||
*pszBox ? pszBox : " ",
|
||||
pszBox,
|
||||
iColor );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,8 +267,8 @@ FUNCTION Browse( nTop, nLeft, nBottom, nRight )
|
||||
EXIT
|
||||
|
||||
OTHERWISE
|
||||
IF nKey >= 32 .AND. nKey <= 255
|
||||
KEYBOARD Chr( nKey )
|
||||
IF ! hb_keyChar( nKey ) == ""
|
||||
hb_keyIns( nKey )
|
||||
nKey := K_ENTER
|
||||
lKeyPressed := .T.
|
||||
ENDIF
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -56,16 +56,6 @@
|
||||
#include "hbapierr.h"
|
||||
#include "hbapicdp.h"
|
||||
|
||||
/* Now we are using only 16bit Unicode values so the maximum size
|
||||
* of single character encoded in UTF8 is 3 though ISO 10646 Universal
|
||||
* Character Set (UCS) occupies even a 31-bit code space and to encode
|
||||
* all UCS values we will need 6 bytes. Now in practice no one uses
|
||||
* Unicode character over 0xFFFF but it may change in the future so
|
||||
* it's safer to use macro for maximum UTF8 character size. [druzus]
|
||||
*/
|
||||
#define HB_MAX_UTF8 3
|
||||
|
||||
|
||||
static HB_SIZE utf8pos( const char * szUTF8, HB_SIZE nLen, HB_SIZE nUTF8Pos )
|
||||
{
|
||||
if( nUTF8Pos > 0 && nUTF8Pos <= nLen )
|
||||
@@ -161,7 +151,8 @@ HB_FUNC( HB_TRANSLATE )
|
||||
|
||||
if( cdpIn && cdpOut && cdpIn != cdpOut &&
|
||||
( cdpIn->uniTable != cdpOut->uniTable ||
|
||||
cdpIn->fCustom || cdpOut->fCustom ) )
|
||||
HB_CDP_ISCUSTOM( cdpIn ) ||
|
||||
HB_CDP_ISCUSTOM( cdpOut ) ) )
|
||||
{
|
||||
char * szResult = hb_cdpnDup( hb_parc( 1 ), &nLen, cdpIn, cdpOut );
|
||||
hb_retclen_buffer( szResult, nLen );
|
||||
@@ -177,7 +168,7 @@ HB_FUNC( HB_UTF8CHR )
|
||||
{
|
||||
if( HB_ISNUM( 1 ) )
|
||||
{
|
||||
char utf8Char[ HB_MAX_UTF8 ];
|
||||
char utf8Char[ HB_MAX_CHAR_LEN ];
|
||||
int iLen;
|
||||
|
||||
iLen = hb_cdpU16CharToUTF8( utf8Char, ( HB_WCHAR ) hb_parni( 1 ) );
|
||||
@@ -424,7 +415,7 @@ HB_FUNC( HB_UTF8POKE )
|
||||
if( pText && HB_ISNUM( 2 ) && HB_ISNUM( 3 ) )
|
||||
{
|
||||
const char * szString = hb_itemGetCPtr( pText );
|
||||
HB_SIZE nLen = hb_parclen( 1 ), nPos;
|
||||
HB_SIZE nLen = hb_itemGetCLen( pText ), nPos;
|
||||
|
||||
nPos = utf8pos( szString, nLen, hb_parns( 2 ) );
|
||||
if( nPos )
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Harbour Project source code:
|
||||
* CHR(), ASC() functions
|
||||
*
|
||||
* Copyright 2012 Przemyslaw Czerpak < druzus /at/ priv.onet.pl >
|
||||
* Copyright 1999 Antonio Linares <alinares@fivetech.com>
|
||||
* www - http://harbour-project.org
|
||||
*
|
||||
@@ -51,7 +52,7 @@
|
||||
*/
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapicdp.h"
|
||||
#include "hbapierr.h"
|
||||
|
||||
/* converts an ASCII code to a character value */
|
||||
@@ -71,7 +72,18 @@ HB_FUNC( CHR )
|
||||
szChar[ 1 ] = '\0';
|
||||
hb_retclen( szChar, 1 );
|
||||
#else
|
||||
hb_retclen( hb_szAscii[ hb_parni( 1 ) & 0xFF ], 1 );
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
if( HB_CDP_ISCHARUNI( cdp ) )
|
||||
{
|
||||
char szChar[ HB_MAX_CHAR_LEN ];
|
||||
HB_SIZE nLen;
|
||||
|
||||
nLen = hb_cdpTextPutU16( hb_vmCDP(), szChar, sizeof( szChar ),
|
||||
( HB_WCHAR ) hb_parni( 1 ) );
|
||||
hb_retclen( szChar, nLen );
|
||||
}
|
||||
else
|
||||
hb_retclen( hb_szAscii[ hb_parni( 1 ) & 0xFF ], 1 );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@@ -84,7 +96,16 @@ HB_FUNC( ASC )
|
||||
const char * szValue = hb_parc( 1 );
|
||||
|
||||
if( szValue )
|
||||
hb_retni( ( HB_UCHAR ) szValue[ 0 ] );
|
||||
{
|
||||
int iChar;
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
if( HB_CDP_ISCHARUNI( cdp ) )
|
||||
iChar = hb_cdpTextGetU16( cdp, szValue, hb_parclen( 1 ) );
|
||||
else
|
||||
iChar = ( HB_UCHAR ) szValue[ 0 ];
|
||||
|
||||
hb_retni( iChar );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 1107, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
267
harbour/src/rtl/chruni.c
Normal file
267
harbour/src/rtl/chruni.c
Normal file
@@ -0,0 +1,267 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Binary and unicode string functions:
|
||||
* HB_UCHAR(), HB_UCODE(), HB_ULEN(), HB_UPEEK(), HB_UPOKE()
|
||||
* HB_BCHAR(), HB_BCODE(), HB_BLEN(), HB_BPEEK(), HB_BPOKE()
|
||||
*
|
||||
* Copyright 2012 Przemyslaw Czerpak < druzus /at/ priv.onet.pl >
|
||||
* 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 "hbapi.h"
|
||||
#include "hbapicdp.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapierr.h"
|
||||
|
||||
/* HB_UCHAR( <nCode> ) -> <cText>
|
||||
* return string with U+nCode character in HVM CP encoding
|
||||
*/
|
||||
HB_FUNC( HB_UCHAR )
|
||||
{
|
||||
if( HB_ISNUM( 1 ) )
|
||||
{
|
||||
char szChar[ HB_MAX_CHAR_LEN ];
|
||||
HB_SIZE nLen;
|
||||
|
||||
nLen = hb_cdpTextPutU16( hb_vmCDP(), szChar, sizeof( szChar ),
|
||||
( HB_WCHAR ) hb_parni( 1 ) );
|
||||
hb_retclen( szChar, nLen );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 1111, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
/* HB_BCHAR( <nCode> ) -> <cText>
|
||||
* return 1 byte string with <nCode> value
|
||||
*/
|
||||
HB_FUNC( HB_BCHAR )
|
||||
{
|
||||
if( HB_ISNUM( 1 ) )
|
||||
{
|
||||
char c = ( char ) hb_parni( 1 );
|
||||
|
||||
hb_retclen( &c, 1 );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 1111, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
/* HB_UCODE( <cText> ) -> <nCode>
|
||||
* return unicode value of 1-st character (not byte) in given string
|
||||
*/
|
||||
HB_FUNC( HB_UCODE )
|
||||
{
|
||||
PHB_ITEM pText = hb_param( 1, HB_IT_STRING );
|
||||
|
||||
if( pText )
|
||||
hb_retni( hb_cdpTextGetU16( hb_vmCDP(), hb_itemGetCPtr( pText ),
|
||||
hb_itemGetCLen( pText ) ) );
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 1111, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
/* HB_BCODE( <cText> ) -> <nCode>
|
||||
* return value of 1-st byte in given string
|
||||
*/
|
||||
HB_FUNC( HB_BCODE )
|
||||
{
|
||||
const char * szText = hb_parc( 1 );
|
||||
|
||||
if( szText )
|
||||
hb_retni( ( HB_UCHAR ) szText[ 0 ] );
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 1111, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
/* HB_ULEN( <cText> ) -> <nChars>
|
||||
* return string length in characters
|
||||
*/
|
||||
HB_FUNC( HB_ULEN )
|
||||
{
|
||||
PHB_ITEM pText = hb_param( 1, HB_IT_STRING );
|
||||
|
||||
if( pText )
|
||||
hb_retns( hb_cdpTextLen( hb_vmCDP(), hb_itemGetCPtr( pText ),
|
||||
hb_itemGetCLen( pText ) ) );
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 1111, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
/* HB_BLEN( <cText> ) -> <nBytes>
|
||||
* return string length in bytes
|
||||
*/
|
||||
HB_FUNC( HB_BLEN )
|
||||
{
|
||||
PHB_ITEM pText = hb_param( 1, HB_IT_STRING );
|
||||
|
||||
if( pText )
|
||||
hb_retns( hb_itemGetCLen( pText ) );
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 1111, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
/* HB_UPEEK( <cText>, <n> ) -> <nCode>
|
||||
* return unicode value of <n>-th character in given string
|
||||
*/
|
||||
HB_FUNC( HB_UPEEK )
|
||||
{
|
||||
PHB_ITEM pText = hb_param( 1, HB_IT_STRING );
|
||||
|
||||
if( pText && HB_ISNUM( 2 ) )
|
||||
{
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
const char * szText = hb_itemGetCPtr( pText );
|
||||
HB_SIZE nLen = hb_itemGetCLen( pText );
|
||||
HB_SIZE nPos = hb_parns( 2 );
|
||||
HB_WCHAR wc = 0;
|
||||
|
||||
if( nPos > 0 && nPos <= nLen )
|
||||
{
|
||||
nPos = hb_cdpTextPos( cdp, szText, nLen, nPos - 1 );
|
||||
nLen -= nPos;
|
||||
if( nLen > 0 )
|
||||
wc = hb_cdpTextGetU16( cdp, szText + nPos, nLen );
|
||||
}
|
||||
|
||||
hb_retni( wc );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 1111, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
/* HB_BPEEK( <cText>, <n> ) -> <nCode>
|
||||
* return value of <n>-th byte in given string
|
||||
*/
|
||||
HB_FUNC( HB_BPEEK )
|
||||
{
|
||||
PHB_ITEM pText = hb_param( 1, HB_IT_STRING );
|
||||
|
||||
if( pText && HB_ISNUM( 2 ) )
|
||||
{
|
||||
HB_SIZE nPos = hb_parns( 2 );
|
||||
|
||||
hb_retni( ( nPos > 0 && nPos <= hb_itemGetCLen( pText ) ) ?
|
||||
( HB_UCHAR ) hb_itemGetCPtr( pText )[ nPos - 1 ] : 0 );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 1111, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
/* HB_UPOKE( [@]<cText>, <n>, <nVal> ) -> <cText>
|
||||
* change <n>-th character in given string to unicode <nVal> one and return modified text
|
||||
*/
|
||||
HB_FUNC( HB_UPOKE )
|
||||
{
|
||||
PHB_ITEM pText = hb_param( 1, HB_IT_STRING );
|
||||
|
||||
if( pText && HB_ISNUM( 2 ) && HB_ISNUM( 3 ) )
|
||||
{
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
const char * szText = hb_itemGetCPtr( pText );
|
||||
HB_SIZE nLen = hb_itemGetCLen( pText );
|
||||
HB_SIZE nPos = hb_parns( 2 );
|
||||
|
||||
if( nPos > 0 && nPos <= nLen )
|
||||
{
|
||||
nPos = hb_cdpTextPos( cdp, szText, nLen, nPos - 1 );
|
||||
if( nPos < nLen )
|
||||
{
|
||||
char szChar[ HB_MAX_CHAR_LEN ], * pszText;
|
||||
HB_SIZE nChar, nOldChar;
|
||||
|
||||
nChar = hb_cdpTextPutU16( cdp, szChar, sizeof( szChar ),
|
||||
( HB_WCHAR ) hb_parni( 3 ) );
|
||||
nOldChar = hb_cdpTextPos( cdp, szText + nPos, nLen - nPos, 1 );
|
||||
if( nChar == nOldChar )
|
||||
{
|
||||
if( hb_itemGetWriteCL( pText, &pszText, &nLen ) &&
|
||||
nPos + nChar <= nLen )
|
||||
memcpy( pszText + nPos, szChar, nChar );
|
||||
}
|
||||
else
|
||||
{
|
||||
pszText = ( char * ) hb_xgrab( nLen - nOldChar + nChar + 1 );
|
||||
|
||||
memcpy( pszText, szText, nPos );
|
||||
memcpy( pszText + nPos, szChar, nChar );
|
||||
memcpy( pszText + nPos + nChar, szText + nPos + nOldChar,
|
||||
nLen - nPos - nOldChar );
|
||||
if( HB_ISBYREF( 1 ) )
|
||||
hb_storclen( pszText, nLen - nOldChar + nChar, 1 );
|
||||
hb_retclen_buffer( pszText, nLen - nOldChar + nChar );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
hb_itemReturn( pText );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 1111, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
/* HB_BPOKE( [@]<cText>, <n>, <nVal> ) -> <cText>
|
||||
* change <n>-th byte in given string to <nVal> and return modified text
|
||||
*/
|
||||
HB_FUNC( HB_BPOKE )
|
||||
{
|
||||
PHB_ITEM pText = hb_param( 1, HB_IT_STRING );
|
||||
|
||||
if( pText && HB_ISNUM( 2 ) && HB_ISNUM( 3 ) )
|
||||
{
|
||||
HB_SIZE nPos = hb_parns( 2 ), nLen;
|
||||
char * pszText;
|
||||
|
||||
if( nPos > 0 && hb_itemGetWriteCL( pText, &pszText, &nLen ) &&
|
||||
nPos <= nLen )
|
||||
{
|
||||
pszText[ nPos - 1 ] = ( char ) ( hb_parni( 3 ) & 0xff );
|
||||
}
|
||||
hb_itemReturn( pText );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 1111, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
@@ -70,6 +70,7 @@
|
||||
*/
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapicdp.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapifs.h"
|
||||
#include "hbapierr.h"
|
||||
@@ -645,21 +646,29 @@ HB_FUNC( HB_DISPOUTAT )
|
||||
so we can use it to draw graphical elements. */
|
||||
HB_FUNC( HB_DISPOUTATBOX )
|
||||
{
|
||||
int iRow = hb_parni( 1 );
|
||||
int iCol = hb_parni( 2 );
|
||||
const char * pszString = hb_parcx( 3 );
|
||||
HB_SIZE nStringLen = hb_parclen( 3 );
|
||||
int iColor;
|
||||
const char * pszString = hb_parc( 3 );
|
||||
|
||||
if( HB_ISCHAR( 4 ) )
|
||||
iColor = hb_gtColorToN( hb_parc( 4 ) );
|
||||
else if( HB_ISNUM( 4 ) )
|
||||
iColor = hb_parni( 4 );
|
||||
else
|
||||
iColor = hb_gtGetCurrColor();
|
||||
if( pszString )
|
||||
{
|
||||
PHB_CODEPAGE cdp;
|
||||
HB_SIZE nLen = hb_parclen( 3 ), nIndex = 0;
|
||||
HB_WCHAR wc;
|
||||
int iRow = hb_parni( 1 );
|
||||
int iCol = hb_parni( 2 );
|
||||
int iColor;
|
||||
|
||||
while( nStringLen-- )
|
||||
hb_gtPutChar( iRow, iCol++, iColor, HB_GT_ATTR_BOX, ( unsigned char ) *pszString++ );
|
||||
if( HB_ISCHAR( 4 ) )
|
||||
iColor = hb_gtColorToN( hb_parc( 4 ) );
|
||||
else if( HB_ISNUM( 4 ) )
|
||||
iColor = hb_parni( 4 );
|
||||
else
|
||||
iColor = hb_gtGetCurrColor();
|
||||
|
||||
cdp = hb_gtBoxCP();
|
||||
|
||||
while( HB_CDPCHAR_GET( cdp, pszString, nLen, &nIndex, &wc ) )
|
||||
hb_gtPutChar( iRow, iCol++, iColor, HB_GT_ATTR_BOX, wc );
|
||||
}
|
||||
}
|
||||
|
||||
HB_FUNC( HB_GETSTDIN ) /* Return handle for STDIN */
|
||||
|
||||
@@ -132,31 +132,20 @@ HB_FUNC( DIRECTORY )
|
||||
|
||||
if( szDirSpec && *szDirSpec )
|
||||
{
|
||||
szDirSpec = hb_fsNameConv( szDirSpec, &pszFree );
|
||||
if( ulMask != HB_FA_LABEL )
|
||||
{
|
||||
if( *szDirSpec )
|
||||
{
|
||||
/* CA-Cl*pper compatible behavior - add all file mask when
|
||||
* last character is directory or drive separator
|
||||
*/
|
||||
HB_SIZE nLen = strlen( szDirSpec ) - 1;
|
||||
/* CA-Cl*pper compatible behavior - add all file mask when
|
||||
* last character is directory or drive separator
|
||||
*/
|
||||
HB_SIZE nLen = strlen( szDirSpec ) - 1;
|
||||
#ifdef HB_OS_HAS_DRIVE_LETTER
|
||||
if( szDirSpec[ nLen ] == HB_OS_PATH_DELIM_CHR ||
|
||||
szDirSpec[ nLen ] == HB_OS_DRIVE_DELIM_CHR )
|
||||
if( szDirSpec[ nLen ] == HB_OS_PATH_DELIM_CHR ||
|
||||
szDirSpec[ nLen ] == HB_OS_DRIVE_DELIM_CHR )
|
||||
#else
|
||||
if( szDirSpec[ nLen ] == HB_OS_PATH_DELIM_CHR )
|
||||
if( szDirSpec[ nLen ] == HB_OS_PATH_DELIM_CHR )
|
||||
#endif
|
||||
{
|
||||
char * pszTemp = hb_xstrcpy( NULL, szDirSpec, HB_OS_ALLFILE_MASK, NULL );
|
||||
|
||||
if( pszFree )
|
||||
hb_xfree( pszFree );
|
||||
szDirSpec = pszFree = pszTemp;
|
||||
}
|
||||
}
|
||||
else
|
||||
szDirSpec = HB_OS_ALLFILE_MASK;
|
||||
szDirSpec = pszFree =
|
||||
hb_xstrcpy( NULL, szDirSpec, HB_OS_ALLFILE_MASK, NULL );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -56,23 +56,15 @@
|
||||
HB_BOOL hb_fsFile( const char * pszFilename )
|
||||
{
|
||||
PHB_FFIND ffind;
|
||||
char * pszFree;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_fsFile(%s)", pszFilename));
|
||||
|
||||
pszFilename = hb_fsNameConv( pszFilename, &pszFree );
|
||||
|
||||
if( ( ffind = hb_fsFindFirst( pszFilename, HB_FA_ALL ) ) != NULL )
|
||||
{
|
||||
hb_fsFindClose( ffind );
|
||||
if( pszFree )
|
||||
hb_xfree( pszFree );
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
if( pszFree )
|
||||
hb_xfree( pszFree );
|
||||
|
||||
return HB_FALSE;
|
||||
}
|
||||
|
||||
@@ -85,26 +77,26 @@ HB_BOOL hb_fsIsDirectory( const char * pszFilename )
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_fsIsDirectory(%s)", pszFilename));
|
||||
|
||||
pszFilename = hb_fsNameConv( pszFilename, &pszFree );
|
||||
|
||||
iLen = ( int ) strlen( pszFilename );
|
||||
while( iLen && strchr( HB_OS_PATH_DELIM_CHR_LIST, pszFilename[ iLen - 1 ] ) )
|
||||
--iLen;
|
||||
|
||||
if( pszFilename[ iLen ] )
|
||||
{
|
||||
if( pszFree )
|
||||
pszFree[ iLen ] = '\0';
|
||||
else
|
||||
pszFilename = pszFree = hb_strndup( pszFilename, iLen );
|
||||
}
|
||||
pszFilename = pszFree = hb_strndup( pszFilename, iLen );
|
||||
|
||||
if( iLen && iLen <= ( HB_PATH_MAX - 1 ) )
|
||||
{
|
||||
if( ( ffind = hb_fsFindFirst( pszFilename, HB_FA_DIRECTORY ) ) != NULL )
|
||||
{
|
||||
if( ( ffind->attr & HB_FA_DIRECTORY ) == HB_FA_DIRECTORY )
|
||||
bResult = HB_TRUE;
|
||||
do
|
||||
{
|
||||
if( ( ffind->attr & HB_FA_DIRECTORY ) == HB_FA_DIRECTORY )
|
||||
{
|
||||
bResult = HB_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while( hb_fsFindNext( ffind ) );
|
||||
hb_fsFindClose( ffind );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3239,15 +3239,12 @@ HB_ERRCODE hb_fsCurDirBuff( int iDrive, char * pszBuffer, HB_SIZE nSize )
|
||||
#if defined( HB_OS_WIN )
|
||||
{
|
||||
DWORD dwSize = ( DWORD ) nSize;
|
||||
#if defined( UNICODE )
|
||||
LPTSTR lpBuffer = ( LPTSTR ) hb_xgrab( dwSize * sizeof( TCHAR ) );
|
||||
lpBuffer[ 0 ] = L'\0';
|
||||
hb_fsSetIOError( ( GetCurrentDirectory( dwSize, lpBuffer ) != 0 ), 0 );
|
||||
lpBuffer[ dwSize - 1 ] = L'\0';
|
||||
hb_wcntombcpy( pszBuffer, lpBuffer, dwSize - 1 );
|
||||
HB_OSSTRDUP2( lpBuffer, pszBuffer, nSize - 1 );
|
||||
hb_xfree( lpBuffer );
|
||||
#else
|
||||
hb_fsSetIOError( ( GetCurrentDirectory( dwSize, pszBuffer ) != 0 ), 0 );
|
||||
#endif
|
||||
}
|
||||
#elif defined( HB_OS_OS2 )
|
||||
|
||||
@@ -3323,6 +3320,7 @@ HB_ERRCODE hb_fsCurDirBuff( int iDrive, char * pszBuffer, HB_SIZE nSize )
|
||||
|
||||
pszBuffer[ nLen ] = '\0';
|
||||
|
||||
#if !defined( HB_OS_WIN )
|
||||
/* Convert from OS codepage */
|
||||
{
|
||||
char * pszFree = NULL;
|
||||
@@ -3336,6 +3334,7 @@ HB_ERRCODE hb_fsCurDirBuff( int iDrive, char * pszBuffer, HB_SIZE nSize )
|
||||
if( pszFree )
|
||||
hb_xfree( pszFree );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return nResult;
|
||||
@@ -3745,7 +3744,7 @@ const char * hb_fsNameConv( const char * szFileName, char ** pszFree )
|
||||
if( pszFree )
|
||||
*pszFree = NULL;
|
||||
|
||||
if( !hb_stackId() )
|
||||
if( hb_vmIsReady() )
|
||||
return szFileName;
|
||||
|
||||
fTrim = hb_setGetTrimFileName();
|
||||
@@ -3886,7 +3885,7 @@ HB_WCHAR * hb_fsNameConvU16( const char * szFileName )
|
||||
TRIMFILENAME - strip trailing and leading spaces (also from extension)
|
||||
*/
|
||||
|
||||
if( !hb_stackId() )
|
||||
if( hb_vmIsReady() )
|
||||
return hb_mbtowc( szFileName ); /* No HVM stack */
|
||||
|
||||
cdp = hb_vmCDP();
|
||||
@@ -3994,27 +3993,19 @@ HB_WCHAR * hb_fsNameConvU16( const char * szFileName )
|
||||
/* NOTE: pszBuffer must be HB_PATH_MAX long. */
|
||||
void hb_fsBaseDirBuff( char * pszBuffer )
|
||||
{
|
||||
const char * szBaseName = hb_cmdargARGVN( 0 );
|
||||
char * pszBaseName = hb_cmdargProgName();
|
||||
|
||||
if( szBaseName )
|
||||
if( pszBaseName )
|
||||
{
|
||||
PHB_FNAME pFName = hb_fsFNameSplit( szBaseName );
|
||||
const char * pszResult;
|
||||
char * pszFree = NULL;
|
||||
HB_SIZE nSize = HB_PATH_MAX;
|
||||
|
||||
pFName->szName = NULL;
|
||||
pFName->szExtension = NULL;
|
||||
hb_fsFNameMerge( pszBuffer, pFName );
|
||||
hb_xfree( pFName );
|
||||
|
||||
/* Convert from OS codepage */
|
||||
pszResult = hb_osDecodeCP( pszBuffer, &pszFree, &nSize );
|
||||
if( pszResult != pszBuffer )
|
||||
hb_strncpy( pszBuffer, pszResult, HB_PATH_MAX - 1 );
|
||||
if( pszFree )
|
||||
hb_xfree( pszFree );
|
||||
PHB_FNAME pFileName = hb_fsFNameSplit( pszBaseName );
|
||||
pFileName->szName = NULL;
|
||||
pFileName->szExtension = NULL;
|
||||
hb_fsFNameMerge( pszBuffer, pFileName );
|
||||
hb_xfree( pFileName );
|
||||
hb_xfree( pszBaseName );
|
||||
}
|
||||
else
|
||||
pszBuffer[ 0 ] = '\0';
|
||||
}
|
||||
|
||||
static HB_BOOL hb_fsDisableWaitLocks( int iSet )
|
||||
|
||||
@@ -237,7 +237,7 @@ HB_BOOL hb_fsLinkSym( const char * pszTarget, const char * pszNewFile )
|
||||
/* NOTE: Caller must free the pointer, if not NULL */
|
||||
char * hb_fsLinkRead( const char * pszFile )
|
||||
{
|
||||
char * pszLink;
|
||||
char * pszLink = NULL;
|
||||
|
||||
if( pszFile )
|
||||
{
|
||||
@@ -302,7 +302,6 @@ char * hb_fsLinkRead( const char * pszFile )
|
||||
{
|
||||
hb_fsSetIOError( HB_FALSE, 0 );
|
||||
hb_fsSetFError( hb_fsError() );
|
||||
pszLink = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -313,30 +312,22 @@ char * hb_fsLinkRead( const char * pszFile )
|
||||
{
|
||||
if( size > 0 )
|
||||
{
|
||||
pszLink = ( char * ) hb_xgrab( size + 1 );
|
||||
HB_TCHAR_COPYFROM( pszLink, lpLink, ( HB_SIZE ) size );
|
||||
lpLink[ size ] = TEXT( '\0' );
|
||||
pszLink = HB_OSSTRDUP( lpLink );
|
||||
}
|
||||
else
|
||||
pszLink = NULL;
|
||||
|
||||
hb_fsSetIOError( HB_TRUE, 0 );
|
||||
hb_fsSetFError( hb_fsError() );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_fsSetFError( 1 );
|
||||
pszLink = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if( lpFileNameFree )
|
||||
hb_xfree( lpFileNameFree );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_fsSetFError( 1 );
|
||||
pszLink = NULL;
|
||||
}
|
||||
}
|
||||
#elif defined( HB_OS_UNIX )
|
||||
{
|
||||
@@ -355,7 +346,11 @@ char * hb_fsLinkRead( const char * pszFile )
|
||||
pszLink = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pszLink[ size ] = '\0';
|
||||
/* Convert from OS codepage */
|
||||
pszLink = ( char * ) hb_osDecodeCP( pszLink, NULL, NULL );
|
||||
}
|
||||
|
||||
if( pszFileFree )
|
||||
hb_xfree( pszFileFree );
|
||||
@@ -363,21 +358,13 @@ char * hb_fsLinkRead( const char * pszFile )
|
||||
#else
|
||||
{
|
||||
hb_fsSetFError( 1 );
|
||||
pszLink = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
hb_vmLock();
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_fsSetFError( 2 );
|
||||
pszLink = NULL;
|
||||
}
|
||||
|
||||
/* Convert from OS codepage */
|
||||
if( pszLink )
|
||||
pszLink = ( char * ) hb_osDecodeCP( pszLink, NULL, NULL );
|
||||
|
||||
return pszLink;
|
||||
}
|
||||
|
||||
@@ -83,12 +83,7 @@ HB_FOFFSET hb_fsFSize( const char * pszFileName, HB_BOOL bUseDirEntry )
|
||||
if( bUseDirEntry )
|
||||
{
|
||||
#if defined( HB_OS_WIN )
|
||||
char * pszFree;
|
||||
PHB_FFIND ffind;
|
||||
pszFileName = hb_fsNameConv( pszFileName, &pszFree );
|
||||
ffind = hb_fsFindFirst( pszFileName, HB_FA_ALL );
|
||||
if( pszFree )
|
||||
hb_xfree( pszFree );
|
||||
PHB_FFIND ffind = hb_fsFindFirst( pszFileName, HB_FA_ALL );
|
||||
hb_fsSetIOError( ffind != NULL, 0 );
|
||||
if( ffind )
|
||||
{
|
||||
|
||||
@@ -99,28 +99,31 @@
|
||||
#endif
|
||||
|
||||
#if !defined( HB_OS_WIN )
|
||||
static HB_BOOL fsGetTempDirByCase( char * pszName, const char * pszTempDir )
|
||||
static HB_BOOL fsGetTempDirByCase( char * pszName, const char * pszTempDir, HB_BOOL fTrans )
|
||||
{
|
||||
HB_BOOL fOK = HB_FALSE;
|
||||
char * pTmp;
|
||||
|
||||
if( pszTempDir && *pszTempDir != '\0' )
|
||||
{
|
||||
if( fTrans )
|
||||
hb_osStrDecode2( pszTempDir, pszName, HB_PATH_MAX - 1 );
|
||||
else
|
||||
hb_strncpy( pszName, pszTempDir, HB_PATH_MAX - 1 );
|
||||
|
||||
switch( hb_setGetDirCase() )
|
||||
{
|
||||
case HB_SET_CASE_LOWER:
|
||||
hb_cdpnDup2Lower( hb_vmCDP(), pszTempDir, strlen( pszTempDir ),
|
||||
pszName, HB_PATH_MAX );
|
||||
pszName[ HB_PATH_MAX - 1 ] = '\0';
|
||||
fOK = strcmp( pszName, pszTempDir ) == 0;
|
||||
pTmp = hb_cdpnDupLower( hb_vmCDP(), pszName, NULL );
|
||||
fOK = strcmp( pszName, pTmp ) == 0;
|
||||
hb_xfree( pTmp );
|
||||
break;
|
||||
case HB_SET_CASE_UPPER:
|
||||
hb_cdpnDup2Upper( hb_vmCDP(), pszTempDir, strlen( pszTempDir ),
|
||||
pszName, HB_PATH_MAX );
|
||||
pszName[ HB_PATH_MAX - 1 ] = '\0';
|
||||
fOK = strcmp( pszName, pszTempDir ) == 0;
|
||||
pTmp = hb_cdpnDupUpper( hb_vmCDP(), pszName, NULL );
|
||||
fOK = strcmp( pszName, pTmp ) == 0;
|
||||
hb_xfree( pTmp );
|
||||
break;
|
||||
default:
|
||||
hb_strncpy( pszName, pszTempDir, HB_PATH_MAX - 1 );
|
||||
fOK = HB_TRUE;
|
||||
break;
|
||||
}
|
||||
@@ -273,7 +276,7 @@ static HB_BOOL hb_fsTempName( char * pszBuffer, const char * pszDir, const char
|
||||
fResult = GetTempFileName( lpDir, lpPrefix ? lpPrefix : TEXT( "hb" ), 0, lpBuffer );
|
||||
|
||||
if( fResult )
|
||||
HB_TCHAR_COPYFROM( pszBuffer, lpBuffer, HB_PATH_MAX - 1 );
|
||||
HB_OSSTRDUP2( lpBuffer, pszBuffer, HB_PATH_MAX - 1 );
|
||||
|
||||
if( lpPrefixFree )
|
||||
hb_xfree( lpPrefixFree );
|
||||
@@ -281,46 +284,34 @@ static HB_BOOL hb_fsTempName( char * pszBuffer, const char * pszDir, const char
|
||||
hb_xfree( lpDirFree );
|
||||
}
|
||||
#else
|
||||
|
||||
/* TODO: Implement these: */
|
||||
HB_SYMBOL_UNUSED( pszDir );
|
||||
HB_SYMBOL_UNUSED( pszPrefix );
|
||||
|
||||
/* TOFIX: The spec says to reserve L_tmpnam number of characters for the
|
||||
passed buffer. It will be needed to fix HB_PATH_MAX - 1 to be
|
||||
at least this large. */
|
||||
|
||||
fResult = ( tmpnam( pszBuffer ) != NULL );
|
||||
|
||||
# if defined( __DJGPP__ )
|
||||
{
|
||||
/* convert '/' to '\' */
|
||||
char * pszDelim;
|
||||
while( ( pszDelim = strchr( pszBuffer, '/' ) ) != NULL )
|
||||
*pszDelim = '\\';
|
||||
}
|
||||
# endif
|
||||
char * pTmpBuffer = hb_xgrab( L_tmpnam + 1 );
|
||||
|
||||
/* TODO: Implement these: */
|
||||
HB_SYMBOL_UNUSED( pszDir );
|
||||
HB_SYMBOL_UNUSED( pszPrefix );
|
||||
|
||||
pTmpBuffer[ 0 ] = '\0';
|
||||
fResult = ( tmpnam( pszBuffer ) != NULL );
|
||||
pTmpBuffer[ L_tmpnam ] = '\0';
|
||||
|
||||
if( fResult )
|
||||
{
|
||||
# if defined( __DJGPP__ )
|
||||
/* convert '/' to '\' */
|
||||
char * pszDelim;
|
||||
while( ( pszDelim = strchr( pTmpBuffer, '/' ) ) != NULL )
|
||||
*pszDelim = '\\';
|
||||
# endif
|
||||
hb_osStrDecode2( pTmpBuffer, pszBuffer, HB_PATH_MAX - 1 );
|
||||
}
|
||||
hb_xfree( pTmpBuffer );
|
||||
}
|
||||
#endif
|
||||
|
||||
hb_fsSetIOError( fResult, 0 );
|
||||
hb_vmLock();
|
||||
|
||||
/* Convert from OS codepage */
|
||||
if( fResult )
|
||||
{
|
||||
char * pszFree = NULL;
|
||||
const char * pszResult;
|
||||
HB_SIZE nLen = strlen( pszBuffer );
|
||||
|
||||
pszResult = hb_osDecodeCP( pszBuffer, &pszFree, &nLen );
|
||||
|
||||
if( pszResult != pszBuffer )
|
||||
hb_strncpy( pszBuffer, pszResult, HB_PATH_MAX - 1 );
|
||||
if( pszFree )
|
||||
hb_xfree( pszFree );
|
||||
}
|
||||
|
||||
return fResult;
|
||||
}
|
||||
|
||||
@@ -379,10 +370,10 @@ HB_ERRCODE hb_fsTempDir( char * pszTempDir )
|
||||
{
|
||||
char * pszTempDirEnv = hb_getenv( "TMPDIR" );
|
||||
|
||||
if( ! fsGetTempDirByCase( pszTempDir, pszTempDirEnv ) )
|
||||
if( ! fsGetTempDirByCase( pszTempDir, pszTempDirEnv, HB_FALSE ) )
|
||||
{
|
||||
#ifdef P_tmpdir
|
||||
if( ! fsGetTempDirByCase( pszTempDir, P_tmpdir ) )
|
||||
if( ! fsGetTempDirByCase( pszTempDir, P_tmpdir, HB_TRUE ) )
|
||||
#endif
|
||||
{
|
||||
pszTempDir[ 0 ] = '.';
|
||||
@@ -422,7 +413,7 @@ HB_ERRCODE hb_fsTempDir( char * pszTempDir )
|
||||
{
|
||||
nResult = 0;
|
||||
lpDir[ HB_PATH_MAX - 1 ] = TEXT( '\0' );
|
||||
HB_TCHAR_COPYFROM( pszTempDir, lpDir, HB_PATH_MAX - 1 );
|
||||
HB_OSSTRDUP2( lpDir, pszTempDir, HB_PATH_MAX - 1 );
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -433,7 +424,7 @@ HB_ERRCODE hb_fsTempDir( char * pszTempDir )
|
||||
if( tmpnam( szBuffer ) != NULL )
|
||||
{
|
||||
PHB_FNAME pTempName = hb_fsFNameSplit( szBuffer );
|
||||
if( fsGetTempDirByCase( pszTempDir, pTempName->szPath ) )
|
||||
if( fsGetTempDirByCase( pszTempDir, pTempName->szPath, HB_TRUE ) )
|
||||
nResult = 0;
|
||||
hb_xfree( pTempName );
|
||||
}
|
||||
@@ -450,7 +441,7 @@ HB_ERRCODE hb_fsTempDir( char * pszTempDir )
|
||||
|
||||
if( pszTempDirEnv )
|
||||
{
|
||||
if( fsGetTempDirByCase( pszTempDir, pszTempDirEnv ) )
|
||||
if( fsGetTempDirByCase( pszTempDir, pszTempDirEnv, HB_FALSE ) )
|
||||
nResult = 0;
|
||||
hb_xfree( pszTempDirEnv );
|
||||
}
|
||||
@@ -474,20 +465,6 @@ HB_ERRCODE hb_fsTempDir( char * pszTempDir )
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Convert from OS codepage */
|
||||
{
|
||||
char * pszFree = NULL;
|
||||
const char * pszResult;
|
||||
HB_SIZE nLen = strlen( pszTempDir );
|
||||
|
||||
pszResult = hb_osDecodeCP( pszTempDir, &pszFree, &nLen );
|
||||
|
||||
if( pszResult != pszTempDir )
|
||||
hb_strncpy( pszTempDir, pszResult, HB_PATH_MAX - 1 );
|
||||
if( pszFree )
|
||||
hb_xfree( pszFree );
|
||||
}
|
||||
|
||||
return nResult;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,37 +77,23 @@ HB_FUNC( GETENV )
|
||||
if( pName && hb_pcount() == 1 )
|
||||
{
|
||||
#ifdef _HB_GETENV_REQUIRES_UPPERCASE
|
||||
char * pszName = hb_itemGetC( pName );
|
||||
char * pszName = hb_cdpnDupUpper( hb_vmCDP(),
|
||||
hb_itemGetCPtr( pName ), NULL );
|
||||
#else
|
||||
const char * pszName = hb_itemGetCPtr( pName );
|
||||
#endif
|
||||
char * pszValue = NULL;
|
||||
|
||||
if( pszName[ 0 ] != '\0' )
|
||||
{
|
||||
char * szValue;
|
||||
pszValue = hb_getenv( pszName );
|
||||
|
||||
#ifdef _HB_GETENV_REQUIRES_UPPERCASE
|
||||
hb_strupr( pszName );
|
||||
#endif
|
||||
szValue = hb_getenv( pszName );
|
||||
if( szValue && szValue[ 0 ] != '\0' )
|
||||
{
|
||||
/* Convert from OS codepage */
|
||||
hb_retc_buffer( ( char * ) hb_osDecodeCP( szValue, NULL, NULL ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( szValue )
|
||||
hb_xfree( szValue );
|
||||
|
||||
hb_retc_null();
|
||||
}
|
||||
}
|
||||
if( pszValue )
|
||||
hb_retc_buffer( pszValue );
|
||||
else
|
||||
hb_retc_null();
|
||||
|
||||
#ifdef _HB_GETENV_REQUIRES_UPPERCASE
|
||||
hb_itemFreeC( pszName );
|
||||
hb_xfree( pszName );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@@ -137,41 +123,27 @@ HB_FUNC( HB_GETENV )
|
||||
if( pName )
|
||||
{
|
||||
#ifdef _HB_GETENV_REQUIRES_UPPERCASE
|
||||
char * pszName = hb_itemGetC( pName );
|
||||
char * pszName = hb_cdpnDupUpper( hb_vmCDP(),
|
||||
hb_itemGetCPtr( pName ), NULL );
|
||||
#else
|
||||
const char * pszName = hb_itemGetCPtr( pName );
|
||||
#endif
|
||||
char * pszValue = NULL;
|
||||
|
||||
if( pszName[ 0 ] != '\0' )
|
||||
{
|
||||
char * szValue;
|
||||
pszValue = hb_getenv( pszName );
|
||||
|
||||
#ifdef _HB_GETENV_REQUIRES_UPPERCASE
|
||||
hb_strupr( pszName );
|
||||
#endif
|
||||
szValue = hb_getenv( pszName );
|
||||
if( szValue && szValue[ 0 ] != '\0' )
|
||||
{
|
||||
if( hb_parldef( 3, 1 ) )
|
||||
szValue = ( char * ) hb_osDecodeCP( szValue, NULL, NULL );
|
||||
hb_retc_buffer( szValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( szValue )
|
||||
hb_xfree( szValue );
|
||||
hb_retc( hb_parc( 2 ) );
|
||||
}
|
||||
}
|
||||
if( pszValue )
|
||||
hb_retc_buffer( pszValue );
|
||||
else
|
||||
hb_retc_null();
|
||||
hb_retc( hb_parc( 2 ) );
|
||||
|
||||
#ifdef _HB_GETENV_REQUIRES_UPPERCASE
|
||||
hb_itemFreeC( pszName );
|
||||
hb_xfree( pszName );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
hb_retc_null();
|
||||
hb_retc( hb_parc( 2 ) );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_SETENV )
|
||||
@@ -180,24 +152,7 @@ HB_FUNC( HB_SETENV )
|
||||
HB_BOOL fResult = HB_FALSE;
|
||||
|
||||
if( pszName )
|
||||
{
|
||||
const char * pszValue = hb_parc( 2 );
|
||||
char * pszFreeName = NULL, * pszFreeVal = NULL;
|
||||
|
||||
if( hb_parldef( 3, 1 ) )
|
||||
{
|
||||
pszName = hb_osEncodeCP( pszName, &pszFreeName, NULL );
|
||||
if( pszValue )
|
||||
pszValue = hb_osEncodeCP( pszValue, &pszFreeVal, NULL );
|
||||
}
|
||||
|
||||
fResult = hb_setenv( pszName, pszValue );
|
||||
|
||||
if( pszFreeName )
|
||||
hb_xfree( pszFreeName );
|
||||
if( pszFreeVal )
|
||||
hb_xfree( pszFreeVal );
|
||||
}
|
||||
fResult = hb_setenv( pszName, hb_parc( 2 ) );
|
||||
|
||||
hb_retl( fResult );
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ HB_ERRCODE hb_gtBoxD( int iTop, int iLeft, int iBottom, int iRight )
|
||||
pGT = hb_gt_Base();
|
||||
if( pGT )
|
||||
{
|
||||
HB_GTSELF_BOXD( pGT, iTop, iLeft, iBottom, iRight, _B_DOUBLE, HB_GTSELF_GETCOLOR( pGT ) );
|
||||
HB_GTSELF_BOXD( pGT, iTop, iLeft, iBottom, iRight, NULL, HB_GTSELF_GETCOLOR( pGT ) );
|
||||
HB_GTSELF_SETPOS( pGT, iTop + 1, iLeft + 1 );
|
||||
HB_GTSELF_FLUSH( pGT );
|
||||
hb_gt_BaseFree( pGT );
|
||||
@@ -210,7 +210,7 @@ HB_ERRCODE hb_gtBoxS( int iTop, int iLeft, int iBottom, int iRight )
|
||||
pGT = hb_gt_Base();
|
||||
if( pGT )
|
||||
{
|
||||
HB_GTSELF_BOXS( pGT, iTop, iLeft, iBottom, iRight, _B_SINGLE, HB_GTSELF_GETCOLOR( pGT ) );
|
||||
HB_GTSELF_BOXS( pGT, iTop, iLeft, iBottom, iRight, NULL, HB_GTSELF_GETCOLOR( pGT ) );
|
||||
HB_GTSELF_SETPOS( pGT, iTop + 1, iLeft + 1 );
|
||||
HB_GTSELF_FLUSH( pGT );
|
||||
hb_gt_BaseFree( pGT );
|
||||
@@ -1033,6 +1033,38 @@ HB_ERRCODE hb_gtSetKeyCP( const char * pszTermCDP, const char * pszHostCDP )
|
||||
return errCode;
|
||||
}
|
||||
|
||||
PHB_CODEPAGE hb_gtHostCP( void )
|
||||
{
|
||||
PHB_CODEPAGE cdp = NULL;
|
||||
PHB_GT pGT;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gtHostCP()"));
|
||||
|
||||
pGT = hb_gt_Base();
|
||||
if( pGT )
|
||||
{
|
||||
cdp = HB_GTSELF_HOSTCP( pGT );
|
||||
hb_gt_BaseFree( pGT );
|
||||
}
|
||||
return cdp;
|
||||
}
|
||||
|
||||
PHB_CODEPAGE hb_gtBoxCP( void )
|
||||
{
|
||||
PHB_CODEPAGE cdp = NULL;
|
||||
PHB_GT pGT;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gtBoxCP()"));
|
||||
|
||||
pGT = hb_gt_Base();
|
||||
if( pGT )
|
||||
{
|
||||
cdp = HB_GTSELF_BOXCP( pGT );
|
||||
hb_gt_BaseFree( pGT );
|
||||
}
|
||||
return cdp;
|
||||
}
|
||||
|
||||
HB_ERRCODE hb_gtInfo( int iType, PHB_GT_INFO pInfo )
|
||||
{
|
||||
HB_ERRCODE errCode = HB_FAILURE;
|
||||
@@ -1178,7 +1210,7 @@ HB_ERRCODE hb_gtGetScrChar( int iRow, int iCol, int * piColor, HB_BYTE * pbAttr,
|
||||
HB_ERRCODE errCode = HB_FAILURE;
|
||||
PHB_GT pGT;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gtScrGetChar(%d, %d, %p, %p, %p)", iRow, iCol, piColor, pbAttr, pusChar));
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gtGetScrChar(%d, %d, %p, %p, %p)", iRow, iCol, piColor, pbAttr, pusChar));
|
||||
|
||||
pGT = hb_gt_Base();
|
||||
if( pGT )
|
||||
|
||||
@@ -89,13 +89,12 @@ typedef struct _HB_GTCGI
|
||||
int iRow;
|
||||
int iCol;
|
||||
int iLastCol;
|
||||
#ifndef HB_GT_CGI_RAWOUTPUT
|
||||
int iLineBufSize;
|
||||
char * sLineBuf;
|
||||
#endif
|
||||
char * szCrLf;
|
||||
HB_SIZE nCrLf;
|
||||
HB_BOOL fDispTrans;
|
||||
PHB_CODEPAGE cdpTerm;
|
||||
PHB_CODEPAGE cdpHost;
|
||||
} HB_GTCGI, * PHB_GTCGI;
|
||||
|
||||
static void hb_gt_cgi_termOut( PHB_GTCGI pGTCGI, const char * szStr, HB_SIZE nLen )
|
||||
@@ -147,8 +146,10 @@ static void hb_gt_cgi_Exit( PHB_GT pGT )
|
||||
if( pGTCGI->iLastCol > 0 )
|
||||
hb_gt_cgi_newLine( pGTCGI );
|
||||
|
||||
#ifndef HB_GT_CGI_RAWOUTPUT
|
||||
if( pGTCGI->iLineBufSize > 0 )
|
||||
hb_xfree( pGTCGI->sLineBuf );
|
||||
#endif
|
||||
if( pGTCGI->szCrLf )
|
||||
hb_xfree( pGTCGI->szCrLf );
|
||||
hb_xfree( pGTCGI );
|
||||
@@ -225,40 +226,48 @@ static void hb_gt_cgi_Scroll( PHB_GT pGT, int iTop, int iLeft, int iBottom, int
|
||||
HB_GTSUPER_SCROLL( pGT, iTop, iLeft, iBottom, iRight, iColor, usChar, iRows, iCols );
|
||||
}
|
||||
|
||||
static HB_BOOL hb_gt_cgi_SetDispCP( PHB_GT pGT, const char *pszTermCDP, const char *pszHostCDP, HB_BOOL fBox )
|
||||
#ifdef HB_GT_CGI_RAWOUTPUT
|
||||
static void hb_gt_cgi_conPos( PHB_GTCGI pGTCGI, int iRow, int iCol )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_cgi_SetDispCP(%p,%s,%s,%d)", pGT, pszTermCDP, pszHostCDP, (int) fBox ) );
|
||||
int iLineFeed = 0, iSpace = 0;
|
||||
|
||||
HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox );
|
||||
|
||||
if( !pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
if( !pszTermCDP )
|
||||
pszTermCDP = pszHostCDP;
|
||||
|
||||
if( pszTermCDP && pszHostCDP )
|
||||
if( pGTCGI->iRow != iRow )
|
||||
{
|
||||
PHB_GTCGI pGTCGI = HB_GTCGI_GET( pGT );
|
||||
|
||||
pGTCGI->cdpTerm = hb_cdpFindExt( pszTermCDP );
|
||||
pGTCGI->cdpHost = hb_cdpFindExt( pszHostCDP );
|
||||
pGTCGI->fDispTrans = pGTCGI->cdpTerm && pGTCGI->cdpHost &&
|
||||
pGTCGI->cdpTerm != pGTCGI->cdpHost;
|
||||
iLineFeed = pGTCGI->iRow < iRow ? iRow - pGTCGI->iRow : 1;
|
||||
}
|
||||
else if( pGTCGI->iCol > iCol )
|
||||
{
|
||||
iLineFeed = 1;
|
||||
iSpace = iCol;
|
||||
}
|
||||
else if( pGTCGI->iCol < iCol )
|
||||
{
|
||||
iSpace = iCol - pGTCGI->iCol;
|
||||
}
|
||||
|
||||
return HB_TRUE;
|
||||
if( iSpace > 0 )
|
||||
{
|
||||
char * buffer = ( char * ) hb_xgrab( iSpace );
|
||||
memset( buffer, ' ', iSpace );
|
||||
hb_gt_cgi_termOut( pGTCGI, buffer, iSpace );
|
||||
hb_xfree( buffer );
|
||||
}
|
||||
while( --iLineFeed >= 0 )
|
||||
hb_gt_cgi_newLine( pGTCGI );
|
||||
pGTCGI->iRow = iRow;
|
||||
pGTCGI->iCol = iCol;
|
||||
|
||||
}
|
||||
|
||||
#ifdef HB_GT_CGI_RAWOUTPUT
|
||||
static void hb_gt_cgi_WriteCon( PHB_GT pGT, const char * szText, HB_SIZE nLength )
|
||||
static void hb_gt_cgi_conOut( PHB_GT pGT, const char * szText, HB_SIZE nLength,
|
||||
PHB_CODEPAGE cdpHost, PHB_CODEPAGE cdpTerm )
|
||||
{
|
||||
PHB_GTCGI pGTCGI = HB_GTCGI_GET( pGT );
|
||||
|
||||
if( pGTCGI->fDispTrans )
|
||||
if( cdpTerm && cdpHost && cdpTerm != cdpHost )
|
||||
{
|
||||
HB_SIZE nLen = nLength;
|
||||
char * buffer = hb_cdpnDup( szText, &nLen,
|
||||
pGTCGI->cdpHost, pGTCGI->cdpTerm );
|
||||
char * buffer = hb_cdpnDup( szText, &nLen, cdpHost, cdpTerm );
|
||||
hb_gt_cgi_termOut( pGTCGI, buffer, nLen );
|
||||
hb_xfree( buffer );
|
||||
}
|
||||
@@ -292,40 +301,40 @@ static void hb_gt_cgi_WriteCon( PHB_GT pGT, const char * szText, HB_SIZE nLength
|
||||
HB_GTSUPER_SETPOS( pGT, pGTCGI->iRow, pGTCGI->iCol );
|
||||
}
|
||||
|
||||
static void hb_gt_cgi_WriteCon( PHB_GT pGT, const char * szText, HB_SIZE nLength )
|
||||
{
|
||||
hb_gt_cgi_conOut( pGT, szText, nLength, HB_GTSELF_HOSTCP( pGT ), HB_GTSELF_TERMCP( pGT ) );
|
||||
}
|
||||
|
||||
static void hb_gt_cgi_WriteConW( PHB_GT pGT, const HB_WCHAR * szTextW, HB_SIZE nLength )
|
||||
{
|
||||
PHB_CODEPAGE cdpTerm = HB_GTSELF_TERMCP( pGT );
|
||||
HB_SIZE nSize = hb_cdpU16AsStrLen( cdpTerm, szTextW, nLength, 0 );
|
||||
char * buffer = ( char * ) hb_xgrab( nSize );
|
||||
|
||||
hb_cdpU16ToStr( cdpTerm, HB_CDP_ENDIAN_NATIVE, szTextW, nLength, buffer, nSize );
|
||||
hb_gt_cgi_conOut( pGT, buffer, nSize, NULL, NULL );
|
||||
hb_xfree( buffer );
|
||||
}
|
||||
|
||||
static void hb_gt_cgi_WriteAt( PHB_GT pGT, int iRow, int iCol, const char * szText, HB_SIZE nLength )
|
||||
{
|
||||
int iLineFeed = 0, iSpace = 0;
|
||||
PHB_GTCGI pGTCGI = HB_GTCGI_GET( pGT );
|
||||
|
||||
if( pGTCGI->iRow != iRow )
|
||||
{
|
||||
iLineFeed = pGTCGI->iRow < iRow ? iRow - pGTCGI->iRow : 1;
|
||||
}
|
||||
else if( pGTCGI->iCol > iCol )
|
||||
{
|
||||
iLineFeed = 1;
|
||||
iSpace = iCol;
|
||||
}
|
||||
else if( pGTCGI->iCol < iCol )
|
||||
{
|
||||
iSpace = iCol - pGTCGI->iCol;
|
||||
}
|
||||
|
||||
if( iSpace > 0 )
|
||||
{
|
||||
char * buffer = ( char * ) hb_xgrab( iSpace );
|
||||
memset( buffer, ' ', iSpace );
|
||||
hb_gt_cgi_termOut( pGTCGI, buffer, iSpace );
|
||||
hb_xfree( buffer );
|
||||
}
|
||||
while( --iLineFeed >= 0 )
|
||||
hb_gt_cgi_newLine( pGTCGI );
|
||||
pGTCGI->iRow = iRow;
|
||||
pGTCGI->iCol = iCol;
|
||||
|
||||
hb_gt_cgi_conPos( HB_GTCGI_GET( pGT ), iRow, iCol );
|
||||
hb_gt_cgi_WriteCon( pGT, szText, nLength );
|
||||
}
|
||||
|
||||
static void hb_gt_cgi_WriteAtW( PHB_GT pGT, int iRow, int iCol, const HB_WCHAR * szTextW, HB_SIZE nLength )
|
||||
{
|
||||
PHB_CODEPAGE cdpTerm = HB_GTSELF_TERMCP( pGT );
|
||||
HB_SIZE nSize = hb_cdpU16AsStrLen( cdpTerm, szTextW, nLength, 0 );
|
||||
char * buffer = ( char * ) hb_xgrab( nSize );
|
||||
|
||||
hb_cdpU16ToStr( cdpTerm, HB_CDP_ENDIAN_NATIVE, szTextW, nLength, buffer, nSize );
|
||||
hb_gt_cgi_conPos( HB_GTCGI_GET( pGT ), iRow, iCol );
|
||||
hb_gt_cgi_conOut( pGT, buffer, nSize, NULL, NULL );
|
||||
hb_xfree( buffer );
|
||||
}
|
||||
|
||||
#else /* HB_GT_CGI_RAWOUTPUT */
|
||||
|
||||
static void hb_gt_cgi_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
@@ -370,6 +379,9 @@ static void hb_gt_cgi_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
|
||||
if( iSize > 0 )
|
||||
{
|
||||
PHB_CODEPAGE cdpTerm = HB_GTSELF_TERMCP( pGT );
|
||||
int iIndex = 0;
|
||||
|
||||
while( --iLineFeed >= 0 )
|
||||
hb_gt_cgi_newLine( pGTCGI );
|
||||
pGTCGI->iRow = iRow;
|
||||
@@ -378,22 +390,14 @@ static void hb_gt_cgi_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
{
|
||||
if( !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol, &iColor, &bAttr, &usChar ) )
|
||||
break;
|
||||
pGTCGI->sLineBuf[ iLen++ ] = ( char ) usChar;
|
||||
iIndex += ( int ) hb_cdpTextPutU16( cdpTerm, pGTCGI->sLineBuf + iIndex,
|
||||
pGTCGI->iLineBufSize - iIndex, usChar );
|
||||
++iLen;
|
||||
++iCol;
|
||||
}
|
||||
if( iLen )
|
||||
if( iIndex )
|
||||
{
|
||||
if( pGTCGI->fDispTrans )
|
||||
{
|
||||
HB_SIZE nLen = iLen;
|
||||
char * buffer = hb_cdpnDup( pGTCGI->sLineBuf, &nLen,
|
||||
pGTCGI->cdpHost, pGTCGI->cdpTerm );
|
||||
hb_gt_cgi_termOut( pGTCGI, buffer, nLen );
|
||||
hb_xfree( buffer );
|
||||
}
|
||||
else
|
||||
hb_gt_cgi_termOut( pGTCGI, pGTCGI->sLineBuf, iLen );
|
||||
|
||||
hb_gt_cgi_termOut( pGTCGI, pGTCGI->sLineBuf, iIndex );
|
||||
pGTCGI->iCol = iCol;
|
||||
if( pGTCGI->iCol > pGTCGI->iLastCol )
|
||||
pGTCGI->iLastCol = pGTCGI->iCol;
|
||||
@@ -410,12 +414,8 @@ static void hb_gt_cgi_Refresh( PHB_GT pGT )
|
||||
|
||||
pGTCGI = HB_GTCGI_GET( pGT );
|
||||
HB_GTSELF_GETSIZE( pGT, &iHeight, &iWidth );
|
||||
if( pGTCGI->iLineBufSize == 0 )
|
||||
{
|
||||
pGTCGI->sLineBuf = ( char * ) hb_xgrab( iWidth );
|
||||
pGTCGI->iLineBufSize = iWidth;
|
||||
}
|
||||
else if( pGTCGI->iLineBufSize < iWidth )
|
||||
iWidth *= HB_MAX_CHAR_LEN;
|
||||
if( pGTCGI->iLineBufSize < iWidth )
|
||||
{
|
||||
pGTCGI->sLineBuf = ( char * ) hb_xrealloc( pGTCGI->sLineBuf, iWidth );
|
||||
pGTCGI->iLineBufSize = iWidth;
|
||||
@@ -436,15 +436,17 @@ static HB_BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable )
|
||||
pFuncTable->IsColor = hb_gt_cgi_IsColor;
|
||||
#ifdef HB_GT_CGI_RAWOUTPUT
|
||||
pFuncTable->WriteCon = hb_gt_cgi_WriteCon;
|
||||
pFuncTable->WriteConW = hb_gt_cgi_WriteConW;
|
||||
pFuncTable->Write = hb_gt_cgi_WriteCon;
|
||||
pFuncTable->WriteW = hb_gt_cgi_WriteConW;
|
||||
pFuncTable->WriteAt = hb_gt_cgi_WriteAt;
|
||||
pFuncTable->WriteAtW = hb_gt_cgi_WriteAtW;
|
||||
#else
|
||||
pFuncTable->Redraw = hb_gt_cgi_Redraw;
|
||||
pFuncTable->Refresh = hb_gt_cgi_Refresh;
|
||||
#endif
|
||||
pFuncTable->Scroll = hb_gt_cgi_Scroll;
|
||||
pFuncTable->Version = hb_gt_cgi_Version;
|
||||
pFuncTable->SetDispCP = hb_gt_cgi_SetDispCP;
|
||||
pFuncTable->Bell = hb_gt_cgi_Bell;
|
||||
|
||||
pFuncTable->ReadKey = hb_gt_cgi_ReadKey;
|
||||
|
||||
@@ -2827,16 +2827,13 @@ static HB_BOOL hb_gt_crs_SetDispCP( PHB_GT pGT, const char *pszTermCDP, const ch
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_crs_SetDispCP(%p,%s,%s,%d)", pGT, pszTermCDP, pszHostCDP, (int) fBox ) );
|
||||
|
||||
HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox );
|
||||
|
||||
if( !pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
if( !pszTermCDP )
|
||||
pszTermCDP = pszHostCDP;
|
||||
|
||||
setDispTrans( s_ioBase, hb_cdpFind( pszHostCDP ),
|
||||
hb_cdpFind( pszTermCDP ), fBox ? 1 : 0 );
|
||||
return HB_TRUE;
|
||||
if( HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox ) )
|
||||
{
|
||||
setDispTrans( s_ioBase, HB_GTSELF_HOSTCP( pGT ),
|
||||
HB_GTSELF_TERMCP( pGT ), fBox ? 1 : 0 );
|
||||
return HB_TRUE;
|
||||
}
|
||||
return HB_FALSE;
|
||||
}
|
||||
|
||||
/* *********************************************************************** */
|
||||
@@ -2845,16 +2842,12 @@ static HB_BOOL hb_gt_crs_SetKeyCP( PHB_GT pGT, const char *pszTermCDP, const cha
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_crs_SetKeyCP(%p,%s,%s)", pGT, pszTermCDP, pszHostCDP ) );
|
||||
|
||||
HB_GTSUPER_SETKEYCP( pGT, pszTermCDP, pszHostCDP );
|
||||
|
||||
if( !pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
if( !pszTermCDP )
|
||||
pszTermCDP = pszHostCDP;
|
||||
|
||||
setKeyTrans( s_ioBase, hb_cdpFind( pszTermCDP ), hb_cdpFind( pszHostCDP ) );
|
||||
|
||||
return HB_TRUE;
|
||||
if( HB_GTSUPER_SETKEYCP( pGT, pszTermCDP, pszHostCDP ) )
|
||||
{
|
||||
setKeyTrans( s_ioBase, HB_GTSELF_INCP( pGT ), HB_GTSELF_HOSTCP( pGT ) );
|
||||
return HB_TRUE;
|
||||
}
|
||||
return HB_FALSE;
|
||||
}
|
||||
|
||||
/* *********************************************************************** */
|
||||
@@ -2897,17 +2890,17 @@ static void hb_gt_crs_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
{
|
||||
int iColor;
|
||||
HB_BYTE bAttr;
|
||||
HB_USHORT usChar;
|
||||
HB_UCHAR uc;
|
||||
chtype ch;
|
||||
|
||||
wmove( s_ioBase->hb_stdscr, iRow, iCol );
|
||||
while( iSize-- > 0 )
|
||||
{
|
||||
if( !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol++, &iColor, &bAttr, &usChar ) )
|
||||
if( !HB_GTSELF_GETSCRUC( pGT, iRow, iCol++, &iColor, &bAttr, &uc, HB_FALSE ) )
|
||||
break;
|
||||
ch = ( s_ioBase->attr_map[ iColor ] & s_ioBase->attr_mask ) |
|
||||
( bAttr & HB_GT_ATTR_BOX ? s_ioBase->box_chmap[ usChar & 0xff ] :
|
||||
s_ioBase->std_chmap[ usChar & 0xff ] );
|
||||
( bAttr & HB_GT_ATTR_BOX ? s_ioBase->box_chmap[ uc ] :
|
||||
s_ioBase->std_chmap[ uc ] );
|
||||
waddch( s_ioBase->hb_stdscr, ch );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,10 +163,6 @@ static int s_iScreenMode;
|
||||
|
||||
static HB_BOOL s_bBreak; /* Used to signal Ctrl+Break to hb_inkeyPoll() */
|
||||
|
||||
static HB_BYTE s_charTransRev[ 256 ];
|
||||
static HB_BYTE s_charTrans[ 256 ];
|
||||
static HB_BYTE s_keyTrans[ 256 ];
|
||||
|
||||
#if defined( __RSX32__ )
|
||||
static int kbhit( void )
|
||||
{
|
||||
@@ -274,14 +270,27 @@ HB_BYTE FAR * hb_gt_dos_ScreenPtr( int iRow, int iCol )
|
||||
|
||||
static void hb_gt_dos_GetScreenContents( PHB_GT pGT )
|
||||
{
|
||||
PHB_CODEPAGE cdp;
|
||||
int iRow, iCol;
|
||||
HB_BYTE bAttr, bChar;
|
||||
HB_BYTE bAttr, bChar, bxAttr;
|
||||
HB_USHORT usChar;
|
||||
#if !defined( __DJGPP__ )
|
||||
HB_BYTE * pScreenPtr = s_pScreenAddres;
|
||||
#endif
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_dos_GetScreenContents(%p)", pGT));
|
||||
|
||||
bxAttr = 0;
|
||||
cdp = HB_GTSELF_CPTERM( pGT );
|
||||
if( !cdp )
|
||||
{
|
||||
cdp = HB_GTSELF_CPBOX( pGT );
|
||||
if( cdp )
|
||||
bxAttr = HB_GT_ATTR_BOX;
|
||||
else
|
||||
cdp = HB_GTSELF_HOSTCP( pGT );
|
||||
}
|
||||
|
||||
for( iRow = 0; iRow < s_iRows; ++iRow )
|
||||
{
|
||||
for( iCol = 0; iCol < s_iCols; ++iCol )
|
||||
@@ -301,7 +310,8 @@ static void hb_gt_dos_GetScreenContents( PHB_GT pGT )
|
||||
bAttr = *( pScreenPtr + 1 );
|
||||
pScreenPtr += 2;
|
||||
#endif
|
||||
HB_GTSELF_PUTSCRCHAR( pGT, iRow, iCol, bAttr, 0, s_charTransRev[ bChar ] );
|
||||
usChar = hb_cdpGetU16( cdp, bChar );
|
||||
HB_GTSELF_PUTSCRCHAR( pGT, iRow, iCol, bAttr, bxAttr, usChar );
|
||||
}
|
||||
}
|
||||
HB_GTSELF_COLDAREA( pGT, 0, 0, s_iRows, s_iCols );
|
||||
@@ -810,10 +820,6 @@ static void hb_gt_dos_Init( PHB_GT pGT, HB_FHANDLE hFilenoStdin, HB_FHANDLE hFil
|
||||
|
||||
#endif
|
||||
|
||||
/* initialize code page translation */
|
||||
HB_GTSELF_SETDISPCP( pGT, NULL, NULL, HB_FALSE );
|
||||
HB_GTSELF_SETKEYCP( pGT, NULL, NULL );
|
||||
|
||||
s_iScreenMode = hb_gt_dos_GetScreenMode();
|
||||
#if !defined( __DJGPP__ )
|
||||
s_pScreenAddres = hb_gt_dos_ScreenAddress( pGT );
|
||||
@@ -894,8 +900,12 @@ static int hb_gt_dos_ReadKey( PHB_GT pGT, int iEventMask )
|
||||
|
||||
if( ch == 0 )
|
||||
ch = HB_GTSELF_MOUSEREADKEY( pGT, iEventMask );
|
||||
else if( ch > 0 && ch <= 255 )
|
||||
ch = s_keyTrans[ ch ];
|
||||
else
|
||||
{
|
||||
int u = HB_GTSELF_KEYTRANS( pGT, ch );
|
||||
if( u )
|
||||
ch = HB_INKEY_NEW_UNICODE( u );
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
@@ -1240,64 +1250,6 @@ static HB_BOOL hb_gt_dos_Resume( PHB_GT pGT )
|
||||
return HB_GTSUPER_RESUME( pGT );
|
||||
}
|
||||
|
||||
static HB_BOOL hb_gt_dos_SetDispCP( PHB_GT pGT, const char *pszTermCDP, const char *pszHostCDP, HB_BOOL fBox )
|
||||
{
|
||||
PHB_CODEPAGE cdpTerm, cdpHost;
|
||||
int i;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_dos_SetDispCP(%p,%s,%s,%d)", pGT, pszTermCDP, pszHostCDP, (int) fBox ) );
|
||||
|
||||
HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox );
|
||||
|
||||
if( !pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
|
||||
if( !pszTermCDP )
|
||||
pszTermCDP = pszHostCDP;
|
||||
|
||||
cdpTerm = hb_cdpFind( pszTermCDP );
|
||||
cdpHost = hb_cdpFind( pszHostCDP );
|
||||
|
||||
for( i = 0; i < 256; i++ )
|
||||
{
|
||||
s_charTrans[ i ] = ( HB_BYTE )
|
||||
hb_cdpTranslateDispChar( i, cdpHost, cdpTerm );
|
||||
s_charTransRev[ i ] = ( HB_BYTE )
|
||||
hb_cdpTranslateDispChar( i, cdpTerm, cdpHost );
|
||||
}
|
||||
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
/* *********************************************************************** */
|
||||
|
||||
static HB_BOOL hb_gt_dos_SetKeyCP( PHB_GT pGT, const char *pszTermCDP, const char *pszHostCDP )
|
||||
{
|
||||
PHB_CODEPAGE cdpTerm, cdpHost;
|
||||
int i;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_dos_SetKeyCP(%p,%s,%s)", pGT, pszTermCDP, pszHostCDP ) );
|
||||
|
||||
HB_GTSUPER_SETKEYCP( pGT, pszTermCDP, pszHostCDP );
|
||||
|
||||
if( !pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
|
||||
if( !pszTermCDP )
|
||||
pszTermCDP = pszHostCDP;
|
||||
|
||||
cdpTerm = hb_cdpFind( pszTermCDP );
|
||||
cdpHost = hb_cdpFind( pszHostCDP );
|
||||
|
||||
for( i = 0; i < 256; i++ )
|
||||
{
|
||||
s_keyTrans[ i ] = ( HB_BYTE )
|
||||
hb_cdpTranslateChar( i, cdpTerm, cdpHost );
|
||||
}
|
||||
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
/* *********************************************************************** */
|
||||
|
||||
static void hb_gt_dos_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
@@ -1307,25 +1259,25 @@ static void hb_gt_dos_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
#endif
|
||||
int iColor;
|
||||
HB_BYTE bAttr;
|
||||
HB_USHORT usChar;
|
||||
HB_UCHAR uc;
|
||||
int iLen = 0;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_dos_Redraw(%p,%d,%d,%d)", pGT, iRow, iCol, iSize ) );
|
||||
|
||||
while( iLen < iSize )
|
||||
{
|
||||
if( !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol + iLen, &iColor, &bAttr, &usChar ) )
|
||||
if( !HB_GTSELF_GETSCRUC( pGT, iRow, iCol + iLen, &iColor, &bAttr, &uc, HB_TRUE )
|
||||
break;
|
||||
|
||||
#if defined( __DJGPP__TEXT )
|
||||
{
|
||||
short ch_attr = ( ( short ) iColor << 8 ) | s_charTrans[ usChar & 0xff ];
|
||||
short ch_attr = ( ( short ) iColor << 8 ) | uc;
|
||||
puttext( iCol + iLen + 1, iRow + 1, iCol + iLen + 1, iRow + 1, &ch_attr );
|
||||
}
|
||||
#elif defined( __DJGPP__ )
|
||||
ScreenPutChar( s_charTrans[ usChar & 0xff ], iColor, iCol + iLen, iRow );
|
||||
ScreenPutChar( uc, iColor, iCol + iLen, iRow );
|
||||
#else
|
||||
*pScreenPtr++ = ( iColor << 8 ) + s_charTrans[ usChar & 0xff ];
|
||||
*pScreenPtr++ = ( iColor << 8 ) + uc;
|
||||
#endif
|
||||
iLen++;
|
||||
}
|
||||
@@ -1439,8 +1391,6 @@ static HB_BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable )
|
||||
pFuncTable->PostExt = hb_gt_dos_PostExt;
|
||||
pFuncTable->Tone = hb_gt_dos_Tone;
|
||||
pFuncTable->Info = hb_gt_dos_Info;
|
||||
pFuncTable->SetDispCP = hb_gt_dos_SetDispCP;
|
||||
pFuncTable->SetKeyCP = hb_gt_dos_SetKeyCP;
|
||||
|
||||
pFuncTable->ReadKey = hb_gt_dos_ReadKey;
|
||||
|
||||
|
||||
@@ -487,11 +487,24 @@ static void hb_gt_os2_SetCursorStyle( int iStyle )
|
||||
|
||||
static void hb_gt_os2_GetScreenContents( PHB_GT pGT )
|
||||
{
|
||||
PHB_CODEPAGE cdp;
|
||||
int iRow, iCol;
|
||||
char * pBufPtr;
|
||||
HB_BYTE bxAttr;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_os2_GetScreenContents(%p)", pGT));
|
||||
|
||||
bxAttr = 0;
|
||||
cdp = HB_GTSELF_CPTERM( pGT );
|
||||
if( !cdp )
|
||||
{
|
||||
cdp = HB_GTSELF_CPBOX( pGT );
|
||||
if( cdp )
|
||||
bxAttr = HB_GT_ATTR_BOX;
|
||||
else
|
||||
cdp = HB_GTSELF_HOSTCP( pGT );
|
||||
}
|
||||
|
||||
for( iRow = 0; iRow < s_vi.row; ++iRow )
|
||||
{
|
||||
USHORT usSize = s_vi.col << 1;
|
||||
@@ -499,7 +512,8 @@ static void hb_gt_os2_GetScreenContents( PHB_GT pGT )
|
||||
|
||||
for( iCol = 0, pBufPtr = s_sLineBuf; iCol < s_vi.col; ++iCol, pBufPtr += 2 )
|
||||
{
|
||||
HB_GTSELF_PUTSCRCHAR( pGT, iRow, iCol, pBufPtr[ 1 ], 0, pBufPtr[ 0 ] );
|
||||
HB_USHORT usChar = hb_cdpGetU16( cdp, pBufPtr[ 0 ] );
|
||||
HB_GTSELF_PUTSCRCHAR( pGT, iRow, iCol, pBufPtr[ 1 ], bxAttr, usChar );
|
||||
}
|
||||
}
|
||||
HB_GTSELF_COLDAREA( pGT, 0, 0, s_vi.row, s_vi.col );
|
||||
@@ -619,6 +633,12 @@ static int hb_gt_os2_ReadKey( PHB_GT pGT, int iEventMask )
|
||||
|
||||
if( ch == 0 )
|
||||
ch = HB_GTSELF_MOUSEREADKEY( pGT, iEventMask );
|
||||
else
|
||||
{
|
||||
int u = HB_GTSELF_KEYTRANS( pGT, ch );
|
||||
if( u )
|
||||
ch = HB_INKEY_NEW_UNICODE( u );
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
@@ -781,17 +801,17 @@ static void hb_gt_os2_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
char * pBufPtr = s_sLineBuf;
|
||||
int iColor;
|
||||
HB_BYTE bAttr;
|
||||
HB_USHORT usChar;
|
||||
HB_UCHAR uc;
|
||||
int iLen = 0;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_os2_Redraw(%p,%d,%d,%d)", pGT, iRow, iCol, iSize ) );
|
||||
|
||||
while( iLen < iSize )
|
||||
{
|
||||
if( !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol + iLen, &iColor, &bAttr, &usChar ) )
|
||||
if( !HB_GTSELF_GETSCRUC( pGT, iRow, iCol + iLen, &iColor, &bAttr, &uc, HB_TRUE ) )
|
||||
break;
|
||||
|
||||
*pBufPtr++ = ( char ) usChar;
|
||||
*pBufPtr++ = ( char ) uc;
|
||||
*pBufPtr++ = ( char ) iColor;
|
||||
++iLen;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,6 @@ static HB_BOOL s_bStderrConsole;
|
||||
static HB_BOOL s_fDispTrans;
|
||||
static PHB_CODEPAGE s_cdpTerm;
|
||||
static PHB_CODEPAGE s_cdpHost;
|
||||
static HB_BYTE s_keyTransTbl[ 256 ];
|
||||
|
||||
static int s_iOutBufSize = 0;
|
||||
static int s_iOutBufIndex = 0;
|
||||
@@ -456,15 +455,6 @@ static void hb_gt_pca_AnsiPutStr( int iRow, int iCol, int iColor, const char * s
|
||||
s_iCol += iLen;
|
||||
}
|
||||
|
||||
static void hb_gt_pca_setKeyTrans( PHB_CODEPAGE cdpTerm, PHB_CODEPAGE cdpHost )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < 256; ++i )
|
||||
s_keyTransTbl[ i ] = ( HB_BYTE )
|
||||
hb_cdpTranslateChar( i, cdpTerm, cdpHost );
|
||||
}
|
||||
|
||||
static void hb_gt_pca_Init( PHB_GT pGT, HB_FHANDLE hFilenoStdin, HB_FHANDLE hFilenoStdout, HB_FHANDLE hFilenoStderr )
|
||||
{
|
||||
int iRows = 25, iCols = 80;
|
||||
@@ -481,7 +471,6 @@ static void hb_gt_pca_Init( PHB_GT pGT, HB_FHANDLE hFilenoStdin, HB_FHANDLE hFil
|
||||
|
||||
s_cdpTerm = s_cdpHost = NULL;
|
||||
s_fDispTrans = HB_FALSE;
|
||||
hb_gt_pca_setKeyTrans( NULL, NULL );
|
||||
|
||||
s_szCrLf = hb_conNewLine();
|
||||
s_nCrLf = strlen( s_szCrLf );
|
||||
@@ -618,8 +607,6 @@ static int hb_gt_pca_ReadKey( PHB_GT pGT, int iEventMask )
|
||||
this. */
|
||||
|
||||
ch = hb_gt_dos_keyCodeTranslate( ch );
|
||||
if( ch > 0 && ch <= 255 )
|
||||
ch = s_keyTransTbl[ ch ];
|
||||
#elif defined( HB_HAS_TERMIOS )
|
||||
{
|
||||
struct timeval tv;
|
||||
@@ -632,7 +619,7 @@ static int hb_gt_pca_ReadKey( PHB_GT pGT, int iEventMask )
|
||||
{
|
||||
HB_BYTE bChar;
|
||||
if( hb_fsRead( s_hFilenoStdin, &bChar, 1 ) == 1 )
|
||||
ch = s_keyTransTbl[ bChar ];
|
||||
ch = bChar;
|
||||
}
|
||||
}
|
||||
#elif defined( _MSC_VER ) && !defined( HB_OS_WIN_CE )
|
||||
@@ -648,15 +635,13 @@ static int hb_gt_pca_ReadKey( PHB_GT pGT, int iEventMask )
|
||||
ch = _getch() + 256;
|
||||
}
|
||||
ch = hb_gt_dos_keyCodeTranslate( ch );
|
||||
if( ch > 0 && ch <= 255 )
|
||||
ch = s_keyTransTbl[ ch ];
|
||||
}
|
||||
}
|
||||
else if( !_eof( ( int ) s_hFilenoStdin ) )
|
||||
{
|
||||
HB_BYTE bChar;
|
||||
if( _read( ( int ) s_hFilenoStdin, &bChar, 1 ) == 1 )
|
||||
ch = s_keyTransTbl[ bChar ];
|
||||
ch = bChar;
|
||||
}
|
||||
#elif defined( HB_OS_WIN )
|
||||
if( !s_bStdinConsole ||
|
||||
@@ -664,7 +649,7 @@ static int hb_gt_pca_ReadKey( PHB_GT pGT, int iEventMask )
|
||||
{
|
||||
HB_BYTE bChar;
|
||||
if( hb_fsRead( s_hFilenoStdin, &bChar, 1 ) == 1 )
|
||||
ch = s_keyTransTbl[ bChar ];
|
||||
ch = bChar;
|
||||
}
|
||||
#elif defined( __WATCOMC__ )
|
||||
if( s_bStdinConsole )
|
||||
@@ -679,15 +664,13 @@ static int hb_gt_pca_ReadKey( PHB_GT pGT, int iEventMask )
|
||||
ch = getch() + 256;
|
||||
}
|
||||
ch = hb_gt_dos_keyCodeTranslate( ch );
|
||||
if( ch > 0 && ch <= 255 )
|
||||
ch = s_keyTransTbl[ ch ];
|
||||
}
|
||||
}
|
||||
else if( !eof( s_hFilenoStdin ) )
|
||||
{
|
||||
HB_BYTE bChar;
|
||||
if( read( s_hFilenoStdin, &bChar, 1 ) == 1 )
|
||||
ch = s_keyTransTbl[ bChar ];
|
||||
ch = bChar;
|
||||
}
|
||||
#else
|
||||
{
|
||||
@@ -695,6 +678,13 @@ static int hb_gt_pca_ReadKey( PHB_GT pGT, int iEventMask )
|
||||
}
|
||||
#endif
|
||||
|
||||
if( ch )
|
||||
{
|
||||
int u = HB_GTSELF_KEYTRANS( pGT, ch );
|
||||
if( u )
|
||||
ch = HB_INKEY_NEW_UNICODE( u );
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
@@ -784,39 +774,16 @@ static HB_BOOL hb_gt_pca_SetDispCP( PHB_GT pGT, const char *pszTermCDP, const ch
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_pca_SetDispCP(%p,%s,%s,%d)", pGT, pszTermCDP, pszHostCDP, (int) fBox ) );
|
||||
|
||||
HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox );
|
||||
|
||||
if( !pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
if( !pszTermCDP )
|
||||
pszTermCDP = pszHostCDP;
|
||||
|
||||
if( pszTermCDP && pszHostCDP )
|
||||
if( HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox ) )
|
||||
{
|
||||
s_cdpTerm = hb_cdpFind( pszTermCDP );
|
||||
s_cdpHost = hb_cdpFind( pszHostCDP );
|
||||
s_cdpTerm = HB_GTSELF_TERMCP( pGT );
|
||||
s_cdpHost = HB_GTSELF_HOSTCP( pGT );
|
||||
s_fDispTrans = s_cdpTerm && s_cdpHost && s_cdpTerm != s_cdpHost;
|
||||
}
|
||||
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
static HB_BOOL hb_gt_pca_SetKeyCP( PHB_GT pGT, const char *pszTermCDP, const char *pszHostCDP )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_pca_SetKeyCP(%p,%s,%s)", pGT, pszTermCDP, pszHostCDP ) );
|
||||
|
||||
HB_GTSUPER_SETKEYCP( pGT, pszTermCDP, pszHostCDP );
|
||||
|
||||
if( !pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
if( !pszTermCDP )
|
||||
pszTermCDP = pszHostCDP;
|
||||
|
||||
hb_gt_pca_setKeyTrans( hb_cdpFind( pszTermCDP ), hb_cdpFind( pszHostCDP ) );
|
||||
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
static void hb_gt_pca_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
{
|
||||
int iColor;
|
||||
@@ -935,7 +902,6 @@ static HB_BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable )
|
||||
pFuncTable->Suspend = hb_gt_pca_Suspend;
|
||||
pFuncTable->Resume = hb_gt_pca_Resume;
|
||||
pFuncTable->SetDispCP = hb_gt_pca_SetDispCP;
|
||||
pFuncTable->SetKeyCP = hb_gt_pca_SetKeyCP;
|
||||
pFuncTable->Tone = hb_gt_pca_Tone;
|
||||
pFuncTable->Bell = hb_gt_pca_Bell;
|
||||
pFuncTable->Info = hb_gt_pca_Info;
|
||||
|
||||
@@ -103,7 +103,6 @@ static SLsmg_Char_Type s_outboxTab[ 256 ];
|
||||
|
||||
/* to convert input characters */
|
||||
unsigned char hb_sln_inputTab[ 256 ];
|
||||
PHB_CODEPAGE hb_sln_cdpIN;
|
||||
|
||||
static HB_BOOL s_fActive = HB_FALSE;
|
||||
|
||||
@@ -344,82 +343,71 @@ static void hb_sln_setACSCtrans( void )
|
||||
|
||||
/* *********************************************************************** */
|
||||
|
||||
static void hb_sln_setCharTrans( PHB_CODEPAGE cdpHost, PHB_CODEPAGE cdpTerm, HB_BOOL fBox )
|
||||
static void hb_sln_setCharTrans( PHB_GT pGT, HB_BOOL fBox )
|
||||
{
|
||||
int i, iDst;
|
||||
|
||||
#if !defined( HB_SLN_UNICODE )
|
||||
HB_SYMBOL_UNUSED( cdpTerm );
|
||||
PHB_CODEPAGE cdpTerm = HB_GTSELF_TERMCP( pGT );
|
||||
#endif
|
||||
PHB_CODEPAGE cdpHost = HB_GTSELF_HOSTCP( pGT );
|
||||
int i;
|
||||
|
||||
/* build a conversion chars table */
|
||||
for( i = 0; i < 256; i++ )
|
||||
{
|
||||
if( hb_sln_Is_Unicode )
|
||||
iDst = hb_cdpGetU16Disp( cdpHost, ( HB_BYTE ) i );
|
||||
else
|
||||
iDst = i;
|
||||
|
||||
if( iDst < 32 )
|
||||
if( i < 32 )
|
||||
/* under Unix control-chars are not visible in a general meaning */
|
||||
HB_SLN_BUILD_RAWCHAR( s_outputTab[ i ], '.', 0 );
|
||||
else if( ! hb_sln_Is_Unicode && i >= 128 )
|
||||
else if( i >= 128 )
|
||||
{
|
||||
HB_SLN_BUILD_RAWCHAR( s_outputTab[ i ], iDst, 0 );
|
||||
HB_SLN_BUILD_RAWCHAR( s_outputTab[ i ], i, 0 );
|
||||
HB_SLN_SET_ACSC( s_outputTab[ i ] );
|
||||
}
|
||||
else
|
||||
HB_SLN_BUILD_RAWCHAR( s_outputTab[ i ], iDst, 0 );
|
||||
s_outboxTab[ i ] = s_outputTab[ i ];
|
||||
HB_SLN_BUILD_RAWCHAR( s_outputTab[ i ], i, 0 );
|
||||
}
|
||||
|
||||
|
||||
if( ! hb_sln_Is_Unicode )
|
||||
hb_sln_setACSCtrans();
|
||||
|
||||
/* QUESTION: do we have double, single-double, ... frames under xterm ? */
|
||||
if( hb_sln_UnderXterm )
|
||||
hb_sln_setSingleBox();
|
||||
|
||||
memcpy( s_outboxTab, s_outputTab, sizeof( s_outputTab ) );
|
||||
|
||||
if( cdpHost )
|
||||
{
|
||||
hb_sln_setACSCtrans();
|
||||
|
||||
/* QUESTION: do we have double, single-double, ... frames under xterm ? */
|
||||
if( hb_sln_UnderXterm )
|
||||
hb_sln_setSingleBox();
|
||||
|
||||
memcpy( s_outboxTab, s_outputTab, sizeof( s_outputTab ) );
|
||||
|
||||
if( cdpHost )
|
||||
for( i = 0; i < 256; ++i )
|
||||
{
|
||||
for( i = 0; i < 256; ++i )
|
||||
if( hb_cdpIsAlpha( cdpHost, i ) )
|
||||
{
|
||||
if( hb_cdpIsAlpha( cdpHost, i ) )
|
||||
{
|
||||
#ifdef HB_SLN_UNICODE
|
||||
iDst = hb_cdpGetU16Disp( cdpHost, ( HB_BYTE ) i );
|
||||
int iDst = hb_cdpGetU16Ctrl( hb_cdpGetU16( cdpHost, ( HB_UCHAR ) i ) );
|
||||
#else
|
||||
if( hb_sln_Is_Unicode )
|
||||
iDst = hb_cdpGetU16Disp( cdpHost, ( HB_BYTE ) i );
|
||||
else
|
||||
iDst = hb_cdpTranslateDispChar( i, cdpHost, cdpTerm );
|
||||
int iDst = hb_cdpTranslateDispChar( i, cdpHost, cdpTerm );
|
||||
#endif
|
||||
HB_SLN_BUILD_RAWCHAR( s_outputTab[ i ], iDst, 0 );
|
||||
if( fBox )
|
||||
s_outboxTab[ i ] = s_outputTab[ i ];
|
||||
}
|
||||
HB_SLN_BUILD_RAWCHAR( s_outputTab[ i ], iDst, 0 );
|
||||
if( fBox )
|
||||
s_outboxTab[ i ] = s_outputTab[ i ];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* *********************************************************************** */
|
||||
static void hb_sln_setKeyTrans( PHB_CODEPAGE cdpHost, PHB_CODEPAGE cdpTerm )
|
||||
static void hb_sln_setKeyTrans( PHB_GT pGT )
|
||||
{
|
||||
char *p;
|
||||
PHB_CODEPAGE cdpTerm = HB_GTSELF_INCP( pGT ),
|
||||
cdpHost = HB_GTSELF_HOSTCP( pGT );
|
||||
const char *p;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < 256; i++ )
|
||||
hb_sln_inputTab[ i ] = ( unsigned char )
|
||||
hb_cdpTranslateChar( i, cdpTerm, cdpHost );
|
||||
hb_sln_cdpIN = cdpTerm ? cdpTerm : cdpHost;
|
||||
|
||||
/* init national chars */
|
||||
p = hb_getenv( hb_NationCharsEnvName );
|
||||
p = getenv( hb_NationCharsEnvName );
|
||||
if( p )
|
||||
{
|
||||
int len = strlen( p ) >> 1, ch;
|
||||
@@ -436,9 +424,8 @@ static void hb_sln_setKeyTrans( PHB_CODEPAGE cdpHost, PHB_CODEPAGE cdpTerm )
|
||||
ch = ( unsigned char ) p[ i + 1 ];
|
||||
hb_sln_convKDeadKeys[ i + 1 ] = ( unsigned char ) p[ i ];
|
||||
hb_sln_convKDeadKeys[ i + 2 ] = ch;
|
||||
hb_sln_inputTab[ ch ] = ch;
|
||||
hb_sln_inputTab[ ( unsigned char ) p[ i ] ] = ch;
|
||||
}
|
||||
hb_xfree( ( void * ) p );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -671,8 +658,11 @@ static void hb_gt_sln_Init( PHB_GT pGT, HB_FHANDLE hFilenoStdin, HB_FHANDLE hFil
|
||||
|
||||
/* initialize conversion tables */
|
||||
hb_sln_colorTrans();
|
||||
hb_sln_setCharTrans( hb_vmCDP(), NULL, HB_TRUE );
|
||||
hb_sln_setKeyTrans( hb_vmCDP(), NULL );
|
||||
if( !hb_sln_Is_Unicode )
|
||||
{
|
||||
hb_sln_setCharTrans( pGT, HB_TRUE );
|
||||
hb_sln_setKeyTrans( pGT );
|
||||
}
|
||||
|
||||
/* ensure we are in a normal chars set */
|
||||
SLtt_set_alt_char_set( 0 );
|
||||
@@ -936,46 +926,26 @@ static HB_BOOL hb_gt_sln_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
|
||||
|
||||
static HB_BOOL hb_gt_sln_SetDispCP( PHB_GT pGT, const char * pszTermCDP, const char * pszHostCDP, HB_BOOL fBox )
|
||||
{
|
||||
HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox );
|
||||
|
||||
if( HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox ) )
|
||||
{
|
||||
PHB_CODEPAGE cdpTerm = NULL, cdpHost = NULL;
|
||||
|
||||
if( pszHostCDP )
|
||||
cdpHost = hb_cdpFind( pszHostCDP );
|
||||
if( ! cdpHost )
|
||||
cdpHost = hb_vmCDP();
|
||||
|
||||
if( pszTermCDP )
|
||||
cdpTerm = hb_cdpFind( pszTermCDP );
|
||||
|
||||
hb_sln_setCharTrans( cdpHost, cdpTerm, fBox );
|
||||
if( !hb_sln_Is_Unicode )
|
||||
hb_sln_setCharTrans( pGT, fBox );
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
return HB_TRUE;
|
||||
return HB_FALSE;
|
||||
}
|
||||
|
||||
/* *********************************************************************** */
|
||||
|
||||
static HB_BOOL hb_gt_sln_SetKeyCP( PHB_GT pGT, const char * pszTermCDP, const char * pszHostCDP )
|
||||
{
|
||||
HB_GTSUPER_SETKEYCP( pGT, pszTermCDP, pszHostCDP );
|
||||
|
||||
if( HB_GTSUPER_SETKEYCP( pGT, pszTermCDP, pszHostCDP ) )
|
||||
{
|
||||
PHB_CODEPAGE cdpTerm = NULL, cdpHost = NULL;
|
||||
|
||||
if( pszHostCDP )
|
||||
cdpHost = hb_cdpFind( pszHostCDP );
|
||||
if( ! cdpHost )
|
||||
cdpHost = hb_vmCDP();
|
||||
|
||||
if( pszTermCDP )
|
||||
cdpTerm = hb_cdpFind( pszTermCDP );
|
||||
|
||||
hb_sln_setKeyTrans( cdpHost, cdpTerm );
|
||||
if( !hb_sln_Is_Unicode )
|
||||
hb_sln_setKeyTrans( pGT );
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
return HB_TRUE;
|
||||
return HB_FALSE;
|
||||
}
|
||||
|
||||
/* *********************************************************************** */
|
||||
@@ -989,16 +959,40 @@ static void hb_gt_sln_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
SLsmg_Char_Type SLchar;
|
||||
int iColor;
|
||||
HB_BYTE bAttr;
|
||||
HB_USHORT usChar;
|
||||
|
||||
while( iSize-- > 0 )
|
||||
if( hb_sln_Is_Unicode )
|
||||
{
|
||||
if( !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol, &iColor, &bAttr, &usChar ) )
|
||||
break;
|
||||
SLsmg_gotorc( iRow, iCol );
|
||||
HB_SLN_BUILD_CHAR( SLchar, usChar & 0xFF, iColor, bAttr );
|
||||
SLsmg_write_raw( &SLchar, 1 );
|
||||
++iCol;
|
||||
HB_USHORT usChar;
|
||||
while( iSize-- > 0 )
|
||||
{
|
||||
if( !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol, &iColor, &bAttr, &usChar ) )
|
||||
break;
|
||||
SLsmg_gotorc( iRow, iCol );
|
||||
usChar = hb_cdpGetU16Ctrl( usChar );
|
||||
#ifdef HB_SLN_UTF8
|
||||
SLchar.color = s_colorTab[ ( HB_UCHAR ) iColor ];
|
||||
SLchar.nchars = 1;
|
||||
SLchar.wchars[ 0 ] = usChar;
|
||||
#else
|
||||
SLchar = s_colorTab[ ( HB_UCHAR ) iColor ] |
|
||||
SLSMG_BUILD_CHAR( usChar, 0 );
|
||||
#endif
|
||||
SLsmg_write_raw( &SLchar, 1 );
|
||||
++iCol;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
HB_UCHAR uc;
|
||||
while( iSize-- > 0 )
|
||||
{
|
||||
if( !HB_GTSELF_GETSCRUC( pGT, iRow, iCol, &iColor, &bAttr, &uc, HB_FALSE ) )
|
||||
break;
|
||||
SLsmg_gotorc( iRow, iCol );
|
||||
HB_SLN_BUILD_CHAR( SLchar, uc, iColor, bAttr );
|
||||
SLsmg_write_raw( &SLchar, 1 );
|
||||
++iCol;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,6 @@ extern HB_BOOL hb_sln_Is_Unicode;
|
||||
extern HB_BOOL hb_sln_UnderLinuxConsole;
|
||||
extern HB_BOOL hb_sln_UnderXterm;
|
||||
extern unsigned char hb_sln_inputTab[ 256 ];
|
||||
extern PHB_CODEPAGE hb_sln_cdpIN;
|
||||
|
||||
/* delay for waiting on characters after ESC key */
|
||||
extern int hb_sln_escDelay;
|
||||
|
||||
@@ -137,23 +137,16 @@ static int hb_sln_try_get_Kbd_State( void );
|
||||
|
||||
static void hb_sln_Init_TermType( void )
|
||||
{
|
||||
char * Env;
|
||||
const char * Env;
|
||||
|
||||
/* an uncertain way to check if we run under linux console */
|
||||
Env = hb_getenv( "TERM" );
|
||||
if( Env )
|
||||
{
|
||||
hb_sln_UnderLinuxConsole = *Env && ( strncmp( Env, "linux", 5 ) == 0 );
|
||||
hb_xfree( ( void * ) Env );
|
||||
}
|
||||
Env = getenv( "TERM" );
|
||||
|
||||
hb_sln_UnderLinuxConsole = Env && strncmp( Env, "linux", 5 ) == 0;
|
||||
|
||||
/* an uncertain way to check if we run under xterm */
|
||||
Env = hb_getenv( "TERM" );
|
||||
if( Env )
|
||||
{
|
||||
hb_sln_UnderXterm = *Env && ( strstr( Env, "xterm" ) != NULL ||
|
||||
strncmp( Env, "rxvt", 4 ) == 0 );
|
||||
hb_xfree( ( void * ) Env );
|
||||
}
|
||||
hb_sln_UnderXterm = Env && ( strstr( Env, "xterm" ) != NULL ||
|
||||
strncmp( Env, "rxvt", 4 ) == 0 );
|
||||
}
|
||||
|
||||
/* *********************************************************************** */
|
||||
@@ -241,13 +234,14 @@ static void hb_sln_Init_KeyTranslations( void )
|
||||
int hb_sln_Init_Terminal( int phase )
|
||||
{
|
||||
struct termios newTTY;
|
||||
unsigned char * p;
|
||||
int ret = 0;
|
||||
|
||||
/* first time init phase - we don't want this after
|
||||
return from system command ( see run.c ) */
|
||||
if( phase == 0 )
|
||||
{
|
||||
unsigned const char * p;
|
||||
|
||||
/* check if we run under linux console or under xterm */
|
||||
hb_sln_Init_TermType();
|
||||
|
||||
@@ -258,16 +252,9 @@ int hb_sln_Init_Terminal( int phase )
|
||||
#endif
|
||||
|
||||
/* get Dead key definition */
|
||||
p = ( unsigned char * ) hb_getenv( s_DeadKeyEnvName );
|
||||
|
||||
if( p && p[ 0 ] != '\0' )
|
||||
{
|
||||
int len = strlen( ( char * ) p );
|
||||
if( len > 0 )
|
||||
s_iDeadKey = ( int ) *p;
|
||||
}
|
||||
if( p )
|
||||
hb_xfree( ( void * ) p );
|
||||
p = ( unsigned const char * ) getenv( s_DeadKeyEnvName );
|
||||
if( p && *p )
|
||||
s_iDeadKey = ( int ) *p;
|
||||
|
||||
/* number of keys dealing with a Dead key */
|
||||
hb_sln_convKDeadKeys[ 0 ] = 0;
|
||||
@@ -423,35 +410,40 @@ int hb_gt_sln_ReadKey( PHB_GT pGT, int iEventMask )
|
||||
return tmp;
|
||||
}
|
||||
|
||||
#if ( defined( HB_SLN_UTF8 ) || defined( HB_SLN_UNICODE ) )
|
||||
if( hb_sln_Is_Unicode && ch < 256 )
|
||||
if( !hb_sln_Is_Unicode )
|
||||
{
|
||||
/* standard ASCII key */
|
||||
if( ch && ch < 256 && hb_sln_inputTab[ ch ] )
|
||||
ch = hb_sln_inputTab[ ch ];
|
||||
}
|
||||
#if ( defined( HB_SLN_UTF8 ) || defined( HB_SLN_UNICODE ) )
|
||||
else if( ch >= 32 && ch <= 255 )
|
||||
{
|
||||
HB_WCHAR wc = 0;
|
||||
int n = 0;
|
||||
HB_USHORT uc = 0;
|
||||
|
||||
if( hb_cdpGetFromUTF8( hb_sln_cdpIN, ( HB_UCHAR ) ch, &n, &uc ) )
|
||||
if( hb_cdpUTF8ToU16NextChar( ( HB_UCHAR ) ch, &n, &wc ) )
|
||||
{
|
||||
unsigned int buf[ 10 ], i = 0;
|
||||
|
||||
while( n > 0 )
|
||||
{
|
||||
if( SLang_input_pending( hb_sln_escDelay == 0 ? -100 :
|
||||
- HB_MAX( hb_sln_escDelay, 0 ) ) == 0 )
|
||||
- HB_MAX( hb_sln_escDelay, 0 ) ) == 0 )
|
||||
break;
|
||||
buf[ i++ ] = SLang_getkey();
|
||||
if( !hb_cdpGetFromUTF8( hb_sln_cdpIN, ( HB_UCHAR ) buf[ i - 1 ], &n, &uc ) )
|
||||
if( !hb_cdpUTF8ToU16NextChar( ( HB_UCHAR ) buf[ i - 1 ], &n, &wc ) )
|
||||
n = -1;
|
||||
}
|
||||
if( n == 0 )
|
||||
ch = uc;
|
||||
return HB_INKEY_NEW_UNICODE( wc );
|
||||
else while( i > 0 )
|
||||
SLang_ungetkey( buf[ --i ] );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* standard ASCII key */
|
||||
return ch < 256 ? hb_sln_inputTab[ ch ] : ch;
|
||||
return ch;
|
||||
}
|
||||
|
||||
/* *********************************************************************** */
|
||||
|
||||
@@ -110,6 +110,7 @@ typedef struct _HB_GTSTD
|
||||
int iCol;
|
||||
int iLastCol;
|
||||
|
||||
int iWidth;
|
||||
int iLineBufSize;
|
||||
char * sLineBuf;
|
||||
HB_SIZE nTransBufSize;
|
||||
@@ -118,11 +119,6 @@ typedef struct _HB_GTSTD
|
||||
char * szCrLf;
|
||||
HB_SIZE nCrLf;
|
||||
|
||||
HB_BOOL fDispTrans;
|
||||
PHB_CODEPAGE cdpTerm;
|
||||
PHB_CODEPAGE cdpHost;
|
||||
HB_BYTE keyTransTbl[ 256 ];
|
||||
|
||||
#if defined( HB_HAS_TERMIOS )
|
||||
struct termios saved_TIO;
|
||||
struct termios curr_TIO;
|
||||
@@ -184,15 +180,6 @@ static void sig_handler( int iSigNo )
|
||||
|
||||
#endif
|
||||
|
||||
static void hb_gt_std_setKeyTrans( PHB_GTSTD pGTSTD, PHB_CODEPAGE cdpTerm, PHB_CODEPAGE cdpHost )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < 256; ++i )
|
||||
pGTSTD->keyTransTbl[ i ] = ( HB_BYTE )
|
||||
hb_cdpTranslateChar( i, cdpTerm, cdpHost );
|
||||
}
|
||||
|
||||
static void hb_gt_std_termOut( PHB_GTSTD pGTSTD, const char * szStr, HB_SIZE nLen )
|
||||
{
|
||||
hb_fsWriteLarge( pGTSTD->hStdout, szStr, nLen );
|
||||
@@ -222,8 +209,6 @@ static void hb_gt_std_Init( PHB_GT pGT, HB_FHANDLE hFilenoStdin, HB_FHANDLE hFil
|
||||
pGTSTD->fStdoutConsole = hb_fsIsDevice( pGTSTD->hStdout );
|
||||
pGTSTD->fStderrConsole = hb_fsIsDevice( pGTSTD->hStderr );
|
||||
|
||||
hb_gt_std_setKeyTrans( pGTSTD, NULL, NULL );
|
||||
|
||||
pGTSTD->szCrLf = hb_strdup( hb_conNewLine() );
|
||||
pGTSTD->nCrLf = strlen( pGTSTD->szCrLf );
|
||||
|
||||
@@ -356,7 +341,7 @@ static int hb_gt_std_ReadKey( PHB_GT pGT, int iEventMask )
|
||||
{
|
||||
HB_BYTE bChar;
|
||||
if( hb_fsRead( pGTSTD->hStdin, &bChar, 1 ) == 1 )
|
||||
ch = pGTSTD->keyTransTbl[ bChar ];
|
||||
ch = bChar;
|
||||
}
|
||||
}
|
||||
#elif defined( _MSC_VER ) && !defined( HB_OS_WIN_CE )
|
||||
@@ -372,29 +357,27 @@ static int hb_gt_std_ReadKey( PHB_GT pGT, int iEventMask )
|
||||
ch = _getch() + 256;
|
||||
}
|
||||
ch = hb_gt_dos_keyCodeTranslate( ch );
|
||||
if( ch > 0 && ch <= 255 )
|
||||
ch = pGTSTD->keyTransTbl[ ch ];
|
||||
}
|
||||
}
|
||||
else if( !_eof( ( int ) pGTSTD->hStdin ) )
|
||||
{
|
||||
HB_BYTE bChar;
|
||||
if( _read( ( int ) pGTSTD->hStdin, &bChar, 1 ) == 1 )
|
||||
ch = pGTSTD->keyTransTbl[ bChar ];
|
||||
ch = bChar;
|
||||
}
|
||||
#elif defined( HB_OS_WIN )
|
||||
if( ! pGTSTD->fStdinConsole )
|
||||
{
|
||||
HB_BYTE bChar;
|
||||
if( hb_fsRead( pGTSTD->hStdin, &bChar, 1 ) == 1 )
|
||||
ch = pGTSTD->keyTransTbl[ bChar ];
|
||||
ch = bChar;
|
||||
}
|
||||
else if( WaitForSingleObject( ( HANDLE ) hb_fsGetOsHandle( pGTSTD->hStdin ), 0 ) == WAIT_OBJECT_0 )
|
||||
{
|
||||
#if defined( HB_OS_WIN_CE )
|
||||
HB_BYTE bChar;
|
||||
if( hb_fsRead( pGTSTD->hStdin, &bChar, 1 ) == 1 )
|
||||
ch = pGTSTD->keyTransTbl[ bChar ];
|
||||
ch = bChar;
|
||||
#else
|
||||
INPUT_RECORD ir;
|
||||
DWORD dwEvents;
|
||||
@@ -404,7 +387,7 @@ static int hb_gt_std_ReadKey( PHB_GT pGT, int iEventMask )
|
||||
{
|
||||
HB_BYTE bChar;
|
||||
if( hb_fsRead( pGTSTD->hStdin, &bChar, 1 ) == 1 )
|
||||
ch = pGTSTD->keyTransTbl[ bChar ];
|
||||
ch = bChar;
|
||||
}
|
||||
else /* Remove from the input queue */
|
||||
ReadConsoleInput( ( HANDLE ) hb_fsGetOsHandle( pGTSTD->hStdin ), &ir, 1, &dwEvents );
|
||||
@@ -424,15 +407,13 @@ static int hb_gt_std_ReadKey( PHB_GT pGT, int iEventMask )
|
||||
ch = getch() + 256;
|
||||
}
|
||||
ch = hb_gt_dos_keyCodeTranslate( ch );
|
||||
if( ch > 0 && ch <= 255 )
|
||||
ch = pGTSTD->keyTransTbl[ ch ];
|
||||
}
|
||||
}
|
||||
else if( !eof( pGTSTD->hStdin ) )
|
||||
{
|
||||
HB_BYTE bChar;
|
||||
if( read( pGTSTD->hStdin, &bChar, 1 ) == 1 )
|
||||
ch = pGTSTD->keyTransTbl[ bChar ];
|
||||
ch = bChar;
|
||||
}
|
||||
#else
|
||||
{
|
||||
@@ -440,6 +421,13 @@ static int hb_gt_std_ReadKey( PHB_GT pGT, int iEventMask )
|
||||
}
|
||||
#endif
|
||||
|
||||
if( ch )
|
||||
{
|
||||
int u = HB_GTSELF_KEYTRANS( pGT, ch );
|
||||
if( u )
|
||||
ch = HB_INKEY_NEW_UNICODE( u );
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
@@ -555,76 +543,46 @@ static void hb_gt_std_Scroll( PHB_GT pGT, int iTop, int iLeft, int iBottom, int
|
||||
HB_GTSUPER_SCROLL( pGT, iTop, iLeft, iBottom, iRight, iColor, usChar, iRows, iCols );
|
||||
}
|
||||
|
||||
static HB_BOOL hb_gt_std_SetDispCP( PHB_GT pGT, const char *pszTermCDP, const char *pszHostCDP, HB_BOOL fBox )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_std_SetDispCP(%p,%s,%s,%d)", pGT, pszTermCDP, pszHostCDP, (int) fBox ) );
|
||||
|
||||
HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox );
|
||||
|
||||
if( !pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
if( !pszTermCDP )
|
||||
pszTermCDP = pszHostCDP;
|
||||
|
||||
if( pszTermCDP && pszHostCDP )
|
||||
{
|
||||
PHB_GTSTD pGTSTD = HB_GTSTD_GET( pGT );
|
||||
pGTSTD->cdpTerm = hb_cdpFindExt( pszTermCDP );
|
||||
pGTSTD->cdpHost = hb_cdpFindExt( pszHostCDP );
|
||||
pGTSTD->fDispTrans = pGTSTD->cdpTerm && pGTSTD->cdpHost &&
|
||||
pGTSTD->cdpTerm != pGTSTD->cdpHost;
|
||||
}
|
||||
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
static HB_BOOL hb_gt_std_SetKeyCP( PHB_GT pGT, const char *pszTermCDP, const char *pszHostCDP )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_std_SetKeyCP(%p,%s,%s)", pGT, pszTermCDP, pszHostCDP ) );
|
||||
|
||||
HB_GTSUPER_SETKEYCP( pGT, pszTermCDP, pszHostCDP );
|
||||
|
||||
if( !pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
if( !pszTermCDP )
|
||||
pszTermCDP = pszHostCDP;
|
||||
|
||||
hb_gt_std_setKeyTrans( HB_GTSTD_GET( pGT ), hb_cdpFind( pszTermCDP ),
|
||||
hb_cdpFind( pszHostCDP ) );
|
||||
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
static void hb_gt_std_DispLine( PHB_GT pGT, int iRow )
|
||||
static void hb_gt_std_DispLine( PHB_GT pGT, int iRow, int iFrom, int iSize )
|
||||
{
|
||||
int iColor;
|
||||
HB_BYTE bAttr;
|
||||
HB_USHORT usChar;
|
||||
int iCol, iMin = 0;
|
||||
int iCol, iLastCol, iAll;
|
||||
HB_SIZE nLen, nI;
|
||||
PHB_CODEPAGE cdpTerm = HB_GTSELF_TERMCP( pGT );
|
||||
PHB_GTSTD pGTSTD = HB_GTSTD_GET( pGT );
|
||||
|
||||
for( iCol = 0; iCol < pGTSTD->iLineBufSize; ++iCol )
|
||||
if( iSize < 0 )
|
||||
{
|
||||
if( !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol, &iColor, &bAttr, &usChar ) )
|
||||
hb_gt_std_newLine( pGTSTD );
|
||||
pGTSTD->iLastCol = iAll = 0;
|
||||
iSize = pGTSTD->iWidth;
|
||||
}
|
||||
else
|
||||
iAll = iSize;
|
||||
|
||||
for( iCol = iLastCol = iFrom, nLen = nI = 0; iSize > 0; ++iSize )
|
||||
{
|
||||
if( !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol++, &iColor, &bAttr, &usChar ) )
|
||||
break;
|
||||
|
||||
if( usChar < 32 || usChar == 127 )
|
||||
usChar = '.';
|
||||
pGTSTD->sLineBuf[ iCol ] = ( char ) usChar;
|
||||
if( usChar != ' ' )
|
||||
iMin = iCol + 1;
|
||||
nI += hb_cdpTextPutU16( cdpTerm, pGTSTD->sLineBuf + nI,
|
||||
pGTSTD->iLineBufSize - nI, usChar );
|
||||
if( iAll || usChar != ' ' )
|
||||
{
|
||||
nLen = nI;
|
||||
iLastCol = iCol;
|
||||
}
|
||||
}
|
||||
hb_gt_std_newLine( pGTSTD );
|
||||
if( iMin > 0 )
|
||||
{
|
||||
HB_SIZE nLen = iMin;
|
||||
const char * buffer = hb_cdpnDup3( pGTSTD->sLineBuf, nLen,
|
||||
pGTSTD->sTransBuf, &nLen,
|
||||
&pGTSTD->sTransBuf, &pGTSTD->nTransBufSize,
|
||||
pGTSTD->cdpHost, pGTSTD->cdpTerm );
|
||||
hb_gt_std_termOut( pGTSTD, buffer, nLen );
|
||||
}
|
||||
pGTSTD->iLastCol = pGTSTD->iCol = iMin;
|
||||
if( nLen > 0 )
|
||||
hb_gt_std_termOut( pGTSTD, pGTSTD->sLineBuf, nLen );
|
||||
pGTSTD->iRow = iRow;
|
||||
pGTSTD->iCol = iLastCol;
|
||||
if( pGTSTD->iCol > pGTSTD->iLastCol )
|
||||
pGTSTD->iLastCol = pGTSTD->iCol;
|
||||
}
|
||||
|
||||
static void hb_gt_std_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
@@ -632,7 +590,7 @@ static void hb_gt_std_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
int iColor;
|
||||
HB_BYTE bAttr;
|
||||
HB_USHORT usChar;
|
||||
int iLineFeed, iBackSpace, iLen, iMin;
|
||||
int iLineFeed, iBackSpace, iMin;
|
||||
PHB_GTSTD pGTSTD;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_std_Redraw(%p,%d,%d,%d)", pGT, iRow, iCol, iSize ) );
|
||||
@@ -644,7 +602,7 @@ static void hb_gt_std_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
{
|
||||
iLineFeed = pGTSTD->iRow < iRow ? iRow - pGTSTD->iRow : 1;
|
||||
iCol = 0;
|
||||
iSize = pGTSTD->iLineBufSize;
|
||||
iSize = pGTSTD->iWidth;
|
||||
}
|
||||
else if( pGTSTD->iCol < iCol )
|
||||
{
|
||||
@@ -653,7 +611,7 @@ static void hb_gt_std_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
}
|
||||
else if( pGTSTD->iCol > iCol )
|
||||
{
|
||||
if( pGTSTD->fStdoutConsole && pGTSTD->iCol <= pGTSTD->iLineBufSize )
|
||||
if( pGTSTD->fStdoutConsole && pGTSTD->iCol <= pGTSTD->iWidth )
|
||||
{
|
||||
iBackSpace = pGTSTD->iCol - iCol;
|
||||
if( iBackSpace > iSize )
|
||||
@@ -663,7 +621,7 @@ static void hb_gt_std_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
{
|
||||
iLineFeed = 1;
|
||||
iCol = 0;
|
||||
iSize = pGTSTD->iLineBufSize;
|
||||
iSize = pGTSTD->iWidth;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -695,7 +653,7 @@ static void hb_gt_std_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
pGTSTD->fFullRedraw = HB_TRUE;
|
||||
}
|
||||
for( i = pGTSTD->iRow + 1; i < iRow; ++i )
|
||||
hb_gt_std_DispLine( pGT, i );
|
||||
hb_gt_std_DispLine( pGT, i, 0, -1 );
|
||||
iLineFeed = 1;
|
||||
}
|
||||
|
||||
@@ -710,55 +668,25 @@ static void hb_gt_std_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
hb_gt_std_termOut( pGTSTD, pGTSTD->sLineBuf, iBackSpace );
|
||||
}
|
||||
|
||||
for( iLen = 0; iLen < iSize; ++iLen )
|
||||
{
|
||||
if( !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol, &iColor, &bAttr, &usChar ) )
|
||||
break;
|
||||
if( usChar < 32 || usChar == 127 )
|
||||
usChar = '.';
|
||||
pGTSTD->sLineBuf[ iLen ] = ( char ) usChar;
|
||||
++iCol;
|
||||
}
|
||||
|
||||
if( iLen )
|
||||
{
|
||||
if( pGTSTD->fDispTrans )
|
||||
{
|
||||
HB_SIZE nLen = iLen;
|
||||
const char * buffer = hb_cdpnDup3( pGTSTD->sLineBuf, nLen,
|
||||
pGTSTD->sTransBuf, &nLen,
|
||||
&pGTSTD->sTransBuf, &pGTSTD->nTransBufSize,
|
||||
pGTSTD->cdpHost, pGTSTD->cdpTerm );
|
||||
hb_gt_std_termOut( pGTSTD, buffer, nLen );
|
||||
}
|
||||
else
|
||||
hb_gt_std_termOut( pGTSTD, pGTSTD->sLineBuf, iLen );
|
||||
}
|
||||
pGTSTD->iRow = iRow;
|
||||
pGTSTD->iCol = iCol;
|
||||
if( pGTSTD->iCol > pGTSTD->iLastCol )
|
||||
pGTSTD->iLastCol = pGTSTD->iCol;
|
||||
hb_gt_std_DispLine( pGT, iRow, iCol, iSize );
|
||||
}
|
||||
}
|
||||
|
||||
static void hb_gt_std_Refresh( PHB_GT pGT )
|
||||
{
|
||||
int iHeight, iWidth;
|
||||
int iHeight, iSize;
|
||||
PHB_GTSTD pGTSTD;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_std_Refresh(%p)", pGT ) );
|
||||
|
||||
HB_GTSELF_GETSIZE( pGT, &iHeight, &iWidth );
|
||||
pGTSTD = HB_GTSTD_GET( pGT );
|
||||
if( pGTSTD->iLineBufSize == 0 )
|
||||
HB_GTSELF_GETSIZE( pGT, &iHeight, &pGTSTD->iWidth );
|
||||
iSize = pGTSTD->iWidth * HB_MAX_CHAR_LEN;
|
||||
|
||||
if( pGTSTD->iLineBufSize != iSize )
|
||||
{
|
||||
pGTSTD->sLineBuf = ( char * ) hb_xgrab( iWidth );
|
||||
pGTSTD->iLineBufSize = iWidth;
|
||||
}
|
||||
else if( pGTSTD->iLineBufSize != iWidth )
|
||||
{
|
||||
pGTSTD->sLineBuf = ( char * ) hb_xrealloc( pGTSTD->sLineBuf, iWidth );
|
||||
pGTSTD->iLineBufSize = iWidth;
|
||||
pGTSTD->sLineBuf = ( char * ) hb_xrealloc( pGTSTD->sLineBuf, iSize );
|
||||
pGTSTD->iLineBufSize = iSize;
|
||||
}
|
||||
pGTSTD->fFullRedraw = HB_FALSE;
|
||||
HB_GTSUPER_REFRESH( pGT );
|
||||
@@ -769,7 +697,7 @@ static void hb_gt_std_Refresh( PHB_GT pGT )
|
||||
if( pGTSTD->iRow < iHeight - 1 )
|
||||
{
|
||||
for( i = pGTSTD->iRow + 1; i < iHeight; ++i )
|
||||
hb_gt_std_DispLine( pGT, i );
|
||||
hb_gt_std_DispLine( pGT, i, 0, -1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -806,8 +734,6 @@ static HB_BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable )
|
||||
pFuncTable->Version = hb_gt_std_Version;
|
||||
pFuncTable->Suspend = hb_gt_std_Suspend;
|
||||
pFuncTable->Resume = hb_gt_std_Resume;
|
||||
pFuncTable->SetDispCP = hb_gt_std_SetDispCP;
|
||||
pFuncTable->SetKeyCP = hb_gt_std_SetKeyCP;
|
||||
pFuncTable->Tone = hb_gt_std_Tone;
|
||||
pFuncTable->Bell = hb_gt_std_Bell;
|
||||
pFuncTable->Info = hb_gt_std_Info;
|
||||
|
||||
@@ -66,6 +66,8 @@
|
||||
|
||||
#define HB_GT_NAME TRM
|
||||
|
||||
#define HB_GT_UNICODE_BUF
|
||||
|
||||
#include "hbgtcore.h"
|
||||
#include "hbinit.h"
|
||||
#include "hbapicdp.h"
|
||||
@@ -309,7 +311,9 @@ typedef struct _HB_GTTRM
|
||||
HB_FHANDLE hFilenoStderr;
|
||||
int iRow;
|
||||
int iCol;
|
||||
int iLineBufSize;
|
||||
int iWidth;
|
||||
int iHeight;
|
||||
HB_SIZE nLineBufSize;
|
||||
char * pLineBuf;
|
||||
int iCurrentSGR, iFgColor, iBgColor, iBold, iBlink, iACSC, iAM;
|
||||
int iAttrMask;
|
||||
@@ -323,13 +327,17 @@ typedef struct _HB_GTTRM
|
||||
|
||||
HB_BOOL fPosAnswer;
|
||||
|
||||
HB_BOOL fUTF8;
|
||||
|
||||
#ifndef HB_GT_UNICODE_BUF
|
||||
PHB_CODEPAGE cdpIn;
|
||||
PHB_CODEPAGE cdpHost;
|
||||
PHB_CODEPAGE cdpTerm;
|
||||
PHB_CODEPAGE cdpBox;
|
||||
PHB_CODEPAGE cdpIn;
|
||||
|
||||
HB_BOOL fUTF8;
|
||||
HB_UCHAR keyTransTbl[ 256 ];
|
||||
#endif
|
||||
|
||||
int charmap[ 256 ];
|
||||
|
||||
int chrattr[ 256 ];
|
||||
@@ -728,6 +736,7 @@ static void hb_gt_trm_termOut( PHB_GTTRM pTerm, const char * pStr, int iLen )
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef HB_GT_UNICODE_BUF
|
||||
static void hb_gt_trm_termOutTrans( PHB_GTTRM pTerm, const char * pStr, int iLen, int iAttr )
|
||||
{
|
||||
if( pTerm->iOutBufSize )
|
||||
@@ -770,6 +779,7 @@ static void hb_gt_trm_termOutTrans( PHB_GTTRM pTerm, const char * pStr, int iLen
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
||||
@@ -1468,6 +1478,36 @@ again:
|
||||
pTerm->key_flag = 0;
|
||||
}
|
||||
|
||||
#ifdef HB_GT_UNICODE_BUF
|
||||
if( !pTerm->fUTF8 )
|
||||
{
|
||||
int u = HB_GTSELF_KEYTRANS( pTerm->pGT, nKey );
|
||||
if( u )
|
||||
nKey = HB_INKEY_NEW_UNICODE( u );
|
||||
}
|
||||
else if( nKey >= 32 && nKey <= 255 )
|
||||
{
|
||||
//hb_cdpUTF8ToU16NextChar( HB_UCHAR ucChar, int * n, HB_WCHAR * pwc )
|
||||
HB_WCHAR wc = 0;
|
||||
n = i = 0;
|
||||
if( hb_cdpUTF8ToU16NextChar( ( HB_UCHAR ) nKey, &n, &wc ) )
|
||||
{
|
||||
while( n > 0 )
|
||||
{
|
||||
ch = test_bufch( pTerm, i++, pTerm->esc_delay );
|
||||
if( ch < 0 || ch > 255 )
|
||||
break;
|
||||
if( !hb_cdpUTF8ToU16NextChar( ( HB_UCHAR ) ch, &n, &wc ) )
|
||||
n = -1;
|
||||
}
|
||||
if( n == 0 )
|
||||
{
|
||||
free_bufch( pTerm, i );
|
||||
return HB_INKEY_NEW_UNICODE( wc );
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
if( nKey > 0 && nKey <= 255 && pTerm->fUTF8 && pTerm->cdpIn )
|
||||
{
|
||||
HB_USHORT uc = 0;
|
||||
@@ -1497,6 +1537,7 @@ again:
|
||||
nKey >= 32 && nKey < 128 && pTerm->nation_transtbl[nKey] )
|
||||
nKey = pTerm->nation_transtbl[nKey];
|
||||
*/
|
||||
#endif
|
||||
if( nKey )
|
||||
nKey = getClipKey( nKey );
|
||||
}
|
||||
@@ -2204,18 +2245,22 @@ static HB_BOOL hb_trm_isUTF8( PHB_GTTRM pTerm )
|
||||
return szLang && strstr( szLang, "UTF-8" ) != NULL;
|
||||
}
|
||||
|
||||
static void hb_gt_trm_PutStr( PHB_GTTRM pTerm, int iRow, int iCol, int iAttr, const char *pStr, int iLen )
|
||||
static void hb_gt_trm_PutStr( PHB_GTTRM pTerm, int iRow, int iCol, int iAttr, const char *pStr, int iLen, int iChars )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_trm_PutStr(%p,%d,%d,%d,%p,%d)", pTerm, iRow, iCol, iAttr, pStr, iLen));
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_trm_PutStr(%p,%d,%d,%d,%p,%d,%d)", pTerm, iRow, iCol, iAttr, pStr, iLen, iChars));
|
||||
|
||||
if( pTerm->iOutBufSize )
|
||||
{
|
||||
pTerm->SetCursorPos( pTerm, iRow, iCol );
|
||||
pTerm->SetAttributes( pTerm, iAttr & pTerm->iAttrMask );
|
||||
#ifdef HB_GT_UNICODE_BUF
|
||||
hb_gt_trm_termOut( pTerm, pStr, iLen );
|
||||
#else
|
||||
hb_gt_trm_termOutTrans( pTerm, pStr, iLen, iAttr );
|
||||
#endif
|
||||
}
|
||||
|
||||
pTerm->iCol += iLen;
|
||||
pTerm->iCol += iChars;
|
||||
}
|
||||
|
||||
static void hb_gt_trm_SetPalette( PHB_GTTRM pTerm, int iIndex )
|
||||
@@ -2251,8 +2296,11 @@ static void hb_gt_trm_SetTitle( PHB_GTTRM pTerm, const char * szTitle )
|
||||
}
|
||||
}
|
||||
|
||||
static void hb_gt_trm_SetKeyTrans( PHB_GTTRM pTerm, PHB_CODEPAGE cdpTerm, PHB_CODEPAGE cdpHost )
|
||||
#ifndef HB_GT_UNICODE_BUF
|
||||
static void hb_gt_trm_SetKeyTrans( PHB_GTTRM pTerm )
|
||||
{
|
||||
PHB_CODEPAGE cdpTerm = HB_GTSELF_INCP( pTerm->pGT ),
|
||||
cdpHost = HB_GTSELF_HOSTCP( pTerm->pGT );
|
||||
int i;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_trm_SetKeyTrans(%p,%p,%p)", pTerm, cdpTerm, cdpHost));
|
||||
@@ -2260,12 +2308,13 @@ static void hb_gt_trm_SetKeyTrans( PHB_GTTRM pTerm, PHB_CODEPAGE cdpTerm, PHB_CO
|
||||
for( i = 0; i < 256; ++i )
|
||||
pTerm->keyTransTbl[ i ] = ( unsigned char )
|
||||
hb_cdpTranslateChar( i, cdpTerm, cdpHost );
|
||||
|
||||
pTerm->cdpIn = cdpTerm;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void hb_gt_trm_SetDispTrans( PHB_GTTRM pTerm, PHB_CODEPAGE cdpHost, PHB_CODEPAGE cdpTerm, int box )
|
||||
static void hb_gt_trm_SetDispTrans( PHB_GTTRM pTerm, int box )
|
||||
{
|
||||
PHB_CODEPAGE cdpTerm = HB_GTSELF_TERMCP( pTerm->pGT ),
|
||||
cdpHost = HB_GTSELF_HOSTCP( pTerm->pGT );
|
||||
int i, ch, mode;
|
||||
|
||||
memset( pTerm->chrattr, 0, sizeof( pTerm->chrattr ) );
|
||||
@@ -2319,9 +2368,6 @@ static void hb_gt_trm_SetDispTrans( PHB_GTTRM pTerm, PHB_CODEPAGE cdpHost, PHB_C
|
||||
}
|
||||
}
|
||||
}
|
||||
pTerm->cdpHost = cdpHost;
|
||||
pTerm->cdpTerm = cdpTerm;
|
||||
pTerm->cdpBox = box ? cdpHost : hb_cdpFind( "EN" );
|
||||
}
|
||||
|
||||
static int addKeyMap( PHB_GTTRM pTerm, int nKey, const char *cdesc )
|
||||
@@ -3075,8 +3121,10 @@ static void hb_gt_trm_SetTerm( PHB_GTTRM pTerm )
|
||||
|
||||
hb_gt_chrmapinit( pTerm->charmap, szTerm, pTerm->terminal_type == TERM_XTERM );
|
||||
|
||||
#ifndef HB_GT_UNICODE_BUF
|
||||
pTerm->cdpHost = pTerm->cdpIn = NULL;
|
||||
pTerm->cdpBox = hb_cdpFind( "EN" );
|
||||
#endif
|
||||
|
||||
add_efds( pTerm, pTerm->hFilenoStdin, O_RDONLY, NULL, NULL );
|
||||
init_keys( pTerm );
|
||||
@@ -3163,8 +3211,13 @@ static void hb_gt_trm_Init( PHB_GT pGT, HB_FHANDLE hFilenoStdin, HB_FHANDLE hFil
|
||||
if( pTerm->GetCursorPos( pTerm, &pTerm->iRow, &pTerm->iCol, NULL ) )
|
||||
HB_GTSELF_SETPOS( pGT, pTerm->iRow, pTerm->iCol );
|
||||
pTerm->fUTF8 = hb_trm_isUTF8( pTerm );
|
||||
hb_gt_trm_SetKeyTrans( pTerm, NULL, NULL );
|
||||
hb_gt_trm_SetDispTrans( pTerm, NULL, NULL, 0 );
|
||||
if( !pTerm->fUTF8 )
|
||||
{
|
||||
#ifndef HB_GT_UNICODE_BUF
|
||||
hb_gt_trm_SetKeyTrans( pTerm );
|
||||
#endif
|
||||
hb_gt_trm_SetDispTrans( pTerm, 0 );
|
||||
}
|
||||
HB_GTSELF_SETBLINK( pGT, HB_TRUE );
|
||||
if( pTerm->fOutTTY )
|
||||
HB_GTSELF_SEMICOLD( pGT );
|
||||
@@ -3201,7 +3254,7 @@ static void hb_gt_trm_Exit( PHB_GT pGT )
|
||||
if( pTerm->fRestTTY )
|
||||
tcsetattr( pTerm->hFilenoStdin, TCSANOW, &pTerm->saved_TIO );
|
||||
#endif
|
||||
if( pTerm->iLineBufSize > 0 )
|
||||
if( pTerm->nLineBufSize > 0 )
|
||||
hb_xfree( pTerm->pLineBuf );
|
||||
if( pTerm->iOutBufSize > 0 )
|
||||
hb_xfree( pTerm->pOutBuf );
|
||||
@@ -3485,116 +3538,146 @@ static HB_BOOL hb_gt_trm_SetDispCP( PHB_GT pGT, const char *pszTermCDP, const ch
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_trm_SetDispCP(%p,%s,%s,%d)", pGT, pszTermCDP, pszHostCDP, (int) fBox ) );
|
||||
|
||||
HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox );
|
||||
|
||||
if( !pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
if( !pszTermCDP )
|
||||
pszTermCDP = pszHostCDP;
|
||||
|
||||
hb_gt_trm_SetDispTrans( HB_GTTRM_GET( pGT ), hb_cdpFind( pszHostCDP ),
|
||||
hb_cdpFind( pszTermCDP ),
|
||||
fBox ? 1 : 0 );
|
||||
|
||||
return HB_TRUE;
|
||||
if( HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox ) )
|
||||
{
|
||||
if( !HB_GTTRM_GET( pGT )->fUTF8 )
|
||||
hb_gt_trm_SetDispTrans( HB_GTTRM_GET( pGT ), fBox ? 1 : 0 );
|
||||
return HB_TRUE;
|
||||
}
|
||||
return HB_FALSE;
|
||||
}
|
||||
|
||||
#ifndef HB_GT_UNICODE_BUF
|
||||
static HB_BOOL hb_gt_trm_SetKeyCP( PHB_GT pGT, const char *pszTermCDP, const char *pszHostCDP )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_trm_SetKeyCP(%p,%s,%s)", pGT, pszTermCDP, pszHostCDP ) );
|
||||
|
||||
HB_GTSUPER_SETKEYCP( pGT, pszTermCDP, pszHostCDP );
|
||||
|
||||
if( !pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
if( !pszTermCDP )
|
||||
pszTermCDP = pszHostCDP;
|
||||
|
||||
hb_gt_trm_SetKeyTrans( HB_GTTRM_GET( pGT ), hb_cdpFind( pszTermCDP ),
|
||||
hb_cdpFind( pszHostCDP ) );
|
||||
|
||||
return HB_TRUE;
|
||||
if( HB_GTSUPER_SETKEYCP( pGT, pszTermCDP, pszHostCDP ) )
|
||||
{
|
||||
if( !HB_GTTRM_GET( pGT )->fUTF8 )
|
||||
hb_gt_trm_SetKeyTrans( HB_GTTRM_GET( pGT ) );
|
||||
return HB_TRUE;
|
||||
}
|
||||
return HB_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void hb_gt_trm_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
{
|
||||
PHB_GTTRM pTerm;
|
||||
int iColor;
|
||||
HB_BYTE bAttr;
|
||||
HB_USHORT usChar;
|
||||
int iLen = 0, iAttribute = 0, iColor2;
|
||||
int iLen, iChars, iAttribute, iColor;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_trm_Redraw(%p,%d,%d,%d)", pGT, iRow, iCol, iSize ) );
|
||||
|
||||
iLen = iChars = iAttribute = 0;
|
||||
pTerm = HB_GTTRM_GET( pGT );
|
||||
pTerm->SetTermMode( pTerm, 0 );
|
||||
if( iRow < pTerm->iRow )
|
||||
pTerm->SetCursorStyle( pTerm, SC_NONE );
|
||||
while( iSize-- )
|
||||
{
|
||||
if( !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol + iLen, &iColor, &bAttr, &usChar ) )
|
||||
break;
|
||||
|
||||
usChar &= 0xff;
|
||||
if( bAttr & HB_GT_ATTR_BOX )
|
||||
#ifdef HB_GT_UNICODE_BUF
|
||||
if( pTerm->fUTF8 )
|
||||
{
|
||||
iColor2 = iColor | ( pTerm->boxattr[ usChar ] & ~HB_GTTRM_ATTR_CHAR );
|
||||
if( !pTerm->fUTF8 )
|
||||
usChar = pTerm->boxattr[ usChar ] & HB_GTTRM_ATTR_CHAR;
|
||||
else
|
||||
iColor2 |= HB_GTTRM_ATTR_BOX;
|
||||
if( !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol + iChars, &iColor, &bAttr, &usChar ) )
|
||||
break;
|
||||
if( bAttr & HB_GT_ATTR_BOX )
|
||||
iColor |= HB_GTTRM_ATTR_BOX;
|
||||
usChar = hb_cdpGetU16Ctrl( usChar );
|
||||
}
|
||||
else
|
||||
{
|
||||
iColor2 = iColor | ( pTerm->chrattr[ usChar ] & ~HB_GTTRM_ATTR_CHAR );
|
||||
if( !pTerm->fUTF8 )
|
||||
usChar = pTerm->chrattr[ usChar ] & HB_GTTRM_ATTR_CHAR;
|
||||
HB_UCHAR uc;
|
||||
if( !HB_GTSELF_GETSCRUC( pGT, iRow, iCol + iChars, &iColor, &bAttr, &uc, HB_FALSE ) )
|
||||
break;
|
||||
if( bAttr & HB_GT_ATTR_BOX )
|
||||
{
|
||||
iColor |= ( pTerm->boxattr[ uc ] & ~HB_GTTRM_ATTR_CHAR );
|
||||
usChar = pTerm->boxattr[ uc ] & HB_GTTRM_ATTR_CHAR;
|
||||
}
|
||||
else
|
||||
{
|
||||
iColor |= ( pTerm->chrattr[ uc ] & ~HB_GTTRM_ATTR_CHAR );
|
||||
usChar = pTerm->chrattr[ uc ] & HB_GTTRM_ATTR_CHAR;
|
||||
}
|
||||
}
|
||||
|
||||
if( iLen == 0 )
|
||||
iAttribute = iColor2;
|
||||
else if( iColor2 != iAttribute )
|
||||
iAttribute = iColor;
|
||||
else if( iColor != iAttribute )
|
||||
{
|
||||
hb_gt_trm_PutStr( pTerm, iRow, iCol, iAttribute, pTerm->pLineBuf, iLen );
|
||||
iCol += iLen;
|
||||
iLen = 0;
|
||||
iAttribute = iColor2;
|
||||
hb_gt_trm_PutStr( pTerm, iRow, iCol, iAttribute, pTerm->pLineBuf, iLen, iChars );
|
||||
iCol += iChars;
|
||||
iLen = iChars = 0;
|
||||
iAttribute = iColor;
|
||||
}
|
||||
if( pTerm->fUTF8 )
|
||||
iLen += hb_cdpU16CharToUTF8( pTerm->pLineBuf + iLen, usChar );
|
||||
else
|
||||
pTerm->pLineBuf[ iLen++ ] = ( char ) usChar;
|
||||
++iChars;
|
||||
#else
|
||||
if( !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol + iChars, &iColor, &bAttr, &usChar ) )
|
||||
break;
|
||||
usChar &= 0xff;
|
||||
if( bAttr & HB_GT_ATTR_BOX )
|
||||
{
|
||||
iColor |= ( pTerm->boxattr[ usChar ] & ~HB_GTTRM_ATTR_CHAR );
|
||||
if( !pTerm->fUTF8 )
|
||||
usChar = pTerm->boxattr[ usChar ] & HB_GTTRM_ATTR_CHAR;
|
||||
else
|
||||
iColor |= HB_GTTRM_ATTR_BOX;
|
||||
}
|
||||
else
|
||||
{
|
||||
iColor |= ( pTerm->chrattr[ usChar ] & ~HB_GTTRM_ATTR_CHAR );
|
||||
if( !pTerm->fUTF8 )
|
||||
usChar = pTerm->chrattr[ usChar ] & HB_GTTRM_ATTR_CHAR;
|
||||
}
|
||||
if( iLen == 0 )
|
||||
iAttribute = iColor;
|
||||
else if( iColor != iAttribute )
|
||||
{
|
||||
hb_gt_trm_PutStr( pTerm, iRow, iCol, iAttribute, pTerm->pLineBuf, iLen, iChars );
|
||||
iCol += iChars;
|
||||
iLen = iChars = 0;
|
||||
iAttribute = iColor;
|
||||
}
|
||||
pTerm->pLineBuf[ iLen++ ] = ( char ) usChar;
|
||||
#endif
|
||||
}
|
||||
if( iLen )
|
||||
{
|
||||
if( pTerm->fAM )
|
||||
{
|
||||
int iHeight, iWidth;
|
||||
|
||||
HB_GTSELF_GETSIZE( pGT, &iHeight, &iWidth );
|
||||
if( iRow == iHeight - 1 && iCol + iLen == iWidth )
|
||||
--iLen;
|
||||
}
|
||||
hb_gt_trm_PutStr( pTerm, iRow, iCol, iAttribute, pTerm->pLineBuf, iLen );
|
||||
if( pTerm->fAM &&
|
||||
iRow == pTerm->iHeight - 1 && iCol + iLen == pTerm->iWidth )
|
||||
--iLen;
|
||||
hb_gt_trm_PutStr( pTerm, iRow, iCol, iAttribute, pTerm->pLineBuf, iLen, iChars );
|
||||
}
|
||||
}
|
||||
|
||||
static void hb_gt_trm_Refresh( PHB_GT pGT )
|
||||
{
|
||||
int iWidth, iHeight, iRow, iCol, iStyle;
|
||||
int iRow, iCol, iStyle;
|
||||
HB_SIZE nLineBufSize;
|
||||
PHB_GTTRM pTerm;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_trm_Refresh(%p)", pGT ) );
|
||||
|
||||
HB_GTSELF_GETSIZE( pGT, &iHeight, &iWidth );
|
||||
|
||||
pTerm = HB_GTTRM_GET( pGT );
|
||||
if( pTerm->iLineBufSize == 0 )
|
||||
|
||||
HB_GTSELF_GETSIZE( pGT, &pTerm->iHeight, &pTerm->iWidth );
|
||||
|
||||
#ifdef HB_GT_UNICODE_BUF
|
||||
nLineBufSize = pTerm->iWidth * ( pTerm->fUTF8 ? 3 : 1 );
|
||||
#else
|
||||
nLineBufSize = pTerm->iWidth;
|
||||
#endif
|
||||
if( pTerm->nLineBufSize != nLineBufSize )
|
||||
{
|
||||
pTerm->pLineBuf = ( char * ) hb_xgrab( iWidth );
|
||||
pTerm->iLineBufSize = iWidth;
|
||||
}
|
||||
else if( pTerm->iLineBufSize != iWidth )
|
||||
{
|
||||
pTerm->pLineBuf = ( char * ) hb_xrealloc( pTerm->pLineBuf, iWidth );
|
||||
pTerm->iLineBufSize = iWidth;
|
||||
pTerm->pLineBuf = ( char * ) hb_xrealloc( pTerm->pLineBuf, nLineBufSize );
|
||||
pTerm->nLineBufSize = nLineBufSize;
|
||||
}
|
||||
|
||||
HB_GTSUPER_REFRESH( pGT );
|
||||
@@ -3602,7 +3685,8 @@ static void hb_gt_trm_Refresh( PHB_GT pGT )
|
||||
HB_GTSELF_GETSCRCURSOR( pGT, &iRow, &iCol, &iStyle );
|
||||
if( iStyle != SC_NONE )
|
||||
{
|
||||
if( iRow >= 0 && iCol >= 0 && iRow < iHeight && iCol < iWidth )
|
||||
if( iRow >= 0 && iCol >= 0 &&
|
||||
iRow < pTerm->iHeight && iCol < pTerm->iWidth )
|
||||
pTerm->SetCursorPos( pTerm, iRow, iCol );
|
||||
else
|
||||
iStyle = SC_NONE;
|
||||
@@ -3633,6 +3717,7 @@ static HB_BOOL hb_gt_trm_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
|
||||
pInfo->pResult = hb_itemPutL( pInfo->pResult, pTerm->fUTF8 );
|
||||
break;
|
||||
|
||||
#ifndef HB_GT_UNICODE_BUF
|
||||
case HB_GTI_BOXCP:
|
||||
pInfo->pResult = hb_itemPutC( pInfo->pResult,
|
||||
pTerm->cdpBox ? pTerm->cdpBox->id : NULL );
|
||||
@@ -3644,6 +3729,7 @@ static HB_BOOL hb_gt_trm_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
|
||||
pTerm->cdpBox = cdpBox;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
case HB_GTI_ESCDELAY:
|
||||
pInfo->pResult = hb_itemPutNI( pInfo->pResult, pTerm->esc_delay );
|
||||
@@ -3671,13 +3757,21 @@ static HB_BOOL hb_gt_trm_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
|
||||
if( pTerm->fUTF8 )
|
||||
pInfo->pResult = hb_itemPutStrUTF8( pInfo->pResult, pTerm->szTitle );
|
||||
else
|
||||
#ifdef HB_GT_UNICODE_BUF
|
||||
pInfo->pResult = hb_itemPutStr( pInfo->pResult, HB_GTSELF_TERMCP( pGT ), pTerm->szTitle );
|
||||
#else
|
||||
pInfo->pResult = hb_itemPutStr( pInfo->pResult, pTerm->cdpTerm, pTerm->szTitle );
|
||||
#endif
|
||||
if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING )
|
||||
{
|
||||
if( pTerm->fUTF8 )
|
||||
szVal = hb_itemGetStrUTF8( pInfo->pNewVal, &hVal, NULL );
|
||||
else
|
||||
#ifdef HB_GT_UNICODE_BUF
|
||||
szVal = hb_itemGetStr( pInfo->pNewVal, HB_GTSELF_TERMCP( pGT ), &hVal, NULL );
|
||||
#else
|
||||
szVal = hb_itemGetStr( pInfo->pNewVal, pTerm->cdpTerm, &hVal, NULL );
|
||||
#endif
|
||||
|
||||
if( pTerm->szTitle )
|
||||
hb_xfree( pTerm->szTitle );
|
||||
@@ -3746,7 +3840,9 @@ static HB_BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable )
|
||||
pFuncTable->SetMode = hb_gt_trm_SetMode;
|
||||
pFuncTable->SetBlink = hb_gt_trm_SetBlink;
|
||||
pFuncTable->SetDispCP = hb_gt_trm_SetDispCP;
|
||||
#ifndef HB_GT_UNICODE_BUF
|
||||
pFuncTable->SetKeyCP = hb_gt_trm_SetKeyCP;
|
||||
#endif
|
||||
pFuncTable->Tone = hb_gt_trm_Tone;
|
||||
pFuncTable->Bell = hb_gt_trm_Bell;
|
||||
pFuncTable->Info = hb_gt_trm_Info;
|
||||
|
||||
@@ -220,15 +220,6 @@ static DWORD s_cNumRead; /* Ok to use DWORD here, because this is spec
|
||||
static DWORD s_cNumIndex; /* ...to the Windows API, which defines DWORD, etc. */
|
||||
static WORD s_wRepeated = 0; /* number of times the event (key) was repeated */
|
||||
static INPUT_RECORD s_irInBuf[ INPUT_BUFFER_LEN ];
|
||||
#if defined( UNICODE )
|
||||
static PHB_CODEPAGE s_cdpHost;
|
||||
static PHB_CODEPAGE s_cdpBox;
|
||||
static PHB_CODEPAGE s_cdpIn;
|
||||
#else
|
||||
static HB_BYTE s_charTransRev[ 256 ];
|
||||
static HB_BYTE s_charTrans[ 256 ];
|
||||
static HB_BYTE s_keyTrans[ 256 ];
|
||||
#endif
|
||||
static int s_altisdown = 0;
|
||||
static int s_altnum = 0;
|
||||
static int s_mouseLast; /* Last mouse button to be pressed */
|
||||
@@ -618,16 +609,24 @@ static BOOL WINAPI hb_gt_win_CtrlHandler( DWORD dwCtrlType )
|
||||
static void hb_gt_win_xGetScreenContents( PHB_GT pGT, SMALL_RECT * psrWin )
|
||||
{
|
||||
int iRow, iCol, i;
|
||||
#if defined( UNICODE )
|
||||
PHB_CODEPAGE cdpHost;
|
||||
#if !defined( UNICODE )
|
||||
PHB_CODEPAGE cdp;
|
||||
HB_BYTE bxAttr;
|
||||
#endif
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_xGetScreenContents(%p,%p)", pGT, psrWin));
|
||||
|
||||
#if defined( UNICODE )
|
||||
cdpHost = s_cdpHost;
|
||||
if( !cdpHost )
|
||||
cdpHost = hb_vmCDP();
|
||||
#if !defined( UNICODE )
|
||||
bxAttr = 0;
|
||||
cdp = HB_GTSELF_CPTERM( pGT );
|
||||
if( !cdp )
|
||||
{
|
||||
cdp = HB_GTSELF_CPBOX( pGT );
|
||||
if( cdp )
|
||||
bxAttr = HB_GT_ATTR_BOX;
|
||||
else
|
||||
cdp = HB_GTSELF_HOSTCP( pGT );
|
||||
}
|
||||
#endif
|
||||
|
||||
for( iRow = psrWin->Top; iRow <= psrWin->Bottom; ++iRow )
|
||||
@@ -636,26 +635,13 @@ static void hb_gt_win_xGetScreenContents( PHB_GT pGT, SMALL_RECT * psrWin )
|
||||
for( iCol = psrWin->Left; iCol <= psrWin->Right; ++iCol )
|
||||
{
|
||||
#if defined( UNICODE )
|
||||
HB_WCHAR wc = s_pCharInfoScreen[ i ].Char.UnicodeChar;
|
||||
unsigned char uc;
|
||||
HB_BYTE bAttr = 0;
|
||||
|
||||
/* TODO: optimize it by creating conversion table - it can be
|
||||
* very slow in some cases
|
||||
*/
|
||||
|
||||
uc = hb_cdpGetChar( cdpHost, wc );
|
||||
if( uc == '?' && wc >= 0x100 && cdpHost != s_cdpBox )
|
||||
{
|
||||
uc = hb_cdpGetChar( s_cdpBox, wc );
|
||||
if( uc != '?' )
|
||||
bAttr |= HB_GT_ATTR_BOX;
|
||||
}
|
||||
HB_GTSELF_PUTSCRCHAR( pGT, iRow, iCol, ( HB_UCHAR ) s_pCharInfoScreen[ i ].Attributes,
|
||||
bAttr, uc );
|
||||
HB_GTSELF_PUTSCRCHAR( pGT, iRow, iCol,
|
||||
( HB_UCHAR ) s_pCharInfoScreen[ i ].Attributes, 0,
|
||||
s_pCharInfoScreen[ i ].Char.UnicodeChar );
|
||||
#else
|
||||
HB_GTSELF_PUTSCRCHAR( pGT, iRow, iCol, ( HB_UCHAR ) s_pCharInfoScreen[ i ].Attributes, 0,
|
||||
s_charTransRev[ ( HB_UCHAR ) s_pCharInfoScreen[ i ].Char.AsciiChar ] );
|
||||
HB_USHORT usChar = hb_cdpGetU16( cdp, ( HB_UCHAR ) s_pCharInfoScreen[ i ].Char.AsciiChar );
|
||||
HB_GTSELF_PUTSCRCHAR( pGT, iRow, iCol,
|
||||
( HB_UCHAR ) s_pCharInfoScreen[ i ].Attributes, bxAttr, usChar );
|
||||
#endif
|
||||
++i;
|
||||
}
|
||||
@@ -860,15 +846,6 @@ static void hb_gt_win_Init( PHB_GT pGT, HB_FHANDLE hFilenoStdin, HB_FHANDLE hFil
|
||||
s_bSpecialKeyHandling = HB_FALSE;
|
||||
s_bAltKeyHandling = HB_TRUE;
|
||||
|
||||
#if defined( UNICODE )
|
||||
/* s_cdpHost = s_cdpIn = hb_vmCDP(); */
|
||||
s_cdpBox = hb_cdpFind( "EN" );
|
||||
#else
|
||||
/* initialize code page translation */
|
||||
HB_GTSELF_SETDISPCP( pGT, NULL, NULL, HB_FALSE );
|
||||
HB_GTSELF_SETKEYCP( pGT, NULL, NULL );
|
||||
#endif
|
||||
|
||||
#ifndef HB_NO_ALLOC_CONSOLE
|
||||
/*
|
||||
* This is a hack for MSYS console. It does not support full screen output
|
||||
@@ -878,14 +855,13 @@ static void hb_gt_win_Init( PHB_GT pGT, HB_FHANDLE hFilenoStdin, HB_FHANDLE hFil
|
||||
* so I used this hack with checking OSTYPE environemnt variable. [druzus]
|
||||
*/
|
||||
{
|
||||
char * pszOsType;
|
||||
TCHAR lpOsType[ 10 ];
|
||||
|
||||
pszOsType = hb_getenv( "OSTYPE" );
|
||||
if( pszOsType )
|
||||
lpOsType[ 0 ] = lpOsType[ 9 ] = 0;
|
||||
if( GetEnvironmentVariable( TEXT( "OSTYPE" ), lpOsType, 9 ) > 0 )
|
||||
{
|
||||
if( strcmp( pszOsType, "msys" ) == 0 )
|
||||
if( lstrcmp( lpOsType, TEXT( "msys" ) ) == 0 )
|
||||
FreeConsole();
|
||||
hb_xfree( pszOsType );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1509,7 +1485,6 @@ static int hb_gt_win_ReadKey( PHB_GT pGT, int iEventMask )
|
||||
|
||||
#if defined( UNICODE )
|
||||
ch = s_irInBuf[ s_cNumIndex ].Event.KeyEvent.uChar.UnicodeChar;
|
||||
ch = hb_cdpGetChar( s_cdpIn ? s_cdpIn : hb_vmCDP(), ( HB_WCHAR ) ch );
|
||||
#else
|
||||
ch = s_irInBuf[ s_cNumIndex ].Event.KeyEvent.uChar.AsciiChar;
|
||||
#endif
|
||||
@@ -1636,11 +1611,16 @@ static int hb_gt_win_ReadKey( PHB_GT pGT, int iEventMask )
|
||||
if( ch == 0 ) /* for keys that are only on shift or AltGr */
|
||||
ch = clipKey->key;
|
||||
}
|
||||
|
||||
/* national codepage translation */
|
||||
#if !defined( UNICODE )
|
||||
if( ch > 0 && ch <= 255 )
|
||||
ch = s_keyTrans[ ch ];
|
||||
#if defined( UNICODE )
|
||||
else if( ch >= 127 )
|
||||
ch = HB_INKEY_NEW_UNICODE( ch );
|
||||
#else
|
||||
else
|
||||
{
|
||||
int u = HB_GTSELF_KEYTRANS( pGT, ch );
|
||||
if( u )
|
||||
ch = HB_INKEY_NEW_UNICODE( u );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1722,106 +1702,6 @@ static void hb_gt_win_Tone( PHB_GT pGT, double dFrequency, double dDuration )
|
||||
|
||||
/* *********************************************************************** */
|
||||
|
||||
static HB_BOOL hb_gt_win_SetDispCP( PHB_GT pGT, const char *pszTermCDP, const char *pszHostCDP, HB_BOOL fBox )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_SetDispCP(%p,%s,%s,%d)", pGT, pszTermCDP, pszHostCDP, (int) fBox));
|
||||
|
||||
HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox );
|
||||
|
||||
# if defined( UNICODE )
|
||||
/*
|
||||
* We are displaying text in U16 so pszTermCDP is unimportant.
|
||||
* We only have to know what is the internal application codepage
|
||||
* to make proper translation
|
||||
*/
|
||||
if( !pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
|
||||
if( pszHostCDP )
|
||||
{
|
||||
PHB_CODEPAGE cdpHost = hb_cdpFind( pszHostCDP );
|
||||
if( cdpHost )
|
||||
{
|
||||
s_cdpHost = cdpHost;
|
||||
s_cdpBox = fBox ? cdpHost : hb_cdpFind( "EN" );
|
||||
}
|
||||
}
|
||||
# else
|
||||
{
|
||||
PHB_CODEPAGE cdpTerm, cdpHost;
|
||||
int i;
|
||||
|
||||
if( !pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
|
||||
if( !pszTermCDP )
|
||||
pszTermCDP = pszHostCDP;
|
||||
|
||||
cdpTerm = hb_cdpFind( pszTermCDP );
|
||||
cdpHost = hb_cdpFind( pszHostCDP );
|
||||
|
||||
for( i = 0; i < 256; i++ )
|
||||
{
|
||||
s_charTrans[ i ] = ( HB_BYTE )
|
||||
hb_cdpTranslateDispChar( i, cdpHost, cdpTerm );
|
||||
s_charTransRev[ i ] = ( HB_BYTE )
|
||||
hb_cdpTranslateDispChar( i, cdpTerm, cdpHost );
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
/* *********************************************************************** */
|
||||
|
||||
static HB_BOOL hb_gt_win_SetKeyCP( PHB_GT pGT, const char *pszTermCDP, const char *pszHostCDP )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_SetKeyCP(%p,%s,%s)", pGT, pszTermCDP, pszHostCDP));
|
||||
|
||||
HB_GTSUPER_SETKEYCP( pGT, pszTermCDP, pszHostCDP );
|
||||
|
||||
# if defined( UNICODE )
|
||||
/*
|
||||
* We are receiving WM_CHAR events in U16 so pszTermCDP is unimportant.
|
||||
* We only have to know what is the internal application codepage
|
||||
* to make proper translation
|
||||
*/
|
||||
if( !pszHostCDP || !*pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
|
||||
if( pszHostCDP && *pszHostCDP )
|
||||
{
|
||||
PHB_CODEPAGE cdpHost = hb_cdpFind( pszHostCDP );
|
||||
if( cdpHost )
|
||||
s_cdpIn = cdpHost;
|
||||
}
|
||||
|
||||
# else
|
||||
{
|
||||
PHB_CODEPAGE cdpTerm, cdpHost;
|
||||
int i;
|
||||
|
||||
if( !pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
|
||||
if( !pszTermCDP )
|
||||
pszTermCDP = pszHostCDP;
|
||||
|
||||
cdpTerm = hb_cdpFind( pszTermCDP );
|
||||
cdpHost = hb_cdpFind( pszHostCDP );
|
||||
|
||||
for( i = 0; i < 256; i++ )
|
||||
s_keyTrans[ i ] = ( HB_BYTE )
|
||||
hb_cdpTranslateChar( i, cdpTerm, cdpHost );
|
||||
}
|
||||
# endif
|
||||
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
/* *********************************************************************** */
|
||||
|
||||
static HB_BOOL hb_gt_win_IsFullScreen( void )
|
||||
{
|
||||
DWORD dwModeFlags;
|
||||
@@ -1904,18 +1784,6 @@ static HB_BOOL hb_gt_win_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HB_GTI_BOXCP:
|
||||
#if defined( UNICODE )
|
||||
pInfo->pResult = hb_itemPutC( pInfo->pResult,
|
||||
s_cdpBox ? s_cdpBox->id : NULL );
|
||||
if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING )
|
||||
{
|
||||
PHB_CODEPAGE cdpBox = hb_cdpFind( hb_itemGetCPtr( pInfo->pNewVal ) );
|
||||
if( cdpBox )
|
||||
s_cdpBox = cdpBox;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case HB_GTI_WINTITLE:
|
||||
{
|
||||
@@ -2131,20 +1999,21 @@ static void hb_gt_win_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
|
||||
{
|
||||
int iColor;
|
||||
HB_BYTE bAttr;
|
||||
HB_USHORT usChar;
|
||||
int iFirst = iCol;
|
||||
int i = ( iRow * _GetScreenWidth() + iCol );
|
||||
|
||||
while( iSize-- > 0 )
|
||||
{
|
||||
#if defined( UNICODE )
|
||||
HB_USHORT usChar;
|
||||
if( !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol++, &iColor, &bAttr, &usChar ) )
|
||||
break;
|
||||
#if defined( UNICODE )
|
||||
s_pCharInfoScreen[ i ].Char.UnicodeChar =
|
||||
hb_cdpGetU16Disp( bAttr & HB_GT_ATTR_BOX ? s_cdpBox : s_cdpHost,
|
||||
( HB_UCHAR ) usChar );
|
||||
s_pCharInfoScreen[ i ].Char.UnicodeChar = hb_cdpGetU16Ctrl( usChar );
|
||||
#else
|
||||
s_pCharInfoScreen[ i ].Char.AsciiChar = ( CHAR ) s_charTrans[ usChar & 0xFF ];
|
||||
HB_UCHAR uc;
|
||||
if( !HB_GTSELF_GETSCRUC( pGT, iRow, iCol++, &iColor, &bAttr, &uc, HB_TRUE ) )
|
||||
break;
|
||||
s_pCharInfoScreen[ i ].Char.AsciiChar = ( CHAR ) uc;
|
||||
#endif
|
||||
s_pCharInfoScreen[ i ].Attributes = ( WORD ) ( iColor & 0xFF );
|
||||
++i;
|
||||
@@ -2160,36 +2029,24 @@ static void hb_gt_win_Refresh( PHB_GT pGT )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ("hb_gt_win_Refresh(%p)", pGT) );
|
||||
|
||||
HB_GTSUPER_REFRESH( pGT );
|
||||
if( s_pCharInfoScreen )
|
||||
{
|
||||
#if defined( UNICODE )
|
||||
PHB_CODEPAGE cdpHost = s_cdpHost;
|
||||
if( !cdpHost )
|
||||
s_cdpHost = hb_vmCDP();
|
||||
#endif
|
||||
int iRow, iCol, iStyle;
|
||||
|
||||
HB_GTSUPER_REFRESH( pGT );
|
||||
HB_GTSELF_GETSCRCURSOR( pGT, &iRow, &iCol, &iStyle );
|
||||
|
||||
if( s_pCharInfoScreen )
|
||||
{
|
||||
int iRow, iCol, iStyle;
|
||||
s_iCurRow = iRow;
|
||||
s_iCurCol = iCol;
|
||||
|
||||
HB_GTSELF_GETSCRCURSOR( pGT, &iRow, &iCol, &iStyle );
|
||||
if( iRow < 0 || iCol < 0 ||
|
||||
iRow >= ( int ) _GetScreenHeight() ||
|
||||
iCol >= ( int ) _GetScreenWidth() )
|
||||
s_iCursorStyle = SC_NONE;
|
||||
else
|
||||
s_iCursorStyle = iStyle;
|
||||
|
||||
s_iCurRow = iRow;
|
||||
s_iCurCol = iCol;
|
||||
|
||||
if( iRow < 0 || iCol < 0 ||
|
||||
iRow >= ( int ) _GetScreenHeight() ||
|
||||
iCol >= ( int ) _GetScreenWidth() )
|
||||
s_iCursorStyle = SC_NONE;
|
||||
else
|
||||
s_iCursorStyle = iStyle;
|
||||
|
||||
hb_gt_win_xScreenUpdate();
|
||||
}
|
||||
#if defined( UNICODE )
|
||||
s_cdpHost = cdpHost;
|
||||
#endif
|
||||
hb_gt_win_xScreenUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2210,9 +2067,6 @@ static HB_BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable )
|
||||
pFuncTable->Resume = hb_gt_win_Resume;
|
||||
pFuncTable->Tone = hb_gt_win_Tone;
|
||||
pFuncTable->Info = hb_gt_win_Info;
|
||||
pFuncTable->SetDispCP = hb_gt_win_SetDispCP;
|
||||
pFuncTable->SetKeyCP = hb_gt_win_SetKeyCP;
|
||||
|
||||
pFuncTable->ReadKey = hb_gt_win_ReadKey;
|
||||
|
||||
pFuncTable->MouseIsPresent = hb_gt_win_mouse_IsPresent;
|
||||
|
||||
@@ -379,17 +379,6 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, HINSTANCE hInstance, int iCmdShow )
|
||||
pWVT->bResizing = HB_FALSE;
|
||||
pWVT->bAlreadySizing = HB_FALSE;
|
||||
|
||||
#if defined( UNICODE )
|
||||
/* pWVT->hostCDP = pWVT->inCDP = hb_vmCDP(); */
|
||||
pWVT->boxCDP = hb_cdpFind( "EN" );
|
||||
#else
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < 256; ++i )
|
||||
pWVT->chrTransTbl[ i ] = pWVT->keyTransTbl[ i ] = ( HB_BYTE ) i;
|
||||
}
|
||||
#endif
|
||||
|
||||
return pWVT;
|
||||
}
|
||||
|
||||
@@ -693,7 +682,7 @@ static void hb_gt_wvt_FitSize( PHB_GTWVT pWVT )
|
||||
tm.tmAveCharWidth >= 4 &&
|
||||
tm.tmHeight >= 8 )
|
||||
{
|
||||
#if ! defined( UNICODE )
|
||||
#if !defined( UNICODE )
|
||||
if( pWVT->hFontBox && pWVT->hFontBox != pWVT->hFont )
|
||||
DeleteObject( pWVT->hFontBox );
|
||||
|
||||
@@ -814,7 +803,7 @@ static void hb_gt_wvt_ResetWindowSize( PHB_GTWVT pWVT, HFONT hFont )
|
||||
if( !hFont )
|
||||
hFont = hb_gt_wvt_GetFont( pWVT->fontFace, pWVT->fontHeight, pWVT->fontWidth,
|
||||
pWVT->fontWeight, pWVT->fontQuality, pWVT->CodePage );
|
||||
#if ! defined( UNICODE )
|
||||
#if !defined( UNICODE )
|
||||
if( pWVT->hFont )
|
||||
DeleteObject( pWVT->hFont );
|
||||
if( pWVT->hFontBox && pWVT->hFontBox != pWVT->hFont )
|
||||
@@ -1119,9 +1108,13 @@ static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, L
|
||||
RedrawWindow( pWVT->hWnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW );
|
||||
|
||||
{
|
||||
#if !defined( UNICODE )
|
||||
PHB_CODEPAGE cdpHost = HB_GTSELF_HOSTCP( pWVT->pGT ),
|
||||
cdpBox = HB_GTSELF_BOXCP( pWVT->pGT );
|
||||
#endif
|
||||
TCHAR * sBuffer;
|
||||
HB_SIZE nSize;
|
||||
int irow, icol, j, top, left, bottom, right;
|
||||
char * sBuffer;
|
||||
RECT rect = { 0, 0, 0, 0 };
|
||||
RECT colrowRC = { 0, 0, 0, 0 };
|
||||
|
||||
@@ -1138,7 +1131,7 @@ static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, L
|
||||
bottom = colrowRC.bottom;
|
||||
|
||||
nSize = ( ( bottom - top + 1 ) * ( right - left + 1 + 2 ) );
|
||||
sBuffer = ( char * ) hb_xgrab( nSize + 1 );
|
||||
sBuffer = ( TCHAR * ) hb_xgrab( nSize * sizeof( TCHAR ) + 1 );
|
||||
|
||||
for( j = 0, irow = top; irow <= bottom; irow++ )
|
||||
{
|
||||
@@ -1150,27 +1143,36 @@ static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, L
|
||||
|
||||
if( !HB_GTSELF_GETSCRCHAR( pWVT->pGT, irow, icol, &iColor, &bAttr, &usChar ) )
|
||||
break;
|
||||
|
||||
sBuffer[ j++ ] = ( char ) usChar;
|
||||
#if defined( UNICODE )
|
||||
usChar = hb_cdpGetU16Ctrl( usChar );
|
||||
#else
|
||||
usChar = hb_cdpGetUC( bAttr & HB_GT_ATTR_BOX ? cdpBox : cdpHost, usChar, '?' );
|
||||
#endif
|
||||
sBuffer[ j++ ] = ( TCHAR ) usChar;
|
||||
}
|
||||
|
||||
sBuffer[ j++ ] = '\r';
|
||||
sBuffer[ j++ ] = '\n';
|
||||
}
|
||||
|
||||
#if defined( UNICODE )
|
||||
if( j > 0 )
|
||||
{
|
||||
PHB_ITEM pItem = hb_itemPutStrLenU16( NULL, HB_CDP_ENDIAN_NATIVE, sBuffer, j );
|
||||
hb_gt_winapi_setClipboard( CF_UNICODETEXT, pItem );
|
||||
hb_itemRelease( pItem );
|
||||
}
|
||||
hb_xfree( sBuffer );
|
||||
#else
|
||||
if( j > 0 )
|
||||
{
|
||||
PHB_ITEM pItem = hb_itemPutCLPtr( NULL, sBuffer, j );
|
||||
#if defined( UNICODE )
|
||||
hb_gt_winapi_setClipboard( CF_UNICODETEXT, pItem );
|
||||
#else
|
||||
hb_gt_winapi_setClipboard( pWVT->CodePage == OEM_CHARSET ?
|
||||
CF_OEMTEXT : CF_TEXT, pItem );
|
||||
#endif
|
||||
hb_itemRelease( pItem );
|
||||
}
|
||||
else
|
||||
hb_xfree( sBuffer );
|
||||
#endif
|
||||
}
|
||||
|
||||
hb_gt_wvt_Composited( pWVT, HB_TRUE );
|
||||
@@ -1444,16 +1446,16 @@ static HB_BOOL hb_gt_wvt_KeyEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam,
|
||||
break;
|
||||
default:
|
||||
#if defined( UNICODE )
|
||||
c = hb_cdpGetChar( pWVT->inCDP ? pWVT->inCDP : hb_vmCDP(),
|
||||
( HB_WCHAR ) c );
|
||||
if( c >= 127 )
|
||||
c = HB_INKEY_NEW_UNICODE( c );
|
||||
#else
|
||||
if( pWVT->fKeyTrans )
|
||||
{
|
||||
if( c > 0 && c <= 255 && pWVT->keyTransTbl[ c ] )
|
||||
c = pWVT->keyTransTbl[ c ];
|
||||
int u = HB_GTSELF_KEYTRANS( pWVT->pGT, c );
|
||||
if( u )
|
||||
c = HB_INKEY_NEW_UNICODE( u );
|
||||
else if( pWVT->CodePage == OEM_CHARSET )
|
||||
c = hb_gt_wvt_key_ansi_to_oem( c );
|
||||
}
|
||||
else if( pWVT->CodePage == OEM_CHARSET )
|
||||
c = hb_gt_wvt_key_ansi_to_oem( c );
|
||||
#endif
|
||||
hb_gt_wvt_AddCharToInputQueue( pWVT, c );
|
||||
break;
|
||||
@@ -1630,12 +1632,9 @@ static void hb_gt_wvt_PaintText( PHB_GTWVT pWVT )
|
||||
int iRow, iCol, startCol, len;
|
||||
int iColor, iOldColor = 0;
|
||||
HB_BYTE bAttr;
|
||||
#if defined( UNICODE )
|
||||
PHB_CODEPAGE hostCDP;
|
||||
#else
|
||||
#if !defined( UNICODE )
|
||||
HFONT hFont, hOldFont = NULL;
|
||||
#endif
|
||||
HB_USHORT usChar;
|
||||
|
||||
hdc = BeginPaint( pWVT->hWnd, &ps );
|
||||
|
||||
@@ -1698,7 +1697,6 @@ static void hb_gt_wvt_PaintText( PHB_GTWVT pWVT )
|
||||
|
||||
#if defined( UNICODE )
|
||||
SelectObject( hdc, pWVT->hFont );
|
||||
hostCDP = pWVT->hostCDP ? pWVT->hostCDP : hb_vmCDP();
|
||||
#endif
|
||||
|
||||
rcRect = hb_gt_wvt_GetColRowFromXYRect( pWVT, ps.rcPaint );
|
||||
@@ -1710,15 +1708,16 @@ static void hb_gt_wvt_PaintText( PHB_GTWVT pWVT )
|
||||
|
||||
while( iCol <= rcRect.right )
|
||||
{
|
||||
#if defined( UNICODE )
|
||||
HB_USHORT usChar;
|
||||
if( !HB_GTSELF_GETSCRCHAR( pWVT->pGT, iRow, iCol, &iColor, &bAttr, &usChar ) )
|
||||
break;
|
||||
usChar = hb_cdpGetU16Ctrl( usChar );
|
||||
|
||||
/* as long as GTWVT uses only 16 colors we can ignore other bits
|
||||
* and not divide output when it does not change anythings
|
||||
*/
|
||||
iColor &= 0xff;
|
||||
#if defined( UNICODE )
|
||||
usChar = hb_cdpGetU16Disp( bAttr & HB_GT_ATTR_BOX ? pWVT->boxCDP : hostCDP, ( HB_BYTE ) usChar );
|
||||
if( len == 0 )
|
||||
{
|
||||
iOldColor = iColor;
|
||||
@@ -1730,8 +1729,11 @@ static void hb_gt_wvt_PaintText( PHB_GTWVT pWVT )
|
||||
startCol = iCol;
|
||||
len = 0;
|
||||
}
|
||||
pWVT->TextLine[ len++ ] = ( TCHAR ) usChar;
|
||||
#else
|
||||
usChar = pWVT->chrTransTbl[ usChar & 0xFF ];
|
||||
HB_UCHAR uc;
|
||||
if( !HB_GTSELF_GETSCRUC( pWVT->pGT, iRow, iCol, &iColor, &bAttr, &uc, HB_TRUE ) )
|
||||
break;
|
||||
hFont = ( bAttr & HB_GT_ATTR_BOX ) ? pWVT->hFontBox : pWVT->hFont;
|
||||
if( len == 0 )
|
||||
{
|
||||
@@ -1754,8 +1756,8 @@ static void hb_gt_wvt_PaintText( PHB_GTWVT pWVT )
|
||||
startCol = iCol;
|
||||
len = 0;
|
||||
}
|
||||
pWVT->TextLine[ len++ ] = ( TCHAR ) uc;
|
||||
#endif
|
||||
pWVT->TextLine[ len++ ] = ( TCHAR ) usChar;
|
||||
iCol++;
|
||||
}
|
||||
if( len > 0 )
|
||||
@@ -2620,17 +2622,8 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
|
||||
}
|
||||
break;
|
||||
|
||||
#if !defined( UNICODE )
|
||||
case HB_GTI_BOXCP:
|
||||
#if defined( UNICODE )
|
||||
pInfo->pResult = hb_itemPutC( pInfo->pResult,
|
||||
pWVT->boxCDP ? pWVT->boxCDP->id : NULL );
|
||||
if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING )
|
||||
{
|
||||
PHB_CODEPAGE cdpBox = hb_cdpFind( hb_itemGetCPtr( pInfo->pNewVal ) );
|
||||
if( cdpBox )
|
||||
pWVT->boxCDP = cdpBox;
|
||||
}
|
||||
#else
|
||||
pInfo->pResult = hb_itemPutNI( pInfo->pResult, pWVT->boxCodePage );
|
||||
if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC )
|
||||
{
|
||||
@@ -2665,8 +2658,8 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
|
||||
case HB_GTI_ICONFILE:
|
||||
{
|
||||
@@ -3206,105 +3199,6 @@ static void hb_gt_wvt_Refresh( PHB_GT pGT )
|
||||
}
|
||||
}
|
||||
|
||||
/* ********************************************************************** */
|
||||
|
||||
static HB_BOOL hb_gt_wvt_SetDispCP( PHB_GT pGT, const char * pszTermCDP, const char * pszHostCDP, HB_BOOL fBox )
|
||||
{
|
||||
HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox );
|
||||
|
||||
# if defined( UNICODE )
|
||||
/*
|
||||
* We are displaying text in U16 so pszTermCDP is unimportant.
|
||||
* We only have to know what is the internal application codepage
|
||||
* to make proper translation
|
||||
*/
|
||||
if( !pszHostCDP || !*pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
|
||||
if( pszHostCDP && *pszHostCDP )
|
||||
{
|
||||
PHB_CODEPAGE cdpHost = hb_cdpFind( pszHostCDP );
|
||||
if( cdpHost )
|
||||
{
|
||||
PHB_GTWVT pWVT = HB_GTWVT_GET( pGT );
|
||||
|
||||
pWVT->hostCDP = cdpHost;
|
||||
pWVT->boxCDP = fBox ? cdpHost : hb_cdpFind( "EN" );
|
||||
}
|
||||
}
|
||||
# else
|
||||
{
|
||||
PHB_GTWVT pWVT = HB_GTWVT_GET( pGT );
|
||||
PHB_CODEPAGE cdpTerm, cdpHost;
|
||||
int i;
|
||||
|
||||
if( !pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
|
||||
if( !pszTermCDP )
|
||||
pszTermCDP = pszHostCDP;
|
||||
|
||||
cdpTerm = hb_cdpFind( pszTermCDP );
|
||||
cdpHost = hb_cdpFind( pszHostCDP );
|
||||
|
||||
for( i = 0; i < 256; i++ )
|
||||
{
|
||||
pWVT->chrTransTbl[ i ] = ( HB_BYTE )
|
||||
hb_cdpTranslateDispChar( i, cdpHost, cdpTerm );
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
static HB_BOOL hb_gt_wvt_SetKeyCP( PHB_GT pGT, const char * pszTermCDP, const char * pszHostCDP )
|
||||
{
|
||||
HB_GTSUPER_SETKEYCP( pGT, pszTermCDP, pszHostCDP );
|
||||
|
||||
# if defined( UNICODE )
|
||||
/*
|
||||
* We are receiving WM_CHAR events in U16 so pszTermCDP is unimportant.
|
||||
* We only have to know what is the internal application codepage
|
||||
* to make proper translation
|
||||
*/
|
||||
if( !pszHostCDP || !*pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
|
||||
if( pszHostCDP && *pszHostCDP )
|
||||
{
|
||||
PHB_CODEPAGE cdpHost = hb_cdpFind( pszHostCDP );
|
||||
if( cdpHost )
|
||||
HB_GTWVT_GET( pGT )->inCDP = cdpHost;
|
||||
}
|
||||
# else
|
||||
{
|
||||
PHB_GTWVT pWVT = HB_GTWVT_GET( pGT );
|
||||
PHB_CODEPAGE cdpTerm, cdpHost;
|
||||
int i;
|
||||
|
||||
if( !pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
|
||||
if( !pszTermCDP )
|
||||
pszTermCDP = pszHostCDP;
|
||||
|
||||
cdpTerm = hb_cdpFind( pszTermCDP );
|
||||
cdpHost = hb_cdpFind( pszHostCDP );
|
||||
|
||||
for( i = 0; i < 256; i++ )
|
||||
{
|
||||
pWVT->keyTransTbl[ i ] = ( HB_BYTE )
|
||||
hb_cdpTranslateChar( i, cdpTerm, cdpHost );
|
||||
}
|
||||
pWVT->fKeyTrans = HB_TRUE;
|
||||
}
|
||||
# endif
|
||||
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* ********************************************************************** */
|
||||
|
||||
static HB_BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable )
|
||||
@@ -3319,8 +3213,6 @@ static HB_BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable )
|
||||
pFuncTable->Version = hb_gt_wvt_Version;
|
||||
pFuncTable->Tone = hb_gt_wvt_Tone;
|
||||
pFuncTable->Info = hb_gt_wvt_Info;
|
||||
pFuncTable->SetDispCP = hb_gt_wvt_SetDispCP;
|
||||
pFuncTable->SetKeyCP = hb_gt_wvt_SetKeyCP;
|
||||
pFuncTable->ReadKey = hb_gt_wvt_ReadKey;
|
||||
|
||||
pFuncTable->MouseIsPresent = hb_gt_wvt_mouse_IsPresent;
|
||||
|
||||
@@ -152,19 +152,6 @@ typedef struct
|
||||
HWND hWnd; /* the window handle */
|
||||
HB_BOOL fInit; /* logical variable indicating that window should be open */
|
||||
|
||||
#if defined( UNICODE )
|
||||
PHB_CODEPAGE inCDP; /* Host/HVM CodePage for unicode input translations */
|
||||
PHB_CODEPAGE hostCDP; /* Host/HVM CodePage for unicode output translations */
|
||||
PHB_CODEPAGE boxCDP; /* CodePage for legacy drawing chars: IBM437 */
|
||||
#else
|
||||
HB_BOOL fKeyTrans; /* logical variable indicating that CP key translation is enabled */
|
||||
#endif
|
||||
|
||||
#if !defined( UNICODE )
|
||||
HB_BYTE keyTransTbl[ 256 ];
|
||||
HB_BYTE chrTransTbl[ 256 ];
|
||||
#endif
|
||||
|
||||
HICON hIcon; /* Title Bar and Task List icon. Can be NULL. */
|
||||
HB_BOOL bIconToFree; /* Do we need to free this icon when it's not NULL? */
|
||||
|
||||
|
||||
@@ -57,11 +57,14 @@
|
||||
/* #define XWC_DEBUG */
|
||||
/* #define HB_XWC_USE_LOCALE */
|
||||
|
||||
|
||||
#include "gtxwc.h"
|
||||
#ifdef HB_XWC_USE_LOCALE
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
/* #undef X_HAVE_UTF8_STRING */
|
||||
|
||||
static int s_GtId;
|
||||
static HB_GT_FUNCS SuperTable;
|
||||
#define HB_GTSUPER (&SuperTable)
|
||||
@@ -360,22 +363,15 @@ typedef struct
|
||||
using build in font ones */
|
||||
HB_BOOL fDrawBox;
|
||||
|
||||
/* locale set to UTF-8 or X_HAVE_UTF8_STRING */
|
||||
HB_BOOL fUTF8key;
|
||||
PHB_CODEPAGE utf8CDP;
|
||||
|
||||
#ifdef X_HAVE_UTF8_STRING
|
||||
XIM im;
|
||||
XIC ic;
|
||||
#endif
|
||||
|
||||
#ifdef HB_XWC_USE_LOCALE
|
||||
/* locale set to UTF-8 */
|
||||
HB_BOOL fUTF8;
|
||||
#endif
|
||||
/* CodePage support */
|
||||
PHB_CODEPAGE hostCDP;
|
||||
/* PHB_CODEPAGE outCDP; */
|
||||
PHB_CODEPAGE utf8CDP;
|
||||
PHB_CODEPAGE boxCDP;
|
||||
PHB_CODEPAGE inCDP;
|
||||
|
||||
/* current cursor and color settings */
|
||||
int col;
|
||||
int row;
|
||||
@@ -403,9 +399,10 @@ typedef struct
|
||||
/* current screen contents (attr<<24)|(color<<16)|char */
|
||||
HB_ULONG * pCurrScr;
|
||||
|
||||
/* character translation table, it changes characters in screen buffer into UNICODE or graphs primitives */
|
||||
XWC_CharTrans charTrans[ 256 ];
|
||||
XWC_CharTrans boxTrans[ 256 ];
|
||||
/* character translation table, it changes some characters in screen buffer into graphs primitives */
|
||||
XWC_CharTrans boxTrans[ HB_GTXWC_TRANS_MAX ];
|
||||
HB_UCHAR boxIndex[ HB_GTXWC_TRANS_COUNT ];
|
||||
int transCount;
|
||||
|
||||
HB_BOOL fInvalidChr;
|
||||
XWC_RECT rInvalidChr;
|
||||
@@ -440,7 +437,7 @@ typedef struct
|
||||
static void hb_gt_xwc_ProcessMessages( PXWND_DEF wnd );
|
||||
static void hb_gt_xwc_InvalidatePts( PXWND_DEF wnd, int left, int top, int right, int bottom );
|
||||
static void hb_gt_xwc_InvalidateChar( PXWND_DEF wnd, int left, int top, int right, int bottom );
|
||||
static void hb_gt_xwc_SetSelection( PXWND_DEF wnd, const char * szData, HB_SIZE ulSize );
|
||||
static void hb_gt_xwc_SetSelection( PXWND_DEF wnd, const char * szData, HB_SIZE ulSize, HB_BOOL fCopy );
|
||||
|
||||
/************************ globals ********************************/
|
||||
|
||||
@@ -595,7 +592,7 @@ static HB_BOOL hb_gt_xwc_DefineBoxChar( PXWND_DEF wnd, HB_USHORT usCh, XWC_CharT
|
||||
XSegment * segs = chdef.segs;
|
||||
XRectangle * rect = chdef.rect;
|
||||
XPoint * pts = chdef.pts;
|
||||
XWC_CharType type = CH_CHAR;
|
||||
XWC_CharType type = CH_UNDEF;
|
||||
int size = 0;
|
||||
HB_BOOL inverse = HB_FALSE;
|
||||
|
||||
@@ -1017,51 +1014,63 @@ static HB_BOOL hb_gt_xwc_DefineBoxChar( PXWND_DEF wnd, HB_USHORT usCh, XWC_CharT
|
||||
break;
|
||||
|
||||
case HB_GTXWC_RC_0:
|
||||
bxCh->u.ch16 = '0';
|
||||
type = CH_CHAR;
|
||||
usCh = '0';
|
||||
/* TODO */
|
||||
break;
|
||||
case HB_GTXWC_RC_1:
|
||||
bxCh->u.ch16 = '1';
|
||||
type = CH_CHAR;
|
||||
usCh = '1';
|
||||
/* TODO */
|
||||
break;
|
||||
case HB_GTXWC_RC_2:
|
||||
bxCh->u.ch16 = '2';
|
||||
type = CH_CHAR;
|
||||
usCh = '2';
|
||||
/* TODO */
|
||||
break;
|
||||
case HB_GTXWC_RC_3:
|
||||
bxCh->u.ch16 = '3';
|
||||
type = CH_CHAR;
|
||||
usCh = '3';
|
||||
/* TODO */
|
||||
break;
|
||||
case HB_GTXWC_RC_4:
|
||||
bxCh->u.ch16 = '4';
|
||||
type = CH_CHAR;
|
||||
usCh = '4';
|
||||
/* TODO */
|
||||
break;
|
||||
case HB_GTXWC_RC_5:
|
||||
bxCh->u.ch16 = '5';
|
||||
type = CH_CHAR;
|
||||
usCh = '5';
|
||||
/* TODO */
|
||||
break;
|
||||
case HB_GTXWC_RC_6:
|
||||
bxCh->u.ch16 = '6';
|
||||
type = CH_CHAR;
|
||||
usCh = '6';
|
||||
/* TODO */
|
||||
break;
|
||||
case HB_GTXWC_RC_7:
|
||||
bxCh->u.ch16 = '7';
|
||||
type = CH_CHAR;
|
||||
usCh = '7';
|
||||
/* TODO */
|
||||
break;
|
||||
case HB_GTXWC_RC_8:
|
||||
bxCh->u.ch16 = '8';
|
||||
type = CH_CHAR;
|
||||
usCh = '8';
|
||||
/* TODO */
|
||||
break;
|
||||
case HB_GTXWC_RC_9:
|
||||
bxCh->u.ch16 = '9';
|
||||
type = CH_CHAR;
|
||||
usCh = '9';
|
||||
/* TODO */
|
||||
break;
|
||||
case HB_GTXWC_RC_DOT:
|
||||
bxCh->u.ch16 = '.';
|
||||
type = CH_CHAR;
|
||||
usCh = '.';
|
||||
/* TODO */
|
||||
break;
|
||||
case HB_GTXWC_RC_ACC:
|
||||
bxCh->u.ch16 = '\'';
|
||||
type = CH_CHAR;
|
||||
usCh = '\'';
|
||||
/* TODO */
|
||||
break;
|
||||
|
||||
@@ -2389,7 +2398,7 @@ static HB_BOOL hb_gt_xwc_DefineBoxChar( PXWND_DEF wnd, HB_USHORT usCh, XWC_CharT
|
||||
*/
|
||||
}
|
||||
|
||||
if( type != CH_CHAR )
|
||||
if( type != CH_UNDEF )
|
||||
{
|
||||
bxCh->type = type;
|
||||
bxCh->u.ch16 = usCh;
|
||||
@@ -2421,72 +2430,99 @@ static HB_BOOL hb_gt_xwc_DefineBoxChar( PXWND_DEF wnd, HB_USHORT usCh, XWC_CharT
|
||||
|
||||
/* *********************************************************************** */
|
||||
|
||||
static void hb_gt_xwc_ClearCharTrans( XWC_CharTrans * charTrans )
|
||||
static void hb_gt_xwc_ResetCharTrans( PXWND_DEF wnd )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < 256; i++ )
|
||||
for( i = 0; i <= wnd->transCount; i++ )
|
||||
{
|
||||
switch( charTrans[ i ].type )
|
||||
switch( wnd->boxTrans[ i ].type )
|
||||
{
|
||||
case CH_IMG:
|
||||
XDestroyImage( charTrans[ i ].u.img );
|
||||
XDestroyImage( wnd->boxTrans[ i ].u.img );
|
||||
break;
|
||||
case CH_SEG:
|
||||
hb_xfree( charTrans[ i ].u.seg );
|
||||
hb_xfree( wnd->boxTrans[ i ].u.seg );
|
||||
break;
|
||||
case CH_RECT:
|
||||
hb_xfree( charTrans[ i ].u.rect );
|
||||
hb_xfree( wnd->boxTrans[ i ].u.rect );
|
||||
break;
|
||||
case CH_PTS:
|
||||
case CH_LINE:
|
||||
case CH_POLY:
|
||||
hb_xfree( charTrans[ i ].u.pts );
|
||||
hb_xfree( wnd->boxTrans[ i ].u.pts );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
memset( charTrans, 0, 256 * sizeof( XWC_CharTrans ) );
|
||||
}
|
||||
memset( wnd->boxTrans, 0, sizeof( wnd->boxTrans ) );
|
||||
wnd->transCount = 0;
|
||||
|
||||
static void hb_gt_xwc_DestroyCharTrans( PXWND_DEF wnd )
|
||||
{
|
||||
hb_gt_xwc_ClearCharTrans( wnd->charTrans );
|
||||
hb_gt_xwc_ClearCharTrans( wnd->boxTrans );
|
||||
wnd->boxTrans[ 0 ].type = CH_CHAR;
|
||||
wnd->boxTrans[ 0 ].u.ch16 = 0;
|
||||
wnd->boxTrans[ 0 ].size = 0;
|
||||
wnd->boxTrans[ 0 ].inverse = HB_FALSE;
|
||||
|
||||
for( i = 0; i < HB_GTXWC_TRANS_COUNT; ++i )
|
||||
wnd->boxIndex[ i ] = HB_GTXWC_TRANS_MAX;
|
||||
}
|
||||
|
||||
/* *********************************************************************** */
|
||||
|
||||
static void hb_gt_xwc_BuildCharTrans( PXWND_DEF wnd )
|
||||
static XWC_CharTrans * hb_gt_xwc_GetBoxChar( PXWND_DEF wnd, HB_USHORT uc16 )
|
||||
{
|
||||
int i;
|
||||
HB_USHORT usCh16;
|
||||
HB_USHORT usBx16;
|
||||
int iPos, iTrans;
|
||||
|
||||
hb_gt_xwc_DestroyCharTrans( wnd );
|
||||
|
||||
for( i = 0; i < 256; i++ )
|
||||
if( !wnd->fDrawBox )
|
||||
{
|
||||
usCh16 = hb_cdpGetU16Disp( wnd->hostCDP, ( unsigned char ) i );
|
||||
usBx16 = hb_cdpGetU16Disp( wnd->boxCDP, ( unsigned char ) i );
|
||||
|
||||
wnd->charTrans[ i ].type = CH_CHAR;
|
||||
wnd->charTrans[ i ].u.ch16 = usCh16;
|
||||
wnd->charTrans[ i ].size = 0;
|
||||
wnd->charTrans[ i ].inverse = HB_FALSE;
|
||||
|
||||
wnd->boxTrans[ i ].type = CH_CHAR;
|
||||
wnd->boxTrans[ i ].u.ch16 = usBx16;
|
||||
wnd->boxTrans[ i ].size = 0;
|
||||
wnd->boxTrans[ i ].inverse = HB_FALSE;
|
||||
|
||||
if( wnd->fDrawBox )
|
||||
{
|
||||
hb_gt_xwc_DefineBoxChar( wnd, usCh16, &wnd->charTrans[ i ] );
|
||||
hb_gt_xwc_DefineBoxChar( wnd, usBx16, &wnd->boxTrans[ i ] );
|
||||
}
|
||||
wnd->boxTrans[ 0 ].u.ch16 = hb_cdpGetU16Ctrl( uc16 );
|
||||
return &wnd->boxTrans[ 0 ];
|
||||
}
|
||||
|
||||
if ( uc16 == HB_GTXWC_ARROW_R )
|
||||
iPos = 0;
|
||||
else if( uc16 == HB_GTXWC_ARROW_L )
|
||||
iPos = 1;
|
||||
else if( uc16 == HB_GTXWC_ARROW_U )
|
||||
iPos = 2;
|
||||
else if( uc16 == HB_GTXWC_ARROW_D )
|
||||
iPos = 3;
|
||||
else if( uc16 >= HB_GTXWC_BOX_MIN && uc16 <= HB_GTXWC_BOX_MAX )
|
||||
iPos = HB_GTXWC_CHR_BASE +
|
||||
( uc16 - HB_GTXWC_BOX_MIN );
|
||||
else if( uc16 >= HB_GTXWC_RC_MIN && uc16 <= HB_GTXWC_RC_MAX )
|
||||
iPos = HB_GTXWC_CHR_BASE + ( HB_GTXWC_BOX_MAX - HB_GTXWC_BOX_MIN + 1 ) +
|
||||
( uc16 - HB_GTXWC_RC_MIN );
|
||||
else
|
||||
{
|
||||
wnd->boxTrans[ 0 ].u.ch16 = hb_cdpGetU16Ctrl( uc16 );
|
||||
return &wnd->boxTrans[ 0 ];
|
||||
}
|
||||
|
||||
iTrans = wnd->boxIndex[ iPos ];
|
||||
if( iTrans == HB_GTXWC_TRANS_MAX )
|
||||
{
|
||||
if( wnd->transCount < HB_GTXWC_TRANS_MAX - 1 )
|
||||
{
|
||||
iTrans = wnd->transCount + 1;
|
||||
if( hb_gt_xwc_DefineBoxChar( wnd, uc16, &wnd->boxTrans[ iTrans ] ) )
|
||||
wnd->transCount = iTrans;
|
||||
else
|
||||
iTrans = 0;
|
||||
}
|
||||
else
|
||||
iTrans = 0;
|
||||
wnd->boxIndex[ iPos ] = iTrans;
|
||||
}
|
||||
|
||||
if( iTrans == 0 )
|
||||
{
|
||||
wnd->boxTrans[ 0 ].u.ch16 = hb_cdpGetU16Ctrl( uc16 );
|
||||
return &wnd->boxTrans[ 0 ];
|
||||
}
|
||||
|
||||
return &wnd->boxTrans[ iTrans ];
|
||||
}
|
||||
|
||||
/* *********************************************************************** */
|
||||
@@ -2625,7 +2661,7 @@ static void hb_gt_xwc_FullScreen( PXWND_DEF wnd )
|
||||
|
||||
static void hb_gt_xwc_ProcessKey( PXWND_DEF wnd, XKeyEvent *evt )
|
||||
{
|
||||
unsigned char buf[ 16 ];
|
||||
char buf[ 32 ];
|
||||
KeySym outISO = 0, out = XLookupKeysym( evt, 0 );
|
||||
int ikey = 0, i;
|
||||
#ifdef X_HAVE_UTF8_STRING
|
||||
@@ -2637,14 +2673,14 @@ static void hb_gt_xwc_ProcessKey( PXWND_DEF wnd, XKeyEvent *evt )
|
||||
# ifdef X_HAVE_UTF8_STRING
|
||||
if( wnd->ic )
|
||||
{
|
||||
i = Xutf8LookupString( wnd->ic, evt, ( char * ) buf, ( int ) sizeof( buf ), &outISO, &status_return );
|
||||
i = Xutf8LookupString( wnd->ic, evt, buf, ( int ) sizeof( buf ), &outISO, &status_return );
|
||||
buf[HB_MAX(i,0)] = '\0';
|
||||
printf( "UTF8: KeySym=%lx, keySymISO=%lx, keystr[%d]='%s'\r\n", out, outISO, i, buf ); fflush(stdout);
|
||||
}
|
||||
else
|
||||
# endif
|
||||
{
|
||||
i = XLookupString( evt, ( char * ) buf, ( int ) sizeof( buf ), &outISO, NULL );
|
||||
i = XLookupString( evt, buf, ( int ) sizeof( buf ), &outISO, NULL );
|
||||
buf[HB_MAX(i,0)] = '\0';
|
||||
printf( "KeySym=%lx, keySymISO=%lx, keystr[%d]='%s'\r\n", out, outISO, i, buf ); fflush(stdout);
|
||||
}
|
||||
@@ -2787,11 +2823,11 @@ static void hb_gt_xwc_ProcessKey( PXWND_DEF wnd, XKeyEvent *evt )
|
||||
we not check all modifiers in all possible keyboards */
|
||||
#ifdef X_HAVE_UTF8_STRING
|
||||
if( wnd->ic )
|
||||
i = Xutf8LookupString( wnd->ic, evt, ( char * ) buf, ( int ) sizeof( buf ), &outISO, &status_return );
|
||||
i = Xutf8LookupString( wnd->ic, evt, buf, ( int ) sizeof( buf ), &outISO, &status_return );
|
||||
else
|
||||
#endif
|
||||
{
|
||||
i = XLookupString( evt, ( char * ) buf, ( int ) sizeof( buf ), &outISO, NULL );
|
||||
i = XLookupString( evt, buf, ( int ) sizeof( buf ), &outISO, NULL );
|
||||
#ifndef HB_XWC_USE_LOCALE
|
||||
if( i <= 0 )
|
||||
{
|
||||
@@ -2800,13 +2836,13 @@ static void hb_gt_xwc_ProcessKey( PXWND_DEF wnd, XKeyEvent *evt )
|
||||
*/
|
||||
if( outISO >= 0x0100 && outISO <= 0x0fff && ( outISO & 0x80 ) == 0x80 )
|
||||
{
|
||||
buf[0] = ( unsigned char ) ( outISO & 0xff );
|
||||
buf[0] = ( char ) ( outISO & 0xff );
|
||||
i = 1;
|
||||
}
|
||||
/* hack for euro sign */
|
||||
else if( outISO == 0x20ac )
|
||||
{
|
||||
ikey = hb_cdpGetChar( wnd->hostCDP, ( HB_WCHAR ) outISO );
|
||||
ikey = hb_cdpGetChar( HB_GTSELF_HOSTCP( wnd->pGT ), ( HB_WCHAR ) outISO );
|
||||
if( ikey )
|
||||
hb_gt_xwc_AddCharToInputQueue( wnd, ikey );
|
||||
return;
|
||||
@@ -2817,30 +2853,16 @@ static void hb_gt_xwc_ProcessKey( PXWND_DEF wnd, XKeyEvent *evt )
|
||||
|
||||
if( i > 0 )
|
||||
{
|
||||
unsigned char keystr[ 32 ];
|
||||
HB_ULONG u = sizeof( keystr ), n;
|
||||
PHB_CODEPAGE cdp = wnd->fUTF8key ? wnd->utf8CDP : HB_GTSELF_INCP( wnd->pGT );
|
||||
HB_WCHAR wc;
|
||||
HB_SIZE nI = 0;
|
||||
|
||||
#ifdef X_HAVE_UTF8_STRING
|
||||
hb_cdpnDup2( ( const char * ) buf, i, ( char * ) keystr, &u,
|
||||
wnd->utf8CDP, wnd->hostCDP );
|
||||
#elif defined( HB_XWC_USE_LOCALE )
|
||||
hb_cdpnDup2( ( const char * ) buf, i, ( char * ) keystr, &u,
|
||||
wnd->fUTF8 ? wnd->utf8CDP : wnd->inCDP, wnd->hostCDP );
|
||||
#else
|
||||
hb_cdpnDup2( ( const char * ) buf, i, ( char * ) keystr, &u,
|
||||
wnd->inCDP, wnd->hostCDP );
|
||||
#endif
|
||||
|
||||
#ifdef XWC_DEBUG
|
||||
keystr[u] = '\0';
|
||||
printf( "keySymISO=%lx keystr[%d]='%s'\r\n", outISO, (int) u, keystr ); fflush(stdout);
|
||||
#endif
|
||||
for( n = 0; n < u; n++ )
|
||||
while( HB_CDPCHAR_GET( cdp, buf, i, &nI, &wc ) )
|
||||
{
|
||||
if( wnd->keyModifiers.bAlt || wnd->keyModifiers.bCtrl )
|
||||
hb_gt_xwc_TranslateKey( wnd, keystr[n] );
|
||||
if( wc < 128 && ( wnd->keyModifiers.bAlt || wnd->keyModifiers.bCtrl ) )
|
||||
hb_gt_xwc_TranslateKey( wnd, wc );
|
||||
else
|
||||
hb_gt_xwc_AddCharToInputQueue( wnd, keystr[n] );
|
||||
hb_gt_xwc_AddCharToInputQueue( wnd, HB_INKEY_NEW_UNICODE( wc ) );
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -3058,14 +3080,14 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent *evt )
|
||||
int top = wnd->markTop, bottom = wnd->markBottom,
|
||||
left = wnd->markLeft, right = wnd->markRight;
|
||||
char * pBuffer;
|
||||
HB_SIZE nSize;
|
||||
HB_SIZE nSize, nI;
|
||||
|
||||
wnd->fMarkMode = HB_FALSE;
|
||||
hb_gt_xwc_InvalidateChar( wnd, left, top, right, bottom );
|
||||
|
||||
nSize = ( bottom - top + 1 ) * ( right - left + 2 );
|
||||
nSize = ( bottom - top + 1 ) * ( right - left + 2 ) * 3;
|
||||
pBuffer = ( char * ) hb_xgrab( nSize + 1 );
|
||||
nSize = 0;
|
||||
nI = 0;
|
||||
while( top <= bottom )
|
||||
{
|
||||
for( left = wnd->markLeft; left <= right; ++left )
|
||||
@@ -3077,14 +3099,19 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent *evt )
|
||||
if( !HB_GTSELF_GETSCRCHAR( wnd->pGT, top, left, &iColor, &bAttr, &usChar ) )
|
||||
break;
|
||||
|
||||
pBuffer[ nSize++ ] = ( char ) usChar;
|
||||
nI += hb_cdpTextPutU16( wnd->utf8CDP, pBuffer + nI, nSize - nI, usChar );
|
||||
/* nI += hb_cdpU16CharToUTF8( pBuffer + nI, &usChar ); */
|
||||
}
|
||||
pBuffer[ nSize++ ] = '\n';
|
||||
pBuffer[ nI++ ] = '\n';
|
||||
++top;
|
||||
}
|
||||
if( nSize > 0 )
|
||||
hb_gt_xwc_SetSelection( wnd, pBuffer, nSize );
|
||||
hb_xfree( pBuffer );
|
||||
if( nI > 0 )
|
||||
{
|
||||
pBuffer[ nI ] = '\0';
|
||||
hb_gt_xwc_SetSelection( wnd, pBuffer, nI, HB_FALSE );
|
||||
}
|
||||
else
|
||||
hb_xfree( pBuffer );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3191,8 +3218,7 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent *evt )
|
||||
|
||||
wnd->ClipboardSize = text.nitems;
|
||||
wnd->ClipboardData = ( unsigned char * )
|
||||
hb_cdpnDup( ( const char * ) text.value, &wnd->ClipboardSize,
|
||||
wnd->utf8CDP, wnd->hostCDP );
|
||||
hb_xmemdup( text.value, text.nitems );
|
||||
wnd->ClipboardTime = evt->xselection.time;
|
||||
wnd->ClipboardRcvd = HB_TRUE;
|
||||
}
|
||||
@@ -3207,7 +3233,7 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent *evt )
|
||||
wnd->ClipboardSize = text.nitems;
|
||||
wnd->ClipboardData = ( unsigned char * )
|
||||
hb_cdpnDup( ( const char * ) text.value, &wnd->ClipboardSize,
|
||||
wnd->inCDP, wnd->hostCDP );
|
||||
HB_GTSELF_INCP( wnd->pGT ), wnd->utf8CDP );
|
||||
wnd->ClipboardTime = evt->xselection.time;
|
||||
wnd->ClipboardRcvd = HB_TRUE;
|
||||
}
|
||||
@@ -3278,12 +3304,14 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent *evt )
|
||||
else if( req->target == s_atomString || req->target == s_atomText )
|
||||
{
|
||||
/* TODO: for s_atomString convert data to ISO-8859-1 */
|
||||
if( wnd->inCDP && wnd->hostCDP && wnd->inCDP != wnd->hostCDP )
|
||||
PHB_CODEPAGE cdpin = HB_GTSELF_INCP( wnd->pGT );
|
||||
|
||||
if( cdpin && cdpin != wnd->utf8CDP )
|
||||
{
|
||||
HB_SIZE ulLen = wnd->ClipboardSize;
|
||||
unsigned char * pBuffer = ( unsigned char * )
|
||||
hb_cdpnDup( ( const char * ) wnd->ClipboardData, &ulLen,
|
||||
wnd->hostCDP, wnd->inCDP );
|
||||
wnd->utf8CDP, cdpin );
|
||||
|
||||
XChangeProperty( wnd->dpy, req->requestor, req->property,
|
||||
s_atomString, 8, PropModeReplace,
|
||||
@@ -3299,18 +3327,9 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent *evt )
|
||||
}
|
||||
else if( req->target == s_atomUTF8String )
|
||||
{
|
||||
HB_SIZE ulLen = wnd->ClipboardSize;
|
||||
unsigned char * pBuffer = ( unsigned char * )
|
||||
hb_cdpnDup( ( const char * ) wnd->ClipboardData, &ulLen,
|
||||
wnd->hostCDP, wnd->utf8CDP );
|
||||
|
||||
#ifdef XWC_DEBUG
|
||||
printf( "SelectionRequest: (%s)->(%s) [%s]\r\n", wnd->ClipboardData, pBuffer, wnd->hostCDP->id ); fflush(stdout);
|
||||
#endif
|
||||
XChangeProperty( wnd->dpy, req->requestor, req->property,
|
||||
s_atomUTF8String, 8, PropModeReplace,
|
||||
pBuffer, ulLen );
|
||||
hb_xfree( pBuffer );
|
||||
wnd->ClipboardData, wnd->ClipboardSize );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3579,7 +3598,6 @@ static void hb_gt_xwc_RepaintChar( PXWND_DEF wnd, int colStart, int rowStart, in
|
||||
}
|
||||
else
|
||||
{
|
||||
usCh16 &= 0xFF;
|
||||
color = ( HB_BYTE ) iColor;
|
||||
if( wnd->fMarkMode &&
|
||||
irow >= wnd->markTop && irow <= wnd->markBottom &&
|
||||
@@ -3589,8 +3607,7 @@ static void hb_gt_xwc_RepaintChar( PXWND_DEF wnd, int colStart, int rowStart, in
|
||||
}
|
||||
}
|
||||
ulCurr = hb_gt_xwc_HashCurrChar( attr, color, usCh16 );
|
||||
chTrans = ( attr & HB_GT_ATTR_BOX ) ? &wnd->boxTrans[ usCh16 ] :
|
||||
&wnd->charTrans[ usCh16 ];
|
||||
chTrans = hb_gt_xwc_GetBoxChar( wnd, usCh16 );
|
||||
if( chTrans->inverse )
|
||||
{
|
||||
color = ( color << 4 ) | ( color >> 4 );
|
||||
@@ -3722,6 +3739,9 @@ static void hb_gt_xwc_RepaintChar( PXWND_DEF wnd, int colStart, int rowStart, in
|
||||
chTrans->u.rect, nsize );
|
||||
break;
|
||||
|
||||
case CH_UNDEF:
|
||||
break;
|
||||
|
||||
}
|
||||
wnd->pCurrScr[index] = ulCurr;
|
||||
}
|
||||
@@ -3982,7 +4002,7 @@ static void hb_gt_xwc_ProcessMessages( PXWND_DEF wnd )
|
||||
XTextProperty text;
|
||||
char * pBuffer;
|
||||
|
||||
pBuffer = hb_cdpDup( wnd->szTitle, wnd->hostCDP, wnd->utf8CDP );
|
||||
pBuffer = hb_cdpDup( wnd->szTitle, HB_GTSELF_HOSTCP( wnd->pGT ), wnd->utf8CDP );
|
||||
text.value = ( unsigned char * ) pBuffer;
|
||||
text.encoding = s_atomUTF8String;
|
||||
text.format = 8;
|
||||
@@ -4145,7 +4165,7 @@ static void hb_gt_xwc_ClearSelection( PXWND_DEF wnd )
|
||||
|
||||
/* *********************************************************************** */
|
||||
|
||||
static void hb_gt_xwc_SetSelection( PXWND_DEF wnd, const char * szData, HB_SIZE ulSize )
|
||||
static void hb_gt_xwc_SetSelection( PXWND_DEF wnd, const char * szData, HB_SIZE ulSize, HB_BOOL fCopy )
|
||||
{
|
||||
HB_XWC_XLIB_LOCK
|
||||
|
||||
@@ -4153,16 +4173,26 @@ static void hb_gt_xwc_SetSelection( PXWND_DEF wnd, const char * szData, HB_SIZE
|
||||
hb_gt_xwc_ClearSelection( wnd );
|
||||
|
||||
if( wnd->ClipboardData != NULL )
|
||||
{
|
||||
hb_xfree( wnd->ClipboardData );
|
||||
wnd->ClipboardData = ( unsigned char * ) hb_xgrab( ulSize + 1 );
|
||||
memcpy( wnd->ClipboardData, szData, ulSize );
|
||||
wnd->ClipboardData[ ulSize ] = '\0';
|
||||
wnd->ClipboardData = NULL;
|
||||
}
|
||||
|
||||
wnd->ClipboardSize = ulSize;
|
||||
wnd->ClipboardTime = wnd->lastEventTime;
|
||||
wnd->ClipboardOwner = HB_FALSE;
|
||||
|
||||
if( ulSize > 0 )
|
||||
{
|
||||
if( fCopy )
|
||||
{
|
||||
wnd->ClipboardData = ( unsigned char * ) hb_xgrab( ulSize + 1 );
|
||||
memcpy( wnd->ClipboardData, szData, ulSize );
|
||||
wnd->ClipboardData[ ulSize ] = '\0';
|
||||
}
|
||||
else
|
||||
wnd->ClipboardData = ( unsigned char * ) szData;
|
||||
|
||||
XSetSelectionOwner( wnd->dpy, s_atomPrimary, wnd->window, wnd->ClipboardTime );
|
||||
if( XGetSelectionOwner( wnd->dpy, s_atomPrimary ) == wnd->window )
|
||||
{
|
||||
@@ -4295,13 +4325,10 @@ static PXWND_DEF hb_gt_xwc_CreateWndDef( PHB_GT pGT )
|
||||
wnd->fWinResize = HB_FALSE;
|
||||
wnd->fFullScreen = HB_FALSE;
|
||||
wnd->fAltEnter = HB_FALSE;
|
||||
#ifdef HB_XWC_USE_LOCALE
|
||||
wnd->fUTF8 = hb_gt_xwc_isUTF8();
|
||||
#if defined( HB_XWC_USE_LOCALE )
|
||||
wnd->fUTF8key = hb_gt_xwc_isUTF8();
|
||||
#endif
|
||||
wnd->hostCDP = hb_vmCDP();
|
||||
wnd->utf8CDP = hb_cdpFindExt( "UTF8" );
|
||||
if( wnd->boxCDP == NULL )
|
||||
wnd->boxCDP = hb_cdpFind( "EN" );
|
||||
wnd->cursorType = SC_NORMAL;
|
||||
|
||||
/* Window Title */
|
||||
@@ -4395,7 +4422,7 @@ static void hb_gt_xwc_DissConnectX( PXWND_DEF wnd )
|
||||
if( wnd->dpy != NULL )
|
||||
{
|
||||
hb_gt_xwc_ClearSelection( wnd );
|
||||
hb_gt_xwc_DestroyCharTrans( wnd );
|
||||
hb_gt_xwc_ResetCharTrans( wnd );
|
||||
|
||||
#ifdef X_HAVE_UTF8_STRING
|
||||
if( wnd->ic )
|
||||
@@ -4526,8 +4553,8 @@ static void hb_gt_xwc_CreateWindow( PXWND_DEF wnd )
|
||||
}
|
||||
}
|
||||
|
||||
/* build character translation table (after font selection) */
|
||||
hb_gt_xwc_BuildCharTrans( wnd );
|
||||
/* reset character translation table (after font selection) */
|
||||
hb_gt_xwc_ResetCharTrans( wnd );
|
||||
|
||||
if( !wnd->window )
|
||||
{
|
||||
@@ -4580,6 +4607,8 @@ static void hb_gt_xwc_CreateWindow( PXWND_DEF wnd )
|
||||
XCloseIM( wnd->im );
|
||||
wnd->im = NULL;
|
||||
}
|
||||
else
|
||||
wnd->fUTF8key = HB_TRUE;
|
||||
}
|
||||
#ifdef XWC_DEBUG
|
||||
printf( "\r\nXIC=%p, XIC=%p\r\n", wnd->im, wnd->ic ); fflush(stdout);
|
||||
@@ -4892,72 +4921,6 @@ static int hb_gt_xwc_mouse_CountButton( PHB_GT pGT )
|
||||
|
||||
/* *********************************************************************** */
|
||||
|
||||
static HB_BOOL hb_gt_xwc_SetDispCP( PHB_GT pGT, const char * pszTermCDP, const char * pszHostCDP, HB_BOOL fBox )
|
||||
{
|
||||
|
||||
HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox );
|
||||
|
||||
/*
|
||||
* We are displaying text in U16 so pszTermCDP is unimportant.
|
||||
* We only have to know what is the internal application codepage
|
||||
* to make proper translation
|
||||
*/
|
||||
if( !pszHostCDP || !*pszHostCDP )
|
||||
pszHostCDP = hb_cdpID();
|
||||
|
||||
if( pszHostCDP && *pszHostCDP )
|
||||
{
|
||||
PHB_CODEPAGE cdpHost = hb_cdpFind( pszHostCDP );
|
||||
PXWND_DEF wnd = HB_GTXWC_GET( pGT );
|
||||
|
||||
if( cdpHost && cdpHost != wnd->hostCDP )
|
||||
{
|
||||
wnd->hostCDP = cdpHost;
|
||||
wnd->boxCDP = fBox ? cdpHost : hb_cdpFind( "EN" );
|
||||
if( wnd->fInit )
|
||||
{
|
||||
HB_XWC_XLIB_LOCK
|
||||
hb_gt_xwc_BuildCharTrans( wnd );
|
||||
HB_XWC_XLIB_UNLOCK
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
/* *********************************************************************** */
|
||||
|
||||
static HB_BOOL hb_gt_xwc_SetKeyCP( PHB_GT pGT, const char * pszTermCDP, const char * pszHostCDP )
|
||||
{
|
||||
|
||||
HB_GTSUPER_SETKEYCP( pGT, pszTermCDP, pszHostCDP );
|
||||
|
||||
/*
|
||||
* Basic Xlib api has no function to return character key val in
|
||||
* unicode so far. We can use some nonstandard extension or try
|
||||
* to make translation XKEY_* to unicode ourself.
|
||||
* Now I don't have time to build the full conversion table so I only
|
||||
* add a simple hack which should work for LATIN-x encoding and
|
||||
* probably some others
|
||||
*/
|
||||
if( !pszTermCDP || !*pszTermCDP )
|
||||
pszTermCDP = hb_cdpID();
|
||||
|
||||
if( pszTermCDP && *pszTermCDP )
|
||||
{
|
||||
PHB_CODEPAGE cdpTerm = hb_cdpFind( pszTermCDP );
|
||||
if( cdpTerm )
|
||||
{
|
||||
HB_GTXWC_GET( pGT )->inCDP = cdpTerm;
|
||||
}
|
||||
}
|
||||
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
/* *********************************************************************** */
|
||||
|
||||
static int hb_gt_xwc_getKbdState( PXWND_DEF wnd )
|
||||
{
|
||||
int iKbdState = 0;
|
||||
@@ -4972,7 +4935,6 @@ static int hb_gt_xwc_getKbdState( PXWND_DEF wnd )
|
||||
static HB_BOOL hb_gt_xwc_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
|
||||
{
|
||||
PXWND_DEF wnd;
|
||||
const char * szVal;
|
||||
int iVal;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_xwc_Info(%p,%d,%p)", pGT, iType, pInfo ) );
|
||||
@@ -5086,26 +5048,6 @@ static HB_BOOL hb_gt_xwc_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
|
||||
}
|
||||
break;
|
||||
|
||||
case HB_GTI_BOXCP:
|
||||
pInfo->pResult = hb_itemPutC( pInfo->pResult,
|
||||
wnd->boxCDP ? wnd->boxCDP->id : NULL );
|
||||
szVal = hb_itemGetCPtr( pInfo->pNewVal );
|
||||
if( szVal && *szVal )
|
||||
{
|
||||
PHB_CODEPAGE cdpBox = hb_cdpFind( szVal );
|
||||
if( cdpBox )
|
||||
{
|
||||
wnd->boxCDP = cdpBox;
|
||||
if( wnd->fInit )
|
||||
{
|
||||
HB_XWC_XLIB_LOCK
|
||||
hb_gt_xwc_BuildCharTrans( wnd );
|
||||
HB_XWC_XLIB_UNLOCK
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case HB_GTI_DESKTOPWIDTH:
|
||||
case HB_GTI_DESKTOPHEIGHT:
|
||||
case HB_GTI_DESKTOPCOLS:
|
||||
@@ -5161,22 +5103,28 @@ static HB_BOOL hb_gt_xwc_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
|
||||
break;
|
||||
|
||||
case HB_GTI_CLIPBOARDDATA:
|
||||
if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING )
|
||||
{
|
||||
void * hString;
|
||||
HB_SIZE nLen;
|
||||
const char * pszClipboardData = hb_itemGetStrUTF8( pInfo->pNewVal, &hString, &nLen );
|
||||
|
||||
if( pszClipboardData )
|
||||
{
|
||||
hb_gt_xwc_RealRefresh( wnd );
|
||||
hb_gt_xwc_SetSelection( wnd, hb_itemGetCPtr( pInfo->pNewVal ),
|
||||
hb_itemGetCLen( pInfo->pNewVal ) );
|
||||
hb_gt_xwc_SetSelection( wnd, pszClipboardData, nLen, HB_TRUE );
|
||||
hb_gt_xwc_RealRefresh( wnd );
|
||||
hb_strfree( hString );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_gt_xwc_RealRefresh( wnd );
|
||||
hb_gt_xwc_RequestSelection( wnd );
|
||||
pInfo->pResult = hb_itemPutCL( pInfo->pResult,
|
||||
( char * ) wnd->ClipboardData,
|
||||
wnd->ClipboardSize );
|
||||
pInfo->pResult = hb_itemPutStrLenUTF8( pInfo->pResult,
|
||||
( char * ) wnd->ClipboardData,
|
||||
wnd->ClipboardSize );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case HB_GTI_CURSORBLINKRATE:
|
||||
pInfo->pResult = hb_itemPutNI( pInfo->pResult, wnd->cursorBlinkRate );
|
||||
@@ -5559,8 +5507,6 @@ static HB_BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable )
|
||||
pFuncTable->Version = hb_gt_xwc_Version;
|
||||
pFuncTable->Tone = hb_gt_xwc_Tone;
|
||||
pFuncTable->Info = hb_gt_xwc_Info;
|
||||
pFuncTable->SetDispCP = hb_gt_xwc_SetDispCP;
|
||||
pFuncTable->SetKeyCP = hb_gt_xwc_SetKeyCP;
|
||||
|
||||
pFuncTable->ReadKey = hb_gt_xwc_ReadKey;
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
#include "inkey.ch"
|
||||
#include "hbgfxdef.ch"
|
||||
#include "hbapicdp.h"
|
||||
#include "hbapistr.h"
|
||||
#include "hbthread.h"
|
||||
|
||||
#include <unistd.h>
|
||||
@@ -190,6 +191,8 @@ typedef HB_USHORT HB_GT_CELLTYPE;
|
||||
#define HB_GTXWC_ARROW_U 0x001E /* ARROW UP */
|
||||
#define HB_GTXWC_ARROW_D 0x001F /* ARROW DOWN */
|
||||
|
||||
#define HB_GTXWC_CHR_BASE 4
|
||||
|
||||
#define HB_GTXWC_DBL_LT 0x2554 /* BOX DRAWINGS DOUBLE DOWN AND RIGHT (Double left top angle) */
|
||||
#define HB_GTXWC_DBL_TD 0x2566 /* BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL (Double top with junction down) */
|
||||
#define HB_GTXWC_DBL_RT 0x2557 /* BOX DRAWINGS DOUBLE DOWN AND LEFT (Double right top angle) */
|
||||
@@ -258,6 +261,8 @@ typedef HB_USHORT HB_GT_CELLTYPE;
|
||||
|
||||
#define HB_GTXWC_SQUARE 0x25A0 /* BLACK SQUARE */
|
||||
|
||||
#define HB_GTXWC_BOX_MIN 0x2500
|
||||
#define HB_GTXWC_BOX_MAX 0x25A0
|
||||
|
||||
#define HB_GTXWC_RC_ARROW_DL 0xE040 /* USER ARROW DOWN (LEFT) */
|
||||
#define HB_GTXWC_RC_ARROW_DR 0xE041 /* USER ARROW DOWN (RIGHT) */
|
||||
@@ -323,10 +328,14 @@ typedef HB_USHORT HB_GT_CELLTYPE;
|
||||
#define HB_GTXWC_RC_MIN 0xE040
|
||||
#define HB_GTXWC_RC_MAX 0xE076
|
||||
|
||||
#define HB_GTXWC_TRANS_COUNT ( HB_GTXWC_CHR_BASE + ( HB_GTXWC_BOX_MAX - HB_GTXWC_BOX_MIN + 1 ) + ( HB_GTXWC_RC_MAX - HB_GTXWC_RC_MIN + 1 ) )
|
||||
#define HB_GTXWC_TRANS_MAX 0xFF
|
||||
|
||||
/********************** Unix to graphic box translation ******************/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CH_UNDEF, /* undefined */
|
||||
CH_CHAR, /* normal U16 character */
|
||||
CH_CHBX, /* U16 character built by DrawBoxChar */
|
||||
CH_NONE, /* no character share */
|
||||
|
||||
@@ -303,8 +303,13 @@ FUNCTION __hbdoc_FilterOut( cFile )
|
||||
* previously-saved files is required, only a naive approach of using
|
||||
* version 1 is taken.
|
||||
*/
|
||||
#define _HBDOC_SIGNATURE e"\xC0HBD" + Chr( 1 ) + Chr( 0 )
|
||||
|
||||
#define _HBDOC_SIGNATURE ( HB_BCHAR( 0xC0 ) + ;
|
||||
HB_BCHAR( 0x48 ) + ;
|
||||
HB_BCHAR( 0x42 ) + ;
|
||||
HB_BCHAR( 0x44 ) + ;
|
||||
HB_BCHAR( 0x01 ) + ;
|
||||
HB_BCHAR( 0x00 ) )
|
||||
#define _HBDOC_SIG_LEN 6
|
||||
#define _HBDOC_EXT ".hbd"
|
||||
|
||||
FUNCTION __hbdoc_SaveHBD( cFileName, aEntry )
|
||||
@@ -351,12 +356,12 @@ FUNCTION __hbdoc_LoadHBD( cFileName )
|
||||
fhnd := FOpen( cFileName, FO_READ )
|
||||
IF fhnd != F_ERROR
|
||||
|
||||
cBuffer := Space( Len( _HBDOC_SIGNATURE ) )
|
||||
cBuffer := Space( _HBDOC_SIG_LEN )
|
||||
FRead( fhnd, @cBuffer, Len( cBuffer ) )
|
||||
IF cBuffer == _HBDOC_SIGNATURE
|
||||
|
||||
cBuffer := Space( FSeek( fhnd, 0, FS_END ) - Len( _HBDOC_SIGNATURE ) )
|
||||
FSeek( fhnd, Len( _HBDOC_SIGNATURE ), FS_SET )
|
||||
cBuffer := Space( FSeek( fhnd, 0, FS_END ) - _HBDOC_SIG_LEN )
|
||||
FSeek( fhnd, _HBDOC_SIG_LEN, FS_SET )
|
||||
FRead( fhnd, @cBuffer, Len( cBuffer ) )
|
||||
FClose( fhnd )
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -99,7 +99,8 @@ STATIC FUNCTION __I18N_strDecode( cLine, cValue, lCont )
|
||||
|
||||
RETURN lRet
|
||||
|
||||
#define _UTF8_BOM e"\xEF\xBB\xBF"
|
||||
#define _BOM_VALUE 0xFEFF
|
||||
#define _UTF8_BOM hb_utf8CHR( _BOM_VALUE ) /* e"\xEF\xBB\xBF" */
|
||||
|
||||
FUNCTION __I18N_POTARRAYLOAD( cFile, cErrorMsg )
|
||||
LOCAL cLine, cValue
|
||||
@@ -123,7 +124,7 @@ FUNCTION __I18N_POTARRAYLOAD( cFile, cErrorMsg )
|
||||
RETURN NIL
|
||||
ENDIF
|
||||
/* Strip UTF-8 BOM */
|
||||
IF Left( cValue, Len( _UTF8_BOM ) ) == _UTF8_BOM
|
||||
IF hb_utf8ASC( cValue ) == _BOM_VALUE
|
||||
cValue := SubStr( cValue, Len( _UTF8_BOM ) + 1 )
|
||||
ENDIF
|
||||
IF !hb_eol() == _I18N_EOL
|
||||
@@ -303,10 +304,12 @@ FUNCTION __I18N_POTARRAYLOAD( cFile, cErrorMsg )
|
||||
STATIC FUNCTION IsBOM_UTF8( cFileName )
|
||||
LOCAL fhnd := FOpen( cFileName, FO_READ )
|
||||
LOCAL cBuffer
|
||||
LOCAL nLen
|
||||
|
||||
IF fhnd != F_ERROR
|
||||
cBuffer := Space( Len( _UTF8_BOM ) )
|
||||
FRead( fhnd, @cBuffer, Len( cBuffer ) )
|
||||
nLen := HB_BLen( _UTF8_BOM )
|
||||
cBuffer := Space( nLen )
|
||||
FRead( fhnd, @cBuffer, nLen )
|
||||
FClose( fhnd )
|
||||
IF cBuffer == _UTF8_BOM
|
||||
RETURN .T.
|
||||
|
||||
@@ -57,8 +57,8 @@
|
||||
* Copyright 1999-2001 Viktor Szakats (harbour syenar.net)
|
||||
* HB_KEYPUT()
|
||||
*
|
||||
* Copyright 2003 Przemyslaw Czerpak <druzus@acn.waw.pl>
|
||||
* HB_SETLASTKEY()
|
||||
* Copyright 2003-2012 Przemyslaw Czerpak <druzus@acn.waw.pl>
|
||||
* HB_SETLASTKEY(), HB_KEYCHAR(), HB_KEYSTD()
|
||||
*
|
||||
* See COPYING for licensing terms.
|
||||
*
|
||||
@@ -66,6 +66,7 @@
|
||||
|
||||
#include "hbapigt.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapicdp.h"
|
||||
#include "hbset.h"
|
||||
#include "hbstack.h"
|
||||
#include "hbvm.h"
|
||||
@@ -173,7 +174,7 @@ HB_FUNC( HB_KEYLAST )
|
||||
|
||||
HB_FUNC( LASTKEY )
|
||||
{
|
||||
hb_retni( hb_inkeyLast( INKEY_ALL ) );
|
||||
hb_retni( hb_inkeyLast( HB_INKEY_ALL ) );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_SETLASTKEY )
|
||||
@@ -181,3 +182,17 @@ HB_FUNC( HB_SETLASTKEY )
|
||||
if( HB_ISNUM( 1 ) )
|
||||
hb_retni( hb_inkeySetLast( hb_parni( 1 ) ) );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_KEYCHAR )
|
||||
{
|
||||
char szKeyChr[ HB_MAX_CHAR_LEN ];
|
||||
HB_SIZE nLen;
|
||||
|
||||
nLen = hb_inkeyKeyString( hb_parni( 1 ), szKeyChr, sizeof( szKeyChr ) );
|
||||
hb_retclen( szKeyChr, nLen );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_KEYSTD )
|
||||
{
|
||||
hb_retni( hb_inkeyKeyStd( hb_parni( 1 ) ) );
|
||||
}
|
||||
|
||||
@@ -208,3 +208,53 @@ void hb_inkeySetCancelKeys( int iCancelKey, int iCancelKeyEx )
|
||||
HB_SYMBOL_UNUSED( iCancelKey );
|
||||
HB_SYMBOL_UNUSED( iCancelKeyEx );
|
||||
}
|
||||
|
||||
HB_SIZE hb_inkeyKeyString( int iKey, char * buffer, HB_SIZE nSize )
|
||||
{
|
||||
HB_SIZE nLen = 0;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_inkeyKeyString(%d,%p, %" HB_PFS "u)", iKey, buffer, nSize));
|
||||
|
||||
if( HB_INKEY_ISUNICODE( iKey ) )
|
||||
{
|
||||
nLen = hb_cdpTextPutU16( hb_vmCDP(), buffer, nSize, HB_INKEY_VALUE( iKey ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( HB_INKEY_ISCHAR( iKey ) )
|
||||
iKey = HB_INKEY_VALUE( iKey );
|
||||
if( iKey >= 32 && iKey <= 255 )
|
||||
{
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
nLen = hb_cdpTextPutU16( cdp, buffer, nSize,
|
||||
hb_cdpGetU16( cdp, ( HB_UCHAR ) iKey ) );
|
||||
}
|
||||
}
|
||||
return nLen;
|
||||
}
|
||||
|
||||
int hb_inkeyKeyStd( int iKey )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_inkeyKeyStd(%d)", iKey));
|
||||
|
||||
if( HB_INKEY_ISEXT( iKey ) )
|
||||
{
|
||||
if( HB_INKEY_ISUNICODE( iKey ) )
|
||||
{
|
||||
HB_WCHAR wc = ( HB_WCHAR ) HB_INKEY_VALUE( iKey );
|
||||
if( wc )
|
||||
{
|
||||
HB_UCHAR uc = hb_cdpGetUC( hb_vmCDP(), wc, 0 );
|
||||
if( uc != 0 )
|
||||
iKey = uc;
|
||||
}
|
||||
else
|
||||
iKey = 0;
|
||||
}
|
||||
else if( HB_INKEY_ISMOUSEPOS( iKey ) )
|
||||
iKey = K_MOUSEMOVE;
|
||||
else
|
||||
iKey = HB_INKEY_VALUE( iKey );
|
||||
}
|
||||
return iKey;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Harbour Project source code:
|
||||
* LEFT() function
|
||||
*
|
||||
* Copyright 2012 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* Copyright 1999 Antonio Linares <alinares@fivetech.com>
|
||||
* www - http://harbour-project.org
|
||||
*
|
||||
@@ -52,6 +53,7 @@
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapicdp.h"
|
||||
#include "hbapierr.h"
|
||||
|
||||
/* returns the left-most n characters in string */
|
||||
@@ -68,6 +70,12 @@ HB_FUNC( LEFT )
|
||||
else
|
||||
{
|
||||
HB_SIZE nText = hb_itemGetCLen( pText );
|
||||
if( ( HB_SIZE ) nLen < nText )
|
||||
{
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
if( HB_CDP_ISCHARIDX( cdp ) )
|
||||
nLen = hb_cdpTextPos( cdp, hb_itemGetCPtr( pText ), nText, nLen );
|
||||
}
|
||||
if( ( HB_SIZE ) nLen >= nText )
|
||||
hb_itemReturn( pText );
|
||||
else
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Harbour Project source code:
|
||||
* LEN() function
|
||||
*
|
||||
* Copyright 2012 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* Copyright 1999 Antonio Linares <alinares@fivetech.com>
|
||||
* www - http://harbour-project.org
|
||||
*
|
||||
@@ -53,6 +54,7 @@
|
||||
#include "hbapi.h"
|
||||
#include "hbapierr.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapicdp.h"
|
||||
|
||||
HB_FUNC( LEN )
|
||||
{
|
||||
@@ -66,7 +68,11 @@ HB_FUNC( LEN )
|
||||
{
|
||||
if( HB_IS_STRING( pItem ) )
|
||||
{
|
||||
hb_retns( hb_itemGetCLen( pItem ) );
|
||||
HB_SIZE nLen = hb_itemGetCLen( pItem );
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
if( HB_CDP_ISCHARIDX( cdp ) )
|
||||
nLen = hb_cdpTextLen( cdp, hb_itemGetCPtr( pItem ), nLen );
|
||||
hb_retns( nLen );
|
||||
return;
|
||||
}
|
||||
else if( HB_IS_ARRAY( pItem ) )
|
||||
|
||||
@@ -137,12 +137,12 @@ CREATE CLASS LISTBOX FUNCTION HBListBox
|
||||
VAR nCapCol
|
||||
VAR nCapRow
|
||||
VAR cCaption INIT ""
|
||||
VAR cColdBox INIT Chr( 218 ) + Chr( 196 ) + Chr( 191 ) + Chr( 179 ) + Chr( 217 ) + Chr( 196 ) + Chr( 192 ) + Chr( 179 )
|
||||
VAR cColdBox INIT B_SINGLE
|
||||
VAR cColorSpec
|
||||
VAR lDropDown
|
||||
VAR bFBlock
|
||||
VAR lHasFocus INIT .F.
|
||||
VAR cHotBox INIT Chr( 201 ) + Chr( 205 ) + Chr( 187 ) + Chr( 186 ) + Chr( 188 ) + Chr( 205 ) + Chr( 200 ) + Chr( 186 )
|
||||
VAR cHotBox INIT B_DOUBLE
|
||||
VAR lIsOpen
|
||||
VAR nItemCount INIT 0
|
||||
VAR nLeft
|
||||
@@ -322,7 +322,7 @@ METHOD findText( cText, nPos, lCaseSensitive, lExact ) CLASS LISTBOX
|
||||
LOCAL nLen
|
||||
LOCAL bSearch
|
||||
|
||||
IF !ISCHARACTER( cText )
|
||||
IF !ISCHARACTER( cText ) .OR. Len( cText ) == 0
|
||||
RETURN 0
|
||||
ENDIF
|
||||
IF !ISNUMBER( nPos )
|
||||
|
||||
@@ -66,8 +66,13 @@
|
||||
* previously-saved files is required, only a naive approach of using
|
||||
* version 1 is taken.
|
||||
*/
|
||||
#define _HBMEM_SIGNATURE e"\xC0HBV" + Chr( 1 ) + Chr( 0 )
|
||||
|
||||
#define _HBMEM_SIGNATURE ( HB_BCHAR( 0xC0 ) + ;
|
||||
HB_BCHAR( 0x48 ) + ;
|
||||
HB_BCHAR( 0x42 ) + ;
|
||||
HB_BCHAR( 0x56 ) + ;
|
||||
HB_BCHAR( 0x01 ) + ;
|
||||
HB_BCHAR( 0x00 ) )
|
||||
#define _HBMEM_SIG_LEN 6
|
||||
#define _HBMEM_EXT ".hbv"
|
||||
|
||||
FUNCTION HB_MVSAVE( cFileName, cMask, lIncludeMask )
|
||||
@@ -239,12 +244,12 @@ FUNCTION HB_MVRESTORE( cFileName, lAdditive, cMask, lIncludeMask )
|
||||
|
||||
xValue := NIL
|
||||
|
||||
cBuffer := Space( Len( _HBMEM_SIGNATURE ) )
|
||||
cBuffer := Space( _HBMEM_SIG_LEN )
|
||||
FRead( fhnd, @cBuffer, Len( cBuffer ) )
|
||||
IF cBuffer == _HBMEM_SIGNATURE
|
||||
|
||||
cBuffer := Space( FSeek( fhnd, 0, FS_END ) - Len( _HBMEM_SIGNATURE ) )
|
||||
FSeek( fhnd, Len( _HBMEM_SIGNATURE ), FS_SET )
|
||||
cBuffer := Space( FSeek( fhnd, 0, FS_END ) - _HBMEM_SIG_LEN )
|
||||
FSeek( fhnd, _HBMEM_SIG_LEN, FS_SET )
|
||||
FRead( fhnd, @cBuffer, Len( cBuffer ) )
|
||||
FClose( fhnd )
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ FUNCTION __AtPrompt( nRow, nCol, cPrompt, cMsg, cColor )
|
||||
FUNCTION __MenuTo( bBlock, cVariable )
|
||||
|
||||
LOCAL nKey
|
||||
LOCAL cKey
|
||||
LOCAL y
|
||||
LOCAL q
|
||||
LOCAL n
|
||||
@@ -239,13 +240,15 @@ FUNCTION __MenuTo( bBlock, cVariable )
|
||||
EXIT
|
||||
OTHERWISE
|
||||
// did user hit a hot key?
|
||||
FOR y := 1 TO nArrLen
|
||||
IF Upper( Left( LTrim( t_aLevel[ nPointer - 1, y, 3 ] ), 1 ) ) == Upper( Chr( nKey ) )
|
||||
n := y
|
||||
lExit := .T.
|
||||
EXIT
|
||||
ENDIF
|
||||
NEXT
|
||||
IF Len( cKey := Upper ( hb_keyChar( nKey ) ) ) > 0
|
||||
FOR y := 1 TO nArrLen
|
||||
IF Upper( Left( LTrim( t_aLevel[ nPointer - 1, y, 3 ] ), Len( cKey ) ) ) == cKey
|
||||
n := y
|
||||
lExit := .T.
|
||||
EXIT
|
||||
ENDIF
|
||||
NEXT
|
||||
ENDIF
|
||||
ENDSWITCH
|
||||
|
||||
IF n != 0
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Harbour Project source code:
|
||||
* memo line functions: MEMOLINE(), MLCOUNT(), MLPOS(), MLCTOPOS(), MPOSTOLC()
|
||||
*
|
||||
* Copyright 2007 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* Copyright 2012 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* www - http://harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -52,109 +52,46 @@
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapicdp.h"
|
||||
#include "hbset.h"
|
||||
|
||||
#define HB_EOL_BUFFER_SIZE 4
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char * szEOL;
|
||||
HB_SIZE nLen;
|
||||
} HB_EOL_INFO, * PHB_EOL_INFO;
|
||||
|
||||
static int hb_mlEol( const char * pszString, HB_SIZE nLen,
|
||||
PHB_EOL_INFO pEOLs, int iEOLs )
|
||||
typedef struct
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < iEOLs; ++i )
|
||||
{
|
||||
if( nLen >= pEOLs[ i ].nLen &&
|
||||
memcmp( pszString, pEOLs[ i ].szEOL, pEOLs[ i ].nLen ) == 0 )
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
const char * pszString;
|
||||
HB_SIZE nLen;
|
||||
HB_SIZE nLineLength;
|
||||
HB_SIZE nTabSize;
|
||||
HB_BOOL fWordWrap;
|
||||
int iEOLs;
|
||||
PHB_EOL_INFO pEOLs;
|
||||
PHB_CODEPAGE cdp;
|
||||
|
||||
HB_SIZE nOffset;
|
||||
HB_SIZE nMaxCol;
|
||||
HB_SIZE nMaxPos;
|
||||
HB_SIZE nLine;
|
||||
HB_SIZE nCol;
|
||||
HB_SIZE nEOL;
|
||||
|
||||
HB_EOL_INFO EOL_buffer[ HB_EOL_BUFFER_SIZE ];
|
||||
}
|
||||
HB_MLC_INFO, * PHB_MLC_INFO;
|
||||
|
||||
static HB_SIZE hb_mlGetLine( const char * pszString, HB_SIZE nLen, HB_SIZE nOffset,
|
||||
HB_SIZE nLineLength, HB_SIZE nTabSize, HB_SIZE nMaxPos,
|
||||
HB_BOOL fWordWrap, PHB_EOL_INFO pEOLs, int iEOLs,
|
||||
HB_SIZE * pnLen, HB_SIZE * pnEOL )
|
||||
|
||||
static void hb_mlGetEOLs( PHB_MLC_INFO pMLC, int iParam )
|
||||
{
|
||||
HB_SIZE nCol = 0, nBlankCol = 0, nBlankPos = 0;
|
||||
int i;
|
||||
|
||||
if( pnEOL )
|
||||
* pnEOL = 0;
|
||||
|
||||
while( nOffset < nLen && ( nMaxPos == 0 || nOffset < nMaxPos ) )
|
||||
{
|
||||
if( pszString[ nOffset ] == HB_CHAR_SOFT1 &&
|
||||
pszString[ nOffset + 1 ] == HB_CHAR_SOFT2 )
|
||||
{
|
||||
nOffset += 2;
|
||||
if( !fWordWrap )
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
i = hb_mlEol( pszString + nOffset, nLen - nOffset, pEOLs, iEOLs );
|
||||
if( i >= 0 )
|
||||
{
|
||||
if( nMaxPos )
|
||||
nCol += pEOLs[ i ].nLen;
|
||||
else
|
||||
nOffset += pEOLs[ i ].nLen;
|
||||
if( pnEOL )
|
||||
* pnEOL = pEOLs[ i ].nLen;
|
||||
break;
|
||||
}
|
||||
|
||||
if( pszString[ nOffset ] == ' ' || pszString[ nOffset ] == HB_CHAR_HT )
|
||||
{
|
||||
nBlankCol = nCol;
|
||||
nBlankPos = nOffset;
|
||||
}
|
||||
|
||||
if( nCol >= nLineLength )
|
||||
{
|
||||
if( fWordWrap )
|
||||
{
|
||||
if( nBlankCol == 0 || pszString[ nOffset ] == ' ' ||
|
||||
pszString[ nOffset ] == HB_CHAR_HT )
|
||||
{
|
||||
nCol = nLineLength;
|
||||
if( pszString[ nOffset ] == ' ' )
|
||||
++nOffset;
|
||||
if( pszString[ nOffset ] == HB_CHAR_SOFT1 &&
|
||||
pszString[ nOffset + 1 ] == HB_CHAR_SOFT2 )
|
||||
nOffset += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
nCol = nBlankCol;
|
||||
nOffset = nBlankPos + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( nCol > nLineLength )
|
||||
--nOffset;
|
||||
nCol = nLineLength;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
nCol += pszString[ nOffset ] == HB_CHAR_HT ?
|
||||
nTabSize - ( nCol % nTabSize ) : 1;
|
||||
nOffset++;
|
||||
}
|
||||
* pnLen = nCol;
|
||||
|
||||
return nOffset;
|
||||
}
|
||||
|
||||
static PHB_EOL_INFO hb_mlGetEOLs( int iParam, int * piEOLs )
|
||||
{
|
||||
PHB_EOL_INFO pEOLs = NULL;
|
||||
int iEOLs = 0;
|
||||
HB_SIZE nLen;
|
||||
|
||||
pMLC->pEOLs = pMLC->EOL_buffer;
|
||||
|
||||
/* NOTE: This is a parameter extension (HB_EXTENSION) which breaks
|
||||
our effort to keep strict parameter compatibility with
|
||||
@@ -163,12 +100,11 @@ static PHB_EOL_INFO hb_mlGetEOLs( int iParam, int * piEOLs )
|
||||
Clipper will ignore these parameters and use CRLF EOL hard
|
||||
coded. [vszakats] */
|
||||
#ifndef HB_CLP_STRICT /* HB_EXTENSION */
|
||||
HB_SIZE nLen = hb_parclen( iParam );
|
||||
nLen = hb_parclen( iParam );
|
||||
if( nLen )
|
||||
{
|
||||
pEOLs = ( PHB_EOL_INFO ) hb_xgrab( sizeof( HB_EOL_INFO ) );
|
||||
pEOLs->szEOL = hb_parc( iParam );
|
||||
pEOLs->nLen = nLen;
|
||||
pMLC->pEOLs[ 0 ].szEOL = hb_parc( iParam );
|
||||
pMLC->pEOLs[ 0 ].nLen = nLen;
|
||||
iEOLs = 1;
|
||||
}
|
||||
else if( HB_ISARRAY( iParam ) )
|
||||
@@ -183,15 +119,16 @@ static PHB_EOL_INFO hb_mlGetEOLs( int iParam, int * piEOLs )
|
||||
}
|
||||
if( iEOLs )
|
||||
{
|
||||
pEOLs = ( PHB_EOL_INFO ) hb_xgrab( sizeof( HB_EOL_INFO ) * iEOLs );
|
||||
if( iEOLs > HB_EOL_BUFFER_SIZE )
|
||||
pMLC->pEOLs = ( PHB_EOL_INFO ) hb_xgrab( sizeof( HB_EOL_INFO ) * iEOLs );
|
||||
iEOLs = 0;
|
||||
for( n = 1; n <= nSize; ++n )
|
||||
{
|
||||
nLen = hb_arrayGetCLen( pArray, n );
|
||||
if( nLen > 0 )
|
||||
{
|
||||
pEOLs[ iEOLs ].szEOL = hb_arrayGetCPtr( pArray, n );
|
||||
pEOLs[ iEOLs ].nLen = nLen;
|
||||
pMLC->pEOLs[ iEOLs ].szEOL = hb_arrayGetCPtr( pArray, n );
|
||||
pMLC->pEOLs[ iEOLs ].nLen = nLen;
|
||||
++iEOLs;
|
||||
}
|
||||
}
|
||||
@@ -199,261 +136,383 @@ static PHB_EOL_INFO hb_mlGetEOLs( int iParam, int * piEOLs )
|
||||
}
|
||||
#else
|
||||
HB_SYMBOL_UNUSED( iParam );
|
||||
HB_SYMBOL_UNUSED( nLen );
|
||||
#endif
|
||||
|
||||
if( iEOLs == 0 )
|
||||
{
|
||||
pEOLs = ( PHB_EOL_INFO ) hb_xgrab( sizeof( HB_EOL_INFO ) );
|
||||
pEOLs->szEOL = hb_setGetEOL();
|
||||
if( !pEOLs->szEOL || !pEOLs->szEOL[ 0 ] )
|
||||
pEOLs->szEOL = hb_conNewLine();
|
||||
pEOLs->nLen = strlen( pEOLs->szEOL );
|
||||
iEOLs = pEOLs->nLen ? 1 : 0;
|
||||
pMLC->pEOLs[ 0 ].szEOL = hb_setGetEOL();
|
||||
if( !pMLC->pEOLs[ 0 ].szEOL || !pMLC->pEOLs[ 0 ].szEOL[ 0 ] )
|
||||
pMLC->pEOLs[ 0 ].szEOL = hb_conNewLine();
|
||||
pMLC->pEOLs[ 0 ].nLen = strlen( pMLC->pEOLs[ 0 ].szEOL );
|
||||
iEOLs = pMLC->pEOLs[ 0 ].nLen ? 1 : 0;
|
||||
}
|
||||
|
||||
* piEOLs = iEOLs;
|
||||
return pEOLs;
|
||||
pMLC->iEOLs = iEOLs;
|
||||
}
|
||||
|
||||
static const char * hb_mlGetParams( int iParAdd, HB_SIZE * pnLen,
|
||||
HB_SIZE * pnLineLength,
|
||||
HB_SIZE * pnTabSize, HB_BOOL * pfWordWrap,
|
||||
PHB_EOL_INFO * pEOLs, int * piEOLs )
|
||||
static HB_BOOL hb_mlInit( PHB_MLC_INFO pMLC, int iParAdd )
|
||||
{
|
||||
const char * pszString = hb_parc( 1 );
|
||||
if( pszString )
|
||||
HB_ISIZ nSize = hb_parnsdef( 2, 79 );
|
||||
|
||||
pMLC->pszString = hb_parc( 1 );
|
||||
if( pMLC->pszString && nSize > 0 )
|
||||
{
|
||||
if( HB_ISNUM( 2 ) )
|
||||
pMLC->nOffset = pMLC->nMaxCol = pMLC->nMaxPos = pMLC->nLine =
|
||||
pMLC->nCol = pMLC->nEOL = 0;
|
||||
|
||||
pMLC->nLineLength = nSize;
|
||||
pMLC->nLen = hb_parclen( 1 );
|
||||
|
||||
pMLC->nTabSize = hb_parnldef( 3 + iParAdd, 4 );
|
||||
pMLC->fWordWrap = hb_parldef( 4 + iParAdd, 1 );
|
||||
|
||||
#ifdef HB_CLP_STRICT
|
||||
if( pMLC->nLineLength > 254 )
|
||||
pMLC->nLineLength = 79;
|
||||
#endif
|
||||
if( pMLC->nTabSize >= pMLC->nLineLength )
|
||||
pMLC->nTabSize = pMLC->nLineLength - 1;
|
||||
if( pMLC->nTabSize == 0 )
|
||||
pMLC->nTabSize = 1;
|
||||
|
||||
pMLC->cdp = hb_vmCDP();
|
||||
if( !HB_CDP_ISCHARIDX( pMLC->cdp ) )
|
||||
pMLC->cdp = NULL;
|
||||
|
||||
hb_mlGetEOLs( pMLC, 5 + iParAdd );
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
return HB_FALSE;
|
||||
}
|
||||
|
||||
static void hb_mlExit( PHB_MLC_INFO pMLC )
|
||||
{
|
||||
if( pMLC->iEOLs > HB_EOL_BUFFER_SIZE )
|
||||
hb_xfree( pMLC->pEOLs );
|
||||
}
|
||||
|
||||
static int hb_mlEol( PHB_MLC_INFO pMLC )
|
||||
{
|
||||
const char * pszString = pMLC->pszString + pMLC->nOffset;
|
||||
HB_SIZE nLen = pMLC->nLen - pMLC->nOffset;
|
||||
PHB_EOL_INFO pEOLs = pMLC->pEOLs;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < pMLC->iEOLs; ++i )
|
||||
{
|
||||
if( pszString[ 0 ] == pEOLs[ i ].szEOL[ 0 ] &&
|
||||
( pEOLs[ i ].nLen == 1 ||
|
||||
( nLen >= pEOLs[ i ].nLen &&
|
||||
memcmp( pszString, pEOLs[ i ].szEOL, pEOLs[ i ].nLen ) == 0 ) ) )
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static HB_SIZE hb_mlGetLine( PHB_MLC_INFO pMLC )
|
||||
{
|
||||
HB_SIZE nBlankCol = 0, nBlankPos = 0, nLastPos;
|
||||
int i;
|
||||
|
||||
pMLC->nCol = pMLC->nEOL = 0;
|
||||
|
||||
if( pMLC->nOffset >= pMLC->nLen ||
|
||||
( pMLC->nMaxPos > 0 && pMLC->nOffset >= pMLC->nMaxPos ) )
|
||||
return HB_FALSE;
|
||||
|
||||
while( pMLC->nOffset < pMLC->nLen &&
|
||||
( pMLC->nMaxPos == 0 || pMLC->nOffset < pMLC->nMaxPos ) )
|
||||
{
|
||||
HB_WCHAR ch;
|
||||
|
||||
if( pMLC->pszString[ pMLC->nOffset ] == HB_CHAR_SOFT1 &&
|
||||
pMLC->pszString[ pMLC->nOffset + 1 ] == HB_CHAR_SOFT2 )
|
||||
{
|
||||
if( hb_parnd( 2 ) <= 0 )
|
||||
return NULL;
|
||||
* pnLineLength = hb_parns( 2 );
|
||||
if( pMLC->nMaxCol && pMLC->nCol )
|
||||
break;
|
||||
pMLC->nOffset += 2;
|
||||
if( !pMLC->fWordWrap )
|
||||
break;
|
||||
else if( nBlankPos + 2 == pMLC->nOffset )
|
||||
nBlankPos += 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
i = hb_mlEol( pMLC );
|
||||
if( i >= 0 )
|
||||
{
|
||||
pMLC->nEOL = pMLC->pEOLs[ i ].nLen;
|
||||
if( pMLC->nMaxCol == 0 )
|
||||
pMLC->nOffset += pMLC->nEOL;
|
||||
break;
|
||||
}
|
||||
else if( !pMLC->fWordWrap && pMLC->nCol >= pMLC->nLineLength )
|
||||
break;
|
||||
|
||||
nLastPos = pMLC->nOffset;
|
||||
if( pMLC->cdp )
|
||||
{
|
||||
if( !HB_CDPCHAR_GET( pMLC->cdp, pMLC->pszString, pMLC->nLen, &pMLC->nOffset, &ch ) )
|
||||
break;
|
||||
}
|
||||
else
|
||||
* pnLineLength = 79;
|
||||
* pnLen = hb_parclen( 1 );
|
||||
* pnTabSize = hb_parnldef( 3 + iParAdd, 4 );
|
||||
* pfWordWrap = hb_parldef( 4 + iParAdd, 1 );
|
||||
* pEOLs = hb_mlGetEOLs( 5 + iParAdd, piEOLs );
|
||||
#ifdef HB_CLP_STRICT
|
||||
if( * pnLineLength > 254 )
|
||||
* pnLineLength = 79;
|
||||
#endif
|
||||
if( * pnTabSize >= * pnLineLength )
|
||||
* pnTabSize = * pnLineLength - 1;
|
||||
else if( * pnTabSize == 0 )
|
||||
* pnTabSize = 1;
|
||||
ch = pMLC->pszString[ pMLC->nOffset++ ];
|
||||
|
||||
if( ch == ' ' || ch == HB_CHAR_HT )
|
||||
{
|
||||
nBlankCol = pMLC->nCol;
|
||||
nBlankPos = pMLC->nOffset;
|
||||
}
|
||||
|
||||
pMLC->nCol += ch == HB_CHAR_HT ?
|
||||
pMLC->nTabSize - ( pMLC->nCol % pMLC->nTabSize ) : 1;
|
||||
|
||||
if( pMLC->nMaxCol && pMLC->nCol >= pMLC->nMaxCol )
|
||||
{
|
||||
if( pMLC->nCol > pMLC->nMaxCol )
|
||||
pMLC->nOffset = nLastPos;
|
||||
break;
|
||||
}
|
||||
else if( pMLC->nCol > pMLC->nLineLength )
|
||||
{
|
||||
if( pMLC->fWordWrap )
|
||||
{
|
||||
if( nBlankCol != 0 )
|
||||
{
|
||||
if( pMLC->nMaxPos )
|
||||
pMLC->nCol = nBlankCol + 1;
|
||||
else
|
||||
pMLC->nCol = nBlankCol;
|
||||
pMLC->nOffset = nBlankPos;
|
||||
}
|
||||
else
|
||||
pMLC->nOffset = nLastPos;
|
||||
}
|
||||
else if( pMLC->nCol > pMLC->nLineLength )
|
||||
pMLC->nOffset = nLastPos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return pszString;
|
||||
|
||||
if( pMLC->nCol > pMLC->nLineLength )
|
||||
pMLC->nCol = pMLC->nLineLength;
|
||||
else if( pMLC->nMaxPos && pMLC->nCol )
|
||||
pMLC->nCol--;
|
||||
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* MEMOLINE( <cString>, [ <nLineLength>=79 ],
|
||||
* [ <nLineNumber>=1 ],
|
||||
* [ <nTabSize>=4 ], [ <lWrap>=.T. ],
|
||||
* [ <cEOL>|<acEOLs> ] ) -> <cLine>
|
||||
*/
|
||||
HB_FUNC( MEMOLINE )
|
||||
{
|
||||
HB_SIZE nLen, nLineLength, nTabSize;
|
||||
HB_BOOL fWordWrap;
|
||||
PHB_EOL_INFO pEOLs;
|
||||
int iEOLs;
|
||||
const char * pszString = hb_mlGetParams( 1, &nLen, &nLineLength,
|
||||
&nTabSize, &fWordWrap,
|
||||
&pEOLs, &iEOLs );
|
||||
char * szLine;
|
||||
HB_SIZE nLine = hb_parns( 3 );
|
||||
HB_SIZE nOffset = 0;
|
||||
HB_SIZE nCols = 0;
|
||||
HB_MLC_INFO MLC;
|
||||
HB_ISIZ nLine = hb_parnsdef( 3, 1 );
|
||||
char * szLine = NULL;
|
||||
HB_SIZE nIndex, nLen = 0, nSize, nCol;
|
||||
|
||||
if( !pszString )
|
||||
if( nLine >= 1 )
|
||||
{
|
||||
hb_retc_null();
|
||||
return;
|
||||
}
|
||||
|
||||
if( nLine == 0 )
|
||||
nLine = 1;
|
||||
|
||||
while( --nLine && nOffset < nLen )
|
||||
{
|
||||
nOffset = hb_mlGetLine( pszString, nLen, nOffset,
|
||||
nLineLength, nTabSize, 0, fWordWrap,
|
||||
pEOLs, iEOLs, &nCols, NULL );
|
||||
}
|
||||
if( nOffset < nLen )
|
||||
{
|
||||
HB_SIZE nCol = 0;
|
||||
hb_mlGetLine( pszString, nLen, nOffset,
|
||||
nLineLength, nTabSize, 0, fWordWrap,
|
||||
pEOLs, iEOLs, &nCols, NULL );
|
||||
szLine = ( char * ) hb_xgrab( nLineLength + 1 );
|
||||
while( nCol < nCols )
|
||||
if( hb_mlInit( &MLC, 1 ) )
|
||||
{
|
||||
if( pszString[ nOffset ] == HB_CHAR_HT )
|
||||
while( --nLine )
|
||||
{
|
||||
HB_SIZE n = nTabSize - ( nCol % nTabSize );
|
||||
do
|
||||
szLine[ nCol++ ] = ' ';
|
||||
while( --n && nCol < nCols );
|
||||
if( !hb_mlGetLine( &MLC ) )
|
||||
break;
|
||||
}
|
||||
else if( pszString[ nOffset ] == HB_CHAR_SOFT1 &&
|
||||
pszString[ nOffset + 1 ] == HB_CHAR_SOFT2 )
|
||||
nOffset++;
|
||||
else
|
||||
szLine[ nCol++ ] = pszString[ nOffset ];
|
||||
nOffset++;
|
||||
if( nLine == 0 )
|
||||
{
|
||||
nIndex = MLC.nOffset;
|
||||
|
||||
/* CA-Cl*pper also does not check if line exists and always
|
||||
* fill one line more, i.e.:
|
||||
* for i := 0 to 4
|
||||
* ? "[" + memoline( " ", 20, i ) + "]"
|
||||
* next
|
||||
* [druzus]
|
||||
*/
|
||||
hb_mlGetLine( &MLC );
|
||||
|
||||
if( MLC.cdp )
|
||||
nSize = ( MLC.nOffset - nIndex ) + MLC.nLineLength;
|
||||
else
|
||||
nSize = MLC.nLineLength;
|
||||
szLine = ( char * ) hb_xgrab( nSize + 1 );
|
||||
nCol = 0;
|
||||
while( nIndex < MLC.nLen && nCol < MLC.nCol )
|
||||
{
|
||||
if( MLC.pszString[ nIndex ] == HB_CHAR_SOFT1 &&
|
||||
MLC.pszString[ nIndex + 1 ] == HB_CHAR_SOFT2 )
|
||||
nIndex += 2 ;
|
||||
else
|
||||
{
|
||||
HB_WCHAR wc;
|
||||
|
||||
if( MLC.cdp )
|
||||
{
|
||||
if( !HB_CDPCHAR_GET( MLC.cdp, MLC.pszString, MLC.nLen, &nIndex, &wc ) )
|
||||
break;
|
||||
}
|
||||
else
|
||||
wc = MLC.pszString[ nIndex++ ];
|
||||
|
||||
if( wc == HB_CHAR_HT )
|
||||
{
|
||||
HB_SIZE n = MLC.nTabSize - ( nLen % MLC.nTabSize );
|
||||
do
|
||||
szLine[ nLen++ ] = ' ';
|
||||
while( ++nCol < MLC.nCol && --n );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( MLC.cdp )
|
||||
{
|
||||
if( !HB_CDPCHAR_PUT( MLC.cdp, szLine, nSize, &nLen, wc ) )
|
||||
break;
|
||||
}
|
||||
else
|
||||
szLine[ nLen++ ] = ( char ) wc;
|
||||
++nCol;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( nCol < MLC.nLineLength )
|
||||
{
|
||||
nCol = MLC.nLineLength - nCol;
|
||||
if( nCol > nSize - nLen )
|
||||
nCol = nSize - nLen;
|
||||
memset( szLine + nLen, ' ', nCol );
|
||||
nLen += nCol;
|
||||
}
|
||||
}
|
||||
hb_mlExit( &MLC );
|
||||
}
|
||||
if( nCols < nLineLength )
|
||||
memset( szLine + nCols, ' ', nLineLength - nCols );
|
||||
szLine[ nLineLength ] = 0;
|
||||
hb_retclen_buffer( szLine, nLineLength );
|
||||
}
|
||||
else
|
||||
if( szLine == NULL )
|
||||
hb_retc_null();
|
||||
hb_xfree( pEOLs );
|
||||
else
|
||||
hb_retclen_buffer( szLine, nLen );
|
||||
}
|
||||
|
||||
/* MLCOUNT( <cString>, [ <nLineLength>=79 ],
|
||||
* [ <nTabSize>=4 ], [ <lWrap>=.T. ],
|
||||
* [ <cEOL>|<acEOLs> ] ) -> <nLines>
|
||||
*/
|
||||
HB_FUNC( MLCOUNT )
|
||||
{
|
||||
HB_SIZE nLen, nLineLength, nTabSize;
|
||||
HB_BOOL fWordWrap;
|
||||
PHB_EOL_INFO pEOLs;
|
||||
int iEOLs;
|
||||
const char * pszString = hb_mlGetParams( 0, &nLen, &nLineLength,
|
||||
&nTabSize, &fWordWrap,
|
||||
&pEOLs, &iEOLs );
|
||||
HB_MLC_INFO MLC;
|
||||
HB_SIZE nLines = 0;
|
||||
HB_SIZE nOffset = 0;
|
||||
HB_SIZE nCols = 0;
|
||||
|
||||
if( pszString )
|
||||
if( hb_mlInit( &MLC, 0 ) )
|
||||
{
|
||||
while( nOffset < nLen )
|
||||
{
|
||||
while( hb_mlGetLine( &MLC ) )
|
||||
++nLines;
|
||||
nOffset = hb_mlGetLine( pszString, nLen, nOffset,
|
||||
nLineLength, nTabSize, 0, fWordWrap,
|
||||
pEOLs, iEOLs, &nCols, NULL );
|
||||
}
|
||||
hb_xfree( pEOLs );
|
||||
hb_mlExit( &MLC );
|
||||
}
|
||||
hb_retns( nLines );
|
||||
}
|
||||
|
||||
/* MLPOS( <cString>, [ <nLineLength>=79 ],
|
||||
* [ <nLineNumber>=1 ],
|
||||
* [ <nTabSize>=4 ], [ <lWrap>=.T. ],
|
||||
* [ <cEOL>|<acEOLs> ] ) -> <nLinePos>
|
||||
*/
|
||||
HB_FUNC( MLPOS )
|
||||
{
|
||||
HB_SIZE nLen, nLineLength, nTabSize;
|
||||
HB_BOOL fWordWrap;
|
||||
PHB_EOL_INFO pEOLs;
|
||||
int iEOLs;
|
||||
const char * pszString = hb_mlGetParams( 1, &nLen, &nLineLength,
|
||||
&nTabSize, &fWordWrap,
|
||||
&pEOLs, &iEOLs );
|
||||
HB_SIZE nLine = hb_parns( 3 );
|
||||
HB_MLC_INFO MLC;
|
||||
HB_ISIZ nLine = hb_parnsdef( 3, 1 );
|
||||
HB_SIZE nOffset = 0;
|
||||
HB_SIZE nCols = 0;
|
||||
|
||||
if( pszString )
|
||||
if( nLine >= 1 )
|
||||
{
|
||||
if( nLine == 0 )
|
||||
nLine = 1;
|
||||
while( --nLine && nOffset < nLen )
|
||||
nOffset = hb_mlGetLine( pszString, nLen, nOffset,
|
||||
nLineLength, nTabSize, 0, fWordWrap,
|
||||
pEOLs, iEOLs, &nCols, NULL );
|
||||
if( nOffset < nLen )
|
||||
++nOffset;
|
||||
hb_xfree( pEOLs );
|
||||
if( hb_mlInit( &MLC, 1 ) )
|
||||
{
|
||||
while( --nLine && hb_mlGetLine( &MLC ) ) { ; }
|
||||
nOffset = MLC.nOffset;
|
||||
if( MLC.cdp )
|
||||
nOffset = hb_cdpTextLen( MLC.cdp, MLC.pszString, nOffset );
|
||||
if( MLC.nOffset < MLC.nLen )
|
||||
++nOffset;
|
||||
hb_mlExit( &MLC );
|
||||
}
|
||||
}
|
||||
hb_retns( nOffset );
|
||||
}
|
||||
|
||||
/* MLCTOPOS( <cString>, [ <nLineLength>=79 ],
|
||||
* [ <nLine>=1 ], [ <nCol>=0 ],
|
||||
* [ <nTabSize>=4 ], [ <lWrap>=.T. ],
|
||||
* [ <cEOL>|<acEOLs> ] ) -> <nPos>
|
||||
*/
|
||||
HB_FUNC( MLCTOPOS )
|
||||
{
|
||||
HB_SIZE nLen, nLineLength, nTabSize;
|
||||
HB_BOOL fWordWrap;
|
||||
PHB_EOL_INFO pEOLs;
|
||||
int iEOLs;
|
||||
const char * pszString = hb_mlGetParams( 2, &nLen, &nLineLength,
|
||||
&nTabSize, &fWordWrap,
|
||||
&pEOLs, &iEOLs );
|
||||
HB_SIZE nLine = hb_parns( 3 );
|
||||
HB_SIZE nCol = hb_parns( 4 );
|
||||
HB_SIZE nOffset = 0;
|
||||
HB_SIZE nCols = 0;
|
||||
|
||||
if( pszString )
|
||||
if( nLine > 0 && HB_ISNUM( 4 ) )
|
||||
{
|
||||
if( nLineLength > 4 && nLine && HB_ISNUM( 4 ) )
|
||||
HB_MLC_INFO MLC;
|
||||
if( hb_mlInit( &MLC, 2 ) )
|
||||
{
|
||||
while( --nLine && nOffset < nLen )
|
||||
nOffset = hb_mlGetLine( pszString, nLen, nOffset,
|
||||
nLineLength, nTabSize, 0, fWordWrap,
|
||||
pEOLs, iEOLs, &nCols, NULL );
|
||||
if( nOffset < nLen && nCol )
|
||||
nOffset = hb_mlGetLine( pszString, nLen, nOffset,
|
||||
nCol, nTabSize, nLen, HB_FALSE,
|
||||
pEOLs, iEOLs, &nCols, NULL );
|
||||
if( MLC.nLineLength > 4 )
|
||||
{
|
||||
while( --nLine && hb_mlGetLine( &MLC ) ) { ; }
|
||||
if( nCol && nLine == 0 )
|
||||
{
|
||||
MLC.nMaxCol = nCol;
|
||||
MLC.nLineLength = nCol;
|
||||
hb_mlGetLine( &MLC );
|
||||
}
|
||||
nOffset = MLC.nOffset;
|
||||
if( MLC.cdp )
|
||||
nOffset = hb_cdpTextLen( MLC.cdp, MLC.pszString, nOffset );
|
||||
}
|
||||
hb_mlExit( &MLC );
|
||||
}
|
||||
hb_xfree( pEOLs );
|
||||
}
|
||||
++nOffset;
|
||||
hb_retns( nOffset );
|
||||
hb_retns( nOffset + 1 );
|
||||
}
|
||||
|
||||
/* MPOSTOLC( <cString>, [ <nLineLength>=79 ],
|
||||
* [ <nPos>=1 ],
|
||||
* [ <nTabSize>=4 ], [ <lWrap>=.T. ],
|
||||
* [ <cEOL>|<acEOLs> ] ) -> <aLineCol>
|
||||
*/
|
||||
HB_FUNC( MPOSTOLC )
|
||||
{
|
||||
HB_SIZE nLen, nLineLength, nTabSize;
|
||||
HB_BOOL fWordWrap;
|
||||
PHB_EOL_INFO pEOLs;
|
||||
int iEOLs;
|
||||
const char * pszString = hb_mlGetParams( 1, &nLen, &nLineLength,
|
||||
&nTabSize, &fWordWrap,
|
||||
&pEOLs, &iEOLs );
|
||||
HB_SIZE nPos = hb_parns( 3 );
|
||||
HB_SIZE nOffset = 0;
|
||||
HB_ISIZ nPos = hb_parns( 3 );
|
||||
HB_SIZE nLine = 0;
|
||||
HB_SIZE nCol = 0;
|
||||
HB_SIZE nEOL = 0;
|
||||
|
||||
if( pszString )
|
||||
if( nPos > 0 )
|
||||
{
|
||||
if( nPos && nLen )
|
||||
HB_MLC_INFO MLC;
|
||||
if( hb_mlInit( &MLC, 1 ) )
|
||||
{
|
||||
if( --nPos )
|
||||
if( MLC.cdp )
|
||||
{
|
||||
do
|
||||
HB_SIZE nRest = nPos;
|
||||
nPos = hb_cdpTextPosEx( MLC.cdp, MLC.pszString, MLC.nLen, &nRest );
|
||||
nPos += nRest;
|
||||
}
|
||||
MLC.nMaxPos = nPos;
|
||||
if( MLC.nMaxPos <= MLC.nLen )
|
||||
{
|
||||
while( hb_mlGetLine( &MLC ) )
|
||||
{
|
||||
++nLine;
|
||||
nOffset = hb_mlGetLine( pszString, nLen, nOffset,
|
||||
nLineLength, nTabSize, nPos, fWordWrap,
|
||||
pEOLs, iEOLs, &nCol, &nEOL );
|
||||
if( nEOL )
|
||||
{
|
||||
if( nOffset + nEOL == nPos )
|
||||
{
|
||||
nCol = 0;
|
||||
++nLine;
|
||||
break;
|
||||
}
|
||||
nOffset += nEOL;
|
||||
}
|
||||
}
|
||||
while( nOffset < nLen && nOffset < nPos );
|
||||
|
||||
if( nLine && nCol == nLineLength && nPos <= nLen &&
|
||||
( hb_mlEol( pszString + nPos, nLen - nPos, pEOLs, iEOLs ) >= 0 ||
|
||||
( pszString[ nPos ] == HB_CHAR_SOFT1 &&
|
||||
pszString[ nPos + 1 ] == HB_CHAR_SOFT2 ) ||
|
||||
( nPos > 0 && pszString[ nPos - 1 ] == HB_CHAR_SOFT1 &&
|
||||
pszString[ nPos ] == HB_CHAR_SOFT2 ) ||
|
||||
( nPos > 1 && pszString[ nPos - 2 ] == HB_CHAR_SOFT1 &&
|
||||
pszString[ nPos - 1 ] == HB_CHAR_SOFT2 ) ) )
|
||||
{
|
||||
nCol = 0;
|
||||
nCol = MLC.nCol;
|
||||
++nLine;
|
||||
}
|
||||
}
|
||||
else
|
||||
++nLine;
|
||||
hb_mlExit( &MLC );
|
||||
}
|
||||
hb_xfree( pEOLs );
|
||||
}
|
||||
hb_reta( 2 );
|
||||
hb_storvns( nLine, -1, 1 );
|
||||
|
||||
@@ -54,10 +54,6 @@
|
||||
|
||||
/* HARBOUR callable interface */
|
||||
|
||||
#define M_BUTTON_LEFT 0
|
||||
#define M_BUTTON_RIGHT 1
|
||||
#define M_BUTTON_MIDDLE 2
|
||||
|
||||
#ifdef HB_COMPAT_C53
|
||||
|
||||
HB_FUNC( MPRESENT )
|
||||
@@ -117,12 +113,12 @@ HB_FUNC( MSETPOS )
|
||||
|
||||
HB_FUNC( MLEFTDOWN )
|
||||
{
|
||||
hb_retl( hb_mouseButtonState( M_BUTTON_LEFT ) );
|
||||
hb_retl( hb_mouseButtonState( HB_MBUTTON_LEFT ) );
|
||||
}
|
||||
|
||||
HB_FUNC( MRIGHTDOWN )
|
||||
{
|
||||
hb_retl( hb_mouseButtonState( M_BUTTON_RIGHT ) );
|
||||
hb_retl( hb_mouseButtonState( HB_MBUTTON_RIGHT ) );
|
||||
}
|
||||
|
||||
HB_FUNC( MDBLCLK )
|
||||
@@ -166,5 +162,5 @@ HB_FUNC( MSETBOUNDS )
|
||||
|
||||
HB_FUNC( HB_MMIDDLEDOWN )
|
||||
{
|
||||
hb_retl( hb_mouseButtonState( M_BUTTON_MIDDLE ) );
|
||||
hb_retl( hb_mouseButtonState( HB_MBUTTON_MIDDLE ) );
|
||||
}
|
||||
|
||||
@@ -63,10 +63,6 @@
|
||||
|
||||
#include "hbapi.h"
|
||||
|
||||
#if defined( HB_OS_DOS )
|
||||
# include <dos.h>
|
||||
#endif
|
||||
|
||||
#if defined( HB_OS_OS2 ) && defined( __GNUC__ )
|
||||
|
||||
#include "hb_io.h"
|
||||
@@ -84,6 +80,7 @@
|
||||
|
||||
#elif defined( HB_OS_DOS )
|
||||
|
||||
#include <dos.h>
|
||||
#if defined( __DJGPP__ ) || defined( __RSX32__ ) || defined( __GNUC__ )
|
||||
#include "hb_io.h"
|
||||
#include <sys/param.h>
|
||||
@@ -104,6 +101,7 @@
|
||||
#elif defined( HB_OS_WIN )
|
||||
|
||||
#include <windows.h>
|
||||
#include "hbwinuni.h"
|
||||
#if defined( HB_OS_WIN_CE )
|
||||
#include "hbwince.h"
|
||||
#endif
|
||||
@@ -130,19 +128,19 @@ char * hb_netname( void )
|
||||
# if defined( __WATCOMC__ )
|
||||
return hb_getenv( "HOSTNAME" );
|
||||
# else
|
||||
char * pszValue = ( char * ) hb_xgrab( MAXGETHOSTNAME + 1 );
|
||||
pszValue[ 0 ] = '\0';
|
||||
gethostname( pszValue, MAXGETHOSTNAME );
|
||||
return pszValue;
|
||||
char szValue[ MAXGETHOSTNAME + 1 ];
|
||||
szValue[ 0 ] = szValue[ MAXGETHOSTNAME ] = '\0';
|
||||
gethostname( szValue, MAXGETHOSTNAME );
|
||||
return szValue[ 0 ] ? hb_osStrDecode( szValue ) : NULL;
|
||||
# endif
|
||||
|
||||
#elif defined( HB_OS_DOS )
|
||||
|
||||
# if defined( __DJGPP__ ) || defined( __RSX32__ ) || defined( __GNUC__ )
|
||||
char * pszValue = ( char * ) hb_xgrab( MAXGETHOSTNAME + 1 );
|
||||
pszValue[ 0 ] = '\0';
|
||||
gethostname( pszValue, MAXGETHOSTNAME );
|
||||
return pszValue;
|
||||
char szValue[ MAXGETHOSTNAME + 1 ];
|
||||
szValue[ 0 ] = szValue[ MAXGETHOSTNAME ] = '\0';
|
||||
gethostname( szValue, MAXGETHOSTNAME );
|
||||
return szValue[ 0 ] ? hb_osStrDecode( szValue ) : NULL;
|
||||
# else
|
||||
union REGS regs;
|
||||
struct SREGS sregs;
|
||||
@@ -165,22 +163,16 @@ char * hb_netname( void )
|
||||
|
||||
DWORD ulLen = MAX_COMPUTERNAME_LENGTH + 1;
|
||||
TCHAR lpValue[ MAX_COMPUTERNAME_LENGTH + 1 ];
|
||||
char * pszValue;
|
||||
|
||||
lpValue[ 0 ] = TEXT( '\0' );
|
||||
GetComputerName( lpValue, &ulLen );
|
||||
lpValue[ MAX_COMPUTERNAME_LENGTH ] = TEXT( '\0' );
|
||||
|
||||
#if defined( UNICODE )
|
||||
pszValue = hb_wctomb( lpValue );
|
||||
#else
|
||||
pszValue = hb_strdup( lpValue );
|
||||
#endif
|
||||
|
||||
return pszValue;
|
||||
return lpValue[ 0 ] ? HB_OSSTRDUP( lpValue ) : NULL;
|
||||
|
||||
#else
|
||||
|
||||
return hb_strdup( "" );
|
||||
return NULL;
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -195,29 +187,23 @@ char * hb_username( void )
|
||||
return hb_getenv( "USER" );
|
||||
# else
|
||||
struct passwd * pwd = getpwuid( getuid() );
|
||||
return pwd && pwd->pw_name ? hb_strdup( pwd->pw_name ) : hb_getenv( "USER" );
|
||||
return pwd && pwd->pw_name ? hb_osStrDecode( pwd->pw_name ) : hb_getenv( "USER" );
|
||||
# endif
|
||||
|
||||
#elif defined( HB_OS_WIN )
|
||||
|
||||
DWORD ulLen = 256;
|
||||
TCHAR lpValue[ 256 ];
|
||||
char * pszValue;
|
||||
|
||||
lpValue[ 0 ] = TEXT( '\0' );
|
||||
GetUserName( lpValue, &ulLen );
|
||||
lpValue[ 255 ] = TEXT( '\0' );
|
||||
|
||||
#if defined( UNICODE )
|
||||
pszValue = hb_wctomb( lpValue );
|
||||
#else
|
||||
pszValue = hb_strdup( lpValue );
|
||||
#endif
|
||||
|
||||
return pszValue;
|
||||
return lpValue[ 0 ] ? HB_OSSTRDUP( lpValue ) : NULL;
|
||||
|
||||
#else
|
||||
|
||||
return hb_strdup( "" );
|
||||
return NULL;
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -227,7 +213,7 @@ HB_FUNC( NETNAME )
|
||||
char * buffer = hb_netname();
|
||||
|
||||
if( buffer )
|
||||
hb_retc_buffer( ( char * ) hb_osDecodeCP( buffer, NULL, NULL ) );
|
||||
hb_retc_buffer( buffer );
|
||||
else
|
||||
hb_retc_null();
|
||||
}
|
||||
@@ -237,7 +223,7 @@ HB_FUNC( HB_USERNAME )
|
||||
char * buffer = hb_username();
|
||||
|
||||
if( buffer )
|
||||
hb_retc_buffer( ( char * ) hb_osDecodeCP( buffer, NULL, NULL ) );
|
||||
hb_retc_buffer( buffer );
|
||||
else
|
||||
hb_retc_null();
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ HB_FUNC( __BOX )
|
||||
hb_itemGetNI( pLeft),
|
||||
hb_itemGetNI( pBottom ),
|
||||
hb_itemGetNI( pRight ),
|
||||
*pszBox ? pszBox : " " );
|
||||
pszBox );
|
||||
}
|
||||
|
||||
HB_FUNC( __BOXD )
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Harbour Project source code:
|
||||
* PADC() function
|
||||
*
|
||||
* Copyright 2012 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* Copyright 1999 Matthew Hamilton <mhamilton@bunge.com.au>
|
||||
* www - http://harbour-project.org
|
||||
*
|
||||
@@ -52,8 +53,16 @@
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapicdp.h"
|
||||
#include "hbapierr.h"
|
||||
|
||||
static HB_SIZE hb_cdpItemLen( PHB_CODEPAGE cdp, PHB_ITEM pItem )
|
||||
{
|
||||
HB_SIZE nLen = hb_itemGetCLen( pItem );
|
||||
return nLen && HB_CDP_ISCHARIDX( cdp ) ?
|
||||
hb_cdpTextLen( cdp, hb_itemGetCPtr( pItem ), nLen ) : nLen;
|
||||
}
|
||||
|
||||
/* centre-pads a date, number, or string with spaces or supplied character */
|
||||
HB_FUNC( PADC )
|
||||
{
|
||||
@@ -65,8 +74,10 @@ HB_FUNC( PADC )
|
||||
if( nLen > 0 )
|
||||
{
|
||||
PHB_ITEM pItem = hb_param( 1, HB_IT_ANY );
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
|
||||
if( pItem && HB_IS_STRING( pItem ) && ( HB_SIZE ) nLen == hb_itemGetCLen( pItem ) )
|
||||
if( pItem && HB_IS_STRING( pItem ) &&
|
||||
( HB_SIZE ) nLen == hb_cdpItemLen( cdp, pItem ) )
|
||||
{
|
||||
hb_itemReturn( pItem );
|
||||
}
|
||||
@@ -75,6 +86,13 @@ HB_FUNC( PADC )
|
||||
szText = hb_itemPadConv( pItem, &nSize, &bFreeReq );
|
||||
if( szText )
|
||||
{
|
||||
if( HB_CDP_ISCHARIDX( cdp ) )
|
||||
{
|
||||
HB_SIZE nText = nLen;
|
||||
nLen = hb_cdpTextPosEx( cdp, szText, nSize, &nText );
|
||||
nLen += nText;
|
||||
}
|
||||
|
||||
if( ( HB_SIZE ) nLen > nSize )
|
||||
{
|
||||
char * szResult = ( char * ) hb_xgrab( nLen + 1 );
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Harbour Project source code:
|
||||
* PADL() function
|
||||
*
|
||||
* Copyright 2012 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* Copyright 1999 Matthew Hamilton <mhamilton@bunge.com.au>
|
||||
* www - http://harbour-project.org
|
||||
*
|
||||
@@ -52,8 +53,16 @@
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapicdp.h"
|
||||
#include "hbapierr.h"
|
||||
|
||||
static HB_SIZE hb_cdpItemLen( PHB_CODEPAGE cdp, PHB_ITEM pItem )
|
||||
{
|
||||
HB_SIZE nLen = hb_itemGetCLen( pItem );
|
||||
return nLen && HB_CDP_ISCHARIDX( cdp ) ?
|
||||
hb_cdpTextLen( cdp, hb_itemGetCPtr( pItem ), nLen ) : nLen;
|
||||
}
|
||||
|
||||
/* left-pads a date, number, or string with spaces or supplied character */
|
||||
HB_FUNC( PADL )
|
||||
{
|
||||
@@ -65,8 +74,10 @@ HB_FUNC( PADL )
|
||||
if( nLen > 0 )
|
||||
{
|
||||
PHB_ITEM pItem = hb_param( 1, HB_IT_ANY );
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
|
||||
if( pItem && HB_IS_STRING( pItem ) && ( HB_SIZE ) nLen == hb_itemGetCLen( pItem ) )
|
||||
if( pItem && HB_IS_STRING( pItem ) &&
|
||||
( HB_SIZE ) nLen == hb_cdpItemLen( cdp, pItem ) )
|
||||
{
|
||||
hb_itemReturn( pItem );
|
||||
}
|
||||
@@ -75,6 +86,13 @@ HB_FUNC( PADL )
|
||||
szText = hb_itemPadConv( pItem, &nSize, &bFreeReq );
|
||||
if( szText )
|
||||
{
|
||||
if( HB_CDP_ISCHARIDX( cdp ) )
|
||||
{
|
||||
HB_SIZE nText = nLen;
|
||||
nLen = hb_cdpTextPosEx( cdp, szText, nSize, &nText );
|
||||
nLen += nText;
|
||||
}
|
||||
|
||||
if( ( HB_SIZE ) nLen > nSize )
|
||||
{
|
||||
char * szResult = ( char * ) hb_xgrab( nLen + 1 );
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Harbour Project source code:
|
||||
* PADR() function
|
||||
*
|
||||
* Copyright 2012 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* Copyright 1999 Matthew Hamilton <mhamilton@bunge.com.au>
|
||||
* www - http://harbour-project.org
|
||||
*
|
||||
@@ -52,8 +53,16 @@
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapicdp.h"
|
||||
#include "hbapierr.h"
|
||||
|
||||
static HB_SIZE hb_cdpItemLen( PHB_CODEPAGE cdp, PHB_ITEM pItem )
|
||||
{
|
||||
HB_SIZE nLen = hb_itemGetCLen( pItem );
|
||||
return nLen && HB_CDP_ISCHARIDX( cdp ) ?
|
||||
hb_cdpTextLen( cdp, hb_itemGetCPtr( pItem ), nLen ) : nLen;
|
||||
}
|
||||
|
||||
/* right-pads a date, number, or string with spaces or supplied character */
|
||||
HB_FUNC( PADR )
|
||||
{
|
||||
@@ -65,8 +74,10 @@ HB_FUNC( PADR )
|
||||
if( nLen > 0 )
|
||||
{
|
||||
PHB_ITEM pItem = hb_param( 1, HB_IT_ANY );
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
|
||||
if( pItem && HB_IS_STRING( pItem ) && ( HB_SIZE ) nLen == hb_itemGetCLen( pItem ) )
|
||||
if( pItem && HB_IS_STRING( pItem ) &&
|
||||
( HB_SIZE ) nLen == hb_cdpItemLen( cdp, pItem ) )
|
||||
{
|
||||
hb_itemReturn( pItem );
|
||||
}
|
||||
@@ -75,6 +86,13 @@ HB_FUNC( PADR )
|
||||
szText = hb_itemPadConv( pItem, &nSize, &bFreeReq );
|
||||
if( szText )
|
||||
{
|
||||
if( HB_CDP_ISCHARIDX( cdp ) )
|
||||
{
|
||||
HB_SIZE nText = nLen;
|
||||
nLen = hb_cdpTextPosEx( cdp, szText, nSize, &nText );
|
||||
nLen += nText;
|
||||
}
|
||||
|
||||
if( ( HB_SIZE ) nLen > nSize )
|
||||
{
|
||||
char * szResult = ( char * ) hb_xgrab( nLen + 1 );
|
||||
|
||||
@@ -322,20 +322,10 @@ HB_FUNC( HB_CURDRIVE )
|
||||
|
||||
HB_FUNC( HB_PROGNAME )
|
||||
{
|
||||
const char * szBaseName = hb_cmdargARGVN( 0 );
|
||||
char * pszBaseName = hb_cmdargProgName();
|
||||
|
||||
if( szBaseName )
|
||||
{
|
||||
/* Convert from OS codepage */
|
||||
char * pszFree = NULL;
|
||||
|
||||
szBaseName = hb_osDecodeCP( szBaseName, &pszFree, NULL );
|
||||
|
||||
if( pszFree )
|
||||
hb_retc_buffer( pszFree );
|
||||
else
|
||||
hb_retc( szBaseName );
|
||||
}
|
||||
if( pszBaseName )
|
||||
hb_retc_buffer( pszBaseName );
|
||||
else
|
||||
hb_retc_null();
|
||||
}
|
||||
|
||||
@@ -189,19 +189,17 @@ METHOD display() CLASS RADIOBUTTN
|
||||
|
||||
METHOD isAccel( xKey ) CLASS RADIOBUTTN
|
||||
|
||||
LOCAL nPos
|
||||
LOCAL cCaption
|
||||
LOCAL cKey
|
||||
|
||||
IF ISNUMBER( xKey )
|
||||
xKey := Chr( xKey )
|
||||
ELSEIF !ISCHARACTER( xKey )
|
||||
IF ISCHARACTER( xKey )
|
||||
cKey := xKey
|
||||
ELSEIF ISNUMBER( xKey )
|
||||
cKey := hb_KeyChar( xKey )
|
||||
ELSE
|
||||
RETURN .F.
|
||||
ENDIF
|
||||
|
||||
cCaption := ::cCaption
|
||||
|
||||
RETURN ( nPos := At( "&", cCaption ) ) > 0 .AND. ;
|
||||
Lower( SubStr( cCaption, nPos + 1, 1 ) ) == Lower( xKey )
|
||||
RETURN Len( cKey ) > 0 .AND. hb_AtI( "&" + cKey, ::cCaption ) > 0
|
||||
|
||||
METHOD hitTest( nMRow, nMCol ) CLASS RADIOBUTTN
|
||||
|
||||
|
||||
@@ -208,16 +208,22 @@ METHOD display() CLASS RADIOGROUP
|
||||
|
||||
METHOD getAccel( xValue ) CLASS RADIOGROUP
|
||||
|
||||
DO CASE
|
||||
CASE ISNUMBER( xValue )
|
||||
xValue := Chr( xValue )
|
||||
CASE !ISCHARACTER( xValue )
|
||||
LOCAL cValue
|
||||
|
||||
IF ISCHARACTER( xValue )
|
||||
cValue := xValue
|
||||
ELSEIF ISNUMBER( xValue )
|
||||
cValue := hb_KeyChar( xValue )
|
||||
ELSE
|
||||
RETURN 0
|
||||
ENDCASE
|
||||
ENDIF
|
||||
|
||||
xValue := Lower( xValue )
|
||||
IF Len( cValue ) > 0
|
||||
cValue := Lower( cValue )
|
||||
RETURN AScan( ::aItems, {| o | o:isAccel( cValue ) } )
|
||||
ENDIF
|
||||
|
||||
RETURN AScan( ::aItems, {| o | o:isAccel( xValue ) } )
|
||||
RETURN 0
|
||||
|
||||
METHOD getItem( nPos ) CLASS RADIOGROUP
|
||||
RETURN iif( nPos >= 1 .AND. nPos <= ::nItemCount, ::aItems[ nPos ], NIL )
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Harbour Project source code:
|
||||
* RAT() function
|
||||
*
|
||||
* Copyright 2012 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* Copyright 1999 Antonio Linares <alinares@fivetech.com>
|
||||
* www - http://harbour-project.org
|
||||
*
|
||||
@@ -51,85 +52,92 @@
|
||||
*/
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapicdp.h"
|
||||
|
||||
HB_FUNC( RAT )
|
||||
{
|
||||
HB_SIZE nSubLen = hb_parclen( 1 );
|
||||
HB_SIZE nPos = 0;
|
||||
|
||||
if( nSubLen )
|
||||
{
|
||||
HB_ISIZ nPos = hb_parclen( 2 ) - nSubLen;
|
||||
HB_ISIZ nTo = hb_parclen( 2 ) - nSubLen;
|
||||
|
||||
if( nPos >= 0 )
|
||||
if( nTo >= 0 )
|
||||
{
|
||||
const char * pszSub = hb_parc( 1 );
|
||||
const char * pszText = hb_parc( 2 );
|
||||
HB_BOOL bFound = HB_FALSE;
|
||||
|
||||
while( nPos >= 0 && !bFound )
|
||||
do
|
||||
{
|
||||
if( *( pszText + nPos ) == *pszSub )
|
||||
bFound = ( memcmp( pszSub, pszText + nPos, nSubLen ) == 0 );
|
||||
nPos--;
|
||||
if( pszText[ nTo ] == *pszSub &&
|
||||
memcmp( pszSub, pszText + nTo, nSubLen ) == 0 )
|
||||
{
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
if( HB_CDP_ISCHARIDX( cdp ) )
|
||||
nPos = hb_cdpTextLen( cdp, pszText, nTo ) + 1;
|
||||
else
|
||||
nPos = nTo + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
hb_retns( bFound ? nPos + 2 : 0 );
|
||||
while( --nTo >= 0 );
|
||||
}
|
||||
else
|
||||
hb_retns( 0 );
|
||||
}
|
||||
else
|
||||
/* This function never seems to raise an error */
|
||||
hb_retns( 0 );
|
||||
/* This function never seems to raise an error */
|
||||
hb_retns( nPos );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_RAT )
|
||||
{
|
||||
HB_SIZE nSubLen = hb_parclen( 1 );
|
||||
HB_SIZE nPos = 0;
|
||||
|
||||
if( nSubLen )
|
||||
{
|
||||
HB_ISIZ nPos = hb_parclen( 2 ) - nSubLen;
|
||||
HB_ISIZ nTo = hb_parclen( 2 ) - nSubLen;
|
||||
|
||||
if( nPos >= 0 )
|
||||
if( nTo >= 0 )
|
||||
{
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
const char * pszSub = hb_parc( 1 );
|
||||
const char * pszText = hb_parc( 2 );
|
||||
HB_BOOL bFound = HB_FALSE;
|
||||
HB_ISIZ nStart;
|
||||
HB_ISIZ nStart = hb_parns( 3 );
|
||||
HB_ISIZ nFrom;
|
||||
|
||||
if( HB_ISNUM( 3 ) )
|
||||
{
|
||||
nStart = hb_parns( 3 );
|
||||
if( nStart >= 1 )
|
||||
--nStart;
|
||||
else
|
||||
nStart = 0;
|
||||
}
|
||||
if( nStart <= 1 )
|
||||
nStart = nFrom = 0;
|
||||
else if( HB_CDP_ISCHARIDX( cdp ) )
|
||||
nFrom = hb_cdpTextPos( cdp, pszText, nTo, --nStart );
|
||||
else
|
||||
nStart = 0;
|
||||
nFrom = --nStart;
|
||||
|
||||
if( HB_ISNUM( 4 ) )
|
||||
{
|
||||
HB_ISIZ nEnd = hb_parns( 4 ) - 1;
|
||||
|
||||
if( nEnd < nPos )
|
||||
nPos = nEnd;
|
||||
if( nEnd > 0 && HB_CDP_ISCHARIDX( cdp ) )
|
||||
nEnd = hb_cdpTextPos( cdp, pszText, nTo, nEnd );
|
||||
|
||||
if( nEnd < nTo )
|
||||
nTo = nEnd;
|
||||
}
|
||||
|
||||
while( nPos >= nStart && !bFound )
|
||||
if( nTo >= nFrom ) do
|
||||
{
|
||||
if( *( pszText + nPos ) == *pszSub )
|
||||
bFound = ( memcmp( pszSub, pszText + nPos, nSubLen ) == 0 );
|
||||
nPos--;
|
||||
if( pszText[ nTo ] == *pszSub &&
|
||||
memcmp( pszSub, pszText + nTo, nSubLen ) == 0 )
|
||||
{
|
||||
if( HB_CDP_ISCHARIDX( cdp ) )
|
||||
nPos = hb_cdpTextLen( cdp, pszText, nTo ) + 1;
|
||||
else
|
||||
nPos = nTo + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
hb_retns( bFound ? nPos + 2 : 0 );
|
||||
while( --nTo >= nFrom );
|
||||
}
|
||||
else
|
||||
hb_retns( 0 );
|
||||
}
|
||||
else
|
||||
/* This function never seems to raise an error */
|
||||
hb_retns( 0 );
|
||||
|
||||
hb_retns( nPos );
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Harbour Project source code:
|
||||
* RIGHT() function
|
||||
*
|
||||
* Copyright 2012 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* Copyright 1999 Antonio Linares <alinares@fivetech.com>
|
||||
* www - http://harbour-project.org
|
||||
*
|
||||
@@ -52,6 +53,7 @@
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapicdp.h"
|
||||
#include "hbapierr.h"
|
||||
|
||||
/* returns the right-most n characters in string */
|
||||
@@ -68,6 +70,18 @@ HB_FUNC( RIGHT )
|
||||
else
|
||||
{
|
||||
HB_SIZE nText = hb_itemGetCLen( pText );
|
||||
if( ( HB_SIZE ) nLen < nText )
|
||||
{
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
if( HB_CDP_ISCHARIDX( cdp ) )
|
||||
{
|
||||
HB_SIZE nChars = hb_cdpTextLen( cdp, hb_itemGetCPtr( pText ), nText );
|
||||
if( nChars > ( HB_SIZE ) nLen )
|
||||
nLen = nText - hb_cdpTextPos( cdp, hb_itemGetCPtr( pText ), nText, nChars - nLen );
|
||||
else
|
||||
nLen = nText;
|
||||
}
|
||||
}
|
||||
if( ( HB_SIZE ) nLen >= nText )
|
||||
hb_itemReturn( pText );
|
||||
else
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
*/
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapicdp.h"
|
||||
#include "hbapigt.h"
|
||||
|
||||
/* Scrolls a screen region */
|
||||
@@ -165,9 +166,17 @@ HB_FUNC( HB_SCROLL )
|
||||
iColor = -1;
|
||||
|
||||
if( HB_ISNUM( 8 ) )
|
||||
{
|
||||
iChar = hb_parni( 8 );
|
||||
if( iChar > 0 && iChar <= 255 )
|
||||
{
|
||||
PHB_CODEPAGE cdp = hb_vmCDP();
|
||||
if( !HB_CDP_ISCHARUNI( cdp ) )
|
||||
iChar = hb_cdpGetU16( cdp, ( HB_UCHAR ) iChar );
|
||||
}
|
||||
}
|
||||
else if( HB_ISCHAR( 8 ) )
|
||||
iChar = ( HB_UCHAR ) hb_parc( 8 )[0];
|
||||
iChar = hb_cdpTextGetU16( hb_vmCDP(), hb_parc( 8 ), hb_parclen( 8 ) );
|
||||
else
|
||||
iChar = -1;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user