Open a file from command line by applying an existent UDL via UDL name
Add command line flag -udl="UDL name" to open a file by applying an existent UDL via its name. Close #10102
This commit is contained in:
parent
88665b5d17
commit
7bb39a08f1
|
@ -6049,6 +6049,7 @@ std::vector<generic_string> Notepad_plus::loadCommandlineParams(const TCHAR * co
|
|||
}
|
||||
|
||||
LangType lt = pCmdParams->_langType;
|
||||
generic_string udl = pCmdParams->_udlName;
|
||||
int lineNumber = pCmdParams->_line2go;
|
||||
int columnNumber = pCmdParams->_column2go;
|
||||
int positionNumber = pCmdParams->_pos2go;
|
||||
|
@ -6074,10 +6075,14 @@ std::vector<generic_string> Notepad_plus::loadCommandlineParams(const TCHAR * co
|
|||
continue;
|
||||
|
||||
lastOpened = bufID;
|
||||
Buffer* pBuf = MainFileManager.getBufferByID(bufID);
|
||||
|
||||
if (lt != L_EXTERNAL && lt < nppParams.L_END)
|
||||
if (!udl.empty())
|
||||
{
|
||||
pBuf->setLangType(L_USER, udl.c_str());
|
||||
}
|
||||
else if (lt != L_EXTERNAL && lt < nppParams.L_END)
|
||||
{
|
||||
Buffer * pBuf = MainFileManager.getBufferByID(bufID);
|
||||
pBuf->setLangType(lt);
|
||||
}
|
||||
|
||||
|
|
|
@ -437,11 +437,11 @@ private:
|
|||
return _activeView;
|
||||
}
|
||||
|
||||
int otherView(){
|
||||
int otherView() {
|
||||
return (_activeView == MAIN_VIEW?SUB_VIEW:MAIN_VIEW);
|
||||
}
|
||||
|
||||
int otherFromView(int whichOne){
|
||||
int otherFromView(int whichOne) {
|
||||
return (whichOne == MAIN_VIEW?SUB_VIEW:MAIN_VIEW);
|
||||
}
|
||||
|
||||
|
@ -507,32 +507,28 @@ private:
|
|||
|
||||
void addHotSpot(ScintillaEditView* view = NULL);
|
||||
|
||||
void bookmarkAdd(int lineno) const
|
||||
{
|
||||
void bookmarkAdd(int lineno) const {
|
||||
if (lineno == -1)
|
||||
lineno = static_cast<int32_t>(_pEditView->getCurrentLineNumber());
|
||||
if (!bookmarkPresent(lineno))
|
||||
_pEditView->execute(SCI_MARKERADD, lineno, MARK_BOOKMARK);
|
||||
}
|
||||
|
||||
void bookmarkDelete(int lineno) const
|
||||
{
|
||||
void bookmarkDelete(int lineno) const {
|
||||
if (lineno == -1)
|
||||
lineno = static_cast<int32_t>(_pEditView->getCurrentLineNumber());
|
||||
while (bookmarkPresent(lineno))
|
||||
_pEditView->execute(SCI_MARKERDELETE, lineno, MARK_BOOKMARK);
|
||||
}
|
||||
|
||||
bool bookmarkPresent(int lineno) const
|
||||
{
|
||||
bool bookmarkPresent(int lineno) const {
|
||||
if (lineno == -1)
|
||||
lineno = static_cast<int32_t>(_pEditView->getCurrentLineNumber());
|
||||
LRESULT state = _pEditView->execute(SCI_MARKERGET, lineno);
|
||||
return ((state & (1 << MARK_BOOKMARK)) != 0);
|
||||
}
|
||||
|
||||
void bookmarkToggle(int lineno) const
|
||||
{
|
||||
void bookmarkToggle(int lineno) const {
|
||||
if (lineno == -1)
|
||||
lineno = static_cast<int32_t>(_pEditView->getCurrentLineNumber());
|
||||
|
||||
|
@ -543,8 +539,7 @@ private:
|
|||
}
|
||||
|
||||
void bookmarkNext(bool forwardScan);
|
||||
void bookmarkClearAll() const
|
||||
{
|
||||
void bookmarkClearAll() const {
|
||||
_pEditView->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK);
|
||||
}
|
||||
|
||||
|
@ -596,8 +591,7 @@ private:
|
|||
bool dumpFiles(const TCHAR * outdir, const TCHAR * fileprefix = TEXT("")); //helper func
|
||||
void drawTabbarColoursFromStylerArray();
|
||||
|
||||
std::vector<generic_string> loadCommandlineParams(const TCHAR * commandLine, const CmdLineParams * pCmdParams)
|
||||
{
|
||||
std::vector<generic_string> loadCommandlineParams(const TCHAR * commandLine, const CmdLineParams * pCmdParams) {
|
||||
const CmdLineParamsDTO dto = CmdLineParamsDTO::FromCmdLineParams(*pCmdParams);
|
||||
return loadCommandlineParams(commandLine, &dto);
|
||||
}
|
||||
|
@ -627,8 +621,7 @@ private:
|
|||
static bool deleteForward(ScintillaEditView *pCurrentView, BufferID targetBufID);
|
||||
static bool selectBack(ScintillaEditView *pCurrentView, BufferID targetBufID);
|
||||
|
||||
static int getRandomNumber(int rangeMax = -1)
|
||||
{
|
||||
static int getRandomNumber(int rangeMax = -1) {
|
||||
int randomNumber = rand();
|
||||
if (rangeMax == -1)
|
||||
return randomNumber;
|
||||
|
|
|
@ -24,6 +24,7 @@ notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-LlangCode] [-nLineNum
|
|||
-multiInst : Launch another Notepad++ instance\r\
|
||||
-noPlugin : Launch Notepad++ without loading any plugin\r\
|
||||
-l : Open file or Ghost type with syntax highlighting of choice\r\
|
||||
-udl=\"My UDL Name\": Open file by applying User Defined Language\r\
|
||||
-L : Apply indicated localization, langCode is browser language code\r\
|
||||
-n : Scroll to indicated line on filePath\r\
|
||||
-c : Scroll to indicated column on filePath\r\
|
||||
|
|
|
@ -238,6 +238,7 @@ struct CmdLineParams
|
|||
|
||||
LangType _langType = L_EXTERNAL;
|
||||
generic_string _localizationPath;
|
||||
generic_string _udlName;
|
||||
|
||||
generic_string _easterEggName;
|
||||
unsigned char _quoteType = '\0';
|
||||
|
@ -269,6 +270,7 @@ struct CmdLineParamsDTO
|
|||
int _pos2go = 0;
|
||||
|
||||
LangType _langType = L_EXTERNAL;
|
||||
generic_string _udlName;
|
||||
|
||||
static CmdLineParamsDTO FromCmdLineParams(const CmdLineParams& params)
|
||||
{
|
||||
|
@ -284,7 +286,7 @@ struct CmdLineParamsDTO
|
|||
dto._pos2go = params._pos2go;
|
||||
|
||||
dto._langType = params._langType;
|
||||
|
||||
dto._udlName = params._udlName;
|
||||
return dto;
|
||||
}
|
||||
};
|
||||
|
@ -1821,7 +1823,6 @@ private:
|
|||
bool _isx64 = false; // by default 32-bit
|
||||
|
||||
generic_string _cmdSettingsDir;
|
||||
|
||||
generic_string _titleBarAdditional;
|
||||
|
||||
public:
|
||||
|
|
|
@ -310,6 +310,7 @@ const TCHAR FLAG_NOTEPAD_COMPATIBILITY[] = TEXT("-notepadStyleCmdline");
|
|||
const TCHAR FLAG_OPEN_FOLDERS_AS_WORKSPACE[] = TEXT("-openFoldersAsWorkspace");
|
||||
const TCHAR FLAG_SETTINGS_DIR[] = TEXT("-settingsDir=");
|
||||
const TCHAR FLAG_TITLEBAR_ADD[] = TEXT("-titleAdd=");
|
||||
const TCHAR FLAG_APPLY_UDL[] = TEXT("-udl=");
|
||||
|
||||
void doException(Notepad_plus_Window & notepad_plus_plus)
|
||||
{
|
||||
|
@ -482,6 +483,19 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int)
|
|||
nppParameters.setTitleBarAdd(titleBarAdditional);
|
||||
}
|
||||
|
||||
generic_string udlName;
|
||||
if (getParamValFromString(FLAG_APPLY_UDL, params, udlName))
|
||||
{
|
||||
if (udlName.length() >= 2)
|
||||
{
|
||||
if (udlName.front() == '"' && udlName.back() == '"')
|
||||
{
|
||||
udlName = udlName.substr(1, udlName.length() - 2);
|
||||
}
|
||||
}
|
||||
cmdLineParams._udlName = udlName;
|
||||
}
|
||||
|
||||
if (showHelp)
|
||||
::MessageBox(NULL, COMMAND_ARG_HELP, TEXT("Notepad++ Command Argument Help"), MB_OK);
|
||||
|
||||
|
|
Loading…
Reference in New Issue