summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2015-03-05 15:40:39 +0100
committertv <tv@shackspace.de>2015-03-05 15:40:39 +0100
commitd42e50abac78352cee37df0c42b967aff9d68f7c (patch)
tree6716e00674a59855b2c1d4c28720abe8ce8e5a43
parent7b9f243320cfe33ddb4f89be81483dd775cc49b0 (diff)
test5: wrap lines with '='
-rw-r--r--env.nix1
-rw-r--r--much.cabal2
-rw-r--r--test5.hs34
3 files changed, 37 insertions, 0 deletions
diff --git a/env.nix b/env.nix
index a79a05d..62bce8f 100644
--- a/env.nix
+++ b/env.nix
@@ -24,6 +24,7 @@ let
email-header
friendly-time
hsemail
+ linebreak
mbox
mime-mail # because modified showAddress
multipart
diff --git a/much.cabal b/much.cabal
index 48e95a9..0671c6e 100644
--- a/much.cabal
+++ b/much.cabal
@@ -19,6 +19,8 @@ executable much
, docopt >=0.6 && <0.7
, email-header
, friendly-time >=0.3 && <0.4
+ , hyphenation >=0.4 && < 0.5
+ , linebreak >=1.0 && <1.1
, mime-mail
, old-locale
, process >=1.2 && <1.3
diff --git a/test5.hs b/test5.hs
index 7d9c3f4..500b1c2 100644
--- a/test5.hs
+++ b/test5.hs
@@ -40,6 +40,8 @@ import System.Posix.Files
import System.Posix.Signals
import System.Process
import TagUtils
+import Text.Hyphenation
+import Text.LineBreak
import Trammel
import TreeSearch
import TreeView
@@ -264,6 +266,38 @@ keymap "\ESC[Z" = moveCursorUpToPrevUnread -- S-Tab
keymap "\t" = moveCursorDownToNextUnread
keymap "\DEL" = moveToParent -- backspace
+-- TODO wrap/unwrap to separate module
+keymap "=" = \q@State{..} ->
+ let cursor' = case Z.label cursor of
+ TVMessageLine a b c s ->
+ wrap (TVMessageLine a b c) cursor s
+ _ -> cursor
+ in return q { cursor = cursor' }
+ where
+
+ --unwrap = error "WIP"
+ -- 1. get current id (must be TVMessageLine)
+ -- 2. find first adjoined TVMessageLine with same id
+ -- 3. find last adjoined TVMessageLine with same id
+ -- 4. join lines (with space?)
+
+ wrap ctor loc s =
+ fromMaybe (error "die hard") $
+ Z.nextTree $
+ foldr (insert . ctor)
+ (Z.delete loc)
+ $ hy s
+
+ insert a =
+ Z.prevSpace . Z.insert (Tree.Node a [])
+
+ hy s =
+ breakStringLn bf s
+ where
+ shy = '\173'
+ hyp = Just german_1996
+ bf = BreakFormat 80 8 shy hyp
+
keymap "\ESCq" = \q@State{..} ->
let parse = filter (/='\n') -- TODO proper parse
draft = fromMaybe "" $ getSearchTerm $ Z.label $ Z.root cursor