packages feed

vty-ui-extras (empty) → 0.1

raw patch · 4 files changed

+100/−0 lines, 4 filesdep +basedep +regex-basedep +regex-pcresetup-changed

Dependencies added: base, regex-base, regex-pcre, vty, vty-ui

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2009-2011, Jonathan Daugherty.+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are+met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * The names of the contributors may not be used to endorse or+      promote products derived from this software without specific+      prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Graphics/Vty/Widgets/Extras/Text.hs view
@@ -0,0 +1,35 @@+{-# LANGUAGE FlexibleContexts #-}+module Graphics.Vty.Widgets.Extras.Text+    ( highlight+    )+where++import Text.Regex.Base (RegexLike, matchAll)++import Graphics.Vty.Widgets.Text (Formatter(..))+import Graphics.Vty (Attr, def_attr)+import Text.Trans.Tokenize (TextStreamEntity(..), Token(..), TextStream(..))++-- |A highlight formatter takes a regular expression used to scan the+-- text and an attribute to assign to matches.  The regular expression+-- is only applied to individual string tokens (individual words,+-- whitespace strings, etc.); it is NOT applied to whole lines,+-- paragraphs, or text spanning multiple lines.  If you have need of+-- that kind of functionality, apply your own attributes with your own+-- regular expression prior to calling 'setTextWithAttrs'.+highlight :: (RegexLike r String) => r -> Attr -> Formatter+highlight regex attr = Formatter $+    \_ (TS ts) -> return $ TS $ map highlightToken ts+        where+          highlightToken :: TextStreamEntity Attr -> TextStreamEntity Attr+          highlightToken NL = NL+          highlightToken (T t) =+              if tokenAttr t /= def_attr+              then T t+              else T (highlightToken' t)++          highlightToken' :: Token Attr -> Token Attr+          highlightToken' t =+              if null $ matchAll regex $ tokenStr t+              then t+              else t { tokenAttr = attr }
+ vty-ui-extras.cabal view
@@ -0,0 +1,33 @@+Name:                vty-ui-extras+Version:             0.1+Synopsis:+  Extra vty-ui functionality not included in the core library++Description:+  Extra vty-ui functionality not included in the core library++Category:            User Interfaces+Author:              Jonathan Daugherty <jtd@galois.com>+Maintainer:          Jonathan Daugherty <jtd@galois.com>+Build-Type:          Simple+License:             BSD3+License-File:        LICENSE+Cabal-Version:       >= 1.6++Source-Repository head+  type:     git+  location: git://github.com/jtdaugherty/vty-ui-extras.git++Library+  Build-Depends:+    base >= 4 && < 5,+    vty >= 4.6 && < 4.8,+    vty-ui >= 1.4 && < 1.5,+    regex-pcre >= 0.94 && < 0.95,+    regex-base >= 0.93 && < 0.94++  GHC-Options:       -Wall++  Hs-Source-Dirs:    src+  Exposed-Modules:+      Graphics.Vty.Widgets.Extras.Text