[NEW] Add "Set Updater proxy..." command for setting the proxy of updater.

[BUG_FIXED] Warn user if current document is read only while replacing operation.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1022 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2013-02-17 18:02:14 +00:00
parent f911b63a5c
commit 1e10e5e4d1
6 changed files with 40 additions and 108 deletions

View File

@ -426,6 +426,12 @@ LRESULT Notepad_plus::init(HWND hwnd)
if (!nppGUI._doesExistUpdater)
{
::DeleteMenu(_mainMenuHandle, IDM_UPDATE_NPP, MF_BYCOMMAND);
::DeleteMenu(_mainMenuHandle, IDM_CONFUPDATERPROXY, MF_BYCOMMAND);
HMENU hHelpMenu = ::GetSubMenu(_mainMenuHandle, MENUINDEX_PLUGINS + 1);
if (!hHelpMenu)
hHelpMenu = ::GetSubMenu(_mainMenuHandle, MENUINDEX_PLUGINS);
if (hHelpMenu)
::DeleteMenu(hHelpMenu, 7, MF_BYPOSITION); // SEPARATOR
::DrawMenuBar(hwnd);
}
//Languages Menu
@ -5117,7 +5123,7 @@ struct Quote{
const char *_quote;
};
const int nbQuote = 108;
const int nbQuote = 109;
Quote quotes[nbQuote] = {
{"Notepad++", "Good programmers use Notepad++ to code.\nExtreme programmers use MS Word to code, in Comic Sans, center aligned."},
{"Martin Golding", "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."},
@ -5170,7 +5176,7 @@ Quote quotes[nbQuote] = {
{"Anonymous #19", "F_CK: All I need is U."},
{"Anonymous #20", "Never make eye contact when eating a banana."},
{"Anonymous #21", "I love my sixpack so much, I protect it with a layer of fat."},
{"Anonymous #22", "\"It's impossible.\" said pride.\n\"It's risky.\" said experience.\n\"It's pointless.\" said reason.\n\"Give it a try.\" whispered the heart.\n...\n\"What the hell was that?!?!?!?!?!.\" shouted the anus two minutes later."},
{"Anonymous #22", "\"It's impossible.\" said pride.\n\"It's risky.\" said experience.\n\"It's pointless.\" said reason.\n\"Give it a try.\" whispered the heart.\n...\n\"What the hell was that?!?!?!?!?!\" shouted the anus two minutes later."},
{"Anonymous #23", "Everybody talks about leaving a better planet for the children.\nWhy nobody tries to leave better children to the planet?"},
{"Anonymous #24", "I'm not saying I hate her.\nI just hope she gets fingered by wolverine"},
{"Anonymous #25", "In a way, I feel sorry for the kids of this generation.\nThey'll have parents who know how to check browser history."},
@ -5220,6 +5226,7 @@ Quote quotes[nbQuote] = {
{"Anonymous #69", "Women need a reason to have sex. Men just need a place."},
{"Anonymous #70", "If abortion is murder then are condoms kidnapping?"},
{"Anonymous #71", "Men also have feelings.\nFor example, they can feel hungry."},
{"Anonymous #72", "Project Manager:\nA person who thinks 9 women can deliver a baby in 1 month."},
{"Apple fan boy", "I'll buy a second iPhone 5 and buy a lot of iOS applications so that Apple will be able to buy Samsung (this shitty company) to shut it down and all the Apple haters will be forced to have an iPhone. Muhahaha..."},
{"Motherf*cker", "Thousands of my potential children died on your mother's face last night."},
{"Hustle Man", "Politicians are like sperm.\nOne in a million turn out to be an actual human being."},

View File

@ -787,11 +787,13 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "Notepad++ Home", IDM_HOMESWEETHOME
MENUITEM "Notepad++ Project Page", IDM_PROJECTPAGE
MENUITEM "Online Documentation", IDM_ONLINEHELP
MENUITEM "Online Documentation", IDM_ONLINEHELP
MENUITEM "Forum", IDM_FORUM
MENUITEM "Get More Plugins", IDM_PLUGINSHOME
MENUITEM SEPARATOR
MENUITEM "Update Notepad++", IDM_UPDATE_NPP
MENUITEM "Set Updater Proxy", IDM_CONFUPDATERPROXY
MENUITEM SEPARATOR
MENUITEM "About Notepad++", IDM_ABOUT
END

View File

@ -2099,6 +2099,7 @@ void Notepad_plus::command(int id)
}
case IDM_UPDATE_NPP :
case IDM_CONFUPDATERPROXY :
{
generic_string updaterDir = (NppParameters::getInstance())->getNppPath();
PathAppend(updaterDir ,TEXT("updater"));
@ -2108,6 +2109,10 @@ void Notepad_plus::command(int id)
generic_string param = TEXT("-verbose -v");
param += VERSION_VALUE;
if (id == IDM_CONFUPDATERPROXY)
param = TEXT("-options");
Process updater(updaterFullPath.c_str(), param.c_str(), updaterDir.c_str());
updater.run();

View File

@ -203,6 +203,13 @@ void AutoCompletion::update(int character)
}
else if (nppGUI._autocStatus == nppGUI.autoc_func)
showAutoComplete();
/*
if (nppGUI._autocStatus == nppGUI.autoc_word)
showWordComplete(false);
else if (nppGUI._autocStatus == nppGUI.autoc_func)
showAutoComplete();
*/
}
}

View File

@ -174,18 +174,13 @@ void Searching::displaySectionCentered(int posStart, int posEnd, ScintillaEditVi
LONG FindReplaceDlg::originalFinderProc = NULL;
#ifdef UNICODE
void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool)
#else
void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUTF8)
#endif
{
if (!hCombo) return;
if (!lstrcmp(txt2add, TEXT(""))) return;
int i = 0;
#ifdef UNICODE
i = ::SendMessage(hCombo, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)txt2add);
if (i != CB_ERR) // found
{
@ -194,94 +189,13 @@ void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUT
i = ::SendMessage(hCombo, CB_INSERTSTRING, 0, (LPARAM)txt2add);
#else
TCHAR text[FINDREPLACE_MAXLENGTH];
bool isWin9x = _winVer <= WV_ME;
wchar_t wchars2Add[FINDREPLACE_MAXLENGTH];
wchar_t textW[FINDREPLACE_MAXLENGTH];
int count = ::SendMessage(hCombo, CB_GETCOUNT, 0, 0);
if (isUTF8)
::MultiByteToWideChar(CP_UTF8, 0, txt2add, -1, wchars2Add, FINDREPLACE_MAXLENGTH - 1);
for ( ; i < count ; i++)
{
if (isUTF8)
{
if (!isWin9x)
::SendMessageW(hCombo, CB_GETLBTEXT, i, (LPARAM)textW);
else
{
::SendMessageA(hCombo, CB_GETLBTEXT, i, (LPARAM)text);
::MultiByteToWideChar(CP_ACP, 0, text, -1, textW, FINDREPLACE_MAXLENGTH - 1);
}
if (!wcscmp(wchars2Add, textW))
{
::SendMessage(hCombo, CB_DELETESTRING, i, 0);
break;
}
}
else
{
::SendMessage(hCombo, CB_GETLBTEXT, i, (LPARAM)text);
if (!strcmp(txt2add, text))
{
::SendMessage(hCombo, CB_DELETESTRING, i, 0);
break;
}
}
}
if (!isUTF8)
i = ::SendMessage(hCombo, CB_INSERTSTRING, 0, (LPARAM)txt2add);
else
{
if (!isWin9x)
i = ::SendMessageW(hCombo, CB_INSERTSTRING, 0, (LPARAM)wchars2Add);
else
{
::WideCharToMultiByte(CP_ACP, 0, wchars2Add, -1, text, FINDREPLACE_MAXLENGTH - 1, NULL, NULL);
i = ::SendMessageA(hCombo, CB_INSERTSTRING, 0, (LPARAM)text);
}
}
#endif
::SendMessage(hCombo, CB_SETCURSEL, i, 0);
}
#ifdef UNICODE
generic_string FindReplaceDlg::getTextFromCombo(HWND hCombo, bool) const
#else
generic_string FindReplaceDlg::getTextFromCombo(HWND hCombo, bool isUnicode) const
#endif
{
TCHAR str[FINDREPLACE_MAXLENGTH];
#ifdef UNICODE
::SendMessage(hCombo, WM_GETTEXT, FINDREPLACE_MAXLENGTH - 1, (LPARAM)str);
#else
bool isWin9x = _winVer <= WV_ME;
if (isUnicode)
{
wchar_t wchars[FINDREPLACE_MAXLENGTH];
if ( !isWin9x )
{
::SendMessageW(hCombo, WM_GETTEXT, FINDREPLACE_MAXLENGTH - 1, (LPARAM)wchars);
}
else
{
char achars[FINDREPLACE_MAXLENGTH];
::SendMessageA(hCombo, WM_GETTEXT, FINDREPLACE_MAXLENGTH - 1, (LPARAM)achars);
::MultiByteToWideChar(CP_ACP, 0, achars, -1, wchars, FINDREPLACE_MAXLENGTH - 1);
}
::WideCharToMultiByte(CP_UTF8, 0, wchars, -1, str, FINDREPLACE_MAXLENGTH - 1, NULL, NULL);
}
else
{
::SendMessage(hCombo, WM_GETTEXT, FINDREPLACE_MAXLENGTH - 1, (LPARAM)str);
}
#endif
return generic_string(str);
}
@ -1377,12 +1291,15 @@ bool FindReplaceDlg::processReplace(const TCHAR *txt2find, const TCHAR *txt2repl
if (!txt2find || !txt2find[0] || !txt2replace)
return false;
if ((*_ppEditView)->getCurrentBuffer()->isReadOnly())
{
::MessageBox(_hParent, TEXT("Cannot replace text. The current document is read only."), TEXT("Find/Replace"), MB_ICONERROR | MB_OK);
return false;
}
FindOption replaceOptions = options ? *options : *_env;
replaceOptions._incrementalType = FirstIncremental;
if ((*_ppEditView)->getCurrentBuffer()->isReadOnly()) return false;
Sci_CharacterRange currentSelection = (*_ppEditView)->getSelection();
FindStatus status;
moreMatches = processFindNext(txt2find, &replaceOptions, &status, FINDNEXTTYPE_FINDNEXTFORREPLACE);
@ -1459,6 +1376,12 @@ int FindReplaceDlg::markAllInc(const FindOption *opt)
int FindReplaceDlg::processAll(ProcessOperation op, const FindOption *opt, bool isEntire, const TCHAR *fileName, int colourStyleID)
{
if (op == ProcessReplaceAll && (*_ppEditView)->getCurrentBuffer()->isReadOnly())
{
::MessageBox(_hParent, TEXT("Cannot replace text. The current document is read only."), TEXT("Replace all"), MB_ICONERROR | MB_OK);
return 0;
}
const FindOption *pOptions = opt?opt:_env;
const TCHAR *txt2find = pOptions->_str2Search.c_str();
const TCHAR *txt2replace = pOptions->_str4Replace.c_str();
@ -1651,21 +1574,8 @@ int FindReplaceDlg::processRange(ProcessOperation op, const TCHAR *txt2find, con
int end_mark = targetEnd - lstart;
(*_ppEditView)->getGenericText(lineBuf, 1024, lstart, lend, &start_mark, &end_mark);
generic_string line;
#ifdef UNICODE
line = lineBuf;
#else
UINT cp = (*_ppEditView)->execute(SCI_GETCODEPAGE);
if (cp != SC_CP_UTF8)
{
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
const wchar_t *pTextW = wmc->char2wchar(lineBuf, ::GetACP());
const char *pTextA = wmc->wchar2char(pTextW, SC_CP_UTF8);
line = pTextA;
}
else
line = lineBuf;
#endif
generic_string line = lineBuf;
line += TEXT("\r\n");
SearchResultMarking srm;
srm._start = start_mark;

View File

@ -418,6 +418,7 @@
#define IDM_UPDATE_NPP (IDM_ABOUT + 6)
#define IDM_WIKIFAQ (IDM_ABOUT + 7)
#define IDM_HELP (IDM_ABOUT + 8)
#define IDM_CONFUPDATERPROXY (IDM_ABOUT + 9)
#define IDM_SETTING (IDM + 8000)