Skip to content

Commit

Permalink
#3462 - cursor pos fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Aug 1, 2017
1 parent 3a64457 commit c5c05d4
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 13 deletions.
4 changes: 4 additions & 0 deletions far/changelog
@@ -1,3 +1,7 @@
drkns 01.08.2017 20:39:18 +0000 - build 4997

1. Продолжение #3462 - не меняем позицию курсора без необходимости.

drkns 31.07.2017 20:01:11 +0000 - build 4996

1. Уточнение 4995.1.
Expand Down
4 changes: 2 additions & 2 deletions far/edit.cpp
Expand Up @@ -1762,9 +1762,9 @@ bool Edit::ProcessMouse(const MOUSE_EVENT_RECORD *MouseEvent)
Немного изменён алгоритм из-за необходимости
добавления поиска целых слов.
*/
int Edit::Search(const string& Str, const string &UpperStr, const string &LowerStr, RegExp &re, RegExpMatch *pm, MatchHash* hm, string& ReplaceStr, int Position, int Case, int WholeWords, int Reverse, int Regexp, int PreserveStyle, int *SearchLength)
int Edit::Search(const string& Str, const string& UpperStr, const string& LowerStr, RegExp& re, RegExpMatch* pm, MatchHash* hm, string& ReplaceStr, int& Position, int Case, int WholeWords, int Reverse, int Regexp, int PreserveStyle, int *SearchLength)
{
return SearchString(m_Str.data(), m_Str.size(), Str, UpperStr, LowerStr, re, pm, hm, ReplaceStr, m_CurPos, Position, Case, WholeWords, Reverse, Regexp, PreserveStyle, SearchLength, WordDiv().data());
return SearchString(m_Str.data(), m_Str.size(), Str, UpperStr, LowerStr, re, pm, hm, ReplaceStr, Position, Case, WholeWords, Reverse, Regexp, PreserveStyle, SearchLength, WordDiv().data());
}

void Edit::InsertTab()
Expand Down
2 changes: 1 addition & 1 deletion far/edit.hpp
Expand Up @@ -152,7 +152,7 @@ class Edit: public SimpleScreenObject

void ClearString() { SetString(L"", 0); }

int Search(const string& Str,const string &UpperStr, const string &LowerStr, RegExp &re, RegExpMatch *pm, MatchHash* hm, string& ReplaceStr,int Position,int Case,int WholeWords,int Reverse,int Regexp,int PreserveStyle, int *SearchLength);
int Search(const string& Str, const string& UpperStr, const string& LowerStr, RegExp& re, RegExpMatch* pm, MatchHash* hm, string& ReplaceStr, int& Position, int Case, int WholeWords, int Reverse, int Regexp, int PreserveStyle, int *SearchLength);
void SetCurPos(int NewPos) {m_CurPos=NewPos; SetPrevCurPos(NewPos);}
void AdjustMarkBlock();
void AdjustPersistentMark();
Expand Down
3 changes: 1 addition & 2 deletions far/editor.cpp
Expand Up @@ -3487,12 +3487,11 @@ bool Editor::Search(bool Next)
Match = true;

m_FoundLine = CurPtr;
m_FoundPos = CurPtr->GetCurPos();
m_FoundPos = CurPos;
m_FoundSize = SearchLength;

if(FindAllReferences)
{
CurPos = m_FoundPos;
int NextPos = CurPos + (SearchLength? SearchLength : 1);

const int service_len = 12;
Expand Down
2 changes: 1 addition & 1 deletion far/help.cpp
Expand Up @@ -1955,7 +1955,7 @@ void Help::Search(const os::fs::file& HelpFile,uintptr_t nCodePage)
string ReplaceStr;
int CurPos=0;
int SearchLength;
bool Result = SearchString(strReadStr.data(), (int)strReadStr.size(), strLastSearchStr, strSearchStrUpper, strSearchStrLower, re, m.data(), &hm, ReplaceStr, CurPos, 0, LastSearchCase, LastSearchWholeWords, false, false, LastSearchRegexp, &SearchLength);
bool Result = SearchString(strReadStr.data(), (int)strReadStr.size(), strLastSearchStr, strSearchStrUpper, strSearchStrLower, re, m.data(), &hm, ReplaceStr, CurPos, LastSearchCase, LastSearchWholeWords, false, false, LastSearchRegexp, &SearchLength);

if (Result)
{
Expand Down
6 changes: 5 additions & 1 deletion far/new_handler.cpp
Expand Up @@ -38,7 +38,8 @@ static new_handler* NewHandler;

new_handler::new_handler():
m_BufferSize{ 80, 25 },
m_Screen(CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, CONSOLE_TEXTMODE_BUFFER, nullptr))
m_Screen(CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, CONSOLE_TEXTMODE_BUFFER, nullptr)),
m_OldHandler()
{
if (!m_Screen)
return;
Expand Down Expand Up @@ -98,6 +99,9 @@ new_handler::new_handler():

new_handler::~new_handler()
{
if (!NewHandler)
return;

std::set_new_handler(m_OldHandler);
NewHandler = nullptr;
}
Expand Down
3 changes: 2 additions & 1 deletion far/preservestyle.cpp
Expand Up @@ -262,8 +262,9 @@ void FindStyleTypeMaskAndPrependCharByExpansion(const wchar_t* Source, const siz
}
}

