[haiku-commits] r33428 - haiku/trunk/src/apps/terminal

  • From: leavengood@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 4 Oct 2009 23:21:40 +0200 (CEST)

Author: leavengood
Date: 2009-10-04 23:21:40 +0200 (Sun, 04 Oct 2009)
New Revision: 33428
Changeset: http://dev.haiku-os.org/changeset/33428/haiku

Modified:
   haiku/trunk/src/apps/terminal/AppearPrefView.cpp
   haiku/trunk/src/apps/terminal/FindWindow.cpp
   haiku/trunk/src/apps/terminal/TermApp.cpp
   haiku/trunk/src/apps/terminal/TermWindow.cpp
Log:
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


Modified: haiku/trunk/src/apps/terminal/AppearPrefView.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/AppearPrefView.cpp    2009-10-04 20:52:04 UTC 
(rev 33427)
+++ haiku/trunk/src/apps/terminal/AppearPrefView.cpp    2009-10-04 21:21:40 UTC 
(rev 33428)
@@ -24,32 +24,7 @@
 #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,
                BMessenger messenger)
        : PrefView(frame, name),
@@ -216,6 +191,32 @@
 }
 
 
+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 *
 AppearancePrefView::_MakeFontMenu(uint32 command, const char *defaultFontName)
 {

Modified: haiku/trunk/src/apps/terminal/FindWindow.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/FindWindow.cpp        2009-10-04 20:52:04 UTC 
(rev 33427)
+++ haiku/trunk/src/apps/terminal/FindWindow.cpp        2009-10-04 21:21:40 UTC 
(rev 33428)
@@ -49,7 +49,8 @@
        //These things are calculated from the top
        float textRadioTop = 12;
        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 selectionRadioBottom = selectionRadioTop + lineHeight + 8;
 
@@ -61,7 +62,7 @@
        float searchButtonRight = searchButtonLeft + 
fFindView->StringWidth("Find") + 60;
 
        //Build the Views
-       fTextRadio = new BRadioButton(BRect(14, textRadioTop, textRadioRight, 
textRadioBottom),
+       fTextRadio = new BRadioButton(BRect(textRadioLeft, textRadioTop, 
textRadioRight, textRadioBottom),
                "fTextRadio", "Use Text: ", NULL);
        fFindView->AddChild(fTextRadio);
 
@@ -160,6 +161,8 @@
                message.AddBool("findselection", true);
 
        //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("forwardsearch", fForwardSearchBox->Value() == 
B_CONTROL_ON);
        message.AddBool("matchcase", fMatchCaseBox->Value() == B_CONTROL_ON);
@@ -167,3 +170,4 @@
 
        fFindDlgMessenger.SendMessage(&message);
 }
+

Modified: haiku/trunk/src/apps/terminal/TermApp.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/TermApp.cpp   2009-10-04 20:52:04 UTC (rev 
33427)
+++ haiku/trunk/src/apps/terminal/TermApp.cpp   2009-10-04 21:21:40 UTC (rev 
33428)
@@ -129,10 +129,11 @@
 void
 TermApp::AboutRequested()
 {
+       // used spaces instead of tabs to avoid Murai's name being wrapped
        BAlert *alert = new BAlert("about", "Terminal\n"
-               "\twritten by Kazuho Okui and Takashi Murai\n"
-               "\tupdated by Kian Duffy and others\n\n"
-               "\tCopyright " B_UTF8_COPYRIGHT "2003-2008, Haiku.\n", "Ok");
+               "    written by Kazuho Okui and Takashi Murai\n"
+               "    updated by Kian Duffy and others\n\n"
+               "    Copyright " B_UTF8_COPYRIGHT "2003-2008, Haiku.\n", "Ok");
        BTextView *view = alert->TextView();
        
        view->SetStylable(true);

Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/TermWindow.cpp        2009-10-04 20:52:04 UTC 
(rev 33427)
+++ haiku/trunk/src/apps/terminal/TermWindow.cpp        2009-10-04 21:21:40 UTC 
(rev 33428)
@@ -416,6 +416,7 @@
                        break;
 
                case MSG_FIND:
+               {
                        fFindPanel->PostMessage(B_QUIT_REQUESTED);
                        message->FindBool("findselection", &fFindSelection);
                        if (!fFindSelection)
@@ -424,8 +425,10 @@
                                _ActiveTermView()->GetSelection(fFindString);
 
                        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);
+                               
                                alert->Go();
                                fFindPreviousMenuItem->SetEnabled(false);
                                fFindNextMenuItem->SetEnabled(false);
@@ -438,7 +441,7 @@
                        findresult = _ActiveTermView()->Find(fFindString, 
fForwardSearch, fMatchCase, fMatchWord);
 
                        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);
                                alert->SetShortcut(0, B_ESCAPE);
                                alert->Go();
@@ -451,6 +454,7 @@
                        fFindPreviousMenuItem->SetEnabled(true);
                        fFindNextMenuItem->SetEnabled(true);
                        break;
+               }
 
                case MENU_FIND_NEXT:
                case MENU_FIND_PREVIOUS:


Other related posts: