|
Post by rikky on Mar 27, 2020 1:16:47 GMT 1
Hello
I have this editor:
WHILE TRUE stndin = WAIT(STDIN_FILENO, 50) IF stndin = 0 THEN CONTINUE stndin$ = CHR$(stndin) PRINT stndin$; WEND It works perfectly, but in a more sophisticated editor you want also the backspace and arrows to work. Luckily we have some tools in BaCon to achieve such things. But for that you first need to know where your cursor is.
So we step up to the next program:
WHILE TRUE stndin = WAIT(STDIN_FILENO, 50) IF stndin = 0 THEN CONTINUE stndin$ = CHR$(stndin) PRINT stndin$; xpos = GETX WEND And that's enough to confuse our editor. That is if you press a key, and keep it pressed, then eventually all kind of weird escape keys appear, that are not wanted.
So if I press a 'd', and keep it pressed, I receive:
dddddd^[[6;8Rdddddddddddddddddddddddddddddddddddddddddddddddd^[[6;66Rd^[[6;76Rdddddddddd At least in my case on a Paspi 3 in lxterminal.
Maybe the machine is too slow to catch conti-presses, or lxterminal sucks?
Thanks, Rik ;°|
|
|
|
Post by alexfish on Mar 27, 2020 1:52:09 GMT 1
Hi Rick
Not sure, but looks like the mouse is enabled
can switch on and off with
'#define MOUSE_ON \ printf("%c[?1001s",27), fflush(stdout), /* save old hilit tracking */ \ printf("%c[?1000h",27), fflush(stdout) /* enable mouse tracking */
'#define MOUSE_OFF \ printf("%c[?1000l",27), fflush(stdout), /* disable mouse tracking */ \ printf("%c[?1001r",27), fflush(stdout) /* restore old hilittracking */
Added
if waiting for a reply with timeout
is the
IF stndin = 0 THEN CONTINUE necessary
BR Alex
|
|
|
Post by rikky on Mar 27, 2020 8:17:27 GMT 1
Indeed, the IF stndin = 0 THEN CONTINUE is not necessary. And switching off the mouse did not work unfortunately.. From your reaction I figured however that you do not seem to have this problem. Hmmm ....
|
|
|
Post by Pjot on Mar 27, 2020 9:57:47 GMT 1
Hi rikky, Well, we've had a discussion about STDIN handling and kernels before Particularly this post may be enlightening... HTH Peter
|
|
|
Post by rikky on Mar 27, 2020 18:59:50 GMT 1
I see. Yes, very enlightening, But also a bit depressing. For whatever I invent as a solution might not work on other platforms. But I got the picture. The answer is : "It's very complicated". I'll keep you informed, about what I find for solution. Rik.
|
|
|
Post by alexfish on Mar 27, 2020 19:44:13 GMT 1
Hi Rick
just had a another look at your code this bit ->arrows and esc
yes they will produce the above bur why the left <- key
have got a working example of how to filter the keys etc
will post in another thread : if on raspberry also have example of vte , can configure using args
as in posting it will be sometime time next week
can confirm there do not appear to be any kernel issues ' as of yet ' of this type of use
yet I did notice an anomaly on stdin 0:
BR alex
|
|
|
Post by rikky on Mar 27, 2020 20:05:55 GMT 1
Great, thanks. :°)
|
|
|
Post by bigbass on Mar 28, 2020 8:09:17 GMT 1
Hello Riky your snippet is working for me I am using the latest version for the RPI3 at some time you will fill the buffer holding down a key but not that quickly cat /etc/os-release PRETTY_NAME="Raspbian GNU/Linux 10 (buster)" NAME="Raspbian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster ID=raspbian ID_LIKE=debian cat /etc/debian_version 10.3 may have to change default terminal the default is 0 I use 3 lxterminal sudo update-alternatives --config x-terminal-emulator Selection Path Priority Status ------------------------------------------------------------ 0 /usr/bin/lxterm 30 auto mode 1 /usr/bin/koi8rxterm 20 manual mode 2 /usr/bin/lxterm 30 manual mode * 3 /usr/bin/lxterminal 20 manual mode 4 /usr/bin/uxterm 20 manual mode 5 /usr/bin/xterm 20 manual mode I will attach a debugging tool to help test key presses ( written in bacon but is gtk gdk) debugkey.tar.gz (1.52 KB) TIP: I noticed that the GETX is a counter that seems to count every char you entered then calculate where you are relative to the input that was given this creates another loop inside your loop WHILE WEND and should be used after the dust settles for example after you press enter then a command GETX Joe
|
|
|
Post by rikky on Mar 28, 2020 20:09:19 GMT 1
I use Stretch, because I like it better. But I just tested Buster, and got the same problem. I think thats because lxterminal get the input from something out of the kernel like Pjot explained. And I use Berryboot, to boot the different systems, and I believe, if I am not mistaken, that Berryboot delevers the kernel, and then the different systems come on top of that. I have not found a boot method that offer the choise of different systems, and a shared folder on top, so I stick with that too, Sorry. :°( So I stick with berryboot, Stretch, and my different shared folders. xterm works, I just tested, but I stck with lxterminal, for tis VTETerminal you can make with Hug, is lxterminal, and I have already some programs .. blablabla.. And your keyprogram works, but I am looking for something not graphical. ;°| Anyway Alixfish has cracked it, (I think, still testing) in the other thread. For which I'm greatfull Thanks for helping me further on the way. Rik.
|
|
|
Post by rikky on Mar 29, 2020 15:25:25 GMT 1
I've been testing now more thoroughly, and I can now definitely confirm that the problem has been solved here. The solution is to NOT put a GETX or GETY in the getkey loop. Although for most people this would not lead to problems. Well, that doesn't mean that my editor is ready, but I can now work on it. Next problem will probably be, what to do if someone resizes the window in the middle of typing a sentence ;°) Anyway, How do you mark something as solved? Rik.
|
|