mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-09 00:11:52 -07:00
Allow to limit maximum row count in X.Prompt completion window
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.
This commit is contained in:
@@ -134,6 +134,8 @@ data XPConfig =
|
|||||||
, position :: XPPosition -- ^ Position: 'Top' or 'Bottom'
|
, 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.
|
, alwaysHighlight :: !Bool -- ^ Always highlight an item, overriden to True with multiple modes. This implies having *one* column of autocompletions only.
|
||||||
, height :: !Dimension -- ^ Window height
|
, 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
|
, historySize :: !Int -- ^ The number of history entries to be saved
|
||||||
, historyFilter :: [String] -> [String]
|
, historyFilter :: [String] -> [String]
|
||||||
-- ^ a filter to determine which
|
-- ^ a filter to determine which
|
||||||
@@ -241,6 +243,7 @@ defaultXPConfig =
|
|||||||
, changeModeKey = xK_grave
|
, changeModeKey = xK_grave
|
||||||
, position = Bottom
|
, position = Bottom
|
||||||
, height = 18
|
, height = 18
|
||||||
|
, maxComplRows = Nothing
|
||||||
, historySize = 256
|
, historySize = 256
|
||||||
, historyFilter = id
|
, historyFilter = id
|
||||||
, defaultText = []
|
, defaultText = []
|
||||||
@@ -933,7 +936,10 @@ getComplWinDim compl = do
|
|||||||
rem_height = rect_height scr - ht
|
rem_height = rect_height scr - ht
|
||||||
(rows,r) = length compl `divMod` fi columns
|
(rows,r) = length compl `divMod` fi columns
|
||||||
needed_rows = max 1 (rows + if r == 0 then 0 else 1)
|
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_rows = min actual_max_number_of_rows (fi needed_rows)
|
||||||
actual_height = actual_rows * ht
|
actual_height = actual_rows * ht
|
||||||
(x,y) = case position c of
|
(x,y) = case position c of
|
||||||
|
Reference in New Issue
Block a user