続くかどうかも分かんないで、とりあえず gist にアップ。
もうちょいなんかやんかなってきたら github に移すかもしらんっすー。
System.Console.ANSI がない言われた場合は http://alphaneet.hatenablog.com/entry/2012/01/23/022059 ここらへんを参考にしてくだしあ。
Created
January 23, 2012 16:45
-
-
Save alphaneet/1664182 to your computer and use it in GitHub Desktop.
haskellでコンソールチャットを作るお!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import System.IO | |
import System.Console.ANSI | |
type Log = [String] | |
main = do | |
hSetBuffering stdout NoBuffering | |
chat [] | |
chat :: Log -> IO() | |
chat log = do | |
clearScreen | |
setCursorPosition 0 0 | |
putStr (foldl (\x y -> x ++ y ++ "\n") "" log) | |
setCursorPosition 10 0 | |
putStr "> " | |
text <- getLine | |
chat (text : log) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment