Ticket #4715: rogueeveTerminalPatches4715

File rogueeveTerminalPatches4715, 6.6 KB (added by rogueeve, 15 years ago)
Line 
1Index: /boot/dev/haiku/src/apps/terminal/TermWindow.cpp
2===================================================================
3--- /boot/dev/haiku/src/apps/terminal/TermWindow.cpp (revision 33411)
4+++ /boot/dev/haiku/src/apps/terminal/TermWindow.cpp (working copy)
5@@ -414,31 +414,34 @@
6 else
7 fFindPanel->Activate();
8 break;
9-
10+
11 case MSG_FIND:
12+ {
13 fFindPanel->PostMessage(B_QUIT_REQUESTED);
14 message->FindBool("findselection", &fFindSelection);
15 if (!fFindSelection)
16 message->FindString("findstring", &fFindString);
17 else
18 _ActiveTermView()->GetSelection(fFindString);
19-
20+
21 if (fFindString.Length() == 0) {
22- BAlert *alert = new BAlert("find failed", "No search string.", "Okay", NULL,
23+ const char *errorMsg = (!fFindSelection) ? "No search string was entered." : "Nothing is selected.";
24+ BAlert *alert = new BAlert("Find failed", errorMsg, "Ok", NULL,
25 NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
26+
27 alert->Go();
28 fFindPreviousMenuItem->SetEnabled(false);
29 fFindNextMenuItem->SetEnabled(false);
30 break;
31 }
32-
33+
34 message->FindBool("forwardsearch", &fForwardSearch);
35 message->FindBool("matchcase", &fMatchCase);
36 message->FindBool("matchword", &fMatchWord);
37 findresult = _ActiveTermView()->Find(fFindString, fForwardSearch, fMatchCase, fMatchWord);
38-
39+
40 if (!findresult) {
41- BAlert *alert = new BAlert("find failed", "Not Found.", "Okay", NULL,
42+ BAlert *alert = new BAlert("Find failed", "Text not found.", "Ok", NULL,
43 NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
44 alert->SetShortcut(0, B_ESCAPE);
45 alert->Go();
46@@ -446,12 +449,13 @@
47 fFindNextMenuItem->SetEnabled(false);
48 break;
49 }
50-
51+
52 // Enable the menu items Find Next and Find Previous
53 fFindPreviousMenuItem->SetEnabled(true);
54 fFindNextMenuItem->SetEnabled(true);
55 break;
56-
57+ }
58+
59 case MENU_FIND_NEXT:
60 case MENU_FIND_PREVIOUS:
61 findresult = _ActiveTermView()->Find(fFindString,
62Index: /boot/dev/haiku/src/apps/terminal/TermView.cpp
63===================================================================
64--- /boot/dev/haiku/src/apps/terminal/TermView.cpp (revision 33411)
65+++ /boot/dev/haiku/src/apps/terminal/TermView.cpp (working copy)
66@@ -1157,7 +1157,7 @@
67 fShell->Write(destBuffer, cnum);
68 return;
69 }
70-
71+
72 _ScrollTo(0, true);
73 fShell->Write(bytes, numBytes);
74 return;
75Index: /boot/dev/haiku/src/apps/terminal/FindWindow.cpp
76===================================================================
77--- /boot/dev/haiku/src/apps/terminal/FindWindow.cpp (revision 33411)
78+++ /boot/dev/haiku/src/apps/terminal/FindWindow.cpp (working copy)
79@@ -49,7 +49,8 @@
80 //These things are calculated from the top
81 float textRadioTop = 12;
82 float textRadioBottom = textRadioTop + 2 + lineHeight + 2 + 1;
83- float textRadioRight = fFindView->StringWidth("Use Text: ") + 30;
84+ float textRadioLeft = 14;
85+ float textRadioRight = textRadioLeft + fFindView->StringWidth("Use Text: ") + 30;
86 float selectionRadioTop = textRadioBottom + 4;
87 float selectionRadioBottom = selectionRadioTop + lineHeight + 8;
88
89@@ -61,7 +62,7 @@
90 float searchButtonRight = searchButtonLeft + fFindView->StringWidth("Find") + 60;
91
92 //Build the Views
93- fTextRadio = new BRadioButton(BRect(14, textRadioTop, textRadioRight, textRadioBottom),
94+ fTextRadio = new BRadioButton(BRect(textRadioLeft, textRadioTop, textRadioRight, textRadioBottom),
95 "fTextRadio", "Use Text: ", NULL);
96 fFindView->AddChild(fTextRadio);
97
98@@ -160,6 +161,8 @@
99 message.AddBool("findselection", true);
100
101 //Add the other parameters
102+ // TODO: "usetext" is never checked for elsewhere and seems redundant with
103+ // "findselection", why is it here?
104 message.AddBool("usetext", fTextRadio->Value() == B_CONTROL_ON);
105 message.AddBool("forwardsearch", fForwardSearchBox->Value() == B_CONTROL_ON);
106 message.AddBool("matchcase", fMatchCaseBox->Value() == B_CONTROL_ON);
107@@ -167,3 +170,4 @@
108
109 fFindDlgMessenger.SendMessage(&message);
110 }
111+
112Index: /boot/dev/haiku/src/apps/terminal/TermApp.cpp
113===================================================================
114--- /boot/dev/haiku/src/apps/terminal/TermApp.cpp (revision 33411)
115+++ /boot/dev/haiku/src/apps/terminal/TermApp.cpp (working copy)
116@@ -129,10 +129,11 @@
117 void
118 TermApp::AboutRequested()
119 {
120+ // used spaces instead of tabs to avoid Murai's name being wrapped
121 BAlert *alert = new BAlert("about", "Terminal\n"
122- "\twritten by Kazuho Okui and Takashi Murai\n"
123- "\tupdated by Kian Duffy and others\n\n"
124- "\tCopyright " B_UTF8_COPYRIGHT "2003-2008, Haiku.\n", "Ok");
125+ " written by Kazuho Okui and Takashi Murai\n"
126+ " updated by Kian Duffy and others\n\n"
127+ " Copyright " B_UTF8_COPYRIGHT "2003-2008, Haiku.\n", "Ok");
128 BTextView *view = alert->TextView();
129
130 view->SetStylable(true);
131Index: /boot/dev/haiku/src/apps/terminal/AppearPrefView.cpp
132===================================================================
133--- /boot/dev/haiku/src/apps/terminal/AppearPrefView.cpp (revision 33411)
134+++ /boot/dev/haiku/src/apps/terminal/AppearPrefView.cpp (working copy)
135@@ -24,32 +24,7 @@
136 #include "TermConst.h"
137
138
139-static bool
140-IsFontUsable(const BFont &font)
141-{
142- // TODO: If BFont::IsFullAndHalfFixed() was implemented, we could
143- // use that. But I don't think it's easily implementable using
144- // Freetype.
145
146- if (font.IsFixed())
147- return true;
148-
149- bool widthOk = true;
150- int lastWidth = 0;
151- char buffer[2] = {0, 0};
152- for (int c = 0x20 ; c <= 0x7e; c++){
153- buffer[0] = c;
154-
155- int width = (int)ceilf(font.StringWidth(buffer));
156- if (c > 0x20 && width != lastWidth)
157- widthOk = false;
158- lastWidth = width;
159- }
160-
161- return widthOk;
162-}
163-
164-
165 AppearancePrefView::AppearancePrefView(BRect frame, const char *name,
166 BMessenger messenger)
167 : PrefView(frame, name),
168@@ -216,13 +191,39 @@
169 }
170
171
172+static bool
173+IsFontUsable(const BFont &font)
174+{
175+ // TODO: If BFont::IsFullAndHalfFixed() was implemented, we could
176+ // use that. But I don't think it's easily implementable using
177+ // Freetype.
178+
179+ if (font.IsFixed())
180+ return true;
181+
182+ // manually check if all applicable chars are the same width
183+ char buffer[2] = { ' ', 0 };
184+ int firstWidth = (int)ceilf(font.StringWidth(buffer));
185+
186+ for (int c = ' '+1; c <= 0x7e; c++) {
187+ buffer[0] = c;
188+ int width = (int)ceilf(font.StringWidth(buffer));
189+
190+ if (width != firstWidth)
191+ return false;
192+ }
193+
194+ return true;
195+}
196+
197+
198 BMenu *
199 AppearancePrefView::_MakeFontMenu(uint32 command, const char *defaultFontName)
200 {
201 BPopUpMenu *menu = new BPopUpMenu("");
202 int32 numFamilies = count_font_families();
203 uint32 flags;
204-
205+
206 for (int32 i = 0; i < numFamilies; i++) {
207 font_family family;
208 if (get_font_family(i, &family, &flags) == B_OK) {