本文整理汇总了C++中NppParameters::getNppGUI方法的典型用法代码示例。如果您正苦于以下问题:C++ NppParameters::getNppGUI方法的具体用法?C++ NppParameters::getNppGUI怎么用?C++ NppParameters::getNppGUI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NppParameters
的用法示例。
在下文中一共展示了NppParameters::getNppGUI方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: catch
TCHAR * FileDialog::doOpenSingleFileDlg()
{
TCHAR dir[MAX_PATH];
::GetCurrentDirectory(MAX_PATH, dir);
NppParameters * params = NppParameters::getInstance();
_ofn.lpstrInitialDir = params->getWorkingDir();
_ofn.Flags |= OFN_FILEMUSTEXIST;
TCHAR *fn = NULL;
try {
fn = ::GetOpenFileName(&_ofn)?_fileName:NULL;
if (params->getNppGUI()._openSaveDir == dir_last)
{
::GetCurrentDirectory(MAX_PATH, dir);
params->setWorkingDir(dir);
}
} catch(std::exception e) {
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
} catch(...) {
::MessageBox(NULL, TEXT("GetSaveFileName crashes!!!"), TEXT(""), MB_OK);
}
::SetCurrentDirectory(dir);
return (fn);
}
示例2:
Buffer::Buffer(FileManager * pManager, BufferID id, Document doc, DocFileStatus type, const TCHAR *fileName)
// type must be either DOC_REGULAR or DOC_UNNAMED
: _pManager(pManager)
, _id(id)
, _doc(doc)
, _lang(L_TEXT)
{
NppParameters* pNppParamInst = NppParameters::getInstance();
const NewDocDefaultSettings& ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings();
_format = ndds._format;
_unicodeMode = ndds._unicodeMode;
_encoding = ndds._codepage;
if (_encoding != -1)
_unicodeMode = uniCookie;
_currentStatus = type;
setFileName(fileName, ndds._lang);
updateTimeStamp();
checkFileState();
// reset after initialization
_isDirty = false;
_canNotify = true;
_needLexer = false; // new buffers do not need lexing, Scintilla takes care of that
}
示例3: initList
void VerticalFileSwitcherListView::initList()
{
TaskListInfo taskListInfo;
static HWND nppHwnd = ::GetParent(_hParent);
::SendMessage(nppHwnd, WM_GETTASKLISTINFO, (WPARAM)&taskListInfo, TRUE);
NppParameters *nppParams = NppParameters::getInstance();
NativeLangSpeaker *pNativeSpeaker = nppParams->getNativeLangSpeaker();
bool isExtColumn = !nppParams->getNppGUI()._fileSwitcherWithoutExtColumn;
RECT rc;
::GetClientRect(_hParent, &rc);
int totalWidth = rc.right - rc.left;
generic_string nameStr = pNativeSpeaker->getAttrNameStr(TEXT("Name"), FS_ROOTNODE, FS_CLMNNAME);
//insertColumn(nameStr.c_str(), 150, 0);
insertColumn(nameStr.c_str(), (isExtColumn ? totalWidth - 50 : totalWidth), 0);
//bool isExtColumn = !nppParams->getNppGUI()._fileSwitcherWithoutExtColumn;
if (isExtColumn)
{
generic_string extStr = pNativeSpeaker->getAttrNameStr(TEXT("Ext."), FS_ROOTNODE, FS_CLMNEXT);
insertColumn(extStr.c_str(), 50, 1);
}
for (size_t i = 0, len = taskListInfo._tlfsLst.size(); i < len ; ++i)
{
TaskLstFnStatus & fileNameStatus = taskListInfo._tlfsLst[i];
TaskLstFnStatus *tl = new TaskLstFnStatus(fileNameStatus._iView, fileNameStatus._docIndex, fileNameStatus._fn, fileNameStatus._status, (void *)fileNameStatus._bufID);
TCHAR fn[MAX_PATH];
lstrcpy(fn, ::PathFindFileName(fileNameStatus._fn.c_str()));
if (isExtColumn)
{
::PathRemoveExtension(fn);
}
LVITEM item;
item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
item.pszText = fn;
item.iItem = static_cast<int32_t>(i);
item.iSubItem = 0;
item.iImage = fileNameStatus._status;
item.lParam = (LPARAM)tl;
ListView_InsertItem(_hSelf, &item);
if (isExtColumn)
{
ListView_SetItemText(_hSelf, i, 1, (LPTSTR)::PathFindExtension(fileNameStatus._fn.c_str()));
}
}
ListView_SetItemState(_hSelf, taskListInfo._currentIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
}
示例4: lstrlen
stringVector * FileDialog::doOpenMultiFilesDlg()
{
TCHAR dir[MAX_PATH];
::GetCurrentDirectory(MAX_PATH, dir);
NppParameters * params = NppParameters::getInstance();
_ofn.lpstrInitialDir = params->getWorkingDir();
_ofn.Flags |= OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_ENABLESIZING;
if (!params->useNewStyleSaveDlg())
{
_ofn.Flags |= OFN_ENABLEHOOK | OFN_NOVALIDATE;
_ofn.lpfnHook = OFNHookProc;
}
BOOL res = ::GetOpenFileName(&_ofn);
if (params->getNppGUI()._openSaveDir == dir_last)
{
::GetCurrentDirectory(MAX_PATH, dir);
params->setWorkingDir(dir);
}
::SetCurrentDirectory(dir);
if (res)
{
TCHAR* pFn = _fileName + lstrlen(_fileName) + 1;
TCHAR fn[MAX_PATH*8];
memset(fn, 0x0, sizeof(fn));
if (!(*pFn))
{
_fileNames.push_back(generic_string(_fileName));
}
else
{
lstrcpy(fn, _fileName);
if (fn[lstrlen(fn) - 1] != '\\')
lstrcat(fn, TEXT("\\"));
}
int term = lstrlen(fn);
while (*pFn)
{
fn[term] = '\0';
lstrcat(fn, pFn);
_fileNames.push_back(generic_string(fn));
pFn += lstrlen(pFn) + 1;
}
return &_fileNames;
}
return nullptr;
}
示例5: resizeColumns
void VerticalFileSwitcherListView::resizeColumns(int totalWidth)
{
NppParameters *nppParams = NppParameters::getInstance();
bool isExtColumn = !nppParams->getNppGUI()._fileSwitcherWithoutExtColumn;
if (isExtColumn)
{
ListView_SetColumnWidth(_hSelf, 0, totalWidth - 50);
ListView_SetColumnWidth(_hSelf, 1, 50);
}
else
{
ListView_SetColumnWidth(_hSelf, 0, totalWidth);
}
}
示例6: lstrlen
stringVector * FileDialog::doOpenMultiFilesDlg()
{
TCHAR dir[MAX_PATH];
::GetCurrentDirectory(MAX_PATH, dir);
//_ofn.lpstrInitialDir = dir;
NppParameters * params = NppParameters::getInstance();
_ofn.lpstrInitialDir = params->getWorkingDir();
_ofn.Flags |= OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT;
BOOL res = ::GetOpenFileName(&_ofn);
if (params->getNppGUI()._openSaveDir == dir_last)
{
::GetCurrentDirectory(MAX_PATH, dir);
params->setWorkingDir(dir);
}
::SetCurrentDirectory(dir);
if (res)
{
TCHAR fn[MAX_PATH];
TCHAR *pFn = _fileName + lstrlen(_fileName) + 1;
if (!(*pFn))
_fileNames.push_back(generic_string(_fileName));
else
{
lstrcpy(fn, _fileName);
if (fn[lstrlen(fn)-1] != '\\')
lstrcat(fn, TEXT("\\"));
}
int term = int(lstrlen(fn));
while (*pFn)
{
fn[term] = '\0';
lstrcat(fn, pFn);
_fileNames.push_back(generic_string(fn));
pFn += lstrlen(pFn) + 1;
}
return &_fileNames;
}
else
return NULL;
}
示例7: TEXT
Buffer::Buffer(FileManager * pManager, BufferID id, Document doc, DocFileStatus type, const TCHAR *fileName) // type must be either DOC_REGULAR or DOC_UNNAMED
: _pManager(pManager), _id(id), _isDirty(false), _doc(doc), _isFileReadOnly(false), _isUserReadOnly(false), _recentTag(-1), _references(0),
_canNotify(false), _timeStamp(0), _needReloading(false), _encoding(-1)
{
NppParameters *pNppParamInst = NppParameters::getInstance();
const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings();
_format = ndds._format;
_unicodeMode = ndds._encoding;
_encoding = ndds._codepage;
if (_encoding != -1)
_unicodeMode = uniCookie;
_userLangExt = TEXT("");
_fullPathName = TEXT("");
_fileName = NULL;
setFileName(fileName, ndds._lang);
updateTimeStamp();
checkFileState();
_currentStatus = type;
_isDirty = false;
_needLexer = false; //new buffers do not need lexing, Scintilla takes care of that
_canNotify = true;
}
示例8: loadFileData
inline bool FileManager::loadFileData(Document doc, const TCHAR * filename, char* data, Utf8_16_Read * unicodeConvertor, LangType & language, int & encoding, EolType & eolFormat)
{
FILE *fp = generic_fopen(filename, TEXT("rb"));
if (!fp)
return false;
//Get file size
_fseeki64 (fp , 0 , SEEK_END);
unsigned __int64 fileSize =_ftelli64(fp);
rewind(fp);
// size/6 is the normal room Scintilla keeps for editing, but here we limit it to 1MiB when loading (maybe we want to load big files without editing them too much)
unsigned __int64 bufferSizeRequested = fileSize + min(1<<20,fileSize/6);
// As a 32bit application, we cannot allocate 2 buffer of more than INT_MAX size (it takes the whole address space)
if(bufferSizeRequested > INT_MAX)
{
::MessageBox(NULL, TEXT("File is too big to be opened by Notepad++"), TEXT("File open problem"), MB_OK|MB_APPLMODAL);
/*
_nativeLangSpeaker.messageBox("NbFileToOpenImportantWarning",
_pPublicInterface->getHSelf(),
TEXT("File is too big to be opened by Notepad++"),
TEXT("File open problem"),
MB_OK|MB_APPLMODAL);
*/
fclose(fp);
return false;
}
//Setup scratchtilla for new filedata
_pscratchTilla->execute(SCI_SETSTATUS, SC_STATUS_OK); // reset error status
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, doc);
bool ro = _pscratchTilla->execute(SCI_GETREADONLY) != 0;
if (ro)
{
_pscratchTilla->execute(SCI_SETREADONLY, false);
}
_pscratchTilla->execute(SCI_CLEARALL);
if (language < L_EXTERNAL)
{
_pscratchTilla->execute(SCI_SETLEXER, ScintillaEditView::langNames[language].lexerID);
}
else
{
int id = language - L_EXTERNAL;
TCHAR * name = NppParameters::getInstance()->getELCFromIndex(id)._name;
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
const char *pName = wmc->wchar2char(name, CP_ACP);
_pscratchTilla->execute(SCI_SETLEXERLANGUAGE, 0, (LPARAM)pName);
}
if (encoding != -1)
_pscratchTilla->execute(SCI_SETCODEPAGE, SC_CP_UTF8);
bool success = true;
EolType format = EolType::unknown;
__try
{
// First allocate enough memory for the whole file (this will reduce memory copy during loading)
_pscratchTilla->execute(SCI_ALLOCATE, WPARAM(bufferSizeRequested));
if (_pscratchTilla->execute(SCI_GETSTATUS) != SC_STATUS_OK)
throw;
size_t lenFile = 0;
size_t lenConvert = 0; //just in case conversion results in 0, but file not empty
bool isFirstTime = true;
int incompleteMultibyteChar = 0;
do
{
lenFile = fread(data+incompleteMultibyteChar, 1, blockSize-incompleteMultibyteChar, fp) + incompleteMultibyteChar;
if (lenFile == 0) break;
if (isFirstTime)
{
// check if file contain any BOM
if (Utf8_16_Read::determineEncoding((unsigned char *)data, lenFile) != uni8Bit)
{
// if file contains any BOM, then encoding will be erased,
// and the document will be interpreted as UTF
encoding = -1;
}
else if (encoding == -1)
{
if (NppParameters::getInstance()->getNppGUI()._detectEncoding)
encoding = detectCodepage(data, lenFile);
}
if (language == L_TEXT)
{
// check the language du fichier
language = detectLanguageFromTextBegining((unsigned char *)data, lenFile);
}
isFirstTime = false;
}
if (encoding != -1)
{
if (encoding == SC_CP_UTF8)
//.........这里部分代码省略.........
示例9: loadFile
// backupFileName is sentinel of backup mode: if it's not NULL, then we use it (load it). Otherwise we use filename
BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encoding, const TCHAR *backupFileName, time_t fileNameTimestamp)
{
bool ownDoc = false;
if (doc == NULL)
{
doc = (Document)_pscratchTilla->execute(SCI_CREATEDOCUMENT);
ownDoc = true;
}
TCHAR fullpath[MAX_PATH];
::GetFullPathName(filename, MAX_PATH, fullpath, NULL);
::GetLongPathName(fullpath, fullpath, MAX_PATH);
bool isSnapshotMode = backupFileName != NULL && PathFileExists(backupFileName);
if (isSnapshotMode && !PathFileExists(fullpath)) // if backup mode and fullpath doesn't exist, we guess is UNTITLED
{
lstrcpy(fullpath, filename); // we restore fullpath with filename, in our case is "new #"
}
Utf8_16_Read UnicodeConvertor; //declare here so we can get information after loading is done
char data[blockSize + 8]; // +8 for incomplete multibyte char
FormatType bkformat = FormatType::unknown;
LangType detectedLang = L_TEXT;
bool res = loadFileData(doc, backupFileName ? backupFileName : fullpath, data, &UnicodeConvertor, detectedLang, encoding, &bkformat);
if (res)
{
Buffer* newBuf = new Buffer(this, _nextBufferID, doc, DOC_REGULAR, fullpath);
BufferID id = (BufferID) newBuf;
newBuf->_id = id;
if (backupFileName != NULL)
{
newBuf->_backupFileName = backupFileName;
if (!PathFileExists(fullpath))
newBuf->_currentStatus = DOC_UNNAMED;
}
if (fileNameTimestamp != 0)
newBuf->_timeStamp = fileNameTimestamp;
_buffers.push_back(newBuf);
++_nrBufs;
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._unicodeMode);
buf->setEncoding(-1);
// if a language has been detected, and the detected value is different from the file extension,
// we use the detected value
if (detectedLang != L_TEXT && detectedLang != buf->getLangType())
buf->setLangType(detectedLang);
if (encoding == -1)
{
// 3 formats : WIN_FORMAT, UNIX_FORMAT and MAC_FORMAT
if (nullptr != UnicodeConvertor.getNewBuf())
{
FormatType format = getEOLFormatForm(UnicodeConvertor.getNewBuf(), UnicodeConvertor.getNewSize());
buf->setFormat(format);
}
else
buf->setFormat(FormatType::osdefault);
UniMode um = UnicodeConvertor.getEncoding();
if (um == uni7Bit)
um = (ndds._openAnsiAsUtf8) ? uniCookie : uni8Bit;
buf->setUnicodeMode(um);
}
else // encoding != -1
{
// Test if encoding is set to UTF8 w/o BOM (usually for utf8 indicator of xml or html)
buf->setEncoding((encoding == SC_CP_UTF8)?-1:encoding);
buf->setUnicodeMode(uniCookie);
buf->setFormat(bkformat);
}
//determine buffer properties
++_nextBufferID;
return id;
}
else //failed loading, release document
{
if (ownDoc)
_pscratchTilla->execute(SCI_RELEASEDOCUMENT, 0, doc); //Failure, so release document
return BUFFER_INVALID;
}
}
示例10: init
void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLine, CmdLineParams *cmdLineParams)
{
time_t timestampBegin = 0;
if (cmdLineParams->_showLoadingTime)
timestampBegin = time(NULL);
Window::init(hInst, parent);
WNDCLASS nppClass;
nppClass.style = CS_BYTEALIGNWINDOW | CS_DBLCLKS;
nppClass.lpfnWndProc = Notepad_plus_Proc;
nppClass.cbClsExtra = 0;
nppClass.cbWndExtra = 0;
nppClass.hInstance = _hInst;
nppClass.hIcon = ::LoadIcon(hInst, MAKEINTRESOURCE(IDI_M30ICON));
nppClass.hCursor = ::LoadCursor(NULL, IDC_ARROW);
nppClass.hbrBackground = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
nppClass.lpszMenuName = MAKEINTRESOURCE(IDR_M30_MENU);
nppClass.lpszClassName = _className;
_isPrelaunch = cmdLineParams->_isPreLaunch;
if (!::RegisterClass(&nppClass))
{
throw std::runtime_error("Notepad_plus_Window::init : RegisterClass() function failed");
}
NppParameters *pNppParams = NppParameters::getInstance();
NppGUI & nppGUI = const_cast<NppGUI &>(pNppParams->getNppGUI());
if (cmdLineParams->_isNoPlugin)
_notepad_plus_plus_core._pluginsManager.disable();
_hSelf = ::CreateWindowEx(
WS_EX_ACCEPTFILES | (_notepad_plus_plus_core._nativeLangSpeaker.isRTL()?WS_EX_LAYOUTRTL:0),
_className,
TEXT("Notepad++"),
(WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN),
// CreateWindowEx bug : set all 0 to walk around the pb
0, 0, 0, 0,
_hParent, nullptr, _hInst,
(LPVOID) this); // pass the ptr of this instantiated object
// for retrieve it in Notepad_plus_Proc from
// the CREATESTRUCT.lpCreateParams afterward.
if (NULL == _hSelf)
throw std::runtime_error("Notepad_plus_Window::init : CreateWindowEx() function return null");
PaintLocker paintLocker{_hSelf};
_notepad_plus_plus_core.staticCheckMenuAndTB();
gNppHWND = _hSelf;
if (cmdLineParams->isPointValid())
{
::MoveWindow(_hSelf, cmdLineParams->_point.x, cmdLineParams->_point.y, nppGUI._appPos.right, nppGUI._appPos.bottom, TRUE);
}
else
{
WINDOWPLACEMENT posInfo;
posInfo.length = sizeof(WINDOWPLACEMENT);
posInfo.flags = 0;
if (_isPrelaunch)
posInfo.showCmd = SW_HIDE;
else
posInfo.showCmd = nppGUI._isMaximized ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL;
posInfo.ptMinPosition.x = (LONG)-1;
posInfo.ptMinPosition.y = (LONG)-1;
posInfo.ptMaxPosition.x = (LONG)-1;
posInfo.ptMaxPosition.y = (LONG)-1;
posInfo.rcNormalPosition.left = nppGUI._appPos.left;
posInfo.rcNormalPosition.top = nppGUI._appPos.top;
posInfo.rcNormalPosition.bottom = nppGUI._appPos.top + nppGUI._appPos.bottom;
posInfo.rcNormalPosition.right = nppGUI._appPos.left + nppGUI._appPos.right;
//SetWindowPlacement will take care of situations, where saved position was in no longer available monitor
::SetWindowPlacement(_hSelf,&posInfo);
}
if ((nppGUI._tabStatus & TAB_MULTILINE) != 0)
::SendMessage(_hSelf, WM_COMMAND, IDM_VIEW_DRAWTABBAR_MULTILINE, 0);
if (!nppGUI._menuBarShow)
::SetMenu(_hSelf, NULL);
if (cmdLineParams->_isNoTab || (nppGUI._tabStatus & TAB_HIDE))
{
const int tabStatusOld = nppGUI._tabStatus;
::SendMessage(_hSelf, NPPM_HIDETABBAR, 0, TRUE);
if (cmdLineParams->_isNoTab)
{
// Restore old settings when tab bar has been hidden from tab bar.
nppGUI._tabStatus = tabStatusOld;
}
}
if (cmdLineParams->_alwaysOnTop)
//.........这里部分代码省略.........
示例11: WinMain
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
{
LPTSTR cmdLine = ::GetCommandLine();
ParamVector params;
parseCommandLine(cmdLine, params);
MiniDumper mdump; //for debugging purposes.
bool TheFirstOne = true;
::SetLastError(NO_ERROR);
::CreateMutex(NULL, false, TEXT("nppInstance"));
if (::GetLastError() == ERROR_ALREADY_EXISTS)
TheFirstOne = false;
bool isParamePresent;
bool showHelp = isInList(FLAG_HELP, params);
bool isMultiInst = isInList(FLAG_MULTI_INSTANCE, params);
bool doFunctionListExport = isInList(FLAG_FUNCLSTEXPORT, params);
bool doPrintAndQuit = isInList(FLAG_PRINTANDQUIT, params);
CmdLineParams cmdLineParams;
cmdLineParams._isNoTab = isInList(FLAG_NOTABBAR, params);
cmdLineParams._isNoPlugin = isInList(FLAG_NO_PLUGIN, params);
cmdLineParams._isReadOnly = isInList(FLAG_READONLY, params);
cmdLineParams._isNoSession = isInList(FLAG_NOSESSION, params);
cmdLineParams._isPreLaunch = isInList(FLAG_SYSTRAY, params);
cmdLineParams._alwaysOnTop = isInList(FLAG_ALWAYS_ON_TOP, params);
cmdLineParams._showLoadingTime = isInList(FLAG_LOADINGTIME, params);
cmdLineParams._isSessionFile = isInList(FLAG_OPENSESSIONFILE, params);
cmdLineParams._isRecursive = isInList(FLAG_RECURSIVE, params);
cmdLineParams._langType = getLangTypeFromParam(params);
cmdLineParams._localizationPath = getLocalizationPathFromParam(params);
cmdLineParams._easterEggName = getEasterEggNameFromParam(params, cmdLineParams._quoteType);
cmdLineParams._ghostTypingSpeed = getGhostTypingSpeedFromParam(params);
// getNumberFromParam should be run at the end, to not consuming the other params
cmdLineParams._line2go = getNumberFromParam('n', params, isParamePresent);
cmdLineParams._column2go = getNumberFromParam('c', params, isParamePresent);
cmdLineParams._pos2go = getNumberFromParam('p', params, isParamePresent);
cmdLineParams._point.x = getNumberFromParam('x', params, cmdLineParams._isPointXValid);
cmdLineParams._point.y = getNumberFromParam('y', params, cmdLineParams._isPointYValid);
if (showHelp)
::MessageBox(NULL, COMMAND_ARG_HELP, TEXT("Notepad++ Command Argument Help"), MB_OK);
NppParameters *pNppParameters = NppParameters::getInstance();
NppGUI & nppGui = const_cast<NppGUI &>(pNppParameters->getNppGUI());
bool doUpdate = nppGui._autoUpdateOpt._doAutoUpdate;
if (doFunctionListExport || doPrintAndQuit) // export functionlist feature will serialize fuctionlist on the disk, then exit Notepad++. So it's important to not launch into existing instance, and keep it silent.
{
isMultiInst = true;
doUpdate = false;
cmdLineParams._isNoSession = true;
}
if (cmdLineParams._localizationPath != TEXT(""))
{
pNppParameters->setStartWithLocFileName(cmdLineParams._localizationPath);
}
pNppParameters->load();
pNppParameters->setFunctionListExportBoolean(doFunctionListExport);
pNppParameters->setPrintAndExitBoolean(doPrintAndQuit);
// override the settings if notepad style is present
if (pNppParameters->asNotepadStyle())
{
isMultiInst = true;
cmdLineParams._isNoTab = true;
cmdLineParams._isNoSession = true;
}
// override the settings if multiInst is choosen by user in the preference dialog
const NppGUI & nppGUI = pNppParameters->getNppGUI();
if (nppGUI._multiInstSetting == multiInst)
{
isMultiInst = true;
// Only the first launch remembers the session
if (!TheFirstOne)
cmdLineParams._isNoSession = true;
}
generic_string quotFileName = TEXT("");
// tell the running instance the FULL path to the new files to load
size_t nbFilesToOpen = params.size();
for (size_t i = 0; i < nbFilesToOpen; ++i)
{
const TCHAR * currentFile = params.at(i).c_str();
if (currentFile[0])
{
//check if relative or full path. Relative paths dont have a colon for driveletter
quotFileName += TEXT("\"");
quotFileName += relativeFilePathToFullFilePath(currentFile);
quotFileName += TEXT("\" ");
}
}
//.........这里部分代码省略.........
示例12: init
void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLine, CmdLineParams *cmdLineParams)
{
time_t timestampBegin = 0;
if (cmdLineParams->_showLoadingTime)
timestampBegin = time(NULL);
Window::init(hInst, parent);
WNDCLASS nppClass;
nppClass.style = CS_BYTEALIGNWINDOW | CS_DBLCLKS;
nppClass.lpfnWndProc = Notepad_plus_Proc;
nppClass.cbClsExtra = 0;
nppClass.cbWndExtra = 0;
nppClass.hInstance = _hInst;
nppClass.hIcon = ::LoadIcon(hInst, MAKEINTRESOURCE(IDI_M30ICON));
nppClass.hCursor = ::LoadCursor(NULL, IDC_ARROW);
nppClass.hbrBackground = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
nppClass.lpszMenuName = MAKEINTRESOURCE(IDR_M30_MENU);
nppClass.lpszClassName = _className;
_isPrelaunch = cmdLineParams->_isPreLaunch;
if (!::RegisterClass(&nppClass))
{
throw std::runtime_error("Notepad_plus_Window::init : RegisterClass() function failed");
}
RECT workAreaRect;
::SystemParametersInfo(SPI_GETWORKAREA, 0, &workAreaRect, 0);
NppParameters *pNppParams = NppParameters::getInstance();
const NppGUI & nppGUI = pNppParams->getNppGUI();
if (cmdLineParams->_isNoPlugin)
_notepad_plus_plus_core._pluginsManager.disable();
_hSelf = ::CreateWindowEx(
WS_EX_ACCEPTFILES | (_notepad_plus_plus_core._nativeLangSpeaker.isRTL()?WS_EX_LAYOUTRTL:0),\
_className,\
TEXT("Notepad++"),\
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,\
// CreateWindowEx bug : set all 0 to walk around the pb
0, 0, 0, 0,\
_hParent,\
NULL,\
_hInst,\
(LPVOID)this); // pass the ptr of this instantiated object
// for retrieve it in Notepad_plus_Proc from
// the CREATESTRUCT.lpCreateParams afterward.
if (!_hSelf)
{
throw std::runtime_error("Notepad_plus_Window::init : CreateWindowEx() function return null");
}
_notepad_plus_plus_core.staticCheckMenuAndTB();
gNppHWND = _hSelf;
// In setting the startup window position, take into account that the last-saved
// position might have assumed a second monitor that's no longer available.
POINT newUpperLeft;
newUpperLeft.x = nppGUI._appPos.left + workAreaRect.left;
newUpperLeft.y = nppGUI._appPos.top + workAreaRect.top;
// GetSystemMetrics does not support the multi-monitor values on Windows NT and Windows 95.
winVer winVersion = pNppParams->getWinVersion();
if ((winVersion != WV_95) && (winVersion != WV_NT))
{
int margin = ::GetSystemMetrics(SM_CYSMCAPTION);
if (newUpperLeft.x > ::GetSystemMetrics(SM_CXVIRTUALSCREEN)-margin)
newUpperLeft.x = workAreaRect.right - nppGUI._appPos.right;
if (newUpperLeft.x + nppGUI._appPos.right < ::GetSystemMetrics(SM_XVIRTUALSCREEN)+margin)
newUpperLeft.x = workAreaRect.left;
if (newUpperLeft.y > ::GetSystemMetrics(SM_CYVIRTUALSCREEN)-margin)
newUpperLeft.y = workAreaRect.bottom - nppGUI._appPos.bottom;
if (newUpperLeft.y + nppGUI._appPos.bottom < ::GetSystemMetrics(SM_YVIRTUALSCREEN)+margin)
newUpperLeft.y = workAreaRect.top;
}
if (cmdLineParams->isPointValid())
::MoveWindow(_hSelf, cmdLineParams->_point.x, cmdLineParams->_point.y, nppGUI._appPos.right, nppGUI._appPos.bottom, TRUE);
else
::MoveWindow(_hSelf, newUpperLeft.x, newUpperLeft.y, nppGUI._appPos.right, nppGUI._appPos.bottom, TRUE);
if (nppGUI._tabStatus & TAB_MULTILINE)
::SendMessage(_hSelf, WM_COMMAND, IDM_VIEW_DRAWTABBAR_MULTILINE, 0);
if (!nppGUI._menuBarShow)
::SetMenu(_hSelf, NULL);
if (cmdLineParams->_isNoTab || (nppGUI._tabStatus & TAB_HIDE))
{
::SendMessage(_hSelf, NPPM_HIDETABBAR, 0, TRUE);
}
if (cmdLineParams->_alwaysOnTop)
{
::SendMessage(_hSelf, WM_COMMAND, IDM_VIEW_ALWAYSONTOP, 0);
}
//.........这里部分代码省略.........
示例13: notify
//.........这里部分代码省略.........
case SCN_MARGINCLICK:
{
if (notification->nmhdr.hwndFrom == _mainEditView.getHSelf())
switchEditViewTo(MAIN_VIEW);
else if (notification->nmhdr.hwndFrom == _subEditView.getHSelf())
switchEditViewTo(SUB_VIEW);
int lineClick = int(_pEditView->execute(SCI_LINEFROMPOSITION, notification->position));
if (notification->margin == ScintillaEditView::_SC_MARGE_FOLDER)
{
_pEditView->marginClick(notification->position, notification->modifiers);
if (_pDocMap)
_pDocMap->fold(lineClick, _pEditView->isFolded(lineClick));
}
else if ((notification->margin == ScintillaEditView::_SC_MARGE_SYBOLE) && !notification->modifiers)
{
if (!_pEditView->markerMarginClick(lineClick))
bookmarkToggle(lineClick);
}
break;
}
case SCN_FOLDINGSTATECHANGED :
{
if ((notification->nmhdr.hwndFrom == _mainEditView.getHSelf())
|| (notification->nmhdr.hwndFrom == _subEditView.getHSelf()))
{
int lineClicked = notification->line;
if (!_isFolding)
{
int urlAction = (NppParameters::getInstance())->getNppGUI()._styleURL;
if ((urlAction == 1) || (urlAction == 2))
addHotSpot();
}
if (_pDocMap)
_pDocMap->fold(lineClicked, _pEditView->isFolded(lineClicked));
}
return TRUE;
}
case SCN_CHARADDED:
{
const NppGUI & nppGui = NppParameters::getInstance()->getNppGUI();
bool indentMaintain = nppGui._maitainIndent;
if (indentMaintain)
MaintainIndentation(static_cast<TCHAR>(notification->ch));
AutoCompletion * autoC = isFromPrimary?&_autoCompleteMain:&_autoCompleteSub;
if (nppGui._matchedPairConf.hasAnyPairsPair())
autoC->insertMatchedChars(notification->ch, nppGui._matchedPairConf);
autoC->update(notification->ch);
break;
}
case SCN_DOUBLECLICK :
{
if(notification->modifiers == SCMOD_CTRL)
{
const NppGUI & nppGUI = NppParameters::getInstance()->getNppGUI();
示例14: notify
// Only for 2 main Scintilla editors
BOOL Notepad_plus::notify(SCNotification *notification)
{
//Important, keep track of which element generated the message
bool isFromPrimary = (_mainEditView.getHSelf() == notification->nmhdr.hwndFrom || _mainDocTab.getHSelf() == notification->nmhdr.hwndFrom);
bool isFromSecondary = !isFromPrimary && (_subEditView.getHSelf() == notification->nmhdr.hwndFrom || _subDocTab.getHSelf() == notification->nmhdr.hwndFrom);
ScintillaEditView * notifyView = nullptr;
if (isFromPrimary)
notifyView = &_mainEditView;
else if (isFromSecondary)
notifyView = &_subEditView;
DocTabView *notifyDocTab = isFromPrimary?&_mainDocTab:&_subDocTab;
TBHDR * tabNotification = (TBHDR*) notification;
switch (notification->nmhdr.code)
{
case SCN_MODIFIED:
{
if (not notifyView)
return FALSE;
static bool prevWasEdit = false;
if (notification->modificationType & (SC_MOD_DELETETEXT | SC_MOD_INSERTTEXT))
{
_pEditView->updateBeginEndSelectPosition(notification->modificationType & SC_MOD_INSERTTEXT, notification->position, notification->length);
prevWasEdit = true;
_linkTriggered = true;
::InvalidateRect(notifyView->getHSelf(), NULL, TRUE);
}
if (notification->modificationType & (SC_MOD_DELETETEXT | SC_MOD_INSERTTEXT | SC_PERFORMED_UNDO | SC_PERFORMED_REDO))
{
// for the backup system
_pEditView->getCurrentBuffer()->setModifiedStatus(true);
}
if (notification->modificationType & SC_MOD_CHANGEFOLD)
{
if (prevWasEdit)
{
notifyView->foldChanged(notification->line, notification->foldLevelNow, notification->foldLevelPrev);
prevWasEdit = false;
}
}
else if (!(notification->modificationType & (SC_MOD_DELETETEXT | SC_MOD_INSERTTEXT)))
{
prevWasEdit = false;
}
break;
}
case SCN_SAVEPOINTREACHED:
case SCN_SAVEPOINTLEFT:
{
Buffer * buf = 0;
if (isFromPrimary)
{
buf = _mainEditView.getCurrentBuffer();
}
else if (isFromSecondary)
{
buf = _subEditView.getCurrentBuffer();
}
else
{
//Done by invisibleEditView?
BufferID id = BUFFER_INVALID;
if (notification->nmhdr.hwndFrom == _invisibleEditView.getHSelf())
{
id = MainFileManager->getBufferFromDocument(_invisibleEditView.execute(SCI_GETDOCPOINTER));
}
else if (notification->nmhdr.hwndFrom == _fileEditView.getHSelf())
{
id = MainFileManager->getBufferFromDocument(_fileEditView.execute(SCI_GETDOCPOINTER));
}
else
break; //wrong scintilla
if (id != BUFFER_INVALID)
{
buf = MainFileManager->getBufferByID(id);
}
else
break;
}
bool isDirty = notification->nmhdr.code == SCN_SAVEPOINTLEFT;
bool isSnapshotMode = NppParameters::getInstance()->getNppGUI().isSnapshotMode();
if (isSnapshotMode && !isDirty)
{
bool canUndo = _pEditView->execute(SCI_CANUNDO) == TRUE;
if (!canUndo && buf->isLoadedDirty() && buf->isDirty())
isDirty = true;
}
buf->setDirty(isDirty);
break;
}
//.........这里部分代码省略.........
示例15: init
void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLine, CmdLineParams *cmdLineParams)
{
time_t timestampBegin = 0;
if (cmdLineParams->_showLoadingTime)
timestampBegin = time(NULL);
Window::init(hInst, parent);
WNDCLASS nppClass;
nppClass.style = CS_BYTEALIGNWINDOW | CS_DBLCLKS;
nppClass.lpfnWndProc = Notepad_plus_Proc;
nppClass.cbClsExtra = 0;
nppClass.cbWndExtra = 0;
nppClass.hInstance = _hInst;
nppClass.hIcon = ::LoadIcon(hInst, MAKEINTRESOURCE(IDI_M30ICON));
nppClass.hCursor = ::LoadCursor(NULL, IDC_ARROW);
nppClass.hbrBackground = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
nppClass.lpszMenuName = MAKEINTRESOURCE(IDR_M30_MENU);
nppClass.lpszClassName = _className;
_isPrelaunch = cmdLineParams->_isPreLaunch;
if (!::RegisterClass(&nppClass))
{
throw std::runtime_error("Notepad_plus_Window::init : RegisterClass() function failed");
}
RECT workAreaRect;
::SystemParametersInfo(SPI_GETWORKAREA, 0, &workAreaRect, 0);
NppParameters *pNppParams = NppParameters::getInstance();
NppGUI & nppGUI = (NppGUI &)pNppParams->getNppGUI();
if (cmdLineParams->_isNoPlugin)
_notepad_plus_plus_core._pluginsManager.disable();
_hSelf = ::CreateWindowEx(
WS_EX_ACCEPTFILES | (_notepad_plus_plus_core._nativeLangSpeaker.isRTL()?WS_EX_LAYOUTRTL:0),\
_className,\
TEXT("Notepad++"),\
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,\
// CreateWindowEx bug : set all 0 to walk around the pb
0, 0, 0, 0,\
_hParent,\
NULL,\
_hInst,\
(LPVOID)this); // pass the ptr of this instantiated object
// for retrieve it in Notepad_plus_Proc from
// the CREATESTRUCT.lpCreateParams afterward.
if (!_hSelf)
{
throw std::runtime_error("Notepad_plus_Window::init : CreateWindowEx() function return null");
}
_notepad_plus_plus_core.staticCheckMenuAndTB();
gNppHWND = _hSelf;
if (cmdLineParams->isPointValid())
::MoveWindow(_hSelf, cmdLineParams->_point.x, cmdLineParams->_point.y, nppGUI._appPos.right, nppGUI._appPos.bottom, TRUE);
else
{
WINDOWPLACEMENT posInfo;
posInfo.length = sizeof(WINDOWPLACEMENT);
posInfo.flags = 0;
if(_isPrelaunch)
posInfo.showCmd = SW_HIDE;
else
posInfo.showCmd = nppGUI._isMaximized?SW_SHOWMAXIMIZED:SW_SHOWNORMAL;
posInfo.ptMinPosition.x = (LONG)-1;
posInfo.ptMinPosition.y = (LONG)-1;
posInfo.ptMaxPosition.x = (LONG)-1;
posInfo.ptMaxPosition.y = (LONG)-1;
posInfo.rcNormalPosition.left = nppGUI._appPos.left;
posInfo.rcNormalPosition.top = nppGUI._appPos.top;
posInfo.rcNormalPosition.bottom = nppGUI._appPos.top + nppGUI._appPos.bottom;
posInfo.rcNormalPosition.right = nppGUI._appPos.left + nppGUI._appPos.right;
//SetWindowPlacement will take care of situations, where saved position was in no longer available monitor
::SetWindowPlacement(_hSelf,&posInfo);
}
if (nppGUI._tabStatus & TAB_MULTILINE)
::SendMessage(_hSelf, WM_COMMAND, IDM_VIEW_DRAWTABBAR_MULTILINE, 0);
if (!nppGUI._menuBarShow)
::SetMenu(_hSelf, NULL);
if (cmdLineParams->_isNoTab || (nppGUI._tabStatus & TAB_HIDE))
{
::SendMessage(_hSelf, NPPM_HIDETABBAR, 0, TRUE);
}
if (cmdLineParams->_alwaysOnTop)
{
::SendMessage(_hSelf, WM_COMMAND, IDM_VIEW_ALWAYSONTOP, 0);
}
//.........这里部分代码省略.........