Adding a ":clear" clear-screen command to GHCi
I have written a (hopeful) patch for this. I say hopeful because I'm not sure if it even compiles (I don't have the space to compile GHC at the moment...).
Anyway if this could be confirmed to work and then incorporated that would be nice :)
@@ -119,6 +119,7 @@
("browse!", keepGoing (browseCmd True), Nothing, completeModule),
("cd", keepGoing changeDirectory, Just filenameWordBreakChars, completeFilename),
("check", keepGoing checkModule, Nothing, completeHomeModule),
+ ("clear", keepGoing clearScreen, Nothing, completeNone),
("continue", keepGoing continueCmd, Nothing, completeNone),
("cmd", keepGoing cmdCmd, Nothing, completeIdentifier),
("ctags", keepGoing createCTagsFileCmd, Just filenameWordBreakChars, completeFilename),
@@ -200,6 +201,7 @@
" :browse[!] [[*]<mod>] display the names defined by module <mod>\n" ++
" (!: more details; *: all top-level names)\n" ++
" :cd <dir> change directory to <dir>\n" ++
+ " :clear clear the screen\n" ++
" :cmd <expr> run the commands returned by <expr>::IO String\n" ++
" :ctags [<file>] create tags file for Vi (default: \"tags\")\n" ++
" :def <cmd> <expr> define a command :<cmd>\n" ++
@@ -936,6 +938,15 @@
prev_context <- GHC.getContext
ok <- trySuccess $ GHC.load LoadAllTargets
afterLoad ok False prev_context
+
+clearScreen :: String -> GHCi ()
+clearScreen _ = do
+ let cmd = case os of
+ "windows" -> Just "cls"
+ "linux" -> Just "clear"
+ _ -> Nothing
+ didnt_work <- maybe (return True) shellEscape cmd
+ when didnt_work (io (putStrLn ("Error: unsupported operating system for command 'clear'. Please report a bug.")))
changeDirectory :: String -> GHCi ()
changeDirectory "" = do
Trac metadata
Trac field | Value |
---|---|
Version | 6.11 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | GHCi |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |