Page 1 of 2

Cursor shape/size in console screen

Posted: Mon Jul 01, 2013 5:23 am
by hynan
Hi all,
My first post, and question,
am using for some program console screen,
so starting with:

REQUEST HB_GT_WIN_DEFAULT
SETMODE ( 25, 80 )
SETCOLOR ( "W+/B, GR+/R, N, GR+/N, GR+/R" )
CLS

when making some SAY GET READ
cursor shape(size) does not change when pressing the INSERT button,
so cannot see if insert or overwrite mode is active.

Is there a way to fix this ?
Thanks in advance,
greetz from Holland ;)

Re: Cursor shape/size in console screen

Posted: Mon Jul 01, 2013 11:29 am
by danielmaximiliano
can you post a short example to test that way forum members prove in their respective machines and would verify the failure or bug.

Re: Cursor shape/size in console screen

Posted: Mon Jul 01, 2013 4:28 pm
by hynan
#include "hmg.ch"
REQUEST HB_GT_WIN_DEFAULT
*---------------------------------------------------------------------------*
FUNCTION MAIN ()
*---------------------------------------------------------------------------*
LOCAL TMP := " "

SETMODE ( 25, 80 )
SET CODEPAGE TO ENGLISH
SET LANGUAGE TO ENGLISH

SETCOLOR ( "W+/B, GR+/R, N, GR+/N, GR+/R" )
CLS

@ 0,0 SAY "Input" GET TMP
READ

When showing the Input cursor will stay same size,
when pressing Insert or not,
Insert is working Ok, change from overwrite to Insert an vice versa,
but cursor size not change ( like old clipper, from full block to half block )
Hope you understand my englisch ;)

Greetz, Hynan

Re: Cursor shape/size in console screen

Posted: Tue Jul 02, 2013 5:12 pm
by dhaine_adp
Hi Hynan,

The code mysIns(), below failed also. HMG ON KEY command can't be used so I tried it with SETKEY(). It seems like the Insert key press is evaluated inside the GET object. Msginfo() didn't appear at all. I also tried replacing VK_INSERT (from HMG i_keyb.ch) using HB INS value 338 but didn't work as well. That's supposed to be a workaround to the problem, LOL but failed. :cry:

Sorry Pal.

Regards,

Danny

Code: Select all

#include "hmg.ch"
REQUEST HB_GT_WIN_DEFAULT
*---------------------------------------------------------------------------*
FUNCTION MAIN ()
*---------------------------------------------------------------------------*
LOCAL TMP := " "

SETMODE ( 25, 80 )
SET CODEPAGE TO ENGLISH
SET LANGUAGE TO ENGLISH 
SETCURSOR(1)
*SET SCOREBOARD OFF
SETKEY( VK_INSERT, { || myIns() } )

SETCOLOR ( "W+/B, GR+/R, N, GR+/N, GR+/R" )
CLS

@ 0,0 SAY "Input" GET TMP
READ


function myIns()

//msginfo( HB_NTOS( SETCURSOR() ), "x" )

SET KEY TO
KEYBOARD VK_INSERT
IF SETCURSOR() = 1
   SETCURSOR( 2 )      // Half block cursor
ELSE
   SETCURSOR( 1 )      // normal cursor
ENDIF
SETKEY( VK_INSERT, { || myIns() } )


Re: Cursor shape/size in console screen

Posted: Tue Jul 02, 2013 5:29 pm
by hynan
Thanks for thinking with me and trying some ;)

Greetz, Hynan...

Cursor shape/size in console screen

Posted: Tue Jul 02, 2013 7:27 pm
by Pablo César
Really bad new, I also did not found a way to change cursor style.
I got how to differenciate insert modes by Daniel example, but I can not get to change console cursor style.

Code: Select all

REQUEST HB_GT_WIN_DEFAULT

Function Main()
LOCAL TMP := "   "

SETMODE ( 25, 80 )
SETCURSOR(1)
*SET SCOREBOARD OFF
SETKEY( 22, { || MyIns() } )

SETCOLOR ( "W+/B, GR+/R, N, GR+/N, GR+/R" )
CLS

@ 0,0 SAY "Input" GET TMP
READ

SETKEY( 22, { || Nil } )
Return Nil


Function MyIns()
IF READINSERT()
   READINSERT(.F.)
   SetCursor( 1 )
   @ 24,00 SAY PadC("NO INS",80)
ELSE
   READINSERT(.T.)
   SETCURSOR( 2 )
   @ 24,00 SAY PadC("INS",80)
ENDIF
Return Nil
Probably the problem is with GT_WIN_DEFAULT

Re: Cursor shape/size in console screen

Posted: Tue Jul 02, 2013 8:03 pm
by danielmaximiliano
Creo se añadio una nueva caracteristica a
por eso el tamaño del cursor no cambia, voy a revisar los cambios en Changed.log de harbour.

Translate Google
I think they added a new feature to
so the size of the cursor does not change, I will review the changes in Changed.log of harbor.
InsertCursor.png
InsertCursor.png (11.45 KiB) Viewed 5515 times
no InsertCursor.png
no InsertCursor.png (11.45 KiB) Viewed 5515 times

Re: Cursor shape/size in console screen

