Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option boldIsBright added #178

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 4.1.0.0

* Add an option for enabling "bold is bright". This forces colors from the
extended light palette to be used whenever Termonad prints bold text.
[#178](https://github.com/cdepillabout/termonad/pull/178).
Thanks [@M0M097](https://github.com/M0M097)!

## 4.0.1.2

* Disable doctest test-suite when building with GHC-8.10.3. The doctests
Expand Down
242 changes: 131 additions & 111 deletions glade/preferences.glade

Large diffs are not rendered by default.

55 changes: 30 additions & 25 deletions src/Termonad/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ import GI.Vte
, terminalSearchFindPrevious
, terminalSearchSetRegex
, terminalSearchSetWrapAround
, terminalSetBoldIsBright
, terminalSetCursorBlinkMode
, terminalSetFont
, terminalSetScrollbackLines
Expand All @@ -127,7 +128,8 @@ import Paths_termonad (getDataFileName)
import Termonad.Gtk (appNew, objFromBuildUnsafe)
import Termonad.Keys (handleKeyPress)
import Termonad.Lenses
( lensConfirmExit
( lensBoldIsBright
, lensConfirmExit
, lensCursorBlinkMode
, lensFontConfig
, lensOptions
Expand Down Expand Up @@ -156,7 +158,8 @@ import Termonad.Term
, showScrollbarToPolicy
)
import Termonad.Types
( FontConfig(..)
( ConfigOptions(..)
, FontConfig(..)
, FontSize(FontSizePoints, FontSizeUnits)
, ShowScrollbar(..)
, ShowTabBar(..)
Expand Down Expand Up @@ -706,9 +709,11 @@ applyNewPreferencesToTab mvarTMState tab = do
scrolledWin = tab ^. lensTMNotebookTabTermContainer
options = tmState ^. lensTMStateConfig . lensOptions
terminalSetFont term (Just fontDesc)
terminalSetCursorBlinkMode term (options ^. lensCursorBlinkMode)
terminalSetWordCharExceptions term (options ^. lensWordCharExceptions)
terminalSetScrollbackLines term (fromIntegral (options ^. lensScrollbackLen))
terminalSetCursorBlinkMode term (cursorBlinkMode options)
terminalSetWordCharExceptions term (wordCharExceptions options)
terminalSetScrollbackLines term (fromIntegral (scrollbackLen options))
terminalSetBoldIsBright term (boldIsBright options)

let vScrollbarPolicy = showScrollbarToPolicy (options ^. lensShowScrollbar)
scrolledWindowSetPolicy scrolledWin PolicyTypeAutomatic vScrollbarPolicy

Expand All @@ -731,6 +736,8 @@ showPreferencesDialog mvarTMState = do
objFromBuildUnsafe preferencesBuilder "confirmExit" CheckButton
showMenuCheckButton <-
objFromBuildUnsafe preferencesBuilder "showMenu" CheckButton
boldIsBrightCheckButton <-
objFromBuildUnsafe preferencesBuilder "boldIsBright" CheckButton
wordCharExceptionsEntryBuffer <-
objFromBuildUnsafe preferencesBuilder "wordCharExceptions" Entry >>=
getEntryBuffer
Expand Down Expand Up @@ -778,18 +785,14 @@ showPreferencesDialog mvarTMState = do
-- Init with current state
fontChooserSetFontDesc fontButton (tmState ^. lensTMStateFontDesc)
let options = tmState ^. lensTMStateConfig . lensOptions
comboBoxSetActive showScrollbarComboBoxText $ options ^. lensShowScrollbar
comboBoxSetActive showTabBarComboBoxText $ options ^. lensShowTabBar
comboBoxSetActive cursorBlinkModeComboBoxText $ options ^. lensCursorBlinkMode
spinButtonSetValue
scrollbackLenSpinButton
(fromIntegral $ options ^. lensScrollbackLen)
toggleButtonSetActive confirmExitCheckButton $ options ^. lensConfirmExit
toggleButtonSetActive showMenuCheckButton $ options ^. lensShowMenu
entryBufferSetText
wordCharExceptionsEntryBuffer
(options ^. lensWordCharExceptions)
(-1)
comboBoxSetActive showScrollbarComboBoxText $ showScrollbar options
comboBoxSetActive showTabBarComboBoxText $ showTabBar options
comboBoxSetActive cursorBlinkModeComboBoxText $ cursorBlinkMode options
spinButtonSetValue scrollbackLenSpinButton (fromIntegral $ scrollbackLen options)
toggleButtonSetActive confirmExitCheckButton $ confirmExit options
toggleButtonSetActive showMenuCheckButton $ showMenu options
toggleButtonSetActive boldIsBrightCheckButton $ boldIsBright options
entryBufferSetText wordCharExceptionsEntryBuffer (wordCharExceptions options) (-1)

-- Run dialog then close
res <- dialogRun preferencesDialog
Expand All @@ -805,21 +808,23 @@ showPreferencesDialog mvarTMState = do
comboBoxGetActive showTabBarComboBoxText [ShowTabBarNever ..]
maybeCursorBlinkMode <-
comboBoxGetActive cursorBlinkModeComboBoxText [CursorBlinkModeSystem ..]
scrollbackLen <-
scrollbackLenVal <-
fromIntegral <$> spinButtonGetValueAsInt scrollbackLenSpinButton
confirmExit <- toggleButtonGetActive confirmExitCheckButton
showMenu <- toggleButtonGetActive showMenuCheckButton
wordCharExceptions <- entryBufferGetText wordCharExceptionsEntryBuffer
confirmExitVal <- toggleButtonGetActive confirmExitCheckButton
showMenuVal <- toggleButtonGetActive showMenuCheckButton
boldIsBrightVal <- toggleButtonGetActive boldIsBrightCheckButton
wordCharExceptionsVal <- entryBufferGetText wordCharExceptionsEntryBuffer

-- Apply the changes to mvarTMState
modifyMVar_ mvarTMState $ pure
. over lensTMStateFontDesc (`fromMaybe` maybeFontDesc)
. over (lensTMStateConfig . lensOptions)
( set lensConfirmExit confirmExit
. set lensShowMenu showMenu
. set lensWordCharExceptions wordCharExceptions
( set lensConfirmExit confirmExitVal
. set lensShowMenu showMenuVal
. set lensBoldIsBright boldIsBrightVal
. set lensWordCharExceptions wordCharExceptionsVal
. over lensFontConfig (`fromMaybe` maybeFontConfig)
. set lensScrollbackLen scrollbackLen
. set lensScrollbackLen scrollbackLenVal
. over lensShowScrollbar (`fromMaybe` maybeShowScrollbar)
. over lensShowTabBar (`fromMaybe` maybeShowTabBar)
. over lensCursorBlinkMode (`fromMaybe` maybeCursorBlinkMode)
Expand Down
1 change: 1 addition & 0 deletions src/Termonad/Lenses.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ $(makeLensesFor
, ("showMenu", "lensShowMenu")
, ("showTabBar", "lensShowTabBar")
, ("cursorBlinkMode", "lensCursorBlinkMode")
, ("boldIsBright", "lensBoldIsBright")
]
''ConfigOptions
)
Expand Down
4 changes: 3 additions & 1 deletion src/Termonad/Term.hs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ import GI.Vte
, terminalSetScrollbackLines
, terminalSpawnSync
, terminalSetWordCharExceptions
, terminalSetBoldIsBright
)
import System.Directory (getSymbolicLinkTarget)
import System.Environment (lookupEnv)
Expand All @@ -111,7 +112,7 @@ import Termonad.Lenses
)
import Termonad.Types
( ConfigHooks(createTermHook)
, ConfigOptions(scrollbackLen, wordCharExceptions, cursorBlinkMode)
, ConfigOptions(scrollbackLen, wordCharExceptions, cursorBlinkMode, boldIsBright)
, ShowScrollbar(..)
, ShowTabBar(..)
, TMConfig(hooks, options)
Expand Down Expand Up @@ -346,6 +347,7 @@ createAndInitVteTerm tmStateFontDesc curOpts = do
terminalSetWordCharExceptions vteTerm $ wordCharExceptions curOpts
terminalSetScrollbackLines vteTerm (fromIntegral (scrollbackLen curOpts))
terminalSetCursorBlinkMode vteTerm (cursorBlinkMode curOpts)
terminalSetBoldIsBright vteTerm (boldIsBright curOpts)
widgetShow vteTerm
pure vteTerm

Expand Down
19 changes: 19 additions & 0 deletions src/Termonad/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,23 @@ data ConfigOptions = ConfigOptions
-- ^ When to show the tab bar.
, cursorBlinkMode :: !CursorBlinkMode
-- ^ How to handle cursor blink.
, boldIsBright :: !Bool
-- ^ This option controls whether or not to force bold text to use colors
-- from the 'Termonad.Config.Colour.ExtendedPalatte'.
--
-- If 'True', then colored bold text will /always/ use colors from the
-- 'Termonad.Config.Colour.ExtendedPalatte'. There will be no way to print
-- bold text colored with the 'Termonad.Config.Colour.BasicPalatte'.
--
-- This often isn't a big problem, since many TUI applications use
-- bold in combination with colors from the 'Termonad.Config.Colour.ExtendedPalatte'.
-- Also, the VTE default blue color can be difficult to read with a dark
-- background, and enabling this can work around the problem.
-- See <https://github.com/cdepillabout/termonad/issues/177> for more information.
--
-- If 'False', then bold can be applied separately to colors from both the
-- 'Termonad.Config.Colour.BasicPalatte' and
-- 'Termonad.Config.Colour.ExtendedPalatte'.
} deriving (Eq, Generic, FromJSON, Show, ToJSON)

instance FromJSON CursorBlinkMode where
Expand Down Expand Up @@ -421,6 +438,7 @@ instance ToJSON CursorBlinkMode where
-- , showMenu = True
-- , showTabBar = ShowTabBarIfNeeded
-- , cursorBlinkMode = CursorBlinkModeOn
-- , boldIsBright = False
-- }
-- in defaultConfigOptions == defConfOpt
-- :}
Expand All @@ -436,6 +454,7 @@ defaultConfigOptions =
, showMenu = True
, showTabBar = ShowTabBarIfNeeded
, cursorBlinkMode = CursorBlinkModeOn
, boldIsBright = False
}

-- | The Termonad 'ConfigOptions' along with the 'ConfigHooks'.
Expand Down
3 changes: 2 additions & 1 deletion termonad.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: termonad
version: 4.0.1.2
version: 4.1.0.0
synopsis: Terminal emulator configurable in Haskell
description:
Termonad is a terminal emulator configurable in Haskell. It is extremely
Expand Down Expand Up @@ -152,6 +152,7 @@ test-suite doctests
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
-- For some reason doctests appear to be segfaulting when compiling with
-- ghc-8.10.3, so only build them when using ghc-8.10.2 or earlier.
-- See https://github.com/cdepillabout/termonad/issues/174.
if impl(ghc <= 8.10.2)
buildable: True
else
Expand Down