how do I control where text is printed to console via fmt?

huangapple go评论81阅读模式
英文:

how do I control where text is printed to console via fmt?

问题

当在运行vim时,如果我输入:,输入光标会移动到屏幕的底部行,我可以输入一个命令,然后返回到屏幕的顶部。箭头键可以让我在屏幕上移动,诸如此类的操作。在Golang中,使用fmt包,我该如何做到这一点?

英文:

When running vim if I type : the input cursor goes to bottom row of the screen and I can type a command, then go back to the top of the screen. Arrow keys let me move around, all that jazz. In Golang using the fmt package how can I do this?

答案1

得分: 3

我觉得你有点困惑。fmt本质上等同于C语言中的printfscanf函数族。控制屏幕缓冲区的复杂性比在终端输出中打印一些内容要复杂得多。

你所说的行为是vim与ncurses库(或类似库)集成的结果。我从未使用过这个,但这里有一个使用cgo的ncurses包装器的链接,你可以像vim一样使用它。

英文:

I think you're kind of confused. What fmt is essentially equivalent to are C's printf and scanf family of functions. The complexity of controlling the screen buffer is quite a bit more complex than just printing some stuff in a terminal output.

The behavior you're talking about is a result of vim's integration with the ncurses library (or something similar to it). Haven't ever used this, but here's a link to an ncurses wrapper in cgo, which you could probably use to do something like vim does.

huangapple
  • 本文由 发表于 2016年8月3日 03:06:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/38728614.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定