Change schema in Terminal to color scheme.

Love this feature, but, color schema is not a thing, it is a color
scheme. Change both the display text and the variable names.

Also changed "Retro Terminal" color scheme to just "Retro". Terminal
is redundant.
This commit is contained in:
John Scipione
2012-12-04 19:09:50 -05:00
parent 760de9b200
commit 2005db27ff
5 changed files with 83 additions and 82 deletions
+45 -44
View File
@@ -100,10 +100,10 @@ AppearancePrefView::AppearancePrefView(const char* name,
fFont = new BMenuField(B_TRANSLATE("Font:"), fontMenu); fFont = new BMenuField(B_TRANSLATE("Font:"), fontMenu);
fFontSize = new BMenuField(B_TRANSLATE("Size:"), sizeMenu); fFontSize = new BMenuField(B_TRANSLATE("Size:"), sizeMenu);
BPopUpMenu* schemasPopUp = _MakeColorSchemaMenu(MSG_COLOR_SCHEMA_CHANGED, BPopUpMenu* schemesPopUp = _MakeColorSchemeMenu(MSG_COLOR_SCHEME_CHANGED,
gPredefinedSchemas, gPredefinedSchemas[0]); gPredefinedColorSchemes, gPredefinedColorSchemes[0]);
fColorSchemaField = new BMenuField(B_TRANSLATE("Color schema:"), fColorSchemeField = new BMenuField(B_TRANSLATE("Color scheme:"),
schemasPopUp); schemesPopUp);
BPopUpMenu* colorsPopUp = _MakeMenu(MSG_COLOR_FIELD_CHANGED, kColorTable, BPopUpMenu* colorsPopUp = _MakeMenu(MSG_COLOR_FIELD_CHANGED, kColorTable,
kColorTable[0]); kColorTable[0]);
@@ -139,8 +139,8 @@ AppearancePrefView::AppearancePrefView(const char* name,
.Add(fFont->CreateMenuBarLayoutItem(), 1, 2) .Add(fFont->CreateMenuBarLayoutItem(), 1, 2)
.Add(fFontSize->CreateLabelLayoutItem(), 0, 3) .Add(fFontSize->CreateLabelLayoutItem(), 0, 3)
.Add(fFontSize->CreateMenuBarLayoutItem(), 1, 3) .Add(fFontSize->CreateMenuBarLayoutItem(), 1, 3)
.Add(fColorSchemaField->CreateLabelLayoutItem(), 0, 4) .Add(fColorSchemeField->CreateLabelLayoutItem(), 0, 4)
.Add(fColorSchemaField->CreateMenuBarLayoutItem(), 1, 4) .Add(fColorSchemeField->CreateMenuBarLayoutItem(), 1, 4)
.Add(fColorField->CreateLabelLayoutItem(), 0, 5) .Add(fColorField->CreateLabelLayoutItem(), 0, 5)
.Add(fColorField->CreateMenuBarLayoutItem(), 1, 5) .Add(fColorField->CreateMenuBarLayoutItem(), 1, 5)
.End() .End()
@@ -155,7 +155,7 @@ AppearancePrefView::AppearancePrefView(const char* name,
fFont->SetAlignment(B_ALIGN_RIGHT); fFont->SetAlignment(B_ALIGN_RIGHT);
fFontSize->SetAlignment(B_ALIGN_RIGHT); fFontSize->SetAlignment(B_ALIGN_RIGHT);
fColorField->SetAlignment(B_ALIGN_RIGHT); fColorField->SetAlignment(B_ALIGN_RIGHT);
fColorSchemaField->SetAlignment(B_ALIGN_RIGHT); fColorSchemeField->SetAlignment(B_ALIGN_RIGHT);
fTabTitle->SetText(PrefHandler::Default()->getString(PREF_TAB_TITLE)); fTabTitle->SetText(PrefHandler::Default()->getString(PREF_TAB_TITLE));
fWindowTitle->SetText(PrefHandler::Default()->getString(PREF_WINDOW_TITLE)); fWindowTitle->SetText(PrefHandler::Default()->getString(PREF_WINDOW_TITLE));
@@ -197,7 +197,7 @@ AppearancePrefView::Revert()
fWarnOnExit->SetValue(PrefHandler::Default()->getBool( fWarnOnExit->SetValue(PrefHandler::Default()->getBool(
PREF_WARN_ON_EXIT)); PREF_WARN_ON_EXIT));
fColorSchemaField->Menu()->ItemAt(0)->SetMarked(true); fColorSchemeField->Menu()->ItemAt(0)->SetMarked(true);
fColorControl->SetValue(PrefHandler::Default()-> fColorControl->SetValue(PrefHandler::Default()->
getRGB(PREF_TEXT_FORE_COLOR)); getRGB(PREF_TEXT_FORE_COLOR));
@@ -221,12 +221,12 @@ AppearancePrefView::AttachedToWindow()
fColorControl->SetTarget(this); fColorControl->SetTarget(this);
fColorField->Menu()->SetTargetForItems(this); fColorField->Menu()->SetTargetForItems(this);
fColorSchemaField->Menu()->SetTargetForItems(this); fColorSchemeField->Menu()->SetTargetForItems(this);
_SetCurrentColorSchema(fColorSchemaField); _SetCurrentColorScheme(fColorSchemeField);
bool enableCustomColors = bool enableCustomColors =
!strcmp(fColorSchemaField->Menu()->FindMarked()->Label(), !strcmp(fColorSchemeField->Menu()->FindMarked()->Label(),
gCustomSchema.name); gCustomColorScheme.name);
_EnableCustomColors(enableCustomColors); _EnableCustomColors(enableCustomColors);
} }
@@ -281,17 +281,17 @@ AppearancePrefView::MessageReceived(BMessage* msg)
} }
break; break;
case MSG_COLOR_SCHEMA_CHANGED: case MSG_COLOR_SCHEME_CHANGED:
{ {
color_schema* newSchema = NULL; color_scheme* newScheme = NULL;
if (msg->FindPointer("color_schema", if (msg->FindPointer("color_scheme",
(void**)&newSchema) == B_OK) { (void**)&newScheme) == B_OK) {
if (newSchema == &gCustomSchema) if (newScheme == &gCustomColorScheme)
_EnableCustomColors(true); _EnableCustomColors(true);
else else
_EnableCustomColors(false); _EnableCustomColors(false);
_ChangeColorSchema(newSchema); _ChangeColorScheme(newScheme);
modified = true; modified = true;
} }
break; break;
@@ -366,45 +366,46 @@ AppearancePrefView::_EnableCustomColors(bool enable)
void void
AppearancePrefView::_ChangeColorSchema(color_schema* schema) AppearancePrefView::_ChangeColorScheme(color_scheme* scheme)
{ {
PrefHandler* pref = PrefHandler::Default(); PrefHandler* pref = PrefHandler::Default();
pref->setRGB(PREF_TEXT_FORE_COLOR, schema->text_fore_color); pref->setRGB(PREF_TEXT_FORE_COLOR, scheme->text_fore_color);
pref->setRGB(PREF_TEXT_BACK_COLOR, schema->text_back_color); pref->setRGB(PREF_TEXT_BACK_COLOR, scheme->text_back_color);
pref->setRGB(PREF_SELECT_FORE_COLOR, schema->select_fore_color); pref->setRGB(PREF_SELECT_FORE_COLOR, scheme->select_fore_color);
pref->setRGB(PREF_SELECT_BACK_COLOR, schema->select_back_color); pref->setRGB(PREF_SELECT_BACK_COLOR, scheme->select_back_color);
pref->setRGB(PREF_CURSOR_FORE_COLOR, schema->cursor_fore_color); pref->setRGB(PREF_CURSOR_FORE_COLOR, scheme->cursor_fore_color);
pref->setRGB(PREF_CURSOR_BACK_COLOR, schema->cursor_back_color); pref->setRGB(PREF_CURSOR_BACK_COLOR, scheme->cursor_back_color);
} }
void void
AppearancePrefView::_SetCurrentColorSchema(BMenuField* field) AppearancePrefView::_SetCurrentColorScheme(BMenuField* field)
{ {
PrefHandler* pref = PrefHandler::Default(); PrefHandler* pref = PrefHandler::Default();
gCustomSchema.text_fore_color = pref->getRGB(PREF_TEXT_FORE_COLOR); gCustomColorScheme.text_fore_color = pref->getRGB(PREF_TEXT_FORE_COLOR);
gCustomSchema.text_back_color = pref->getRGB(PREF_TEXT_BACK_COLOR); gCustomColorScheme.text_back_color = pref->getRGB(PREF_TEXT_BACK_COLOR);
gCustomSchema.select_fore_color = pref->getRGB(PREF_SELECT_FORE_COLOR); gCustomColorScheme.select_fore_color = pref->getRGB(PREF_SELECT_FORE_COLOR);
gCustomSchema.select_back_color = pref->getRGB(PREF_SELECT_BACK_COLOR); gCustomColorScheme.select_back_color = pref->getRGB(PREF_SELECT_BACK_COLOR);
gCustomSchema.cursor_fore_color = pref->getRGB(PREF_CURSOR_FORE_COLOR); gCustomColorScheme.cursor_fore_color = pref->getRGB(PREF_CURSOR_FORE_COLOR);
gCustomSchema.cursor_back_color = pref->getRGB(PREF_CURSOR_BACK_COLOR); gCustomColorScheme.cursor_back_color = pref->getRGB(PREF_CURSOR_BACK_COLOR);
const char* currentSchemaName = NULL; const char* currentSchemeName = NULL;
color_schema** schemas = const_cast<color_schema**>(gPredefinedSchemas); color_scheme** schemes
while (*schemas) { = const_cast<color_scheme**>(gPredefinedColorSchemes);
if (gCustomSchema == **schemas) { while (*schemes) {
currentSchemaName = (*schemas)->name; if (gCustomColorScheme == **schemes) {
currentSchemeName = (*schemes)->name;
break; break;
} }
schemas++; schemes++;
} }
for (int32 i = 0; i < fColorSchemaField->Menu()->CountItems(); i++) { for (int32 i = 0; i < fColorSchemeField->Menu()->CountItems(); i++) {
BMenuItem* item = fColorSchemaField->Menu()->ItemAt(i); BMenuItem* item = fColorSchemeField->Menu()->ItemAt(i);
if (!strcmp(item->Label(), currentSchemaName)) { if (!strcmp(item->Label(), currentSchemeName)) {
item->SetMarked(true); item->SetMarked(true);
break; break;
} }
@@ -521,8 +522,8 @@ AppearancePrefView::_MakeMenu(uint32 msg, const char** items,
/*static*/ BPopUpMenu* /*static*/ BPopUpMenu*
AppearancePrefView::_MakeColorSchemaMenu(uint32 msg, const color_schema** items, AppearancePrefView::_MakeColorSchemeMenu(uint32 msg, const color_scheme** items,
const color_schema* defaultItemName) const color_scheme* defaultItemName)
{ {
BPopUpMenu* menu = new BPopUpMenu(""); BPopUpMenu* menu = new BPopUpMenu("");
@@ -532,7 +533,7 @@ AppearancePrefView::_MakeColorSchemaMenu(uint32 msg, const color_schema** items,
menu->AddSeparatorItem(); menu->AddSeparatorItem();
else { else {
BMessage* message = new BMessage(msg); BMessage* message = new BMessage(msg);
message->AddPointer("color_schema", (const void*)*items); message->AddPointer("color_scheme", (const void*)*items);
menu->AddItem(new BMenuItem((*items)->name, message)); menu->AddItem(new BMenuItem((*items)->name, message));
} }
+8 -8
View File
@@ -19,7 +19,7 @@ static const uint32 MSG_FULL_FONT_CHANGED = 'mcff';
static const uint32 MSG_FULL_SIZE_CHANGED = 'mcfs'; static const uint32 MSG_FULL_SIZE_CHANGED = 'mcfs';
static const uint32 MSG_COLOR_FIELD_CHANGED = 'mccf'; static const uint32 MSG_COLOR_FIELD_CHANGED = 'mccf';
static const uint32 MSG_COLOR_CHANGED = 'mcbc'; static const uint32 MSG_COLOR_CHANGED = 'mcbc';
static const uint32 MSG_COLOR_SCHEMA_CHANGED = 'mccs'; static const uint32 MSG_COLOR_SCHEME_CHANGED = 'mccs';
static const uint32 MSG_TAB_TITLE_SETTING_CHANGED = 'mtts'; static const uint32 MSG_TAB_TITLE_SETTING_CHANGED = 'mtts';
static const uint32 MSG_WINDOW_TITLE_SETTING_CHANGED = 'mwts'; static const uint32 MSG_WINDOW_TITLE_SETTING_CHANGED = 'mwts';
@@ -32,7 +32,7 @@ static const uint32 MSG_HISTORY_CHANGED = 'mhst';
static const uint32 MSG_PREF_MODIFIED = 'mpmo'; static const uint32 MSG_PREF_MODIFIED = 'mpmo';
struct color_schema; struct color_scheme;
class BCheckBox; class BCheckBox;
class BColorControl; class BColorControl;
class BMenu; class BMenu;
@@ -56,8 +56,8 @@ public:
private: private:
void _EnableCustomColors(bool enable); void _EnableCustomColors(bool enable);
void _ChangeColorSchema(color_schema* schema); void _ChangeColorScheme(color_scheme* scheme);
void _SetCurrentColorSchema(BMenuField* field); void _SetCurrentColorScheme(BMenuField* field);
static BMenu* _MakeFontMenu(uint32 command, static BMenu* _MakeFontMenu(uint32 command,
const char* defaultFamily, const char* defaultFamily,
@@ -68,16 +68,16 @@ private:
static BPopUpMenu* _MakeMenu(uint32 msg, const char** items, static BPopUpMenu* _MakeMenu(uint32 msg, const char** items,
const char* defaultItem); const char* defaultItem);
static BPopUpMenu* _MakeColorSchemaMenu(uint32 msg, static BPopUpMenu* _MakeColorSchemeMenu(uint32 msg,
const color_schema** schemas, const color_scheme** schemes,
const color_schema* defaultItemName); const color_scheme* defaultItemName);
BCheckBox* fBlinkCursor; BCheckBox* fBlinkCursor;
BCheckBox* fWarnOnExit; BCheckBox* fWarnOnExit;
BMenuField* fFont; BMenuField* fFont;
BMenuField* fFontSize; BMenuField* fFontSize;
BMenuField* fColorSchemaField; BMenuField* fColorSchemeField;
BMenuField* fColorField; BMenuField* fColorField;
BColorControl* fColorControl; BColorControl* fColorControl;
+24 -24
View File
@@ -10,7 +10,7 @@
#undef B_TRANSLATION_CONTEXT #undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Terminal colors schema" #define B_TRANSLATION_CONTEXT "Terminal colors scheme"
// Standard colors // Standard colors
@@ -20,7 +20,7 @@ const rgb_color kWhite = { 255, 255, 255, 255 };
const rgb_color kYellow = { 255, 255, 0, 255 }; const rgb_color kYellow = { 255, 255, 0, 255 };
const struct color_schema kColorDefault = { const struct color_scheme kColorSchemeDefault = {
B_TRANSLATE("Default"), B_TRANSLATE("Default"),
kBlack, kBlack,
kWhite, kWhite,
@@ -30,7 +30,7 @@ const struct color_schema kColorDefault = {
kBlack kBlack
}; };
const struct color_schema kColorBlue = { const struct color_scheme kColorSchemeBlue = {
B_TRANSLATE("Blue"), B_TRANSLATE("Blue"),
kYellow, kYellow,
{ 0, 0, 139, 255 }, { 0, 0, 139, 255 },
@@ -40,7 +40,7 @@ const struct color_schema kColorBlue = {
{ 0, 139, 139, 255 }, { 0, 139, 139, 255 },
}; };
const struct color_schema kColorMidnight = { const struct color_scheme kColorSchemeMidnight = {
B_TRANSLATE("Midnight"), B_TRANSLATE("Midnight"),
kWhite, kWhite,
kBlack, kBlack,
@@ -50,7 +50,7 @@ const struct color_schema kColorMidnight = {
kWhite kWhite
}; };
const struct color_schema kColorProfessional = { const struct color_scheme kColorSchemeProfessional = {
B_TRANSLATE("Professional"), B_TRANSLATE("Professional"),
kWhite, kWhite,
{ 8, 8, 8, 255 }, { 8, 8, 8, 255 },
@@ -60,8 +60,8 @@ const struct color_schema kColorProfessional = {
{ 50, 50, 50, 255 }, { 50, 50, 50, 255 },
}; };
const struct color_schema kColorRetroTerminal = { const struct color_scheme kColorSchemeRetro = {
B_TRANSLATE("Retro Terminal"), B_TRANSLATE("Retro"),
kGreen, kGreen,
kBlack, kBlack,
kBlack, kBlack,
@@ -70,7 +70,7 @@ const struct color_schema kColorRetroTerminal = {
kGreen kGreen
}; };
const struct color_schema kColorSlate = { const struct color_scheme kColorSchemeSlate = {
B_TRANSLATE("Slate"), B_TRANSLATE("Slate"),
kWhite, kWhite,
{ 20, 20, 28, 255 }, { 20, 20, 28, 255 },
@@ -80,31 +80,31 @@ const struct color_schema kColorSlate = {
{ 70, 70, 70, 255 }, { 70, 70, 70, 255 },
}; };
struct color_schema gCustomSchema = { struct color_scheme gCustomColorScheme = {
B_TRANSLATE("Custom") B_TRANSLATE("Custom")
}; };
const color_schema* gPredefinedSchemas[] = { const color_scheme* gPredefinedColorSchemes[] = {
&kColorDefault, &kColorSchemeDefault,
&kColorBlue, &kColorSchemeBlue,
&kColorMidnight, &kColorSchemeMidnight,
&kColorProfessional, &kColorSchemeProfessional,
&kColorRetroTerminal, &kColorSchemeRetro,
&kColorSlate, &kColorSchemeSlate,
&gCustomSchema, &gCustomColorScheme,
NULL NULL
}; };
bool bool
color_schema::operator==(const color_schema& schema) color_scheme::operator==(const color_scheme& scheme)
{ {
if (text_fore_color == schema.text_fore_color if (text_fore_color == scheme.text_fore_color
&& text_back_color == schema.text_back_color && text_back_color == scheme.text_back_color
&& cursor_fore_color == schema.cursor_fore_color && cursor_fore_color == scheme.cursor_fore_color
&& cursor_back_color == schema.cursor_back_color && cursor_back_color == scheme.cursor_back_color
&& select_fore_color == schema.select_fore_color && select_fore_color == scheme.select_fore_color
&& select_back_color == schema.select_back_color) && select_back_color == scheme.select_back_color)
return true; return true;
return false; return false;
+5 -5
View File
@@ -8,7 +8,8 @@
#include <InterfaceDefs.h> #include <InterfaceDefs.h>
struct color_schema {
struct color_scheme {
const char* name; const char* name;
rgb_color text_fore_color; rgb_color text_fore_color;
rgb_color text_back_color; rgb_color text_back_color;
@@ -16,12 +17,11 @@ struct color_schema {
rgb_color cursor_back_color; rgb_color cursor_back_color;
rgb_color select_fore_color; rgb_color select_fore_color;
rgb_color select_back_color; rgb_color select_back_color;
bool operator==(const color_schema& color); bool operator==(const color_scheme& color);
}; };
extern color_scheme gCustomColorScheme;
extern color_schema gCustomSchema; extern const color_scheme* gPredefinedColorSchemes[];
extern const color_schema* gPredefinedSchemas[];
#endif // _COLORS_H #endif // _COLORS_H
+1 -1
View File
@@ -839,7 +839,7 @@ TermWindow::MessageReceived(BMessage *message)
break; break;
case MSG_COLOR_CHANGED: case MSG_COLOR_CHANGED:
case MSG_COLOR_SCHEMA_CHANGED: case MSG_COLOR_SCHEME_CHANGED:
{ {
_SetTermColors(_ActiveTermViewContainerView()); _SetTermColors(_ActiveTermViewContainerView());
_ActiveTermViewContainerView()->Invalidate(); _ActiveTermViewContainerView()->Invalidate();