Skip to content

Commit

Permalink
Customisable scroll-wheel amount in Pango.
Browse files Browse the repository at this point in the history
  • Loading branch information
reinerp authored and arenl committed Sep 11, 2011
1 parent c4382e0 commit c4627bd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions yi/src/library/Yi/Config.hs
Expand Up @@ -23,6 +23,7 @@ data UIConfig = UIConfig {
configFontSize :: Maybe Int, -- ^ Font size, for the UI that support it.
configScrollStyle ::Maybe ScrollStyle,
-- ^ Style of scroll
configScrollWheelAmount :: Int, -- ^ Amount to move the buffer when using the scroll wheel
configLeftSideScrollBar :: Bool, -- ^ Should the scrollbar be shown on the left side?
configAutoHideScrollBar :: Bool, -- ^ Hide scrollbar automatically if text fits on one page.
configAutoHideTabBar :: Bool, -- ^ Hide the tabbar automatically if only one tab is present
Expand Down
1 change: 1 addition & 0 deletions yi/src/library/Yi/Config/Default.hs
Expand Up @@ -134,6 +134,7 @@ defaultConfig =
, configUI = UIConfig
{ configFontSize = Nothing
, configFontName = Nothing
, configScrollWheelAmount = 4
, configScrollStyle = Nothing
, configCursorStyle = FatWhenFocusedAndInserting
, configLineWrap = True
Expand Down
9 changes: 7 additions & 2 deletions yi/src/library/Yi/Config/Simple.hs
Expand Up @@ -30,6 +30,7 @@ module Yi.Config.Simple (
-- * Appearance
fontName,
fontSize,
scrollWheelAmount,
scrollStyle,
ScrollStyle(..),
cursorStyle,
Expand Down Expand Up @@ -107,8 +108,8 @@ import Yi.Config(Config, UIConfig,
startFrontEndA, configUIA, startActionsA, initialActionsA, defaultKmA,
configInputPreprocessA, modeTableA, debugModeA,
configRegionStyleA, configKillringAccumulateA, bufferUpdateHandlerA,
configVtyEscDelayA, configFontNameA, configFontSizeA, configScrollStyleA,
configCursorStyleA, CursorStyle(..),
configVtyEscDelayA, configFontNameA, configFontSizeA, configScrollWheelAmountA,
configScrollStyleA, configCursorStyleA, CursorStyle(..),
configLeftSideScrollBarA, configAutoHideScrollBarA, configAutoHideTabBarA,
configLineWrapA, configWindowFillA, configThemeA, layoutManagersA, configVarsA,
)
Expand Down Expand Up @@ -244,6 +245,10 @@ fontName = configFontNameA . configUIA
fontSize :: Field (Maybe Int)
fontSize = configFontSizeA . configUIA

-- | Amount to move the buffer when using the scroll wheel.
scrollWheelAmount :: Field Int
scrollWheelAmount = configScrollWheelAmountA . configUIA

-- | 'Just' the scroll style, or 'Nothing' for default.
scrollStyle :: Field (Maybe ScrollStyle)
scrollStyle = configScrollStyleA . configUIA
Expand Down
5 changes: 3 additions & 2 deletions yi/src/library/Yi/UI/Pango.hs
Expand Up @@ -700,9 +700,10 @@ handleScroll ui w = do
-- query new coordinates
let editorAction = do
withBuffer0 $ scrollB $ case scrollDirection of
ScrollUp -> -1
ScrollDown -> 1
ScrollUp -> negate configAmount
ScrollDown -> configAmount
_ -> 0 -- Left/right scrolling not supported
configAmount = configScrollWheelAmount $ uiConfig ui
uiActionCh ui (makeAction editorAction)
if ifPressed
then selectArea ui w xy
Expand Down

0 comments on commit c4627bd

Please sign in to comment.