Browse Source

Make TextEditor compatible with Core Notes, drop Core Notes

Signed-off-by: falkTX <falktx@falktx.com>
tags/22.02
falkTX 3 years ago
parent
commit
362cf9b2b9
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
7 changed files with 47 additions and 16 deletions
  1. +24
    -2
      plugins/Cardinal/src/ImGuiTextEditor.cpp
  2. +3
    -0
      plugins/Cardinal/src/ImGuiTextEditor.hpp
  3. +18
    -2
      plugins/Cardinal/src/TextEditor.cpp
  4. +0
    -10
      plugins/Core.json
  5. +0
    -2
      plugins/plugins.cpp
  6. +1
    -0
      src/Makefile
  7. +1
    -0
      src/override/plugin.cpp

+ 24
- 2
plugins/Cardinal/src/ImGuiTextEditor.cpp View File

@@ -145,11 +145,10 @@ void ImGuiTextEditor::drawImGui()

const TextEditor::Coordinates cpos = editor.GetCursorPosition();

ImGui::Text("%6d/%-6d %6d lines | %s | %s | %s | %s",
ImGui::Text("%6d/%-6d %6d lines | %s | %s | %s",
cpos.mLine + 1, cpos.mColumn + 1,
editor.GetTotalLines(),
editor.IsOverwrite() ? "Ovr" : "Ins",
editor.CanUndo() ? "*" : " ",
editor.GetLanguageDefinition().mName.c_str(),
pData->file.c_str());

@@ -158,3 +157,26 @@ void ImGuiTextEditor::drawImGui()

ImGui::End();
}

/*
void ImGuiTextEditor::onSelectKey(const SelectKeyEvent& e)
{
ImGuiWidget::onSelectKey(e);

if (e.action == GLFW_PRESS && (e.mods & GLFW_MOD_CONTROL) != 0)
{
switch (e.key)
{
case GLFW_KEY_X:
pData->editor.Cut();
break;
case GLFW_KEY_C:
pData->editor.Copy();
break;
case GLFW_KEY_V:
pData->editor.Paste();
break;
}
}
}
*/

+ 3
- 0
plugins/Cardinal/src/ImGuiTextEditor.hpp View File

@@ -59,4 +59,7 @@ struct ImGuiTextEditor : ImGuiWidget
protected:
/** @internal */
void drawImGui() override;
/*
void onSelectKey(const SelectKeyEvent& e) override;
*/
};

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

@@ -50,13 +50,29 @@ struct TextEditorModule : Module {
json_t* rootJ = json_object();
json_object_set_new(rootJ, "filepath", json_string(file.c_str()));
json_object_set_new(rootJ, "lang", json_string(lang.c_str()));
json_object_set_new(rootJ, "text", json_string(text.c_str()));
json_object_set_new(rootJ, "etext", json_string(text.c_str()));
json_object_set_new(rootJ, "width", json_integer(width));
return rootJ;
}

void dataFromJson(json_t* const rootJ) override
{
// Rack Core Notes compatiblity
if (json_t* const textJ = json_object_get(rootJ, "text"))
{
text = json_string_value(textJ);
file = "";
lang = "None";
width = 16;
#ifndef HEADLESS
if (ImGuiTextEditor* const widget = widgetPtr)
{
widget->setLanguageDefinition(lang);
widget->setText(text);
}
#endif
}

if (json_t* const widthJ = json_object_get(rootJ, "width"))
width = json_integer_value(widthJ);

@@ -90,7 +106,7 @@ struct TextEditorModule : Module {
}
}

if (json_t* const textJ = json_object_get(rootJ, "text"))
if (json_t* const textJ = json_object_get(rootJ, "etext"))
{
text = json_string_value(textJ);
#ifndef HEADLESS


+ 0
- 10
plugins/Core.json View File

@@ -71,16 +71,6 @@
"Blank"
],
"hidden": true
},
{
"slug": "Notes",
"name": "Notes",
"description": "Write text for patch notes or artist attribution",
"manualUrl": "https://vcvrack.com/manual/Core#Notes",
"tags": [
"Blank"
],
"hidden": true
}
]
}

+ 0
- 2
plugins/plugins.cpp View File

@@ -607,7 +607,6 @@ extern Model* modelMIDIMap;
extern Model* modelCV_MIDICC;
extern Model* modelGate_MIDI;
extern Model* modelBlank;
extern Model* modelNotes;
}

// regular plugins
@@ -705,7 +704,6 @@ static void initStatic__Core()
p->addModel(rack::core::modelCV_MIDICC);
p->addModel(rack::core::modelGate_MIDI);
p->addModel(rack::core::modelBlank);
p->addModel(rack::core::modelNotes);
}
}



+ 1
- 0
src/Makefile View File

@@ -130,6 +130,7 @@ IGNORED_FILES += Rack/src/app/TipWindow.cpp
IGNORED_FILES += Rack/src/core/Audio.cpp
IGNORED_FILES += Rack/src/core/CV_MIDI.cpp
IGNORED_FILES += Rack/src/core/MIDI_CV.cpp
IGNORED_FILES += Rack/src/core/Notes.cpp
IGNORED_FILES += Rack/src/engine/Engine.cpp
IGNORED_FILES += Rack/src/plugin/Model.cpp
IGNORED_FILES += Rack/src/window/Window.cpp


+ 1
- 0
src/override/plugin.cpp View File

@@ -89,6 +89,7 @@ static const std::map<PluginModuleSlug, PluginModuleSlug> moduleSlugFallbacks =
{{"Core", "AudioInterface16"}, {"Cardinal", "HostAudio8"}},
{{"Core", "MIDIToCVInterface"}, {"Cardinal", "HostMIDI"}},
{{"Core", "CV-MIDI"}, {"Cardinal", "HostMIDI"}},
{{"Core", "Notes"}, {"Cardinal", "TextEditor"}},
{{"MindMeld-ShapeMasterPro", "ShapeMasterPro"}, {"MindMeldModular", "ShapeMaster"}},
{{"MindMeldModular", "ShapeMaster"}, {"MindMeld-ShapeMasterPro", "ShapeMasterPro"}},
// {{"", ""}, {"", ""}},


Loading…
Cancel
Save