Author Topic: The [SOLVED] mystery of the disappearing blinking cursor  (Read 6874 times)

0 Members and 1 Guest are viewing this topic.

Offline Bert22306

  • Forum Regular
  • Posts: 206
    • View Profile
The [SOLVED] mystery of the disappearing blinking cursor
« on: December 19, 2018, 04:16:44 pm »
This is probably a stupid question, but whatever. Try this trivial bit of code, in SCREEN 0:

Code: QB64: [Select]
  1. COLOR 0, 0
  2. COLOR 15, 0
  3. INPUT "Enter x"; x
  4.  

Now, running it that way, surprise, no cursor shows up. (I searched the wiki, and had high hopes on the _BLINK statement, but no luck.) You can go ahead and enter an input value no problem, but it's disconcerting to see nothing to show where you are.

Next, remark out all of the lines above the INPUT statement. Finally, all else looking exactly the same, the blinking cursor reassuringly appears.

(I use those top few statements because I generally don't have a black background or white characters, in SCREEN 0. At first, I thought maybe it's the background color I was using. But no. Even with the same background as the default black, same odd behavior.)

On the other hand, in graphics mode, you do get a cursor to show up, even if it doesn't blink.

Thanks guys, for any clues!
« Last Edit: December 20, 2018, 12:22:48 am by odin »

FellippeHeitor

  • Guest
Re: The mystery of the disappearing blinking cursor
« Reply #1 on: December 19, 2018, 04:49:43 pm »
_BLINK ON is default behavior. You mean you tried _BLINK OFF?

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: The mystery of the disappearing blinking cursor
« Reply #2 on: December 19, 2018, 06:32:44 pm »
Try this line,

LOCATE , , 1 ' display the print cursor for INKEY$

it comes from the Mini Messenger program from the wiki.
see if that gives you what you want.
Granted after becoming radioactive I only have a half-life!

Offline Bert22306

  • Forum Regular
  • Posts: 206
    • View Profile
Re: The mystery of the disappearing blinking cursor
« Reply #3 on: December 19, 2018, 08:27:52 pm »
_BLINK ON is default behavior. You mean you tried _BLINK OFF?

If _BLINK ON is the default behavior, then why does it not work with or without that _BLINK statement? I am trying to see the blinking cursor, when I have INPUT statements requriring an input to be entered, but I cannot see the cursor.

Code: QB64: [Select]
  1. COLOR 0, 0
  2. COLOR 15, 0
  3. INPUT "Enter x"; x
  4.  

Fellippe, are you saying you see the blinking cursor when you run that code? With or without the _BLINK statement?

And Cobalt, your attempt doesn't work either. The only ways to see the cursor are (a) do not use a different background and font color in SCREEN 0, or use graphics mode, or use console mode. As far as I can tell.

(I'm not sure if you are telling me that you did try that code and do see the cursor, and that somehow my own machines are creating the problem. BTW, I'm seeing "best answer" checks on these posts. Weird.)
« Last Edit: December 19, 2018, 08:30:14 pm by Bert22306 »

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: The mystery of the disappearing blinking cursor
« Reply #4 on: December 19, 2018, 08:53:36 pm »
Interestingly Bert - if you comment out the CLS, the blinking returns.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: The mystery of the disappearing blinking cursor
« Reply #5 on: December 19, 2018, 09:05:07 pm »
Code: QB64: [Select]
  1.  
  2. COLOR 4, 0
  3. COLOR 15, 0
  4. INPUT "Enter x";x
  5.  

Run the above and look closely.  The foreground color set before a CLS becomes the color of the blinker.  In this case Red and Black.

With COLOR 0, 0: CLS, the blinker becomes black and black...  thus disappearing in a black background.

Whether this mimics QB45 behavior or not, I don’t know; but it does explain, “the mystery of...”
« Last Edit: December 19, 2018, 09:07:00 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: The mystery of the disappearing blinking cursor
« Reply #6 on: December 19, 2018, 09:12:06 pm »
Code: QB64: [Select]
  1. COLOR 0, 0
  2. COLOR 15, 0
  3. INPUT "Enter x"; x
  4.  

