[BUG_FIXED] Fix brace highlighting breaking issue.

[NEW] Add new encodings in the shortcuts map.
[CLEAN] Remove annoying encoding issue warning dialogs.
[ENHANCE] Enhance Html encoding auto-detection.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@577 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2009-12-01 01:20:13 +00:00
parent df88f81d9e
commit 51e96391c6
5 changed files with 120 additions and 101 deletions

View File

@ -18,10 +18,10 @@
; Define the application name ; Define the application name
!define APPNAME "Notepad++" !define APPNAME "Notepad++"
!define APPVERSION "5.6" !define APPVERSION "5.6.1"
!define APPNAMEANDVERSION "Notepad++ v5.6" !define APPNAMEANDVERSION "Notepad++ v5.6.1"
!define VERSION_MAJOR 5 !define VERSION_MAJOR 5
!define VERSION_MINOR 6 !define VERSION_MINOR 61
!define APPWEBSITE "http://notepad-plus.sourceforge.net/" !define APPWEBSITE "http://notepad-plus.sourceforge.net/"
@ -29,7 +29,7 @@
Name "${APPNAMEANDVERSION}" Name "${APPNAMEANDVERSION}"
InstallDir "$PROGRAMFILES\Notepad++" InstallDir "$PROGRAMFILES\Notepad++"
InstallDirRegKey HKLM "Software\${APPNAME}" "" InstallDirRegKey HKLM "Software\${APPNAME}" ""
OutFile "..\bin\npp.5.6.Installer.exe" OutFile "..\bin\npp.5.6.1.Installer.exe"
; GetWindowsVersion ; GetWindowsVersion
; ;

View File

