Skip to content

Commit 615ec5e

Browse files
committed
Remove unused code from Editor class
1 parent 7e28201 commit 615ec5e

2 files changed

Lines changed: 0 additions & 188 deletions

File tree

src/editor/Editor.cpp

Lines changed: 0 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ Editor::Editor()
2727
fHighlightedWhitespaceStart(0),
2828
fHighlightedWhitespaceEnd(0),
2929
fHighlightedWhitespaceCurrentPos(0),
30-
fSearchTarget(-1, -1),
31-
fSearchLastResult(-1, -1),
32-
fSearchLast(""),
33-
fSearchLastFlags(0),
3430
fNumberMarginEnabled(false),
3531
fFoldMarginEnabled(false),
3632
fBookmarkMarginEnabled(false),
@@ -345,142 +341,6 @@ Editor::AppendNLAtTheEndIfNotPresent()
345341
}
346342

347343

348-
bool
349-
Editor::Find(BMessage* message)
350-
{
351-
bool inSelection = message->GetBool("inSelection");
352-
bool matchCase = message->GetBool("matchCase");
353-
bool matchWord = message->GetBool("matchWord");
354-
bool wrapAround = message->GetBool("wrapAround");
355-
bool backwards = message->GetBool("backwards");
356-
bool regex = message->GetBool("regex");
357-
const char* search = message->GetString("findText", "");
358-
359-
Sci::Guard<SearchTarget, SearchFlags> guard(this);
360-
361-
int length = SendMessage(SCI_GETLENGTH);
362-
Sci_Position anchor = SendMessage(SCI_GETANCHOR);
363-
Sci_Position current = SendMessage(SCI_GETCURRENTPOS);
364-
365-
if(anchor != fSearchLastResult.first || current != fSearchLastResult.second) {
366-
ResetFindReplace();
367-
}
368-
369-
if(fNewSearch == true) {
370-
if(inSelection == true) {
371-
fSearchTarget = Get<Selection>();
372-
if(backwards == true) {
373-
std::swap(fSearchTarget.first, fSearchTarget.second);
374-
}
375-
} else {
376-
fSearchTarget = backwards ? Sci::Range(anchor, 0) : Sci::Range(current, length);
377-
}
378-
}
379-
380-
auto temp = fSearchTarget;
381-
382-
if(fNewSearch == false) {
383-
temp.first = (backwards ? anchor : current);
384-
}
385-
386-
bool found;
387-
found = _Find(search, temp.first, temp.second, matchCase, matchWord, regex);
388-
389-
if(found == false && wrapAround == true) {
390-
Sci_Position startAgain;
391-
if(inSelection == true) {
392-
startAgain = fSearchTarget.first;
393-
} else {
394-
startAgain = (backwards ? length : 0);
395-
}
396-
found = _Find(search, startAgain, fSearchTarget.second, matchCase,
397-
matchWord, regex);
398-
}
399-
fNewSearch = false;
400-
fSearchLastMessage = *message;
401-
return found;
402-
}
403-
404-
405-
void
406-
Editor::FindNext()
407-
{
408-
Find(&fSearchLastMessage);
409-
}
410-
411-
412-
void
413-
Editor::FindSelection()
414-
{
415-
std::string selection = SelectionText();
416-
if(!selection.empty()) {
417-
fSearchLastMessage.MakeEmpty();
418-
fSearchLastMessage.AddBool("wrapAround", true);
419-
fSearchLastMessage.AddString("findText", selection.c_str());
420-
Find(&fSearchLastMessage);
421-
}
422-
}
423-
424-
425-
void
426-
Editor::Replace(std::string replacement, bool regex)
427-
{
428-
Sci::Guard<SearchTarget, SearchFlags> guard(this);
429-
430-
int replaceMsg = (regex ? SCI_REPLACETARGETRE : SCI_REPLACETARGET);
431-
if(fSearchLastResult != Sci::Range{ -1, -1 }) {
432-
// we need to search again, because whitespace highlighting messes with
433-
// the results
434-
Set<SearchFlags>(fSearchLastFlags);
435-
Set<SearchTarget>(fSearchLastResult);
436-
SendMessage(SCI_SEARCHINTARGET, (uptr_t) fSearchLast.size(), (sptr_t) fSearchLast.c_str());
437-
SendMessage(replaceMsg, -1, (sptr_t) replacement.c_str());
438-
fSearchLastResult = { -1, -1 };
439-
}
440-
}
441-
442-
443-
int
444-
Editor::ReplaceAll(std::string search, std::string replacement, bool matchCase,
445-
bool matchWord, bool inSelection, bool regex)
446-
{
447-
Sci::Guard<SearchTarget, SearchFlags> guard(this);
448-
Sci::UndoAction action(this);
449-
450-
int replaceMsg = (regex ? SCI_REPLACETARGETRE : SCI_REPLACETARGET);
451-
int occurences = 0;
452-
SendMessage(inSelection ? SCI_TARGETFROMSELECTION : SCI_TARGETWHOLEDOCUMENT);
453-
auto target = Get<SearchTarget>();
454-
bool found;
455-
do {
456-
found = _Find(search, target.first, target.second, matchCase, matchWord, regex);
457-
if(found) {
458-
SendMessage(replaceMsg, -1, (sptr_t) replacement.c_str());
459-
target.first = Get<SearchTargetEnd>();
460-
occurences++;
461-
}
462-
} while(found);
463-
return occurences;
464-
}
465-
466-
467-
void
468-
Editor::ReplaceAndFind()
469-
{
470-
bool regex = fSearchLastMessage.GetBool("regex");
471-
const char* replaceText = fSearchLastMessage.GetString("replaceText", "");
472-
Replace(replaceText, regex);
473-
Find(&fSearchLastMessage);
474-
}
475-
476-
477-
void
478-
Editor::ResetFindReplace()
479-
{
480-
fNewSearch = true;
481-
}
482-
483-
484344
/**
485345
* Jumps to line maintaining distance from window edges - in other words swaps
486346
* the current line without changing caret position on the screen.
@@ -878,30 +738,3 @@ Editor::_SetLineIndentation(int line, int indent)
878738
Set<Selection>({static_cast<int>(crange.cpMin), static_cast<int>(crange.cpMax)});
879739
}
880740
}
881-
882-
883-
bool
884-
Editor::_Find(std::string search, Sci_Position start, Sci_Position end,
885-
bool matchCase, bool matchWord, bool regex)
886-
{
887-
int searchFlags = 0;
888-
if(matchCase == true)
889-
searchFlags |= SCFIND_MATCHCASE;
890-
if(matchWord == true)
891-
searchFlags |= SCFIND_WHOLEWORD;
892-
if(regex == true)
893-
searchFlags |= SCFIND_REGEXP | SCFIND_CXX11REGEX;
894-
Set<SearchFlags>(searchFlags);
895-
fSearchLastFlags = searchFlags;
896-
897-
Set<SearchTarget>({start, end});
898-
899-
fSearchLast = search;
900-
Sci_Position pos = SendMessage(SCI_SEARCHINTARGET, (uptr_t) search.size(), (sptr_t) search.c_str());
901-
if(pos != -1) {
902-
fSearchLastResult = Get<SearchTarget>();
903-
Set<Selection>(fSearchLastResult);
904-
return true;
905-
}
906-
return false;
907-
}

src/editor/Editor.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,6 @@ class Editor : public BScintillaView {
7474

7575
void AppendNLAtTheEndIfNotPresent();
7676

77-
bool Find(BMessage* message);
78-
void FindNext();
79-
void FindSelection();
80-
void Replace(std::string replacement, bool regex = false);
81-
int ReplaceAll(std::string search, std::string replacement,
82-
bool matchCase, bool matchWord, bool inSelection,
83-
bool regex = false);
84-
void ReplaceAndFind();
85-
void ResetFindReplace();
86-
8777
void UpdateLineNumberWidth();
8878

8979
void GoToLine(int64 line);
@@ -120,10 +110,6 @@ class Editor : public BScintillaView {
120110

121111
void _SetLineIndentation(int line, int indent);
122112

123-
bool _Find(std::string search, Sci_Position start,
124-
Sci_Position end, bool matchCase, bool matchWord,
125-
bool regex = false);
126-
127113
editor::StatusView* fStatusView;
128114

129115
std::string fCommentLineToken;
@@ -134,13 +120,6 @@ class Editor : public BScintillaView {
134120
Sci_Position fHighlightedWhitespaceEnd;
135121
Sci_Position fHighlightedWhitespaceCurrentPos;
136122

137-
Scintilla::Range fSearchTarget;
138-
Scintilla::Range fSearchLastResult;
139-
std::string fSearchLast;
140-
int fSearchLastFlags;
141-
bool fNewSearch;
142-
BMessage fSearchLastMessage;
143-
144123
bool fNumberMarginEnabled;
145124
bool fFoldMarginEnabled;
146125
bool fBookmarkMarginEnabled;

0 commit comments

Comments
 (0)