我正在项目中执行ssh函数。 (使用https://pub.dartlang.org/packages/ssh),现在会话已与xterm连接,可以预期使用cmd,并且ssh服务器的结果将显示在Text小部件中,该小部件的字符串将类似于'[0m ... [0m ',如果我将结果打印到控制台(print(result))中,它将以指定的颜色正确显示,那么如何模拟一个可在我的应用程序中正确显示结果的shell窗口?
Output in console which I want to emulate in my app
答案 0 :(得分:0)
好吧,您看到的奇怪的[0
是ANSI转义码。这些代码告诉终端,字符串的某个部分需要获得颜色。您可以在这里找到颜色列表:https://en.wikipedia.org/wiki/ANSI_escape_code#Colors。
然后,当您获得该信息时,将需要一些工具来为TextField
的各个部分设置样式。在Flutter中,您可以使用RichText
类:https://docs.flutter.io/flutter/widgets/RichText-class.html。我的建议是查找并替换显示的文本。
参考文献: