packages feed

yi-core 0.17.1 → 0.18.0

raw patch · 11 files changed

+94/−31 lines, 11 filesdep ~yi-language

Dependency ranges changed: yi-language

Files

src/Yi/CompletionTree.hs view
@@ -39,6 +39,7 @@ import           Data.ListLike       (ListLike) import           Lens.Micro.Platform (over, Lens', _2, (.~), (&)) import           Data.Binary         (Binary)+import           Data.Semigroup      (Semigroup)  -- | A CompletionTree is a map of partial completions. --@@ -60,7 +61,7 @@ -- (The empty strings are needed to denote the end of a word) -- (A CompletionTree is not limited to a binary tree) newtype CompletionTree a = CompletionTree {_unCompletionTree :: (Map a (CompletionTree a))}-  deriving (Monoid, Eq, Binary)+  deriving (Semigroup, Monoid, Eq, Binary)  unCompletionTree :: Lens' (CompletionTree a) (Map a (CompletionTree a)) unCompletionTree f ct = (\unCompletionTree' -> ct {_unCompletionTree = unCompletionTree'}) <$>
src/Yi/Config/Default.hs view
@@ -94,6 +94,7 @@            , configAutoHideTabBar = True            , configWindowFill = ' '            , configTheme = defaultTheme+           , configLineNumbers = False            }          , defaultKm        = modelessKeymapSet nilKeymap          , startActions     = mempty
src/Yi/Config/Simple.hs view
@@ -77,6 +77,7 @@   lineWrap,   windowFill,   theme,+  lineNumbers,   -- ** Layout   layoutManagers,   -- * Debugging@@ -147,7 +148,7 @@                            CursorStyle(..), configLeftSideScrollBarA,                            configAutoHideScrollBarA, configAutoHideTabBarA,                            configLineWrapA, configWindowFillA, configThemeA,-                           layoutManagersA, configVarsA,+                           layoutManagersA, configVarsA, configLineNumbersA                            )  @@ -286,6 +287,10 @@ -- | UI colour theme. theme :: Field Theme theme = configUIA . configThemeA++-- | Line numbers.+lineNumbers :: Field Bool+lineNumbers = configUIA . configLineNumbersA  ---------- Layout -- | List of registered layout managers. When cycling through layouts,
src/Yi/Core.hs view
@@ -164,14 +164,13 @@ postActions :: IsRefreshNeeded -> [Action] -> YiM () postActions refreshNeeded actions = do yi <- ask; liftBase $ yiOutput yi refreshNeeded actions --- | Display the errors buffer if it is not already visible.+-- | Display the errors buffer in a new split window if it exists. showErrors :: YiM () showErrors = withEditor $ do-               bs <- gets $ findBufferWithName "*errors*"-               case bs of-                 [] -> return ()-                 _  -> do splitE-                          switchToBufferWithNameE "*errors*"+               bs <- gets $ doesBufferNameExist "*errors*"+               when bs $ do +                 splitE+                 switchToBufferWithNameE "*errors*"  -- | Process events by advancing the current keymap automaton and -- executing the generated actions.
src/Yi/Editor.hs view
@@ -33,6 +33,7 @@                  , currentWindowA                  , deleteBuffer                  , deleteTabE+                 , doesBufferNameExist                  , emptyEditor                  , findBuffer                  , findBufferWith@@ -128,7 +129,7 @@ import qualified Data.Monoid                    as Mon ((<>)) import           Data.Semigroup                 ((<>)) import qualified Data.Sequence                  as S-import qualified Data.Text                      as T (Text, null, pack, unlines, unpack, unwords)+import qualified Data.Text                      as T (Text, null, pack, unlines, unpack, unwords, isInfixOf) import           System.FilePath                (splitPath) import           Yi.Buffer import           Yi.Config@@ -335,16 +336,21 @@ findBufferWithName :: T.Text -> Editor -> [BufferRef] findBufferWithName n e =   let bufs = M.elems $ buffers e-      sameIdent b = shortIdentString (length $ commonNamePrefix e) b == n-  in map bkey $ filter sameIdent bufs+      hasInfix b = n `T.isInfixOf` identString b+  in map bkey $ filter hasInfix bufs +doesBufferNameExist :: T.Text -> Editor -> Bool+doesBufferNameExist n e =+  not $ null $ filter ((== n) . identString) $ M.elems $ buffers e+ -- | Find buffer with given name. Fail if not found. getBufferWithName :: MonadEditor m => T.Text -> m BufferRef getBufferWithName bufName = withEditor $ do   bs <- gets $ findBufferWithName bufName   case bs of     [] -> fail ("Buffer not found: " ++ T.unpack bufName)-    b:_ -> return b+    [b] -> return b+    _ -> fail ("Ambiguous buffer name: " ++ T.unpack bufName)  ------------------------------------------------------------------------ -- | Perform action with any given buffer, using the last window that@@ -804,9 +810,9 @@   e <- gets id   -- increment the index of the hint until no buffer is found with that name   let find_next currentName (nextName:otherNames) =-          case findBufferWithName currentName e of-            (_b : _) -> find_next nextName otherNames-            []      -> currentName+          if doesBufferNameExist currentName e+            then find_next nextName otherNames+            else currentName       find_next _ [] = error "Looks like nearly infinite list has just ended."       next_tmp_name = find_next name names       (name : names) = (fmap (("tmp-" Mon.<>) . T.pack . show) [0 :: Int ..])
src/Yi/Eval.hs view
@@ -49,7 +49,8 @@ import Data.Foldable ( mapM_ ) import qualified Data.HashMap.Strict as M     ( HashMap, insert, lookup, empty, keys )-import Data.Monoid ( (<>) )+import Data.Monoid ((<>))+import Data.Semigroup ( Semigroup ) import Data.Typeable ( Typeable ) #ifdef HINT import Control.Concurrent@@ -307,7 +308,7 @@  newtype PublishedActions = PublishedActions {     _publishedActions :: M.HashMap String Action-  } deriving(Typeable, Monoid)+  } deriving(Typeable, Semigroup, Monoid)  instance Default PublishedActions where def = mempty 
src/Yi/Interact.hs view
@@ -1,9 +1,11 @@-{-# LANGUAGE FlexibleInstances      #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE GADTs                  #-}-{-# LANGUAGE OverloadedStrings      #-}-{-# LANGUAGE ScopedTypeVariables    #-}-{-# LANGUAGE UndecidableInstances   #-}+{-# LANGUAGE FlexibleInstances          #-}+{-# LANGUAGE FunctionalDependencies     #-}+{-# LANGUAGE GADTs                      #-}+{-# LANGUAGE OverloadedStrings          #-}+{-# LANGUAGE ScopedTypeVariables        #-}+{-# LANGUAGE UndecidableInstances       #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE CPP                        #-} {-# OPTIONS_HADDOCK show-extensions #-}  {-|@@ -221,6 +223,11 @@  -- | Abstraction of the automaton state. data InteractState event w =  Ambiguous [(Int,w,P event w)] | Waiting | Dead | Running w (P event w)++#if __GLASGOW_HASKELL__ >= 804 +instance Semigroup (InteractState event w) where+  (<>) = mappend+#endif  instance Monoid (InteractState event w) where     -- not used at the moment:
src/Yi/Paths.hs view
@@ -4,7 +4,6 @@ module Yi.Paths ( getEvaluatorContextFilename                 , getConfigFilename                 , getConfigModules-                , getArticleDbFilename                 , getPersistentStateFilename                 , getConfigDir                 , getConfigPath@@ -58,15 +57,12 @@  -- Below are all points that are used in Yi code (to keep it clean.) getEvaluatorContextFilename, getConfigFilename, getConfigModules,-    getArticleDbFilename, getPersistentStateFilename :: (MonadBase IO m) => m FilePath+    getPersistentStateFilename :: (MonadBase IO m) => m FilePath  -- | Get Yi master configuration script. getConfigFilename = getConfigPath "yi.hs"  getConfigModules = getConfigPath "modules"---- | Get articles.db database of locations to visit (for Yi.IReader.)-getArticleDbFilename = getConfigPath "articles.db"  -- | Get path to Yi history that stores state between runs. getPersistentStateFilename = getDataPath "history"
src/Yi/Types.hs view
@@ -394,7 +394,8 @@    configWindowFill :: Char,    -- ^ The char with which to fill empty window space.  Usually '~' for vi-like    -- editors, ' ' for everything else.-   configTheme :: Theme             -- ^ UI colours+   configTheme :: Theme,            -- ^ UI colours+   configLineNumbers :: Bool        -- ^ Should we show line numbers by default?   }  
+ src/Yi/UI/LineNumbers.hs view
@@ -0,0 +1,45 @@+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE DeriveGeneric      #-}+{-# OPTIONS_HADDOCK show-extensions #-}++-- |+-- Module      :  Yi.UI.LineNumbers+-- License     :  GPL-2+-- Maintainer  :  yi-devel@googlegroups.com+-- Stability   :  experimental+-- Portability :  portable+--+-- Line numbers.++module Yi.UI.LineNumbers+  ( getDisplayLineNumbersLocal+  , setDisplayLineNumbersLocal+  ) where++import           Data.Binary    (Binary (..))+import           Data.Default   (Default (..))+import           Data.Typeable  (Typeable)+import           GHC.Generics   (Generic)+import           Yi.Buffer      (getBufferDyn, putBufferDyn)+import           Yi.Types       (BufferM, YiVariable)++newtype DisplayLineNumbersLocal = DisplayLineNumbersLocal { unDisplayLineNumbersLocal :: Maybe Bool }+  deriving (Generic, Typeable)++instance Default DisplayLineNumbersLocal where+  def = DisplayLineNumbersLocal Nothing++instance Binary DisplayLineNumbersLocal++instance YiVariable DisplayLineNumbersLocal++-- | Get the buffer-local line number setting.+getDisplayLineNumbersLocal :: BufferM (Maybe Bool)+getDisplayLineNumbersLocal = unDisplayLineNumbersLocal <$> getBufferDyn++-- | Set the buffer-local line number setting.+-- Nothing: use global setting+-- Just True: display line numbers only in this buffer+-- Just False: hide line numbers only in this buffer+setDisplayLineNumbersLocal :: Maybe Bool -> BufferM ()+setDisplayLineNumbersLocal = putBufferDyn . DisplayLineNumbersLocal
yi-core.cabal view
@@ -1,5 +1,5 @@ name:           yi-core-version:        0.17.1+version:        0.18.0 synopsis:       Yi editor core library category:       Yi homepage:       https://github.com/yi-editor/yi#readme@@ -51,7 +51,7 @@     , unix-compat >= 0.1     , unordered-containers >= 0.1.3     , xdg-basedir >= 0.2.1-    , yi-language >= 0.17+    , yi-language >= 0.18     , yi-rope >= 0.10     , exceptions   if flag(hint)@@ -123,6 +123,7 @@       Yi.TextCompletion       Yi.Types       Yi.UI.Common+      Yi.UI.LineNumbers       Yi.UI.SimpleLayout       Yi.UI.TabBar       Yi.UI.Utils