Text UI

Discussions about the BBC BASIC language, with particular reference to BB4W and BBCSDL
commiesoft
Posts: 3
Joined: Sun 13 Oct 2019, 14:35

Text UI

Post by commiesoft »

Hi, I'm trying to go 40 years back in time and create a text UI for my programs, and got this so far,
with a bit of help ;-) The only thing is I need control of the keyboard input.. If someone puts their
finger on the escape button, it stops? I need the UI to remain as is, until the user presses a button
the app expects.

REM Get screen width and height:
SYS "GetSystemMetrics", 0 TO screenW: SYS "GetSystemMetrics", 1 TO screenH

REM user defined mode:
nCols = 48: nRows = 24: nColors = 16: charSet = 0 REM ANSI
charW = screenW DIV nCols : charH = screenH DIV nRows
VDU 23, 22, screenW; screenH; charW, charH, nColors, charSet

REM Set full screen window (code from BB4W Help manual):
GWL_STYLE = -16
HWND_TOPMOST = -1
WS_VISIBLE = &10000000
WS_CLIPCHILDREN = &2000000
WS_CLIPSIBLINGS = &4000000
SYS "SetWindowLong", @hwnd%, GWL_STYLE, WS_VISIBLE + WS_CLIPCHILDREN + WS_CLIPSIBLINGS
SYS "SetWindowPos", @hwnd%, HWND_TOPMOST, 0, 0, screenW, screenH, 0
VDU 26

REM text color:
fColor = 2 : bColor = 0: REM green on black
COLOUR fColor: COLOUR bColor + 128
CLS

FOR row = 0 TO nRows - 1
PRINT TAB(0, row); STR$(row); : WAIT 4
NEXT row
WAIT 100

FOR col = 0 TO nCols - 1
PRINT TAB(col, 0); RIGHT$(STR$(col), 1); : WAIT 2
NEXT col
WAIT 100

PRINT TAB(nCols DIV 2 - 20, nRows DIV 2) "Alt+F4 to quit ;-)"
REPEAT WAIT 10 : UNTIL FALSE
DDRM

Re: Text UI

Post by DDRM »

Hi,

NB Edited, so if you saw it in the first few minutes, it's changed! :-)

In the manual it says that if you use

*ESC OFF

you can switch off the normal function of the escape key: it will simply return an ASCII code (27) like any other key.

Does that solve your problem? Doing *ESC ON will switch it back on, so you could just disable it while the menu is up, so that it can be used if something else goes wrong with the program.

Hope that helps,

D
commiesoft
Posts: 3
Joined: Sun 13 Oct 2019, 14:35

Re: Text UI

Post by commiesoft »

DDRM: 'Does that solve your problem? ME: Yes, it did, great :) Thanks! Cool, BBC Basic is my new tool ;-)
commiesoft
Posts: 3
Joined: Sun 13 Oct 2019, 14:35

Re: Text UI

Post by commiesoft »

Thanks for pointing me in the right direction :) This seems to be immune to keypresses
I don't need... but who knows:

Code: Select all

      *ESC OFF

      REM Get screen width and height:
      SYS "GetSystemMetrics", 0 TO screenW: SYS "GetSystemMetrics", 1 TO screenH

      REM user defined mode:
      nCols = 48: nRows = 24: nColors = 16: charSet = 0 REM ANSI
      charW = screenW DIV nCols : charH = screenH DIV nRows
      VDU 23, 22, screenW; screenH; charW, charH, nColors, charSet

      REM Set full screen window (code from BB4W Help manual):
      GWL_STYLE = -16
      HWND_TOPMOST = -1
      WS_VISIBLE = &10000000
      WS_CLIPCHILDREN = &2000000
      WS_CLIPSIBLINGS = &4000000
      SYS "SetWindowLong", @hwnd%, GWL_STYLE, WS_VISIBLE + WS_CLIPCHILDREN + WS_CLIPSIBLINGS
      SYS "SetWindowPos", @hwnd%, HWND_TOPMOST, 0, 0, screenW, screenH, 0
      VDU 26

      REM text color:
      fColor = 2 : bColor = 0: REM green on black
      COLOUR fColor: COLOUR bColor + 128
      CLS

      FOR row = 0 TO nRows - 1
        PRINT TAB(0, row); STR$(row); : WAIT 2
      NEXT row
      WAIT 10

      FOR col = 0 TO nCols - 1
        PRINT TAB(col, 0); RIGHT$(STR$(col), 1); : WAIT 2
      NEXT col
      WAIT 10

      PRINT TAB(nCols DIV 2 - 20, nRows DIV 2) "Q to quit ;-)"

      REM *ESC ON

      REPEAT UNTIL INKEY(-17) = -1

      CLS: QUIT