ide: FindReplace return option

git-svn-id: svn://ultimatepp.org/upp/trunk@7507 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-07-14 11:47:23 +00:00
parent 9cbaaf54de
commit e5d17842e5
7 changed files with 54 additions and 32 deletions

View file

@ -232,6 +232,9 @@ protected:
bool mark_lines;
bool check_edited;
bool persistent_find_replace;
bool do_ff_restore_pos;
int ff_restore_pos;
FindReplaceDlg findreplace;
@ -346,6 +349,7 @@ public:
void Highlight(const String& h);
String GetHighlight() const { return highlight; }
void EscapeFindReplace();
void CloseFindReplace();
void FindReplace(bool pick_selection, bool pick_text, bool replace);
bool FindFrom(int pos, bool back, const wchar *text, bool wholeword, bool ignorecase, bool wildcards, bool block);
@ -444,6 +448,9 @@ public:
void PersistentFindReplace(bool b = true) { persistent_find_replace = b; }
bool IsPersistentFindReplace() const { return persistent_find_replace; }
void FindReplaceRestorePos(bool b = true) { do_ff_restore_pos = b; }
bool IsFindReplaceRestorePos() const { return do_ff_restore_pos; }
void Annotations(int width) { bar.Annotations(width); }
void SetAnnotation(int i, const Image& icon, const String& a) { bar.SetAnnotation(i, icon, a); }

View file

