From e41c1f20671f5ffd5375d43b9ebdce0d5bad5d74 Mon Sep 17 00:00:00 2001 From: Paul Fertser Date: Thu, 21 Feb 2013 13:20:50 +0100 Subject: Allow to limit maximum row count in X.Prompt completion window Ignore-this: 923656f02996f2de2b1336275392c5f9 On a keyboard-less device (such as a smartphone), where one has to use an on-screen keyboard, the maximum completion window height must be limited to avoid overlapping the keyboard. darcs-hash:20130221122050-52607-7d086c3f11ba83887e11c26b4fd41dd1ab4c77aa.gz --- XMonad/Prompt.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'XMonad') diff --git a/XMonad/Prompt.hs b/XMonad/Prompt.hs index d6b44eb..e9613db 100644 --- a/XMonad/Prompt.hs +++ b/XMonad/Prompt.hs @@ -134,6 +134,8 @@ data XPConfig = , position :: XPPosition -- ^ Position: 'Top' or 'Bottom' , alwaysHighlight :: !Bool -- ^ Always highlight an item, overriden to True with multiple modes. This implies having *one* column of autocompletions only. , height :: !Dimension -- ^ Window height + , maxComplRows :: Maybe Dimension + -- ^ Just x: maximum number of rows to show in completion window , historySize :: !Int -- ^ The number of history entries to be saved , historyFilter :: [String] -> [String] -- ^ a filter to determine which @@ -241,6 +243,7 @@ defaultXPConfig = , changeModeKey = xK_grave , position = Bottom , height = 18 + , maxComplRows = Nothing , historySize = 256 , historyFilter = id , defaultText = [] @@ -933,7 +936,10 @@ getComplWinDim compl = do rem_height = rect_height scr - ht (rows,r) = length compl `divMod` fi columns needed_rows = max 1 (rows + if r == 0 then 0 else 1) - actual_max_number_of_rows = rem_height `div` ht + limit_max_number = case maxComplRows c of + Nothing -> id + Just m -> min m + actual_max_number_of_rows = limit_max_number $ rem_height `div` ht actual_rows = min actual_max_number_of_rows (fi needed_rows) actual_height = actual_rows * ht (x,y) = case position c of -- cgit v1.2.3