9 extern int __ecereVMethodID_class_OnFree;
10 extern int __ecereVMethodID_class_OnGetString;
11 extern int __ecereVMethodID_class_OnGetDataFromString;
16 // #define _DEBUG_LINE
19 #define FULL_STRING_SEARCH
21 #define UTF8_IS_FIRST(x) (__extension__({ byte b = x; (!(b) || !((b) & 0x80) || ((b) & 0x40)); }))
22 #define UTF8_NUM_BYTES(x) (__extension__({ byte b = x; (b & 0x80 && b & 0x40) ? ((b & 0x20) ? ((b & 0x10) ? 4 : 3) : 2) : 1; }))
24 define newEntryStringDebug = $"New|id=";
25 define newEntryString = $"New";
27 public char ToASCII(unichar ch)
32 if(ch == 'À' || ch == 'Á' || ch == 'Â' || ch == 'Ã' || ch == 'Ä' || ch == 'Å')
36 else if(ch == 'È' || ch == 'É' || ch == 'Ê' || ch == 'Ë')
38 else if(ch == 'Ì' || ch == 'Í' || ch == 'Î' || ch == 'Ï')
42 else if(ch == 'Ò' || ch == 'Ó' || ch == 'Ô' || ch == 'Õ' || ch == 'Ö')
44 else if(ch == 'Ù' || ch == 'Ú' || ch == 'Û' || ch == 'Ü')
46 else if(ch == 'à' || ch == 'á' || ch == 'â' || ch == 'ã' || ch == 'ä' || ch == 'å')
50 else if(ch == 'è' || ch == 'é' || ch == 'ê' || ch == 'ë')
52 else if(ch == 'ì' || ch == 'í' || ch == 'î' || ch == 'ï')
56 else if(ch == 'ò' || ch == 'ó' || ch == 'ô' || ch == 'õ' || ch == 'ö')
58 else if(ch == 'ù' || ch == 'ú' || ch == 'û' || ch == 'ü')
66 public char * ConvertToASCII(char * string, char * newString, int * len, bool lowerCase)
73 for(c = 0; (unich = UTF8GetChar(string + c, &nb)); c += nb)
75 char ch = ToASCII(unich);
76 if(ch < 128 && ch > 32) //(ch == '-' || isalpha(ch) || ch == ','))
77 newString[d++] = lowerCase ? (char)tolower(ch) : (char)ch;
85 public class NoCaseAccent : SQLCustomFunction
87 Array<char> array { minAllocSize = 1024 };
89 String function(String text)
91 int len = text ? strlen(text) : 0;
93 ConvertToASCII(text ? text : "", array.array, &len, true);
98 public class MemberStringSample
103 default extern int __ecereVMethodID_class_OnUnserialize;
105 public class GetMemberString<class NT:void * = MemberStringSample, name = NT::name> : NoCaseAccent
108 String function(NT pn)
110 return NoCaseAccent::function((pn && pn.name) ? pn.name : null);
114 // The old way is still possible...
115 SerialBuffer buffer { };
116 String function(void * ptr)
121 buffer.count = MAXINT;
123 class(NT)._vTbl[__ecereVMethodID_class_OnUnserialize](class(NT), &pn, buffer);
124 result = NoCaseAccent::function((pn && pn.name) ? pn.name : null);
126 buffer.buffer = null;
128 // TOFIX: If we name GetName's type 'T', the following name confuses with Array's 'T'
129 //ConvertToASCII(s ? s : "", array.array, &len, true);
135 // Rename TableEditor to TableControl and move to eda/src/gui/controls
136 public class TableEditor : public Window
144 DebugLn("TableEditor::table|set");
154 DebugLn("TableEditor::index|set");
156 filterRow.tbl = index;
163 DebugLn("TableEditor::OnPostCreate");
171 InitFieldsBoxes(); // IMPORTANT: table must be set *AFTER* all related FieldEditors have been initialized
173 Field fldId = idField, fldName = stringField, fldActive = null;
174 FieldIndex indexedFields[1];
175 if(!idField) fldId = table.FindField(defaultIdField);
176 if(!fldName) fldName = table.FindField(defaultNameField);
177 if(!fldActive) fldActive = table.FindField(defaultActiveField);
178 indexedFields[0] = { fldId };
179 table.Index(1, indexedFields);
187 if(!listEnumerationTimer.hasCompleted)
189 if(list && !list.currentRow)
190 list.SelectRow(list.firstRow); // should the tableeditor select method be used here?
195 bool OnClose(bool parentClosing)
197 bool result = NotifyClosing();
206 property ListBox list
210 DebugLn("TableEditor::list|set");
217 Field indexFilterField;
220 property Array<ListField> listFields
224 DebugLn("TableEditor::listFields|set");
229 Array<ListField> listFields;
231 DataField listSortField;
232 bool disabledFullListing;
234 property Array<StringSearchField> searchFields
238 StringSearchTable searchTable { table, idField, value };
239 DebugLn("TableEditor::searchFields|set");
240 // The searchTables property will incref...
241 property::searchTables = { [ searchTable ] };
245 property Array<StringSearchTable> searchTables
249 // This API is not very clear on ownership of search tables array/search table/field...
250 // Right now both the array and tables themselves are incref'ed here
252 for(t : value) { incref t; }
253 DebugLn("TableEditor::searchTables|set");
254 if(searchTables) searchTables.Free();
256 searchTables = value;
259 Array<StringSearchTable> searchTables;
261 property Array<SQLiteSearchTable> sqliteSearchTables
266 for(t : value) { incref t; }
267 DebugLn("TableEditor::searchTables|set");
268 if(sqliteSearchTables) sqliteSearchTables.Free();
269 delete sqliteSearchTables;
270 sqliteSearchTables = value;
273 Array<SQLiteSearchTable> sqliteSearchTables;
275 property String searchString
279 bool modified = modifiedDocument;
280 DebugLn("TableEditor::searchString|set");
281 switch(modified ? OnLeavingModifiedDocument() : no)
291 if(value && value[0])
292 searchString = CopyString(value);
300 Map<Table, Lookup> lookups;
302 Array<LookupEditor> dynamicLookupEditors;
303 property Array<LookupEditor> dynamicLookupEditors
307 DebugLn("TableEditor::dynamicLookupEditors|set");
308 dynamicLookupEditors = value;
313 property Id selectedId { get { return selectedId; } }
315 Array<FieldBox> fieldsBoxes { };
316 Array<TableEditor> tableEditors { };
317 Array<TableEditor> dynamicLookupTableEditors { };
321 public virtual void OnInitialize();
322 public virtual void OnLoad();
323 public virtual void OnStateChanged();
324 bool internalModifications;
325 public void NotifyModifiedDocument()
327 DebugLn("TableEditor::NotifyModifiedDocument");
328 if(!internalModifications)
332 //public virtual bool Window::NotifyNew(AltListSection listSection, Row r);
333 //virtual void Window::NotifyInitFields(AltEditSection editSection);
335 public virtual DialogResult OnLeavingModifiedDocument()
337 DebugLn("TableEditor::OnLeavingModifiedDocument");
338 return MessageBox { master = this, type = yesNoCancel, text = text && text[0] ? text : $"Table Editor",
339 contents = $"You have modified this entry. Would you like to save it before proceeding?"
343 public virtual bool OnRemovalRequest()
345 DebugLn("TableEditor::OnRemovalRequest");
346 return MessageBox { master = this, type = yesNo, text = text && text[0] ? text : $"Table Editor",
347 contents = $"You are about to permanently remove an entry.\n"
348 "Do you wish to continue?"
352 //public virtual void Window::NotifyDeleting(ListSection listSection);
353 //public virtual void Window::NotifyDeleted(ListSection listSection);
355 public bool NotifyClosing()
358 DebugLn("TableEditor::NotifyClosing");
361 switch(OnLeavingModifiedDocument())
375 StopWordListPrepTimer();
376 StopListEnumerationTimer();
381 //public void List() // this gets called out of nowhere by some constructor thing...
382 public void Enumerate()
384 DebugLn("TableEditor::Enumerate");
387 StopListEnumerationTimer();
391 if(list || OnList != TableEditor::OnList)
394 Array<Id> matches = null;
395 listEnumerationTimer.sqliteSearch = false;
396 if(searchTables && searchTables.count)
397 matches = SearchWordList();
398 //else if(sqliteSearchTables && sqliteSearchTables.count)
399 //matches = SearchSQLite();
400 else if(searchString && searchString[0] &&
401 sqliteSearchTables && sqliteSearchTables.count &&
402 sqliteSearchTables[0].table && sqliteSearchTables[0].idField &&
403 sqliteSearchTables[0].searchFields && sqliteSearchTables[0].searchFields.count &&
404 sqliteSearchTables[0].searchFields[0].field)
405 listEnumerationTimer.sqliteSearch = true;
406 if(matches && matches.count)
407 PrintLn("results count: ", matches.count);
412 modifiedDocument = false; // setting this here is not really logical, enumeration and modified have nothing to do with eachother
415 virtual void OnList(Row r, Array<Id> matches)
417 DebugLn("TableEditor::OnList");
418 if(!listEnumerationTimer.started)
420 listEnumerationTimer.hasCompleted = false;
421 listEnumerationTimer.matchesIndex = 0;
422 listEnumerationTimer.tablesIndex = 0;
423 if(!listEnumerationTimer.sqliteSearch)
424 listEnumerationTimer.row = Row { r.tbl };
427 listEnumerationTimer.matches = { };
428 // TOFIX: This (void *) cast here should NOT be required... Fix this Container warning:
429 // warning: incompatible expression matches (ecere::com::Array<eda::Id>); expected ecere::com::Container<T>
430 listEnumerationTimer.matches.Copy((void *)matches);
433 listEnumerationTimer.matches = null;
434 listEnumerationTimer.Start();
437 DebugLn("TableEditor::OnList -- timer state error");
440 virtual void OnCreateDynamicLookupEditors()
442 DebugLn("TableEditor::OnCreateLookupEditors");
443 if(dynamicLookupEditors && dynamicLookupEditors.count)
445 for(f : dynamicLookupEditors)
447 if(f.editorClass && f.parentWindow && f.lookupFindField)
449 Row row { f.lookupFindIndex ? f.lookupFindIndex : f.lookupFindField.table };
450 // todo: make this work for all types
452 editRow.GetData(f.lookupValueField, id);
453 // TODO: add alternative class instance for creation when no rows are found via lookup
454 for(row.Find(f.lookupFindField, middle, nil, id); !row.nil; row.Next())
456 // todo: make this work for all types, although this is meant to be an id field
458 TableEditor editor = eInstance_New(f.editorClass);
460 editor.parent = f.parentWindow;
461 editor.master = this;
462 dynamicLookupTableEditors.Add(editor);
464 row.GetData(f.lookupIdField, id);
473 TableEditor masterEditor;
475 public property TableEditor masterEditor
479 if(value != masterEditor)
482 masterEditor.RemoveTableEditor(this);
483 masterEditor = value;
485 value.AddTableEditor(this);
492 if(eClass_IsDerived(parent._class, class(TableEditor)))
493 property::masterEditor = (TableEditor)parent;
498 if(eClass_IsDerived(master._class, class(TableEditor)))
499 property::masterEditor = (TableEditor)master;
504 DebugLn("TableEditor::CreateRow");
505 //list.NotifySelect(this, list, null, 0);
506 if(!modifiedDocument)
508 uint id; // = table.rowsCount + 1; // this is bad with deleted rows, won't work, how to have unique id?
509 // I think the 3 following comment lines apply to the old sqlite driver before many fix we done for wsms
510 Row r = editRow;// { table }; // the multipurpose row is buggy with sqlite driver, you can't use the same row to do Row::Last(), Row::Next(), Row::Find(), etc...
511 //Row r { editRow.tbl }; // for example, Row::Last() here is not using the proper sqlite statement and fails to
512 // return false when no rows are present in a table
516 /*uint count = editRow.tbl.GetRowsCount();
519 // r.Last() is returning true even if there are not rows in this table (SQLite)
520 if(count && !(r.Last() || r.Last()))
521 DebugLn("PROBLEM");*/
522 if(r.Last()) // this will reuse ids in cases where the item(s) with the last id have been deleted
524 r.GetData(idField, id);
535 // Patch for SQLite driver which auto-increments IDs
537 if(r.GetData(idField, curId))
540 r.SetData(idField, id);
543 r.SetData(fldActive, active);*/
546 newText = PrintString("[", newEntryStringDebug, id, "]");
548 newText = PrintString("[", newEntryString, "]");
551 //if(NotifyNew(master, this, r))
552 if(listFields && idField)
556 if(lf.dataField && lf.field)
558 if(lf.field.type == class(String))
559 r.SetData(lf.field, newText);
560 else // this whole block is new?
562 if(lf.field.type._vTbl[__ecereVMethodID_class_OnGetDataFromString])
564 Class dataType = lf.field.type;
565 int64 dataHolder = 0;
566 void * data = &dataHolder;
568 if(dataType && dataType.type == structClass)
570 dataHolder = (int64)new0 byte[dataType.structSize];
571 data = (void *)dataHolder;
573 /*else if(dataType && (dataType.type == noHeadClass || dataType.type == normalClass))
575 if(eClass_IsDerived(dataType, class(char*)))
576 dataHolder = (int64)CopyString("");
578 dataHolder = (int64)eInstance_New(dataType);
579 data = (void *)&dataHolder;
587 dataType._vTbl[__ecereVMethodID_class_OnGetDataFromString](dataType, data, newText);
590 /*dataType._vTbl[__ecereVMethodID_class_OnFree](dataType, dataHolder);
591 if(dataType.type == structClass)
593 void * dataPtr = (void *)dataHolder;
605 // have a better technique than Row::Next(); Row::Find(...); to make sure Row::GetData() will work right after a Row::SetData()?
606 // it seems we're missing Row::Update()
611 // next line is a patch for SQLite not returning data from GetData right after a SetData
612 if(idField && r.Find(idField, middle, nil, id))
613 SetListRowFields(r, row, false);
616 else if(idField && stringField)
618 r.SetData(stringField, newText);
621 row = list.AddString(newText);
631 list.Sort(listSortField, listSortOrder);
632 if(row) SelectListRow(row);
640 DebugLn("TableEditor::Remove");
641 if(editRow.sysID) //list && list.currentRow)
643 if(OnRemovalRequest())
647 list.DeleteRow(list.currentRow);
649 //NotifyDeleted(master, this);
651 SelectListRow(list.currentRow);
659 DebugLn("TableEditor::Load");
665 DebugLn("TableEditor::Write");
669 bool ListSelect(DataRow row)
672 DebugLn("TableEditor::ListSelect");
673 if(/*-row && -*/row != lastRow)
679 list.currentRow = lastRow;
681 switch(OnLeavingModifiedDocument())
689 list.currentRow = row;
693 if(list.currentRow == row)
702 DebugLn("TableEditor::Select");
703 // EDA is now set up so that Next()/Prev() will work with sysID = , but not with Find() (As Find() will return a particular set of results)
704 if(idField && (editRow.sysID = id, !editRow.nil))// && editRow.Find(idField, middle, nil, id))
706 //Id test = editRow.sysID;
707 selectedId = editRow.sysID;
719 DebugLn("TableEditor::Filter");
720 if(selectedId && index && indexFilterField)
722 for(filterRow.Find(indexFilterField, middle, nil, id); !filterRow.nil; filterRow.Next())
725 filterRow.GetData(idField, id2);
726 if(id2 == selectedId)
742 bool wasNil = !editRow.sysID;
743 DebugLn("TableEditor::SelectNext");
744 // How about confirmation / saving before changing the entry?
749 if(wasNil && filterRow.sysID == selectedId)
751 editRow.sysID = filterRow.sysID;
760 //Id test = editRow.sysID;
761 selectedId = editRow.sysID;
768 // Wrap around after 2 Next if commented out (1st time could inform user of reaching the end)
769 // The first Next() bring the row to a null row (rowID = 0), a Next() on a rowID = 0 starts at first row
770 //editRow.Previous();
775 bool SelectPrevious()
778 bool wasNil = !editRow.sysID;
779 DebugLn("TableEditor::SelectPrevious");
782 if(filterRow.Previous())
784 if(wasNil && filterRow.sysID == selectedId)
785 filterRow.Previous();
786 editRow.sysID = filterRow.sysID;
795 //Id test = editRow.sysID;
796 selectedId = editRow.sysID;
803 // Wrap around after 2 Prev if commented out (1st time could inform user of reaching the end)
804 // The first Prev() bring the row to a null row (rowID = 0), a Prev() on a rowID = 0 starts at last row
810 void SelectListRow(DataRow row)
812 // Time startTime = GetTime();
813 DebugLn("TableEditor::SelectListRow");
816 selectedId = row.tag;
819 if(list.currentRow != row)
820 list.currentRow = row;
821 if(idField && editRow.Find(idField, middle, nil, selectedId))
823 //Id test = editRow.sysID;
825 //NotifySelectListRow(master, this, selectedId);
829 // Logf("SelectListRow took %f seconds\n", GetTime() - startTime);
839 Array<char> searchCI { };
841 ListEnumerationTimer listEnumerationTimer
843 userData = this, delay = 0.1f;
846 static Time startTime;
849 Row row = listEnumerationTimer.row;
850 Array<Id> matches = listEnumerationTimer.matches;
851 Time delay = listEnumerationTimer.delay;
852 Time lastTime = GetTime();
853 static int slice = 128;
855 static int wordListPrepRowCount = 0, wordListPrepRowNum = 0, ticks = 0;
858 PrintLn("listing... ");
862 int index = listEnumerationTimer.matchesIndex;
863 if(listFields && idField)
865 for(c=0; c<slice && (next = index++<matches.count); c++)
867 if(row.Find(idField, middle, nil, matches[index]))
870 DataRow dataRow = list.AddRow();
871 row.GetData(idField, id);
873 SetListRowFields(row, dataRow, true);
876 DebugLn($"WordList match cannot be found in database.");
878 listEnumerationTimer.matchesIndex = index;
879 if(next) slice = Max(32, (int)(slice * (delay / (GetTime() - lastTime))));
881 else if(idField && stringField)
883 for(c=0; c<slice && (next = index++<matches.count); c++)
885 if(row.Find(idField, middle, nil, matches[index]))
889 row.GetData(idField, id);
890 row.GetData(stringField, s);
891 list.AddString(s).tag = id;
895 DebugLn($"WordList match cannot be found in database.");
897 listEnumerationTimer.matchesIndex = index;
898 if(next) slice = Max(32, (int)(slice * (delay / (GetTime() - lastTime))));
901 else if(listEnumerationTimer.sqliteSearch)
903 static SQLiteSearchTable st = null;
904 Row lookupRow { table };
905 Map<Id, int> uniques = listEnumerationTimer.uniques;
908 if(listEnumerationTimer.tablesIndex < sqliteSearchTables.count)
910 char queryString[4096*4];
912 if(!listEnumerationTimer.uniques)
913 listEnumerationTimer.uniques = uniques = { };
915 st = sqliteSearchTables[listEnumerationTimer.tablesIndex];
916 if(st.table && st.idField && st.searchFields && st.searchFields.count)
918 wordListPrepRowNum = 0;
919 wordListPrepRowCount = st.table.rowsCount;
921 if(st.table && st.idField && st.searchFields && st.searchFields.count &&
922 st.searchFields[0].field)
927 listEnumerationTimer.row = row = { st.table };
930 int len = searchString ? strlen(searchString) : 0;
931 searchCI.size = len + 1;
932 ConvertToASCII(searchString ? searchString : "", searchCI.array, &len, true);
933 searchCI.count = len + 1;
936 sprintf(queryString, "SELECT ROWID, * FROM `%s`", st.table.name);
937 strcat(queryString, " WHERE ");
938 for(sf : st.searchFields)
943 strcat(queryString, " OR ");
944 #define PERSON_SEARCH_LIKE
945 // This code tries to implement the logic of PersonName::OnGetDataFromString because PersonName is inaccessible from here
946 if(strstr(sf.field.type.name, "PersonName"))
948 #ifdef PERSON_SEARCH_LIKE
949 String ln = null, fn = null, mn = null;
950 char * comma = strchr(searchCI.array, ',');
953 int len = comma - searchCI.array;
954 ln = new char[len + 1];
955 memcpy(ln, searchCI.array, len);
958 fn = CopyString(comma+1);
961 for(c = strlen(fn)-2; c > 0; c--)
965 mn = CopyString(fn + c + 1);
972 ln = CopyString(searchCI.array);
974 /* We could simply do this if we had access to PersonName: (don't forget the delete pn; below)
976 pn.OnGetDataFromString(searchCI.array);
980 // Only last name is pecified in search object, it is looked for in all fields
981 strcatf(queryString, "(PNLastName(`%s`) LIKE '%%%s%%' OR PNFirstName(`%s`) LIKE '%%%s%%' OR PNMiddleName(`%s`) LIKE '%%%s%%')",
982 sf.field.name, searchCI.array, sf.field.name, searchCI.array, sf.field.name, ln);
984 else if(ln || fn || mn)
986 // Otherwise search is in respective fields only (all specified must match)
988 strcatf(queryString, "(");
991 if(!first) strcatf(queryString, " AND ");
993 strcatf(queryString, "PNLastName(`%s`) LIKE '%%%s%%'", sf.field.name, ln);
997 if(!first) strcatf(queryString, " AND ");
999 strcatf(queryString, "PNFirstName(`%s`) LIKE '%%%s%%'", sf.field.name, fn);
1003 if(!first) strcatf(queryString, " AND ");
1005 strcatf(queryString, "PNMiddleName(`%s`) LIKE '%%%s%%'", sf.field.name, mn);
1007 strcatf(queryString, ")");
1010 delete ln; delete fn; delete mn;
1012 // To use CompPersonName::OnCompare:
1013 strcatf(queryString, "`%s` = ?", sf.field.name);
1017 strcatf(queryString, "`%s` LIKE '%%%s%%'", sf.field.name, searchString);
1021 PrintLn(queryString);
1022 startTime = GetTime();
1023 row.query = queryString;
1024 #ifndef PERSON_SEARCH_LIKE
1025 // To use CompPersonName::OnCompare:
1026 for(sf : st.searchFields)
1030 if(strstr(sf.field.type.name, "PersonName"))
1033 sf.field.type._vTbl[__ecereVMethodID_class_OnGetDataFromString](sf.field.type, &pn, searchCI.array);
1034 row.SetQueryParamObject(++bindId, pn, sf.field.type);
1050 if(listFields && idField)
1052 // should we not start with a Next() ??? :S -- right now, query = does not need a Next(), unless it had parameters (SetQueryParam), See #591
1053 // when going through all the rows in a table you always start with Next() no?
1054 // is this different for query results?
1055 for(c = 0, next = !row.nil; c<slice && next; c++, next = row.Next())
1058 row.GetData(st.idField, id);
1059 //if(uniques[id]++ == 0)
1060 if(uniques[id] == 0)
1062 DataRow dataRow = list.AddRow();
1064 if(st.table == table)
1065 SetListRowFields(row, dataRow, true);
1066 else if(lookupRow.Find(idField, middle, nil, id))
1067 SetListRowFields(lookupRow, dataRow, true);
1071 uniques[id] = uniques[id] + 1;
1073 if(next) slice = Max(32, (int)(slice * (delay / (GetTime() - lastTime))));
1076 delete listEnumerationTimer.row; row = null;
1077 next = ++listEnumerationTimer.tablesIndex < sqliteSearchTables.count;
1080 else if(idField && stringField)
1082 // should we not start with a Next() ??? :S
1083 // when going through all the rows in a table you always start with Next() no?
1084 // is this different for query results?
1085 for(c = 0, next = !row.nil; c<slice && next; c++, next = row.Next())
1088 row.GetData(st.idField, id);
1089 //if(uniques[id]++ == 0)
1090 if(uniques[id] == 0)
1093 if(st.table == table)
1094 row.GetData(stringField, s);
1095 else if(lookupRow.Find(idField, middle, nil, id))
1096 lookupRow.GetData(stringField, s);
1099 list.AddString(s).tag = id;
1102 uniques[id] = uniques[id] + 1;
1104 if(next) slice = Max(32, (int)(slice * (delay / (GetTime() - lastTime))));
1107 delete listEnumerationTimer.row; row = null;
1108 next = ++listEnumerationTimer.tablesIndex < sqliteSearchTables.count;
1114 else if(!disabledFullListing)
1116 if(listFields && idField)
1118 for(c = 0; c<slice && (next = row.Next()); c++)
1121 DataRow dataRow = list.AddRow();
1122 row.GetData(idField, id);
1124 SetListRowFields(row, dataRow, true);
1125 //app.UpdateDisplay();
1127 if(next) slice = Max(32, (int)(slice * (delay / (GetTime() - lastTime))));
1129 else if(idField && stringField)
1131 for(c = 0; c<slice && (next = row.Next()); c++)
1135 row.GetData(idField, id);
1136 row.GetData(stringField, s);
1137 list.AddString(s).tag = id;
1140 if(next) slice = Max(32, (int)(slice * (delay / (GetTime() - lastTime))));
1144 list.Sort(listSortField, listSortOrder);
1148 listEnumerationTimer.hasCompleted = true;
1149 StopListEnumerationTimer();
1151 if(startTime) PrintLn("*** Search took ", (uint)((GetTime() - startTime) * 1000), "ms ***");
1156 void StopListEnumerationTimer()
1158 listEnumerationTimer.Stop();
1159 listEnumerationTimer.matchesIndex = 0;
1160 listEnumerationTimer.tablesIndex = 0;
1161 delete listEnumerationTimer.row;
1162 delete listEnumerationTimer.matches;
1163 delete listEnumerationTimer.uniques;
1166 WordListPrepTimer wordListPrepTimer
1168 userData = this, delay = 0.1f;
1172 Row row = wordListPrepTimer.row;
1173 static int slice = 512;
1174 static StringSearchTable st = null;
1176 static int wordListPrepRowCount = 0, wordListPrepRowNum = 0, ticks = 0;
1180 if(wordListPrepTimer.tablesIndex < searchTables.count)
1182 st = searchTables[wordListPrepTimer.tablesIndex];
1183 if(st.table && st.idField && st.searchFields && st.searchFields.count)
1185 wordListPrepRowNum = 0;
1186 wordListPrepRowCount = st.table.rowsCount;
1188 wordListPrepTimer.row = row = { st.table };
1189 DebugLn("building word list for ", st.table.name, " table ------------------------------------- ");
1196 Time delay = wordListPrepTimer.delay;
1197 Time lastTime = GetTime();
1201 PrintLn("indexing ", wordListPrepRowNum, " of ", wordListPrepRowCount, " --- slice is ", slice);
1203 for(c = 0; c<slice && (next = row.Next()); c++)
1206 row.GetData(st.idField, id);
1208 wordListPrepRowNum++;
1210 for(sf : st.searchFields)
1212 Field field = sf.field;
1213 StringSearchIndexingMethod method = sf.method;
1214 if(field && field.type == class(String))
1216 String string = null;
1217 row.GetData(field, string);
1219 if(string && string[0])
1220 ProcessWordListString(string, method, id);
1223 // todo: need to improve on this...
1224 // else ... call OnGetString of type ... etc...
1225 //PrintLn("todo: support other field types for string search");
1226 else if(field && field.type)
1228 char * n = field.name;
1229 char tempString[MAX_F_STRING];
1231 Class type = field.type;
1232 if(type.type == unitClass && !type.typeSize)
1234 Class dataType = eSystem_FindClass(type.module, type.dataTypeString);
1238 if(type.type == structClass)
1239 data = (int64)new0 byte[type.structSize];
1240 ((bool (*)())(void *)row.GetData)(row, field, type, (type.type == structClass) ? (void *)data : &data);
1242 if(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass)
1243 field.type._vTbl[__ecereVMethodID_class_OnGetString](field.type, &data, tempString, null, null);
1245 field.type._vTbl[__ecereVMethodID_class_OnGetString](field.type, (void *)data, tempString, null, null);
1248 ProcessWordListString(tempString, method, id);
1250 if(!(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass))
1251 type._vTbl[__ecereVMethodID_class_OnFree](type, data);
1252 if(type.type == structClass)
1257 if(next) slice = Max(32, (int)(slice * (delay / (GetTime() - lastTime))));
1260 delete wordListPrepTimer.row; row = null;
1261 next = ++wordListPrepTimer.tablesIndex < searchTables.count;
1267 char filePath[MAX_FILENAME];
1270 sprintf(filePath, "%s.search", table.name);
1271 // this doesn't want to work? :S :S :S
1273 f = FileOpenBuffered(filePath, read);
1280 wordListPrepTimer.hasCompleted = true;
1281 StopWordListPrepTimer();
1287 void StopWordListPrepTimer()
1289 wordListPrepTimer.Stop();
1290 wordListPrepTimer.tablesIndex = 0;
1291 delete wordListPrepTimer.row;
1296 DebugLn("TableEditor::~()");
1298 fieldsBoxes.Free(); // TOCHECK: do I need to delete each to oppose the incref in AddFieldBox? -- Free() does just that
1299 delete searchString;
1304 delete dynamicLookupEditors;
1305 delete dynamicLookupTableEditors;
1306 if(searchTables) searchTables.Free();
1307 delete searchTables;
1308 if(sqliteSearchTables) sqliteSearchTables.Free();
1309 delete sqliteSearchTables;
1312 void ResetListFields()
1314 DebugLn("TableEditor::ResetListFields");
1315 if(list && listFields && listFields.count)
1317 bool c = list.created;
1319 for(lf : listFields)
1321 list.AddField(lf.dataField);
1322 incref lf.dataField;
1327 void AddTableEditor(TableEditor tableEditor)
1329 DebugLn("TableEditor::AddTableEditor");
1330 if(!tableEditors.Find(tableEditor))
1332 tableEditors.Add(tableEditor);
1336 DebugLn(" TableEditor instance already added");
1339 void RemoveTableEditor(TableEditor tableEditor)
1341 Iterator<TableEditor> it { tableEditors };
1342 DebugLn("TableEditor::RemoveTableEditor");
1343 if(it.Find(tableEditor))
1345 it.Remove(); // tableEditors.Remove(it.pointer); // <-- any reason why we would want to do that instead? -- It's the same.
1346 delete tableEditor; // AddTableEditor increfs...
1349 DebugLn(" TableEditor instance not found, no need to remove");
1352 void AddFieldBox(FieldBox fieldBox)
1354 // I was putting this here to force autosize on the lists (e.g. the Radiologists fields):
1356 if(!fieldBox.autoSize)
1357 fieldBox.autoSize = true;
1359 DebugLn("TableEditor::AddFieldBox");
1360 if(!fieldsBoxes.Find(fieldBox))
1362 fieldsBoxes.Add(fieldBox);
1368 DebugLn(" FieldBox instance already added");
1371 void RemoveFieldBox(FieldBox fieldBox)
1373 Iterator<FieldBox> it { fieldsBoxes };
1374 DebugLn("TableEditor::RemoveFieldBox");
1375 if(it.Find(fieldBox))
1377 it.Remove(); // fieldsBoxes.Remove(it.pointer); // <-- any reason why we would want to do that instead? -- It's the same.
1380 DebugLn(" FieldBox instance not found, no need to remove");
1383 void InitFieldsBoxes()
1385 DebugLn("TableEditor::InitFieldsBoxes");
1388 for(fb : fieldsBoxes)
1396 for(fb : fieldsBoxes)
1399 //NotifyInitFields(master, this);
1404 DebugLn("TableEditor::EditNew");
1406 modifiedDocument = false;
1411 DebugLn("TableEditor::EditSave");
1412 internalModifications = true;
1413 for(fb : fieldsBoxes)
1416 if(idField && list && listFields && listFields.count)
1418 DataRow listRow = list.currentRow;
1419 // ADDED THIS HERE FOR SQLITE TO REFRESH
1420 editRow.Find(idField, middle, nil, listRow.tag);
1421 SetListRowFields(editRow, listRow, false);
1422 list.Sort(listSortField, listSortOrder);
1424 internalModifications = false;
1426 for(te : tableEditors)
1429 modifiedDocument = false;
1435 DebugLn("TableEditor::EditLoad");
1438 internalModifications = true;
1444 lu.row = { lu.findIndex ? lu.findIndex : lu.findField.table };
1445 if(lu.valueField && eClass_IsDerived(lu.valueField.type, class(Id)) &&
1446 lu.findField && eClass_IsDerived(lu.findField.type, class(Id)))
1449 editRow.GetData(lu.valueField, id);
1450 lu.row.Find(lu.findField, middle, nil, id);
1454 for(fb : fieldsBoxes)
1456 OnCreateDynamicLookupEditors();
1457 internalModifications = false;
1458 size = size; // This seems to be required to fix autoSize on entering order screen
1460 DebugLn(" TODO: implement virtual method TableEditor::OnSubEditorsLoad");
1462 modifiedDocument = false;
1468 DebugLn("TableEditor::EditClear");
1469 internalModifications = true;
1470 for(fb : fieldsBoxes)
1472 for(e : dynamicLookupTableEditors)
1474 for(e : tableEditors)
1476 tableEditors.Free();
1477 dynamicLookupTableEditors.Free();
1478 //dynamicLookupTableEditors.size = 0;
1479 internalModifications = false;
1481 DebugLn(" TODO: remove all sub table editors");
1483 modifiedDocument = false;
1487 void SetListRowFields(Row dbRow, DataRow listRow, bool restoreSelection)
1489 // DebugLn("TableEditor::SetListRowFields");
1490 for(lf : listFields)
1492 if(lf.dataField && lf.field)
1494 if(eClass_IsDerived(lf.field.type, class(char*)))
1497 dbRow.GetData(lf.field, s);
1498 listRow.SetData(lf.dataField, s);
1501 else if(eClass_IsDerived(lf.field.type, class(Id)))
1507 dbRow.GetData(lf.field, id);
1508 s = lf.CustomLookup(id);
1509 listRow.SetData(lf.dataField, s);
1512 else if(lf.lookupFindField && (lf.lookupFindIndex || lf.lookupFindField.table) && lf.lookupValueField &&
1513 eClass_IsDerived(lf.lookupFindField.type, class(Id)) &&
1514 eClass_IsDerived(lf.lookupValueField.type, class(char*)))
1518 Row lookupRow { lf.lookupFindIndex ? lf.lookupFindIndex : lf.lookupFindField.table };
1519 dbRow.GetData(lf.field, id);
1520 if(lookupRow.Find(lf.lookupFindField, middle, nil, id))
1521 lookupRow.GetData(lf.lookupValueField, s);
1522 listRow.SetData(lf.dataField, s);
1527 else if(lf.CustomLookup && lf.field.type)
1529 char * n = lf.field.name;
1532 Class type = lf.field.type;
1533 if(type.type == unitClass && !type.typeSize)
1535 Class dataType = eSystem_FindClass(type.module, type.dataTypeString);
1539 if(type.type == structClass)
1540 data = (int64)new0 byte[type.structSize];
1541 ((bool (*)())(void *)dbRow.GetData)(dbRow, lf.field, type, (type.type == structClass) ? (void *)data : &data);
1542 s = lf.CustomLookup((int)data);
1543 listRow.SetData(lf.dataField, s);
1544 if(!(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass))
1545 type._vTbl[__ecereVMethodID_class_OnFree](type, data);
1546 if(type.type == structClass)
1550 else if(lf.field.type && eClass_IsDerived(lf.dataField.dataType, class(char*)))
1552 char * n = lf.field.name;
1553 char tempString[MAX_F_STRING];
1555 Class type = lf.field.type;
1556 if(type.type == unitClass && !type.typeSize)
1558 Class dataType = eSystem_FindClass(type.module, type.dataTypeString);
1562 if(type.type == structClass)
1563 data = (int64)new0 byte[type.structSize];
1564 ((bool (*)())(void *)dbRow.GetData)(dbRow, lf.field, type, (type.type == structClass) ? (void *)data : &data);
1565 if(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass)
1566 lf.field.type._vTbl[__ecereVMethodID_class_OnGetString](lf.field.type, &data, tempString, null, null);
1568 lf.field.type._vTbl[__ecereVMethodID_class_OnGetString](lf.field.type, (void*)data, tempString, null, null);
1570 listRow.SetData(lf.dataField, tempString);
1572 if(!(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass))
1573 type._vTbl[__ecereVMethodID_class_OnFree](type, data);
1574 if(type.type == structClass)
1577 else if(lf.field.type)
1579 char * n = lf.field.name;
1580 //char tempString[256];
1582 Class type = lf.field.type;
1583 if(type.type == unitClass && !type.typeSize)
1585 Class dataType = eSystem_FindClass(type.module, type.dataTypeString);
1589 if(type.type == structClass)
1590 data = (int64)new0 byte[type.structSize];
1591 ((bool (*)())(void *)dbRow.GetData)(dbRow, lf.field, type, (type.type == structClass) ? (void *)data : &data);
1592 if(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass)
1593 listRow.SetData(lf.dataField, (void *)&data);
1595 listRow.SetData(lf.dataField, (void *)data);
1596 if(!(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass))
1597 type._vTbl[__ecereVMethodID_class_OnFree](type, data);
1598 if(type.type == structClass)
1603 if(restoreSelection && !list.currentRow)
1606 if((select = list.FindRow(selectedId)))
1607 SelectListRow(select);
1611 Array<Id> SearchWordList()
1613 DebugLn("TableEditor::SearchWordList");
1614 #ifdef FULL_STRING_SEARCH
1620 WordEntry entries[256];
1621 Array<Id> results = null;
1622 if(searchTables && searchTables.count && searchString && searchString[0])
1624 char * searchCopy = CopyString(searchString);
1625 numTokens = TokenizeWith(searchCopy, sizeof(words) / sizeof(char *), words, " ',/-;[]{}", false);
1626 for(c = 0; c<numTokens; c++)
1628 len[c] = strlen(words[c]);
1630 entries[c] = (WordEntry)wordTree.FindString(words[c]);
1640 Map<Id, int> matches { };
1641 Map<Id, int> uniques { };
1642 MapNode<Id, int> mn;
1644 for(c = 0; c<numTokens; c++)
1646 if(entries[c] && entries[c].items && entries[c].items.count)
1648 for(i = 0; i<entries[c].items.count; i++)
1650 int count = uniques[entries[c].items.ids[i]];
1655 matches[entries[c].items.ids[i]]++;
1660 for(mn = matches.root.minimum; mn; mn = mn.next)
1663 results.Add(mn.key);
1669 else if(numTokens == 1)
1672 if(entries[0] && entries[0].items && entries[0].items.count)
1674 for(c = 0; c<entries[0].items.count; c++)
1675 results.Add(entries[0].items.ids[c]);
1687 // find a way to not load a tree for different searchFields
1688 // if the code that sets the searchFields has changed
1689 // store a search index signature containing following:
1690 // tables name, idField name and type, fields name and type
1691 void PrepareWordList()
1693 DebugLn("TableEditor::PrepareWordList");
1694 #ifdef FULL_STRING_SEARCH
1696 char filePath[MAX_FILENAME];
1699 sprintf(filePath, "%s.search", table.name);
1700 f = filePath ? FileOpenBuffered(filePath, read) : null;
1707 for(a = 0; a<26; a++)
1711 word[0] = 'a' + (char)a;
1714 letters[a] = (WordEntry)wordTree.FindString(word);
1715 for(b = 0; b<26; b++)
1717 word[1] = 'a' + (char)b;
1718 doubleLetters[a][b] = (WordEntry)wordTree.FindString(word);
1722 else if(searchTables && searchTables.count)
1727 for(a = 0; a<26; a++)
1731 word[0] = 'a' + (char)a;
1734 wordTree.Add((BTNode)(letters[a] = WordEntry { string = CopyString(word) }));
1735 for(b = 0; b<26; b++)
1737 word[1] = 'a' + (char)b;
1738 wordTree.Add((BTNode)(doubleLetters[a][b] = WordEntry { string = CopyString(word) }));
1743 wordListPrepTimer.tablesIndex = 0;
1744 wordListPrepTimer.Start();
1750 void ProcessWordListString(char * string, StringSearchIndexingMethod method, Id id)
1759 char asciiWord[1024];
1761 for(c = 0; ; c += nb)
1763 ch = UTF8GetChar(string + c, &nb);
1765 if(!ch || CharMatchCategories(ch, separators) ||
1766 (count && CharMatchCategories(ch, letters|numbers|marks|connector) != CharMatchCategories(lastCh, letters|numbers|marks|connector)))
1771 asciiWord[numChars] = 0;
1775 AddWord(word, count, method == allSubstrings, id);
1776 if(count > numChars)
1777 AddWord(asciiWord, strlen(asciiWord), method == allSubstrings, id);
1781 if(!CharMatchCategories(ch, separators))
1784 for(cc = 0; cc < nb; cc++)
1785 word[count++] = string[c + cc];
1787 asciiWord[numChars++] = ToASCII(ch);
1795 for(cc = 0; cc < nb; cc++)
1796 word[count++] = string[c + cc];
1798 asciiWord[numChars++] = ToASCII(ch);
1804 /*static */WordEntryBinaryTree wordTree
1806 CompareKey = (void *)BinaryTree::CompareString;
1807 FreeKey = BinaryTree::FreeString;
1810 WordEntry letters[26];
1811 WordEntry doubleLetters[26][26];
1813 void AddWord(char * word, int count, bool addAllSubstrings, Id id)
1815 //DebugLn("TableEditor::AddWord");
1816 #ifdef FULL_STRING_SEARCH
1818 if(addAllSubstrings)
1821 WordEntry mainEntry = null;
1822 WordEntry sEntry = null;
1824 for(s = 0; s < count; s += UTF8_NUM_BYTES(word[s]))
1829 WordEntry lEntry = null;
1830 memcpy(subWord, word + s, count-s);
1831 subWord[count-s] = 0; // THIS IS REQUIRED!! THE WHILE LOOP BELOW CHECKED count-s FIRST!!
1834 for(l = count-s; l>0; l--)
1837 WordEntry start = null, wordEntry;
1839 while(l > 0 && !UTF8_IS_FIRST(subWord[l])) l--;
1844 if(ch1 >= 'a' && ch1 <= 'z')
1846 char ch2 = subWord[1];
1847 if(count - s > 1 && ch2 >= 'a' && ch2 <= 'z')
1849 char ch2 = subWord[1];
1850 start = doubleLetters[ch1 - 'a'][ch2 - 'a'];
1854 start = letters[ch1 - 'a'];
1861 while(start && (max = (WordEntry)((BTNode)start).maximum))
1863 if(strcmp(max.string, subWord) >= 0)
1865 start = start.parent;
1870 start = (WordEntry)wordTree.root;
1872 if((wordEntry = (WordEntry)((BTNode)start).FindString(subWord)))
1878 wordTree.Add((BTNode)(wordEntry = WordEntry { string = CopyString(subWord) }));
1882 mainEntry = wordEntry;
1890 if(!wordEntry.words) wordEntry.words = IdList { };
1891 wordEntry.words.Add((Id)mainEntry);
1896 if(!wordEntry.words) wordEntry.words = IdList { };
1897 wordEntry.words.Add((Id)sEntry);
1901 if(!wordEntry.words) wordEntry.words = IdList { };
1902 wordEntry.words.Add((Id)lEntry);
1904 if(!wordEntry.items) wordEntry.items = IdList { };
1905 wordEntry.items.Add(id);
1911 WordEntry wordEntry;
1912 if(!(wordEntry = (WordEntry)(wordTree.root).FindString(word)))
1913 wordTree.Add((BTNode)(wordEntry = WordEntry { string = CopyString(word) }));
1914 if(!wordEntry.items) wordEntry.items = IdList { };
1915 wordEntry.items.Add(id);
1922 public class ListField : struct
1926 DataField dataField;
1927 Field lookupFindField;
1928 Field lookupValueField;
1929 Table lookupFindIndex;
1930 String (*CustomLookup)(Id);
1955 public class LookupEditor : struct
1958 subclass(TableEditor) editorClass;
1959 Window parentWindow;
1960 Field lookupValueField;
1961 Field lookupFindField;
1962 Field lookupIdField;
1963 Table lookupFindIndex;
1966 // all methods currently perform ascii conversion and all that jazz on every string added to the index
1967 public enum StringSearchIndexingMethod { fullString, allSubstrings };
1969 public class StringSearchField
1973 StringSearchIndexingMethod method;
1975 Field lookupFindField;
1976 Field lookupValueField;
1978 //String (*CustomRead)(Id);
1981 public class StringSearchTable
1986 Array<StringSearchField> searchFields;
1989 ~StringSearchTable()
1991 delete searchFields;
1995 public class SQLiteSearchField
1999 //StringSearchIndexingMethod method;
2002 public class SQLiteSearchTable
2007 Array<SQLiteSearchField> searchFields;
2010 ~SQLiteSearchTable()
2012 delete searchFields;
2016 static WordEntry * btnodes;
2018 struct WordEntryBinaryTree : BinaryTree
2020 WordEntry * entries;
2022 void OnSerialize(IOChannel channel)
2026 uint count = this.count;
2027 DebugLn("WordEntryBinaryTree::OnSerialize");
2028 for(id = 1, node = (WordEntry)root; node;)
2035 else if(node.parent)
2037 bool isLeft = node == node.parent.left;
2042 if(isLeft && node.right)
2048 isLeft = node == node.parent.left;
2057 channel.Serialize(id);
2058 channel.Serialize((WordEntry)root);
2061 void OnUnserialize(IOChannel channel)
2063 WordEntry root, node;
2065 DebugLn("WordEntryBinaryTree::OnUnserialize");
2066 channel.Unserialize(count);
2067 entries = new WordEntry[count];
2069 channel.Unserialize(root);
2070 this.root = (BTNode)root;
2071 // count = root ? this.root.count : 0;
2073 for(node = (WordEntry)root; node;)
2078 for(c = 0; c<node.words.count; c++)
2079 node.words.ids[c] = (Id)btnodes[node.words.ids[c] - 1];
2085 else if(node.parent)
2087 bool isLeft = node == node.parent.left;
2092 if(isLeft && node.right)
2098 isLeft = node == node.parent.left;
2110 class WordEntry : struct
2114 WordEntry left, right;
2127 void OnSerialize(IOChannel channel)
2129 #ifdef FULL_STRING_SEARCH
2132 channel.Serialize(id);
2133 channel.Serialize(string);
2134 channel.Serialize(items);
2139 channel.Serialize(words.count);
2140 for(c = 0; c < words.count; c++)
2142 uint id = ((WordEntry)words.ids[c]).id;
2143 channel.Serialize(id);
2149 channel.Serialize(none);
2152 // channel.Serialize(words);
2153 channel.Serialize(left);
2154 channel.Serialize(right);
2159 channel.Serialize(nothing);
2164 void OnUnserialize(IOChannel channel)
2166 #ifdef FULL_STRING_SEARCH
2168 channel.Unserialize(id);
2173 // TODO: Fix typed_object issues
2174 entry = btnodes[id - 1] = eInstance_New(class(WordEntry));
2175 this = (void *)entry;
2177 channel.Unserialize(string);
2178 channel.Unserialize(items);
2179 channel.Unserialize(words);
2181 channel.Unserialize(left);
2182 if(left) { left.parent = (void *)this; }
2183 channel.Unserialize(right);
2184 if(right) { right.parent = (void *)this; }
2186 // TODO: Precomp errors without extra brackets
2187 depth = ((BTNode)((void *)this)).depthProp;
2196 class ListEnumerationTimer : Timer
2204 Map<Id, int> uniques;
2207 class WordListPrepTimer : Timer
2215 class EnumerateThread : Thread
2234 bool abort, abortNow;
2241 //if(app.ProcessInput(true))
2244 Row r { editor.table };
2248 if(editor.listFields && editor.idField)
2250 /*for(c=0; c<matches.count && !abort; c++)
2252 if(r.Find(editor.idField, middle, nil, matches[c]))
2257 row = editor.list.AddRow();
2258 r.GetData(editor.idField, id);
2260 editor.SetListRowFields(r, row, true);
2264 DebugLn($"WordList match cannot be found in database.");
2267 else if(editor.idField && editor.stringField)
2269 /*for(c=0; c<matches.count && !abort; c++)
2271 if(r.Find(editor.idField, middle, nil, matches[c]))
2275 r.GetData(editor.idField, id);
2276 r.GetData(editor.stringField, s);
2278 editor.list.AddString(s).tag = id;
2283 DebugLn($"WordList match cannot be found in database.");
2289 else if(!editor.disabledFullListing)
2291 if(editor.listFields && editor.idField)
2294 while(r.Next() && !abort)
2299 r.GetData(editor.idField, id);
2300 //if(app.ProcessInput(true))
2304 row = editor.list.AddRow();
2306 editor.SetListRowFields(r, row, true);
2311 else if(editor.idField && editor.stringField)
2313 /*while(r.Next() && !abort)
2318 r.GetData(editor.idField, id);
2319 r.GetData(editor.stringField, s);
2320 editor.list.AddString(s).tag = id;
2332 editor.list.Sort(editor.listSortField, editor.listSortOrder);
2351 editor.list.Update(null);
2352 //app.Wait(); // Sleep(0.2f);
2353 //if(app.ProcessInput(true))
2356 //app.UpdateDisplay();
2363 static define app = ((GuiApplication)__thisModule);
2365 static inline void DebugLn(typed_object object, ...)
2367 #if defined(_DEBUG_LINE)
2370 va_start(args, object);
2371 PrintStdArgsToBuffer(buffer, sizeof(buffer), object, args);