英文:
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语言中的printf
和scanf
函数族。控制屏幕缓冲区的复杂性比在终端输出中打印一些内容要复杂得多。
你所说的行为是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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论