#include "TextEditorWrapper.h" #include "TextEditor.h" #include "WrapperConverter.h" IggTextEditorLanguageDefinition IggNewLanguageDef() { TextEditor::LanguageDefinition *ld = new TextEditor::LanguageDefinition(); return static_cast(ld); } void IggTextEditorLDSetName(IggTextEditorLanguageDefinition handle, const char *name) { TextEditor::LanguageDefinition *ld = reinterpret_cast(handle); ld->mName = name; } void IggTextEditorLDSetKeywords(IggTextEditorLanguageDefinition handle, const char **keywords, int length) { TextEditor::LanguageDefinition *ld = reinterpret_cast(handle); int i = 0; for (i = 0; i < length; i++) ld->mKeywords.insert(keywords[i]); } IggTextEditor IggNewTextEditor() { TextEditor *editor = new TextEditor(); return static_cast(editor); } void IggTextEditorRender(IggTextEditor handle, const char* aTitle, IggVec2 const *size, int aBorder) { Vec2Wrapper sizeArg(size); TextEditor *editor = reinterpret_cast(handle); editor->Render(aTitle, *sizeArg, aBorder != 0); } void IggTextEditorSetShowWhitespaces(IggTextEditor handle, int aValue) { TextEditor *editor = reinterpret_cast(handle); editor->SetShowWhitespaces(aValue != 0); } void IggTextEditorSetTabSize(IggTextEditor handle, int size) { TextEditor *editor = reinterpret_cast(handle); editor->SetTabSize(size); } void IggTextEditorSetText(IggTextEditor handle, const char* text) { TextEditor *editor = reinterpret_cast(handle); editor->SetText(text); } void IggTextEditorInsertText(IggTextEditor handle, const char *text) { TextEditor *editor = reinterpret_cast(handle); editor->InsertText(text); } IggBool IggTextEditorHasSelection(IggTextEditor handle) { TextEditor *editor = reinterpret_cast(handle); return editor->HasSelection() ? 1 : 0; } char const *IggTextEditorGetText(IggTextEditor handle) { TextEditor *editor = reinterpret_cast(handle); std::string str = editor->GetText(); char* c = strcpy(new char[str.length() + 1], str.c_str()); return c; } char const *IggTextEditorGetWordUnderCursor(IggTextEditor handle) { TextEditor *editor = reinterpret_cast(handle); std::string str = editor->GetWordUnderCursor(); char* c = strcpy(new char[str.length() + 1], str.c_str()); return c; } char const *IggTextEditorGetSelectedText(IggTextEditor handle) { TextEditor *editor = reinterpret_cast(handle); std::string str = editor->GetSelectedText(); char* c = strcpy(new char[str.length() + 1], str.c_str()); return c; } char const *IggTextEditorGetCurrentLineText(IggTextEditor handle) { TextEditor *editor = reinterpret_cast(handle); std::string str = editor->GetCurrentLineText(); char* c = strcpy(new char[str.length() + 1], str.c_str()); return c; } IggBool IggTextEditorIsTextChanged(IggTextEditor handle) { TextEditor *editor = reinterpret_cast(handle); return editor->IsTextChanged() ? 1 : 0; } void IggTextEditorGetScreenCursorPos(IggTextEditor handle, int *x, int* y) { TextEditor *editor = reinterpret_cast(handle); TextEditor::Coordinates col = editor->GetScreenCursorPosition(); *x = (float)col.mColumn; *y = (float)col.mLine; } void IggTextEditorGetCursorPos(IggTextEditor handle, int* column, int* line) { TextEditor *editor = reinterpret_cast(handle); TextEditor::Coordinates col = editor->GetCursorPosition(); *column = (float)col.mColumn; *line = (float)col.mLine; } void IggTextEditorSetCursorPos(IggTextEditor handle, int column, int line) { TextEditor *editor = reinterpret_cast(handle); TextEditor::Coordinates col(line, column); editor->SetCursorPosition(col); } void IggTextEditorGetSelectionStart(IggTextEditor handle, int* column, int* line) { TextEditor *editor = reinterpret_cast(handle); TextEditor::Coordinates col = editor->GetSelectionStart(); *column = (float)col.mColumn; *line = (float)col.mLine; } void IggTextEditorSetLanguageDefinition(IggTextEditor handle, IggTextEditorLanguageDefinition defHandle) { TextEditor *editor = reinterpret_cast(handle); TextEditor::LanguageDefinition *def = static_cast(defHandle); editor->SetLanguageDefinition(*def); } void IggTextEditorSetLanguageDefinitionSQL(IggTextEditor handle) { TextEditor *editor = reinterpret_cast(handle); editor->SetLanguageDefinition(TextEditor::LanguageDefinition::SQL()); } void IggTextEditorSetLanguageDefinitionCPP(IggTextEditor handle) { TextEditor *editor = reinterpret_cast(handle); editor->SetLanguageDefinition(TextEditor::LanguageDefinition::CPlusPlus()); } void IggTextEditorSetLanguageDefinitionC(IggTextEditor handle) { TextEditor *editor = reinterpret_cast(handle); editor->SetLanguageDefinition(TextEditor::LanguageDefinition::C()); } void IggTextEditorSetLanguageDefinitionLua(IggTextEditor handle) { TextEditor *editor = reinterpret_cast(handle); editor->SetLanguageDefinition(TextEditor::LanguageDefinition::Lua()); } IggTextEditorErrorMarkers IggTextEditorNewErrorMarkers() { TextEditor::ErrorMarkers *markers = new TextEditor::ErrorMarkers(); return static_cast(markers); } void IggTextEditorErrorMarkersInsert(IggTextEditorErrorMarkers handle, int pos, const char* errMsg) { TextEditor::ErrorMarkers *markers = reinterpret_cast(handle); markers->insert(std::pair(pos, errMsg)); } void IggTextEditorErrorMarkersClear(IggTextEditorErrorMarkers marker) { TextEditor::ErrorMarkers *markers = reinterpret_cast(marker); markers->clear(); } unsigned int IggTextEditorErrorMarkersSize(IggTextEditorErrorMarkers handle) { TextEditor::ErrorMarkers *markers = reinterpret_cast(handle); return markers->size(); } void IggTextEditorSetErrorMarkers(IggTextEditor handle, IggTextEditorErrorMarkers marker) { TextEditor *editor = reinterpret_cast(handle); TextEditor::ErrorMarkers *markers = reinterpret_cast(marker); editor->SetErrorMarkers(*markers); } void IggTextEditorCopy(IggTextEditor handle) { TextEditor *editor = reinterpret_cast(handle); editor->Copy(); } void IggTextEditorCut(IggTextEditor handle) { TextEditor *editor = reinterpret_cast(handle); editor->Cut(); } void IggTextEditorPaste(IggTextEditor handle) { TextEditor *editor = reinterpret_cast(handle); editor->Paste(); } void IggTextEditorDelete(IggTextEditor handle) { TextEditor *editor = reinterpret_cast(handle); editor->Delete(); } void IggTextEditorSelectWordUnderCursor(IggTextEditor handle) { TextEditor *editor = reinterpret_cast(handle); editor->SelectWordUnderCursor(); } void IggTextEditorSelectAll(IggTextEditor handle) { TextEditor *editor = reinterpret_cast(handle); editor->SelectAll(); } void IggTextEditorSetHandleKeyboardInputs(IggTextEditor handle, int aValue) { TextEditor *editor = reinterpret_cast(handle); editor->SetHandleKeyboardInputs(aValue); }