hrev44406 adds 2 changesets to branch 'master' old head: f081f8b731d7d7ca46c939ff07227fb46a279de1 new head: 48249b20646d5a6a58b084eee73827953df407ca ---------------------------------------------------------------------------- a736c8a: Patch by x-ist, thanks! Fixes non-terminating ReplaceAll, #8141. 48249b2: Stylefixes, no functional change. [ Humdinger <humdingerb@xxxxxxxxx> ] ---------------------------------------------------------------------------- 11 files changed, 58 insertions(+), 40 deletions(-) src/apps/stylededit/ColorMenuItem.cpp | 5 ++-- src/apps/stylededit/ColorMenuItem.h | 4 +-- src/apps/stylededit/Constants.h | 8 +++--- src/apps/stylededit/FindWindow.h | 5 ++-- src/apps/stylededit/ReplaceWindow.cpp | 2 +- src/apps/stylededit/ReplaceWindow.h | 6 ++--- src/apps/stylededit/StyledEditApp.cpp | 6 ++--- src/apps/stylededit/StyledEditView.cpp | 9 ++++--- src/apps/stylededit/StyledEditView.h | 6 ++--- src/apps/stylededit/StyledEditWindow.cpp | 34 ++++++++++++++++++-------- src/apps/stylededit/StyledEditWindow.h | 13 +++++----- ############################################################################ Commit: a736c8aa6bdaaba029f8f651f6018422697478e9 URL: http://cgit.haiku-os.org/haiku/commit/?id=a736c8a Author: Humdinger <humdingerb@xxxxxxxxx> Date: Wed Jul 25 16:48:24 2012 UTC Ticket: https://dev.haiku-os.org/ticket/8141 Patch by x-ist, thanks! Fixes non-terminating ReplaceAll, #8141. ---------------------------------------------------------------------------- diff --git a/src/apps/stylededit/StyledEditWindow.cpp b/src/apps/stylededit/StyledEditWindow.cpp index 3ac8541..37fa6ac 100644 --- a/src/apps/stylededit/StyledEditWindow.cpp +++ b/src/apps/stylededit/StyledEditWindow.cpp @@ -1408,7 +1408,7 @@ StyledEditWindow::_RevertToSaved() bool StyledEditWindow::_Search(BString string, bool caseSensitive, bool wrap, - bool backSearch) + bool backSearch, bool scrollToOccurence) { int32 start; int32 finish; @@ -1450,7 +1450,9 @@ StyledEditWindow::_Search(BString string, bool caseSensitive, bool wrap, if (start != B_ERROR) { finish = start + length; fTextView->Select(start, finish); - fTextView->ScrollToSelection(); + + if (scrollToOccurence) + fTextView->ScrollToSelection(); return true; } @@ -1501,17 +1503,28 @@ StyledEditWindow::_ReplaceAll(BString findThis, BString replaceWith, { bool first = true; fTextView->SetSuppressChanges(true); - while (_Search(findThis, caseSensitive, true, false)) { + + // start from the beginning of text + fTextView->Select(0,0); + + int32 start, finish; + + // iterate occurences of findThis without wrapping around + while (_Search(findThis, caseSensitive, false, false, false)) { if (first) { _UpdateCleanUndoRedoSaveRevert(); first = false; } - int32 start, finish; + fTextView->GetSelection(&start, &finish); - fTextView->Delete(start, start + findThis.Length()); fTextView->Insert(start, replaceWith.String(), replaceWith.Length()); + + // advance the caret behind the inserted text + start += replaceWith.Length(); + fTextView->Select(start, start); } + fTextView->ScrollToSelection(); fTextView->SetSuppressChanges(false); } diff --git a/src/apps/stylededit/StyledEditWindow.h b/src/apps/stylededit/StyledEditWindow.h index 241de30..d107917 100644 --- a/src/apps/stylededit/StyledEditWindow.h +++ b/src/apps/stylededit/StyledEditWindow.h @@ -57,7 +57,8 @@ private: status_t _LoadFile(entry_ref* ref); void _RevertToSaved(); bool _Search(BString searchFor, bool caseSensitive, - bool wrap, bool backSearch); + bool wrap, bool backSearch, + bool scrollToOccurence = true); void _FindSelection(); bool _Replace(BString findThis, BString replaceWith, bool caseSensitive, bool wrap, ############################################################################ Revision: hrev44406 Commit: 48249b20646d5a6a58b084eee73827953df407ca URL: http://cgit.haiku-os.org/haiku/commit/?id=48249b2 Author: Humdinger <humdingerb@xxxxxxxxx> Date: Wed Jul 25 17:16:11 2012 UTC Stylefixes, no functional change. ---------------------------------------------------------------------------- diff --git a/src/apps/stylededit/ColorMenuItem.cpp b/src/apps/stylededit/ColorMenuItem.cpp index 923bdcd..863a2af 100644 --- a/src/apps/stylededit/ColorMenuItem.cpp +++ b/src/apps/stylededit/ColorMenuItem.cpp @@ -11,7 +11,8 @@ #include <Message.h> -ColorMenuItem::ColorMenuItem(const char *label, rgb_color color, BMessage *message) +ColorMenuItem::ColorMenuItem(const char *label, rgb_color color, + BMessage *message) : BMenuItem(label, message, 0, 0), fItemColor(color) { @@ -21,7 +22,7 @@ ColorMenuItem::ColorMenuItem(const char *label, rgb_color color, BMessage *messa void ColorMenuItem::DrawContent() { - BMenu *menu = Menu(); + BMenu* menu = Menu(); if (menu) { rgb_color menuColor = menu->HighColor(); diff --git a/src/apps/stylededit/ColorMenuItem.h b/src/apps/stylededit/ColorMenuItem.h index 257d91c..45b4715 100644 --- a/src/apps/stylededit/ColorMenuItem.h +++ b/src/apps/stylededit/ColorMenuItem.h @@ -18,8 +18,8 @@ class BMessage; class ColorMenuItem: public BMenuItem { public: - ColorMenuItem(const char *label, rgb_color color, - BMessage *message); + ColorMenuItem(const char* label, rgb_color color, + BMessage* message); protected: virtual void DrawContent(); diff --git a/src/apps/stylededit/Constants.h b/src/apps/stylededit/Constants.h index cbd4776..7863a1a 100644 --- a/src/apps/stylededit/Constants.h +++ b/src/apps/stylededit/Constants.h @@ -54,10 +54,10 @@ const uint32 kMsgSetBold = 'Fbld'; // fontcolors const rgb_color BLACK = {0, 0, 0, 255}; const rgb_color RED = {255, 0, 0, 255}; -const rgb_color GREEN = {0, 255, 0, 255}; -const rgb_color BLUE = {0, 0, 255, 255}; -const rgb_color CYAN = {0, 255, 255, 255}; -const rgb_color MAGENTA = {255, 0, 255, 255}; +const rgb_color GREEN = {0, 255, 0, 255}; +const rgb_color BLUE = {0, 0, 255, 255}; +const rgb_color CYAN = {0, 255, 255, 255}; +const rgb_color MAGENTA = {255, 0, 255, 255}; const rgb_color YELLOW = {255, 255, 0, 255}; // "Document"-menu diff --git a/src/apps/stylededit/FindWindow.h b/src/apps/stylededit/FindWindow.h index f63dc87..e8720c8 100644 --- a/src/apps/stylededit/FindWindow.h +++ b/src/apps/stylededit/FindWindow.h @@ -20,8 +20,9 @@ class BTextControl; class FindWindow : public BWindow { public: - FindWindow(BRect frame, BHandler* handler, BString *searchString, - bool caseState, bool wrapState, bool backState); + FindWindow(BRect frame, BHandler* handler, + BString* searchString, bool caseState, + bool wrapState, bool backState); virtual void MessageReceived(BMessage* message); virtual void DispatchMessage(BMessage* message, BHandler* handler); diff --git a/src/apps/stylededit/ReplaceWindow.cpp b/src/apps/stylededit/ReplaceWindow.cpp index b35e28f..9b63c5b 100644 --- a/src/apps/stylededit/ReplaceWindow.cpp +++ b/src/apps/stylededit/ReplaceWindow.cpp @@ -29,7 +29,7 @@ #define B_TRANSLATION_CONTEXT "FindandReplaceWindow" ReplaceWindow::ReplaceWindow(BRect frame, BHandler* _handler, - BString* searchString, BString *replaceString, + BString* searchString, BString* replaceString, bool caseState, bool wrapState, bool backState) : BWindow(frame, "ReplaceWindow", B_MODAL_WINDOW, B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS, diff --git a/src/apps/stylededit/ReplaceWindow.h b/src/apps/stylededit/ReplaceWindow.h index bb51f05..ddcff4c 100644 --- a/src/apps/stylededit/ReplaceWindow.h +++ b/src/apps/stylededit/ReplaceWindow.h @@ -23,12 +23,12 @@ class BTextControl; class ReplaceWindow : public BWindow { public: - ReplaceWindow(BRect frame, BHandler *_handler, - BString *searchString, BString *replaceString, + ReplaceWindow(BRect frame, BHandler* _handler, + BString* searchString, BString* replaceString, bool caseState, bool wrapState, bool backState); virtual void MessageReceived(BMessage* message); - virtual void DispatchMessage(BMessage* message, BHandler *handler); + virtual void DispatchMessage(BMessage* message, BHandler* handler); private: void _SendMessage(uint32 what); diff --git a/src/apps/stylededit/StyledEditApp.cpp b/src/apps/stylededit/StyledEditApp.cpp index ff66954..49294e9 100644 --- a/src/apps/stylededit/StyledEditApp.cpp +++ b/src/apps/stylededit/StyledEditApp.cpp @@ -32,7 +32,7 @@ using namespace BPrivate; -BRect gWindowRect(7-15, 26-15, 507, 426); +BRect gWindowRect(7 - 15, 26 - 15, 507, 426); namespace @@ -117,8 +117,8 @@ StyledEditApp::StyledEditApp() name.Append(mime); name.Append(")"); } - BMenuItem* item = - new BMenuItem(name.String(), new BMessage(OPEN_AS_ENCODING)); + BMenuItem* item + = new BMenuItem(name.String(), new BMessage(OPEN_AS_ENCODING)); item->SetTarget(this); fOpenPanelEncodingMenu->AddItem(item); if (charset.GetFontID() == fOpenAsEncoding) diff --git a/src/apps/stylededit/StyledEditView.cpp b/src/apps/stylededit/StyledEditView.cpp index 66b871d..1025824 100644 --- a/src/apps/stylededit/StyledEditView.cpp +++ b/src/apps/stylededit/StyledEditView.cpp @@ -30,7 +30,8 @@ using namespace BPrivate; -StyledEditView::StyledEditView(BRect viewFrame, BRect textBounds, BHandler *handler) +StyledEditView::StyledEditView(BRect viewFrame, BRect textBounds, + BHandler* handler) : BTextView(viewFrame, "textview", textBounds, B_FOLLOW_ALL, B_FRAME_EVENTS | B_WILL_DRAW) { @@ -162,7 +163,7 @@ StyledEditView::GetEncoding() const const BCharacterSet* set = BCharacterSetRoster::FindCharacterSetByName(fEncoding.String()); - if(set != NULL) + if (set != NULL) return set->GetFontID(); return 0; @@ -181,8 +182,8 @@ StyledEditView::DeleteText(int32 start, int32 finish) void -StyledEditView::InsertText(const char *text, int32 length, int32 offset, - const text_run_array *runs) +StyledEditView::InsertText(const char* text, int32 length, int32 offset, + const text_run_array* runs) { if (!fSuppressChanges) fMessenger->SendMessage(TEXT_CHANGED); diff --git a/src/apps/stylededit/StyledEditView.h b/src/apps/stylededit/StyledEditView.h index 945f34d..b0482fb 100644 --- a/src/apps/stylededit/StyledEditView.h +++ b/src/apps/stylededit/StyledEditView.h @@ -23,14 +23,14 @@ class BPositionIO; class StyledEditView : public BTextView { public: StyledEditView(BRect viewframe, BRect textframe, - BHandler *handler); + BHandler* handler); virtual ~StyledEditView(); virtual void Select(int32 start, int32 finish); virtual void DeleteText(int32 start, int32 finish); virtual void FrameResized(float width, float height); - virtual void InsertText(const char *text, int32 length, int32 offset, - const text_run_array *runs = NULL); + virtual void InsertText(const char* text, int32 length, int32 offset, + const text_run_array* runs = NULL); void Reset(); void SetSuppressChanges(bool suppressChanges); diff --git a/src/apps/stylededit/StyledEditWindow.cpp b/src/apps/stylededit/StyledEditWindow.cpp index 37fa6ac..61e7c1a 100644 --- a/src/apps/stylededit/StyledEditWindow.cpp +++ b/src/apps/stylededit/StyledEditWindow.cpp @@ -862,7 +862,8 @@ StyledEditWindow::Print(const char* documentName) int32 currentLine = 0; while (currentLine < linesInDocument) { float currentHeight = 0; - while (currentHeight < printableRect.Height() && currentLine < linesInDocument) { + while (currentHeight < printableRect.Height() && currentLine + < linesInDocument) { currentHeight += fTextView->LineHeight(currentLine); if (currentHeight < printableRect.Height()) currentLine++; @@ -1027,8 +1028,8 @@ StyledEditWindow::_InitWindow(uint32 encoding) new BMessage(MENU_NEW), 'N')); menuItem->SetTarget(be_app); - menu->AddItem(menuItem = new BMenuItem(fRecentMenu = - new BMenu(B_TRANSLATE("Open" B_UTF8_ELLIPSIS)), + menu->AddItem(menuItem = new BMenuItem(fRecentMenu + = new BMenu(B_TRANSLATE("Open" B_UTF8_ELLIPSIS)), new BMessage(MENU_OPEN))); menuItem->SetShortcut('O', 0); menuItem->SetTarget(be_app); @@ -1042,8 +1043,8 @@ StyledEditWindow::_InitWindow(uint32 encoding) menuItem->SetShortcut('S', B_SHIFT_KEY); menuItem->SetEnabled(true); - menu->AddItem(fRevertItem = - new BMenuItem(B_TRANSLATE("Revert to saved" B_UTF8_ELLIPSIS), + menu->AddItem(fRevertItem + = new BMenuItem(B_TRANSLATE("Revert to saved" B_UTF8_ELLIPSIS), new BMessage(MENU_REVERT))); fRevertItem->SetEnabled(false); menu->AddItem(new BMenuItem(B_TRANSLATE("Close"), @@ -1505,7 +1506,7 @@ StyledEditWindow::_ReplaceAll(BString findThis, BString replaceWith, fTextView->SetSuppressChanges(true); // start from the beginning of text - fTextView->Select(0,0); + fTextView->Select(0, 0); int32 start, finish; diff --git a/src/apps/stylededit/StyledEditWindow.h b/src/apps/stylededit/StyledEditWindow.h index d107917..19f0ad8 100644 --- a/src/apps/stylededit/StyledEditWindow.h +++ b/src/apps/stylededit/StyledEditWindow.h @@ -118,17 +118,17 @@ private: BString fReplaceString; // undo modes - bool fUndoFlag; // we just did an undo action - bool fCanUndo; // we can do an undo action next - bool fRedoFlag; // we just did a redo action - bool fCanRedo; // we can do a redo action next + bool fUndoFlag; // we just did an undo action + bool fCanUndo; // we can do an undo action next + bool fRedoFlag; // we just did a redo action + bool fCanRedo; // we can do a redo action next // clean modes bool fUndoCleans; // an undo action will put us in a clean state bool fRedoCleans; // a redo action will put us in a clean state - bool fClean; // we are in a clean state + bool fClean; // we are in a clean state bool fCaseSensitive; bool fWrapAround;