Add more API for custom auto-indentation and current macro status
4 new API are added: - NPPM_GETEXTERNALLEXERAUTOINDENTMODE - NPPM_SETEXTERNALLEXERAUTOINDENTMODE - NPPM_ISAUTOINDENTON - NPPM_GETCURRENTMACROSTATUS * Added support for custom auto-indentation for external lexer. * Also added messages to fetch current Macro status (Idle, Recording, Stopped, Running) -> for this also affects auto-indentation behavior. * Also added capability to query for the current User Settings of "Use Auto Indentation". Fix #11253, close #11278pull/11352/head
parent
a06b404708
commit
9cbd03c301
|
@ -159,10 +159,6 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
|
||||
#define MACRO_RECORDING_IN_PROGRESS 1
|
||||
#define MACRO_RECORDING_HAS_STOPPED 2
|
||||
|
||||
#define REBARBAND_SIZE sizeof(REBARBANDINFO)
|
||||
|
||||
generic_string PathRemoveFileSpec(generic_string & path);
|
||||
|
|
|
@ -36,8 +36,10 @@ enum LangType {L_TEXT, L_PHP , L_C, L_CPP, L_CS, L_OBJC, L_JAVA, L_RC,\
|
|||
// Don't use L_JS, use L_JAVASCRIPT instead
|
||||
// The end of enumated language type, so it should be always at the end
|
||||
L_EXTERNAL};
|
||||
enum class ExternalLexerAutoIndentMode { Standard, C_Like, Custom };
|
||||
enum class MacroStatus { Idle, RecordInProgress, RecordingStopped, PlayingBack };
|
||||
|
||||
enum winVer{ WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV_S2003, WV_XPX64, WV_VISTA, WV_WIN7, WV_WIN8, WV_WIN81, WV_WIN10 };
|
||||
enum winVer { WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV_S2003, WV_XPX64, WV_VISTA, WV_WIN7, WV_WIN8, WV_WIN81, WV_WIN10 };
|
||||
enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 };
|
||||
|
||||
|
||||
|
@ -454,6 +456,32 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 };
|
|||
HICON hToolbarIconDarkMode;
|
||||
};
|
||||
|
||||
#define NPPM_GETEXTERNALLEXERAUTOINDENTMODE (NPPMSG + 103)
|
||||
// BOOL NPPM_GETEXTERNALLEXERAUTOINDENTMODE(const TCHAR *languageName, ExternalLexerAutoIndentMode &autoIndentMode)
|
||||
// Get ExternalLexerAutoIndentMode for an installed external programming language.
|
||||
// - Standard means Notepad++ will keep the same TAB indentation between lines;
|
||||
// - C_Like means Notepad++ will perform a C-Language style indentation for the selected external language;
|
||||
// - Custom means a Plugin will be controlling auto-indentation for the current language.
|
||||
// returned values: TRUE for successful searches, otherwise FALSE.
|
||||
|
||||
#define NPPM_SETEXTERNALLEXERAUTOINDENTMODE (NPPMSG + 104)
|
||||
// BOOL NPPM_SETEXTERNALLEXERAUTOINDENTMODE(const TCHAR *languageName, ExternalLexerAutoIndentMode autoIndentMode)
|
||||
// Set ExternalLexerAutoIndentMode for an installed external programming language.
|
||||
// - Standard means Notepad++ will keep the same TAB indentation between lines;
|
||||
// - C_Like means Notepad++ will perform a C-Language style indentation for the selected external language;
|
||||
// - Custom means a Plugin will be controlling auto-indentation for the current language.
|
||||
// returned value: TRUE if function call was successful, otherwise FALSE.
|
||||
|
||||
#define NPPM_ISAUTOINDENTON (NPPMSG + 105)
|
||||
// BOOL NPPM_ISAUTOINDENTON(0, 0)
|
||||
// Returns the current Use Auto-Indentation setting in Notepad++ Preferences.
|
||||
|
||||
#define NPPM_GETCURRENTMACROSTATUS (NPPMSG + 106)
|
||||
// MacroStatus NPPM_GETCURRENTMACROSTATUS(0, 0)
|
||||
// Gets current enum class MacroStatus { Idle - means macro is not in use and it's empty, RecordInProgress, RecordingStopped, PlayingBack }
|
||||
|
||||
|
||||
|
||||
#define VAR_NOT_RECOGNIZED 0
|
||||
#define FULL_CURRENT_PATH 1
|
||||
#define CURRENT_DIRECTORY 2
|
||||
|
|
|
@ -3103,6 +3103,16 @@ void Notepad_plus::maintainIndentation(TCHAR ch)
|
|||
intptr_t tabWidth = _pEditView->execute(SCI_GETTABWIDTH);
|
||||
|
||||
LangType type = _pEditView->getCurrentBuffer()->getLangType();
|
||||
ExternalLexerAutoIndentMode autoIndentMode = ExternalLexerAutoIndentMode::Standard;
|
||||
|
||||
// For external languages, query for custom auto-indentation funcionality
|
||||
if (type >= L_EXTERNAL)
|
||||
{
|
||||
NppParameters& nppParam = NppParameters::getInstance();
|
||||
autoIndentMode = nppParam.getELCFromIndex(type - L_EXTERNAL)._autoIndentMode;
|
||||
if (autoIndentMode == ExternalLexerAutoIndentMode::Custom)
|
||||
return;
|
||||
}
|
||||
|
||||
// Do not alter indentation if we were at the beginning of the line and we pressed Enter
|
||||
if ((((eolMode == SC_EOL_CRLF || eolMode == SC_EOL_LF) && ch == '\n') ||
|
||||
|
@ -3110,7 +3120,8 @@ void Notepad_plus::maintainIndentation(TCHAR ch)
|
|||
return;
|
||||
|
||||
if (type == L_C || type == L_CPP || type == L_JAVA || type == L_CS || type == L_OBJC ||
|
||||
type == L_PHP || type == L_JS || type == L_JAVASCRIPT || type == L_JSP || type == L_CSS || type == L_PERL || type == L_RUST || type == L_POWERSHELL || type == L_JSON)
|
||||
type == L_PHP || type == L_JS || type == L_JAVASCRIPT || type == L_JSP || type == L_CSS || type == L_PERL ||
|
||||
type == L_RUST || type == L_POWERSHELL || type == L_JSON || autoIndentMode == ExternalLexerAutoIndentMode::C_Like)
|
||||
{
|
||||
if (((eolMode == SC_EOL_CRLF || eolMode == SC_EOL_LF) && ch == '\n') ||
|
||||
(eolMode == SC_EOL_CR && ch == '\r'))
|
||||
|
|
|
@ -1295,11 +1295,13 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
return MAKELONG(auxVer, mainVer);
|
||||
}
|
||||
|
||||
case WM_GETCURRENTMACROSTATUS:
|
||||
case NPPM_GETCURRENTMACROSTATUS:
|
||||
{
|
||||
if (_recordingMacro)
|
||||
return MACRO_RECORDING_IN_PROGRESS;
|
||||
return (_macro.empty())?0:MACRO_RECORDING_HAS_STOPPED;
|
||||
return static_cast<LRESULT>(MacroStatus::RecordInProgress);
|
||||
if (_playingBackMacro)
|
||||
return static_cast<LRESULT>(MacroStatus::PlayingBack);
|
||||
return (_macro.empty()) ? static_cast<LRESULT>(MacroStatus::Idle) : static_cast<LRESULT>(MacroStatus::RecordingStopped);
|
||||
}
|
||||
|
||||
case WM_FRSAVE_INT:
|
||||
|
@ -2553,6 +2555,31 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
return langDesc.length();
|
||||
}
|
||||
|
||||
case NPPM_GETEXTERNALLEXERAUTOINDENTMODE:
|
||||
{
|
||||
int index = nppParam.getExternalLangIndexFromName(reinterpret_cast<TCHAR*>(wParam));
|
||||
if (index < 0)
|
||||
return FALSE;
|
||||
|
||||
*(reinterpret_cast<ExternalLexerAutoIndentMode*>(lParam)) = nppParam.getELCFromIndex(index)._autoIndentMode;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case NPPM_SETEXTERNALLEXERAUTOINDENTMODE:
|
||||
{
|
||||
int index = nppParam.getExternalLangIndexFromName(reinterpret_cast<TCHAR*>(wParam));
|
||||
if (index < 0)
|
||||
return FALSE;
|
||||
|
||||
nppParam.getELCFromIndex(index)._autoIndentMode = static_cast<ExternalLexerAutoIndentMode>(lParam);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case NPPM_ISAUTOINDENTON:
|
||||
{
|
||||
return nppParam.getNppGUI()._maitainIndent;
|
||||
}
|
||||
|
||||
case NPPM_DOCLISTDISABLEPATHCOLUMN:
|
||||
case NPPM_DOCLISTDISABLEEXTCOLUMN:
|
||||
{
|
||||
|
|
|
@ -1082,6 +1082,7 @@ class ExternalLangContainer final
|
|||
public:
|
||||
TCHAR _name[MAX_EXTERNAL_LEXER_NAME_LEN];
|
||||
TCHAR _desc[MAX_EXTERNAL_LEXER_DESC_LEN];
|
||||
ExternalLexerAutoIndentMode _autoIndentMode = ExternalLexerAutoIndentMode::Standard;
|
||||
|
||||
ExternalLangContainer(const TCHAR* name, const TCHAR* desc)
|
||||
{
|
||||
|
|
|
@ -1182,7 +1182,7 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
|||
|
||||
case WM_COMMAND :
|
||||
{
|
||||
bool isMacroRecording = (::SendMessage(_hParent, WM_GETCURRENTMACROSTATUS,0,0) == MACRO_RECORDING_IN_PROGRESS);
|
||||
bool isMacroRecording = (static_cast<MacroStatus>(::SendMessage(_hParent, NPPM_GETCURRENTMACROSTATUS,0,0)) == MacroStatus::RecordInProgress);
|
||||
NppParameters& nppParamInst = NppParameters::getInstance();
|
||||
FindHistory & findHistory = nppParamInst.getFindHistory();
|
||||
switch (LOWORD(wParam))
|
||||
|
@ -2066,7 +2066,7 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op
|
|||
msg = TEXT("^ ") + msg;
|
||||
(*_ppEditView)->showCallTip(start, msg.c_str());
|
||||
}
|
||||
if (::SendMessage(_hParent, WM_GETCURRENTMACROSTATUS,0,0) == MACRO_RECORDING_IN_PROGRESS)
|
||||
if (static_cast<MacroStatus>(::SendMessage(_hParent, NPPM_GETCURRENTMACROSTATUS,0,0)) == MacroStatus::RecordInProgress)
|
||||
(*_ppEditView)->execute(SCI_STARTRECORD);
|
||||
|
||||
delete [] pText;
|
||||
|
|
|
@ -30,7 +30,7 @@ void RunMacroDlg::initMacroList()
|
|||
|
||||
::SendDlgItemMessage(_hSelf, IDC_MACRO_COMBO, CB_RESETCONTENT, 0, 0);
|
||||
|
||||
if (::SendMessage(_hParent, WM_GETCURRENTMACROSTATUS, 0, 0) == MACRO_RECORDING_HAS_STOPPED)
|
||||
if (static_cast<MacroStatus>(::SendMessage(_hParent, NPPM_GETCURRENTMACROSTATUS, 0, 0)) == MacroStatus::RecordingStopped)
|
||||
::SendDlgItemMessage(_hSelf, IDC_MACRO_COMBO, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(TEXT("Current recorded macro")));
|
||||
|
||||
for (size_t i = 0, len = macroList.size(); i < len ; ++i)
|
||||
|
@ -174,6 +174,6 @@ void RunMacroDlg::check(int id)
|
|||
|
||||
int RunMacroDlg::getMacro2Exec() const
|
||||
{
|
||||
bool isCurMacroPresent = ::SendMessage(_hParent, WM_GETCURRENTMACROSTATUS, 0, 0) == MACRO_RECORDING_HAS_STOPPED;
|
||||
bool isCurMacroPresent = static_cast<MacroStatus>(::SendMessage(_hParent, NPPM_GETCURRENTMACROSTATUS, 0, 0)) == MacroStatus::RecordingStopped;
|
||||
return isCurMacroPresent?(_macroIndex - 1):_macroIndex;
|
||||
}
|
||||
|
|
|
@ -667,7 +667,7 @@
|
|||
|
||||
|
||||
#define MACRO_USER (WM_USER + 4000)
|
||||
#define WM_GETCURRENTMACROSTATUS (MACRO_USER + 01)
|
||||
// #define WM_GETCURRENTMACROSTATUS (MACRO_USER + 01) // Replaced with NPPM_GETCURRENTMACROSTATUS
|
||||
#define WM_MACRODLGRUNMACRO (MACRO_USER + 02)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue