This commit is contained in:
Don HO 2016-07-23 11:39:04 +02:00
commit 83f291acf8
11 changed files with 120 additions and 149 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<NotepadPlus>
<Native-Langue name="Polish" filename="polish.xml" version="6.8.2">
<Native-Langue name="Polish" filename="polish.xml" version="6.9.2">
<Menu>
<Main>
<!-- Main Menu Entries -->
@ -92,7 +92,7 @@
<Item id="41016" name="Usuń z dysku"/>
<Item id="41017" name="Zmień nazwę..."/>
<Item id="41021" name="Odzyskaj ostatnio zamknięty plik"/>
<Item id="41022" name="Otwórz folder jako obszar roboczy..."/>
<Item id="42001" name="Wyt&amp;nij"/>
<Item id="42002" name="&amp;Kopiuj"/>
<Item id="42003" name="C&amp;ofnij"/>
@ -237,6 +237,7 @@
<Item id="44082" name="Panel projektu &amp;2"/>
<Item id="44083" name="Panel projektu &amp;3"/>
<Item id="44084" name="Lista funkcji"/>
<Item id="44085" name="Widok obszaru roboczego"/>
<Item id="44086" name="1. Zakładka"/>
<Item id="44087" name="2. Zakładka"/>
<Item id="44088" name="3. Zakładka"/>
@ -248,7 +249,7 @@
<Item id="44094" name="9. Zakładka"/>
<Item id="44095" name="Kolejne zakładki"/>
<Item id="44096" name="Poprzednia zakładka"/>
<Item id="44097" name="Monitorowanie pliku (tail -f)" />
<Item id="45001" name="Konwertuj na format Windows"/>
<Item id="45002" name="Konwertuj na format Unix"/>
<Item id="45003" name="Konwertuj na format Mac"/>
@ -288,7 +289,8 @@
<Item id="47006" name="Uaktualnij Notepad++"/>
<Item id="47009" name="Ustaw proxy aktualizacji..."/>
<Item id="47010" name="Argumenty linii poleceń..."/>
<Item id="47011" name="Pomoc na żywo"/>
<Item id="47011" name="Czat użytkowników..."/>
<Item id="47012" name="Informacje o środowisku..."/>
<Item id="48005" name="Importuj wtyczki..."/>
<Item id="48006" name="Importuj motywy..."/>
<Item id="48009" name="Skróty klawiaturowe..."/>
@ -684,6 +686,7 @@
<Item id="6413" name="Folder domyślny (otwórz/zapisz)"/>
<Item id="6414" name="Według bieżącego dokumentu"/>
<Item id="6415" name="Zapamiętaj ostatnio użyty folder"/>
<Item id="6430" name="Użyj nowego stylu okna zapisywania (bez domyślnego rozszerzenia pliku)" />
</DefaultDir>
<FileAssoc title="Powiązania plików">
@ -827,6 +830,7 @@
<Item id="6333" name="Inteligentne podświetlanie"/>
<Item id="6334" name="Automatycznie rozpoznaj kodowanie"/>
<Item id="6335" name="Użyj '\' jako znaku ucieczki dla SQL"/>
<Item id="6337" name="Roz. pliku obszaru rob.:"/>
</MISC>
</Preference>
<MultiMacro title="Uruchom makro wielokrotnie">
@ -908,6 +912,9 @@ Twoje ustawienia w chmurze zostaną anulowane. Zmień miejsce zapisu ustawień p
<SortTip name="Sortuj" />
<ReloadTip name="Odśwież" />
</FunctionList>
<FileBrowser>
<PanelTitle name="Obszar roboczy"/>
</FileBrowser>
<ProjectManager>
<PanelTitle name="Projekt"/>
<WorkspaceRootName name="Obszar roboczy"/>

View File

@ -26,6 +26,7 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include <algorithm>
#include <stdexcept>
#include <sstream>
#include <shlwapi.h>
#include <shlobj.h>
#include <uxtheme.h>
@ -37,6 +38,7 @@
WcharMbcsConvertor* WcharMbcsConvertor::_pSelf = new WcharMbcsConvertor;
typedef std::basic_stringstream<TCHAR> generic_stringstream;
@ -53,6 +55,13 @@ void printStr(const TCHAR *str2print)
::MessageBox(NULL, str2print, TEXT(""), MB_OK);
}
generic_string commafyInt(size_t n)
{
generic_stringstream ss;
ss.imbue(std::locale(""));
ss << n;
return ss.str();
}
std::string getFileContent(const TCHAR *file2read)
{

View File

@ -71,6 +71,7 @@ generic_string getFolderName(HWND parent, const TCHAR *defaultDir = NULL);
void printInt(int int2print);
void printStr(const TCHAR *str2print);
generic_string commafyInt(size_t n);
void writeLog(const TCHAR *logFileName, const char *log2write);
int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep);

