Browse Source

TextEditor: Improve none color, fix data/state load

Signed-off-by: falkTX <falktx@falktx.com>
tags/22.02
falkTX 4 years ago
parent
commit
d37fc6dda9
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 10 additions and 5 deletions
  1. +1
    -1
      plugins/Cardinal/src/DearImGuiColorTextEditor/TextEditor.cpp
  2. +2
    -1
      plugins/Cardinal/src/DearImGuiColorTextEditor/TextEditor.h
  3. +4
    -1
      plugins/Cardinal/src/ImGuiTextEditor.cpp
  4. +3
    -2
      plugins/Cardinal/src/TextEditor.cpp

+ 1
- 1
plugins/Cardinal/src/DearImGuiColorTextEditor/TextEditor.cpp View File

@@ -2010,7 +2010,7 @@ void TextEditor::Redo(int aSteps)
const TextEditor::Palette & TextEditor::GetDarkPalette() const TextEditor::Palette & TextEditor::GetDarkPalette()
{ {
const static Palette p = { { const static Palette p = { {
0xff7f7f7f, // Default
0xffe0e0e0, // Default
0xffd69c56, // Keyword 0xffd69c56, // Keyword
0xff00ff00, // Number 0xff00ff00, // Number
0xff7070e0, // String 0xff7070e0, // String


+ 2
- 1
plugins/Cardinal/src/DearImGuiColorTextEditor/TextEditor.h View File

@@ -173,7 +173,8 @@ public:
bool mCaseSensitive; bool mCaseSensitive;
LanguageDefinition() LanguageDefinition()
: mPreprocChar('#')
: mName("None")
, mPreprocChar('#')
, mAutoIndentation(true) , mAutoIndentation(true)
, mColorize(nullptr) , mColorize(nullptr)
, mColorizeData(nullptr) , mColorizeData(nullptr)


+ 4
- 1
plugins/Cardinal/src/ImGuiTextEditor.cpp View File

@@ -1,6 +1,6 @@
/* /*
* Syntax highlighting text editor (for ImGui in DPF) * Syntax highlighting text editor (for ImGui in DPF)
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
* Copyright (c) 2017 BalazsJako * Copyright (c) 2017 BalazsJako
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -75,6 +75,8 @@ std::string ImGuiTextEditor::getFile() const


void ImGuiTextEditor::setLanguageDefinition(const std::string& lang) void ImGuiTextEditor::setLanguageDefinition(const std::string& lang)
{ {
pData->editor.SetColorizerEnable(true);

if (lang == "AngelScript") if (lang == "AngelScript")
return pData->editor.SetLanguageDefinition(TextEditor::LanguageDefinition::AngelScript()); return pData->editor.SetLanguageDefinition(TextEditor::LanguageDefinition::AngelScript());
if (lang == "C") if (lang == "C")
@@ -90,6 +92,7 @@ void ImGuiTextEditor::setLanguageDefinition(const std::string& lang)
if (lang == "SQL") if (lang == "SQL")
return pData->editor.SetLanguageDefinition(TextEditor::LanguageDefinition::SQL()); return pData->editor.SetLanguageDefinition(TextEditor::LanguageDefinition::SQL());


pData->editor.SetColorizerEnable(false);
pData->editor.SetLanguageDefinition(TextEditor::LanguageDefinition()); pData->editor.SetLanguageDefinition(TextEditor::LanguageDefinition());
} }




+ 3
- 2
plugins/Cardinal/src/TextEditor.cpp View File

@@ -1,6 +1,6 @@
/* /*
* DISTRHO Cardinal Plugin * DISTRHO Cardinal Plugin
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@@ -134,7 +134,7 @@ struct TextEditorLangSelectItem : MenuItem {
rightText = CHECKMARK_STRING; rightText = CHECKMARK_STRING;
} }


void onAction(const event::Action &e) override
void onAction(const event::Action&) override
{ {
module->lang = text; module->lang = text;
widget->setLanguageDefinition(text); widget->setLanguageDefinition(text);
@@ -311,6 +311,7 @@ struct TextEditorModuleWidget : ModuleWidget {
textEditorWidget->box.pos = Vec(RACK_GRID_WIDTH, 0); textEditorWidget->box.pos = Vec(RACK_GRID_WIDTH, 0);
textEditorWidget->box.size = Vec((module->width - 2) * RACK_GRID_WIDTH, box.size.y); textEditorWidget->box.size = Vec((module->width - 2) * RACK_GRID_WIDTH, box.size.y);
addChild(textEditorWidget); addChild(textEditorWidget);
module->widgetPtr = textEditorWidget;
} }
else else
{ {


Loading…
Cancel
Save