Posted: Wed Jul 03, 2013 6:03 am
by hynan
Thanks all for looking into it,

Greetz, Hynan

Re: Cursor shape/size in console screen

Posted: Wed Jul 03, 2013 6:36 pm
by dhaine_adp
Hi Pablo & Hynan,

The code below works and change the cursor size. The trick is that we need to use the command CLEAR GETS and re-invoke GET OBJECT. It works fine with one READ statement.

The new problem begins with this sample code below. SETKEY() have to be redefined on UDF getMisc() because of parameter changes, it has to call getMisc(). Also you would notice that even if the cursor is set into half block mode on the first getKey() READ, when getMisc() were executed the cursor is set to normal [SETCURSOR(1)] by GT itself?

We need to break the GET objects so that when CLEAR GETS were issued the program won't terminate.

Pablo: Thanks for the READINSERT()

Now, I wonder if it is really the right approach or is it a bug from GT? Because if you look at the code there are two EXIT points that must be taken care off in order to change the cursor size. It will be fine as long as the get*() UDF will always RETURNs NIL.

Regards,

Danny

Code: Select all

REQUEST HB_GT_WIN_DEFAULT

Function Main()

PRIVATE aItems_ := {SPACE(5),SPACE(10), 0}

SETMODE ( 25, 80 )
SETCURSOR(1)
*SET SCOREBOARD OFF


SETCOLOR ( "W+/B, GR+/R, N, GR+/N, GR+/R" )
CLS

getLabels()
getKey()
getMisc()

SETKEY( 22, { || Nil } )
Return Nil


function getLabels()
@ 0,0 SAY "Code:"
@ 1,0 SAY "Description:"
@ 2,0 SAY "Unit Cost:"
RETURN NIL


function getKey()
SETKEY( 22, { || MyIns("CODE") } )
@ 0, 7 get aItems_[ 1 ] PICTURE "@!"
READ
RETURN NIL


function getMisc()
SETKEY( 22, { || MyIns("MISC") } )
@ 24,00 SAY PadC("NO INS-" + HB_NTOS( SETCURSOR() ),80)
@ 1,13 get aItems_[ 2 ] PICTURE "@!"
@ 2,12 get aItems_[ 3 ] PICTURE "@ZB9,999.999"
READ
END SEQUENCE
RETURN NIL


Function MyIns( cMode )
CLEAR GETS
IF READINSERT()
   READINSERT(.F.)
   SetCursor( 1 )
   @ 24,00 SAY PadC("NO INS-" + HB_NTOS( SETCURSOR() ),80)
ELSE
   READINSERT(.T.)
   SETCURSOR( 2 )
   @ 24,00 SAY PadC("INS-" + HB_NTOS( SETCURSOR() ),80)
ENDIF
IF cMode == "CODE"
   getKey()
ELSE
   getMisc()
ENDIF
Return Nil

Re: Cursor shape/size in console screen

Posted: Wed Jul 03, 2013 7:38 pm
by dhaine_adp
Hi all,

I think its problem with GT. Below is another implementation of the sample code:

To test, copy & paste the code below and recompile. While you are in GET aItems_[1] press insert and fill-up the field until it moves to the second instance of the GET object aItems_[2] and #3. You'll notice that you are still in Insert Mode but the cursor is set to normal. Press Insert key twice and you'll see the cursor change to half block.

There's is no checking on the cursor size. I think that's all, I'm going to quit testing.

Regards,

Danny

Code: Select all

REQUEST HB_GT_WIN_DEFAULT

Function Main()

PRIVATE aItems_ := {SPACE(5),SPACE(10), 0}
PRIVA cMode := ""

SETMODE ( 25, 80 )
SETCURSOR(1)
*SET SCOREBOARD OFF

SETKEY( 22, { || MyIns(cMode) } )
SETCOLOR ( "W+/B, GR+/R, N, GR+/N, GR+/R" )
CLS

getLabels()
getKey()
getMisc()

SETKEY( 22, { || Nil } )
Return Nil


function getLabels()
@ 0,0 SAY "Code:"
@ 1,0 SAY "Description:"
@ 2,0 SAY "Unit Cost:"
RETURN NIL


function getKey()
cMode := "CODE"
@ 0, 7 get aItems_[ 1 ] PICTURE "@!"
READ
RETURN NIL


function getMisc()
cMode := "MISC"
@ 24,00 SAY PadC("NO INS-" + HB_NTOS( SETCURSOR() ),80)
@ 1,13 get aItems_[ 2 ] PICTURE "@!"
@ 2,12 get aItems_[ 3 ] PICTURE "@ZB9,999.999"
READ
END SEQUENCE
RETURN NIL


Function MyIns( cMode )
CLEAR GETS
IF READINSERT()
   READINSERT(.F.)
   SetCursor( 1 )
   @ 24,00 SAY PadC("NO INS-" + HB_NTOS( SETCURSOR() ),80)
ELSE
   READINSERT(.T.)
   SETCURSOR( 2 )
   @ 24,00 SAY PadC("INS-" + HB_NTOS( SETCURSOR() ),80)
ENDIF
IF cMode == "CODE"
   getKey()
ELSE
   getMisc()
ENDIF
Return Nil