How to clear the Terminal screen in Swift?

前端 未结 5 1732
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-11 19:02

I am writing a BASIC Interpreter for the Command Line in Swift 2, and I cannot find a way to implement the simple command, CLS (clear all text from the Terminal.) Should I s

5条回答
  •  一生所求
    2020-12-11 19:40

    You can use the following ANSI sequence:

    print("\u{001B}[2J")
    

    ... where \u{001B} is ESCAPE and [2J is clear screen.

提交回复
热议问题