bool PreserveStyleReplaceString(const wchar_t* Source, size_t StrSize, const string& Str, string& ReplaceStr, int& CurPos, int Position, int Case, int WholeWords, const wchar_t *WordDiv, int Reverse, int& SearchLength)
bool PreserveStyleReplaceString(const wchar_t* Source, size_t StrSize, const string& Str, string& ReplaceStr, int& CurPos, int Case, int WholeWords, const wchar_t *WordDiv, int Reverse, int& SearchLength)
{
int Position = CurPos;
SearchLength = 0;

if (Reverse)
Expand Down
2 changes: 1 addition & 1 deletion far/preservestyle.hpp
Expand Up @@ -33,6 +33,6 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

bool PreserveStyleReplaceString(const wchar_t* Source, size_t StrSize, const string& Str, string& ReplaceStr, int& CurPos, int Position, int Case, int WholeWords, const wchar_t *WordDiv, int Reverse, int& SearchLength);
bool PreserveStyleReplaceString(const wchar_t* Source, size_t StrSize, const string& Str, string& ReplaceStr, int& CurPos, int Case, int WholeWords, const wchar_t *WordDiv, int Reverse, int& SearchLength);

#endif // PRESERVESTYLE_HPP_07024896_908E_4C05_9275_59B20F7E8AA2
5 changes: 3 additions & 2 deletions far/strmix.cpp
Expand Up @@ -1031,14 +1031,15 @@ string ReplaceBrackets(const wchar_t *SearchStr, const string& ReplaceStr, const
return result;
}

bool SearchString(const wchar_t* Source, int StrSize, const string& Str, const string &UpperStr, const string &LowerStr, RegExp &re, RegExpMatch *pm, MatchHash* hm, string& ReplaceStr, int& CurPos, int Position, int Case, int WholeWords, int Reverse, int Regexp, int PreserveStyle, int *SearchLength, const wchar_t* WordDiv)
bool SearchString(const wchar_t* Source, int StrSize, const string& Str, const string &UpperStr, const string &LowerStr, RegExp &re, RegExpMatch *pm, MatchHash* hm, string& ReplaceStr, int& CurPos, int Case, int WholeWords, int Reverse, int Regexp, int PreserveStyle, int *SearchLength, const wchar_t* WordDiv)
{
int Position = CurPos;
*SearchLength = 0;

if (!WordDiv)
WordDiv=Global->Opt->strWordDiv.data();

if (!Regexp && PreserveStyle && PreserveStyleReplaceString(Source, StrSize, Str, ReplaceStr, CurPos, Position, Case, WholeWords, WordDiv, Reverse, *SearchLength))
if (!Regexp && PreserveStyle && PreserveStyleReplaceString(Source, StrSize, Str, ReplaceStr, CurPos, Case, WholeWords, WordDiv, Reverse, *SearchLength))
return true;

if (Reverse)
Expand Down
2 changes: 1 addition & 1 deletion far/strmix.hpp
Expand Up @@ -93,7 +93,7 @@ bool IsCaseMixed(const string &strStr);

string ReplaceBrackets(const wchar_t *SearchStr, const string& ReplaceStr, const RegExpMatch* Match, size_t Count, const MatchHash* HMatch);

bool SearchString(const wchar_t* Source, int StrSize, const string& Str, const string &UpperStr, const string &LowerStr, RegExp &re, RegExpMatch *pm, MatchHash* hm, string& ReplaceStr,int& CurPos, int Position,int Case,int WholeWords,int Reverse,int Regexp,int PreserveStyle, int *SearchLength,const wchar_t* WordDiv=nullptr);
bool SearchString(const wchar_t* Source, int StrSize, const string& Str, const string& UpperStr, const string& LowerStr, RegExp& re, RegExpMatch* pm, MatchHash* hm, string& ReplaceStr, int& CurPos, int Case, int WholeWords, int Reverse, int Regexp, int PreserveStyle, int* SearchLength, const wchar_t* WordDiv = nullptr);

inline wchar_t* UNSAFE_CSTR(const string& s) {return const_cast<wchar_t*>(s.data());}

Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
@@ -1 +1 @@
m4_define(BUILD,4996)m4_dnl
m4_define(BUILD,4997)m4_dnl

0 comments on commit c5c05d4

Please sign in to comment.