Author Topic: Windows Console Demo  (Read 5006 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Windows Console Demo
« on: August 26, 2019, 07:51:54 am »
A demo of the console overhaul which I've been working on for my personal repo.  I hope to get these changes pushed into the main QB64 repo after folks have had a while to test them and see if there's any glitches which need to be worked out.

Code: QB64: [Select]
  1.  
  2. PRINT "Welcome to a demostration of the Windows Console System for QB64,"
  3. PRINT "as overhauled by Steve!"
  4. PRINT "First, allow me to illustrate two newly implemented commands: SLEEP and CLS"
  5. Pause
  6. PRINT "And now, I'll illustrate how to change colors in the console:"
  7. FOR i = 0 TO 15
  8.     COLOR i, 15 - i
  9.     PRINT "COLORS:"; i; "ON"; 15 - i
  10. Pause
  11. PRINT "And now, we're going to have fun with the console size."
  12. PRINT "Our original screen should be set at 80x25 for default."
  13. PRINT "Press <ANY KEY> when ready to change modes."
  14. Pause
  15. WIDTH 120, 50
  16. PRINT "Here we're set at 120x50."
  17. Pause
  18. WIDTH 120, 50, 120, 50
  19. PRINT "And here we no longer have a scroll buffer; it's also 120x50."
  20. PRINT "Notice the vertical scroll bar is gone?"
  21. Pause
  22. WIDTH 120, 50, 300, 300
  23. PRINT "And here we now have both a vertical and a hortizontal scroll bar."
  24. FOR i = 1 TO 50
  25.     PRINT "See? ";
  26.     _LIMIT 10
  27. PRINT "Be certain to scroll the bar so you can 'See' all the text."
  28. Pause
  29. WIDTH , , 120, 50
  30. PRINT "And now, prepare as I do something amazing!"
  31. Pause
  32. PRINT "TaDa!!  Your font is now size 16!"
  33. Pause
  34. PRINT "And just in case yours was already size 16, it's now size 24!"
  35. Pause
  36. Pause
  37. PRINT "And now, let's take a look at... MOUSE SUPPORT!!"
  38. LOCATE 10, 10
  39. PRINT "<<CLICK HERE TO CONTINUE>>"
  40.     x = _GETCONSOLEINPUT
  41.     IF _MOUSEX >= 10 AND _MOUSEX <= 38 AND _MOUSEY = 10 AND _MOUSEBUTTON(1) THEN EXIT DO
  42. PRINT "WAAAAAAIIIIIIT A MOMENT!!"
  43. FOR i = 1 TO 40
  44.     PRINT MID$("THE CONSOLE NOW HAS MOUSE SUPPORT?!!", i, 1);
  45.     _DELAY .1
  46. PRINT "WOOOOOOOO!!!!!"
  47. Pause
  48. PRINT "And, of course, I can now work with LOCATE..."
  49. LOCATE 10, 10: PRINT "LOCATE 10,10"
  50. LOCATE 20: PRINT "LOCATE 20"
  51. LOCATE , 20: PRINT "LOCATE ,20"
  52. Pause
  53. PRINT "And, of course, I can now get back single character returns..."
  54. PRINT "Press any key, and I'll give you the scan code for it.  <ESC> quits the demo."
  55.     x = _GETCONSOLEINPUT
  56.     c = _CINP
  57.     PRINT c;
  58. LOOP UNTIL c = 1
  59.  
  60. SUB Pause
  61.     PRINT
  62.     PRINT "Press <ANY KEY> to continue."
  63.     SLEEP

Now, since a lot of folks haven't cloned my personal repo, they're not going to be able to just copy and paste the code above to see the demo.  Instead of requiring everyone to grab a whole customized version of QB64, I've compiled the source into an EXE (for windows only, which is ONLY what all this console work has been for anyway -- Linux and Mac folks will need to find someone better versed in their OS to work in better console support for them.), which is downloadable below.

There's been a ton of work which I've done for the console in windows, so I may not have highlighted all the changes into the demo.  You can see the full list of changes that I've pushed into my repo here: https://www.qb64.org/forum/index.php?topic=1589.0

If you want to test out writing things yourself, with my repo, feel free to grab your own copyfrom the link in my signature below.

NOTE: EXE below is 64-bit; it won't run on Windows 32-bit systems.
* Console Demo.exe (Filesize: 1.54 MB, Downloads: 228)
« Last Edit: August 26, 2019, 07:57:03 am by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Windows Console Demo
« Reply #1 on: August 26, 2019, 10:03:36 am »
Hi Steve. Thank for your work! Very nice demo, but font size in my case is always the same. I also tried to set EXE as administrator, it didn't help. Except for this one thing, everything works great!

 
font.PNG

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Windows Console Demo
« Reply #2 on: August 26, 2019, 10:27:09 am »
Next test outputs: If after starting i go to upper corner created window, clicking with right mouse button, selecting properties, set characters to lucida console, and set font to lucida and  size to 8, then program set font to 8x12 raster character after print, that he set font to 16.

Next - your _CINP function for reading characters react also for _MOUSEINPUT - try moving with mouse in this program area if program wait until is some key pressed. For mouse moving print 0 to screen for me.
« Last Edit: August 26, 2019, 10:32:54 am by Petr »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Windows Console Demo
« Reply #3 on: August 26, 2019, 11:06:46 am »
Next test outputs: If after starting i go to upper corner created window, clicking with right mouse button, selecting properties, set characters to lucida console, and set font to lucida and  size to 8, then program set font to 8x12 raster character after print, that he set font to 16.

Try changing the properties of your console to use “Courier New” or “Consolas” (non-raster) fonts, and then try it.  Font sizing/changing is a very provisional thing at the moment, which I’ll probably need to dig deeper into, in the future.

Quote
Next - your _CINP function for reading characters react also for _MOUSEINPUT - try moving with mouse in this program area if program wait until is some key pressed. For mouse moving print 0 to screen for me.

The console is rather strange in this as well, with all input being handled in one routine.  It’s basically a case of:


        ReadConsoleInput(hIn, &InRec, 1, &NumRead); // get input from console

        switch (InRec.EventType  {
            case KEY_EVENT:
                   //keyboard input
            case MOUSE_EVENT:
                  //mouse input
             case. OTHER.....

One routine reads it all, and we get all that information at once.  Unfortunately, QB64 isn’t set up to quite work in that way, so we break the info down into chunks for us: _MOUSEX, _MOUSEY, _MOUSEBUTTON(), _CINP....

Input in one updates the status of all — thus we need to decide WHEN to use that input (and why the new _GETCONSOLEINPUT command is a function).

DO
    x = _GETCONSOLEINPUT
    IF x = 1 THEN
         ‘Do your keyboard processing
    ELSEIF x = 2 THEN
         ‘Do your mouse processing
    ELSE
         ‘Ignore buffer events and other stuff
    END IF
LOOP

_GETCONSOLEINPUT tells us what input we’re getting, with 1 for keyboard, 2 for mouse, 0 for junk.
« Last Edit: August 26, 2019, 11:08:00 am by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Windows Console Demo
« Reply #4 on: August 26, 2019, 11:35:25 am »
Hi Steve. If I set the font to Consolas, then the program will set the raster font type again after the message that the font is set to 16. Maybe it is still somewhere in the system in the settings? I managed to do the application error, it was before reading the keyboard input, I do not know what I pressed. Suddenly it was there, after clicking it works on.

 
Application error.PNG



The message is  The application failed to start correctly. Click OK to exit program.
« Last Edit: August 26, 2019, 11:37:04 am by Petr »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Windows Console Demo
« Reply #5 on: August 26, 2019, 11:47:44 am »
Have you downloaded the repo itself, Petr?  If so, I can give you some code to test run, to try and see what’s going on a bit.  Otherwise, I’ll compile a few test EXE Files, to try and see when/what causes the font issue, and you can test them for me, if you will.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Windows Console Demo
« Reply #6 on: August 26, 2019, 12:07:04 pm »
Github is very confusing for me. I'm just trying to install your version of QB64 :) Wait

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Windows Console Demo
« Reply #7 on: August 26, 2019, 12:12:51 pm »
Github is very confusing for me. I'm just trying to install your version of QB64 :) Wait

https://github.com/SteveMcNeill/Steve64 -- If you click the green "Clone or Download" button on the right side of the screen, there's an option there to download as a ZIP file.  Many thanks for helping to test things for me, so I can try and eventually get these changes pushed into the main repo.  The more people who help test things on their systems, the more I can try and sort out what the difference is between why it might work for me and not for them.  (It also helps me see where people might be confused by some of the new processes, so I can help clarify/tweak/or document them better.)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Windows Console Demo
« Reply #8 on: August 26, 2019, 12:18:02 pm »
So I'm on the right way, already unzipping the file. It's a nice giant, 46000 files :). 5 minutes to end extracting all files.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Windows Console Demo
« Reply #9 on: August 26, 2019, 12:23:51 pm »
I am ready.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Windows Console Demo
« Reply #10 on: August 26, 2019, 12:24:23 pm »
So I'm on the right way, already unzipping the file. It's a nice giant, 46000 files :). 5 minutes to end extracting all files.

Lots of junk in it which aren't exactly related to the QB64 compiler -- I also use the repo to store demos and archives  of stuff which I find interesting/useful, or complex enough that I might want to look back over how I got things working in the past, so I can reimplement them again in the future.

In fact, you didn't just get to download the Steve64 version of QB64, which I've been working on, you've also got the old SDL version which I was upkeeping zipped up inside there, as well as both the 32 and 64-bit compilers which we package nowadays.  (Usually you'd only get one of those and have them preset for you..)

It's my personal development/test bed, and it's full of all sorts of junk.  LOL!
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: Windows Console Demo
« Reply #11 on: August 26, 2019, 12:27:03 pm »
I am ready.

Let's start out with something rather simple and see how these three things work for you:

Code: QB64: [Select]
  1.  
  2. _CONSOLEFONT "Courier New", 18
  3. PRINT "Hello World"
  4.  
  5. _CONSOLEFONT "Consolas", 16
  6. PRINT "Hello World"
  7.  
  8. _CONSOLEFONT "Lucida Console", 20
  9. PRINT "Hello World"
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: Windows Console Demo
« Reply #12 on: August 26, 2019, 12:29:39 pm »
If you're going to online for a bit, come visit in the irc chat room and we can talk/test things, without spamming up the forums here so terribly.  ;)

http://www.qb64.org/ircpage.html
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Windows Console Demo
« Reply #13 on: August 26, 2019, 12:31:11 pm »
Ok, i go there