mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
ide: Fixed issues with history #1214
git-svn-id: svn://ultimatepp.org/upp/trunk@8770 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
55a110e92b
commit
54672a4b9e
7 changed files with 48 additions and 26 deletions
|
|
@ -675,8 +675,20 @@ void MakeBuild::SaveMakeFile(const String& fn, bool exporting)
|
|||
".PHONY: all\n"
|
||||
"all: prepare $(OutFile)\n"
|
||||
"\n"
|
||||
".PHONY: build_info\n"
|
||||
"build_info:\n"
|
||||
" date '+#define bmYEAR %y%n'\\\n"
|
||||
" '#define bmMONTH %m%n'\\\n"
|
||||
" '#define bmDAY %d%n'\\\n"
|
||||
" '#define bmHOUR %H%n'\\\n"
|
||||
" '#define bmMINUTE %M%n'\\\n"
|
||||
" '#define bmSECOND %S%n'\\\n"
|
||||
" '#define bmTIME Time(%y, %m, %d, %H, %M, %S)' > build_info.h\n"
|
||||
" echo '#define bmMACHINE \"'`hostname`'\"' >> build_info.h\n"
|
||||
" echo '#define bmUSER \"'`whoami`'\"' >> build_info.h\n"
|
||||
"\n"
|
||||
".PHONY: prepare\n"
|
||||
"prepare:\n";
|
||||
"prepare: build_info\n";
|
||||
}
|
||||
config << mf.config;
|
||||
install << mf.install;
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ void Ide::FindId(const String& id)
|
|||
}
|
||||
else
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String RemoveTemplateParams(const String& s)
|
||||
|
|
@ -159,6 +159,8 @@ void Ide::ContextGoto0(int pos)
|
|||
if(!IsNull(path)) {
|
||||
AddHistory();
|
||||
EditFile(path);
|
||||
editor.SetCursor(0);
|
||||
AddHistory();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -442,8 +442,10 @@ void Ide::GotoBookmark(const Bookmark& b)
|
|||
|
||||
bool Ide::IsHistDiff(int i)
|
||||
{
|
||||
if(i < 0 || i >= history.GetCount())
|
||||
return false;
|
||||
Bookmark& b = history[i];
|
||||
return b.file != editfile || abs(editor.GetCursor() - b.pos.cursor) > 200;
|
||||
return b.file != editfile || abs(editor.GetCursor() - b.pos.cursor) > 20;
|
||||
}
|
||||
|
||||
void Ide::IdePaste(String& data)
|
||||
|
|
@ -462,33 +464,39 @@ void Ide::IdePaste(String& data)
|
|||
|
||||
void Ide::AddHistory()
|
||||
{
|
||||
if(history.GetCount() && histi - 1 >= 0 && histi <= history.GetCount()) {
|
||||
if(IsHistDiff(histi - 1))
|
||||
if(history.GetCount()) {
|
||||
if(IsHistDiff(histi))
|
||||
++histi;
|
||||
}
|
||||
else
|
||||
histi = 1;
|
||||
history.SetCount(histi);
|
||||
histi = 0;
|
||||
history.At(histi);
|
||||
Bookmark& b = history.Top();
|
||||
b.file = editfile;
|
||||
b.pos = editor.GetEditPos();
|
||||
TouchFile(editfile);
|
||||
SetBar();
|
||||
}
|
||||
|
||||
void Ide::HistoryBk()
|
||||
void Ide::EditorEdit()
|
||||
{
|
||||
while(histi > 0 && --histi < history.GetCount())
|
||||
if(IsHistDiff(histi)) {
|
||||
GotoBookmark(history[histi]);
|
||||
SetBar();
|
||||
break;
|
||||
}
|
||||
AddHistory();
|
||||
TouchFile(editfile);
|
||||
}
|
||||
|
||||
void Ide::HistoryFw()
|
||||
int Ide::GetHistory(int d)
|
||||
{
|
||||
if(histi < history.GetCount() - 1 && ++histi >= 0) {
|
||||
if(history.GetCount())
|
||||
for(int i = histi + (d > 0); i >= 0 && i < history.GetCount(); i += d)
|
||||
if(IsHistDiff(i))
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void Ide::History(int d)
|
||||
{
|
||||
int i = GetHistory(d);
|
||||
if(i >= 0) {
|
||||
histi = i;
|
||||
GotoBookmark(history[histi]);
|
||||
SetBar();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -671,9 +671,10 @@ public:
|
|||
|
||||
void BookKey(int key);
|
||||
void AddHistory();
|
||||
int GetHistory(int d);
|
||||
void History(int dir);
|
||||
void EditorEdit();
|
||||
void GotoBookmark(const Bookmark& b);
|
||||
void HistoryFw();
|
||||
void HistoryBk();
|
||||
bool IsHistDiff(int i);
|
||||
|
||||
void IdePaste(String& s);
|
||||
|
|
|
|||
|
|
@ -596,12 +596,12 @@ void Ide::BrowseMenu(Bar& menu)
|
|||
menu.MenuSeparator();
|
||||
}
|
||||
|
||||
menu.Add("Go back", IdeImg::AssistGoBack(), THISBACK(HistoryBk))
|
||||
menu.Add("Go back", IdeImg::AssistGoBack(), THISBACK1(History, -1))
|
||||
.Key(K_ALT_LEFT)
|
||||
.Enable(histi > 0);
|
||||
menu.Add("Go forward", IdeImg::AssistGoForward(), THISBACK(HistoryFw))
|
||||
.Enable(GetHistory(-1) >= 0);
|
||||
menu.Add("Go forward", IdeImg::AssistGoForward(), THISBACK1(History, 1))
|
||||
.Key(K_ALT_RIGHT)
|
||||
.Enable(histi < history.GetCount() - 1);
|
||||
.Enable(GetHistory(1) >= 0);
|
||||
|
||||
if(menu.IsMenuBar()) {
|
||||
menu.MenuSeparator();
|
||||
|
|
|
|||
|
|
@ -51,8 +51,7 @@ void Ide::GotoPos(String path, int line)
|
|||
editor.SetCursor(editor.GetPos(line - 1));
|
||||
editor.TopCursor(4);
|
||||
editor.SetFocus();
|
||||
if(path.GetCount())
|
||||
AddHistory();
|
||||
AddHistory();
|
||||
}
|
||||
|
||||
void Ide::GotoCpp(const CppItem& pos)
|
||||
|
|
|
|||
|
|
@ -467,7 +467,7 @@ Ide::Ide()
|
|||
editor2.topsbbutton.ScrollStyle().NoWantFocus().Show();
|
||||
editor2.topsbbutton1.ScrollStyle().NoWantFocus().Show();
|
||||
editor2.WhenLeftDown = THISBACK(SwapEditors);
|
||||
editor.WhenAction = THISBACK(AddHistory);
|
||||
editor.WhenAction = THISBACK(EditorEdit);
|
||||
editor.WhenBar = THISBACK(EditorMenu);
|
||||
editor.WhenFontScroll = THISBACK(EditorFontScroll);
|
||||
editor.WhenOpenFindReplace = THISBACK(AddHistory);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue