A patch from Caitlin Shaw (aka rogueeve) to fix #4715, some Terminal
improvements: * fixed text for "Use Text" radio button in Find dialog being cut off * more user friendly error messages for Find dialog: "no search string" becomes "No search string was entered.", or "Nothing is selected." as appropriate. * Preferences dialog opens unacceptably slow when a larger number of fonts are installed due to AppearPrefView's "IsFontUsuable" routine. But was able to cut opening time by about half with a minor optimization to the loop. * Fixed an ugly word-wrap of Takashi Murai's name in About dialog git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33428 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -24,31 +24,6 @@
|
|||||||
#include "TermConst.h"
|
#include "TermConst.h"
|
||||||
|
|
||||||
|
|
||||||
static bool
|
|
||||||
IsFontUsable(const BFont &font)
|
|
||||||
{
|
|
||||||
// TODO: If BFont::IsFullAndHalfFixed() was implemented, we could
|
|
||||||
// use that. But I don't think it's easily implementable using
|
|
||||||
// Freetype.
|
|
||||||
|
|
||||||
if (font.IsFixed())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
bool widthOk = true;
|
|
||||||
int lastWidth = 0;
|
|
||||||
char buffer[2] = {0, 0};
|
|
||||||
for (int c = 0x20 ; c <= 0x7e; c++){
|
|
||||||
buffer[0] = c;
|
|
||||||
|
|
||||||
int width = (int)ceilf(font.StringWidth(buffer));
|
|
||||||
if (c > 0x20 && width != lastWidth)
|
|
||||||
widthOk = false;
|
|
||||||
lastWidth = width;
|
|
||||||
}
|
|
||||||
|
|
||||||
return widthOk;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AppearancePrefView::AppearancePrefView(BRect frame, const char *name,
|
AppearancePrefView::AppearancePrefView(BRect frame, const char *name,
|
||||||
BMessenger messenger)
|
BMessenger messenger)
|
||||||
@@ -216,6 +191,32 @@ AppearancePrefView::MessageReceived(BMessage *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool
|
||||||
|
IsFontUsable(const BFont &font)
|
||||||
|
{
|
||||||
|
// TODO: If BFont::IsFullAndHalfFixed() was implemented, we could
|
||||||
|
// use that. But I don't think it's easily implementable using
|
||||||
|
// Freetype.
|
||||||
|
|
||||||
|
if (font.IsFixed())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// manually check if all applicable chars are the same width
|
||||||
|
char buffer[2] = { ' ', 0 };
|
||||||
|
int firstWidth = (int)ceilf(font.StringWidth(buffer));
|
||||||
|
|
||||||
|
for (int c = ' '+1; c <= 0x7e; c++) {
|
||||||
|
buffer[0] = c;
|
||||||
|
int width = (int)ceilf(font.StringWidth(buffer));
|
||||||
|
|
||||||
|
if (width != firstWidth)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BMenu *
|
BMenu *
|
||||||
AppearancePrefView::_MakeFontMenu(uint32 command, const char *defaultFontName)
|
AppearancePrefView::_MakeFontMenu(uint32 command, const char *defaultFontName)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ FindWindow::FindWindow (BRect frame, BMessenger messenger , BString &str,
|
|||||||
//These things are calculated from the top
|
//These things are calculated from the top
|
||||||
float textRadioTop = 12;
|
float textRadioTop = 12;
|
||||||
float textRadioBottom = textRadioTop + 2 + lineHeight + 2 + 1;
|
float textRadioBottom = textRadioTop + 2 + lineHeight + 2 + 1;
|
||||||
float textRadioRight = fFindView->StringWidth("Use Text: ") + 30;
|
float textRadioLeft = 14;
|
||||||
|
float textRadioRight = textRadioLeft + fFindView->StringWidth("Use Text: ") + 30;
|
||||||
float selectionRadioTop = textRadioBottom + 4;
|
float selectionRadioTop = textRadioBottom + 4;
|
||||||
float selectionRadioBottom = selectionRadioTop + lineHeight + 8;
|
float selectionRadioBottom = selectionRadioTop + lineHeight + 8;
|
||||||
|
|
||||||
@@ -61,7 +62,7 @@ FindWindow::FindWindow (BRect frame, BMessenger messenger , BString &str,
|
|||||||
float searchButtonRight = searchButtonLeft + fFindView->StringWidth("Find") + 60;
|
float searchButtonRight = searchButtonLeft + fFindView->StringWidth("Find") + 60;
|
||||||
|
|
||||||
//Build the Views
|
//Build the Views
|
||||||
fTextRadio = new BRadioButton(BRect(14, textRadioTop, textRadioRight, textRadioBottom),
|
fTextRadio = new BRadioButton(BRect(textRadioLeft, textRadioTop, textRadioRight, textRadioBottom),
|
||||||
"fTextRadio", "Use Text: ", NULL);
|
"fTextRadio", "Use Text: ", NULL);
|
||||||
fFindView->AddChild(fTextRadio);
|
fFindView->AddChild(fTextRadio);
|
||||||
|
|
||||||
@@ -160,6 +161,8 @@ FindWindow::_SendFindMessage()
|
|||||||
message.AddBool("findselection", true);
|
message.AddBool("findselection", true);
|
||||||
|
|
||||||
//Add the other parameters
|
//Add the other parameters
|
||||||
|
// TODO: "usetext" is never checked for elsewhere and seems redundant with
|
||||||
|
// "findselection", why is it here?
|
||||||
message.AddBool("usetext", fTextRadio->Value() == B_CONTROL_ON);
|
message.AddBool("usetext", fTextRadio->Value() == B_CONTROL_ON);
|
||||||
message.AddBool("forwardsearch", fForwardSearchBox->Value() == B_CONTROL_ON);
|
message.AddBool("forwardsearch", fForwardSearchBox->Value() == B_CONTROL_ON);
|
||||||
message.AddBool("matchcase", fMatchCaseBox->Value() == B_CONTROL_ON);
|
message.AddBool("matchcase", fMatchCaseBox->Value() == B_CONTROL_ON);
|
||||||
@@ -167,3 +170,4 @@ FindWindow::_SendFindMessage()
|
|||||||
|
|
||||||
fFindDlgMessenger.SendMessage(&message);
|
fFindDlgMessenger.SendMessage(&message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,10 +129,11 @@ TermApp::Quit()
|
|||||||
void
|
void
|
||||||
TermApp::AboutRequested()
|
TermApp::AboutRequested()
|
||||||
{
|
{
|
||||||
|
// used spaces instead of tabs to avoid Murai's name being wrapped
|
||||||
BAlert *alert = new BAlert("about", "Terminal\n"
|
BAlert *alert = new BAlert("about", "Terminal\n"
|
||||||
"\twritten by Kazuho Okui and Takashi Murai\n"
|
" written by Kazuho Okui and Takashi Murai\n"
|
||||||
"\tupdated by Kian Duffy and others\n\n"
|
" updated by Kian Duffy and others\n\n"
|
||||||
"\tCopyright " B_UTF8_COPYRIGHT "2003-2008, Haiku.\n", "Ok");
|
" Copyright " B_UTF8_COPYRIGHT "2003-2008, Haiku.\n", "Ok");
|
||||||
BTextView *view = alert->TextView();
|
BTextView *view = alert->TextView();
|
||||||
|
|
||||||
view->SetStylable(true);
|
view->SetStylable(true);
|
||||||
|
|||||||
@@ -416,6 +416,7 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_FIND:
|
case MSG_FIND:
|
||||||
|
{
|
||||||
fFindPanel->PostMessage(B_QUIT_REQUESTED);
|
fFindPanel->PostMessage(B_QUIT_REQUESTED);
|
||||||
message->FindBool("findselection", &fFindSelection);
|
message->FindBool("findselection", &fFindSelection);
|
||||||
if (!fFindSelection)
|
if (!fFindSelection)
|
||||||
@@ -424,8 +425,10 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
_ActiveTermView()->GetSelection(fFindString);
|
_ActiveTermView()->GetSelection(fFindString);
|
||||||
|
|
||||||
if (fFindString.Length() == 0) {
|
if (fFindString.Length() == 0) {
|
||||||
BAlert *alert = new BAlert("find failed", "No search string.", "Okay", NULL,
|
const char *errorMsg = (!fFindSelection) ? "No search string was entered." : "Nothing is selected.";
|
||||||
|
BAlert *alert = new BAlert("Find failed", errorMsg, "Ok", NULL,
|
||||||
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||||
|
|
||||||
alert->Go();
|
alert->Go();
|
||||||
fFindPreviousMenuItem->SetEnabled(false);
|
fFindPreviousMenuItem->SetEnabled(false);
|
||||||
fFindNextMenuItem->SetEnabled(false);
|
fFindNextMenuItem->SetEnabled(false);
|
||||||
@@ -438,7 +441,7 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
findresult = _ActiveTermView()->Find(fFindString, fForwardSearch, fMatchCase, fMatchWord);
|
findresult = _ActiveTermView()->Find(fFindString, fForwardSearch, fMatchCase, fMatchWord);
|
||||||
|
|
||||||
if (!findresult) {
|
if (!findresult) {
|
||||||
BAlert *alert = new BAlert("find failed", "Not Found.", "Okay", NULL,
|
BAlert *alert = new BAlert("Find failed", "Text not found.", "Ok", NULL,
|
||||||
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||||
alert->SetShortcut(0, B_ESCAPE);
|
alert->SetShortcut(0, B_ESCAPE);
|
||||||
alert->Go();
|
alert->Go();
|
||||||
@@ -451,6 +454,7 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
fFindPreviousMenuItem->SetEnabled(true);
|
fFindPreviousMenuItem->SetEnabled(true);
|
||||||
fFindNextMenuItem->SetEnabled(true);
|
fFindNextMenuItem->SetEnabled(true);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case MENU_FIND_NEXT:
|
case MENU_FIND_NEXT:
|
||||||
case MENU_FIND_PREVIOUS:
|
case MENU_FIND_PREVIOUS:
|
||||||
|
|||||||
Reference in New Issue
Block a user