GTWVT & clipboard problem

330 views
Skip to first unread message

Zeljko

unread,
Dec 23, 2012, 1:49:31 PM12/23/12
to harbou...@googlegroups.com
Hi everybody. I have the need to paste data from MS Word documents to my Harbour program via memoedit. I'm using  hb_gtinfo( HB_GTI_CLIPBOARDPASTE ) to paste previously copied data from MS Word documents and this works great except for special diacritic characters which are displayed as question marks. My Windows code page is set to CP1250 and the OEM CP is 852 (Croatian). I am running the program under GTWVT with the font set to Lucide Console. Why are all special Croatian characters displayed as question marks? Do I have to do some translation I am not aware of? I already tried HB_SETDISPCP("HRWIN"), HB_SETDISPCP("HR") and HB_SETDISPCP("HR852") but this did not help. Any help would be highly appreciated. Thanks in advance.

elch

unread,
Jan 1, 2013, 11:16:08 AM1/1/13
to harbou...@googlegroups.com

THANKs for your nice hint !


Overlooked this possibility, just integrated it also into my getsys.

Cause of overlapping same keycode K_INS and K_CTRL_V, i changed the original task for K_INS (change input mode) to key K_CTRL_I.


Works here fine for me, even with special language chars.

I use the developer (nightly) version of Harbour.

I assume ! that you can type direct per keyboard your special chars.


I'm NOT sure, especially with your CP's and terminal settings, but perhaps 'play' a little bit before paste with HB_GTI_CLIPBOARDDATA and different 2 + 3 parameter of HB_Translate().


hb_gtinfo( HB_GTI_CLIPBOARDDATA, HB_Translate(hb_gtinfo( HB_GTI_CLIPBOARDDATA), "HR1250", "HR852"))


best regards

rolf

Zeljko

unread,
Jan 1, 2013, 12:57:58 PM1/1/13
to harbou...@googlegroups.com
Solved my problem. Turns out that HB_SETDISPCP was completely irrelevant to clipboard pasting, but when I changed HB_CDPSELECT("HR646") to HB_CDPSELECT("HRWIN") everything worked as expected.

Klas Engwall

unread,
Jan 1, 2013, 5:20:46 PM1/1/13
to harbou...@googlegroups.com
Hi Rolf,

> Cause of overlapping same keycode K_INS and K_CTRL_V, i changed the
> original task for K_INS (change input mode) to key K_CTRL_I.

Another way to handle "overlapping" key codes like K_INS vs K_CTRL_V and
K_PGDN vs K_CTRL_C is to check the status of the control key(s) with
hb_gtinfo(HB_GTI_KBDSHIFTS) and then compare the result against
HB_GTI_KBD_CTRL with a hb_bitor() check. For example:

nBits := hb_gtinfo( HB_GTI_KBDSHIFTS )
if nBits == hb_bitor( nBits, HB_GTI_KBD_CTRL )
// If equal, a control key was pressed
endif

Regards,
Klas

elch

unread,
Jan 2, 2013, 6:35:45 AM1/2/13
to harbou...@googlegroups.com

VERY very thanks !, Klas


for your hint - your example works if the inkey is processed immedeate as it

occurs - but ... what's about simulating inkey with HB_KEYPUT() or even keyboard macros i'm working with sooo long ?? - another fred ...


###

When using hb_gtinfo( HB_GTI_CLIPBOARDPASTE ), the content is like 'typed' in.

If the clipboard contain MORE than one line of text, additional work is to be done: we have to remove a CHR(10) from DOS/WIN EndOfLine char-pair OR convert a single Linux CHR(10) to a CHR(13). This can be done by modifying the clipboard with hb_gtinfo( HB_GTI_CLIPBOARDDATA)).


i.e. using a cTmp help var - and these uppermost famous string functions from clipper tools (link with -hbct):


* is something there to fetch ?

