Make TextEditor compatible with Core Notes, drop Core Notes

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2022-01-24 20:45:02 +00:00
parent d37fc6dda9
commit 362cf9b2b9
No known key found for this signature in database
GPG key ID: CDBAA37ABC74FBA0
7 changed files with 47 additions and 16 deletions

View file

@ -145,11 +145,10 @@ void ImGuiTextEditor::drawImGui()
const TextEditor::Coordinates cpos = editor.GetCursorPosition(); 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, cpos.mLine + 1, cpos.mColumn + 1,
editor.GetTotalLines(), editor.GetTotalLines(),
editor.IsOverwrite() ? "Ovr" : "Ins", editor.IsOverwrite() ? "Ovr" : "Ins",
editor.CanUndo() ? "*" : " ",
editor.GetLanguageDefinition().mName.c_str(), editor.GetLanguageDefinition().mName.c_str(),
pData->file.c_str()); pData->file.c_str());
@ -158,3 +157,26 @@ void ImGuiTextEditor::drawImGui()
ImGui::End(); 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;
}
}
}
*/

View file

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

View file

@ -50,13 +50,29 @@ struct TextEditorModule : Module {
json_t* rootJ = json_object(); json_t* rootJ = json_object();
json_object_set_new(rootJ, "filepath", json_string(file.c_str())); 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, "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)); json_object_set_new(rootJ, "width", json_integer(width));
return rootJ; return rootJ;
} }
void dataFromJson(json_t* const rootJ) override 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")) if (json_t* const widthJ = json_object_get(rootJ, "width"))
width = json_integer_value(widthJ); 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); text = json_string_value(textJ);
#ifndef HEADLESS #ifndef HEADLESS

View file

@ -71,16 +71,6 @@
"Blank" "Blank"
], ],
"hidden": true "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
} }
] ]
} }

View file

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

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/Audio.cpp
IGNORED_FILES += Rack/src/core/CV_MIDI.cpp IGNORED_FILES += Rack/src/core/CV_MIDI.cpp
IGNORED_FILES += Rack/src/core/MIDI_CV.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/engine/Engine.cpp
IGNORED_FILES += Rack/src/plugin/Model.cpp IGNORED_FILES += Rack/src/plugin/Model.cpp
IGNORED_FILES += Rack/src/window/Window.cpp IGNORED_FILES += Rack/src/window/Window.cpp

View file

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