packages feed

hspresent (empty) → 0.1

raw patch · 5 files changed

+128/−0 lines, 5 filesdep +basedep +bytestringdep +vtysetup-changed

Dependencies added: base, bytestring, vty

Files

+ LICENSE view
@@ -0,0 +1,13 @@+Copyright 2009, Evan Klitzke <evan@eklitzke.org>++Permission to use, copy, modify, and/or distribute this software for any+purpose with or without fee is hereby granted, provided that the above+copyright notice and this permission notice appear in all copies.++THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ Main.hs view
@@ -0,0 +1,62 @@+import System.Environment+import System.Exit+import System.IO++import Data.ByteString.Char8 (pack)+import Graphics.Vty++-- |Split an input list+split :: Eq a => [a] -> [[a]] -> [[[a]]]+split _ [] = [[]]+split tok (x:xs)+      | tok == x  = [] : split tok xs+      | otherwise = let (x':xs') = split tok xs in (x:x') : xs'++-- |Render a string as an Image, and right pad it with some character.+bsLine :: String -> Char -> Int -> Image+bsLine txt fill width = renderBS attr $ pack txt'+    where+      txt' = ' ' : txt ++ (replicate (width - length txt - 2) fill)++-- |Take a Vty and a list of frames, and do the presentation; this function+-- terminates when q or Ctrl-C are entered.+loop :: Vty -> [[String]] -> IO ()+loop vty frames = loop' 0+    where+      maxframe = length frames - 1+      formatText w [] = empty+      formatText w (x:xs) = (bsLine x ' ' w) <-> (formatText w xs)+      loop' n = do+        let (title:text) = frames !! n+        (w, h) <- getSize vty+        let im = bsLine title ' ' w <->+                 bsLine "" '-' w <->+                 formatText w text+        update vty (pic { pCursor = NoCursor,+                          pImage = im })+        ev <- getEvent vty+        case ev of+          EvKey KLeft _  -> loop' (max 0 (n-1))+          EvKey KRight _ -> loop' (min maxframe (n+1))+          EvKey (KASCII 'q') _       -> return ()+          EvKey (KASCII 'c') [MCtrl] -> return ()+          _              -> loop' n++main = do+  args <- getArgs+  presentation <- parse args+  h <- openFile presentation ReadMode+  frames <- fmap makeFrames $ hGetContents h+  vty <- mkVty+  refresh vty+  loop vty frames+  shutdown vty+  where+    makeFrames s = split "--" $ lines s++    parse ["-h"] = usage+    parse [x]    = return x+    parse _      = usage++    usage = putStrLn "Usage: hspresent [-h] <presentation>" >> exit+    exit = exitWith ExitSuccess
+ README.md view
@@ -0,0 +1,29 @@+Presenting hspresent+====================++This is a simple program that lets you give powerpoint-like presentations in+your terminal (for certain definitions of powerpoint-like). It's extremely basic+and unintelligent. Don't expect much.++Compile and install using cabal:+    cabal build && cabal install++This will compile hspresent, and install an `hspresent` command line program.++Usage+-----+Invoke like `hspresent /path/to/your/presentation`. Left and right arrow keys+move between slides, and hitting `q` or `Ctrl-C` quits the presentation.++The file format is really simple right now. Slides are separated by lines+consisting of the characters `--`. That's it. Here's an example presentation:+    the title of the first slide+    this is+    really cool+    --+    the title of the second slide+    hooray for hspresent+    --+    look at how fancy the title to this slide is+    * bullet point one+    * bullet point two
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ hspresent.cabal view
@@ -0,0 +1,22 @@+Author:        Evan Klitzke+Maintainer:    Evan Klitzke <evan@eklitzke.org>+Name:          hspresent+Version:       0.1+Cabal-Version: >= 1.2+License:       BSD3+License-File:  LICENSE+Category:      Console+Copyright:     (c) 2009 by Evan Klitzke+Synopsis:      A terminal presentation tool+Description:+  Give fancy presentations in your terminal.+ +Build-Type: Simple++Executable hspresent+  Main-Is: Main.hs++Library+  Build-Depends: base < 5+               , bytestring+               , vty