简体   繁体   English

GoLand 设置终端单元不起作用

[英]GoLand setting terminal cells doesn't work

I'm using the tcell library to display terminal cell graphics.我正在使用tcell库来显示终端单元格图形。

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.在 GoLand 中编写这个项目时,我注意到使用正常运行配置并在集成终端中运行程序,我没有看到单元格按预期设置,尽管 tcell 没有给出任何错误。

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:戈兰 output:

GoLand 终端,不显示 Xs

The program works as expected when running through cmd:通过 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?如何在 GoLand 中设置运行配置以在 cmd 或其他允许我设置这样的单元格的终端形式中运行我的程序?

  1. Open Help | Find Action...打开Help | Find Action... Help | Find Action...
  2. Type Registry and hit Enter.键入注册表并按 Enter。
  3. Find go.run.processes.with.pty there and turn it on.在那里找到go.run.processes.with.pty并打开它。

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.如果您注意到与控制台 output 相关的奇怪 IDE 行为,请重新禁用注册表选项。

I'm not sure if points on Y-axis do display properly inside the Run window.我不确定 Y 轴上的点是否在 Run window 内正确显示。

I guess GoLands terminal is a fake terminal without real cursor addressability.我猜 GoLands 终端是没有真正 cursor 可寻址性的假终端。 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.我是 tcell 的作者,我使用 goland,但我承认我总是在真实终端中运行我的测试程序,而不是在 IDE 提供的玩具终端中运行。 This is true whether I use goland, visual studio code, or even the venerable emacs.无论我使用 goland、Visual Studio 代码还是古老的 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.通过使用新的批处理运行配置,您可以运行批处理文件来构建程序,然后在新的 cmd window 中运行程序。

In the run configuration in GoLand, set "Working directory" to the main package directory.在 GoLand 的运行配置中,将“工作目录”设置为主 package 目录。 Then set the script to a new batch file.然后将脚本设置为新的批处理文件。

Here is the code in my batch file for my package client这是我的 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.运行此配置将构建 package,然后在新的外部 cmd window 中运行程序,其中单元格正确显示。

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.这个解决方案不是很好,因为 GoLand 运行配置系统的大部分优势都丢失了,包括调试、进程管理(停止/重启)和其他构建选项。

Does anyone have a better solution?有没有人有更好的解决方案?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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