View File

@ -3031,19 +3031,22 @@ void Notepad_plus::updateStatusBar()
long selected_length = _pEditView->getSelectedLength();
if (selected_length != -1)
wsprintf(strSel, TEXT("Sel : %d | %d"), selected_length, selLine);
wsprintf(strSel, TEXT("Sel : %s | %s"), commafyInt(selected_length).c_str(), commafyInt(selLine).c_str());
else
wsprintf(strSel, TEXT("Sel : %s"), TEXT("N/A"));
wsprintf(strLnCol, TEXT("Ln : %d Col : %d %s"),\
(_pEditView->getCurrentLineNumber() + 1), \
(_pEditView->getCurrentColumnNumber() + 1),\
strSel);
wsprintf(strLnCol, TEXT("Ln : %s Col : %s %s"),
commafyInt(_pEditView->getCurrentLineNumber() + 1).c_str(),
commafyInt(_pEditView->getCurrentColumnNumber() + 1).c_str(),
strSel);
_statusBar.setText(strLnCol, STATUSBAR_CUR_POS);
TCHAR strDocLen[256];
wsprintf(strDocLen, TEXT("length : %d lines : %d"), _pEditView->getCurrentDocLen(), _pEditView->execute(SCI_GETLINECOUNT));
wsprintf(strDocLen, TEXT("length : %s lines : %s"),
commafyInt(_pEditView->getCurrentDocLen()).c_str(),
commafyInt(_pEditView->execute(SCI_GETLINECOUNT)).c_str());
_statusBar.setText(strDocLen, STATUSBAR_DOC_SIZE);
_statusBar.setText(_pEditView->execute(SCI_GETOVERTYPE) ? TEXT("OVR") : TEXT("INS"), STATUSBAR_TYPING_MODE);
}

View File

@ -1686,10 +1686,8 @@ void Notepad_plus::command(int id)
characterNumber += curBuf->getFileTime(Buffer::ft_modified);
characterNumber += TEXT("\r");
TCHAR fileLenStr[64];
generic_sprintf(fileLenStr, TEXT("%I64u"), static_cast<UINT64>( fileLen ) );
characterNumber += fileLenLabel;
characterNumber += fileLenStr;
characterNumber += commafyInt(static_cast<UINT64>(fileLen)).c_str();
characterNumber += TEXT("\r");
characterNumber += TEXT("\r");
}
@ -1710,42 +1708,27 @@ void Notepad_plus::command(int id)
auto nbSelByte = getSelectedBytes();
auto nbRange = getSelectedAreas();
TCHAR nbCharStr[32];
TCHAR nbWordStr[16];
TCHAR nbByteStr[32];
TCHAR nbLineStr[32];
TCHAR nbSelStr[32];
TCHAR nbSelByteStr[32];
TCHAR nbRangeStr[8];
generic_sprintf(nbCharStr, TEXT("%d"), nbChar);
characterNumber += nbCharLabel;
characterNumber += nbCharStr;
characterNumber += commafyInt(nbChar).c_str();
characterNumber += TEXT("\r");
generic_sprintf(nbWordStr, TEXT("%d"), nbWord);
characterNumber += nbWordLabel;
characterNumber += nbWordStr;
characterNumber += commafyInt(nbWord).c_str();
characterNumber += TEXT("\r");
generic_sprintf(nbLineStr, TEXT("%d"), static_cast<int>( nbLine ) );
characterNumber += nbLineLabel;
characterNumber += nbLineStr;
characterNumber += commafyInt(static_cast<int>(nbLine)).c_str();
characterNumber += TEXT("\r");
generic_sprintf(nbByteStr, TEXT("%d"), nbByte);
characterNumber += nbByteLabel;
characterNumber += nbByteStr;
characterNumber += commafyInt(nbByte).c_str();
characterNumber += TEXT("\r");
generic_sprintf(nbSelStr, TEXT("%d"), nbSel);
generic_sprintf(nbSelByteStr, TEXT("%d"), nbSelByte);
generic_sprintf(nbRangeStr, TEXT("%d"), nbRange);
characterNumber += nbSelStr;
characterNumber += commafyInt(nbSel).c_str();
characterNumber += nbSelLabel1;
characterNumber += nbSelByteStr;
characterNumber += commafyInt(nbSelByte).c_str();
characterNumber += nbSelLabel2;
characterNumber += nbRangeStr;
characterNumber += commafyInt(nbRange).c_str();
characterNumber += nbRangeLabel;
characterNumber += TEXT("\r");

