-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Complete bindings to the dmenu and dmenu2 command line tools. -- -- Provides fuzzy selection via a GUI menu. @package dmenu @version 0.2.0.0 module DMenu.Lens makeLensesL :: Name -> DecsQ module DMenu -- | A state monad transformer in which the command line options of -- dmenu can be configured. type DMenuT = StateT Options -- | The MonadIO constraint additionally allows to spawn processes -- with System.Process in between. type MonadDMenu m = (MonadIO m, MonadState Options m) -- | When a spawned process fails, this type is used to represent the exit -- code and stderr output. type ProcessError = (Int, String) -- | Run a StateT Options m a action using the command line -- options from the config file or an empty set of options as initial -- state. -- -- For example -- --
-- import qualified DMenu -- -- main :: IO () -- main = DMenu.run $ do -- DMenu.numLines .= 10 -- DMenu.prompt .= "run" -- liftIO . print =<< DMenu.selectM ["A","B","C"] --run :: MonadIO m => DMenuT m a -> m a -- | Run DMenu with the command line options from m and a list of -- Strings from which the user should choose. selectM :: MonadDMenu m => [String] -> m (Either ProcessError String) -- | Convenience function combining run and selectM. -- -- The following example has the same behavior as the example for -- run: -- --
-- import qualified DMenu -- -- main :: IO () -- main = print =<< DMenu.select setOptions ["A","B","C"] -- -- setOptions :: DMenu.MonadDMenu m => m () -- setOptions = do -- DMenu.numLines .= 10 -- DMenu.prompt .= "run" --select :: MonadIO m => DMenuT m () -> [String] -> m (Either ProcessError String) -- | Same as selectM, but allows the user to select from a list of -- arbitrary elements, which have a String representation. selectWithM :: MonadDMenu m => (a -> String) -> [a] -> m (Either ProcessError a) -- | Same as select, but allows the user to select from a list of -- arbitrary elements, which have a String representation. -- -- For example -- --
-- import qualified DMenu -- -- main :: IO () -- main = print =<< DMenu.selectWith setOptions show [1..10::Int] -- -- setOptions :: DMenu.MonadDMenu m => m () -- setOptions = do -- DMenu.numLines .= 10 -- DMenu.prompt .= "run" --selectWith :: MonadIO m => DMenuT m () -> (a -> String) -> [a] -> m (Either ProcessError a) -- | Like selectM but uses the dmenu2 option -- filterMode, which returns not only the selected item, but all -- items which fuzzy match the input term. filterM :: MonadDMenu m => [String] -> m (Either ProcessError [String]) -- | Like select but uses the dmenu2 option -- filterMode, which returns not only the selected item, but all -- items which fuzzy match the input term. filter :: MonadIO m => DMenuT m () -> [String] -> m (Either ProcessError [String]) -- | Like selectWithM but uses the dmenu2 option -- filterMode, which returns not only the selected item, but all -- items which fuzzy match the input term. filterWithM :: MonadDMenu m => (a -> String) -> [a] -> m (Either ProcessError [a]) -- | Like selectWith but uses the dmenu2 option -- filterMode, which returns not only the selected item, but all -- items which fuzzy match the input term. filterWith :: MonadIO m => DMenuT m () -> (a -> String) -> [a] -> m (Either ProcessError [a]) -- | Contains the binary path and command line options of dmenu. The option -- descriptions are copied from the dmenu man page. data Options -- | Path to the the dmenu executable file. Default looks for -- dmenu in the PATH enviroment variable. binaryPath :: Lens' Options FilePath -- | -b; dmenu appears at the bottom of the screen. displayAtBottom :: Lens' Options Bool -- | -f; dmenu grabs the keyboard before reading stdin. This is -- faster, but will lock up X until stdin reaches end-of-file. grabKeyboardBeforeStdin :: Lens' Options Bool -- | -i; dmenu matches menu items case insensitively. caseInsensitive :: Lens' Options Bool -- | -m screen; dmenu is displayed on the monitor number supplied. -- Monitor numbers are starting from 0. spawnOnMonitor :: Lens' Options Int -- | -l lines; dmenu lists items vertically, with the given number -- of lines. numLines :: Lens' Options Int -- | -p prompt; defines the prompt to be displayed to the left of -- the input field. prompt :: Lens' Options String -- | -fn font; defines the font or font set used. eg. -- "fixed" or "Monospace-12:normal" (an xft font) font :: Lens' Options String -- | -nb color; defines the normal background color. -- #RGB, #RRGGBB, and X color names are supported. normalBGColor :: Lens' Options Color -- | -nf color; defines the normal foreground color. normalFGColor :: Lens' Options Color -- | -sb color; defines the selected background color. selectedBGColor :: Lens' Options Color -- | -sf color; defines the selected foreground color. selectedFGColor :: Lens' Options Color -- | -v; prints version information to stdout, then exits. printVersionAndExit :: Lens' Options Bool -- | Contains the command line options of dmenu2 which are not -- part of dmenu. The _filterMode option is not listed; -- it can be implicitly used by using DMenu.filter instead of -- DMenu.select. The option descriptions are copied from the -- dmenu2 man page. data Options2 -- | -q; dmenu will not show any items if the search string is -- empty. displayNoItemsIfEmpty :: Lens' Options2 Bool -- | -r; activates filter mode. All matching items currently shown -- in the list will be selected, starting with the item that is -- highlighted and wrapping around to the beginning of the list. -- (Note: Instead of setting this flag yourself, the -- dmenu filter functions can be used instead of the -- select functions.) filterMode :: Lens' Options2 Bool -- | -z; dmenu uses fuzzy matching. It matches items that have all -- characters entered, in sequence they are entered, but there may be any -- number of characters between matched characters. For example it takes -- "txt" makes it to "*t*x*t" glob pattern and checks -- if it matches. fuzzyMatching :: Lens' Options2 Bool -- | -t; dmenu uses space-separated tokens to match menu items. -- Using this overrides -z option. tokenMatching :: Lens' Options2 Bool -- | -mask; dmenu masks input with asterisk characters -- (*). maskInputWithStar :: Lens' Options2 Bool -- | -noinput; dmenu ignores input from stdin (equivalent to: -- echo | dmenu). ignoreStdin :: Lens' Options2 Bool -- | -s screen; dmenu apears on the specified screen number. -- Number given corespondes to screen number in X configuration. spawnOnScreen :: Lens' Options2 Int -- | -name name; defines window name for dmenu. Defaults to -- "dmenu". windowName :: Lens' Options2 String -- | -class class; defines window class for dmenu. Defaults to -- "Dmenu". windowClass :: Lens' Options2 String -- | -o opacity; defines window opacity for dmenu. Defaults to -- 1.0. windowOpacity :: Lens' Options2 Double -- | -dim opacity; enables screen dimming when dmenu appers. Takes -- dim opacity as argument. windowDimOpacity :: Lens' Options2 Double -- | -dc color; defines color of screen dimming. Active only when -- -dim in effect. Defautls to black (#000000) windowDimColor :: Lens' Options2 Color -- | -h height; defines the height of the bar in pixels. heightInPixels :: Lens' Options2 Int -- | -uh height; defines the height of the underline in pixels. underlineHeightInPixels :: Lens' Options2 Int -- | -x xoffset; defines the offset from the left border of the -- screen. windowOffsetX :: Lens' Options2 Int -- | -y yoffset; defines the offset from the top border of the -- screen. windowOffsetY :: Lens' Options2 Int -- | -w width; defines the desired menu window width. width :: Lens' Options2 Int -- | -uc color; defines the underline color. underlineColor :: Lens' Options2 Color -- | -hist histfile; the file to use for history historyFile :: Lens' Options2 FilePath -- | Multiple representations for colors. -- -- For example, green can be defined as -- --
-- green1 = HexColor 0x00FF00 -- green2 = RGBColor 0 255 0 -- green3 = RGBColorF 0 1 0 --data Color HexColor :: Int -> Color RGBColor :: Int -> Int -> Int -> Color RGBColorF :: Float -> Float -> Float -> Color -- | Replace the target of a Lens or all of the targets of a -- Setter or Traversal in our monadic state with a new -- value, irrespective of the old. -- -- This is an infix version of assign. -- --
-- >>> execState (do _1 .= c; _2 .= d) (a,b) -- (c,d) ---- --
-- >>> execState (both .= c) (a,b) -- (c,c) ---- --
-- (.=) :: MonadState s m => Iso' s a -> a -> m () -- (.=) :: MonadState s m => Lens' s a -> a -> m () -- (.=) :: MonadState s m => Traversal' s a -> a -> m () -- (.=) :: MonadState s m => Setter' s a -> a -> m () ---- -- It puts the state in the monad or it gets the hose again. (.=) :: MonadState s m => ASetter s s a b -> b -> m () infix 4 .=