TextSearch: trim trailing whitespace.

This commit is contained in:
Augustin Cavalier
2015-03-31 17:42:02 -04:00
parent 05840b4c2a
commit 696f4254ca
13 changed files with 193 additions and 193 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ using std::nothrow;
#endif #endif
ChangesIterator::ChangesIterator(const Model* model) ChangesIterator::ChangesIterator(const Model* model)
: FileIterator(), : FileIterator(),
fPathMap(), fPathMap(),
fIteratorIndex(0), fIteratorIndex(0),
+15 -15
View File
@@ -1,23 +1,23 @@
/* /*
* Copyright (c) 2008 Stephan Aßmus <[email protected]> * Copyright (c) 2008 Stephan Aßmus <[email protected]>
* Copyright (c) 1998-2007 Matthijs Hollemans * Copyright (c) 1998-2007 Matthijs Hollemans
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#ifndef FILE_ITERATOR_H #ifndef FILE_ITERATOR_H
+23 -23
View File
@@ -1,25 +1,25 @@
/* /*
* Copyright (c) 1998-2007 Matthijs Hollemans * Copyright (c) 1998-2007 Matthijs Hollemans
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#include "GrepApp.h" #include "GrepApp.h"
#include <stdio.h> #include <stdio.h>
@@ -46,19 +46,19 @@ GrepApp::~GrepApp()
} }
void void
GrepApp::ArgvReceived(int32 argc, char** argv) GrepApp::ArgvReceived(int32 argc, char** argv)
{ {
fGotArgvOnStartup = true; fGotArgvOnStartup = true;
BMessage message(B_REFS_RECEIVED); BMessage message(B_REFS_RECEIVED);
int32 refCount = 0; int32 refCount = 0;
for (int32 i = 1; i < argc; i++) { for (int32 i = 1; i < argc; i++) {
BEntry entry(argv[i]); BEntry entry(argv[i]);
entry_ref ref; entry_ref ref;
entry.GetRef(&ref); entry.GetRef(&ref);
if (entry.Exists()) { if (entry.Exists()) {
message.AddRef("refs", &ref); message.AddRef("refs", &ref);
refCount += 1; refCount += 1;
@@ -73,7 +73,7 @@ GrepApp::ArgvReceived(int32 argc, char** argv)
void void
GrepApp::RefsReceived(BMessage* message) GrepApp::RefsReceived(BMessage* message)
{ {
if (IsLaunching()) if (IsLaunching())
fGotRefsOnStartup = true; fGotRefsOnStartup = true;
@@ -114,12 +114,12 @@ GrepApp::MessageReceived(BMessage* message)
void void
GrepApp::_TryQuit() GrepApp::_TryQuit()
{ {
if (CountWindows() == 0) if (CountWindows() == 0)
PostMessage(B_QUIT_REQUESTED); PostMessage(B_QUIT_REQUESTED);
if (CountWindows() == 1 && fQuitter == NULL) { if (CountWindows() == 1 && fQuitter == NULL) {
fQuitter = new BMessageRunner(be_app_messenger, fQuitter = new BMessageRunner(be_app_messenger,
new BMessage(MSG_TRY_QUIT), 200000, -1); new BMessage(MSG_TRY_QUIT), 200000, -1);
} }
} }
+15 -15
View File
@@ -1,22 +1,22 @@
/* /*
* Copyright (c) 1998-2007 Matthijs Hollemans * Copyright (c) 1998-2007 Matthijs Hollemans
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#include <Application.h> #include <Application.h>
+17 -17
View File
@@ -1,22 +1,22 @@
/* /*
* Copyright (c) 1998-2007 Matthijs Hollemans * Copyright (c) 1998-2007 Matthijs Hollemans
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
@@ -30,12 +30,12 @@ ResultItem::ResultItem(const entry_ref& ref)
{ {
BEntry entry(&ref); BEntry entry(&ref);
BPath path(&entry); BPath path(&entry);
SetText(path.Path()); SetText(path.Path());
} }
GrepListView::GrepListView() GrepListView::GrepListView()
: BOutlineListView(BRect(0, 0, 40, 80), "SearchResults", : BOutlineListView(BRect(0, 0, 40, 80), "SearchResults",
B_MULTIPLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES, B_MULTIPLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES,
B_WILL_DRAW | B_NAVIGABLE) B_WILL_DRAW | B_NAVIGABLE)
{ {
+15 -15
View File
@@ -1,22 +1,22 @@
/* /*
* Copyright (c) 1998-2007 Matthijs Hollemans * Copyright (c) 1998-2007 Matthijs Hollemans
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#ifndef GREP_LIST_VIEW_H #ifndef GREP_LIST_VIEW_H
+5 -5
View File
@@ -397,7 +397,7 @@ GrepWindow::_SetWindowTitle()
if (entry.GetPath(&path) == B_OK) { if (entry.GetPath(&path) == B_OK) {
if (fOldPattern.Length()) { if (fOldPattern.Length()) {
title = B_TRANSLATE("%appname% : %path% : %searchtext%"); title = B_TRANSLATE("%appname% : %path% : %searchtext%");
title.ReplaceAll("%searchtext%", fOldPattern.String()); title.ReplaceAll("%searchtext%", fOldPattern.String());
} else } else
title = B_TRANSLATE("%appname% : %path%"); title = B_TRANSLATE("%appname% : %path%");
@@ -787,7 +787,7 @@ GrepWindow::_OnStartCancel()
fButton->MoveTo( fButton->MoveTo(
fMenuBar->Frame().Width() - fButton->Frame().Width() - 8, fMenuBar->Frame().Width() - fButton->Frame().Width() - 8,
8 + fSearchText->Frame().Height() + 8); 8 + fSearchText->Frame().Height() + 8);
fSearch->SetEnabled(false); fSearch->SetEnabled(false);
// We need to remember the search pattern, because during // We need to remember the search pattern, because during
@@ -844,7 +844,7 @@ GrepWindow::_OnSearchFinished()
fButton->MoveTo( fButton->MoveTo(
fMenuBar->Frame().Width() - fButton->Frame().Width() - 8, fMenuBar->Frame().Width() - fButton->Frame().Width() - 8,
8 + fSearchText->Frame().Height() + 8); 8 + fSearchText->Frame().Height() + 8);
fButton->SetEnabled(true); fButton->SetEnabled(true);
fSearch->SetEnabled(true); fSearch->SetEnabled(true);
@@ -1028,7 +1028,7 @@ GrepWindow::_OnReportFileName(BMessage* message)
fSearchText->TruncateString(&name, B_TRUNCATE_MIDDLE, fSearchText->TruncateString(&name, B_TRUNCATE_MIDDLE,
fSearchBoxWidth - 10); fSearchBoxWidth - 10);
fSearchText->SetText(name); fSearchText->SetText(name);
} }
} }
@@ -1440,7 +1440,7 @@ GrepWindow::_OnSelectInTracker()
BString str1; BString str1;
str1 << B_TRANSLATE("%APP_NAME couldn't open one or more folders."); str1 << B_TRANSLATE("%APP_NAME couldn't open one or more folders.");
str1.ReplaceFirst("%APP_NAME",APP_NAME); str1.ReplaceFirst("%APP_NAME",APP_NAME);
BAlert* alert = new BAlert(NULL, str1.String(), B_TRANSLATE("OK"), BAlert* alert = new BAlert(NULL, str1.String(), B_TRANSLATE("OK"),
NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go(NULL); alert->Go(NULL);
+19 -19
View File
@@ -1,22 +1,22 @@
/* /*
* Copyright (c) 1998-2007 Matthijs Hollemans * Copyright (c) 1998-2007 Matthijs Hollemans
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#ifndef GREP_WINDOW_H #ifndef GREP_WINDOW_H
@@ -38,14 +38,14 @@ class GrepWindow : public BWindow {
public: public:
GrepWindow(BMessage* message); GrepWindow(BMessage* message);
virtual ~GrepWindow(); virtual ~GrepWindow();
virtual void FrameResized(float width, float height); virtual void FrameResized(float width, float height);
virtual void FrameMoved(BPoint origin); virtual void FrameMoved(BPoint origin);
virtual void MenusBeginning(); virtual void MenusBeginning();
virtual void MenusEnded(); virtual void MenusEnded();
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
virtual void Quit(); virtual void Quit();
private: private:
void _InitRefsReceived(entry_ref* directory, void _InitRefsReceived(entry_ref* directory,
BMessage* message); BMessage* message);
@@ -54,7 +54,7 @@ private:
void _CreateViews(); void _CreateViews();
void _LayoutViews(); void _LayoutViews();
void _TileIfMultipleWindows(); void _TileIfMultipleWindows();
void _LoadPrefs(); void _LoadPrefs();
void _SavePrefs(); void _SavePrefs();
@@ -101,7 +101,7 @@ private:
private: private:
BTextControl* fSearchText; BTextControl* fSearchText;
GrepListView* fSearchResults; GrepListView* fSearchResults;
BMenuBar* fMenuBar; BMenuBar* fMenuBar;
BMenu* fFileMenu; BMenu* fFileMenu;
BMenuItem* fNew; BMenuItem* fNew;
+23 -23
View File
@@ -1,22 +1,22 @@
/* /*
* Copyright (c) 1998-2007 Matthijs Hollemans * Copyright (c) 1998-2007 Matthijs Hollemans
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#ifndef GREPPER_H #ifndef GREPPER_H
@@ -38,18 +38,18 @@ public:
bool IsValid() const; bool IsValid() const;
void Start(); void Start();
void Cancel(); void Cancel();
private: private:
// Spawns the real grepper thread. // Spawns the real grepper thread.
static int32 _SpawnThread(void* cookie); static int32 _SpawnThread(void* cookie);
// The thread function that does the actual grepping. // The thread function that does the actual grepping.
int32 _GrepperThread(); int32 _GrepperThread();
// Remembers, and possibly escapes, the search pattern. // Remembers, and possibly escapes, the search pattern.
void _SetPattern(const char* source); void _SetPattern(const char* source);
// Prepends all quotes, dollars and backslashes with at backslash // Prepends all quotes, dollars and backslashes with at backslash
// to prevent the shell from misinterpreting them. // to prevent the shell from misinterpreting them.
bool _EscapeSpecialChars(char* buffer, bool _EscapeSpecialChars(char* buffer,
@@ -57,16 +57,16 @@ private:
private: private:
// The (escaped) search pattern. // The (escaped) search pattern.
char* fPattern; char* fPattern;
// The settings from the model. // The settings from the model.
BMessenger fTarget; BMessenger fTarget;
bool fEscapeText : 1; bool fEscapeText : 1;
bool fCaseSensitive : 1; bool fCaseSensitive : 1;
uint32 fEncoding; uint32 fEncoding;
// The supplier of files to grep // The supplier of files to grep
FileIterator* fIterator; FileIterator* fIterator;
// Our thread's ID. // Our thread's ID.
thread_id fThreadId; thread_id fThreadId;
+23 -23
View File
@@ -1,23 +1,23 @@
/* /*
* Copyright (c) 2008 Stephan Aßmus <[email protected]> * Copyright (c) 2008 Stephan Aßmus <[email protected]>
* Copyright (c) 1998-2007 Matthijs Hollemans * Copyright (c) 1998-2007 Matthijs Hollemans
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
@@ -40,7 +40,7 @@ using std::nothrow;
// For the moment I don't know the life cycle of the InitialIterator object. // For the moment I don't know the life cycle of the InitialIterator object.
InitialIterator::InitialIterator(const Model* model) InitialIterator::InitialIterator(const Model* model)
: FileIterator(), : FileIterator(),
fDirectories(10), fDirectories(10),
fCurrentDir(new (nothrow) BDirectory(&model->fDirectory)), fCurrentDir(new (nothrow) BDirectory(&model->fDirectory)),
@@ -90,7 +90,7 @@ InitialIterator::GetNextName(char* buffer)
return false; return false;
// If the entry is a subdir, then add it to the // If the entry is a subdir, then add it to the
// list of directories and continue the loop. // list of directories and continue the loop.
// If the entry is a file and we can grep it // If the entry is a file and we can grep it
// (i.e. it is a text file), then we're done // (i.e. it is a text file), then we're done
// here. Otherwise, continue with the next entry. // here. Otherwise, continue with the next entry.
@@ -119,12 +119,12 @@ InitialIterator::NotifyNegatives() const
bool bool
InitialIterator::GetTopEntry(BEntry& entry) InitialIterator::GetTopEntry(BEntry& entry)
{ {
// If the user selected one or more files, we must look // If the user selected one or more files, we must look
// at the "refs" inside the message that was passed into // at the "refs" inside the message that was passed into
// our add-on's process_refs(). If the user didn't select // our add-on's process_refs(). If the user didn't select
// any files, we will simply read all the entries from the // any files, we will simply read all the entries from the
// current working directory. // current working directory.
entry_ref fileRef; entry_ref fileRef;
if (fSelectedFiles.FindRef("refs", fCurrentRef, &fileRef) == B_OK) { if (fSelectedFiles.FindRef("refs", fCurrentRef, &fileRef) == B_OK) {
@@ -184,7 +184,7 @@ InitialIterator::_GetSubEntry(BEntry& entry)
if (fCurrentDir->GetNextEntry(&entry, fRecurseLinks) == B_OK) if (fCurrentDir->GetNextEntry(&entry, fRecurseLinks) == B_OK)
return true; return true;
// If we get here, there are no more entries in // If we get here, there are no more entries in
// this subdir, so return to the parent directory. // this subdir, so return to the parent directory.
fDirectories.RemoveItem(fCurrentDir); fDirectories.RemoveItem(fCurrentDir);
+17 -17
View File
@@ -1,23 +1,23 @@
/* /*
* Copyright (c) 2008 Stephan Aßmus <[email protected]> * Copyright (c) 2008 Stephan Aßmus <[email protected]>
* Copyright (c) 1998-2007 Matthijs Hollemans * Copyright (c) 1998-2007 Matthijs Hollemans
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#ifndef INITIAL_ITERATOR_H #ifndef INITIAL_ITERATOR_H
@@ -69,10 +69,10 @@ private:
private: private:
// Contains pointers to BDirectory objects. // Contains pointers to BDirectory objects.
BList fDirectories; BList fDirectories;
// The directory we are currently looking at. // The directory we are currently looking at.
BDirectory* fCurrentDir; BDirectory* fCurrentDir;
// The ref number we are currently looking at. // The ref number we are currently looking at.
int32 fCurrentRef; int32 fCurrentRef;
+19 -19
View File
@@ -1,22 +1,22 @@
/* /*
* Copyright (c) 1998-2007 Matthijs Hollemans * Copyright (c) 1998-2007 Matthijs Hollemans
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#ifndef MODEL_H #ifndef MODEL_H
@@ -60,7 +60,7 @@ enum {
MSG_REFS_RECEIVED, MSG_REFS_RECEIVED,
MSG_TRY_QUIT, MSG_TRY_QUIT,
MSG_QUIT_NOW, MSG_QUIT_NOW,
MSG_TRIM_SELECTION, MSG_TRIM_SELECTION,
MSG_COPY_TEXT, MSG_COPY_TEXT,
MSG_SELECT_IN_TRACKER, MSG_SELECT_IN_TRACKER,
@@ -78,7 +78,7 @@ enum state_t {
class Model { class Model {
public: public:
Model(); Model();
status_t LoadPrefs(); status_t LoadPrefs();
status_t SavePrefs(); status_t SavePrefs();
@@ -124,13 +124,13 @@ public:
// Grep string encoding ? // Grep string encoding ?
uint32 fEncoding; uint32 fEncoding;
private: private:
bool _LoadHistory(BList& items) const; bool _LoadHistory(BList& items) const;
status_t _SaveHistory(const BList& items) const; status_t _SaveHistory(const BList& items) const;
void _FreeHistory(const BList& items) const; void _FreeHistory(const BList& items) const;
status_t _OpenFile(BFile* file, const char* name, status_t _OpenFile(BFile* file, const char* name,
uint32 openMode = B_READ_ONLY, uint32 openMode = B_READ_ONLY,
directory_which which directory_which which
= B_USER_SETTINGS_DIRECTORY, = B_USER_SETTINGS_DIRECTORY,
BVolume* volume = NULL) const; BVolume* volume = NULL) const;
+1 -1
View File
@@ -11,7 +11,7 @@
int int
main() main()
{ {
GrepApp app; GrepApp app;
app.Run(); app.Run();