mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
X.Prompt: Add maxComplColumns field to XPConfig
This allows limiting the number of columns in the completion window. The window width is divided equally between the columns.
This commit is contained in:
parent
fcbccc1df2
commit
577fd81450
@ -418,6 +418,9 @@
|
|||||||
- The prompt now cycles through its suggestions if one hits the ends
|
- The prompt now cycles through its suggestions if one hits the ends
|
||||||
of the suggestion list and presses `TAB` again.
|
of the suggestion list and presses `TAB` again.
|
||||||
|
|
||||||
|
- Added `maxComplColumns` field to `XPConfig`, to limit the number of
|
||||||
|
columns in the completion window.
|
||||||
|
|
||||||
* `XMonad.Actions.TreeSelect`
|
* `XMonad.Actions.TreeSelect`
|
||||||
|
|
||||||
- Fixed a crash when focusing a new window while the tree select
|
- Fixed a crash when focusing a new window while the tree select
|
||||||
|
@ -172,10 +172,12 @@ data XPConfig =
|
|||||||
, borderColor :: String -- ^ Border color
|
, borderColor :: String -- ^ Border color
|
||||||
, promptBorderWidth :: !Dimension -- ^ Border width
|
, promptBorderWidth :: !Dimension -- ^ Border width
|
||||||
, position :: XPPosition -- ^ Position: 'Top', 'Bottom', or 'CenteredAt'
|
, position :: XPPosition -- ^ Position: 'Top', 'Bottom', or 'CenteredAt'
|
||||||
, 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
|
||||||
, height :: !Dimension -- ^ Window height
|
, height :: !Dimension -- ^ Window height
|
||||||
, maxComplRows :: Maybe Dimension
|
, maxComplRows :: Maybe Dimension
|
||||||
-- ^ Just x: maximum number of rows to show in completion window
|
-- ^ Just x: maximum number of rows to show in completion window
|
||||||
|
, maxComplColumns :: Maybe Dimension
|
||||||
|
-- ^ Just x: maximum number of columns 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
|
||||||
@ -323,6 +325,7 @@ instance Default XPConfig where
|
|||||||
, position = Bottom
|
, position = Bottom
|
||||||
, height = 18
|
, height = 18
|
||||||
, maxComplRows = Nothing
|
, maxComplRows = Nothing
|
||||||
|
, maxComplColumns = Nothing
|
||||||
, historySize = 256
|
, historySize = 256
|
||||||
, historyFilter = id
|
, historyFilter = id
|
||||||
, defaultText = []
|
, defaultText = []
|
||||||
@ -1497,8 +1500,10 @@ getComplWinDim compl = do
|
|||||||
bw = promptBorderWidth c
|
bw = promptBorderWidth c
|
||||||
|
|
||||||
tws <- mapM (textWidthXMF (dpy st) fs) compl
|
tws <- mapM (textWidthXMF (dpy st) fs) compl
|
||||||
let max_compl_len = fromIntegral ((fi ht `div` 2) + maximum tws)
|
let max_compl_len = (fi ht `div` 2) + maximum tws
|
||||||
columns = max 1 $ wh `div` fi max_compl_len
|
limit_max_columns = maybe id min (maxComplColumns c)
|
||||||
|
columns = max 1 $ limit_max_columns $ wh `div` fi max_compl_len
|
||||||
|
column_width = wh `div` columns
|
||||||
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)
|
||||||
@ -1516,7 +1521,7 @@ getComplWinDim compl = do
|
|||||||
let yp = fi $ (ht + fi (asc - desc)) `div` 2
|
let yp = fi $ (ht + fi (asc - desc)) `div` 2
|
||||||
xp = (asc + desc) `div` 2
|
xp = (asc + desc) `div` 2
|
||||||
yy = map fi . take (fi actual_rows) $ [yp,(yp + ht)..]
|
yy = map fi . take (fi actual_rows) $ [yp,(yp + ht)..]
|
||||||
xx = take (fi columns) [xp,(xp + max_compl_len)..]
|
xx = take (fi columns) [xp,(xp + fi column_width)..]
|
||||||
|
|
||||||
return (rect_x scr + x, rect_y scr + fi y, wh, actual_height, xx, yy)
|
return (rect_x scr + x, rect_y scr + fi y, wh, actual_height, xx, yy)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user