@ -18,6 +18,7 @@ void CodeEditor::InitFindReplace()
findreplace.find <<= findreplace.wholeword <<= findreplace.wildcards
<<= findreplace.incremental <<= findreplace.regexp
<<= findreplace.ignorecase <<= THISBACK(IncrementalFind);
ff_restore_pos = -1;
}
FindReplaceDlg::FindReplaceDlg()
@ -514,7 +515,7 @@ void CodeEditor::OpenNormalFindReplace(bool replace)
findreplace.itext = GetI();
findreplace.prev.Show();
findreplace.next <<= THISBACK(DoFind);
findreplace.close <<= THISBACK(CloseFindReplace);
findreplace.close <<= THISBACK(EscapeFindReplace);
if(!findreplace.IsOpen())
InsertFrame(FindFrame(sb), findreplace);
WhenOpenFindReplace();
@ -526,6 +527,8 @@ void CodeEditor::FindReplace(bool pick_selection, bool pick_text, bool replace)
if(findreplace.IsOpen())
CloseFindReplace();
ff_restore_pos = GetCursor();
replacei = 0;
WString find_text;
int find_pos = -1;
@ -676,6 +679,15 @@ void CodeEditor::CloseFindReplace()
}
}
void CodeEditor::EscapeFindReplace()
{
CloseFindReplace();
if(ff_restore_pos >= 0 && ff_restore_pos < GetLength() && findreplace.incremental && do_ff_restore_pos) {
SetCursor(ff_restore_pos);
ff_restore_pos = -1;
}
}
void CodeEditor::IncrementalFind()
{
NoFindError();

View file

@ -1,12 +1,8 @@
#ifndef _CodeEditor_icpp_init_stub
#define _CodeEditor_icpp_init_stub
#include "CtrlLib/init"
<<<<<<< .mine
#define BLITZ_INDEX__ Fa19bf999ba2b201492446aa335bd578e
=======
#include "plugin/pcre/init"
#define BLITZ_INDEX__ F8defc3b59944b6f49a28a98ad6148c81
>>>>>>> .r7504
#define BLITZ_INDEX__ F9714522c143037334ef92752f80fbeaa
#include "CRegister.icpp"
#undef BLITZ_INDEX__
#endif

View file

@ -144,7 +144,7 @@ void Sentinel(Stream& s, const char *txt)
void Ide::Serialize(Stream& s)
{
int version = 3;
int version = 4;
Sentinel(s, "before 12341234");
s.Magic(0x12341234);
Sentinel(s, "after magic");
@ -171,6 +171,9 @@ void Ide::Serialize(Stream& s)
s % filetabs;
s % auto_enclose;
s % persistent_find_replace;
if(version >= 4) {
s % find_replace_restore_pos;
}
s % show_tabs;
s % tabs_icons;
s % tabs_crosses;

View file

@ -132,6 +132,7 @@ void Ide::UpdateFormat(CodeEditor& editor)
editor.MarkLines(mark_lines);
editor.BorderColumn(bordercolumn, bordercolor);
editor.PersistentFindReplace(persistent_find_replace);
editor.FindReplaceRestorePos(find_replace_restore_pos);
editor.Refresh();
}
@ -408,6 +409,7 @@ void Ide::SetupFormat() {
(edt.tabs_stacking, tabs_stacking)
(edt.tabs_serialize, tabs_serialize)
(edt.persistent_find_replace, persistent_find_replace)
(edt.find_replace_restore_pos, find_replace_restore_pos)
(assist.barline, barline)
(assist.auto_enclose, auto_enclose)

View file

@ -679,6 +679,7 @@ public:
int bordercolumn;
Color bordercolor;
bool persistent_find_replace;
bool find_replace_restore_pos;
/*
astyle code formatter control vars

View file

@ -465,32 +465,33 @@ END_LAYOUT
LAYOUT(SetupEditorLayout, 544, 276)
ITEM(Label, dv___0, SetLabel(t_("Tab size")).LeftPosZ(4, 108).TopPosZ(4, 19))
ITEM(EditIntSpin, tabsize, LeftPosZ(116, 52).TopPosZ(4, 19))
ITEM(Label, dv___2, SetLabel(t_("Indent")).LeftPosZ(4, 108).TopPosZ(28, 19))
ITEM(EditIntSpin, indent_amount, LeftPosZ(116, 52).TopPosZ(28, 19))
ITEM(Label, dv___4, SetLabel(t_("Paint line at column")).HSizePosZ(4, 432).TopPosZ(52, 19))
ITEM(EditIntSpin, bordercolumn, Min(0).LeftPosZ(116, 52).TopPosZ(52, 19))
ITEM(ColorPusher, bordercolor, LeftPosZ(172, 48).TopPosZ(52, 20))
ITEM(Label, dv___7, SetLabel(t_("Default charset")).LeftPosZ(4, 108).TopPosZ(76, 19))
ITEM(DropList, charset, LeftPosZ(116, 104).TopPosZ(76, 19))
ITEM(Label, dv___9, SetLabel(t_("Line endings")).LeftPosZ(4, 108).TopPosZ(100, 19))
ITEM(DropList, lineends, LeftPosZ(116, 160).TopPosZ(100, 19))
ITEM(Option, showtabs, SetLabel(t_("Show tabs and line endings")).LeftPosZ(4, 272).TopPosZ(124, 16))
ITEM(Option, indent_spaces, SetLabel(t_("Indent using spaces")).HSizePosZ(4, 268).TopPosZ(140, 16))
ITEM(Option, no_parenthesis_indent, SetLabel(t_("No indent after parenthesis")).LeftPosZ(4, 272).TopPosZ(156, 16))
ITEM(Option, numbers, SetLabel(t_("Show line numbers")).LeftPosZ(4, 272).TopPosZ(172, 16))
ITEM(Option, bookmark_pos, SetLabel(t_("Bookmarks restore position")).LeftPosZ(4, 272).TopPosZ(188, 16))
ITEM(Option, findpicksel, SetLabel(t_("Find picks selection")).LeftPosZ(4, 272).TopPosZ(204, 16))
ITEM(Option, findpicktext, SetLabel(t_("Find picks selection or text")).LeftPosZ(4, 272).TopPosZ(220, 16))
ITEM(Option, deactivate_save, SetLabel(t_("Save file on TheIde window deactivation")).LeftPosZ(4, 272).TopPosZ(236, 16))
ITEM(Option, persistent_find_replace, SetLabel(t_("Do not close Find/Replace dialog automatically")).LeftPosZ(4, 272).TopPosZ(252, 16))
ITEM(Label, dv___20, SetLabel(t_("File Tabs")).LeftPosZ(304, 64).TopPosZ(4, 19))
ITEM(Label, dv___2, SetLabel(t_("Indent")).LeftPosZ(4, 108).TopPosZ(24, 19))
ITEM(EditIntSpin, indent_amount, LeftPosZ(116, 52).TopPosZ(24, 19))
ITEM(Label, dv___4, SetLabel(t_("Paint line at column")).HSizePosZ(4, 432).TopPosZ(44, 19))
ITEM(EditIntSpin, bordercolumn, Min(0).LeftPosZ(116, 52).TopPosZ(44, 19))
ITEM(ColorPusher, bordercolor, LeftPosZ(172, 48).TopPosZ(44, 20))
ITEM(Label, dv___7, SetLabel(t_("Default charset")).LeftPosZ(4, 108).TopPosZ(64, 19))
ITEM(DropList, charset, LeftPosZ(116, 104).TopPosZ(64, 19))
ITEM(Label, dv___9, SetLabel(t_("Line endings")).LeftPosZ(4, 108).TopPosZ(84, 19))
ITEM(DropList, lineends, LeftPosZ(116, 160).TopPosZ(84, 19))
ITEM(Option, showtabs, SetLabel(t_("Show tabs and line endings")).LeftPosZ(4, 272).TopPosZ(108, 16))
ITEM(Option, indent_spaces, SetLabel(t_("Indent using spaces")).HSizePosZ(4, 268).TopPosZ(124, 16))
ITEM(Option, no_parenthesis_indent, SetLabel(t_("No indent after parenthesis")).LeftPosZ(4, 272).TopPosZ(140, 16))
ITEM(Option, numbers, SetLabel(t_("Show line numbers")).LeftPosZ(4, 272).TopPosZ(156, 16))
ITEM(Option, bookmark_pos, SetLabel(t_("Bookmarks restore position")).LeftPosZ(4, 272).TopPosZ(172, 16))
ITEM(Option, findpicksel, SetLabel(t_("Find picks selection")).LeftPosZ(4, 272).TopPosZ(188, 16))
ITEM(Option, findpicktext, SetLabel(t_("Find picks selection or text")).LeftPosZ(4, 272).TopPosZ(204, 16))
ITEM(Option, deactivate_save, SetLabel(t_("Save file on TheIde window deactivation")).LeftPosZ(4, 272).TopPosZ(220, 16))
ITEM(Option, persistent_find_replace, SetLabel(t_("Do not close Find/Replace dialog automatically")).LeftPosZ(4, 272).TopPosZ(236, 16))
ITEM(Option, find_replace_restore_pos, SetLabel(t_("Restore position on canceling incremental search")).LeftPosZ(4, 272).TopPosZ(252, 16))
ITEM(Label, dv___21, SetLabel(t_("File Tabs")).LeftPosZ(304, 64).TopPosZ(4, 19))
ITEM(DropList, filetabs, LeftPosZ(372, 64).TopPosZ(4, 19))
ITEM(Label, dv___22, SetLabel(t_("Crosses")).LeftPosZ(304, 64).TopPosZ(28, 19))
ITEM(DropList, tabs_crosses, LeftPosZ(372, 64).TopPosZ(28, 19))
ITEM(Option, tabs_icons, SetLabel(t_("Icons")).LeftPosZ(304, 132).TopPosZ(52, 16))
ITEM(Option, tabs_grouping, SetLabel(t_("Grouping")).LeftPosZ(304, 132).TopPosZ(72, 16))
ITEM(Option, tabs_stacking, SetLabel(t_("Stacking")).LeftPosZ(304, 132).TopPosZ(92, 16))
ITEM(Option, tabs_serialize, SetLabel(t_("Persistent tabs")).LeftPosZ(304, 132).TopPosZ(112, 16))
ITEM(Label, dv___23, SetLabel(t_("Crosses")).LeftPosZ(304, 64).TopPosZ(24, 19))
ITEM(DropList, tabs_crosses, LeftPosZ(372, 64).TopPosZ(24, 19))
ITEM(Option, tabs_icons, SetLabel(t_("Icons")).LeftPosZ(304, 132).TopPosZ(48, 16))
ITEM(Option, tabs_grouping, SetLabel(t_("Grouping")).LeftPosZ(304, 132).TopPosZ(68, 16))
ITEM(Option, tabs_stacking, SetLabel(t_("Stacking")).LeftPosZ(304, 132).TopPosZ(88, 16))
ITEM(Option, tabs_serialize, SetLabel(t_("Persistent tabs")).LeftPosZ(304, 132).TopPosZ(108, 16))
END_LAYOUT
LAYOUT(SetupAssistLayout, 532, 136)