View File

@ -422,7 +422,7 @@ static const ScintillaKeyDefinition scintKeyDefs[] =
{TEXT("SCI_LINEENDDISPLAY"), SCI_LINEENDDISPLAY, false, true, false, VK_END, 0},
{TEXT("SCI_LINEENDDISPLAYEXTEND"), SCI_LINEENDDISPLAYEXTEND, false, false, false, 0, 0},
{TEXT("SCI_LINEENDWRAP"), SCI_LINEENDWRAP, false, false, false, VK_END, 0},
{TEXT("SCI_LINEENDWRAPEXTEND"), SCI_LINEENDWRAPEXTEND, false, false, false, 0, 0},
{TEXT("SCI_LINEENDEXTEND"), SCI_LINEENDEXTEND, false, false, false, 0, 0},
{TEXT("SCI_DOCUMENTSTART"), SCI_DOCUMENTSTART, true, false, false, VK_HOME, 0},
{TEXT("SCI_DOCUMENTSTARTEXTEND"), SCI_DOCUMENTSTARTEXTEND, true, false, true, VK_HOME, 0},
{TEXT("SCI_DOCUMENTEND"), SCI_DOCUMENTEND, true, false, false, VK_END, 0},

View File

@ -368,7 +368,7 @@ bool AutoCompletion::showFunctionComplete()
return false;
}
void AutoCompletion::getCloseTag(char *closeTag, size_t closeTagSize, size_t caretPos, LangType language)
void AutoCompletion::getCloseTag(char *closeTag, size_t closeTagSize, size_t caretPos, bool isHTML)
{
char prev = (char)_pEditView->execute(SCI_GETCHARAT, caretPos - 2);
char prevprev = (char)_pEditView->execute(SCI_GETCHARAT, caretPos - 3);
@ -404,12 +404,15 @@ void AutoCompletion::getCloseTag(char *closeTag, size_t closeTagSize, size_t car
if (tagHead[1] == '/') // "</toto>" will be ignored
return;
if (tagHead[1] == '?') // "<?" (Processing Instructions) will be ignored
return;
if (strncmp(tagHead, "<!--", 4) == 0) // Comments will be ignored
return;
if (language == L_HTML) // for HTML: "br", "hr", "img", "link", "!doctype" and "meta" will be ignored
if (isHTML) // for HTML: "br", "hr", "img", "link", "!doctype" and "meta" will be ignored
{
const char *disallowedTags[] = { "br", "hr", "img", "link", "meta", "!doctype" };
char *disallowedTags[] = { "br", "hr", "img", "link", "meta", "!doctype" };
size_t disallowedTagsLen = sizeof(disallowedTags) / sizeof(char *);
for (size_t i = 0; i < disallowedTagsLen; ++i)
{
@ -417,12 +420,6 @@ void AutoCompletion::getCloseTag(char *closeTag, size_t closeTagSize, size_t car
return;
}
}
else if (language == L_XML)
{
// Ignore "?xml"
if (strnicmp(tagHead + 1, "?xml", strlen("?xml")) == 0)
return;
}
closeTag[0] = '<';
closeTag[1] = '/';
@ -642,7 +639,7 @@ void AutoCompletion::insertMatchedChars(int character, const MatchedPairConf & m
{
if (matchedPairConf._doHtmlXmlTag && (_curLang == L_HTML || _curLang == L_XML))
{
getCloseTag(closeTag, tagMaxLen, caretPos, _curLang);
getCloseTag(closeTag, tagMaxLen, caretPos, _curLang == L_HTML);
if (closeTag[0] != '\0')
matchedChars = closeTag;
}

View File

@ -84,7 +84,7 @@ public:
void insertMatchedChars(int character, const MatchedPairConf & matchedPairConf);
void update(int character);
void callTipClick(int direction);
void getCloseTag(char *closeTag, size_t closeTagLen, size_t caretPos, LangType language);
void getCloseTag(char *closeTag, size_t closeTagLen, size_t caretPos, bool isHTML);
private:
bool _funcCompletionActive = false;

View File

@ -39,54 +39,25 @@ SmartHighlighter::SmartHighlighter(FindReplaceDlg * pFRDlg)
void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView)
{
//Get selection
CharacterRange range = pHighlightView->getSelection();
//Clear marks
// Clear marks
pHighlightView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_SMART);
//If nothing selected, dont mark anything
if (range.cpMin == range.cpMax)
{
// If nothing selected, dont mark anything
if (pHighlightView->execute(SCI_GETSELECTIONEMPTY) == 1)
return;
auto curPos = pHighlightView->execute(SCI_GETCURRENTPOS);
auto wordStart = pHighlightView->execute(SCI_WORDSTARTPOSITION, curPos, true);
auto wordEnd = pHighlightView->execute(SCI_WORDENDPOSITION, wordStart, true);
auto range = pHighlightView->getSelection();
// Make sure the "word" positions match the current selection
if (wordStart == wordEnd || wordStart != range.cpMin || wordEnd != range.cpMax)
return;
}
int textlen = range.cpMax - range.cpMin + 1;
char * text2Find = new char[textlen];
pHighlightView->getSelectedText(text2Find, textlen, false); //do not expand selection (false)
//GETWORDCHARS for isQualifiedWord2() and isWordChar2()
auto listCharSize = pHighlightView->execute(SCI_GETWORDCHARS, 0, 0);
char *listChar = new char[listCharSize+1];
pHighlightView->execute(SCI_GETWORDCHARS, 0, (LPARAM)listChar);
listChar[listCharSize] = '\0';
bool valid = true;
//The word has to consist if wordChars only, and the characters before and after something else
if (!isQualifiedWord(text2Find, listChar))
valid = false;
else
{
UCHAR c = (UCHAR)pHighlightView->execute(SCI_GETCHARAT, range.cpMax);
if (c)
{
if (isWordChar(char(c), listChar))
valid = false;
}
c = (UCHAR)pHighlightView->execute(SCI_GETCHARAT, range.cpMin-1);
if (c)
{
if (isWordChar(char(c), listChar))
valid = false;
}
}
if (!valid) {
delete [] text2Find;
delete [] listChar;
return;
}
pHighlightView->getSelectedText(text2Find, textlen, false); //do not expand selection (false)
// save target locations for other search functions
auto originalStartPos = pHighlightView->execute(SCI_GETTARGETSTART);
@ -140,28 +111,6 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView)
// restore the original targets to avoid conflicts with the search/replace functions
pHighlightView->execute(SCI_SETTARGETRANGE, originalStartPos, originalEndPos);
delete [] listChar;
delete[] text2Find;
}
bool SmartHighlighter::isQualifiedWord(const char *str, char *listChar) const
{
for (size_t i = 0, len = strlen(str) ; i < len ; ++i)
{
if (!isWordChar(str[i], listChar))
return false;
}
return true;
};
bool SmartHighlighter::isWordChar(char ch, char listChar[]) const
{
for (size_t i = 0, len = strlen(listChar) ; i < len ; ++i)
{
if (ch == listChar[i])
{
return true;
}
}
return false;
};

View File

@ -37,9 +37,6 @@ public:
void highlightView(ScintillaEditView * pHighlightView);
private:
FindReplaceDlg * _pFRDlg;
bool isQualifiedWord(const char *str, char listChar[]) const;
bool isWordChar(char ch, char listChar[]) const;
};
#endif //SMARTHIGHLIGHTER_H

View File

@ -31,6 +31,7 @@ http://notepad-plus-plus.org/features/function-list.html
<association langID="22" id="python_function"/>
<association langID="26" id="bash_function"/>
<association langID="28" id="nsis_syntax"/>
<association langID="36" id="ruby_function"/>
<!--
if langID cannot be found above, you can still set the file extensions
<association ext=".my_passer_ext1" id="my_passer_id"/>
@ -172,39 +173,39 @@ http://notepad-plus-plus.org/features/function-list.html
</function>
</parser>
<parser id="php_function" displayName="PHP" commentExpr="((/\*.*?\*)/|(//.*?$))">
<classRange
mainExpr="^[\s]*(class|abstract[\s]+class|final[\s]+class)[\t ]+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*([\s]*|[\s]*(extends|implements|(extends[\s]+(\\|[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)+[\s]+implements))[\s]+(\,[\s]*|(\\|[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*))+[\s]*)?\{"
openSymbole = "\{"
closeSymbole = "\}"
displayMode="node">
<className>
<nameExpr expr="(class|abstract[\s]+class|final[\s]+class)[\s]+[\w]+"/>
<nameExpr expr="[\s]+[\w]+\Z"/>
<nameExpr expr="[\w]+\Z"/>
</className>
<function
mainExpr="^[\s]*((static|public|protected|private|final)*(\s+(static|public|protected|private|final))+[\s]+)?(function[\s]+)+([\w]+([\s]+[\w]+)?([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+))?([\w_]+[\s]*::)?(?!(if|while|for|switch))[\w_~]+[\s]*\([^\{]*\{">
<functionName>
<funcNameExpr expr="(?!(if|while|for|switch))[\w_]+[\s]*\([^\{]*"/>
<!-- comment below node if want display method with parmas -->
<funcNameExpr expr="(?!(if|while|for|switch))[\w_]+"/>
</functionName>
</function>
</classRange>
<function
mainExpr="^[\s]*function[\s]+\w+\("
displayMode="$className->$functionName">
<functionName>
<nameExpr expr="(?!(if|while|for))[\w_]+[\s]*\("/>
<nameExpr expr="(?!(if|while|for))[\w_]+"/>
</functionName>
<className>
<nameExpr expr="[\w_]+(?=[\s]*::)"/>
</className>
</function>
</parser>
<parser id="php_function" displayName="PHP" commentExpr="((/\*.*?\*)/|(//.*?$))">
<classRange
mainExpr="^[\s]*(class|abstract[\s]+class|final[\s]+class)[\t ]+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*([\s]*|[\s]*(extends|implements|(extends[\s]+(\\|[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)+[\s]+implements))[\s]+(\,[\s]*|(\\|[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*))+[\s]*)?\{"
openSymbole = "\{"
closeSymbole = "\}"
displayMode="node">
<className>
<nameExpr expr="(class|abstract[\s]+class|final[\s]+class)[\s]+[\w]+"/>
<nameExpr expr="[\s]+[\w]+\Z"/>
<nameExpr expr="[\w]+\Z"/>
</className>
<function
mainExpr="^[\s]*((static|public|protected|private|final)*(\s+(static|public|protected|private|final))+[\s]+)?(function[\s]+)+([\w]+([\s]+[\w]+)?([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+))?([\w_]+[\s]*::)?(?!(if|while|for|switch))[\w_~]+[\s]*\([^\{]*\{">
<functionName>
<funcNameExpr expr="(?!(if|while|for|switch))[\w_]+[\s]*\([^\{]*"/>
<!-- comment below node if want display method with parmas -->
<funcNameExpr expr="(?!(if|while|for|switch))[\w_]+"/>
</functionName>
</function>
</classRange>
<function
mainExpr="^[\s]*function[\s]+\w+\("
displayMode="$className->$functionName">
<functionName>
<nameExpr expr="(?!(if|while|for))[\w_]+[\s]*\("/>
<nameExpr expr="(?!(if|while|for))[\w_]+"/>
</functionName>
<className>
<nameExpr expr="[\w_]+(?=[\s]*::)"/>
</className>
</function>
</parser>
<parser id="bash_function" displayName="Shell" commentExpr="(#.*?$)">
<function
mainExpr="^[\t ]*(function[\t\r\n ]*)?([a-zA-Z0-9_])+[\t\r\n ]*(\([^\)]*\))?[\t\r\n ]*(\{)[^(\})\r\n\t ]*"
@ -214,6 +215,7 @@ http://notepad-plus-plus.org/features/function-list.html
</functionName>
</function>
</parser>
<parser id="python_function" displayName="Python class" commentExpr="(#.*?$|'''.*?('''|\Z))">
<classRange mainExpr="(?&lt;=^class ).*?(?=\n\S|\Z)">
<className>
@ -232,6 +234,29 @@ http://notepad-plus-plus.org/features/function-list.html
</function>
</parser>
<parser id="ruby_function" displayName="Ruby">
<!-- within a class-->
<classRange
mainExpr="(?&lt;=^class ).*?(?=\n\S|\Z)"
displayMode="node" >
<className>
<nameExpr expr="\w+"/>
</className>
<function mainExpr="^\s*def\s+\w+" displayMode="$className->$functionName" >
<functionName>
<funcNameExpr expr="(?&lt;=def\s)\w+"/>
</functionName>
</function>
</classRange>
<!-- without class-->
<function mainExpr="^\s*def\s+\w+" displayMode="$functionName" >
<functionName>
<nameExpr expr="(?&lt;=def\s)\w+"/>
</functionName>
</function>
</parser>
<parser id="cs_function" displayName="C# Class" commentExpr="((/\*.*?\*)/|(//.*?$))">
<classRange
mainExpr="^[\t ]*((public|protected|private|internal)[\s]+)?([\w]+[\s]*)?(class|struct|interface)[\t ]+[^\{]+\{"