简体   繁体   中英

GoLand setting terminal cells doesn't work

I'm using the tcell library to display terminal cell graphics.

While writing this project in GoLand, I've noticed that using a normal run configuration and running the program in the integrated terminal, I'm not seeing the cells getting set as intended, despite tcell not giving any errors.

Program:

package main

import (
    "time"
    "github.com/gdamore/tcell"  
)

func main() {
    screen, err := tcell.NewScreen()
    if err != nil {
        panic(err)
    }

    err = screen.Init()
    if err != nil {
        panic(err)
    }

    screen.SetCell(0, 0, tcell.StyleDefault, 'X')
    screen.SetCell(1, 0, tcell.StyleDefault, 'X')
    screen.SetCell(1, 1, tcell.StyleDefault, 'X')
    screen.SetCell(10, 10, tcell.StyleDefault, 'X')
    screen.Show()

    time.Sleep(time.Second*5)
}

GoLand output:

GoLand 终端,不显示 Xs

The program works as expected when running through cmd:

在此处输入图像描述

How can I set a run configuration in GoLand to run my program in cmd, or some other form of terminal that will allow me to set cells like this?

  1. Open Help | Find Action... Help | Find Action...
  2. Type Registry and hit Enter.
  3. Find go.run.processes.with.pty there and turn it on.

Please, keep in mind that it can cause problems with run configurations like failing green tests or vice versa, never finishing debug sessions, and so on. If you notice weird IDE behavior related to console output, please disable the registry option back.

I'm not sure if points on Y-axis do display properly inside the Run window.

I guess GoLands terminal is a fake terminal without real cursor addressability. There may not be a good solution if that is the case.

I'm the author of tcell and I use goland but I confess I always run my test programs in a real terminal rather than in the toy terminal that the IDE provides. This is true whether I use goland, visual studio code, or even the venerable emacs.

By using a new Batch run configuration, you can run a batch file to build the program, then run the program in a new cmd window.

In the run configuration in GoLand, set "Working directory" to the main package directory. Then set the script to a new batch file.

Here is the code in my batch file for my package client

go build
start cmd /C client.exe

Running this configuration will build the package, then run the program in a new external cmd window where the cells display properly.

This solution isn't great, because most of the advantages of the GoLand run configuration system are lost, including debugging, process management (stop / restart), and other build options.

Does anyone have a better solution?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM