1. Override function fails
- Posted by irv Oct 19, 2020
- 727 views
Try the code below, please.
Run it with eui, then compile and run. Both work fine for me.
Next, uncomment the first part, and try again.
With eui, it works for me, displaying TAB 9 when tab key is pressed. It also works when bound or shrouded.
It won't compile, however.
--override function get_key() --integer x = eu:get_key() --if x = 9 then puts(1,"TAB ") end if --return x --end function integer key = 0 while 1 do key = get_key() if key = 27 then exit elsif key > 0 then printf(1,"%d %s\n",{key,key}) end if end while
$ euc -build-dir build -extra-lflags="-no-pie" -makefile getkey.ex Segmentation fault (core dumped)
Two files are created in the build folder: main-.h and init-.c - both containing a total of 0 bytes!
2. Re: Override function fails
- Posted by Senator Oct 19, 2020
- 704 views
On Ubuntu 20.04 compile all compiles fail.
Interpreted runs fine Shroud works fine I didn't try bind
IT makes a somewhat better version of key.ex as is, I think.
Does this accomplish anything useful?
-- -- key2.ex -- ---------- key.ex with modifications derived from Irv Mullin's overide function get_key() code -- USE shroud -- DOES NOT COMPILE ON LINUX! -- -- -- Find out what numeric key code is generated by any key on the keyboard -- -- Usage -- {{{ -- eui key2.ex [keybindfile] -- eui key2.ex -- }}} -- If you supply a valid file containing key bindings, they will be set prior to -- testing the keycodes returned. include std/os.e include std/console.e include std/io.e include std/types.e without warning sequence cmd = command_line() integer OVERIDE if length(cmd) >= 3 then set_keycodes(cmd[3]) writefln("Testing keyboard codes on\n[1] using bindings from [2]", {uname(), cmd[3]}) OVERIDE = FALSE else writefln("Testing keyboard codes on [1]", {uname()}) OVERIDE = TRUE end if puts(1, "Press any key. I'll show you the key code. Press ESC (key=27) to quit\n") function overide_get_key() integer x = get_key() if x = 9 then puts(1, "TAB ") elsif x = 10 then puts(1, "ENTER/LF ") elsif x = 27 then puts(1, "ESC ") elsif x = 32 then puts(1, "SPACE ") elsif x = 127 then puts(1, "BACK ") end if return x end function integer key = 0 while 1 do if OVERIDE then key=overide_get_key() else key = get_key() end if if key = 27 then printf(1,"%d %s\n",{key,key}) exit elsif key > 0 then printf(1,"%d %s\n",{key,key}) end if end while
Regards, Ken
3. Re: Override function fails
- Posted by irv Oct 19, 2020
- 769 views
Hi, thanks.
I was looking more for confirmation that Euphoria's override function doesn't work when compiled. Perhaps it used to work, or only worked on 32-bit platforms?
We'll need for other people to try it, and if it in fact fails, create a ticket to fix it, change the docs, or whatever seems best.