Skip to content

Commit

Permalink
addons/imguicodeeditor/imguicodeeditor.h/.cpp: Fixed LANG_GLSL that w…
Browse files Browse the repository at this point in the history
…as incorrectly registered as LANG_CPP.

examples/addons_examples/main.cpp: Added a language Combo.
  • Loading branch information
Flix01 committed Dec 3, 2016
1 parent 880c717 commit 876249f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 19 deletions.
6 changes: 3 additions & 3 deletions addons/imguicodeeditor/imguicodeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,11 +1160,11 @@ class FoldSegmentVector : public ImVectorEx<FoldSegment> {
};



static ImVectorEx<FoldingStringVector> gFoldingStringVectors;
static int gFoldingStringVectorIndices[LANG_COUNT] = {-1,-1,-1,-1,-1}; // global variable (values are indices from LANG_ENUM into gFoldingStringVectors)
static int gFoldingStringVectorIndices[LANG_COUNT] = {-1,-1,-1,-1,-1,-1}; // global variable (values are indices from LANG_ENUM into gFoldingStringVectors)
static ImString gTotalLanguageExtensionFilter = ""; // SOMETHING LIKE ".cpp;.h;.cs;.py"
static void InitFoldingStringVectors() {
for (int i=0;i<(int)LANG_COUNT;i++) gFoldingStringVectorIndices[i] = -1; // This is mandatory, because when I add an enum, the compiler somehow does not trigger any error in the declaration of gFoldingStringVectorIndices...
if (gFoldingStringVectors.size()==0) {
//gFoldingStringVectors.reserve(LANG_COUNT);
// CPP
Expand Down Expand Up @@ -1508,7 +1508,7 @@ static void InitFoldingStringVectors() {

// Assignment:
gFoldingStringVectors.push_back(foldingStrings);
gFoldingStringVectorIndices[LANG_CPP] = gFoldingStringVectors.size()-1;
gFoldingStringVectorIndices[LANG_GLSL] = gFoldingStringVectors.size()-1;
}
// LUA
{
Expand Down
5 changes: 5 additions & 0 deletions addons/imguicodeeditor/imguicodeeditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ enum Language {
LANG_PYTHON,
LANG_COUNT
};
inline static const char** GetLanguageNames() {
static const char* gLanguageNames[LANG_COUNT] = {"LANG_NONE","LANG_CPP","LANG_CS","LANG_GLSL","LANG_LUA","LANG_PYTHON"};
return &gLanguageNames[0];
}
inline static int GetNumLanguages() {return (int) LANG_COUNT;}

enum FoldingType {
FOLDING_TYPE_PARENTHESIS = 0,
Expand Down
Binary file modified examples/addons_examples/html/main.data
Binary file not shown.
Binary file modified examples/addons_examples/html/main.html.mem
Binary file not shown.
30 changes: 15 additions & 15 deletions examples/addons_examples/html/main.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion examples/addons_examples/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,10 +1044,14 @@ void DrawGL() // Mandatory
# ifndef NO_IMGUITABWINDOW
ImGui::Spacing();
ImGui::Text("ImGui::InputTextWithSyntaxHighlighting(...) [Experimental] (CTRL+MW: zoom):");
ImGui::PushItemWidth(ImGui::GetWindowWidth()*0.35f);
static int languageIndex = (int) ImGuiCe::LANG_CPP;
ImGui::Combo("Language##BCE_LanguageCombo",&languageIndex,ImGuiCe::GetLanguageNames(),(int)ImGuiCe::LANG_COUNT);
ImGui::PopItemWidth();
static const char* myCode="# include <sadd.h>\n\nusing namespace std;\n\n//This is a comment\nclass MyClass\n{\npublic:\nMyClass() {}\nvoid Init(int num)\n{ // for loop\nfor (int t=0;t<20;t++)\n {\n mNum=t; /* setting var */\n const float myFloat = 1.25f;\n break;\n }\n}\n\nprivate:\nint mNum;\n};\n\nstatic const char* SomeStrings[] = {\"One\"/*Comment One*//*Comment*/,\"Two /*Fake Comment*/\",\"Three\\\"Four\"};\n\nwhile (i<25 && i>=0) {\n\ti--;\nbreak;} /*comment*/{/*This should not fold*/}/*comment2*/for (int i=0;i<20;i++) {\n\t\t\tcontinue;//OK\n} // end second folding\n\nfor (int j=0;j<200;j++) {\ncontinue;}\n\n//region Custom Region Here\n{\n//something inside here\n}\n//endregion\n\n/*\nMultiline\nComment\nHere\n*/\n\n/*\nSome Unicode Characters here:\n€€€€\n*/\n\n";
static char bceBuffer[1024]="";
if (bceBuffer[0]=='\0') strcpy(bceBuffer,myCode); //Bad init (use initGL() to fill the buffer
ImGui::InputTextWithSyntaxHighlighting("ITWSH_JustForID",bceBuffer,sizeof(bceBuffer),ImGuiCe::LANG_CPP,ImVec2(0,300));
ImGui::InputTextWithSyntaxHighlighting("ITWSH_JustForID",bceBuffer,sizeof(bceBuffer),(ImGuiCe::Language)languageIndex,ImVec2(0,300));
# else //NO_IMGUICODEEDITOR
ImGui::Text("%s","Excluded from this build.\n");
# endif //NO_IMGUICODEEDITOR
Expand Down

0 comments on commit 876249f

Please sign in to comment.