From d42e50abac78352cee37df0c42b967aff9d68f7c Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 5 Mar 2015 15:40:39 +0100 Subject: test5: wrap lines with '=' --- env.nix | 1 + much.cabal | 2 ++ test5.hs | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) 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 -- cgit v1.2.3