[BUG_FIXED] Fix the initial document encoding is not set by "New Document Settings".

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@707 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2010-11-17 00:34:45 +00:00
parent 2179160db9
commit 8b2fe6f459
2 changed files with 10 additions and 16 deletions

View File

@ -843,20 +843,6 @@ void Notepad_plus::fileNew()
BufferID newBufID = MainFileManager->newEmptyDocument(); BufferID newBufID = MainFileManager->newEmptyDocument();
loadBufferIntoView(newBufID, currentView(), true); //true, because we want multiple new files if possible loadBufferIntoView(newBufID, currentView(), true); //true, because we want multiple new files if possible
activateBuffer(newBufID, currentView()); activateBuffer(newBufID, currentView());
NppParameters *pNppParam = NppParameters::getInstance();
NppGUI & nppGUI = (NppGUI & )pNppParam->getNppGUI();
NewDocDefaultSettings & ndds = (NewDocDefaultSettings &)nppGUI.getNewDocDefaultSettings();
if (ndds._codepage != -1)
{
EncodingMapper *em = EncodingMapper::getInstance();
int cmdID = em->getIndexFromEncoding(ndds._codepage);
if (cmdID != -1)
{
cmdID += IDM_FORMAT_ENCODE;
::SendMessage(_pPublicInterface->getHSelf(), WM_COMMAND, cmdID, 0);
}
}
} }
bool Notepad_plus::isFileSession(const TCHAR * filename) { bool Notepad_plus::isFileSession(const TCHAR * filename) {

View File

@ -23,6 +23,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "Parameters.h" #include "Parameters.h"
#include "Notepad_plus.h" #include "Notepad_plus.h"
#include "ScintillaEditView.h" #include "ScintillaEditView.h"
#include "EncodingMapper.h"
FileManager * FileManager::_pSelf = new FileManager(); FileManager * FileManager::_pSelf = new FileManager();
@ -42,6 +43,9 @@ Buffer::Buffer(FileManager * pManager, BufferID id, Document doc, DocFileStatus
const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings(); const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings();
_format = ndds._format; _format = ndds._format;
_unicodeMode = ndds._encoding; _unicodeMode = ndds._encoding;
_encoding = ndds._codepage;
if (_encoding != -1)
_unicodeMode = uniCookie;
_userLangExt[0] = 0; _userLangExt[0] = 0;
_fullPathName[0] = 0; _fullPathName[0] = 0;
@ -463,6 +467,12 @@ BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encodin
_nrBufs++; _nrBufs++;
Buffer * buf = _buffers.at(_nrBufs - 1); Buffer * buf = _buffers.at(_nrBufs - 1);
// restore the encoding (ANSI based) while opening the existing file
NppParameters *pNppParamInst = NppParameters::getInstance();
const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings();
buf->setUnicodeMode(ndds._encoding);
buf->setEncoding(-1);
if (encoding == -1) if (encoding == -1)
{ {
// 3 formats : WIN_FORMAT, UNIX_FORMAT and MAC_FORMAT // 3 formats : WIN_FORMAT, UNIX_FORMAT and MAC_FORMAT
@ -480,8 +490,6 @@ BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encodin
UniMode um = UnicodeConvertor.getEncoding(); UniMode um = UnicodeConvertor.getEncoding();
if (um == uni7Bit) if (um == uni7Bit)
{ {
NppParameters *pNppParamInst = NppParameters::getInstance();
const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings();
if (ndds._openAnsiAsUtf8) if (ndds._openAnsiAsUtf8)
{ {
um = uniCookie; um = uniCookie;