Skip to content

Commit

Permalink
Use "Terminal" lexer from the submodule project.
Browse files Browse the repository at this point in the history
Signed-off-by: Eran Ifrah <eran@codelite.org>
  • Loading branch information
eranif committed Nov 30, 2024
1 parent 37ed471 commit c4790a1
Show file tree
Hide file tree
Showing 8 changed files with 54,111 additions and 53,509 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@
[submodule "submodules/wxsf-code"]
path = submodules/wxsf-code
url = https://github.com/eranif/wxsf-code.git
[submodule "submodules/lexilla"]
path = submodules/lexilla
url = https://github.com/eranif/lexilla.git
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,9 @@ endif()
# add the dtl module include path before we include Plugin folder
include_directories(submodules/dtl)

# Extran lexers required by CodeLite
add_subdirectory(submodules/lexilla)

add_subdirectory(submodules)
include_directories(submodules/cJSON)

Expand Down Expand Up @@ -1191,4 +1194,3 @@ endif()
unset(WITH_CHATAI CACHE)
unset(DEBUG_BUILD CACHE)
unset(BUILD_TESTING CACHE)

1 change: 1 addition & 0 deletions Plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ target_link_libraries(
${wxWidgets_LIBRARIES}
${LIBYAML_CPP}
-L"${CL_LIBPATH}"
lexers_extra

This comment has been minimized.

Copy link
@xialin2008

xialin2008 Dec 6, 2024

Compilation failed, LexerBase. cxx. o and LexerSimple. cxx. o are missing - fPIC in the Lexlib static library

This comment has been minimized.

Copy link
@eranif

eranif Dec 6, 2024

Author Owner

All the CI are passing, you can compare the way you compile to what we are doing in the CI.

For example:

https://github.com/eranif/codelite/actions/runs/12188759773/job/34002491882

libcodelite)

if(USE_PCH)
Expand Down
98 changes: 52 additions & 46 deletions Plugin/ThemeImporters/ThemeImporterErrorlist.cpp
Original file line number Diff line number Diff line change
@@ -1,77 +1,83 @@
#include "ThemeImporterErrorlist.hpp"

#include "ExtraLexers.h"
#include "clColours.h"
#include "drawingutils.h"

ThemeImporterErrorlist::ThemeImporterErrorlist()
{
SetFileExtensions("*.log");
m_langName = "errorlist";
m_langName = "terminal";
}

ThemeImporterErrorlist::~ThemeImporterErrorlist() {}

LexerConf::Ptr_t ThemeImporterErrorlist::Import(const wxFileName& theme_file)
{
LexerConf::Ptr_t lexer = InitializeImport(theme_file, m_langName, wxSTC_LEX_ERRORLIST);
LexerConf::Ptr_t lexer = InitializeImport(theme_file, m_langName, wxSTC_LEX_TERMINAL);
bool is_dark = DrawingUtils::IsDark(m_editor.bg_colour);

AddProperty(lexer, wxSTC_ERR_DEFAULT, "Default", m_editor);
AddProperty(lexer, wxSTC_ERR_PYTHON, "Python error message", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_GCC, "GCC like error message", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_MS, "MSVC error message", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_CMD, "CMD error message", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_BORLAND, "Borland error message", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_PERL, "Perl error message", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_NET, ".NET error message", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_LUA, "LUA error message", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_CTAG, "CTags line", clColours::Cyan(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_DIFF_CHANGED, "Diff line changed", clColours::Yellow(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_DIFF_ADDITION, "Diff line added", clColours::Green(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_DIFF_DELETION, "Diff line deleted", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_DIFF_MESSAGE, "Diff line message", clColours::Cyan(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_PHP, "PHP error message", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_ELF, "Essential Lahey Fortran error message", clColours::Red(is_dark),
AddProperty(lexer, wxSTC_TERMINAL_DEFAULT, "Default", m_editor);
AddProperty(lexer, wxSTC_TERMINAL_PYTHON, "Python error message", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_GCC, "GCC like error message", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_GCC_WARNING, "GCC like warning message", clColours::Yellow(is_dark),
m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_GCC_NOTE, "GCC like note message", clColours::Cyan(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_MS, "MSVC error message", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_CMD, "CMD error message", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_BORLAND, "Borland error message", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_PERL, "Perl error message", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_NET, ".NET error message", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_LUA, "LUA error message", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_CTAG, "CTags line", clColours::Cyan(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_DIFF_CHANGED, "Diff line changed", clColours::Yellow(is_dark),
m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_IFC, "Intel Fortran Compiler error/warning message", clColours::Red(is_dark),
AddProperty(lexer, wxSTC_TERMINAL_DIFF_ADDITION, "Diff line added", clColours::Green(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_DIFF_DELETION, "Diff line deleted", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_DIFF_MESSAGE, "Diff line message", clColours::Cyan(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_PHP, "PHP error message", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_ELF, "Essential Lahey Fortran error message", clColours::Red(is_dark),
m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_IFORT, "Intel Fortran Compiler v8.0 error/warning message", clColours::Red(is_dark),
AddProperty(lexer, wxSTC_TERMINAL_IFC, "Intel Fortran Compiler error/warning message", clColours::Red(is_dark),
m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_ABSF, "Absoft Pro Fortran 90/95 v8.2 error and/or warning message",
AddProperty(lexer, wxSTC_TERMINAL_IFORT, "Intel Fortran Compiler v8.0 error/warning message",
clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_TIDY, "HTML tidy style", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_JAVA_STACK, "Java stack", clColours::Cyan(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_VALUE, "Value", m_editor);
AddProperty(lexer, wxSTC_ERR_GCC_INCLUDED_FROM, "GCC 'included from'", clColours::Grey(is_dark),
AddProperty(lexer, wxSTC_TERMINAL_ABSF, "Absoft Pro Fortran 90/95 v8.2 error and/or warning message",
clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_TIDY, "HTML tidy style", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_JAVA_STACK, "Java stack", clColours::Cyan(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_VALUE, "Value", m_editor);
AddProperty(lexer, wxSTC_TERMINAL_GCC_INCLUDED_FROM, "GCC 'included from'", clColours::Grey(is_dark),
m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_ESCSEQ, "ANSI escape sequence", m_editor);
AddProperty(lexer, wxSTC_ERR_ESCSEQ_UNKNOWN, "ANSI escape sequence unknown", clColours::Red(is_dark),
AddProperty(lexer, wxSTC_TERMINAL_ESCSEQ, "ANSI escape sequence", m_editor);
AddProperty(lexer, wxSTC_TERMINAL_ESCSEQ_UNKNOWN, "ANSI escape sequence unknown", clColours::Red(is_dark),
m_editor.bg_colour);

#if wxCHECK_VERSION(3, 3, 0)
AddProperty(lexer, wxSTC_ERR_GCC_EXCERPT, "GCC code excerpt and pointer to issue", clColours::Cyan(is_dark),
AddProperty(lexer, wxSTC_TERMINAL_GCC_EXCERPT, "GCC code excerpt and pointer to issue", clColours::Cyan(is_dark),
m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_BASH, "Bash diagnostic line", clColours::Red(is_dark), m_editor.bg_colour);
#endif
AddProperty(lexer, wxSTC_TERMINAL_BASH, "Bash diagnostic line", clColours::Red(is_dark), m_editor.bg_colour);

AddProperty(lexer, wxSTC_ERR_ES_BLACK, "ANSI escape black", clColours::Black(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_ES_RED, "ANSI escape red", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_ES_GREEN, "ANSI escape green", clColours::Green(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_ES_BROWN, "ANSI escape brown", clColours::Yellow(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_ES_BLUE, "ANSI escape blue", clColours::Blue(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_ES_MAGENTA, "ANSI escape magenta", clColours::Magenta(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_ES_CYAN, "ANSI escape cyan", clColours::Cyan(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_ES_GRAY, "ANSI escape grey", clColours::Grey(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_ES_YELLOW, "ANSI escape yellow", clColours::Yellow(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_ES_DARK_GRAY, "ANSI escape dark grey", clColours::Grey(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_ES_BRIGHT_RED, "ANSI escape bright red", clColours::Red(is_dark, true),
AddProperty(lexer, wxSTC_TERMINAL_ES_BLACK, "ANSI escape black", clColours::Black(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_ES_RED, "ANSI escape red", clColours::Red(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_ES_GREEN, "ANSI escape green", clColours::Green(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_ES_BROWN, "ANSI escape brown", clColours::Yellow(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_ES_BLUE, "ANSI escape blue", clColours::Blue(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_ES_MAGENTA, "ANSI escape magenta", clColours::Magenta(is_dark),
m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_ES_CYAN, "ANSI escape cyan", clColours::Cyan(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_ES_GRAY, "ANSI escape grey", clColours::Grey(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_ES_YELLOW, "ANSI escape yellow", clColours::Yellow(is_dark), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_ES_DARK_GRAY, "ANSI escape dark grey", clColours::Grey(is_dark),
m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_ES_BRIGHT_GREEN, "ANSI escape bright green", clColours::Green(is_dark, true),
AddProperty(lexer, wxSTC_TERMINAL_ES_BRIGHT_RED, "ANSI escape bright red", clColours::Red(is_dark, true),
m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_ES_BRIGHT_BLUE, "ANSI escape bright blue", clColours::Blue(is_dark, true),
AddProperty(lexer, wxSTC_TERMINAL_ES_BRIGHT_GREEN, "ANSI escape bright green", clColours::Green(is_dark, true),
m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_ES_BRIGHT_MAGENTA, "ANSI escape bright magenta", clColours::Magenta(is_dark, true),
AddProperty(lexer, wxSTC_TERMINAL_ES_BRIGHT_BLUE, "ANSI escape bright blue", clColours::Blue(is_dark, true),
m_editor.bg_colour);
AddProperty(lexer, wxSTC_ERR_ES_BRIGHT_CYAN, "ANSI escape bright cyan", clColours::Cyan(is_dark, true),
AddProperty(lexer, wxSTC_TERMINAL_ES_BRIGHT_MAGENTA, "ANSI escape bright magenta",
clColours::Magenta(is_dark, true), m_editor.bg_colour);
AddProperty(lexer, wxSTC_TERMINAL_ES_BRIGHT_CYAN, "ANSI escape bright cyan", clColours::Cyan(is_dark, true),
m_editor.bg_colour);
FinalizeImport(lexer);
return lexer;
Expand Down
25 changes: 19 additions & 6 deletions Plugin/lexer_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
//////////////////////////////////////////////////////////////////////////////
#include "lexer_configuration.h"

#include "ExtraLexers.h"
#include "FontUtils.hpp"
#include "clSystemSettings.h"
#include "cl_config.h"
Expand Down Expand Up @@ -92,7 +93,19 @@ wxColour to_wx_colour(const wxString& colour_as_string) { return wxColour(colour

void LexerConf::Apply(wxStyledTextCtrl* ctrl, bool applyKeywords)
{
ctrl->SetLexer(GetLexerId());
// Apply the lexer
switch (GetLexerId()) {
case wxSTC_LEX_TERMINAL: {
// Allocate custom lexer
auto plexer = CreateExtraLexerTerminal();
ctrl->SetILexer(plexer);
} break;
default:
// Standard lexers
ctrl->SetLexer(GetLexerId());
break;
}

ctrl->StyleClearAll();
ctrl->FoldDisplayTextSetStyle(wxSTC_FOLDDISPLAYTEXT_BOXED);
ctrl->SetIdleStyling(wxSTC_IDLESTYLING_TOVISIBLE);
Expand Down Expand Up @@ -133,13 +146,13 @@ void LexerConf::Apply(wxStyledTextCtrl* ctrl, bool applyKeywords)
ctrl->SetProperty("lexer.css.scss.language", "1");
}

if (GetLexerId() == wxSTC_LEX_ERRORLIST) {
ctrl->SetProperty("lexer.errorlist.escape.sequences", "1");
ctrl->SetProperty("lexer.errorlist.value.separate", "1");
if (GetLexerId() == wxSTC_LEX_TERMINAL) {
ctrl->SetProperty("lexer.terminal.escape.sequences", "1");
ctrl->SetProperty("lexer.terminal.value.separate", "1");

// Hide escape sequence styles
ctrl->StyleSetVisible(wxSTC_ERR_ESCSEQ, false);
ctrl->StyleSetVisible(wxSTC_ERR_ESCSEQ_UNKNOWN, false);
ctrl->StyleSetVisible(wxSTC_TERMINAL_ESCSEQ, false);
ctrl->StyleSetVisible(wxSTC_TERMINAL_ESCSEQ_UNKNOWN, false);
}

// Find the default style
Expand Down
4 changes: 2 additions & 2 deletions Plugin/wxTerminalCtrl/wxTerminalOutputCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void wxTerminalOutputCtrl::Initialise(const wxFont& font, const wxColour& bg_col
m_ctrl->SetEditable(false);
m_ctrl->SetWordChars(R"#(\:~abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$/.-)#");
m_ctrl->IndicatorSetStyle(INDICATOR_HYPERLINK, wxSTC_INDIC_PLAIN);
auto lexer = ColoursAndFontsManager::Get().GetLexer("errorlist");
auto lexer = ColoursAndFontsManager::Get().GetLexer("terminal");
if (lexer) {
lexer->Apply(m_ctrl);
m_ctrl->IndicatorSetForeground(INDICATOR_HYPERLINK, clColours::Blue(lexer->IsDark()));
Expand Down Expand Up @@ -225,7 +225,7 @@ void wxTerminalOutputCtrl::OnThemeChanged(clCommandEvent& event)

void wxTerminalOutputCtrl::ApplyTheme()
{
auto lexer = ColoursAndFontsManager::Get().GetLexer("errorlist");
auto lexer = ColoursAndFontsManager::Get().GetLexer("terminal");
if (lexer) {
lexer->Apply(m_ctrl);
}
Expand Down
Loading

0 comments on commit c4790a1

Please sign in to comment.