Skip to content

Commit

Permalink
Update ImGuiColorTextEdit (from santaclose fork)
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Jan 28, 2025
1 parent edcafb6 commit 1c6ea0c
Show file tree
Hide file tree
Showing 7 changed files with 244 additions and 706 deletions.
10 changes: 5 additions & 5 deletions bindings/imgui_bundle/demos_cpp/demo_text_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ TextEditor _PrepareTextEditor()
std::string this_file_code = fplus::read_text_file("/demos_cpp/demo_text_edit.cpp")();
#endif
editor.SetText(this_file_code);
editor.SetLanguageDefinition(TextEditor::LanguageDefinition::CPlusPlus());
editor.SetLanguageDefinition(TextEditor::LanguageDefinitionId::Cpp);
return editor;
}

Expand All @@ -31,16 +31,16 @@ void demo_text_edit()
auto ShowPaletteButtons = []()
{
if (ImGui::SmallButton("Dark palette"))
editor.SetPalette(TextEditor::GetDarkPalette());
editor.SetPalette(TextEditor::PaletteId::Dark);
ImGui::SameLine();
if (ImGui::SmallButton("Light palette"))
editor.SetPalette(TextEditor::GetLightPalette());
editor.SetPalette(TextEditor::PaletteId::Light);
ImGui::SameLine();
if (ImGui::SmallButton("Retro blue palette"))
editor.SetPalette(TextEditor::GetRetroBluePalette());
editor.SetPalette(TextEditor::PaletteId::RetroBlue);
ImGui::SameLine();
if (ImGui::SmallButton("Mariana palette"))
editor.SetPalette(TextEditor::GetMarianaPalette());
editor.SetPalette(TextEditor::PaletteId::Mariana);
};

ShowPaletteButtons();
Expand Down
17 changes: 9 additions & 8 deletions bindings/imgui_bundle/demos_python/demo_text_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ def _prepare_text_editor():
this_file_code = f.read()
editor = TextEditor()
editor.set_text(this_file_code)
editor.set_language_definition(TextEditor.LanguageDefinition.python())
editor.set_language_definition(TextEditor.LanguageDefinitionId.python)
return editor


@static(editor=_prepare_text_editor())
@static(editor=None)
def demo_gui():
static = demo_gui
editor = static.editor
if demo_gui.editor is None:
demo_gui.editor = _prepare_text_editor()
editor = demo_gui.editor

imgui_md.render(
"""
Expand All @@ -28,16 +29,16 @@ def demo_gui():

def show_palette_buttons():
if imgui.small_button("Dark palette"):
editor.set_palette(ed.TextEditor.get_dark_palette())
editor.set_palette(ed.TextEditor.PaletteId.dark)
imgui.same_line()
if imgui.small_button("Light palette"):
editor.set_palette(TextEditor.get_light_palette())
editor.set_palette(TextEditor.PaletteId.light)
imgui.same_line()
if imgui.small_button("Retro blue palette"):
editor.set_palette(TextEditor.get_retro_blue_palette())
editor.set_palette(TextEditor.PaletteId.retro_blue)
imgui.same_line()
if imgui.small_button("Mariana palette"):
editor.set_palette(TextEditor.get_mariana_palette())
editor.set_palette(TextEditor.PaletteId.mariana)

show_palette_buttons()
imgui.push_font(imgui_md.get_code_font())
Expand Down
Loading

0 comments on commit 1c6ea0c

Please sign in to comment.