🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 6 September 2022.
00:00 jjido left 00:06 reportable6 left 00:07 reportable6 joined 00:42 avar left 00:47 avar joined 00:53 epony joined 01:00 Kaipei joined 01:04 Kaiepi left 01:30 avar left, avar joined 02:00 razetime joined 02:20 HvszrStykp left, Sauvin left, Geth left, ProperNoun left, hexology left, peder left, zostay left, jcallen left, leedo left, GreaseMonkey left, bartolin left, thowe left, esh left, jdv left, nebuchadnezzar left, TieUpYourCamel left, bdju left, archenoth left, kjp left, nebuchadnezzar joined, jdv joined, bartolin joined, TieUpYourCamel joined, thowe joined, peder joined, greaser|q joined, leedo joined, zostay joined, kjp joined 02:21 greaser|q left, greaser|q joined, jcallen joined 02:22 Sauvin joined, jroc joined, hexology joined, greaser|q is now known as GreaseMonkey, archenoth joined, ProperNoun joined, HvszrStykp joined 02:23 Geth joined, jroc left 02:25 esh joined, bdju joined 02:26 HvszrSty1p joined 02:28 HvszrStykp left 02:29 HvszrSty1p left 02:57 epony left 02:58 epony joined 03:58 greppable6 left, coverable6 left, sourceable6 left, unicodable6 left, shareable6 left, linkable6 left, bisectable6 left, notable6 left, statisfiable6 left, committable6 left, bloatable6 left, releasable6 left 03:59 unicodable6 joined, bisectable6 joined, shareable6 joined, statisfiable6 joined, committable6 joined, notable6 joined 04:00 bloatable6 joined, linkable6 joined, greppable6 joined, coverable6 joined, sourceable6 joined 04:01 releasable6 joined 04:12 archenoth left 04:43 vrurg left 04:45 vrurg joined 04:56 labster joined 05:01 epony left 05:03 epony joined 05:07 labster left 06:07 committable6 left, statisfiable6 left, squashable6 left, bisectable6 left, greppable6 left, tellable6 left, benchable6 left, nativecallable6 left, linkable6 left, evalable6 left, bloatable6 left, coverable6 left, sourceable6 left, unicodable6 left, quotable6 left, releasable6 left, shareable6 left, notable6 left, reportable6 left, greppable6 joined, linkable6 joined, squashable6 joined, sourceable6 joined, quotable6 joined, evalable6 joined 06:08 bisectable6 joined, statisfiable6 joined, unicodable6 joined, nativecallable6 joined, reportable6 joined, releasable6 joined 06:09 tellable6 joined, coverable6 joined, shareable6 joined, bloatable6 joined, committable6 joined 06:10 notable6 joined, benchable6 joined 06:18 Xliff joined
Xliff \o 06:19
tellable6 2022-10-26T07:34:58Z #raku-dev <lizmat> Xliff: about 3.5x as fast
2022-10-26T07:38:28Z #raku-dev <lizmat> Xliff Actually, more than 7.4x as fast, if you want strings, as .comb.rotor() will give you lists that would need to get joined: .comb.rotor(3 => -2)>>.join
Xliff How can I get function key input in raku?
.tell lizmat Wow! Nice work. Thanks for the info.
tellable6 Xliff, I'll pass your message to lizmat
Xliff How can I get function key input in raku? 06:43
I've tried Term::ReadKey and it's not working as I expected.
06:46 Sgeo left 07:03 labster joined 07:05 epony left 07:07 epony joined 07:46 archenoth joined 07:50 epony left 08:03 epony joined
Xliff How can I get function key input in raku? 08:05
Inline::Perl5 still doesn't work.
So the one working solution I've found isn't applicable, ATM
08:09 dakkar joined
Anton Antonov <@742445366489645080> On what platform / OS is not working as expected? 08:22
Xliff Linux / Terminal, so I don't have access to GUI toolkits 08:30
08:35 lichtkind joined 09:09 razetime left 09:10 epony left 09:11 epony joined, sena_kun joined
lizmat weekly: dev.to/lizmat/dont-fear-the-grepper-4-nki 09:50
notable6 lizmat, Noted! (weekly)
tellable6 2022-10-27T06:19:42Z #raku <Xliff> lizmat Wow! Nice work. Thanks for the info.
09:54 japhb left 09:58 japhb joined
Xliff lizmat: I'm trying to detect function keys like F1, F2, etc... do you know of a good mechanism in Raku for that? 10:02
lizmat nope :-(
10:02 labster left
Xliff :( 10:02
Term::ReadKey gives you the sequences, but that's hard to switch into F1/F2 and such because you have to build the sequences manually. 10:03
Inline::Perl5 is still br0kered. 10:04
m: use CPAN:from<Perl5>
camelia ===SORRY!=== Error while compiling <tmp>
Please install Inline::Perl5 for Perl 5 support.
at <tmp>:1
Xliff Ah.
lizmat Xliff: looks like you will need to make a supply converter 10:05
Xliff How would that work? 10:10
lizmat github.com/rakudo/rakudo/blob/mast...s.pm6#L498 gives a nice example of that 10:12
Xliff Not really. That's a lot of code with no examples. :) 10:13
lizmat method produce 10:14
taking a Supply, and producing another Supply
Xliff And how does that apply to keystroke sequences? 10:15
lizmat Term::Readkey produces a Supply, right ?
Xliff Yes.... it can.
lizmat key-pressed 10:16
the problem is that function keys are emitted as more than one value by that supply, right ?
Xliff Yes. 10:18
I've only ever used supplies as event handlers.
I've never used them for things like lists, so this is new to me.
So can you get a Supply to take successive values and then check if that list is (1, 2, 3, 4)? 10:19
lizmat the Supply produce method is an example of a taking a supply, and collecting info from a given supply, and emitting values on a new supply
yup, just collect them, and pass them on when it matches your idea of a sensible sequence 10:20
Xliff Is there an example of this?
lizmat the link I just posted ?
Xliff That's the source for produce. Not an example. 10:21
And the docs have this: docs.raku.org/type/Supply#method_produce 10:22
Which is just a sum, not a sequence tracker.
lizmat gist.github.com/lizmat/737f60089a9...bbfed4f17d 10:26
I mean, it's very simplified
10:30 kjp left
Xliff Thinking. I just tried something like this, myself. 10:30
10:30 kjp joined 10:32 razetime joined
Xliff This still doesn't work -- 10:38
raku -e 'use Mojo::DOM:from<Perl5>; #===SORRY!=== Error while compiling -e. Too many positionals passed; expected 1 argument but got 2 10:39
10:40 Nemokosch joined 10:42 sena_kun left 10:43 sena_kun joined
Xliff It would be nice if Supply.tail(3) would automatically give me the last 3 values emitted. 10:44
10:54 jjido joined
lizmat it doesn't? 11:02
it should? 11:03
ah, you mean "the last 3 values emitted before the current value" 11:04
Xliff: but that wouldn't help you, would it? because it would pass on invalid values also? 11:05
11:11 jjido left 11:14 epony left 11:15 epony joined 11:19 sena_kun left
lizmat afk& 11:25
11:33 razetime left 11:34 jjido joined 11:36 jjido left
SmokeMachine m: Supply.from-list(4, 3, 2, 1, 2, 3, 4).rotor(3 => -2).grep({ $_ ~~ [1, 2, 3] }).act: &say # Xliff would something like this help? 11:38
camelia [1 2 3]
12:07 reportable6 left, reportable6 joined 12:27 xinming left
Xliff SmokeMachine: Thanks for trying, but no. 12:35
SmokeMachine then I think I gon't get what the problem is... :(
Xliff The valies come one at a time, therefore .rotor and .tail don't wokr.
So it's more like... 12:36
SmokeMachine but it works with that coming aone at a time...
12:38 derpydoo joined
Xliff m: my $s = Supplier::Preserving.new; $s.emit($_) for 4, 3, 2, 1, 2, 3, 4; my $sup = $s.Supply; $s.rotor(3 => -2).grep({ $_ ~~ [1, 2, 3] ]).act: .say 12:39
camelia ===SORRY!=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> s.rotor(3 => -2).grep({ $_ ~~ [1, 2, 3] ⏏]).act: .say
expecting any of:
statement end
statement modifier
statement modif…
Xliff m: my $s = Supplier::Preserving.new; $s.emit($_) for 4, 3, 2, 1, 2, 3, 4; my $sup = $s.Supply; $s.rotor(3 => -2).grep({ $_ ~~ [1, 2, 3] }).act: .say
camelia (Any)
No such method 'act' for invocant of type 'Seq'
in block <unit> at <tmp> line 1
SmokeMachine m: supply { whenever Supply.interval: 0.001 { emit ^5 .roll } }.rotor(3 => -2).grep({ $_ ~~ [1, 2, 3] }).act: &say; sleep 1
camelia [1 2 3]
[1 2 3]
[1 2 3]
[1 2 3]
[1 2 3]
[1 2 3]
Xliff m: supply { whenever Supply.interval: 0.001 { emit (^5).roll } }.rotor(3 => -2).grep({ $_ ~~ [1, 2, 3] }).act: &say; sleep 1 12:40
camelia [1 2 3]
[1 2 3]
Xliff That might work.
SmokeMachine the rotor I'm using is not the List's one, but the Supply's one
Xliff That's what I was hoping to use. 12:41
Let me try that last one and see what I get. 12:42
12:47 archenoth left 12:48 archenoth joined 13:15 xinming joined 13:18 epony left 13:19 epony joined
Xliff SmokeMachine: OK, after attempts I have managed to get this: "use Term::ReadKey; react { whenever key-pressed( :!echo ).rotor(4) { .map( *.ord ).say }; }; 13:21
However, if the return sequence isn't 3 characters, I have to wait until a 4th character comes before I can act on the input. 13:22
The problem is I need to be able to act on sequences of an arbitrary number of values 13:24
F1-F4 have 3 characters per sequence. 13:25
F-F10 have 5 characters.
s/F-F10/F5-F10/ 13:26
How can the supply pattern handle that in a non-blocking way?
13:32 Sgeo joined 13:42 archenoth left 13:43 archenoth joined 13:58 xinming left 13:59 Nemokosch left 14:00 xinming joined 14:14 Nemokosch joined
Xliff How can I detect if $*OUT is redirected to a file? 14:23
Oh! .t is available. Excellent! 14:25
japhb Oh dear lord, don't do this by hand! 14:27
Xliff: See Terminal::ANSIParser if you absolutely need the key sequence yourself. 14:28
See Terminal::LineEditor (and its guts) if you want to learn more about how to use a parsed ANSI sequence 14:29
See also Terminal::Widgets (and its guts) for an even more advanced user of same
14:29 Nemokosch1 joined 14:31 Nemokosch left
japhb In particular Terminal::LineEditor::RawTerminalInput and Terminal::Widgets::Terminal may be of use. 14:32
Do we still have a knowledge bot in channel? 14:33
Xliff japhb: Oh. Thank. You. Jeebus!
I just wanna get the keystrokes.
japhb I feel like I need to create a bot that detects Term::ReadKey and goes "YOU PROBABLY DON'T WANT THAT, PLEASE LOOK OVER HERE." ;-)
Xliff YES, PLS!
I thought I looked at Terminal::Widgets. But it was late at night. I want to put an interface on this app I am writing for $dayJob. 14:34
japhb Terminal::Widgets only has a very small actual widget set. Most of my available hours were spent on getting the guts right. 14:35
So that's completely understandable.
I mean, it's usable for some things, with some work on your part, but certainly not "out of the box ready" 14:36
Xliff japhb: I am most happy to PR the parts I need that aren't there.
I just need something to take keystrokes and give me: F1, or F2, etc
japhb Look at Terminal::LineEditor::RawTerminalInput, that should give you an idea how I wrapped up usage of Terminal::ANSIParser. 14:37
BTW, I gave a talk on all this at the last Raku conf.
conf.raku.org/talk/178 (It's not technical, but the second half does show you what each of the Terminal::Modules do. The first half talks about *why* I've been going through all this pain.) 14:39
Xliff So far, not seeing any function key symbols.
Ooh! Watching, now.
japhb github.com/japhb/Terminal-LineEdit...akumod#L21 14:40
The next couple hundred lines have structures and declarations for decoding the result of Terminal::ANSIParser; starting around github.com/japhb/Terminal-LineEdit...kumod#L356 are the input and output pumps for the ANSI parser. 14:42
(And the length of all that is why I suggest just using the module. ;-) 14:43
14:46 razetime joined 14:53 Nemokosch1 left 14:54 Nemokosch joined
Xliff japhb: So how is ::RawTerminalInput used? 15:06
japhb: This doesn't seem to be sufficient. All of your examples focus on line, not key based input handling... 15:20
japhb Xliff: Starting here: github.com/japhb/Terminal-LineEdit...kumod#L652 you can see how all of that is used to make a single-line line editor input. github.com/japhb/Terminal-Widgets/...al.rakumod shows using the building blocks to form an event pump for terminal events.
Xliff: Have you watched the whole video? :-) 15:21
Xliff --> "use Terminal::LineEditor; use Terminal::LineEditor::RawTerminalInput; my $cli = Terminal::LineEditor::CLIInput.new; $cli.start-decoder; react { whenever $cli.decoded { say $_ } }
Not yet. I am doing like... 3 things at once. I'm in the middle of the workday, here.
japhb AH!
Xliff I got as far as your Basic games books and cracked up laughing. Got strange looks, here.
I think I had those. 15:22
japhb Terminal::LineEditor::CLIInput *uses* the real-time key handling to create a line editor. But that's just the cap on that particular stack. ;-)
Love it!
15:22 epony left
Xliff OK. I might have to wait until lunch. 15:24
.... oh wait....
It is lunch!
japhb :-) 15:25
15:25 Kaipei left, Kaipei joined 15:27 epony joined 15:31 Kaipii joined 15:34 Kaipei left 15:38 razetime left 15:50 razetime joined 15:57 archenoth left 15:58 archenoth joined 16:07 archenoth left 16:18 archenoth joined 16:27 clarjon1 joined 16:30 dakkar left 16:54 Kaipei joined 16:57 Kaipii left 17:02 archenoth left 17:03 archenoth joined 17:12 archenoth left 17:13 archenoth joined 17:16 Kaipii joined, razetime left
Xliff japh: Do you still have those OpenGL demos? 17:18
17:19 Kaipei left
Xliff japhb: github.com/Xliff/p6-COGL 17:20
I can pull >60fps from this one: github.com/Xliff/p6-COGL/blob/mast...03-crate.t
Nemokosch What is this? 17:23
Xliff Raku bindings for the COGL library.
It's based on my p6-GLib work, so it's a bear to install. 17:24
Nemokosch wowie 17:29
17:31 derpydoo left, epony left 17:32 epony joined
Xliff COGL is basically a wrapper around Open GL 17:35
Installation instructions updated in case anyone wants to check it out.
17:52 archenoth left, jjido joined 17:53 archenoth joined
Xliff japhb: Is the mad scientist demo anywhere? 18:05
18:06 reportable6 left
Xliff japhb: MMORPG roguelike FTW? 18:07
18:07 reportable6 joined
Xliff Oh! MUGS! 18:11
18:15 Kaipei joined 18:18 Kaipii left
Nemokosch wonders which one is the real Kaiepi 18:22
Xliff Nemokosch... it's the one with two eyes! 18:23
japhb: my &parse-codepoint := make-ansi-parser( emit-item => { @parsed.push: $_ }); parse-codepoint($_) for $input-buffer.list; # missing the definition for $input-buffer! 18:24
Nemokosch what is the state of MUGS, by the way? 18:31
18:35 Kaipei left 18:58 Kaipei joined
Xliff <punchy>Advocating an Array.lop as the front analog for .chop -- who's with me?</punchy> 19:09
m: "Hello".chop(2).say 19:10
camelia Hel
Xliff m: "Hello".lop(2).say
camelia No such method 'lop' for invocant of type 'Str'. Did you mean 'log'?
in block <unit> at <tmp> line 1
Xliff :( -- This needs correcting!! # :-)
Xliff got into the catnip again.... don't mind him 19:11
japhb: use Terminal::Print::DecodedInput; my $in = decoded-input-supply; react { whenever $in { .say } }; 19:18
19:19 Sauvin left 19:20 Xliff left 19:28 Nemokosch left 19:34 Sauvin joined 19:36 epony left 19:37 epony joined
gfldex .tell Xliff a simple implementation for your problem: gist.github.com/abebd2c82c79858a43...b1bf564412 20:06
tellable6 gfldex, I'll pass your message to Xliff
20:09 jgaz joined 21:04 jjido left 21:14 jjido joined 21:24 jgaz left 21:25 jjido left, Xliff joined 21:26 mykhal left 21:28 mykhal joined
japhb Xliff: It's an older code, but it checks out. :-) 21:30
Xliff: Several of the demos from that talk are not *externally* available, mostly because people get weird expectations around released code, and those don't hit the bar for me. 21:33
Still working on the rpg-ui demo in my "spare time". The "intuitive character creation" demo will eventually be merged into that. 21:34
MUGS development has been paused a bit while I throw energy at those demos, and try to turn them into decent code via Terminal::Widgets improvements. 21:35
My life as a yak shaver, I guess. :-)
21:49 jjido joined
Xliff Hahahaha! 22:16
tellable6 2022-10-27T20:06:26Z #raku <gfldex> Xliff a simple implementation for your problem: gist.github.com/abebd2c82c79858a43...b1bf564412
22:19 deoac joined
Xliff gfldex: Ooh! Thanks 22:21
japhb: What am I missing from the newer code. I would prefer to use the latest and greatest, but I see a lot of similarities between the two... and it works. 22:22
22:22 lichtkind left
Xliff How can I get a method's callable object? 22:25
m: class A { method a { }; method b { &self.a.^name.say }; }; A.b
camelia Nil
Xliff m: class A { method a { }; method b { &self.a.^name.say }; }; A.b() 22:26
camelia Nil
Xliff m: class A { method a { }; method b { &self.a.name.say }; }; A.b()
camelia Nil
Xliff ??
22:26 Xliff left 22:37 Kaipei left 23:14 patterner____ left, patterner____ joined
Voldenet m: class A { method a { say "a called"; }; method b { self.^lookup("a") }; }; A.b.(A) 23:30
camelia a called
Voldenet consider the following 23:31
23:36 jjido left 23:44 epony left 23:45 epony joined