输入命令的控制台
我想为我的应用程序制作一些调试控制台。它应该输出一些数据并接受输入命令。我该怎么做?最好的方法是更新控制台,例如:绘制信息并在数据后提示输入。 我是在Linux下开发的。例如,gdb 可以从控制台获取输入。
I want to make some debug console for my application. It should output some data and take input commands. How can I do this? The best way is updating console like: drawing information and prompt for input after the data.
I'm developing under Linux. For example, gdb could take input from console.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您熟悉套接字编程(或者实际上任何其他类型的 IPC 机制),您可能希望在应用程序中启用一些侦听器,并开发一个外部应用程序,该应用程序将在通信时为您完成所有“控制台”工作与主要应用程序。
假设您有一个具有单个按钮和单个文本标签的应用程序,每次按下该按钮时,文本标签都会增加 1,从 1 到 2 到 3 等。
您可以在该应用程序中构建一个套接字侦听器。当套接字侦听器接受新的传入连接时,您将启动一个连接线程,该连接线程可以:
。然后您构建另一个,外部应用程序,连接到主应用程序,并根据从用户那里获得的控制台输入向其发送消息。它还会监听传入的更新并将其显示给用户。
使用外部应用程序来调试控制您的主应用程序非常有帮助,其优点如下:
If you're familiar with socket programming (or actually, any other kind of IPC mechanism), you might want to enable some listener within your application, and develop an external application that will do all the "console" stuff for you, while communicating with the main application.
Let's suppose you have an application that has a single button and a single text label, and every time you press that button - the text label goes up by 1, from 1 to 2 to 3 etc.
You can build a socket listener into that application. When the socket listener accepts a new incoming connection, you'd start a connection thread that can:
Then you build another, external application, which connects to the main application, and sends messages to it, based on console input it gets from the user. It would also listen to incoming updates and show them to the user.
Using an external application for debug-controlling your main application is extremely helpful, with the following reasons being some of the advantages: