Skip to content

Commit

Permalink
CMake: update the keywords for syntax highlight
Browse files Browse the repository at this point in the history
Colours and fonts dialog: use a more modern dialog for displaying the keywords

Signed-off-by: Eran Ifrah <[email protected]>
  • Loading branch information
eranif committed Oct 8, 2024
1 parent 5180d7d commit 39c244b
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 58 deletions.
34 changes: 10 additions & 24 deletions LiteEditor/free_text_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,44 +29,29 @@
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////

#ifdef WX_PRECOMP

#include "wx/wxprec.h"
#include "free_text_dialog.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif //__BORLANDC__
#include "globals.h"

#else
#include <wx/wx.h>
#endif // WX_PRECOMP

#include "free_text_dialog.h"
#include <wx/wxprec.h>

///////////////////////////////////////////////////////////////////////////

FreeTextDialog::FreeTextDialog(wxWindow* parent,
wxString value,
int id,
wxString title,
wxPoint pos,
wxSize size,
int style)
FreeTextDialog::FreeTextDialog(wxWindow* parent, const wxString& value, int id, const wxString& title, wxPoint pos,
wxSize size, int style)
: wxDialog(parent, id, title, pos, size, style)
{
this->SetSizeHints(wxDefaultSize, wxDefaultSize);

wxBoxSizer* bSizer23;
bSizer23 = new wxBoxSizer(wxVERTICAL);

m_text = new wxTextCtrl(this,
wxID_ANY,
wxEmptyString,
wxDefaultPosition,
wxDefaultSize,
wxTE_MULTILINE | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB | wxTE_RICH2);
m_text = new clThemedSTC(this, wxID_ANY, value, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
m_text->SetWrapMode(wxSTC_WRAP_WORD);

bSizer23->Add(m_text, 1, wxALL | wxEXPAND, 5);
m_text->SetValue(value);
m_text->CallAfter(&clThemedSTC::SetFocus);

m_staticline9 = new wxStaticLine(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL);
bSizer23->Add(m_staticline9, 0, wxEXPAND | wxALL, 5);
Expand All @@ -85,4 +70,5 @@ FreeTextDialog::FreeTextDialog(wxWindow* parent,
this->SetSizer(bSizer23);
this->Layout();
m_text->SetFocus();
::clSetDialogBestSizeAndPosition(this);
}
37 changes: 11 additions & 26 deletions LiteEditor/free_text_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,43 +22,28 @@
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version May 5 2007)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////

#ifndef __free_text_dialog__
#define __free_text_dialog__
#pragma once

#include <wx/wx.h>
#include "clThemedSTC.hpp"

#include <wx/statline.h>
#include <wx/button.h>
#include <wx/statline.h>
#include <wx/wx.h>

///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////
/// Class FreeTextDialog
///////////////////////////////////////////////////////////////////////////////
class FreeTextDialog : public wxDialog
{
protected:
wxTextCtrl* m_text;
wxStaticLine* m_staticline9;
wxButton* m_buttonOK;
wxButton* m_buttonCancel;
clThemedSTC* m_text = nullptr;
wxStaticLine* m_staticline9 = nullptr;
wxButton* m_buttonOK = nullptr;
wxButton* m_buttonCancel = nullptr;

public:
FreeTextDialog(wxWindow* parent,
wxString value = wxEmptyString,
int id = wxID_ANY,
wxString title = _("Edit"),
wxPoint pos = wxDefaultPosition,
wxSize size = wxSize(481, 299),
int style = wxDEFAULT_DIALOG_STYLE);
FreeTextDialog(wxWindow* parent, const wxString& value = wxEmptyString, int id = wxID_ANY,
const wxString& title = _("Edit"), wxPoint pos = wxDefaultPosition, wxSize size = wxSize(481, 299),
int style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
wxString GetValue() const { return m_text->GetValue(); }
};

#endif //__free_text_dialog__
147 changes: 139 additions & 8 deletions Plugin/ColoursAndFontsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@
#include "cl_command_event.h"
#include "cl_standard_paths.h"
#include "codelite_events.h"
#include "editor_config.h"
#include "event_notifier.h"
#include "file_logger.h"
#include "fileextmanager.h"
#include "fileutils.h"
#include "globals.h"
#include "imanager.h"
#include "macros.h"
#include "wxStringHash.h"
#include "xmlutils.h"

#include <algorithm>
#include <wx/busyinfo.h>
Expand All @@ -39,6 +34,138 @@ wxDEFINE_EVENT(wxEVT_UPGRADE_LEXERS_PROGRESS, clCommandEvent);

namespace
{
// CMake keywords
const std::vector<wxString> CMAKE_KEYWORDS = {
"add_compile_definitions",
"add_compile_options",
"add_custom_command",
"add_custom_target",
"add_definitions",
"add_dependencies",
"add_executable",
"add_library",
"add_link_options",
"add_subdirectory",
"add_test",
"aux_source_directory",
"block",
"break",
"build_command",
"build_name",
"cmake_file_api",
"cmake_host_system_information",
"cmake_language",
"cmake_minimum_required",
"cmake_parse_arguments",
"cmake_path",
"cmake_policy",
"configure_file",
"continue",
"create_test_sourcelist",
"ctest_build",
"ctest_configure",
"ctest_coverage",
"ctest_empty_binary_directory",
"ctest_memcheck",
"ctest_read_custom_files",
"ctest_run_script",
"ctest_sleep",
"ctest_start",
"ctest_submit",
"ctest_test",
"ctest_update",
"ctest_upload",
"define_property",
"else",
"elseif",
"enable_language",
"enable_testing",
"endblock",
"endforeach",
"endfunction",
"endif",
"endmacro",
"endwhile",
"exec_program",
"execute_process",
"export",
"export_library_dependencies",
"file",
"find_file",
"find_library",
"find_package",
"find_path",
"find_program",
"fltk_wrap_ui",
"foreach",
"function",
"get_cmake_property",
"get_directory_property",
"get_filename_component",
"get_property",
"get_source_file_property",
"get_target_property",
"get_test_property",
"if",
"include",
"include_directories",
"include_external_msproject",
"include_guard",
"include_regular_expression",
"install",
"install_files",
"install_programs",
"install_targets",
"link_directories",
"link_libraries",
"list",
"load_cache",
"load_command",
"macro",
"make_directory",
"mark_as_advanced",
"math",
"message",
"option",
"output_required_files",
"project",
"qt_wrap_cpp",
"qt_wrap_ui",
"remove",
"remove_definitions",
"return",
"separate_arguments",
"set",
"set_directory_properties",
"set_property",
"set_source_files_properties",
"set_target_properties",
"set_tests_properties",
"site_name",
"source_group",
"string",
"subdir_depends",
"subdirs",
"target_compile_definitions",
"target_compile_features",
"target_compile_options",
"target_include_directories",
"target_link_directories",
"target_link_libraries",
"target_link_options",
"target_precompile_headers",
"target_sources",
"try_compile",
"try_run",
"unset",
"use_mangled_mesa",
"utility_source",
"variable_requires",
"variable_watch",
"while",
"write_file",
};

wxString DEFAULT_THEME = "Atom One-Dark";
void AddLexerKeywords(LexerConf::Ptr_t lexer, int setIndex, const std::vector<wxString>& words)
{
Expand Down Expand Up @@ -911,6 +1038,10 @@ LexerConf::Ptr_t ColoursAndFontsManager::DoAddLexer(JSONItem json)
AddFileExtension(lexer, "*.conf");
}

if (lexer->GetName() == "cmake") {
AddLexerKeywords(lexer, 0, CMAKE_KEYWORDS);
}

// Upgrade the lexer colours
UpdateLexerColours(lexer, false);

Expand Down Expand Up @@ -988,9 +1119,9 @@ bool ColoursAndFontsManager::ImportLexersFile(const wxFileName& inputFile, bool
}

if (prompt) {
if (::wxMessageBox(
_("Importing syntax highlight file will override any duplicate syntax highlight settings.\nContinue?"),
"CodeLite", wxICON_QUESTION | wxYES_NO | wxCANCEL | wxYES_DEFAULT, NULL) != wxYES) {
if (::wxMessageBox(_("Importing syntax highlight file will override any duplicate syntax highlight "
"settings.\nContinue?"),
"CodeLite", wxICON_QUESTION | wxYES_NO | wxCANCEL | wxYES_DEFAULT, NULL) != wxYES) {
return false;
}
}
Expand Down

0 comments on commit 39c244b

Please sign in to comment.