ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.23.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
rocky has quit [Remote host closed the connection]
<crystal-gh> [crystal] oprypin opened pull request #4813: Add a macro to `collect` outputs of a yielding method to an array (master...collect) https://git.io/v7Pxa
vifino has quit [Ping timeout: 248 seconds]
vifino has joined #crystal-lang
alibby has joined #crystal-lang
<FromGitter> <doughsay> can anyone point me to any good tutorials on IO objects and reading and writing different kinds of types to/from them? Trying to build a tcpsocket server/client and don't want to send and decode strings back and forth... The API docs and language guide seem a little sparse on this subject
<watzon> Ok the fact that VSCode's default installer for windows is the 32 bit one annoys me. If I wasn't looking for it this time around I never would have seen the 64 bit installer
<FromGitter> <doughsay> @faustinoaq how do I properly use your plugin? after installing it, all my files have the error `while requireing "prelude": can't find file 'prelude' ...` at the very top of them
<watzon> @doughsay to which plugin are you referring?
<FromGitter> <doughsay> Vscode crystal plugin being talked about up there ^
hightower3 has quit [Ping timeout: 258 seconds]
<watzon> @doughsay what's your system information and the output of `crystal -v`?
<Papierkorb> doughsay, you can use JSON.mapping for structured data if JSON fits the bill. If you're looking for a more powerful (but non-portable) binary protocol, you can build your own of course, or use https://github.com/Papierkorb/cannon (disclaimer, i'm the author)
<watzon> Second disclaimer: he's authored a couple other awesome shards as well
hightower3 has joined #crystal-lang
<Papierkorb> doughsay, if you have a specific protocol in mind, search for it on http://crystalshards.xyz
<Papierkorb> doughsay, and if you really just want to do some RPC without thinking about all the details, cannon can do that too.
<FromGitter> <doughsay> @papierkorb thanks!
<FromGitter> <doughsay> I think cannon is exactly what I'm looking for
<FromGitter> <doughsay> @watzon `Crystal 0.23.1 (2017-07-13) LLVM 4.0.1` installed using homebrew on macOS 10.12.6
rohitpaulk has joined #crystal-lang
<hightower3> Hey, please remind me. Some days ago I got instructions I should not do File.read(filename) to read binary data, but which alternative?
hightower2 has joined #crystal-lang
hightower3 has quit [Ping timeout: 260 seconds]
<hightower2> (File.open and IO.read_bytes)
_whitelogger has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
hightower2 has quit [Ping timeout: 240 seconds]
<FromGitter> <doughsay> there seem to be two competing vscode plugins being worked on, which one's "better" right now? crystal-lang or crystal-ide? just looking for some opinions... ;)
<watzon> I’m using Crystal Lang
rohitpaulk has quit [Ping timeout: 276 seconds]
<FromGitter> <doughsay> with scry installed? is that working well yet?
<FromGitter> <faustinoaq> @doughsay The extension Crystal-Lang is based on Crystal-IDE 😅 . I refactored the code made by @kofno. Also I added symbols, hover information, completion, embed crystal, slang, and many other features.
<FromGitter> <doughsay> aha, I see, thanks for the info!
<watzon> I’m having mixed results with scry at the moment, but I’m also on Windows and hacking things royally
<FromGitter> <faustinoaq> I need to install Linux Subsystem on Windows and try Scry, Maybe I can fix my extension to support that way.
<FromGitter> <doughsay> is it possible to compile scry with Crystal 0.23.1? not having much luck here...
hightower2 has joined #crystal-lang
<FromGitter> <doughsay> also, did you see my question from earlier @faustinoaq? I'm getting `while requiring "prelude": can't find file 'prelude' ...` at the top of every file using vscode-crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter> <faustinoaq> > while requiring "prelude": can't find file 'prelude' ⏎ ⏎ Seems to be a CRYSTAL_PATH issue, ⏎ ⏎ This line is the problem https://github.com/faustinoaq/vscode-crystal-lang/blob/master/src/crystalConfiguration.ts#L18 [https://gitter.im/crystal-lang/crystal?at=598a794080d90ca024dffb6c]
<FromGitter> <faustinoaq> I use Linux, so `/usr/lib/crystal` is the default path for Crystal stdlib.
<FromGitter> <faustinoaq> I don't have a Mac 😅 so, Can you show me your `crystal env` output please?,
<watzon> faustinoaq: maybe you could make that line contingent upon the OS?
<FromGitter> <doughsay> CRYSTAL_CACHE_DIR="/Users/chris/.cache/crystal" ⏎ CRYSTAL_PATH="/usr/local/Cellar/crystal-lang/0.23.1/src:lib" ⏎ CRYSTAL_VERSION="0.23.1"
<FromGitter> <doughsay> it's installed using homebrew, which will put it in a different folder every version
<FromGitter> <faustinoaq> watzon: Yes, now I remember I did it right on Sry https://github.com/kofno/scry/blob/1bff42ea0624eb991f11a7a90307a49fe4dce6cf/src/scry/initializer.cr#L14
<watzon> Yeah that looks better
<FromGitter> <faustinoaq> > it's installed using homebrew, which will put it in a different folder every version ⏎ ⏎ Ok, let me fix that on the extension 😅
<FromGitter> <doughsay> thanks @faustinoaq! 😄
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
<crystal-gh> [crystal] icyleaf opened pull request #4814: HTTP::Response: set default cookie domain (master...support/default_cookie_domain) https://git.io/v7XTf
<watzon> Almost got my boss to let us use Crystal for a pretty big project today, but since it isn't out of beta yet he doesn't want to risk it
<FromGitter> <doughsay> so close!
<watzon> Looks like we'll be using Scala or Kotlin instead
hightower2 has quit [Ping timeout: 255 seconds]
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
tdc has joined #crystal-lang
<FromGitter> <doughsay> @papierkorb cannon is super cool and works perfectly for me. it has definitely increased my performance over manually serializing and deserializing. great job on this shard!
A124 has quit [Read error: Connection reset by peer]
FWTIKPNWBSRSHYOM has joined #crystal-lang
DTZUZO has quit [Ping timeout: 246 seconds]
mark_66 has joined #crystal-lang
<FromGitter> <bew> what would be the cleaner way to get a program stderr? for stdout we have `<backtick>program_to_run arg1, arg2<backtick>`, I wonder if there is a almost as clean way to get the stderr only
FWTIKPNWBSRSHYOM has quit [Ping timeout: 268 seconds]
<FromGitter> <bew> nvm I used the backtick method and just replaces `output` by `error`, it seems to be the closest thing I can get easily
hightower2 has joined #crystal-lang
DTZUZO has joined #crystal-lang
jhass has quit [*.net *.split]
tatey has quit [*.net *.split]
dom96 has quit [*.net *.split]
cyberarm has quit [Ping timeout: 258 seconds]
DTZUZO has quit [Ping timeout: 260 seconds]
cyberarm has joined #crystal-lang
<hightower2> Hey, I wanted to open a binary file using File.open, read it into a Bytes variable using IO.read, and then run a series of IO.read_* on the Bytes to extract individual fields. However, the result of IO.read() is a Slice, on which there are no #read_* methods. What's the catch?
<FromGitter> <straight-shoota> hightower2, you don't need to read twice
<FromGitter> <straight-shoota> either you read the fields directly from the file or read the whole file into a Slice
<hightower2> Yes, true, but I would like to have access to the convenient read_* methods. What do you suggest for e.g. reading an UInt16 in LE format from the Bytes?
<FromGitter> <straight-shoota> Why don't you just use the read methods on the IO?
<hightower2> I'd prefer to load the whole thing in memory and be done with the file on disk
<hightower2> but yeah, I could do that
<hightower2> Looks like I could do IO::Memory.new( Bytes)
<hightower2> this would give me the IO object which is not associated to the disk file
<FromGitter> <straight-shoota> File is buffered anyway
<FromGitter> <straight-shoota> so maybe you don't even need that
<hightower2> ok
<hightower2> thanks
<hightower2> (Got it working as expected)
DTZUZO has joined #crystal-lang
jhass has joined #crystal-lang
tatey has joined #crystal-lang
dom96 has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
<hightower2> Do I see it right that IO has no variable telling how many bytes were read / current position?
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <bew> `IO#read` will return the number of bytes that has been read
<FromGitter> <bew> the current position has almost no meaning for thing that are not files. but you can get the current position in the file by using `IO::FileDescriptor#pos`
<oprypin> hightower2, IO subclasses are free to have that
<hightower2> Great, thanks.
bmcginty has quit [Ping timeout: 240 seconds]
bmcginty has joined #crystal-lang
<FromGitter> <faustinoaq> @doughsay I published vscode-crystal-lang@0.2.14 (https://marketplace.visualstudio.com/items?itemName=faustinoaq.crystal-lang). I think `prelude` problem have been solved 😅
<hightower2> Can I somehow achieve the effect of IO#read_string, but to have the method figure out where the nul-character is, instead of me having to specify length in advance?
<hightower2> Will do it reading a byte at a time and appending to string unless it is \0
<hightower2> ah, even better, there is read_char
<FromGitter> <sdogruyol> Hey everyone
<FromGitter> <straight-shoota> hightower2, you can use `gets('\0')`
<hightower2> straight-shoota: you da man, that was it
<FromGitter> <straight-shoota> or `gets(' \0', true)` to chomp the zero character
<FromGitter> <straight-shoota> sry `gets('\0', true)`
<FromGitter> <straight-shoota> `Char::ZERO` would even be better than literal
<hightower2> ++
<FromGitter> <straight-shoota> Does someone know if it is possible to define an abstract method which receives a block without catching it?
<Papierkorb> For an abstract method iirc, you have define the block as catching, but in the implementation, you can use `yield` and not catch the block at all
<FromGitter> <straight-shoota> Ah yes, that works
<FromGitter> <straight-shoota> thanks
A124 has joined #crystal-lang
Ven has joined #crystal-lang
Ven is now known as Guest88211
tdc has quit [Quit: Leaving]
tdc has joined #crystal-lang
w-p has quit [Ping timeout: 248 seconds]
<RX14> oprypin, wouldn't it be possible to use Array(typeof({{expr}} { |x| break x })).new
<RX14> i havent tested it though
<Papierkorb> using both `{..}` and do/end on the same expr could break in some edge cases
<RX14> well i think ASTNode#to_s probably brackets it to be ambiguous
<RX14> non-ambiguous*
<RX14> because it always uses () around args
Guest88211 has quit [Ping timeout: 248 seconds]
<RX14> actually my solution breaks if there's early return
<FromGitter> <straight-shoota> your solution always breaks :P
<oprypin> RX14, your suggestion - that's nillable
<RX14> hmm?
<oprypin> RX14, typeof({{expr}} { |x| break x })) is x or nil
<RX14> weird
<oprypin> "what if block executes 0 times"
<oprypin> in my case it's x or sentinel and i can throw away sentinel
<RX14> yeah your solution is the best
<RX14> but i do think that maybe there ought to be a better way
<oprypin> lol calling the kludge the best
<RX14> well a kludge is the best if it's the only solution that works
<Papierkorb> I'm actually more surprised that typeof() accepts a begin-block at all
<RX14> really?
<RX14> it's used a fair lot
<Papierkorb> seeing how restricted typeof() is, yes
<Papierkorb> oh, no, sizeof() was restricted
<RX14> yes
<FromGitter> <straight-shoota> passing the type explicitly is much simpler ;)
<oprypin> i wanna make it look nice if so
<FromGitter> <straight-shoota> different question: does anyone have any idea how I can find and filter files more detailed than `Dir.glob`? I looked an crystalshards.xyz and awesome-crystal but didn't fine anything related. I want to be able to be able do query for example all files with extension .sass or .scss in non-hidden directories and basename does not begin with `_`. So I basically want `find` as a Crystal lib :P
<oprypin> someone recently struggled with that
<oprypin> i dont think there was a solution
rohitpaulk has joined #crystal-lang
alibby1 has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 276 seconds]
alibby has quit [Ping timeout: 248 seconds]
rohitpaulk has joined #crystal-lang
<RX14> looks like someone needs to write a crystal lib
rohitpaulk has quit [Ping timeout: 276 seconds]
beardedeagle has joined #crystal-lang
<hightower2> straight-shoota: something like https://github.com/sstephenson/hike ?
<hightower2> (Ruby version, let's figure out which lib it would be best based on)
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
mark_66 has quit [Remote host closed the connection]
<FromGitter> <straight-shoota> yeah something like that
<FromGitter> <straight-shoota> though with a nice API ;)
beardedeagle has quit [Quit: WeeChat 1.9]
Ven has joined #crystal-lang
Ven is now known as Guest36538
<FromGitter> <Fryguy> what is the mailing list for crystal? I don't see it on the Comminity page on the website https://crystal-lang.org/community/
rohitpaulk has joined #crystal-lang
mjblack has joined #crystal-lang
<oprypin> that page should have the words mailing list, not just Google groups and an irrelevant logo
gewo has quit [Quit: WeeChat 1.6]
tdc has quit [Read error: Connection reset by peer]
tdc has joined #crystal-lang
<FromGitter> <Fryguy> thank you!
<FromGitter> <Nbotz> how can i break a .each loop?
<FromGitter> <Fryguy> yeah, I didn't realize Google Groups == mailing list
<FromGitter> <Fryguy> I can make a PR for that
<Papierkorb> Nbotz, `break`
<FromGitter> <Nbotz> i get an error
<Papierkorb> That's not how it works. Remove the `break`, look at the output again to see, what `i` is.
<Papierkorb> Then have a second look at the actual error message
<watzon> Nbotz you're reuzing the variable `i` which is an Int32
<FromGitter> <Nbotz> should i use something else?
<FromGitter> <Nbotz> i want to make sure the .each loop doesn't go over a certain amount
Guest36538 has quit [Ping timeout: 276 seconds]
<FromGitter> <Nbotz> oh no wait i get it now holy moly i feel stupid thanks for the help guys
<watzon> I'm confused as to what you're trying to accomplish haha
<watzon> All right :)
<FromGitter> <Nbotz> i wanted to do the equivalent of for(i = 0, i < 5, i++)
<Papierkorb> See #each_with_index in the simplest case
<watzon> So something kinda like this? https://play.crystal-lang.org/#/r/2i2h
<FromGitter> <Nbotz> that's perfect watzon and Papierkorb
<watzon> Scratch that
<FromGitter> <Nbotz> is it wrong?
<watzon> That's better
<FromGitter> <Fryguy> @RX14 @oprypin I made a PR to add the term "mailing list" to the website: https://github.com/crystal-lang/crystal-website/pull/49 Thanks!
<watzon> Is that technically a mailing list though? It's a Google Group isn't it?
<RX14> oprypin, i think the macros not being available on generics is a bug
<RX14> it's weird but that works
<RX14> it seems to me more of a parsing error than anything else
Ven has joined #crystal-lang
Ven is now known as Guest39777
<FromGitter> <bararchy> Does someone remmbers what parameters I need to increase in Arch Linux at the system (limits?) level to allow more Fibers
<FromGitter> <bararchy> ?
<watzon> Are you referring to the inotify watch limit? I don’t know about increasing fiber limits
<FromGitter> <bararchy> I think it's increasing the heap size limit
<FromGitter> <johnjansen> or memory?
<FromGitter> <johnjansen> `export GC_INITIAL_HEAP_SIZE=8G && ./my_executable`
<FromGitter> <johnjansen> if its heap thats the problem
<FromGitter> <bararchy> I get ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=598b4a40210ac269206aa121]
<FromGitter> <bararchy> So I think I need to increase max heap size right ?
<RX14> @bararchy vm.max_map_count
<RX14> it's the number of mmaps that's the limit not the memory
<FromGitter> <bararchy> RX14: Yes !! Thansk :) 👍 👏
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <bararchy> Well... seems like I still getting this thing ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Any ideas why ? [https://gitter.im/crystal-lang/crystal?at=598b50021c8697534aa1eb7f]
<FromGitter> <bararchy> I got 16Gb RAM , it's not looking like it eats them
<FromGitter> <sdogruyol> @bararchy gc config?
<watzon> @bararchy what’s the code that’s causing the heap to overflow?
<FromGitter> <bararchy> @sdogruyol Running with `export GC_INITIAL_HEAP_SIZE=8G && ./my_executable` Still creates this issue
<FromGitter> <bararchy> watzon, well, I'm not sure, it's kinda big haha
<FromGitter> <sdogruyol> Hmm
<FromGitter> <bararchy> But, I can't decipher this error, is there a place I can increase the heap size ? 84MiB is really small no ?
Guest39777 has quit [Ping timeout: 240 seconds]
tdc has quit [Ping timeout: 255 seconds]
Ven has joined #crystal-lang
Ven is now known as Guest3761
<FromGitter> <LuckyChicken91_twitter> can i set a limit how much the user can enter in `gets`?
<oprypin> not in any reasonably easy way
<watzon> What do you mean exactly?
<oprypin> just make a loop and ask for input until the user enters something of acceptable length
<FromGitter> <LuckyChicken91_twitter> the `gets` is just stopping getting input when the user is pressing ENTER
<FromGitter> <LuckyChicken91_twitter> but until the user can enter things as long as he wants
<FromGitter> <LuckyChicken91_twitter> and this is what i want preven
<FromGitter> <LuckyChicken91_twitter> t
<watzon> So you want to limit the amount of characters the user can type?
<watzon> Not easy to do without using something like ncurses
<FromGitter> <LuckyChicken91_twitter> hm i could just test if the user is pressing a key and then im printing it
<FromGitter> <LuckyChicken91_twitter> and then i whould have more control of the entering from the user
<FromGitter> <LuckyChicken91_twitter> but theres one big problem
<FromGitter> <straight-shoota> If it was a gui application, you could easily implement a key event listner... unfortunately this is not so simple in a terminal. You'll probably have to use ncurses or similar
<FromGitter> <johnjansen> @LuckyChicken91_twitter gets can take a limit ⏎ https://crystal-lang.org/api/0.23.1/IO.html#gets%28limit%3AInt%2Cchomp%3Dfalse%29%3AString%3F-instance-method
<FromGitter> <johnjansen> im assuming this works for STDIN
<FromGitter> <LuckyChicken91_twitter> no i dont mean this @johnjansen
<FromGitter> <johnjansen> ok, sorry ;-)
<FromGitter> <LuckyChicken91_twitter> this is just changing the string of the user AFTER he entered it
<watzon> Yeah what you want won’t really be possible without ncurses
<FromGitter> <LuckyChicken91_twitter> but before he can still enter text so long as he want
<oprypin> LuckyChicken91_twitter, i suggest to tell the user to try again, not change it
<FromGitter> <LuckyChicken91_twitter> but this dont looks good
<oprypin> i'm saying that you don't want to actually prevent the user from entering text because it's very difficult. ncurses, as watzon suggests, would do it.
<FromGitter> <LuckyChicken91_twitter> i could do all this without ncruses but the problem is that deleting characters is not working good anymore
<oprypin> but oh god i dont want to provide customer support about that
<FromGitter> <LuckyChicken91_twitter> this is the onlyst problem
<watzon> Just tell them there is a character limit and print an error if they enter too many. There’s a reason you don’t see any terminal based apps limiting characters, and that’s because it’s not easy to do without ncurses or similar
<FromGitter> <LuckyChicken91_twitter> but i generaly want that the user cant enter some characters
<watzon> If you know c you can try to translate this to crystal https://stackoverflow.com/questions/10004895/c-reading-from-stdin-as-characters-are-typed
<watzon> It’s similar to what you want
<FromGitter> <LuckyChicken91_twitter> can not just someone help me with the problem that the deleting of characters is not working really good with my easy method?
<FromGitter> <LuckyChicken91_twitter> i just want to test if the user is pressing a key
<FromGitter> <LuckyChicken91_twitter> and then im printing the key
<watzon> It would help if you’d share the code that you have already
<FromGitter> <LuckyChicken91_twitter> is there maybe a super special character which is having the same function as the delete key on our normal keyboards
<FromGitter> <LuckyChicken91_twitter> okay wait
<oprypin> sure, "\b "
<oprypin> space included
<FromGitter> <LuckyChicken91_twitter> i already tried this
<watzon> +1 for oprypin
<FromGitter> <LuckyChicken91_twitter> its not working excatly like the normal backspace key
<watzon> Code?
<oprypin> "\b \b" could do it
<FromGitter> <LuckyChicken91_twitter> tried it too i think
<watzon> Where do these _twitter usernames come from?
<oprypin> watzon, log in with twitter
<FromGitter> <LuckyChicken91_twitter> from the guys who are loggining in with twitter
<watzon> Ahh gotcha
<FromGitter> <LuckyChicken91_twitter> like me
<FromGitter> <LuckyChicken91_twitter> orypin, im yet using already "\b \b"
<watzon> Should’ve been obvious I suppose, but I’ve never logged in with twitter
<oprypin> k well if you want help, show a minimal example that shows what you have and what you're missing from it
<watzon> Is your code in GitHub? If not share it as a gist or on play.crystal-lang.org
<FromGitter> <LuckyChicken91_twitter> this \b \b is working but not if i want to delete a char for example in the middle of a string
<FromGitter> <LuckyChicken91_twitter> because then theres a space
<oprypin> how do you even have a cursor
<FromGitter> <LuckyChicken91_twitter> but i want that the other chars are going to the thing where i deleted (really hard to explain) like the normal backspace
<FromGitter> <LuckyChicken91_twitter> im just having a cursor
<oprypin> oh ok
<FromGitter> <LuckyChicken91_twitter> windows 10 is giving you normaly a cursor
<FromGitter> <LuckyChicken91_twitter> and i really like this cursor because its really helpful
<FromGitter> <LuckyChicken91_twitter> it whould be really sad if we whould be in 2017 and still using just the keyboard to control our cimputers
<oprypin> you are using a terminal from 1980 and complaining that it doesn't have 2017 features
<watzon> Lol 😂
<watzon> Nothing wrong with using the keyboard. It’s more efficient. That’s the whole promise behind editors like vim and emacs
<watzon> If you want a GUI just make a GUI
<watzon> Premise*
<FromGitter> <LuckyChicken91_twitter> uh yes is someone having a solution for the why-are-the-other-chars-not-going-to-the-place-of-the-deleted-char-problem?
<watzon> Not without code samples
<FromGitter> <LuckyChicken91_twitter> what was the website again for crystal code samples
<watzon> play.crystal-lang.org or carc.in I believe
<FromGitter> <LuckyChicken91_twitter> ah carc in1
<FromGitter> <LuckyChicken91_twitter> i luv this webiste+
<watzon> Although you almost may as well use a gist. If your code requires user input carc.in isn’t going to do us any good
<oprypin> yes
<oprypin> https://glot.io/new/crystal is good but they rarely update the version (0.21.1 now)
<watzon> Good one. Didn’t even know that existed
<FromGitter> <LuckyChicken91_twitter> here https://carc.in/#/r/2i43/edit
<FromGitter> <LuckyChicken91_twitter> not working in carc.in
<FromGitter> <LuckyChicken91_twitter> test it in normal terminal
<oprypin> good :)
<FromGitter> <LuckyChicken91_twitter> and now? if you are for example in the middle of "lddw" and then pressing backspace then theres a hole. A space
<oprypin> yes i got u, example coming soon
<FromGitter> <LuckyChicken91_twitter> okay
<oprypin> my terminal doesn't support jumping to the middle of the string though
<oprypin> as it shouldn't
<FromGitter> <LuckyChicken91_twitter> no just use arrow keys
<FromGitter> <LuckyChicken91_twitter> i mean if you go normaly with arrow keys to the middle
<oprypin> i cannot
<oprypin> and because it's not a normal terminal feature you probably can't detect cursor position
<watzon> I’m not at my computer right now, but I think instead of printing the input you should be adding entered characters to an array, flush stdin, and then print the array as a string with the carriage return character on the end
<FromGitter> <LuckyChicken91_twitter> i can detect arrow keys
<FromGitter> <LuckyChicken91_twitter> i just need to add a case statement
<oprypin> watzon, that is correct, the problem is you don't know which part of the array to delete when backspace is presse
<watzon> Then keep track of the cursor position by listening for the left and right arrow keys
<watzon> Those keys get sent to stdin right?
<oprypin> that's gonna break
<watzon> Then rather than using the `\b` character you’d just delete the character at the cursor position
<oprypin> \b by itself drops the cursor position, as well
<watzon> I’ll get back to my computer and do some tinkering
<FromGitter> <straight-shoota> I don't think this is going to lead anywhere. If you need such fine grained terminal control, there are libraries for that. It's really a pain in the ass to get this right by yourself.
<FromGitter> <LuckyChicken91_twitter> orypin, you can use your arrow keys now with this code
<FromGitter> <LuckyChicken91_twitter> https://carc.in/#/r/2i46/edit
<oprypin> LuckyChicken91_twitter, https://carc.in/#/r/2i48
<oprypin> cuz i assume you need to have that string available as well, right?
<oprypin> otherwise you're just printing stuff but you never save it
<FromGitter> <LuckyChicken91_twitter> its not important if im not saving it
<FromGitter> <LuckyChicken91_twitter> its just a sample
<FromGitter> <LuckyChicken91_twitter> a prototype
Guest3761 has quit [Ping timeout: 248 seconds]
<oprypin> LuckyChicken91_twitter, https://gist.github.com/36ca2b9e108763c0aed0dc25bbe4e03b it has a crazy amount of edge cases
<Papierkorb> ... why not Readline?
<oprypin> ‎[20:40:47] <LuckyChicken91_twitter> can i set a limit how much the user can enter in `gets`?
<watzon> Yeah, this just isn't going to work without a lot of hacking
<FromGitter> <LuckyChicken91_twitter> orypin
<FromGitter> <LuckyChicken91_twitter> why is this solution so simple
jokke has quit [Quit: WeeChat 1.7.1]
jokke has joined #crystal-lang
onionhammer has quit [Read error: Connection reset by peer]
cyberarm has quit [Ping timeout: 240 seconds]
cyberarm has joined #crystal-lang
onionhammer has joined #crystal-lang
<watzon> Would it make sense to add a `Resolv` class to the standard library that has more or less the same functionality as Ruby's Resolv class? https://ruby-doc.org/stdlib-2.1.0/libdoc/resolv/rdoc/Resolv.html
alibby1 has quit [Ping timeout: 240 seconds]
alibby has joined #crystal-lang
onionhammer has quit [Ping timeout: 260 seconds]
alibby has quit [Ping timeout: 248 seconds]
<hightower2> Hey, I'm doing (literally) "if obj.x!= 1" and I am getting "undefined method 'x!=' for MyClass". Is really != a method? What purpose would one have in defining that? Shouldn't this just be a negation of == ?
<hightower2> (If I add a space to have "if obj.x != 1" then it works normally)
<watzon> Yeah a space is necessary
<FromGitter> <doughsay> I assume that's a holdover from the ruby syntax that crystal is inspired by. Ruby methods can end in a `!` or `?`
<FromGitter> <doughsay> BUT, ruby doesn't allow "setters" to have `!` or `?` in them... so that's a little different?
<hightower2> No but the error message says "undefined method x!=". This would imply that it thinks the method name is "!=", not just "!"
<hightower2> Also, in Ruby I believe one can write x!= something, and it is properly parsed as !(x == something)
<FromGitter> <doughsay> no, the method name is `x!=`
<hightower2> ooh
<FromGitter> <doughsay> yes, you're right, ruby doesn't produce the same error, it works as expected
<Papierkorb> you're confusing the tokenizer. how should it know you actually meant `foo !=` ?
<watzon> x!= is a valid method name I believe
<FromGitter> <doughsay> it appears to be a valid method name in crystal, but it's not in ruby
onionhammer has joined #crystal-lang
<watzon> May be something to add to the issue tracker. Idk if that should be a valid method
<hightower2> Will do
<hightower2> Another problematic/nonobvious thing I have is what I believe to be related to implicit initialize() methods. I have initialize in base class, and I set @var = value. Then I have initialize in the subclass, and I also set @var = value. But some default/implicit initializes must be getting created, because whatever I do it tells me that some initialize methods don't initialize @var.
<hightower2> Which isn't true (at least not in my code), since I only have 2 of them (one in parent class, one in subclass), and both define it
<hightower2> Ok solved that one, please ignore.
<FromGitter> <doughsay> :D
<FromGitter> <simaoneves> Hello everyone
<FromGitter> <simaoneves> i've been messing around with Crystal, it looks great :)
<FromGitter> <simaoneves> quick question, is it possible to access system clipboard?
<watzon> Not easily
<watzon> The "clipboard" is dependent on your OS and window manager
<FromGitter> <simaoneves> thanks :)
<FromGitter> <simaoneves> right, hard to do
<FromGitter> <simaoneves> we could always "shell" out to do it i guess, based on each system
ragmaanir has joined #crystal-lang
ragmaanir has quit [Client Quit]
ragmaanir has joined #crystal-lang
snsei has joined #crystal-lang
<watzon> Someone could always create a shard for it, but the shard would have to detect the window manager and then use that specific window manager's protocol for accessing the clipboard
<watzon> You can always look at xclip for ideas https://github.com/milki/xclip
<oprypin> that's not something a window manager does
snsei has quit [Ping timeout: 260 seconds]
<ragmaanir> hi, anyone knows a tool with which to convert terminal output (with color) to an image (svg/png or so)? but this should be possible to run a script without running extra terminal windows etc.
alibby has joined #crystal-lang
alibby has quit [Read error: Connection reset by peer]
alibby1 has joined #crystal-lang