From dfb80fe504fff4aa5457d810912e52cf6b826eed Mon Sep 17 00:00:00 2001 From: cxl Date: Mon, 1 Dec 2014 08:57:23 +0000 Subject: [PATCH] ide: Optimized toolbar git-svn-id: svn://ultimatepp.org/upp/trunk@7937 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlCore/TopWin32.cpp | 2 +- uppsrc/ide/Json.cpp | 2 ++ uppsrc/ide/OutputMode.cpp | 14 ++++++++++---- uppsrc/ide/UppDlg.h | 3 +++ uppsrc/ide/UppWspc.cpp | 15 +++++++++++++++ uppsrc/ide/Xml.cpp | 2 ++ uppsrc/ide/ide.h | 7 +++++-- uppsrc/ide/idebar.cpp | 12 ++++++------ uppsrc/ide/idefile.cpp | 6 ++++++ uppsrc/ide/idetool.cpp | 12 ------------ uppsrc/ide/idewin.cpp | 2 ++ 11 files changed, 52 insertions(+), 25 deletions(-) diff --git a/uppsrc/CtrlCore/TopWin32.cpp b/uppsrc/CtrlCore/TopWin32.cpp index 491fa40df..65810a479 100644 --- a/uppsrc/CtrlCore/TopWin32.cpp +++ b/uppsrc/CtrlCore/TopWin32.cpp @@ -407,7 +407,7 @@ void TopWindow::SerializePlacement(Stream& s, bool reminimize) s.Pack(mn, mx, fs); // 12-05-23 Tom changed from: s.Pack(mn, mx); else s.Pack(mn, mx); - LLOG("TopWindow::SerializePlacement / " << (s.IsStoring() ? "write" : "read")); + LLOG(Name(this) << "::SerializePlacement / " << (s.IsStoring() ? "write" : "read")); LLOG("minimized = " << mn << ", maximized = " << mx << ", fullscreen = " << fs); // 12-05-23 Tom extended with fullscreen LLOG("rect = " << rect << ", overlapped = " << overlapped); if(s.IsLoading()) { diff --git a/uppsrc/ide/Json.cpp b/uppsrc/ide/Json.cpp index a7ea60d72..2e5f6cde7 100644 --- a/uppsrc/ide/Json.cpp +++ b/uppsrc/ide/Json.cpp @@ -119,4 +119,6 @@ void Ide::Json() LoadFromGlobal(dlg, "JSONview"); dlg.OpenMain(); } + else + dlg.SetForeground(); } diff --git a/uppsrc/ide/OutputMode.cpp b/uppsrc/ide/OutputMode.cpp index 7af476311..9fe234ca4 100644 --- a/uppsrc/ide/OutputMode.cpp +++ b/uppsrc/ide/OutputMode.cpp @@ -158,7 +158,7 @@ void OutMode::Load() void OutMode::Save() { - ide.method = ~method; + ide.SetMethod(~method); ide.targetmode = ~mode; ide.export_dir = ~export_dir; debug.Save(ide.debug); @@ -291,9 +291,15 @@ void Ide::DropMethodList() methodlist.SetCursor(i); } +void Ide::SetMethod(const String& m) +{ + method = m; + current_builder = GetMethodVars(method).Get("BUILDER", ""); +} + void Ide::SelectMethod() { - method = methodlist.GetKey(); + SetMethod(methodlist.GetKey()); int q = recent_buildmode.Find(~method); if(q >= 0) { StringStream ss(recent_buildmode[q]); @@ -318,12 +324,12 @@ void Ide::SelectMode() void Ide::SetupDefaultMethod() { if(IsNull(method)) { - method = GetDefaultMethod(); + SetMethod(GetDefaultMethod()); if(IsNull(method)) { FindFile ff(ConfigFile("*.bm")); if(!ff) return; - method = GetFileTitle(ff.GetName()); + SetMethod(GetFileTitle(ff.GetName())); } VectorMap map = GetMethodVars(method); debug.linkmode = atoi(map.Get("DEBUG_LINKMODE", "0")); diff --git a/uppsrc/ide/UppDlg.h b/uppsrc/ide/UppDlg.h index 8e401ff0d..c562d4a83 100644 --- a/uppsrc/ide/UppDlg.h +++ b/uppsrc/ide/UppDlg.h @@ -253,6 +253,7 @@ struct WorkspaceWork { int actualfileindex; Package actual; bool editormode; + bool svn_dirs; struct Sepfo : Moveable { String package; @@ -299,6 +300,8 @@ struct WorkspaceWork { void RestoreBackup(); void SyncErrorPackages(); + Vector SvnDirs(bool actual = false); + void SerializeFileSetup(Stream& s) { s % filelist % package; } Sepfo GetActiveSepfo(); diff --git a/uppsrc/ide/UppWspc.cpp b/uppsrc/ide/UppWspc.cpp index 17e10d13c..7546c28d3 100644 --- a/uppsrc/ide/UppWspc.cpp +++ b/uppsrc/ide/UppWspc.cpp @@ -296,6 +296,7 @@ void WorkspaceWork::PackageCursor() InvalidatePackageCache(); filelist.WhenBar.Clear(); actualpackage = GetActivePackage(); + svn_dirs = false; if(actualpackage.IsEmpty()) return; if(actualpackage == METAPACKAGE) { actual.file.Clear(); @@ -313,6 +314,19 @@ void WorkspaceWork::PackageCursor() filelist.Enable(); if(actualpackage != METAPACKAGE) filelist.WhenBar = THISBACK(FileMenu); + svn_dirs = SvnDirs(true).GetCount(); +} + +Vector WorkspaceWork::SvnDirs(bool actual) +{ + Vector d = GetUppDirs(); + if (actual && !IsAux()) + d.Insert(0, GetFileFolder(PackagePath(actualpackage))); + Vector r; + for(int i = 0; i < d.GetCount(); i++) + if(IsSvnDir(d[i])) + r.Add(d[i]); + return r; } void WorkspaceWork::FileCursor() @@ -1051,6 +1065,7 @@ WorkspaceWork::WorkspaceWork() filelist.BackPaintHint(); showtime = false; sort = true; + svn_dirs = false; } void WorkspaceWork::SerializeClosed(Stream& s) diff --git a/uppsrc/ide/Xml.cpp b/uppsrc/ide/Xml.cpp index d8b8eb6e9..34d88c2d9 100644 --- a/uppsrc/ide/Xml.cpp +++ b/uppsrc/ide/Xml.cpp @@ -142,4 +142,6 @@ void Ide::Xml() LoadFromGlobal(dlg, "XMLview"); dlg.OpenMain(); } + else + dlg.SetForeground(); } diff --git a/uppsrc/ide/ide.h b/uppsrc/ide/ide.h index ba82de40a..517a4e8e6 100644 --- a/uppsrc/ide/ide.h +++ b/uppsrc/ide/ide.h @@ -675,6 +675,8 @@ public: String editfile; FileTime edittime; int editfile_line_endings; + bool editfile_svn; + bool editfile_isfolder; String editfile2; @@ -855,6 +857,8 @@ public: int issaving; int isscanning; + + String current_builder; // ------------------------------------ @@ -935,6 +939,7 @@ public: void SyncBuildMode(); void SetupBuildMethods(); void DropMethodList(); + void SetMethod(const String& m); void SelectMethod(); void DropModeList(); void SelectMode(); @@ -946,8 +951,6 @@ public: void LoadAbbr(); void SaveAbbr(); - Vector SvnDirs(bool actual = false); - void File(Bar& menu); void EditWorkspace(); void EditAnyFile(); diff --git a/uppsrc/ide/idebar.cpp b/uppsrc/ide/idebar.cpp index c8407ce62..ef689c318 100644 --- a/uppsrc/ide/idebar.cpp +++ b/uppsrc/ide/idebar.cpp @@ -398,7 +398,7 @@ void Ide::Project(Bar& menu) { } FilePropertiesMenu(menu); if(!IsEditorMode()) { - if(SvnDirs(true).GetCount()) { + if(svn_dirs) { if(menu.IsMenuBar()) menu.Add("SVN", THISBACK(ProjectSvn)); else @@ -413,12 +413,12 @@ void Ide::FilePropertiesMenu(Bar& menu) .Help("File properties stored in package"); menu.Add(IsActiveFile() && !designer, AK_SAVEENCODING, THISBACK(ChangeCharset)) .Help("Convert actual file to different encoding"); - menu.AddMenu(IsActiveFile() && !IsFolder(editfile) && !designer, AK_DIFF, IdeImg::Diff(), THISBACK(Diff)) + menu.AddMenu(IsActiveFile() && !editfile_isfolder && !designer, AK_DIFF, IdeImg::Diff(), THISBACK(Diff)) .Help("Show differences between the project and arbitrary files"); - menu.AddMenu(IsActiveFile() && !IsFolder(editfile) && !designer, AK_PATCH, IdeImg::Patch(), THISBACK(Patch)) + menu.AddMenu(IsActiveFile() && !editfile_isfolder && !designer, AK_PATCH, IdeImg::Patch(), THISBACK(Patch)) .Help("Show differences with patch file applied"); - if(IsSvnDir(GetFileFolder(editfile))) - menu.AddMenu(IsActiveFile() && !IsFolder(editfile) && !designer, AK_SVNDIFF, IdeImg::SvnDiff(), THISBACK(SvnHistory)) + if(editfile_svn) + menu.AddMenu(IsActiveFile() && !editfile_isfolder && !designer, AK_SVNDIFF, IdeImg::SvnDiff(), THISBACK(SvnHistory)) .Help("Show svn history of file"); } @@ -431,7 +431,7 @@ void Ide::BuildFileMenu(Bar& menu) menu.Add(b, "Preprocess " + GetFileName(editfile), IdeImg::Header(), THISBACK1(Preprocess, false)) .Key(AK_PREPROCESSFILE) .Help("Preprocess current file into temporary file & open in editor"); - if(GetMethodVars(method).Get("BUILDER", "") == "GCC") + if(findarg(current_builder, "GCC", "CLANG") >= 0) menu.Add(b, "Show assembler code for " + GetFileName(editfile), THISBACK1(Preprocess, true)) .Key(AK_ASSEMBLERCODE) .Help("Compile the file into assembler code"); diff --git a/uppsrc/ide/idefile.cpp b/uppsrc/ide/idefile.cpp index 78cb23cc8..89692073c 100644 --- a/uppsrc/ide/idefile.cpp +++ b/uppsrc/ide/idefile.cpp @@ -395,6 +395,8 @@ void Ide::FlushFile() { if(!editfile.IsEmpty()) Filedata(editfile).undodata = editor.PickUndoData(); editfile.Clear(); + editfile_svn = editfile_isfolder = false; + svn_dirs = SvnDirs(true).GetCount(); // Perhaps not the best place, but should be ok editor.Clear(); editor.Disable(); editorsplit.Ctrl::Remove(); @@ -446,6 +448,9 @@ void Ide::EditFile0(const String& path, byte charset, bool astext, const String& editfile = path; editor.SetCharset(charset); AddLru(); + + editfile_isfolder = IsFolder(editfile); + svn_dirs = SvnDirs(true).GetCount(); // Perhaps not the best place, but should be ok if(!astext && !(debugger && (PathIsEqual(path, posfile[0]) || PathIsEqual(path, posfile[0]))) && editastext.Find(path) < 0 && !IsNestReadOnly(editfile)) { @@ -545,6 +550,7 @@ void Ide::EditFile0(const String& path, byte charset, bool astext, const String& editor.CheckEdited(true); editor.Annotate(editfile); editor.SyncNavigator(); + editfile_svn = IsSvnDir(GetFileFolder(editfile)); } void Ide::EditFileAssistSync() diff --git a/uppsrc/ide/idetool.cpp b/uppsrc/ide/idetool.cpp index 388f13de1..d23daacf0 100644 --- a/uppsrc/ide/idetool.cpp +++ b/uppsrc/ide/idetool.cpp @@ -360,18 +360,6 @@ void Ide::Times() while(statdlg.Run() == IDRETRY); } -Vector Ide::SvnDirs(bool actual) -{ - Vector d = GetUppDirs(); - if (actual && !IsAux()) - d.Insert(0, GetFileFolder(PackagePath(actualpackage))); - Vector r; - for(int i = 0; i < d.GetCount(); i++) - if(IsSvnDir(d[i])) - r.Add(d[i]); - return r; -} - INITBLOCK { RegisterGlobalConfig("svn-msgs"); } diff --git a/uppsrc/ide/idewin.cpp b/uppsrc/ide/idewin.cpp index 4685faef7..bc7ac80f1 100644 --- a/uppsrc/ide/idewin.cpp +++ b/uppsrc/ide/idewin.cpp @@ -591,6 +591,8 @@ Ide::Ide() warning_count = 0; editor.WhenUpdate = THISBACK(TriggerAssistSync); + + editfile_isfolder = editfile_svn = false; } Ide::~Ide()