diff options
author | tv <tv@shackspace.de> | 2015-03-05 15:40:39 +0100 |
---|---|---|
committer | tv <tv@shackspace.de> | 2015-03-05 15:40:39 +0100 |
commit | d42e50abac78352cee37df0c42b967aff9d68f7c (patch) | |
tree | 6716e00674a59855b2c1d4c28720abe8ce8e5a43 | |
parent | 7b9f243320cfe33ddb4f89be81483dd775cc49b0 (diff) |
test5: wrap lines with '='
-rw-r--r-- | env.nix | 1 | ||||
-rw-r--r-- | much.cabal | 2 | ||||
-rw-r--r-- | test5.hs | 34 |
3 files changed, 37 insertions, 0 deletions
@@ -24,6 +24,7 @@ let email-header friendly-time hsemail + linebreak mbox mime-mail # because modified showAddress multipart @@ -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 @@ -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 |