-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OSX console doesn't hook stdout #224
Comments
regarding
i think you 're talking about When you write it that way parenthesis are mandatory, same for slots and probably some others |
Here's another approach for OSX http://stackoverflow.com/questions/16391279/how-to-redirect-stdout-to-a-nstextview?rq=1 instead of the tesi.c . I also see commented code in cocoa-term.m that suggests I tried something like that (but not well enough). There is something very odd going on with OSX and standard out. At the end of shoe_native_console I do a printf("Mak\010c\t console \t\tcreated\n"); //test \b \t in string` That shows on the screen after going thru the pty/tesi. (it's there to to test tabs and bs). It works!. A newer test:
does switch and output "Now on stdout" which suggests Ruby (on osx) is not using fd[1] for stdout which makes no sense at all. |
don't know how to help here ... i have "Now on stdout" also on linux |
Some success on this issue._ Here's the individual video tests. https://gist.github.com/ccoupe/a6e77b37e3edcbff3559 from OSX. The run all test doesn't work - hangs Shoes after test 2. Of course the question arises about one of the test failures? Is it even fixable? |
Now this is funky ! the test failure in the gist is strange : it does get a height but 474 instead 480 is non sense ... (do test pass if you check for height != 0 instead of a concrete dimension ?, some codec dimension accommodating ? (i know some codec have restriction on size, must be multiple of 16 for example) - let's hope it's not a fiddle/mac peculiar behaviour, in test4 that's where the dimensions comes from - Also does the scrolling works ? in gtk the rendering must happen in a visible part of the ui : |
Cocoa uses a run_loop of events, where events can be generated by program code so it is essentially asynchronous as well as timers, and many external activities. There's an odd bug on the mailing list about video on OSX - where the widget doesn't show the video, just the black screen but the audio plays. But only on the older osx 10.9. On My unauthorized 10.9 VM, both shoes and VLC app do that (don't work) but that's not a confirmation or way to test it since VLC.app works for him. It does suggest some race condition. I think I have to subclass NSView for the Video widget in order to specify the callbacks. There are a couple that might work Going through the tests in order did draw one big black bar so I think that code is OK now that start{} is working. For what it's worth, testing native control sizes/dimensions would fail on different platforms. You may need some fuzzy measure of success +/- 10% of requested? |
only for test4, right ?, others must be small ! beware, though the black screen is not a guaranty of success, it could be only the NSView being drawn, it tells nothing about the success of Vlc's hook on that surface |
* works just as well (or just as bad). * more control possible for events * add some log messages * need to do something for shoes_native_surface_remove
The latest commit uses a new cocoa subclass and does the realized settting in a separate method (and time?) Doesn't hurt. Doesn't help. Videos are fine for users. Same behaviour for tests. Except I added a few log messages. If you look at the commit you might notice shoes_native_surface_remove is a no-op and if you saw the test log with the new NSLog messages in it one might think that is a real problem I should fix. ;-) If we ever get to #144, tests like you've done for would be very valuable. That idea needs an opaque Shoes class "Insertion_Point" (very different native implementations) and methods to move it, append here, delete from here to there, Since that opaque class is completely undefined at this time, tests would be very good to add as we (if) we work on that. |
oh wait, ... this is coherent with problem at hand ... (on tests at least) Might be wrong by i think you nailed it ! |
* compile and call tesi differently on osx. don't use a pty on OSX. * #224 - still a problem.
I should surrender my Unix Programmer Card because I forgot that some nix syscalls set the global variable 'errorno' and it can be used to get a string error message. Here's what I get when trying to dup2(newfd, (fileno(stdout)):
Finally a clue! I wonder what would happen if I close(stdout) before the dup2?
That makes sense. Why or when OSX became so difficult to deal with stdout will be discovered. |
OR test code bugs are the problem being reported by the test code. I hate that! Number 25 (0r 26 or 23) is the fd of the pipe, not the error code. sigh |
* now able to output from C to stdout fd - write(fileno(stdout), ...); * fprintf(stdout) ... not working (aka printf() ) * can write to pipe with cocoa. * much much more to do
I think I mo`-betta understand the problem after many man days of huh? Most folks would launch Shoes with a double click on the icon in /Applications which actually calls the bash script 'shoes-launch' which tries to decide if it should call 'open Shoes.app --args' or 'ugly/path/to/shoes-bin args'. Only the latter has stdout pointing to a terminal (the launching terminal). This is similar to what Windows does, i.e. shoes.exe vs cshoes.exe When OSX shoes spins up from a non terminal launch stdout points to the equivalent to /deb/null. The ./cshoes script for OSX can go either way depending on args parsed by shoes-launch. So, when shoe_terminal gets called, C, Obj->C/Cocoa ,and Ruby already have references to stdout as as an fd, File * or FileHandle * or all three. Which one does osx/ruby hold in $stdout ? It's big deal for Shoes/OSX and it's not simple because it affects a lot of Shoes launch code |
I managed to get a stdout working almost well enough(I think). C write(), C printf, and Obj-C [NSFileHandle write: data] works for #236. Ruby however, seems to use the old /dev/null stdout that existed at startup and I haven't found the magic Ruby calls to re-init stdout. Some of the code really should be run at Shoes startup - before initializing Ruby if it can detect that it doesn't have a stdout. Important IF. OSX uses the cocoa notification center - observer stuff for file events - dataAvailble for Filehandle. I like it. I vaguely remember that gio/gtk can do something similar, @passenger94 - is that true? If so, that would allow us to get rid of the pty for Linux and possibly do something nice for Windows. . Another Big IF. |
* hack to use stderr for Ruby since I can't find a better way to tell ruby that stdout has changed.
* new bug script for testing * BEWARE the Monkey Patch. I might do it in C. OSX can not line buffer NSPipes. * if your running Shoes scripts that need a terminal (ick) a few extra lines of Ruby is the least of your problems.
I figured out how to reset stdout at the Ruby level so I don't have to deal with fixing world.c (yet) to handle terminal/no-terminal situations. It requires a monkey patch to IO.puts if Shoes.terminal is called. @passenger94 , @backorder please look at the monkey patch in bugs/bug224 before I move it into rb_eval_string() (but only for OSX) |
can't tell what's going on on OSX, all i know is that i can do Hello, busy at the moment, sorry fo not being around too much lately. |
* works well enough stdout wise. Now #236 is calling.
I'm closing this one. There's rough edges if your cocoa savvy and some unused code could be deleted but it's done. |
only the $stderr.puts is displayed. Also, why can't button accept { quit } and requires do end.
The text was updated successfully, but these errors were encountered: