From 2caf491e9ddbea7e08b13d3612127771ad9239ea Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sat, 18 Nov 2023 18:55:06 +0800 Subject: [PATCH] Remove the "show all tool" config We show all tools at the moment anyway. --- app/ghcup/BrickMain.hs | 45 ++++++++++---------------------- app/ghcup/Main.hs | 1 - lib-opt/GHCup/OptParse/Config.hs | 1 - lib/GHCup/Types.hs | 4 --- 4 files changed, 14 insertions(+), 37 deletions(-) diff --git a/app/ghcup/BrickMain.hs b/app/ghcup/BrickMain.hs index 5ae12bd..5f3cc06 100644 --- a/app/ghcup/BrickMain.hs +++ b/app/ghcup/BrickMain.hs @@ -89,9 +89,6 @@ notInstalledSign = "X " notInstalledSign = "✗ " #endif -hiddenTools :: [Tool] -hiddenTools = [] - data BrickData = BrickData { lr :: [ListResult] @@ -100,7 +97,6 @@ data BrickData = BrickData data BrickSettings = BrickSettings { showAllVersions :: Bool - , showAllTools :: Bool } deriving Show @@ -134,19 +130,14 @@ keyHandlers KeyBindings {..} = , ( bShowAllVersions , \BrickSettings {..} -> if showAllVersions then "Don't show all versions" else "Show all versions" - , hideShowHandler (not . showAllVersions) showAllTools - ) - , ( bShowAllTools - , \BrickSettings {..} -> - if showAllTools then "Don't show all tools" else "Show all tools" - , hideShowHandler showAllVersions (not . showAllTools) + , hideShowHandler (not . showAllVersions) ) , (bUp, const "Up", \BrickState {..} -> put BrickState{ appState = moveCursor 1 appState Up, .. }) , (bDown, const "Down", \BrickState {..} -> put BrickState{ appState = moveCursor 1 appState Down, .. }) ] where - hideShowHandler f p BrickState{..} = - let newAppSettings = appSettings { showAllVersions = f appSettings , showAllTools = p appSettings } + hideShowHandler f BrickState{..} = + let newAppSettings = appSettings { showAllVersions = f appSettings } newInternalState = constructList appData newAppSettings (Just appState) in put (BrickState appData newAppSettings newInternalState appKeys) @@ -411,8 +402,7 @@ constructList :: BrickData -> Maybe BrickInternalState -> BrickInternalState constructList appD appSettings = - replaceLR (filterVisible (showAllVersions appSettings) - (showAllTools appSettings)) + replaceLR (filterVisible (showAllVersions appSettings)) (lr appD) listSelectedElement' :: BrickInternalState -> Maybe (Int, ListResult) @@ -443,22 +433,15 @@ replaceLR filterF lr s = lTool e1 == lTool e2 && lVer e1 == lVer e2 && lCross e1 == lCross e2 -filterVisible :: Bool -> Bool -> ListResult -> Bool -filterVisible v t e | lInstalled e = True - | v - , not t - , Nightly `notElem` lTag e - , lTool e `notElem` hiddenTools = True - | not v - , t - , Old `notElem` lTag e - , Nightly `notElem` lTag e = True - | v - , Nightly `notElem` lTag e - , t = True - | otherwise = (Old `notElem` lTag e) && - (Nightly `notElem` lTag e) && - (lTool e `notElem` hiddenTools) +filterVisible :: Bool -> ListResult -> Bool +filterVisible v e | lInstalled e = True + | v + , Nightly `notElem` lTag e = True + | not v + , Old `notElem` lTag e + , Nightly `notElem` lTag e = True + | otherwise = (Old `notElem` lTag e) && + (Nightly `notElem` lTag e) install' :: (MonadReader AppState m, MonadIO m, MonadThrow m, MonadFail m, MonadMask m, MonadUnliftIO m, Alternative m) @@ -712,7 +695,7 @@ brickMain s = do defaultAppSettings :: BrickSettings -defaultAppSettings = BrickSettings { showAllVersions = False, showAllTools = False } +defaultAppSettings = BrickSettings { showAllVersions = False } getGHCupInfo :: IO (Either String GHCupInfo) diff --git a/app/ghcup/Main.hs b/app/ghcup/Main.hs index bc24f8d..dd910f7 100644 --- a/app/ghcup/Main.hs +++ b/app/ghcup/Main.hs @@ -107,7 +107,6 @@ toSettings options = do , bSet = fromMaybe bSet kSet , bChangelog = fromMaybe bChangelog kChangelog , bShowAllVersions = fromMaybe bShowAllVersions kShowAll - , bShowAllTools = fromMaybe bShowAllTools kShowAllTools } diff --git a/lib-opt/GHCup/OptParse/Config.hs b/lib-opt/GHCup/OptParse/Config.hs index c04eac5..6d0e3ca 100644 --- a/lib-opt/GHCup/OptParse/Config.hs +++ b/lib-opt/GHCup/OptParse/Config.hs @@ -149,7 +149,6 @@ updateSettings usl usr = , kSet = kSet kbl <|> kSet kbr , kChangelog = kChangelog kbl <|> kChangelog kbr , kShowAll = kShowAll kbl <|> kShowAll kbr - , kShowAllTools = kShowAllTools kbl <|> kShowAllTools kbr } diff --git a/lib/GHCup/Types.hs b/lib/GHCup/Types.hs index e8995f5..4690506 100644 --- a/lib/GHCup/Types.hs +++ b/lib/GHCup/Types.hs @@ -422,7 +422,6 @@ fromSettings Settings{..} (Just KeyBindings{..}) = , kSet = Just bSet , kChangelog = Just bChangelog , kShowAll = Just bShowAllVersions - , kShowAllTools = Just bShowAllTools } in UserSettings { uCache = Just cache @@ -449,7 +448,6 @@ data UserKeyBindings = UserKeyBindings , kSet :: Maybe KeyCombination , kChangelog :: Maybe KeyCombination , kShowAll :: Maybe KeyCombination - , kShowAllTools :: Maybe KeyCombination } deriving (Show, GHC.Generic, Eq) @@ -462,7 +460,6 @@ data KeyBindings = KeyBindings , bSet :: KeyCombination , bChangelog :: KeyCombination , bShowAllVersions :: KeyCombination - , bShowAllTools :: KeyCombination } deriving (Show, GHC.Generic) @@ -485,7 +482,6 @@ defaultKeyBindings = KeyBindings , bSet = KeyCombination { key = KChar 's', mods = [] } , bChangelog = KeyCombination { key = KChar 'c', mods = [] } , bShowAllVersions = KeyCombination { key = KChar 'a', mods = [] } - , bShowAllTools = KeyCombination { key = KChar 't', mods = [] } } data AppState = AppState