Terminal ESC sequence '[' versus 'O'

General FreeBASIC programming questions.
Post Reply
GWBASICcoder
Posts: 21
Joined: Jul 29, 2022 12:43

Terminal ESC sequence '[' versus 'O'

Post by GWBASICcoder »

Hi,

I wrote a FreeBASIC wrapper over https://github.com/antirez/linenoise - a minimalist readline replacement. You can see it here https://github.com/hacksterous/lined. (Thanks to the help I received here)
It works nicely, including the hints and completions.

However, I noticed that the terminal escape sequences "introducer" character is different when run from the native C (where the character is '[')
and in FreeBASIC, where this character is 'O' (that is Oh, not zero). This needed a change in the way the first character is handled in linenoise.c

I printed the input character in the C file linenoise.c, and it shows this when the C example is run:

Code: Select all

~/Src/BASIC/noisyline: ./example
hello> got an ESC char - seq[0] = [
hello> linenoisegot an ESC char - seq[0] = [
hello> linenoisgot an ESC char - seq[0] = [
hello> linenoigot an ESC char - seq[0] = [
hello> linenogot an ESC char - seq[0] = [
hello> linengot an ESC char - seq[0] = [
hello> linegot an ESC char - seq[0] = [
hello> linenoise
... and this when the FB code is run.

Code: Select all

~/Src/BASIC/noisyline: ./lined
basic#1> linenoisegot an ESC char - seq[0] = O
basic#1> linenoisgot an ESC char - seq[0] = O
basic#1> linenoigot an ESC char - seq[0] = O
basic#1> linenogot an ESC char - seq[0] = O
basic#1> linengot an ESC char - seq[0] = O
basic#1> linegot an ESC char - seq[0] = O
Why is this difference? Any information is much appreciated!

EDIT: I am on GNU/Linux. I have tested on KDE Konsole and xterm.

GWBc
Post Reply