Terminal: Add option to use bright instead of bold text
A saturated add was chosen instead of tint_color, as the results of tint_color were too extreme.
This commit is contained in:
@@ -86,6 +86,10 @@ AppearancePrefView::AppearancePrefView(const char* name,
|
||||
B_TRANSLATE("Blinking cursor"),
|
||||
new BMessage(MSG_BLINK_CURSOR_CHANGED));
|
||||
|
||||
fBrightInsteadOfBold = new BCheckBox(
|
||||
B_TRANSLATE("Use bright instead of bold text"),
|
||||
new BMessage(MSG_BRIGHT_INSTEAD_OF_BOLD_CHANGED));
|
||||
|
||||
fWarnOnExit = new BCheckBox(
|
||||
B_TRANSLATE("Confirm exit if active programs exist"),
|
||||
new BMessage(MSG_WARN_ON_EXIT_CHANGED));
|
||||
@@ -139,6 +143,7 @@ AppearancePrefView::AppearancePrefView(const char* name,
|
||||
.Add(fColorControl = new BColorControl(BPoint(10, 10),
|
||||
B_CELLS_32x8, 8.0, "", new BMessage(MSG_COLOR_CHANGED)))
|
||||
.Add(fBlinkCursor)
|
||||
.Add(fBrightInsteadOfBold)
|
||||
.Add(fWarnOnExit);
|
||||
|
||||
fTabTitle->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
|
||||
@@ -154,6 +159,8 @@ AppearancePrefView::AppearancePrefView(const char* name,
|
||||
PrefHandler::Default()->getRGB(PREF_TEXT_FORE_COLOR));
|
||||
|
||||
fBlinkCursor->SetValue(PrefHandler::Default()->getBool(PREF_BLINK_CURSOR));
|
||||
fBrightInsteadOfBold->SetValue(PrefHandler::Default()->getBool(
|
||||
PREF_BRIGHT_INSTEAD_OF_BOLD));
|
||||
fWarnOnExit->SetValue(PrefHandler::Default()->getBool(PREF_WARN_ON_EXIT));
|
||||
|
||||
BTextControl* redInput = (BTextControl*)fColorControl->ChildAt(0);
|
||||
@@ -206,6 +213,7 @@ AppearancePrefView::AttachedToWindow()
|
||||
fTabTitle->SetTarget(this);
|
||||
fWindowTitle->SetTarget(this);
|
||||
fBlinkCursor->SetTarget(this);
|
||||
fBrightInsteadOfBold->SetTarget(this);
|
||||
fWarnOnExit->SetTarget(this);
|
||||
|
||||
fFontField->Menu()->SetTargetForItems(this);
|
||||
@@ -321,6 +329,15 @@ AppearancePrefView::MessageReceived(BMessage* msg)
|
||||
}
|
||||
break;
|
||||
|
||||
case MSG_BRIGHT_INSTEAD_OF_BOLD_CHANGED:
|
||||
if (PrefHandler::Default()->getBool(PREF_BRIGHT_INSTEAD_OF_BOLD)
|
||||
!= fBrightInsteadOfBold->Value()) {
|
||||
PrefHandler::Default()->setBool(PREF_BRIGHT_INSTEAD_OF_BOLD,
|
||||
fBrightInsteadOfBold->Value());
|
||||
modified = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case MSG_WARN_ON_EXIT_CHANGED:
|
||||
if (PrefHandler::Default()->getBool(PREF_WARN_ON_EXIT)
|
||||
!= fWarnOnExit->Value()) {
|
||||
|
||||
@@ -24,6 +24,7 @@ static const uint32 MSG_COLOR_SCHEME_CHANGED = 'mccs';
|
||||
static const uint32 MSG_TAB_TITLE_SETTING_CHANGED = 'mtts';
|
||||
static const uint32 MSG_WINDOW_TITLE_SETTING_CHANGED = 'mwts';
|
||||
static const uint32 MSG_BLINK_CURSOR_CHANGED = 'mbcc';
|
||||
static const uint32 MSG_BRIGHT_INSTEAD_OF_BOLD_CHANGED = 'bibc';
|
||||
static const uint32 MSG_WARN_ON_EXIT_CHANGED = 'mwec';
|
||||
static const uint32 MSG_COLS_CHANGED = 'mccl';
|
||||
static const uint32 MSG_ROWS_CHANGED = 'mcrw';
|
||||
@@ -77,6 +78,7 @@ private:
|
||||
const char* style, const char* size);
|
||||
|
||||
BCheckBox* fBlinkCursor;
|
||||
BCheckBox* fBrightInsteadOfBold;
|
||||
BCheckBox* fWarnOnExit;
|
||||
BMenuField* fFontField;
|
||||
|
||||
|
||||
@@ -134,6 +134,8 @@ static const char* const PREF_ROWS = "Rows";
|
||||
static const char* const PREF_TEXT_ENCODING = "Text encoding";
|
||||
|
||||
static const char* const PREF_BLINK_CURSOR = "Blinking cursor";
|
||||
static const char* const PREF_BRIGHT_INSTEAD_OF_BOLD =
|
||||
"Bright instead of bold text";
|
||||
static const char* const PREF_WARN_ON_EXIT = "Warn on exit";
|
||||
static const char* const PREF_CURSOR_STYLE = "Cursor style";
|
||||
static const char* const PREF_EMULATE_BOLD = "Emulate bold";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2013, Haiku, Inc.
|
||||
* Copyright 2001-2014, Haiku, Inc.
|
||||
* Copyright 2003-2004 Kian Duffy, [email protected]
|
||||
* Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai.
|
||||
* All rights reserved. Distributed under the terms of the MIT license.
|
||||
@@ -8,6 +8,7 @@
|
||||
* Stefano Ceccherini, [email protected]
|
||||
* Kian Duffy, [email protected]
|
||||
* Y.Hayakawa, [email protected]
|
||||
* Jonathan Schleifer, [email protected]
|
||||
* Ingo Weinhold, [email protected]
|
||||
* Clemens Zeidler, [email protected]
|
||||
* Siarzhuk Zharski, [email protected]
|
||||
@@ -121,6 +122,15 @@ restrict_value(const Type& value, const Type& min, const Type& max)
|
||||
}
|
||||
|
||||
|
||||
template<typename Type>
|
||||
static inline Type
|
||||
saturated_add(Type a, Type b)
|
||||
{
|
||||
const Type max = (Type)(-1);
|
||||
return (max - a >= b ? a + b : max);
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - TextBufferSyncLocker
|
||||
|
||||
|
||||
@@ -273,6 +283,7 @@ TermView::_InitObject(const ShellParameters& shellParameters)
|
||||
fFontHeight = 0;
|
||||
fFontAscent = 0;
|
||||
fEmulateBold = false;
|
||||
fBrightInsteadOfBold = false;
|
||||
fFrameResized = false;
|
||||
fResizeViewDisableCount = 0;
|
||||
fLastActivityTime = 0;
|
||||
@@ -768,6 +779,9 @@ TermView::SetTermFont(const BFont *font)
|
||||
fEmulateBold = PrefHandler::Default() == NULL ? false
|
||||
: PrefHandler::Default()->getBool(PREF_EMULATE_BOLD);
|
||||
|
||||
fBrightInsteadOfBold = PrefHandler::Default() == NULL ? false
|
||||
: PrefHandler::Default()->getBool(PREF_BRIGHT_INSTEAD_OF_BOLD);
|
||||
|
||||
_ScrollTo(0, false);
|
||||
if (fScrollBar != NULL)
|
||||
fScrollBar->SetSteps(fFontHeight, fFontHeight * fRows);
|
||||
@@ -948,7 +962,8 @@ TermView::_DrawLinePart(int32 x1, int32 y1, uint32 attr, char *buf,
|
||||
if (highlight != NULL)
|
||||
attr = highlight->Highlighter()->AdjustTextAttributes(attr);
|
||||
|
||||
inView->SetFont(IS_BOLD(attr) && !fEmulateBold ? &fBoldFont : &fHalfFont);
|
||||
inView->SetFont(IS_BOLD(attr) && !fEmulateBold && !fBrightInsteadOfBold
|
||||
? &fBoldFont : &fHalfFont);
|
||||
|
||||
// Set pen point
|
||||
int x2 = x1 + fFontWidth * width;
|
||||
@@ -989,10 +1004,20 @@ TermView::_DrawLinePart(int32 x1, int32 y1, uint32 attr, char *buf,
|
||||
inView->SetHighColor(rgb_fore);
|
||||
|
||||
// Draw character.
|
||||
if (IS_BOLD(attr) && fEmulateBold) {
|
||||
inView->MovePenTo(x1 - 1, y1 + fFontAscent - 1);
|
||||
inView->DrawString((char *)buf);
|
||||
inView->SetDrawingMode(B_OP_BLEND);
|
||||
if (IS_BOLD(attr)) {
|
||||
if (fBrightInsteadOfBold) {
|
||||
rgb_color bright = rgb_fore;
|
||||
|
||||
bright.red = saturated_add<uint8>(bright.red, 64);
|
||||
bright.green = saturated_add<uint8>(bright.green, 64);
|
||||
bright.blue = saturated_add<uint8>(bright.blue, 64);
|
||||
|
||||
inView->SetHighColor(bright);
|
||||
} else if (fEmulateBold) {
|
||||
inView->MovePenTo(x1 - 1, y1 + fFontAscent - 1);
|
||||
inView->DrawString((char *)buf);
|
||||
inView->SetDrawingMode(B_OP_BLEND);
|
||||
}
|
||||
}
|
||||
|
||||
inView->MovePenTo(x1, y1 + fFontAscent);
|
||||
|
||||
@@ -275,6 +275,7 @@ private:
|
||||
int fFontAscent;
|
||||
struct escapement_delta fEscapement;
|
||||
bool fEmulateBold;
|
||||
bool fBrightInsteadOfBold;
|
||||
|
||||
// frame resized flag.
|
||||
bool fFrameResized;
|
||||
|
||||
@@ -831,6 +831,7 @@ TermWindow::MessageReceived(BMessage *message)
|
||||
|
||||
case MSG_HALF_FONT_CHANGED:
|
||||
case MSG_FULL_FONT_CHANGED:
|
||||
case MSG_BRIGHT_INSTEAD_OF_BOLD_CHANGED:
|
||||
{
|
||||
BFont font;
|
||||
_GetPreferredFont(font);
|
||||
|
||||
Reference in New Issue
Block a user