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
This commit is contained in:
harrybharry 2008-10-22 21:44:58 +00:00
parent 15afe60aea
commit 9f3ecd76fc
2 changed files with 109 additions and 0 deletions

View File

@ -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 *)

View File

@ -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;