mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #70] Run 3rd party program #50
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#50
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lesovsky on GitHub (Mar 10, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/70
Hi,
I'm trying to run 3rd party program such as "less", "vi", "psql" but when 3rd party program is finished I can't safely return to the main UI mode. When it's finished, I've got different artifacts in UI mode and I need to completely redraw all primitives.
Could you assist me to solve this issue?
I have a following example and problem is near the runPager() function.
@rivo commented on GitHub (Mar 10, 2018):
Hi,
tcell(and thereforetview) currently doesn't work well when you send your own output to stdout. This messes up the cell buffer.Wouldn't it be better to pipe the output of
lessinto its ownTextViewinstead of stdout? WhenTextViewhas focus, you can also navigate it. Here's what I mean:This way, you don't need to leave the application.
Let me know if this works for you.
@lesovsky commented on GitHub (Mar 10, 2018):
It may works with pager, but with more complex programs like psql (postgresql interactive terminal) or vi it will not work.
Maybe it's possible to realize it as it done in C ncurses with endwin() and refresh() calls?
editor example
psql example
@lesovsky commented on GitHub (Mar 10, 2018):
Yep, I've done it with app.Stop() and wrapping app.SetRoot() into infinte loop with additional
do_quitflag.@rivo commented on GitHub (Mar 10, 2018):
Interesting. I wasn't sure if this was going to work. But it's good that you were able to make it work.
You probably won't even need to call
SetRoot()in the loop.Run()will start atcellsession andStop()will end it.If I had given you a dedicated function for this purpose (e.g. something like
Escape()), it probably would have done the same thing internally. I can still do this for you if you let me know that you need it.@lesovsky commented on GitHub (Mar 11, 2018):
Of course, It would be great and this function will be convenient for me.
@rivo commented on GitHub (Mar 13, 2018):
Please have a look at
Application.Suspend()which should do what you need.There appears to be a bug in
tcell(gdamore/tcell#194) though that leads to one key event being lost of the application comes back from "suspended mode". Once that is fixed, this should work as expected.@lesovsky commented on GitHub (Mar 13, 2018):
Thanks a lot!
Even with mentioned bug,
Application.Suspend()works as I expect and there is no need to useApplication.Stop()+ extra-loop forApplication.Run()@rivo commented on GitHub (Feb 20, 2021):
Reopening this as a reminder to switch to the new
tcellAPI, see https://github.com/gdamore/tcell/issues/194.@rivo commented on GitHub (Mar 11, 2021):
github.com/rivo/tview@b2dec96e1aimplementstcell's new methods but fails whenApplication.Stop()is called while the app is suspended. Waiting for https://github.com/gdamore/tcell/issues/440 to fix this, so this issue is still open for now.@gdamore commented on GitHub (May 19, 2021):
I'm pretty sure that bug is fixed now. Please retest and let me know -- the only reason it's still open is for feedback.
@rivo commented on GitHub (May 20, 2021):
It works! Thanks!