Ticket #199: 199-2.patch
File 199-2.patch, 13.1 KB (added by , 18 years ago) |
---|
-
src/apps/terminal/TermWindow.cpp
27 27 #include "CodeConv.h" 28 28 #include "ColorWindow.h" 29 29 #include "MenuUtil.h" 30 #include "FindDlg.h" 30 31 #include "PrefDlg.h" 31 32 #include "PrefView.h" 32 33 #include "PrefHandler.h" … … 219 220 fEditmenu->AddSeparatorItem (); 220 221 fEditmenu->AddItem (new BMenuItem ("Select All", new BMessage (B_SELECT_ALL), 'A')); 221 222 fEditmenu->AddItem (new BMenuItem ("Clear All", new BMessage (MENU_CLEAR_ALL), 'L')); 223 fEditmenu->AddSeparatorItem (); 224 fEditmenu->AddItem (new BMenuItem ("Find", new BMessage (MENU_FIND_STRING),'F')); 225 fEditmenu->AddItem (new BMenuItem ("Find Again", new BMessage (MENU_FIND_AGAIN), ']')); 222 226 223 /*224 // TODO: Implement Finding225 fEditmenu->AddSeparatorItem ();226 fEditmenu->AddItem (new BMenuItem ("Find", new BMessage (MENU_FIND_STRING),'F'));227 fEditmenu->AddItem (new BMenuItem ("Find Again", new BMessage (MENU_FIND_AGAIN), ']'));228 */229 227 fMenubar->AddItem (fEditmenu); 230 228 231 229 // Make Help Menu. … … 277 275 BRect r; 278 276 BFont halfFont; 279 277 BFont fullFont; 278 BString findstring; 279 bool forwardsearch, matchcase, matchword, regexp, findresult; 280 280 281 281 switch (message->what) { 282 282 case MENU_SWITCH_TERM: { … … 303 303 fPrefWindow = NULL; 304 304 break; 305 305 } 306 case MENU_FIND_STRING: { 307 if (!fFindPanel) { 308 BRect r = Frame(); 309 r.left += 20; 310 r.top += 20; 311 r.right = r.left + 260; 312 r.bottom = r.top + 220; 313 fFindPanel = new FindDlg(r, this); 314 } 315 else 316 fFindPanel->Activate(); 317 break; 318 } 319 case MSG_FIND: { 320 fFindPanel->QuitRequested(); 321 message->FindString("findstring", &findstring); 322 message->FindBool("forwardsearch", &forwardsearch); 323 message->FindBool("matchcase", &matchcase); 324 message->FindBool("matchword", &matchword); 325 message->FindBool("regexp", ®exp); 326 findresult = fTermView->Find(findstring, forwardsearch, matchcase, matchword, regexp); 327 if (!findresult) 328 ; //Display error 329 break; 330 } 331 case MSG_FIND_CLOSED: { 332 fFindPanel = NULL; 333 break; 334 } 306 335 case MENU_FILE_QUIT: { 307 336 be_app->PostMessage(B_QUIT_REQUESTED); 308 337 break; … … 522 551 { 523 552 delete fTermParse; 524 553 delete fCodeConv; 525 if(fPrefWindow) fPrefWindow->PostMessage (B_QUIT_REQUESTED); 526 be_app->PostMessage (B_QUIT_REQUESTED, be_app); 554 if (fPrefWindow) fPrefWindow->PostMessage (B_QUIT_REQUESTED); 555 if (fFindPanel) fFindPanel->PostMessage(B_QUIT_REQUESTED); 556 557 be_app->PostMessage (B_QUIT_REQUESTED, be_app); 527 558 BWindow::Quit (); 528 559 } 529 560 -
src/apps/terminal/TermView.cpp
2248 2248 *height = fFontHeight; 2249 2249 } 2250 2250 2251 // Find a string, and select it if found 2252 bool 2253 TermView::Find (const BString &str, bool forwardSearch, bool matchCase, bool matchWord, bool regexp) 2254 { 2255 uchar buffercontent[fTextBuffer->GetArraySize() + 1]; 2256 ushort attr; 2257 int count; 2258 2259 //Get the buffer contents 2260 count = fTextBuffer->GetString(0, 0, fTextBuffer->GetArraySize(), buffercontent, &attr); 2261 2262 BString buffer((const char *)&buffercontent); 2263 2264 return false; 2265 } 2266 2251 2267 // Send DrawRect data to Draw Engine thread. 2252 2268 inline void 2253 2269 TermView::SendDataToDrawEngine(int x1, int y1, int x2, int y2) -
src/apps/terminal/Changelog
13 13 Terminal window supports scrolling 14 14 15 15 TODO: 16 Make a Jamfile17 Make Find work18 16 Fix titling (-t works already, its the Terminal 1, 2, 3, etc...) 19 17 Fix the Colour menu 20 18 Move Fonts and font sizes to the "Right Place" 21 19 Kill the Preferences Panel 22 Move to .rdef source resources -
src/apps/terminal/FindDlg.h
33 33 #include <Window.h> 34 34 #include <TextView.h> 35 35 36 #include "CurPos.h" 37 36 const ulong MSG_FIND = 'msgf'; 38 37 const ulong MSG_FIND_START = 'msac'; 38 const ulong MSG_FIND_CLOSED = 'mfcl'; 39 39 40 40 class BRect; 41 41 class BBitmap; 42 42 class BMessage; 43 43 class TermWindow; 44 class BTextControl; 45 class BRadioButton; 46 class BCheckBox; 44 47 45 48 class FindDlg : public BWindow 46 49 { 47 50 public: 48 FindDlg(BRect frame, TermWindow *win);49 51 FindDlg (BRect frame, TermWindow *win); 52 ~FindDlg (); 50 53 51 void Find (CurPos *start, CurPos *end); 54 private: 55 virtual void Quit (void); 56 void MessageReceived (BMessage *msg); 52 57 53 private: 54 virtual void Quit (void); 55 56 BString *fFindString; 57 TermWindow *fWindow; 58 void SendFindMessage (void); 58 59 60 BView *fFindView; 61 BTextControl *fFindLabel; 62 BRadioButton *fTextRadio; 63 BRadioButton *fSelectionRadio; 64 BBox *fSeparator; 65 BCheckBox *fForwardSearchBox; 66 BCheckBox *fMatchCaseBox; 67 BCheckBox *fMatchWordBox; 68 BCheckBox *fRegexpBox; 69 BButton *fFindButton; 70 71 BString *fFindString; 72 TermWindow *fWindow; 59 73 }; 60 74 61 75 -
src/apps/terminal/Jamfile
7 7 AppearPrefView.cpp 8 8 CodeConv.cpp 9 9 CurPos.cpp 10 FindDlg.cpp 10 11 MenuUtil.cpp 11 12 Terminal.cpp 12 13 PrefDlg.cpp -
src/apps/terminal/FindDlg.cpp
31 31 #include <Window.h> 32 32 #include <Rect.h> 33 33 #include <TextControl.h> 34 #include <Box.h> 35 #include <CheckBox.h> 34 36 #include <Button.h> 37 #include <RadioButton.h> 35 38 #include <Message.h> 36 39 #include <stdio.h> 37 40 #include <File.h> 38 41 #include <String.h> 39 42 43 #include "TermWindow.h" 40 44 #include "FindDlg.h" 41 45 #include "TermApp.h" 42 46 #include "MenuUtil.h" … … 44 48 45 49 // message define 46 50 47 const uint32 FPANEL_HIDE = 'Fhid';51 const uint32 MSG_FIND_HIDE = 'Fhid'; 48 52 49 53 ////////////////////////////////////////////////////////////////////////////// 50 54 // FindDlg 51 55 // Constructer 52 56 ////////////////////////////////////////////////////////////////////////////// 53 57 FindDlg::FindDlg (BRect frame, TermWindow *win) 54 55 58 : BWindow(frame, "Find", 59 B_FLOATING_WINDOW, B_NOT_RESIZABLE|B_NOT_ZOOMABLE) 56 60 { 57 PrefHandler title;58 LoadLocaleFile (&title);61 fWindow = win; 62 SetTitle("Find"); 59 63 60 fWindow = win; 61 this->SetTitle (title.getString ("Find")); 64 AddShortcut ((ulong)'W', (ulong)B_COMMAND_KEY, new BMessage (MSG_FIND_HIDE)); 62 65 63 AddShortcut ((ulong)'Q', (ulong)B_COMMAND_KEY, new BMessage (FPANEL_HIDE)); 64 AddShortcut ((ulong)'W', (ulong)B_COMMAND_KEY, new BMessage (FPANEL_HIDE)); 66 //Build up view 67 fFindView = new BView(Bounds(), "FindView", B_FOLLOW_ALL, B_WILL_DRAW); 68 fFindView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 69 AddChild(fFindView); 65 70 66 BRect r (10, 10, 120, 20); 67 68 BTextControl *text_ctl = new BTextControl (r, "text", NULL, NULL, NULL); 69 AddChild (text_ctl); 71 font_height height; 72 fFindView->GetFontHeight(&height); 73 float lineHeight = height.ascent + height.descent + height.leading; 70 74 71 r.Set (100, 40, 130, 60); 72 BButton *button = new BButton (r, NULL, "Find", new BMessage (MSG_FIND_START)); 73 AddChild (button); 74 75 //These labels are from the bottom up 76 float buttonsTop = frame.Height() - 19 - lineHeight; 77 float regexpBottom = buttonsTop - 4; 78 float regexpTop = regexpBottom - lineHeight - 8; 79 float matchwordBottom = regexpTop - 4; 80 float matchwordTop = matchwordBottom - lineHeight - 8; 81 float matchcaseBottom = matchwordTop - 4; 82 float matchcaseTop = matchcaseBottom - lineHeight - 8; 83 float forwardsearchBottom = matchcaseTop - 4; 84 float forwardsearchTop = forwardsearchBottom - lineHeight - 10; 85 86 //These things are calculated from the top 87 float textRadioTop = 12; 88 float textRadioBottom = textRadioTop + 2 + lineHeight + 2 + 1; 89 float textRadioRight = fFindView->StringWidth("Use Text: ") + 30; 90 float selectionRadioTop = textRadioBottom + 4; 91 float selectionRadioBottom = selectionRadioTop + lineHeight + 8; 92 93 //Divider 94 float dividerHeight = (selectionRadioBottom + forwardsearchTop) / 2; 95 96 //Button Coordinates 97 float searchbuttonLeft = (frame.Width() - fFindView->StringWidth("Find") - 60) / 2; 98 float searchbuttonRight = searchbuttonLeft + fFindView->StringWidth("Find") + 60; 99 100 //Build the Views 101 fTextRadio = new BRadioButton(BRect(14, textRadioTop, textRadioRight, textRadioBottom), 102 "fTextRadio", "Use Text: ", NULL); 103 fFindView->AddChild(fTextRadio); 104 105 fFindLabel = new BTextControl(BRect(textRadioRight + 4, textRadioTop, frame.Width() - 14, textRadioBottom), 106 "fFindLabel", "", "", NULL); 107 fFindLabel->SetDivider(0); 108 fFindView->AddChild(fFindLabel); 109 110 fTextRadio->SetValue(1); //enable first option 111 112 fSelectionRadio = new BRadioButton(BRect(14, selectionRadioTop, frame.Width() - 14, selectionRadioBottom), 113 "fSelectionRadio", "Use Selection", NULL); 114 fFindView->AddChild(fSelectionRadio); 115 116 fSeparator = new BBox(BRect(6, dividerHeight, frame.Width() - 6, dividerHeight + 1)); 117 fFindView->AddChild(fSeparator); 118 119 fForwardSearchBox = new BCheckBox(BRect(14, forwardsearchTop, frame.Width() - 14, forwardsearchBottom), 120 "fForwardSearchBox", "Search Forward", NULL); 121 fFindView->AddChild(fForwardSearchBox); 122 123 fMatchCaseBox = new BCheckBox(BRect(14, matchcaseTop, frame.Width() - 14, matchcaseBottom), 124 "fMatchCaseBox", "Match Case", NULL); 125 fFindView->AddChild(fMatchCaseBox); 126 127 fMatchWordBox = new BCheckBox(BRect(14, matchwordTop, frame.Width() - 14, matchwordBottom), 128 "fMatchWordBox", "Match Word", NULL); 129 fFindView->AddChild(fMatchWordBox); 130 131 fRegexpBox = new BCheckBox(BRect(14, regexpTop, frame.Width() - 14, regexpBottom), 132 "fRegexpBox", "Use Regular Expression", NULL); 133 fFindView->AddChild(fRegexpBox); 134 135 fFindButton = new BButton(BRect(searchbuttonLeft, buttonsTop, searchbuttonRight, frame.Height() - 14), 136 "fFindButton", "Find", new BMessage(MSG_FIND)); 137 fFindButton->MakeDefault(true); 138 fFindView->AddChild(fFindButton); 139 140 Show(); 75 141 } 76 142 77 143 FindDlg::~FindDlg (void) … … 80 146 } 81 147 82 148 void 149 FindDlg::MessageReceived (BMessage *msg) 150 { 151 switch (msg->what) { 152 case B_QUIT_REQUESTED: 153 Quit(); 154 break; 155 case MSG_FIND: 156 SendFindMessage(); 157 break; 158 case MSG_FIND_HIDE: 159 Quit(); 160 break; 161 default: 162 BWindow::MessageReceived(msg); 163 break; 164 } 165 } 166 167 void 83 168 FindDlg::Quit (void) 84 169 { 85 BWindow::Quit (); 170 fWindow->PostMessage(MSG_FIND_CLOSED); 171 BWindow::Quit (); 86 172 } 87 173 174 void 175 FindDlg::SendFindMessage (void) 176 { 177 BMessage message(MSG_FIND); 178 179 //Add the search string 180 message.AddString("findstring", fFindLabel->Text()); 181 182 //Add the other parameters 183 message.AddBool("usetext", fTextRadio->Value() == B_CONTROL_ON); 184 message.AddBool("forwardsearch", fForwardSearchBox->Value() == B_CONTROL_ON); 185 message.AddBool("matchcase", fMatchCaseBox->Value() == B_CONTROL_ON); 186 message.AddBool("matchword", fMatchWordBox->Value() == B_CONTROL_ON); 187 message.AddBool("regexp", fRegexpBox->Value() == B_CONTROL_ON); 188 189 fWindow->PostMessage(MSG_FIND); 190 } -
src/apps/terminal/TermView.h
184 184 void ScrollScreenDraw (void); 185 185 void GetFrameSize (float *width, float *height); 186 186 void GetFontInfo (int *, int*); 187 bool Find(const BString &str, bool forwardSearch, bool matchCase, bool matchWord, bool regexp); 187 188 188 189 /* 189 190 * PRIVATE MEMBER. -
src/apps/terminal/Constants.h
1 /*Terminal: constants*/2 #ifndef CONSTANTS_H3 #define CONSTANTS_H4 5 #include <GraphicsDefs.h>6 #include <SupportDefs.h>7 8 #define APP_SIGNATURE "application/x-vnd.obos.terminal"9 10 const float TEXT_INSET = 3.0;11 12 // Application messages13 14 const uint32 OPEN_TERMINAL ='OTRM';15 16 // Messages for menu commands17 18 // Terminal19 const uint32 TERMINAL_SWITCH_TERMINAL ='TSWT';20 const uint32 TERMINAL_START_NEW_TERMINAL='TSNT';21 const uint32 TERMINAL_LOG_TO_FILE ='TLTF';22 // Edit23 const uint32 EDIT_WRITE_SELECTION ='EWSL';24 const uint32 EDIT_CLEAR_ALL ='ECLA';25 const uint32 EDIT_FIND ='EFND';26 const uint32 EDIT_FIND_BACKWARD ='EFBK';27 const uint32 EDIT_FIND_FORWARD ='EFFD';28 // Settings29 const uint32 SETTINGS_WINDOW_SIZE ='SWSZ';30 const uint32 SETTINGS_FONT ='SFNT';31 const uint32 SETTINGS_FONT_SIZE ='SFSZ';32 const uint32 SETTINGS_FONT_ENCODING ='SFEN';33 const uint32 SETTINGS_TAB_WIDTH ='STBW';34 const uint32 SETTINGS_COLOR ='SCLR';35 const uint32 SETTINGS_SAVE_AS_DEFAULT ='SSAD';36 const uint32 SETTINGS_SAVE_AS_SETTINGS ='SSAS';37 38 // Edit menu toggle39 const uint32 ENABLE_ITEMS ='EDON';40 const uint32 DISABLE_ITEMS ='EDOF';41 42 #endif // CONSTANTS_H