如何实现“文本编辑器”使用 c 在终端上设计界面
我还没有尝试制作文本编辑器。我现在想做的事情更简单。它将是一个命令行工具(Linux 或 Windows)。当您执行它时,用户将看到一个清除的终端区域,就像您尝试使用 vi 创建一个新文件一样。
然后用户可以输入一些预定义的命令。问题:如何定义用户输入的位置?就像终端屏幕底部的 vi 所做的那样?
根据用户输入的命令,一些信息或图形将显示/绘制在屏幕上。
用户可以随时输入命令,结果会立即输出。
对我来说困难在于如何实现这样的输入/输出接口。有什么不清楚的可以评论。
I'm not trying to make a text editor yet. What I want to do now is simpler. It will be a command line tool (either Linux or windows). When you execute it, the user shall see a cleared terminal area, like you try to create a new file using vi.
The user can then type in some pre-defined command. Question: how to define where the user inputs? Say like what vi does, at the bottom of the terminal screen?
According to the command the user typed in, some info or figure will be shown/drawn on the screen.
The user can type in command at any time, the result will be output immediately.
The difficulty for me is how to implement such an input/output interface. Comment if there is anything not clear.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
C 标准“本身”没有为此任务定义任何内容,就其而言,终端“就像一个文件”——两个(三个计数 stderr)数据流,仅此而已。
要以更高级的方式使用终端,您必须使用特定于平台的方法,例如 ioctl 调用< /a> 或 VT* 转义序列。但更可能的是,您最好使用一个更高级别的库来处理所有低级别的麻烦,并让您专注于更重要的事情,经典的库是 ncurses.
The C standard "per se" doesn't define anything for this task, for what it is concerned the terminal is "just like a file" - two (three counting stderr) streams of data, that's it.
To use the terminal in a more advanced way you have to use platform-specific methods, be them ioctl calls or VT* escape sequences. But more probably you'd better use a higher level library that handles all the low-level fuss and lets you focus on more important stuff, the classical one is ncurses.