From e2f6ad4db347c2462ed85561e486eba5e623c493 Mon Sep 17 00:00:00 2001 From: cxl Date: Tue, 16 Jun 2020 16:13:01 +0000 Subject: [PATCH] ide: Insert file path now has some file filters, fixed minor issue with rename/duplicate package git-svn-id: svn://ultimatepp.org/upp/trunk@14601 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/ide/Insert.cpp | 29 +++++++++++++++++------------ uppsrc/ide/SelectPkg.cpp | 2 ++ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/uppsrc/ide/Insert.cpp b/uppsrc/ide/Insert.cpp index 4e6a07346..8f13b1ee2 100644 --- a/uppsrc/ide/Insert.cpp +++ b/uppsrc/ide/Insert.cpp @@ -148,11 +148,26 @@ void Ide::InsertText(const String& text) editor.Paste(text.ToWString()); } +String SelectInsertFile() +{ + return SelectFileOpen( + "All files (*.*)\t*.*\n" + "Graphics files (*.png *.bmp *.jpg *.jpeg *.gif *.ico *.svg)\t*.png *.bmp *.jpg *.jpeg *.gif *.ico *.svg\n" + "Source files (*.cpp *.h *.hpp *.c *.C *.cc *.cxx *.icpp *.diff *.patch *.lay *.py *.pyc *.pyd *.pyo *.iml *.java *.lng *.sch *.usc *.rc *.brc *.upt *.witz *.js)\t" + "*.cpp *.h *.hpp *.c *.C *.cc *.cxx *.icpp *.diff *.patch *.lay *.py *.pyc *.pyd *.pyo *.iml *.java *.lng *.sch *.usc *.rc *.brc *.upt *.witz *.js\n" + "Web files (*.js *.css *.html *.htm *.htmls)\t*.js *.css *.html *.htm *.htmls\n" + "Data files (*.csv *.xml *.json)\t*.csv *.xml *.json\n" + "Text files (*.txt *.log *.info)\t*.txt *.log *.info\n" + "Document files (*.xlsx *.xls *.doc *.qtf *.odt *.ods *.pdf)\t*.xlsx *.xls *.doc *.qtf *.odt *.ods *.pdf\n" + "Compressed files (*.zip *.7z *.gz *.xz)\t*.zip *.7z *.gz *.xz\n" + ); +} + void Ide::InsertFilePath(bool c) { if(editor.IsReadOnly()) return; - String path = SelectFileOpen("All files\t*.*"); + String path = SelectInsertFile(); path.Replace("\\", "/"); if(path.GetCount()) { if(c) @@ -212,7 +227,7 @@ void Ide::InsertFileBase64() { if(editor.IsReadOnly()) return; - String path = SelectFileOpen("All files\t*.*"); + String path = SelectInsertFile(); path.Replace("\\", "/"); if(path.GetCount()) { if(GetFileLength(path) >= 20*1024) { @@ -221,16 +236,6 @@ void Ide::InsertFileBase64() } InsertAs(LoadFile(path)); } -/* String s = Encode64(LoadFile(path)); - int i = 0; - while(i < s.GetLength()) { - int n = min(s.GetCount() - i, 2000); - if(i) - editor.Paste("\n"); - editor.Paste(AsCString(s.Mid(i, n)).ToWString()); - i += n; - } - }*/ } void Ide::InsertMenu(Bar& bar) diff --git a/uppsrc/ide/SelectPkg.cpp b/uppsrc/ide/SelectPkg.cpp index b07b90626..bcd13620c 100644 --- a/uppsrc/ide/SelectPkg.cpp +++ b/uppsrc/ide/SelectPkg.cpp @@ -78,7 +78,9 @@ again: return; if(!RenamePackageFs(PackagePath(GetCurrentName()), n, duplicate)) goto again; + search <<= Null; Load(n); + alist.ScrollIntoCursor(); } void SelectPackageDlg::MovePackage(bool copy)