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