Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 44 lines (32 sloc) 0.762 kB
13104d3 @michaelfeathers first commit
authored
1
2
3 module Rendering
4 ( render
5 , cls
6 , goto
7 , home
8 , commandHome
9 , writeAt
10 )
11 where
12
13 import EditBuffer
14 import IO
15
16 yExtent :: Int
17 yExtent = 40
18
19 home :: Location
20 home = (0,0)
21
22 commandHome :: Location
23 commandHome = (0, yExtent + 1)
24
25 cls :: IO ()
26 cls = putStr "\ESC[2J"
27
91a14d4 @michaelfeathers Added autoscrolling via frame function on EditBuffer
authored
28 render :: EditBuffer -> IO ()
29 render (EditBuffer topLine (x,y) contents) = do
30 writeAt home $ window screenLines
31 goto (x, y - topLine)
32 where window = unlines . take yExtent . drop topLine
33 screenLines = (lines contents) ++ (repeat "~")
13104d3 @michaelfeathers first commit
authored
34
35 goto :: Location -> IO ()
36 goto (x,y) =
37 putStr ("\ESC[" ++ show (y + 1) ++ "; " ++ show (x + 1) ++ "H")
38
39 writeAt :: Location -> String -> IO ()
40 writeAt location xs = do
41 goto location
42 putStr xs
43
Something went wrong with that request. Please try again.