As you can see, it works perfectly fine here, as the second CLS sets the blinker color to white and black.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: The mystery of the disappearing blinking cursor
« Reply #7 on: December 19, 2018, 11:03:13 pm »
Steve - I see it working but I'm still a little lost on why that works.  Why didn't CLS wipe out the old Color 0,0? If CLS only clears text and graphics on a screen (and NOT clear color settings), then what role does it play in color settings? Seems in this case removal or adding more CLS commands did affect the visibility of the blinking curser.

It appears, if you completely remove the CLS from Berts code, you do get the blinking WHITE curser - makes complete sense to me because the color commands then run one after the other (color 0,0 : followed by color 15,0) The last one giving the blinking white curser.  But if you seperate those two color commands with a CLS, the former foreground color is chosen by the computer. color 4,0 :ClS:Color 15,0 gets us a RED blinking curser.

Not a big deal but is one of those things that make you go Huuuum.

FellippeHeitor

  • Guest
Re: The mystery of the disappearing blinking cursor
« Reply #8 on: December 19, 2018, 11:03:50 pm »
Case closed, I suppose. _BLINK found innocent.

Offline Bert22306

  • Forum Regular
  • Posts: 206
    • View Profile
Re: The mystery of the disappearing blinking cursor
« Reply #9 on: December 19, 2018, 11:11:58 pm »
Well, sumbich, Steve and Dimster. I'll be a monkey's uncle. Whatever other platitude I can utter, in my amazement. All it took was one gratuitous extra CLS, or subtraction of one CLS, and the cursor shows up again. And luckily, additional CLSs, after that second one don't hurt.

Thanks, guys! This has been bugging me, although on the back burner, for some time. I also don't remember whether it worked right back in the MS QB days.

Here, this one shows a proper blue cursor, blinking away, on a white background:

Code: QB64: [Select]
  1. COLOR 1, 7
  2. INPUT "Enter x"; x
  3. INPUT "Again try x"; x
  4.  

Fellippe, I never much doubted the _BLINK command per se. It was the fact that default blinking ON or not, I couldn't get that blasted cursor to show up.
« Last Edit: December 19, 2018, 11:29:15 pm by Bert22306 »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: The mystery of the disappearing blinking cursor
« Reply #10 on: December 19, 2018, 11:45:44 pm »
Steve - I see it working but I'm still a little lost on why that works.  Why didn't CLS wipe out the old Color 0,0? If CLS only clears text and graphics on a screen (and NOT clear color settings), then what role does it play in color settings? Seems in this case removal or adding more CLS commands did affect the visibility of the blinking curser.

It appears, if you completely remove the CLS from Berts code, you do get the blinking WHITE curser - makes complete sense to me because the color commands then run one after the other (color 0,0 : followed by color 15,0) The last one giving the blinking white curser.  But if you seperate those two color commands with a CLS, the former foreground color is chosen by the computer. color 4,0 :ClS:Color 15,0 gets us a RED blinking curser.

Not a big deal but is one of those things that make you go Huuuum.

Why it works is like this:

That prompt (blinker as we’re calling it) has to be *some* color.  Generally, you want it to match your screen color as much as possible.  By default, your screen starts out with white as the foreground, and the blinker is White (on background color). 

Now, since Galleon figured you probably don’t intend to alter that blinker color every time you change the text color, he fixed it so it changes only when CLS is called.

In Bert’s case, he’s setting the foreground color Black, then calling CLS and it’s setting the blinker black:

COLOR 0 ‘foreground color black
CLS  ‘clear screen, set blinker to black

Now, when INPUT is called, the background is black, and the blinker is a black foreground, on a black background...  It’s actually faithfully doing its job — you just can’t see it as it’s always the same color as the background.

So why’s my second CLS work?

COLOR 15 ‘foreground color bright white
CLS ‘clear screen and set blinker to bright white

Now when printing on the black background, it’s a bright white/black toggle, which is nice and visible for us.

****************

Maybe we should see about adding in a _BLINKERCOLOR command, so people can manually change that color, without needing to use CLS to do so.   ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

FellippeHeitor

  • Guest
Re: The mystery of the disappearing blinking cursor
« Reply #11 on: December 20, 2018, 12:09:30 am »
Maybe we should see about adding in a _BLINKERCOLOR command, so people can manually change that color, without needing to use CLS to do so.   ;)

I beg to differ.

What you guys seem to fail to observe is that what CLS does is clear the whole screen using the last COLOR set, both fg and bg. When that happens with COLOR 0, 0 all the screen is immediately COLOR 0, 0 after a CLS and that's why even after setting COLOR 15 the cursor will still be moving over COLOR 0, 0 CHR$(32) all over the screen.

_BLINKERCOLOR would be wrong because what's expected is to have the cursor blink in the same color of the screen character position it's on.

Please run this:
Code: QB64: [Select]
  1. FOR i = 1 TO 15
  2.     COLOR i
  3.     PRINT " ";
  4. LOCATE 1, 1
  5. INPUT "", x$

While it's running, type slooooowly and observe how the blinker color will change with every keystroke, since I previously placed color spaces in positions 1 to 15.

FellippeHeitor

  • Guest
Re: The mystery of the disappearing blinking cursor
« Reply #12 on: December 20, 2018, 12:19:01 am »
Now to make things even clearer regarding _BLINK:

  • It's related to blinking colors from 17 to thirty-something in SCREEN 0, not to the cursor. When set to OFF, instead of having those colors blink you activate high-intensity mode, mimicking an old DOS interrupt call that did the same for VGA cards.
  • If your intention is to enable/disable the blinking *cursor*, use LOCATE ,,0 (disable) or LOCATE ,,1 (enable). This is effective to show the cursor after a PRINT statement. For INPUT it doesn't matter if you disabled it or not, as it'll show anyway.
  • That's that.
« Last Edit: December 20, 2018, 12:26:10 am by FellippeHeitor »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: The mystery of the disappearing blinking cursor
« Reply #13 on: December 20, 2018, 12:39:30 am »
Maybe we should see about adding in a _BLINKERCOLOR command, so people can manually change that color, without needing to use CLS to do so.   ;)

I beg to differ.

What you guys seem to fail to observe is that what CLS does is clear the whole screen using the last COLOR set, both fg and bg. When that happens with COLOR 0, 0 all the screen is immediately COLOR 0, 0 after a CLS and that's why even after setting COLOR 15 the cursor will still be moving over COLOR 0, 0 CHR$(32) all over the screen.

_BLINKERCOLOR would be wrong because what's expected is to have the cursor blink in the same color of the screen character position it's on.

Please run this:
Code: QB64: [Select]
  1. FOR i = 1 TO 15
  2.     COLOR i
  3.     PRINT " ";
  4. LOCATE 1, 1
  5. INPUT "", x$

While it's running, type slooooowly and observe how the blinker color will change with every keystroke, since I previously placed color spaces in positions 1 to 15.

Gotcha.

CLS isn’t so much “clearing the screen”, by wiping it all blank; it’s just overwriting everything with colored spaces.

COLOR 4 ‘red
CLS

The above basically wipes the screen clear by filling it with Red spaces... When INPUT is called, the blinker toggles from foreground to background — in this case, Red/Black.

(Think COLOR 4: PRINT “HELLO WORLD”.  What COLOR is the space between the O and W?)

Bert’s code was setting black on black for the screen, so the blinking cursor blinked black on black.

The “blinker” isn’t an independent setting to change; as I first concluded; it’s just a simple toggle switch of the positions foreground/background colors.  If they’re the same, the blinker is going to be as well, which makes it invisible.
« Last Edit: December 20, 2018, 12:41:57 am by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: The [SOLVED] mystery of the disappearing blinking cursor
« Reply #14 on: December 20, 2018, 09:16:09 am »
So in essence, Bert's coding (ie by separating the two Color commands with a Clear Statement) effectively controls both the color of the cursor and the color of the text.

color 4,0
cls
color 2,0

has the cursor as a red bar, and the text entry as green. Cool. I didn't realize this combination was worked as it does. Bert your a genius. And thanks to SMcNeill and FellippeHeitor, I may change my handle from Dimster to LittleBrighterster.