@ -905,8 +905,11 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const
} }
else // if (langT == L_HTML) else // if (langT == L_HTML)
{ {
// find encoding by RegExpr const char *htmlHeaderRegExpr = "<meta[ \\t]+http-equiv[ \\t]*=[ \\t\"']*Content-Type[ \\t\"']*content[ \\t]*= *[\"']text/html;[ \\t]+charset[ \\t]*=[ \\t]*.+[\"'] */*>";
const char *htmlHeaderRegExpr = "<meta[ \\t]+http-equiv[ \\t]*=[ \\t]*\"Content-Type\"[ \\t]+content[ \\t]*=[ \\t]*\"text/html;[ \\t]+charset[ \\t]*=[ \\t]*.+\"[ \\t]*/*>"; const char *htmlHeaderRegExpr2 = "<meta[ \\t]+content[ \\t]*= *[\"']text/html;[ \\t]+charset[ \\t]*=[ \\t]*.+[ \\t\"']http-equiv[ \\t]*=[ \\t\"']*Content-Type[ \\t\"']*/*>";
const char *charsetBlock = "charset[ \\t]*=[ \\t]*[^\"']+";
const char *intermediaire = "=[ \\t]*.+";
const char *encodingStrRE = "[^ \\t=]+";
int startPos = 0; int startPos = 0;
int endPos = lenFile-1; int endPos = lenFile-1;
@ -917,15 +920,15 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const
int posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(htmlHeaderRegExpr), (LPARAM)htmlHeaderRegExpr); int posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(htmlHeaderRegExpr), (LPARAM)htmlHeaderRegExpr);
if (posFound != -1) if (posFound == -1)
{ {
const char *charsetBlockRegExpr = "charset[ \\t]*=[ \\t]*.+[\"]"; posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(htmlHeaderRegExpr2), (LPARAM)htmlHeaderRegExpr2);
posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(charsetBlockRegExpr), (LPARAM)charsetBlockRegExpr); if (posFound == -1)
return -1;
const char *charsetRegExpr = "=[ \\t]*[^\"]+"; }
posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(charsetRegExpr), (LPARAM)charsetRegExpr); posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(charsetBlock), (LPARAM)charsetBlock);
posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(intermediaire), (LPARAM)intermediaire);
posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingAliasRegExpr), (LPARAM)encodingAliasRegExpr); posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingStrRE), (LPARAM)encodingStrRE);
startPos = int(_invisibleEditView.execute(SCI_GETTARGETSTART)); startPos = int(_invisibleEditView.execute(SCI_GETTARGETSTART));
endPos = int(_invisibleEditView.execute(SCI_GETTARGETEND)); endPos = int(_invisibleEditView.execute(SCI_GETTARGETEND));
@ -937,17 +940,6 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const
int enc = em->getEncodingFromString(encodingStr); int enc = em->getEncodingFromString(encodingStr);
return (enc==CP_ACP?-1:enc); return (enc==CP_ACP?-1:enc);
} }
else
{
const char *htmlHeaderRegExpr2 = "<meta[ \\t]+content[ \\t]*=[ \\t]*\"text/html;[ \\t]+charset[ \\t]*=[ \\t]*.+\"[ \\t]*http-equiv[ \\t]*=[ \\t]*\"Content-Type\"[ \\t]+/*>";
posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(htmlHeaderRegExpr2), (LPARAM)htmlHeaderRegExpr2);
if (posFound == -1)
return -1;
//TODO
}
return -1;
}
} }
bool Notepad_plus::doReload(BufferID id, bool alert) bool Notepad_plus::doReload(BufferID id, bool alert)
@ -2772,10 +2764,18 @@ BOOL Notepad_plus::notify(SCNotification *notification)
if (notification->nmhdr.hwndFrom != _pEditView->getHSelf()) if (notification->nmhdr.hwndFrom != _pEditView->getHSelf())
break; break;
braceMatch();
NppGUI & nppGui = (NppGUI &)nppParam->getNppGUI(); NppGUI & nppGui = (NppGUI &)nppParam->getNppGUI();
static int originalColour = _pEditView->execute(SCI_STYLEGETFORE, STYLE_BRACELIGHT);
_pEditView->execute(SCI_STYLESETFORE, STYLE_BRACELIGHT, originalColour);
if (braceMatch())
{
_pEditView->clearIndicator(SCE_UNIVERSAL_TAGMATCH);
_pEditView->clearIndicator(SCE_UNIVERSAL_TAGATTR);
}
else
{
if (nppGui._enableTagsMatchHilite) if (nppGui._enableTagsMatchHilite)
{ {
XmlMatchedTagsHighlighter xmlTagMatchHiliter(_pEditView); XmlMatchedTagsHighlighter xmlTagMatchHiliter(_pEditView);
@ -2797,6 +2797,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
int lineOpposite = int(_pEditView->execute(SCI_LINEFROMPOSITION, braceOpposite)); int lineOpposite = int(_pEditView->execute(SCI_LINEFROMPOSITION, braceOpposite));
if (lineAtCaret != lineOpposite) if (lineAtCaret != lineOpposite)
{ {
StyleArray & stylers = nppParam->getMiscStylerArray(); StyleArray & stylers = nppParam->getMiscStylerArray();
int iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_TAGMATCH); int iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_TAGMATCH);
if (iFind) if (iFind)
@ -2810,6 +2811,8 @@ BOOL Notepad_plus::notify(SCNotification *notification)
} }
} }
} }
}
if (nppGui._enableSmartHilite) if (nppGui._enableSmartHilite)
{ {
@ -3174,7 +3177,7 @@ void Notepad_plus::findMatchingBracePos(int & braceAtCaret, int & braceOpposite)
braceAtCaret = -1; braceAtCaret = -1;
braceOpposite = -1; braceOpposite = -1;
TCHAR charBefore = '\0'; TCHAR charBefore = '\0';
//TCHAR styleBefore = '\0';
int lengthDoc = int(_pEditView->execute(SCI_GETLENGTH)); int lengthDoc = int(_pEditView->execute(SCI_GETLENGTH));
if ((lengthDoc > 0) && (caretPos > 0)) if ((lengthDoc > 0) && (caretPos > 0))
@ -3200,8 +3203,8 @@ void Notepad_plus::findMatchingBracePos(int & braceAtCaret, int & braceOpposite)
braceOpposite = int(_pEditView->execute(SCI_BRACEMATCH, braceAtCaret, 0)); braceOpposite = int(_pEditView->execute(SCI_BRACEMATCH, braceAtCaret, 0));
} }
// return true if 1 or 2 (matched) brace(s) is found
void Notepad_plus::braceMatch() bool Notepad_plus::braceMatch()
{ {
int braceAtCaret = -1; int braceAtCaret = -1;
int braceOpposite = -1; int braceOpposite = -1;
@ -3225,6 +3228,7 @@ void Notepad_plus::braceMatch()
} }
enableCommand(IDM_SEARCH_GOTOMATCHINGBRACE, (braceAtCaret != -1) && (braceOpposite != -1), MENU | TOOLBAR); enableCommand(IDM_SEARCH_GOTOMATCHINGBRACE, (braceAtCaret != -1) && (braceOpposite != -1), MENU | TOOLBAR);
return (braceAtCaret != -1);
} }
@ -3279,7 +3283,7 @@ void Notepad_plus::setUniModeText()
int cmdID = em->getIndexFromEncoding(encoding); int cmdID = em->getIndexFromEncoding(encoding);
if (cmdID == -1) if (cmdID == -1)
{ {
printStr(TEXT("Encoding problem. Encoding is not added in encoding_table?")); //printStr(TEXT("Encoding problem. Encoding is not added in encoding_table?"));
return; return;
} }
cmdID += IDM_FORMAT_ENCODE; cmdID += IDM_FORMAT_ENCODE;
@ -4626,7 +4630,7 @@ void Notepad_plus::command(int id)
int encoding = em->getEncodingFromIndex(index); int encoding = em->getEncodingFromIndex(index);
if (encoding == -1) if (encoding == -1)
{ {
printStr(TEXT("Encoding problem. Command is not added in encoding_table?")); //printStr(TEXT("Encoding problem. Command is not added in encoding_table?"));
return; return;
} }
@ -6401,7 +6405,7 @@ void Notepad_plus::enableConvertMenuItems(formatType f) const
enableCommand(IDM_FORMAT_TOMAC, (f != MAC_FORMAT), MENU); enableCommand(IDM_FORMAT_TOMAC, (f != MAC_FORMAT), MENU);
} }
void Notepad_plus::checkUnicodeMenuItems(/*UniMode um*/) const void Notepad_plus::checkUnicodeMenuItems() const
{ {
Buffer *buf = _pEditView->getCurrentBuffer(); Buffer *buf = _pEditView->getCurrentBuffer();
UniMode um = buf->getUnicodeMode(); UniMode um = buf->getUnicodeMode();
@ -6440,7 +6444,7 @@ void Notepad_plus::checkUnicodeMenuItems(/*UniMode um*/) const
int cmdID = em->getIndexFromEncoding(encoding); int cmdID = em->getIndexFromEncoding(encoding);
if (cmdID == -1) if (cmdID == -1)
{ {
printStr(TEXT("Encoding problem. Encoding is not added in encoding_table?")); //printStr(TEXT("Encoding problem. Encoding is not added in encoding_table?"));
return; return;
} }
cmdID += IDM_FORMAT_ENCODE; cmdID += IDM_FORMAT_ENCODE;

View File

@ -459,7 +459,7 @@ private:
void getMainClientRect(RECT & rc) const; void getMainClientRect(RECT & rc) const;
void dynamicCheckMenuAndTB() const; void dynamicCheckMenuAndTB() const;
void enableConvertMenuItems(formatType f) const; void enableConvertMenuItems(formatType f) const;
void checkUnicodeMenuItems(/*UniMode um*/) const; void checkUnicodeMenuItems() const;
generic_string getLangDesc(LangType langType, bool shortDesc = false); generic_string getLangDesc(LangType langType, bool shortDesc = false);
@ -531,7 +531,7 @@ private:
void replaceMarkedline(int ln, const TCHAR *str); void replaceMarkedline(int ln, const TCHAR *str);
generic_string getMarkedLine(int ln); generic_string getMarkedLine(int ln);
void findMatchingBracePos(int & braceAtCaret, int & braceOpposite); void findMatchingBracePos(int & braceAtCaret, int & braceOpposite);
void braceMatch(); bool braceMatch();
void activateNextDoc(bool direction); void activateNextDoc(bool direction);
void activateDoc(int pos); void activateDoc(int pos);

View File

@ -192,26 +192,41 @@ WinMenuKeyDefinition winKeyDefs[] = {
{VK_NULL, IDM_FORMAT_CONV2_UTF_8, false, false, false, NULL}, {VK_NULL, IDM_FORMAT_CONV2_UTF_8, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_CONV2_UCS_2BE, false, false, false, NULL}, {VK_NULL, IDM_FORMAT_CONV2_UCS_2BE, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_CONV2_UCS_2LE, false, false, false, NULL}, {VK_NULL, IDM_FORMAT_CONV2_UCS_2LE, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_CP855, false, false, false, NULL}, {VK_NULL, IDM_FORMAT_ISO_8859_6, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_MAC_CYRILLIC, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_KIO8U_CYRILLIC, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_KIO8R_CYRILLIC, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_DOS437, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_WIN1255, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_WIN1257, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_WIN1258, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_WIN1251, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_WIN1252, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_WIN1254, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_ISO_8859_8, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_WIN1250, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_WIN1253, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_WIN1256, false, false, false, NULL}, {VK_NULL, IDM_FORMAT_WIN1256, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_TIS_620, false, false, false, NULL}, {VK_NULL, IDM_FORMAT_ISO_8859_13, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_WIN1257, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_ISO_8859_14, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_CP855, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_ISO_8859_5, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_MAC_CYRILLIC, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_KIO8R_CYRILLIC, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_KIO8U_CYRILLIC, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_WIN1251, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_WIN1250, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_BIG5, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_GB2312, false, false, false, NULL}, {VK_NULL, IDM_FORMAT_GB2312, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_DOS437, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_ISO_8859_2, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_ISO_8859_7, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_WIN1253, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_ISO_8859_8, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_WIN1255, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_SHIFT_JIS, false, false, false, NULL}, {VK_NULL, IDM_FORMAT_SHIFT_JIS, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_EUC_KR, false, false, false, NULL}, {VK_NULL, IDM_FORMAT_EUC_KR, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_BIG5, false, false, false, NULL}, {VK_NULL, IDM_FORMAT_ISO_8859_10, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_ISO_8859_15, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_ISO_8859_4, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_ISO_8859_16, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_ISO_8859_3, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_ISO_8859_11, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_TIS_620, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_ISO_8859_9, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_WIN1254, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_WIN1252, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_ISO_8859_1, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_WIN1258, false, false, false, NULL},
{VK_NULL, IDM_SETTING_PREFERECE, false, false, false, NULL}, {VK_NULL, IDM_SETTING_PREFERECE, false, false, false, NULL},
{VK_NULL, IDM_LANGSTYLE_CONFIG_DLG, false, false, false, NULL}, {VK_NULL, IDM_LANGSTYLE_CONFIG_DLG, false, false, false, NULL},
{VK_NULL, IDM_SETTING_SHORTCUT_MAPPER, false, false, false, NULL}, {VK_NULL, IDM_SETTING_SHORTCUT_MAPPER, false, false, false, NULL},

View File

@ -18,9 +18,9 @@
#ifndef RESOURCE_H #ifndef RESOURCE_H
#define RESOURCE_H #define RESOURCE_H
#define NOTEPAD_PLUS_VERSION TEXT("Notepad++ v5.6") #define NOTEPAD_PLUS_VERSION TEXT("Notepad++ v5.6.1")
#define VERSION_VALUE TEXT("5.6\0") // should be X.Y : ie. if VERSION_DIGITALVALUE == 4, 7, 1, 0 , then X = 4, Y = 71 #define VERSION_VALUE TEXT("5.6.1\0") // should be X.Y : ie. if VERSION_DIGITALVALUE == 4, 7, 1, 0 , then X = 4, Y = 71
#define VERSION_DIGITALVALUE 5, 6, 0, 0 #define VERSION_DIGITALVALUE 5, 6, 1, 0
#ifdef UNICODE #ifdef UNICODE
#define UNICODE_ANSI_MODE TEXT("(UNICODE)") #define UNICODE_ANSI_MODE TEXT("(UNICODE)")