Is it possible to segment CMD window on Windows and segment Terminal window on Linux with golang?

98 views
Skip to first unread message

洪嘉鴻

unread,
Apr 10, 2020, 6:52:20 AM4/10/20
to golang-nuts
Hello everyone:
I use golang with Win10. I want to build executables which can segment terminal window and show different messages on different windows.
Besides, I also want the code can also cross-compile for Linux so that it is convenient to maintain.
Is it possible to segment CMD window on Windows and segment Terminal window on Linux with golang?

Any help is appreciated.
Thank you very much!
Max

Jason E. Aten

unread,
Apr 10, 2020, 7:16:20 AM4/10/20
to golang-nuts
https://github.com/gdamore/tcell/ tcell lets you do fine grain control of the terminal. https://github.com/gdamore/proxima5 is an example game written with it.

However be aware the the terminal on Windows is generally... garbage. There aren't any really good terminal emulators for windows. The cmd.exe terminal responses can vary based on QuickEdit mode and other settings, e.g.

https://github.com/gdamore/tcell/issues/182

洪嘉鴻

unread,
Apr 10, 2020, 8:55:47 AM4/10/20
to golang-nuts
It looks interesting!
However, it looks too difficult for me to do this.
I just found this and use cross-compile to build Windows and Linux executables with Win10.
Then, I executed  the executables on Win10 and Linux(with VMware).
Both of them could work.
Now I'm trying to segment two windows.
One is for scanning inputs.
The other is for displaying results.
Besides, the window which displays results should refresh the screen before displaying new results.
I'm looking for some examples about that. 
Thanks for your replying.
Max

Jason E. Aten於 2020年4月10日星期五 UTC+8下午3時16分20秒寫道:

Jason E. Aten

unread,
Apr 10, 2020, 10:42:50 AM4/10/20
to golang-nuts
Terminals are a pain to work with. Since you want cross-platform anyway, you
should just create a little web server within your Go program, and serve webpages to a browser.
Believe this, it will save you vast amounts of time and energy.

Jason E. Aten

unread,
Apr 10, 2020, 10:49:12 AM4/10/20
to golang-nuts
If you insist on terminal (which as I pointed out, is a mistake; I have made it and learned better), then

https://github.com/rivo/tview

is probably the better choice versus termui.

Mandolyte

unread,
Apr 11, 2020, 10:57:25 AM4/11/20
to golang-nuts
Might review how the micro editor handles it... as an editor functioning in a terminal window and cross platform, it is quite stellar.

洪嘉鴻

unread,
Apr 13, 2020, 1:45:11 AM4/13/20
to golang-nuts
I think that you are right.
I found that the "Hello World" executables are a little different.
In fact, the executables are compiled from the same source code, which means that it might cause a lot of problems if I use it.
I'll try to create a web browser.
Thanks for your suggestions!
Max

Jason E. Aten於 2020年4月10日星期五 UTC+8下午6時42分50秒寫道:
CMD.PNG
VMware.PNG

洪嘉鴻

unread,
Apr 13, 2020, 2:05:34 AM4/13/20
to golang-nuts
I've tried this which you offered, I don't think that it is correct for the box.
Besides, I have no idea why "H" disappeared with Linux executable?
However, I think I'll try to use this for my tasks.
Thanks for your information!
Max

Jason E. Aten於 2020年4月10日星期五 UTC+8下午6時49分12秒寫道:
CMD.PNG
VMware (Ubuntu).PNG

洪嘉鴻

unread,
Apr 13, 2020, 2:22:40 AM4/13/20
to golang-nuts
I don't think it is simple to use because it seems to configure lots of settings.
However, I'll try this.
Thanks for your information!
Max

Mandolyte於 2020年4月11日星期六 UTC+8下午6時57分25秒寫道:
Reply all
Reply to author
Forward
0 new messages