如何清除 Haskell 中的终端屏幕?

发布于 2024-08-25 15:38:42 字数 32 浏览 3 评论 0原文

用户从应用程序菜单中选择选项后,如何清除终端屏幕?

How can I clear a terminal screen after my user has selected an option from my application's menu?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

酒绊 2024-09-01 15:38:42

:! 运行 shell 命令
<强>:! windows下的cls
<强>:! Linux 和 OS X 下清晰

:! run the shell command
:! cls under windows
:! clear under linux and OS X

枯寂 2024-09-01 15:38:42

这就是您可能正在寻找的内容:

ansi-terminal: 简单的 ANSI 终端支持,与 Windows 兼容

You can find it in Hackage and install using cabal install ansi-terminal. It specifically has functions for clearing the screen, displaying colors, moving the cursor, etc.

使用它来清除屏幕很容易:(这是使用 GHCI)

import System.Console。 ANSI

clearScreen

This is what you may be looking for:

ansi-terminal: Simple ANSI terminal support, with Windows compatibility

You can find it in Hackage and install using cabal install ansi-terminal. It specifically has functions for clearing the screen, displaying colors, moving the cursor, etc.

Using it to clear the screen is easy: (this is with GHCI)

import System.Console.ANSI

clearScreen

送舟行 2024-09-01 15:38:42

只需按 Ctrl+L(适用于 Windows)

Just press Ctrl+L (works on Windows)

水中月 2024-09-01 15:38:42

在理解 ANSI 转义序列(我相信 Unix/Linux 系统中的每个术语)的终端上,您可以简单地执行以下操作:

clear = putStr "\ESC[2J"

2 清除整个屏幕。如果要清除从光标到屏幕末尾或从光标到屏幕开头,可以分别使用 01

但我认为这在 Windows shell 中不起作用。

On a terminal that understands ANSI escape sequences (I believe every term in Unix/Linux systems) you can do it simply with:

clear = putStr "\ESC[2J"

The 2 clears the entire screen. You can use 0 or 1 respectively if you want to clear from the cursor to end of screen or from cursor to the beginning of the screen.

However I don't think this works in the Windows shell.

陪你到最终 2024-09-01 15:38:42

在 Windows 上,使用 Ctrl + L 作为 Haskell 命令提示符终端。并且,对于 GUI,请使用 Ctrl + S

On Windows, use Ctrl + L for Haskell command prompt terminal. And, for GUI use Ctrl + S.

蓝天白云 2024-09-01 15:38:42

在 Unix 系统上,您可以执行 System.system "clear" ,它只会调用命令行实用程序clear。对于不依赖于外部工具的解决方案,您需要一个抽象不同终端类型的库,例如 ansi 终端

On Unix systems you can do System.system "clear" which just invokes the command-line utility clear. For a solution that does not depend on external tools, you'd need a library that abstracts over different terminal-types like for example ansi-terminal.

你又不是我 2024-09-01 15:38:42

Windows 上的一种快速方法是

import System.Process

clear :: IO ()
clear = system "cls"

A quick way on Windows would be to

import System.Process

clear :: IO ()
clear = system "cls"
帝王念 2024-09-01 15:38:42

在 Linux 下(至少 Ubuntu),这是我用来清除终端的代码:

import qualified System.Process as SP

clearScreen :: IO ()
clearScreen = do
  _ <- SP.system "reset"
  return ()

Under Linux (Ubuntu at least), that's the code I use for clearing the terminal:

import qualified System.Process as SP

clearScreen :: IO ()
clearScreen = do
  _ <- SP.system "reset"
  return ()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文