CTRL+ENTER not working?

Hello everyone! I am trying to write an app that needs to diferentiate between carriage return and line feed with stty raw -echo modes. When I test it in WSL2 it works this way: * CR: ENTER * LF: ^ENTER I plan to use this so I can make a REPL that allows multiline input editing (the language does not have block delimiters nor significant whitespace), currently I use brackets
➜ ~ merlin

|_ Merlin OS -- v0.e (18M06)
|_| | (c) 2024 Ismael Venegas Castello
| Type 'bye' to exit.

Ready
@msg-str [
"Brakets 20 "allow 20 "multiline
20 "input 20 "for 20 "now 20 "using
20 "stty 20 "canonical 20 "mode. 0a00
]
ok
;msg-str pzstr
Brakets allow multiline input for now using stty canonical mode.
ok
➜ ~ merlin

|_ Merlin OS -- v0.e (18M06)
|_| | (c) 2024 Ismael Venegas Castello
| Type 'bye' to exit.

Ready
@msg-str [
"Brakets 20 "allow 20 "multiline
20 "input 20 "for 20 "now 20 "using
20 "stty 20 "canonical 20 "mode. 0a00
]
ok
;msg-str pzstr
Brakets allow multiline input for now using stty canonical mode.
ok
However brackets are used in Uxntal for grouping and don't have any semantic meaning, with this in mind I thought to use double enter instead of brackets to end an expression, but from a UX point of view, typing enter twice just to finish any expression is not good Then I learned about the non canonical input method without echo, I want to make this work so I can use CTRL+ENTER to add a newline without JIT assembling the input and executing it, so that when it is ready to be processed, a simple ENTER would do the job, this is the interaction I expect to have
➜ ~ merlin

|_ Merlin OS -- v0.e (18M06)
|_| | (c) 2024 Ismael Venegas Castello
| Type 'bye' to exit.

Ready
@msg-str ( ^ENTER LF 0a )
"CR 20 "and 20 "LF 20 "would 20 "allow 20 ( ^ENTER LF 0a )
"multiline 20 "input 20 20 "using 20 "stty ( ^ENTER LF 0a )
20 "non 20 "canonical 20 "mode 20 "without ( ^ENTER LF 0a )
20 "echo. 090a 00 ( ^ENTER LF 0a )
( ENTER CR 09 )
ok
;msg-str pzstr ( ENTER CR 09 )
CR and LF would allow multiline input using stty non canonical mode without echo.
ok
➜ ~ merlin

|_ Merlin OS -- v0.e (18M06)
|_| | (c) 2024 Ismael Venegas Castello
| Type 'bye' to exit.

Ready
@msg-str ( ^ENTER LF 0a )
"CR 20 "and 20 "LF 20 "would 20 "allow 20 ( ^ENTER LF 0a )
"multiline 20 "input 20 20 "using 20 "stty ( ^ENTER LF 0a )
20 "non 20 "canonical 20 "mode 20 "without ( ^ENTER LF 0a )
20 "echo. 090a 00 ( ^ENTER LF 0a )
( ENTER CR 09 )
ok
;msg-str pzstr ( ENTER CR 09 )
CR and LF would allow multiline input using stty non canonical mode without echo.
ok
Uxntal: https://wiki.xxiivv.com/site/uxntal.html Thanks!
6 Replies
komo
komo5mo ago
why don't you implement your REPL to hold execution if there's incomplete bracket?
Ismael-VC
Ismael-VCOP5mo ago
Hello Komo! That is the way it currently works, however I found that ENTER and ^ENTER send different bytes and it made me thought that this could be a better solution as I want this system to be 100% compatible with uxntal (I did not invent the language) It all started by wanting to make a repl for uxntal. However I ended up making a complete OS as Varvara (the virtual PC that uses Uxn (the virtual CPU) is an 8bit computer with 16bits addressing and 64Kb of memory) I use my android with Termux for most of the development I do. Sometimes I get a Windows with WSL2 lended, when I tested and codes in win/WSL2 I noticed that ^ENTER and ENTER were different, but when I tested in Termux it didn't work. I want this system to work reliably in Win/wsl, Linux, Mac and Termux because I want it to be useful for others and possibly write a booklet tutorial down the line about Varvara/Uxn using Uxntal. I don't want to change the syntax nor semantics of Uxntal. That is my only constraint.
Ismael-VC
Ismael-VCOP5mo ago
@Komo — /'koʊmoʊ/ here is a video with the issue in Termux: * https://youtu.be/vYY1PJg1pCk?si=WzXexTosnbteTwqC
Ismael-VC
Ismael-VCOP5mo ago
Here is how the ANSI codes behave in Windows 11 with WSL2: * https://youtu.be/L0_RYXkmDqY?si=n_XfFK8BWC6ArkN0
komo
komo5mo ago
i'm just assuming it's probably how Termux handle Ctrl key it won't register Ctrl+Enter as ^ENTER because of that
Ismael-VC
Ismael-VCOP5mo ago
Yeah, this doesn't work either:
{key: CTRL, popup: {macro: "CTRL ENTER", display: "^ENTER"}}, \
{key: CTRL, popup: {macro: "CTRL ENTER", display: "^ENTER"}}, \
I guess I'll just use ctrl+enter in wsl and alt+enter in termux So I only need an assembly time option, but I'll need different roms for different OSs At least in Termux Alt can be right next to Ctrl (in physical keyboards I swap ctrl <-> caps lock) Thank you for your help 🙏
Want results from more Discord servers?
Add your server