-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Help with using Notcurses through Neovim #2308
Comments
i'll look into this ASAP, but python is definitely not my area of expertise, so it might take a bit of exploration and experimentation. thanks for the report! i'll see what i can do to help you =]. |
Thank you very much! I understand Python is not quite your thing, take your time -- if you need/want help, hit me up. |
BTW, this isn't a Python-specific issue -- it's more like a Neovim-specific issue, as evidenced by the fact that doing a system call of the compiled C code has the same result. That means that if we can solve this via C this should be solved on the Python end as well. |
yeah, realized that when i looked at it later. it's friday night here, and i've got some people coming over, but i've got this slated for my first thing to look into tomorrow =]. sorry for the delay |
No worries, take your time! Again, thank you very much! |
alright, taking a look at this now =] |
ahhh ok so your entire issue is getting something displayed up from within NeoVim. gotcha. if it captures stdout, it will indeed not display. what if you tried something like if not, a small wrapper that opened alternatively you could write the output to |
perhaps i ought add a |
this feels kinda unnecessary, since the calling code ought always be able to set up |
so here you can see what's going down. first i run so yeah, neovim is taking that output up, presumably by creating a pair of pipes before |
btw note that the second output is oddly placed, obscuring the line from which it was launched. that's because there's cursor-positioning info inside that file. this is another reason why it would be better to redup() /dev/tty, as opposed to printing the output from within neovim. |
if this whole concept of |
Just woke up to this! 😄 Okay, I can try
|
Also, just to check, I'd be using |
|
Gotcha! I'll implement it and then ask for MacOS people to test it then. :)
Ah! I didn't know that! Yeah, I'm glad I asked that, haha |
some other things to note:
|
yep! sorry for being so slow in getting back to you on this; i saw your two code samples and filed this away as a "will have to go debug user's code" problem |
honestly |
No worries! |
Quick question -- with what options should I open |
like i'm not promising antyhing but the following might work: #!/bin/sh
ncplayer -k "$@" > /dev/tty since you can hit /dev/tty from any scope, this uses the shell to do the rebinding, and then shows whatever with |
Ah, fair enough |
I'll try that |
all you ought need is write, yeah, unless you don't lol |
this is all contingent on neovim not redrawing the screen after it calls out, which it might do because of exactly this kind of thing. if that's the case, nothing's going to work; you'll need some different kind of neovim integration. |
LOL
I tried that, it sort of didn't work; I'll try to record a video, but essentially, instead of the escapes being interpreted by the terminal emulator, they were displayed in escaped form. Maybe neovim is the actual /dev/tty? |
I'm pretty sure we don't need to worry about that, but we'll see. |
For some reason I can't reproduce that anymore... what happens now is the following: when run from Neovim, |
ok, i'll have to look at what neovim is doing, exactly. i assume the script does work outside of neovim? |
Oh yeah, it does. |
(I'm takiing a quick break from this now, brb) |
yeah i've got a few other things to cycle to as well. here's the upshot: if you can get something displayed from outside neovim within your script (i.e. it's not just neovim printing it after you return), you ought be able to use the same method to get this working. what terminal btw? if you throw an export | grep TERM in your script, what also try |
Looks like it actually exits with exit code 1, having complained about the following:
Same as my terminal, st:
Similar results if we run it instead on Kitty:
The output is quite large. I've attached a file with that, generated via |
very strange! is there no what happens if you launch do you have a link to the documentation for running stuff from neovim? does it describe what it's doing to that environment? |
Outside Neovim:
Inside Neovim:
Huh.......... it's even the same if I do it from the script...
The script looks like this now, btw:
I'll try to look for that. Worst case scenario we can open an issue there asking for this information. |
With
Also,
In my case, I have I'll take a look if anything different happens with that (The |
You know, if you don't mind, I think I'm actually going to open an issue on Neovim itself, asking about how we should do this. Someone there ought to know. |
sorry to have been distracted away from this, but i intend to look at it today! |
did you hear anything back from the neovim people? they were probably busy getting 6.0 out the door, but maybe they can provide some insight now. if you've got a bug link, do please provide it! |
No worries at all. Same here.
Just opened a topic on their discourse: https://neovim.discourse.group/t/accessing-the-tty-from-neovim-to-show-images-with-notcurses/1597. Apparently that's where they like their questions. |
I've finally been able to take some time to tackle an issue in one of my projects, dccsillag/magma-nvim#15. The idea over there is to use Notcurses in order to show images in the terminal in a more portable manner.
I've successfully come up with the following (sketched!) C code to show an image on some given position and dimensions:
In my case, I need to write my code in Python. Based on the code above, I came up with the following script which does the same:
This works as expected when run as
python test.py
(with that code intest.py
). However, I need to run something along the lines of this Python code above from Neovim. When attempting to do so, via:I get no errors, but I see no output. The same thing happens if I do
where
a.out
is the executable compiled from the C code above.I expect this was probably because Neovim did something like redirect stdout to somewhere weird.
I tried a bunch of hacky and non-portable solutions (e.g., go up the ppid tree to get the containing pty's file descriptor) but none of them worked at all.
So now I'm drawing a blank. What could I do to use basic notcurses functionality (creating a plane, drawing an ncvisual to it, rendering that ncvisual to a part of the terminal grid, and later erasing it) from a program that likes to do weird things with stdout? Or even, is there something I could do to help debug this?
In any case, thank you for your time!
The text was updated successfully, but these errors were encountered: