Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge changes from release 1.16 to master #53

Merged
merged 4 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//////////////////////////////////////////////////////////////////////////
//
// Vinatext Syntax Highlight Settings
// -----------------------------------------------------------------------
// This is a part of Vinatext Project
// Copyright(C) www.vinatext.dev - vinadevs
// This file can be used, distributed or modified under MIT license
//
// HOW TO SUPPORT SYNTAX HIGHLIGHT FOR A NEW FILE FORMAT
// IF YOU WANT FILE EXTENTION .vala USING CSHAPE (C#) HIGHLIGHT SYNTAX
// - 1. ADD "vala" AFTER "|" EX: SYNTAX_HIGHLIGHT_CSHAPE : cs|vala
// - 2. SAVE THIS FILE AND REOPEN VINATEXT
//////////////////////////////////////////////////////////////////////////

SYNTAX_HIGHLIGHT_PYTHON : py|pyw|
SYNTAX_HIGHLIGHT_CPP : cpp|cxx|h|hh|hpp|hxx|cc|
SYNTAX_HIGHLIGHT_ADA : ada|ads|adb|
SYNTAX_HIGHLIGHT_ASM : asm|
SYNTAX_HIGHLIGHT_INNOSETUP : iss|
SYNTAX_HIGHLIGHT_BASH : sh|
SYNTAX_HIGHLIGHT_BATCH : bat|cmd|nt|
SYNTAX_HIGHLIGHT_C : c|
SYNTAX_HIGHLIGHT_CMAKE : cmake|
SYNTAX_HIGHLIGHT_CSHAPE : cs|vala|
SYNTAX_HIGHLIGHT_CSS : css|
SYNTAX_HIGHLIGHT_ERLANG : erl|hrl|
SYNTAX_HIGHLIGHT_FORTRAN : f|for|f90|f95|f77|
SYNTAX_HIGHLIGHT_HTML : htm|html|shtml|htt|cfm|tpl|hta|
SYNTAX_HIGHLIGHT_JAVA : java|
SYNTAX_HIGHLIGHT_JAVASCRIPT : js|jsx|
SYNTAX_HIGHLIGHT_TYPESCRIPT : ts|tsx|
SYNTAX_HIGHLIGHT_LUA : lua|
SYNTAX_HIGHLIGHT_MATLAB : m|
SYNTAX_HIGHLIGHT_PASCAL : pas|inc|pp|
SYNTAX_HIGHLIGHT_PERL : pl|pm|cgi|pod|
SYNTAX_HIGHLIGHT_PHP : php|php3|php4|php5|phps|phpt|phtml|
SYNTAX_HIGHLIGHT_POWERSHELL : ps1|psm1|
SYNTAX_HIGHLIGHT_RUBY : rb|
SYNTAX_HIGHLIGHT_RUST : rs|
SYNTAX_HIGHLIGHT_SQL : sql|spec|body|sps|spb|sf|sp|
SYNTAX_HIGHLIGHT_TCL : tcl|
SYNTAX_HIGHLIGHT_VISUALBASIC : vb|vbs|frm|cls|ctl|pag|dsr|dob|
SYNTAX_HIGHLIGHT_VERILOG : v|sv|vh|svh|
SYNTAX_HIGHLIGHT_VHDL : vhd|vhdl|
SYNTAX_HIGHLIGHT_XML : xml|gcl|xsl|svg|xul|xsd|dtd|xslt|axl|
SYNTAX_HIGHLIGHT_JSON : json|
SYNTAX_HIGHLIGHT_GOLANG : go|
SYNTAX_HIGHLIGHT_MARKDOWN : md|markdown|rmd|
SYNTAX_HIGHLIGHT_PROTOBUF : proto|
SYNTAX_HIGHLIGHT_R : r|
SYNTAX_HIGHLIGHT_LICENSE : lic|
SYNTAX_HIGHLIGHT_RESOURCE : rc|
SYNTAX_HIGHLIGHT_AUTOIT : au3|
SYNTAX_HIGHLIGHT_BASIC : bas|
SYNTAX_HIGHLIGHT_VCPROJECT : vcxproj|filters|user|vcproj|csproj|csxproj|vbproj|dbproj|sln|
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//////////////////////////////////////////////////////////////////////////
//
// Vinatext Syntax Highlight Settings
// -----------------------------------------------------------------------
// This is a part of Vinatext Project
// Copyright(C) www.vinatext.dev - vinadevs
// This file can be used, distributed or modified under MIT license
//
// HOW TO SUPPORT SYNTAX HIGHLIGHT FOR A NEW FILE FORMAT
// IF YOU WANT FILE EXTENTION .vala USING CSHAPE (C#) HIGHLIGHT SYNTAX
// - 1. ADD "vala" AFTER "|" EX: SYNTAX_HIGHLIGHT_CSHAPE : cs|vala
// - 2. SAVE THIS FILE AND REOPEN VINATEXT
//////////////////////////////////////////////////////////////////////////

SYNTAX_HIGHLIGHT_PYTHON : py|pyw|
SYNTAX_HIGHLIGHT_CPP : cpp|cxx|h|hh|hpp|hxx|cc|
SYNTAX_HIGHLIGHT_ADA : ada|ads|adb|
SYNTAX_HIGHLIGHT_ASM : asm|
SYNTAX_HIGHLIGHT_INNOSETUP : iss|
SYNTAX_HIGHLIGHT_BASH : sh|
SYNTAX_HIGHLIGHT_BATCH : bat|cmd|nt|
SYNTAX_HIGHLIGHT_C : c|
SYNTAX_HIGHLIGHT_CMAKE : cmake|
SYNTAX_HIGHLIGHT_CSHAPE : cs|vala|
SYNTAX_HIGHLIGHT_CSS : css|
SYNTAX_HIGHLIGHT_ERLANG : erl|hrl|
SYNTAX_HIGHLIGHT_FORTRAN : f|for|f90|f95|f77|
SYNTAX_HIGHLIGHT_HTML : htm|html|shtml|htt|cfm|tpl|hta|
SYNTAX_HIGHLIGHT_JAVA : java|
SYNTAX_HIGHLIGHT_JAVASCRIPT : js|jsx|
SYNTAX_HIGHLIGHT_TYPESCRIPT : ts|tsx|
SYNTAX_HIGHLIGHT_LUA : lua|
SYNTAX_HIGHLIGHT_MATLAB : m|
SYNTAX_HIGHLIGHT_PASCAL : pas|inc|pp|
SYNTAX_HIGHLIGHT_PERL : pl|pm|cgi|pod|
SYNTAX_HIGHLIGHT_PHP : php|php3|php4|php5|phps|phpt|phtml|
SYNTAX_HIGHLIGHT_POWERSHELL : ps1|psm1|
SYNTAX_HIGHLIGHT_RUBY : rb|
SYNTAX_HIGHLIGHT_RUST : rs|
SYNTAX_HIGHLIGHT_SQL : sql|spec|body|sps|spb|sf|sp|
SYNTAX_HIGHLIGHT_TCL : tcl|
SYNTAX_HIGHLIGHT_VISUALBASIC : vb|vbs|frm|cls|ctl|pag|dsr|dob|
SYNTAX_HIGHLIGHT_VERILOG : v|sv|vh|svh|
SYNTAX_HIGHLIGHT_VHDL : vhd|vhdl|
SYNTAX_HIGHLIGHT_XML : xml|gcl|xsl|svg|xul|xsd|dtd|xslt|axl|
SYNTAX_HIGHLIGHT_JSON : json|
SYNTAX_HIGHLIGHT_GOLANG : go|
SYNTAX_HIGHLIGHT_MARKDOWN : md|markdown|rmd|
SYNTAX_HIGHLIGHT_PROTOBUF : proto|
SYNTAX_HIGHLIGHT_R : r|
SYNTAX_HIGHLIGHT_LICENSE : lic|
SYNTAX_HIGHLIGHT_RESOURCE : rc|
SYNTAX_HIGHLIGHT_AUTOIT : au3|
SYNTAX_HIGHLIGHT_BASIC : bas|
SYNTAX_HIGHLIGHT_VCPROJECT : vcxproj|filters|user|vcproj|csproj|csxproj|vbproj|dbproj|sln|
12 changes: 11 additions & 1 deletion src/AppSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void CAppSettings::ResetAllSettings()
m_bEnableShowHideFoldingMargin = FALSE;
m_bAutoSaveFileWhenCloseApp = TRUE;
m_bAutoAddNewLineAtTheEOF = FALSE;
m_bUseInstallPathAsAppDataPath = FALSE;
m_bUseInstallPathAsAppDataPath = TRUE;
m_bUseUserIndentationSettings = FALSE;

// folder bar
Expand Down Expand Up @@ -375,6 +375,16 @@ void CAppSettings::ResetEditorCaretInfo()
m_RecentEditorCaretInfo.clear();
}

void CAppSettings::ResetWindowPlacements()
{
m_bResetWindowPlacements = TRUE;
}

BOOL CAppSettings::ShouldResetWindowPlacements() const
{
return m_bResetWindowPlacements;
}

void CAppSettings::SaveRecentEditorCaretInfo(const CString& strPathName)
{
CEditorDoc* pDoc = dynamic_cast<CEditorDoc*>(AppUtils::GetExistedDocument(strPathName));
Expand Down
8 changes: 7 additions & 1 deletion src/AppSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class CAppSettings
void SaveRecentEditorCaretInfo(const CString& strPathName);
RecentEditorInfo GetRecentEditorCaretInfo(const CString& strPathName);
void ResetEditorCaretInfo();
void ResetWindowPlacements();
BOOL ShouldResetWindowPlacements() const;

// save/load from file
BOOL SaveSettingData();
Expand Down Expand Up @@ -106,7 +108,7 @@ class CAppSettings
BOOL m_bEnableShowHideFoldingMargin = FALSE;
BOOL m_bAutoSaveFileWhenCloseApp = TRUE;
BOOL m_bAutoAddNewLineAtTheEOF = FALSE;
BOOL m_bUseInstallPathAsAppDataPath = FALSE;
BOOL m_bUseInstallPathAsAppDataPath = TRUE;
BOOL m_bUseUserIndentationSettings = FALSE;

// editor style
Expand Down Expand Up @@ -179,6 +181,10 @@ class CAppSettings
// Document ID
typedef std::unordered_set<int> DocumentEmptyIDBuffer;
DocumentEmptyIDBuffer m_DocIDBuffer;

// reset workspace
BOOL m_bResetWindowPlacements = FALSE;

// singleton
SINGLETON_IMPLEMENT(CAppSettings)
};
Expand Down
5 changes: 5 additions & 0 deletions src/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ void CCommandLineInfoEx::ParseParam(const TCHAR* pszParam, BOOL bFlag, BOOL bLas
m_cmdOption = VINATEXT_CMD_OPTION::VINATEXT_CMD_REOPEN_WITH_ADMIN_RIGHT;
return;
}
else if (strParam == _T("restartApplication"))
{
m_cmdOption = VINATEXT_CMD_OPTION::VINATEXT_CMD_RESTART_APP;
return;
}
}
CCommandLineInfo::ParseParam(pszParam, bFlag, bLast);
}
Expand Down
1 change: 1 addition & 0 deletions src/CommandLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum class VINATEXT_CMD_OPTION : unsigned int
VINATEXT_CMD_OPTION_INIT = 0,
VINATEXT_CMD_MOVE_TO_NEW_WINDOW = 1,
VINATEXT_CMD_REOPEN_WITH_ADMIN_RIGHT = 2,
VINATEXT_CMD_RESTART_APP = 3,
};

class CCommandLineInfoEx : public CCommandLineInfo
Expand Down
39 changes: 31 additions & 8 deletions src/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include "EditorColorDark.h"
#include "EditorColorLight.h"

#include "UserCustomizeData.h"

CEditorCtrl::CEditorCtrl()
{
m_wideBuf = std::make_unique<wchar_t[]>(m_wideBufSize);
Expand Down Expand Up @@ -3050,19 +3052,40 @@ BOOL CEditorCtrl::SaveEditorDataToFile(const CString& szFile, CString& m_strLexe
CString CEditorCtrl::GetLexerNameFromExtension(const CString& szExtension)
{
int lexerIndex = 0;
CString pExtension = EditorLanguageDef::arrLangExtensions[lexerIndex];
while (!pExtension.IsEmpty())
const auto& userArrLangExtensions = AppUtils::GetVinaTextApp()->m_userCustomizeData->GetSyntaxHighlightUserData();
if (userArrLangExtensions.empty())
{
CString extension = EditorLanguageDef::arrLangExtensions[lexerIndex];
while (!extension.IsEmpty())
{
CLexingParser parser(EditorLanguageDef::arrLangExtensions[lexerIndex], _T("|"));
while (parser.HasMoreTokens())
{
if (parser.Next().CompareNoCase(szExtension) == 0)
{
return AppUtils::StdToCString(EditorLanguageDef::arrLexerNames[lexerIndex]);
}
}
lexerIndex++;
extension = EditorLanguageDef::arrLangExtensions[lexerIndex];
}
}
else
{
CLexingParser parser(EditorLanguageDef::arrLangExtensions[lexerIndex], _T("|"));
while (parser.HasMoreTokens())
CString extension = userArrLangExtensions[lexerIndex];
while (!extension.IsEmpty())
{
if (parser.Next().CompareNoCase(szExtension) == 0)
CLexingParser parser(userArrLangExtensions[lexerIndex], _T("|"));
while (parser.HasMoreTokens())
{
return AppUtils::StdToCString(EditorLanguageDef::arrLexerNames[lexerIndex]);
if (parser.Next().CompareNoCase(szExtension) == 0)
{
return AppUtils::StdToCString(EditorLanguageDef::arrLexerNames[lexerIndex]);
}
}
lexerIndex++;
extension = userArrLangExtensions[lexerIndex];
}
lexerIndex++;
pExtension = EditorLanguageDef::arrLangExtensions[lexerIndex];
}
return LEXER_PLAIN_TEXT;
}
Expand Down
2 changes: 1 addition & 1 deletion src/EditorCommonDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace EditorLanguageDef
_T("js|jsx"), // SCLEX_CPP
_T("ts|tsx"), // SCLEX_CPP
_T("lua"), // SCLEX_LUA
_T("m"), // SCLEX_MATLAB// SCLEX_LUA
_T("m"), // SCLEX_MATLAB
_T("pas|inc|pp"), // SCLEX_PASCAL
_T("pl|pm|cgi|pod"), // SCLEX_PERL
_T("php|php3|php4|php5|phps|phpt|phtml"), // SCLEX_PHP
Expand Down
14 changes: 14 additions & 0 deletions src/EditorView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ BEGIN_MESSAGE_MAP(CEditorView, CViewBase)
ON_COMMAND(ID_DOCUMENT_TEXT_LEXER_BASH_BATCH, OnEnableUserLexerLexerBashBatch)
ON_COMMAND(ID_DOCUMENT_TEXT_LEXER_VB_PASCAL, OnEnableUserLexerLexerVBPascal)
ON_COMMAND(ID_DOCUMENT_TEXT_LEXER_NON, OnDisableUserLexer)
ON_COMMAND(ID_DOCUMENT_TEXT_LEXER_EXTENSION, OnAddLexerForFileExtension)
ON_COMMAND(ID_EDIT_ALIGN_LEFT, OnOptionAlignLeft)
ON_COMMAND(ID_EDIT_ALIGN_RIGHT, OnOptionAlignRight)
ON_COMMAND(ID_EDIT_ALIGN_CENTER, OnOptionAlignCenter)
Expand Down Expand Up @@ -9064,6 +9065,19 @@ void CEditorView::OnDisableUserLexer()
ChangeUserLexer(_T(""));
}

void CEditorView::OnAddLexerForFileExtension()
{
const CString syntaxHighlightUserDataPath = PathUtils::GetSyntaxHighlightUserDataPath();
if (PathFileExists(syntaxHighlightUserDataPath))
{
AppUtils::CreateDocumentFromFile(syntaxHighlightUserDataPath);
}
else
{
AfxMessageBoxFormat(MB_ICONWARNING, _T("[Path Error] \"%s\" does not exist!\n"), syntaxHighlightUserDataPath);
}
}

void CEditorView::ChangeToEditorReadOnly()
{
m_EditorCtrl.SetReadOnlyEditor(TRUE);
Expand Down
1 change: 1 addition & 0 deletions src/EditorView.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ class CEditorView : public CViewBase
afx_msg void OnEnableUserLexerLexerBashBatch();
afx_msg void OnEnableUserLexerLexerVBPascal();
afx_msg void OnDisableUserLexer();
afx_msg void OnAddLexerForFileExtension();
afx_msg void OnOptionAlignLeft();
afx_msg void OnOptionAlignRight();
afx_msg void OnOptionAlignCenter();
Expand Down
2 changes: 1 addition & 1 deletion src/GeneralSettingDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ constexpr int DEFAULT_LFWEIGHT = 10;
IMPLEMENT_DYNAMIC(GeneralSettingDlg, CDialogEx)

GeneralSettingDlg::GeneralSettingDlg(CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_DIALOG_SETTING_GENERAL, pParent), m_bUseInstallPathAsAppDataPath(FALSE)
: CDialogEx(IDD_DIALOG_SETTING_GENERAL, pParent)
{
m_pScrollHelper = std::make_unique<CScrollHelper>();
m_pScrollHelper->AttachWnd(this);
Expand Down
7 changes: 6 additions & 1 deletion src/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,11 @@ void CMainFrame::OnDestroy()
m_wndSearchAndReplaceWindow.SaveDialogState();
}

if (AppSettingMgr.ShouldResetWindowPlacements())
{
OSUtils::DeleteRegistryKey(_T("VinaText-Vinadevs"));
}

CMDIFrameWndEx::OnDestroy();
}

Expand Down Expand Up @@ -3749,7 +3754,7 @@ void CMainFrame::OnMDITabMoveToNewVinaText()
if (PathFileExists(strPathVinaTextExe))
{
// Open new app instance...
BOOL bRet = OSUtils::CreateWin32Process(strPathVinaTextExe + _T(" -moveFileToNewInstance ") + +_T(" \"") + strPathName + _T("\""));
BOOL bRet = OSUtils::CreateWin32Process(strPathVinaTextExe + _T(" -moveFileToNewInstance ") + _T(" \"") + strPathName + _T("\""));
if (bRet)
{
// Create new instance fine so close current doc
Expand Down
47 changes: 44 additions & 3 deletions src/OSUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,25 @@ CString OSUtils::GetRegistryAppPath(const CString & strEXEName)
return strFullPath;
}

void OSUtils::DeleteRegistryKey(const CString& lpSubKey)
{
HKEY hKey;
LONG result = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software"), 0, KEY_WRITE, &hKey);
if (result == ERROR_SUCCESS)
{
result = RegDeleteTree(hKey, lpSubKey);
if (result != ERROR_SUCCESS)
{
assert(FALSE);
}
RegCloseKey(hKey);
}
else
{
assert(FALSE);
}
}

void OSUtils::OpenFileInWebBrowser(const CString& strEXEName, const CString& strFilePath)
{
if (strEXEName.Find(_T("MicrosoftEdge")) != -1)
Expand Down Expand Up @@ -394,7 +413,7 @@ void OSUtils::UseAdministrationHandler()
CString strPathVinaTextExe = PathUtils::GetVinaTextExePath();
if (PathFileExists(strPathVinaTextExe))
{
intptr_t bRet = reinterpret_cast<intptr_t>(::ShellExecute(AppUtils::GetMainFrame()->GetSafeHwnd(), TEXT("runas"), strPathVinaTextExe, _T(" -openWithAdminRight "), NULL, SW_SHOW));
const intptr_t bRet = reinterpret_cast<intptr_t>(::ShellExecute(AppUtils::GetMainFrame()->GetSafeHwnd(), TEXT("runas"), strPathVinaTextExe, _T(" -openWithAdminRight "), NULL, SW_SHOW));
if (bRet)
{
if (bRet < SUCCESS_SHELL_EXEC_RET)
Expand All @@ -403,7 +422,7 @@ void OSUtils::UseAdministrationHandler()
}
else
{
::PostQuitMessage(0);
AppUtils::GetMainFrame()->DestroyWindow();
}
}
}
Expand All @@ -413,4 +432,26 @@ void OSUtils::UseAdministrationHandler()
LOG_OUTPUT_MESSAGE_ACTIVE_PANE(strMsg, BasicColors::orange);
}
}
}
}

void OSUtils::RestartApplication()
{
CString strPathVinaTextExe = PathUtils::GetVinaTextExePath();
if (PathFileExists(strPathVinaTextExe))
{
const BOOL bRet = OSUtils::CreateWin32Process(strPathVinaTextExe + _T(" -restartApplication "));
if (!bRet)
{
AfxMessageBox(_T("[Error] Could not restart VinaText."));
}
else
{
AppUtils::GetMainFrame()->DestroyWindow();
}
}
else
{
CString strMsg; strMsg.Format(_T("[Path Error] \"%s\" does not exist...\n"), strPathVinaTextExe);
LOG_OUTPUT_MESSAGE_ACTIVE_PANE(strMsg, BasicColors::orange);
}
}
Loading