IF ! EMPTY(cTmp := hb_gtinfo( HB_GTI_CLIPBOARDDATA))

* eol chars in it ?

IF CHR(10)$cTmp .OR. CHR(13)$cTmp

* single chr(10) -> chr(13); CHR(13)+CHR(10) -> CHR(13)

IF ! CHR(13)$cTmp

* convert all chr(10)

cTmp := CHARREPL(CHR(10), cTmp, CHR(13), .F.)

ELSE

* replace ALL chr(10)+chr(13) pairs to chr(13)

cTmp := ATREPL(CHR(13) + CHR(10), cTmp, CHR(13), NUMAT(CHR(13)+CHR(10),cTmp), .F.) //alle ersetzen

ENDIF

* modify clipboard buffer

hb_gtinfo( HB_GTI_CLIPBOARDDATA, cTmp)

ENDIF

ENDIF

* type it ...

hb_gtinfo( HB_GTI_CLIPBOARDPASTE )



-----

For a single get-field i do NOT want to have multiline input. Also we can push it direct into the get:buffer. Just at the position we are standing, depending on input-overwrite mode. To be done in getsys.prg:


* remark: get buffer are ALWAYS of type "C"haracter

* something there with the correct data type

IF ! EMPTY(hb_gtinfo( HB_GTI_CLIPBOARDDATA)) .AND. VALTYPE(hb_gtinfo( HB_GTI_CLIPBOARDDATA)) == VALTYPE(get:buffer)

cTmp := hb_gtinfo( HB_GTI_CLIPBOARDDATA)

* get all before -any- EOL-char

IF CHR(13)$cTmp

cTmp := LEFT( cTmp, AT(CHR(13), cTmp) - 1)

ENDIF

IF CHR(10)$cTmp

cTmp := LEFT( cTmp, AT(CHR(10), cTmp) - 1)

ENDIF

* anything left ? - insert it

IF ! EMPTY(cTmp)

IF get:pos > 1

get:buffer := LEFT(;

SUBSTR(get:buffer, 1, get:pos -1) + ;

cTmp + ;

SUBSTR(get:buffer, IF( Set( _SET_INSERT), get:pos, get:pos + LEN(cTmp))),;

LEN(get:buffer))

ELSE

get:buffer := LEFT( cTmp + SUBSTR( get:buffer, IF( Set( _SET_INSERT), 1, LEN(cTmp) +1)), LEN(get:buffer))

ENDIF

* two needed steps to make our buffer assigned and visible

get:assign()

get:display()

ENDIF

ENDIF



best regards

Rolf




Am Sonntag, 23. Dezember 2012 19:49:31 UTC+1 schrieb Zeljko:

elch

unread,
Jan 2, 2013, 6:39:57 AM1/2/13
to harbou...@googlegroups.com
excuse - indentation seem to be removed at drag/drop ;-(

wanst...@gmail.com

unread,
Mar 8, 2026, 10:46:29 AM (7 days ago) Mar 8
to Harbour Users
Hi, the message is pretty "old" but I found it and I implemented the mentioned clipboard feature here but with some changes...

Rolf wrote:

When using hb_gtinfo( HB_GTI_CLIPBOARDPASTE ), the content is like 'typed' in.

If the clipboard contain MORE than one line of text, additional work is to be done: we have to remove a CHR(10) from DOS/WIN EndOfLine char-pair OR convert a single Linux CHR(10) to a CHR(13). This can be done by modifying the clipboard with hb_gtinfo( HB_GTI_CLIPBOARDDATA)).

So I have an idea for the question of the Linux [LF] or Windows [CRLF] or old I/OS [CR].
What about replacing it by ";" and open the possibility of multi-GET paste?
What I did here was to have 2 possible keys to paste (Ctrl-V and Ctrl-P), with Ctrl-V for multi-GET and Ctrl-P for only one GET.

Just to give someone one more option :)


Reply all
Reply to author
Forward
0 new messages