Re: [Factor-talk] Handling keyboard input

2023-03-21 Thread Jon Harper
Hi,
in terminals, the application interacts with text streams (0 stdin,  1
stdout,  2 stderr, and optionally others with higher numbers) so all
you can get is text (including control characters). You can find
documentation here
https://docs.factorcode.org/content/article-streams.html . You should
be able to write a program to solve
https://rosettacode.org/wiki/Keyboard_input/Obtain_a_Y_or_N_response
from https://docs.factorcode.org/content/article-stream-examples.html
for example.
This is very mature.

To work with keyboard key codes (which can represent modifiers like
control or alt) in the terminal, you need a more general library.
Factor has ncurses bindings which look like it should work on windows
mac and linux: https://docs.factorcode.org/content/vocab-curses.html
if that's what you're looking for.

To work with keyboard key codes in a graphical window, you can use the
UI support in the library:
https://docs.factorcode.org/content/article-ui.html and more precisely
https://docs.factorcode.org/content/article-ui-gestures.html and
https://docs.factorcode.org/content/article-keyboard-gestures.html .
You can get a feel of what kind of event you can receive by running
the run-gesture-logger from extra/gesture-logger/gesture-logger.factor
. Here's the output from a short session I just did:

(random pressing keys on my keyboard and moving the cursor with the
focus on the the black window opened by factor to have focus on it:

T{ key-down }
T{ key-up { mods { A+ } } }
lose-focus
gain-focus
lose-focus
gain-focus
T{ key-down }
T{ key-up { mods { C+ } } }
T{ key-down }
T{ key-down { sym "A" } }
T{ key-up { sym "A" } }
T{ key-up }
T{ key-down }
T{ key-up }
T{ key-down { sym "D" } }
T{ key-up { sym "D" } }
T{ key-down { sym "A" } }
T{ key-up { sym "A" } }
T{ key-down }
T{ key-up }
T{ key-down { sym "RET" } }
T{ key-up { sym "RET" } }
T{ key-down { sym "BACKSPACE" } }
T{ key-up { sym "BACKSPACE" } }
mouse-enter
motion
motion
motion
motion
motion
mouse-leave
lose-focus
)

Hope that helps, feel free to ask more questions !

Cheers,
Jon

On Mon, Mar 20, 2023 at 4:58 PM Cleverson Casarin Uliana
 wrote:
>
> Hi,
> Have you implemented keyboard handling in a terminal like the Windows
> command prompt? In the factor library, there is e.g. extra/key-handlers,
> but it seems quite sparse.
>
> In Rosetta Code there is no related tasks implemented as well; see for
> example the Keyboard Input related tasks at:
> https://rosettacode.org/w/index.php?title=Category:Programming_Tasks=Four+is+magic#mw-pages
>
> I'd like something similar to 8th in this respect, see:
> https://8th-dev.com/manual.html#key-codes
>
> P.S.: Apologies to the moderator for sending a message from the wrong
> address earlier.
>
> Greetings,
> Cleverson
>
>
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk


___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Handling keyboard input

2023-03-20 Thread Cleverson Casarin Uliana

Hi,
Have you implemented keyboard handling in a terminal like the Windows 
command prompt? In the factor library, there is e.g. extra/key-handlers, 
but it seems quite sparse.


In Rosetta Code there is no related tasks implemented as well; see for 
example the Keyboard Input related tasks at:

https://rosettacode.org/w/index.php?title=Category:Programming_Tasks=Four+is+magic#mw-pages

I'd like something similar to 8th in this respect, see:
https://8th-dev.com/manual.html#key-codes

P.S.: Apologies to the moderator for sending a message from the wrong 
address earlier.


Greetings,
Cleverson


___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk