Page 1 of 1

[PB 6.21] Regresion in console output behaviour

Posted: Tue Jun 17, 2025 3:38 am
by ColeopterusMaximus
There has been some kind of regresion/bug in how the output to the console is handled in PB6.21

The following code in PB6.20 allows you (using the arrow keys) to move the console's cursor inside the console window without filling it with garbage:

Code: Select all

EnableExplicit

#CONSOLE_CODE_CURSOR_UP    = Chr(27) + "[1A"
#CONSOLE_CODE_CURSOR_DOWN  = Chr(27) + "[1B"
#CONSOLE_CODE_CURSOR_RIGHT = Chr(27) + "[1C"
#CONSOLE_CODE_CURSOR_LEFT  = Chr(27) + "[1D"

Define str_keypress.s = ""
Define int_keycode.i  = 0

If OpenConsole()
    Repeat
        str_keypress = Inkey()
        int_keycode  = RawKey()

        If int_keycode
            Select int_keycode
                 Case 65
                    Print(#CONSOLE_CODE_CURSOR_UP)
                 Case 66
                    Print(#CONSOLE_CODE_CURSOR_DOWN)
                 Case 67
                    Print(#CONSOLE_CODE_CURSOR_RIGHT)
                 Case 68
                    Print(#CONSOLE_CODE_CURSOR_LEFT)
            EndSelect
        EndIf
        Delay(10) ; Removing the delay reduces the problem but that's not a valid solution.
    ForEver
EndIf
In PB6.21 this happens: (incorrect)

https://freeimage.host/i/FCSsXUu

This is in PB6.20 (correct)

https://freeimage.host/i/FCStx7n

Re: Regresion in console output behaviour - PB6.21

Posted: Tue Jun 17, 2025 8:41 am
by mk-soft
Same on macOS

Re: [PB 6.21] Regresion in console output behaviour

Posted: Thu Jun 19, 2025 5:00 pm
by benubi
Yes, I was also surprised. The escape sequences get somehow debugged/echoed, without the leading escape character.

Happens on x64 and arm64 Linux, PB 6.21. The code demonstrates the problem when you press cursor keys and other "special" keys, including return/newline. It also appears when using Input().

Code: Select all

Procedure KeyLoop()
  Protected a$,rk
  Repeat 
    a$=Inkey()
    rk = RawKey()
    If rk=0 And a$=#Empty$
      Delay(1)
    EndIf 
  Until a$=Chr(13) Or a$=Chr(10)
EndProcedure


OpenConsole()
PrintN("Default mode console")
PrintN("Enter Cursor Keys and hit return")
KeyLoop()
PrintN("Graphical console")
EnableGraphicalConsole(1)
PrintN("Enter Cursor Keys, and hit return")
KeyLoop()
EnableGraphicalConsole(0)
PrintN("Text mode, press cursor keys, enter return to exit")
Input()
CloseConsole()