From 9f3ecd76fcf78456eabea58ddbcf743089d612b7 Mon Sep 17 00:00:00 2001 From: harrybharry Date: Wed, 22 Oct 2008 21:44:58 +0000 Subject: [PATCH] Add messages: NPPM_[G/S]ET_BUFFERLANGTYPE, NPPM_[G/S]ET_BUFFERENCODING, NPPM_[G/S]ET_BUFFERFORMAT, to access buffer properties. See Notepad_plus_msgs.h for details. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@345 f5eea248-9336-0410-98b8-ebc06183d4e3 --- .../MISC/PluginsManager/Notepad_plus_msgs.h | 35 +++++++++ PowerEditor/src/Notepad_plus.cpp | 74 +++++++++++++++++++ 2 files changed, 109 insertions(+) diff --git a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h index 2f5f2cdbe..1c17d3b5b 100644 --- a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h +++ b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h @@ -240,6 +240,41 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV //lParam: name to set (TCHAR*) //Buffer must have been previously unnamed (eg "new 1" document types) + #define NPPM_GETBUFFERLANGTYPE (NPPMSG + 64) + //wParam: BufferID to get LangType from + //lParam: 0 + //Returns as int, see LangType. -1 on error + + #define NPPM_SETBUFFERLANGTYPE (NPPMSG + 65) + //wParam: BufferID to set LangType of + //lParam: LangType + //Returns TRUE on success, FALSE otherwise + //use int, see LangType for possible values + //L_USER and L_EXTERNAL are not supported + + #define NPPM_GETBUFFERENCODING (NPPMSG + 66) + //wParam: BufferID to get encoding from + //lParam: 0 + //returns as int, see UniMode. -1 on error + + #define NPPM_SETBUFFERENCODING (NPPMSG + 67) + //wParam: BufferID to set encoding of + //lParam: format + //Returns TRUE on success, FALSE otherwise + //use int, see UniMode + //Can only be done on new, unedited files + + #define NPPM_GETBUFFERFORMAT (NPPMSG + 68) + //wParam: BufferID to get format from + //lParam: 0 + //returns as int, see formatType. -1 on error + + #define NPPM_SETBUFFERFORMAT (NPPMSG + 69) + //wParam: BufferID to set format of + //lParam: format + //Returns TRUE on success, FALSE otherwise + //use int, see formatType + /* #define NPPM_ADDREBAR (NPPMSG + 57) // BOOL NPPM_ADDREBAR(0, REBARBANDINFO *) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index fc80ad7cc..429999ff0 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -6805,6 +6805,80 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } break; + case NPPM_GETBUFFERLANGTYPE: + { + if (!wParam) + return -1; + BufferID id = (BufferID)wParam; + Buffer * b = MainFileManager->getBufferByID(id); + return b->getLangType(); + } + break; + + case NPPM_SETBUFFERLANGTYPE: + { + if (!wParam) + return FALSE; + if (lParam < L_TXT || lParam >= L_EXTERNAL || lParam == L_USER) + return FALSE; + + BufferID id = (BufferID)wParam; + Buffer * b = MainFileManager->getBufferByID(id); + b->setLangType((LangType)lParam); + return TRUE; + } + break; + + case NPPM_GETBUFFERENCODING: + { + if (!wParam) + return -1; + BufferID id = (BufferID)wParam; + Buffer * b = MainFileManager->getBufferByID(id); + return b->getUnicodeMode(); + } + break; + + case NPPM_SETBUFFERENCODING: + { + if (!wParam) + return FALSE; + if (lParam < uni8Bit || lParam >= uniEnd) + return FALSE; + + BufferID id = (BufferID)wParam; + Buffer * b = MainFileManager->getBufferByID(id); + if (b->getStatus() != DOC_UNNAMED || b->isDirty()) //do not allow to change the encoding if the file has any content + return FALSE; + b->setUnicodeMode((UniMode)lParam); + return TRUE; + } + break; + + case NPPM_GETBUFFERFORMAT: + { + if (!wParam) + return -1; + BufferID id = (BufferID)wParam; + Buffer * b = MainFileManager->getBufferByID(id); + return b->getFormat(); + } + break; + + case NPPM_SETBUFFERFORMAT: + { + if (!wParam) + return FALSE; + if (lParam < WIN_FORMAT || lParam >= UNIX_FORMAT) + return FALSE; + + BufferID id = (BufferID)wParam; + Buffer * b = MainFileManager->getBufferByID(id); + b->setFormat((formatType)lParam); + return TRUE; + } + break; + case NPPM_GETBUFFERIDFROMPOS: { DocTabView * pView = NULL;