*/}}

la_util.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. /*
  2. * LaGUI: A graphical application framework.
  3. * Copyright (C) 2022-2023 Wu Yiming
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #pragma once
  19. #define _CRT_SECURE_NO_WARNINGS
  20. #define _GNU_SOURCE
  21. #include <time.h>
  22. #include "GL/glew.h"
  23. #include "GL/gl.h"
  24. #include "ft2build.h"
  25. #include "freetype/freetype.h"
  26. #include "la_icon.h"
  27. #include <stddef.h>
  28. #include <stdint.h>
  29. #ifdef __linux__
  30. #include <fcntl.h>
  31. #include <unistd.h>
  32. #include <errno.h>
  33. #include <wchar.h>
  34. #define SYSWINDOW Window
  35. #define SYSGLCONTEXT GLXContext
  36. #define SYSTEMDC DC
  37. #define SYSTEMRC RC
  38. #define SYSTEMDISPLAY Display
  39. #endif
  40. #ifdef _WIN32
  41. #include <Windows.h>
  42. #define SYSWINDOW HWND
  43. #define SYSGLCONTEXT HGLRC
  44. #define SYSTEMDC HDC
  45. #define SYSTEMRC HRC
  46. #define SYSTEMDISPLAY int
  47. #define PATH_MAX 4096
  48. #endif
  49. #define NEED_STRUCTURE(a) \
  50. typedef struct _##a a;
  51. #define STRUCTURE(a) \
  52. typedef struct _##a a;\
  53. struct _##a
  54. #define lengthof(a) \
  55. (sizeof(a)/sizeof(a[0]))
  56. #define DBL_TRIANGLE_LIM 1e-11
  57. #define DBL_EDGE_LIM 1e-9
  58. #ifndef LAGUI_GIT_BRANCH
  59. #define LAGUI_GIT_BRANCH "Release 1"
  60. #endif
  61. // No need to show hash when not compiled from git repo.
  62. //#ifndef LAGUI_GIT_HASH
  63. //#define LAGUI_GIT_HASH "?"
  64. //#endif
  65. #define LA_HYPER_CREATED_TIME(hi) \
  66. hi->TimeCreated.Year,hi->TimeCreated.Month,hi->TimeCreated.Day,hi->TimeCreated.Hour,hi->TimeCreated.Minute,hi->TimeCreated.Second
  67. typedef double real;
  68. typedef unsigned long long u64bit;
  69. typedef unsigned int u32bit;
  70. typedef unsigned short u16bit;
  71. typedef unsigned short ushort;
  72. typedef unsigned char u8bit;
  73. typedef struct _laListSingle laListSingle;
  74. struct _laListSingle {
  75. void* pNext;
  76. };
  77. typedef struct _laListHandle laListHandle;
  78. struct _laListHandle {
  79. void* pFirst;
  80. void* pLast;
  81. };
  82. typedef struct _laListWithPivot laListWithPivot;
  83. struct _laListWithPivot {
  84. void* pFirst;
  85. void* pLast;
  86. void* Pivot;
  87. };
  88. typedef struct _laListItem laListItem;
  89. struct _laListItem {
  90. void* pPrev;
  91. void* pNext;
  92. };
  93. typedef struct _laListItem2 laListItem2;
  94. struct _laListItem2 {
  95. void* O1;
  96. void* O2;
  97. void* pPrev;
  98. void* pNext;
  99. };
  100. typedef struct _laListItem3 laListItem3;
  101. struct _laListItem3 {
  102. void* O1;
  103. void* O2;
  104. void* O3;
  105. void* O4;
  106. void* pPrev;
  107. void* pNext;
  108. };
  109. NEED_STRUCTURE(laSafeString);
  110. STRUCTURE(laAuthorInfo) {
  111. laListItem Item;
  112. laSafeString* Name;
  113. laSafeString* CopyrightString;
  114. };
  115. STRUCTURE(laTimeInfo) {
  116. u16bit Year;//Also Used As Timer [ms] counter
  117. u8bit Month;
  118. u8bit Day;
  119. u8bit Hour;
  120. u8bit Minute;
  121. u8bit Second;
  122. };
  123. NEED_STRUCTURE(laPropContainer);
  124. typedef struct _laUID laUID;
  125. struct _laUID {
  126. char String[32];//a simplified uuid, example: 0E3F9BA4802FDDC2-20160601123546 [\0]
  127. };
  128. typedef struct _laListItemPointer laListItemPointer;
  129. struct _laListItemPointer {
  130. void* pPrev;
  131. void* pNext;
  132. void* p;
  133. };
  134. typedef struct _laItemUserLinker laItemUserLinker;
  135. typedef void(*laUserRemoveFunc)(void* This, laItemUserLinker* iul);
  136. NEED_STRUCTURE(laProp);
  137. struct _laItemUserLinker {
  138. laListItemPointer Pointer;
  139. laUserRemoveFunc Remove;
  140. laProp* Which;
  141. void* Additional;
  142. unsigned int FrameDistinguish;
  143. int ForceRecalc;
  144. };
  145. typedef struct _laItemUserLinkerLocal laItemUserLinkerLocal;
  146. struct _laItemUserLinkerLocal {
  147. laItemUserLinker Link;
  148. void* Instance;
  149. };
  150. typedef struct _laElementListItem laElementListItem;
  151. struct _laElementListItem {
  152. laListItem Item;
  153. void* Ext;
  154. };
  155. typedef struct _laListNonRecursiveRoot laListNonRecursiveRoot;
  156. struct _laListNonRecursiveRoot {
  157. laListHandle NSItems;
  158. };
  159. typedef int(*laCompareFunc)(void*, void*);
  160. typedef void(*laListDoFunc)(void*);
  161. typedef void(*laListNonRecursiveDoFunc)(laListNonRecursiveRoot*, void*, void*);//item,custom
  162. typedef void(*laListNonRecursiveCopyFunc)(laListNonRecursiveRoot*, void*, void*, void*);//old,new,custom
  163. typedef void(*laListDoFuncArgp)(void*, void*);
  164. typedef void(*laCopyListFunc)(void*, void*);
  165. typedef void(*laListCustomDataRemover)(void*);
  166. //typedef void(*ListMatcherFunc)(void*,void*);//gotten value,enumed curent lst item.
  167. typedef struct _laListNonRecursiveItem laListNonRecursiveItem;
  168. struct _laListNonRecursiveItem {
  169. laListItem Item;
  170. laListHandle handle;
  171. laListHandle *ToHandle;//This Is Pointer!
  172. laListNonRecursiveDoFunc func;
  173. laListNonRecursiveCopyFunc CopyFunc;
  174. laListCustomDataRemover remover;
  175. void* CustomData;
  176. int bFreeList;
  177. int SizeEachNode;
  178. };
  179. typedef struct _laHash256 laHash256;
  180. struct _laHash256 {
  181. laListHandle Entries[256];
  182. };
  183. typedef struct _laHash65536 laHash65536;
  184. struct _laHash65536 {
  185. laListHandle Entries[65536];
  186. //laHash256 HashHandles[256];
  187. };
  188. typedef struct _laHash16M laHash16M;
  189. struct _laHash16M {
  190. laListHandle Entries[16777216];
  191. };
  192. typedef struct _laSafeString laSafeString;
  193. struct _laSafeString {
  194. laListItem Item;
  195. char * Ptr;
  196. };
  197. typedef struct _laSafeStringCollection laSafeStringCollection;
  198. struct _laSafeStringCollection {
  199. laListHandle SafeStrings;
  200. };
  201. typedef struct _laStringSplitor laStringSplitor;
  202. struct _laStringSplitor {
  203. int NumberParts;
  204. laListHandle parts;
  205. };
  206. typedef struct _laStringPart laStringPart;
  207. struct _laStringPart {
  208. laListItem Item;
  209. char * Content;
  210. int IntValue;
  211. real FloatValue;
  212. char Type;
  213. };
  214. STRUCTURE(laStringLine) {
  215. laListItem Item;
  216. wchar_t Buf[1024];//unicode
  217. };
  218. STRUCTURE(laStringEdit) {
  219. laListHandle Lines;
  220. int CursorLine, CursorBefore, CursorPreferBefore;
  221. int BeginLine, BeginBefore;
  222. int EndLine, EndBefore;
  223. int _BeginLine, _BeginBefore; // selection order
  224. int _EndLine, _EndBefore;
  225. int TotalLines;
  226. int ViewStartLine, ViewStartCol;
  227. int ViewHeight, ViewWidth;
  228. int MouseSelecting;
  229. };
  230. #define LA_SWAP(T,x,y) \
  231. { T SWAP = x; x = y; y = SWAP; }
  232. #define LA_MEMORY_POOL_1MB 1048576
  233. #define LA_MEMORY_POOL_128MB 134217728
  234. #define LA_MEMORY_POOL_256MB 268435456
  235. #define LA_MEMORY_POOL_512MB 536870912
  236. STRUCTURE(laMemoryPool) {
  237. laListItem Item;
  238. int NodeSize;
  239. int NextCount;
  240. int UsableCount;
  241. int Hyperlevel;
  242. laListHandle Pools;
  243. };
  244. STRUCTURE(laMemoryPoolPart) {
  245. laListItem Item;
  246. laListHandle FreeMemoryNodes;
  247. int UsedCount;
  248. laMemoryPool* PoolRoot;
  249. //<------Pool mem starts here
  250. };
  251. NEED_STRUCTURE(laDBInst);
  252. STRUCTURE(laMemNode0){
  253. laListItem Item;
  254. laMemoryPoolPart* InPool;//<---- Keep at the last
  255. //<------User mem starts here
  256. };
  257. STRUCTURE(laMemNode) {
  258. laListItem Item;
  259. laListHandle Users; //<---- Keep at the second
  260. void* ReadInstance;
  261. laMemoryPoolPart* InPool; //<---- Keep at the last
  262. //<------User mem starts here
  263. };
  264. NEED_STRUCTURE(laManagedUDF);
  265. STRUCTURE(laMemNodeHyper) {
  266. laListItem Item;
  267. laListHandle Users; //<---- Keep at the second
  268. laUID NUID;
  269. laTimeInfo TimeCreated;
  270. laManagedUDF* FromFile;
  271. int Modified;
  272. int UNUSEDUndoDirty;
  273. laMemoryPoolPart* InPool; //<---- Keep at the last
  274. //<------User mem starts here
  275. };
  276. STRUCTURE(laStaticMemoryPoolNode) {
  277. laListItem Item;
  278. int UsedByte;
  279. //<------User mem starts here
  280. };
  281. STRUCTURE(laStaticMemoryPool) {
  282. int EachSize;
  283. laListHandle Pools;
  284. //pthread_spinlock_t csMem;
  285. };
  286. STRUCTURE(laAVLNodeReal64) {
  287. laAVLNodeReal64* Parent;
  288. u64bit Index;
  289. real Value;
  290. //real SmallestValue;
  291. //real GreatestValue;
  292. laAVLNodeReal64* Smaller;
  293. laAVLNodeReal64* Greater;
  294. char Height;
  295. void* Pointer;
  296. };
  297. STRUCTURE(laAVLTreeReal64) {
  298. laAVLNodeReal64* Root;
  299. u64bit ItemCount;
  300. laMemoryPool MemoryPool;
  301. };
  302. STRUCTURE(laTimeRecorder) {
  303. struct timespec ts;
  304. };
  305. STRUCTURE(laTranslationNode) {
  306. laListItem Item;
  307. laSafeString* LanguageName;
  308. laHash256 Matches;
  309. };
  310. STRUCTURE(laTranslation) {
  311. int EnableTranslation;
  312. laListHandle Languages;
  313. laTranslationNode* CurrentLanguage;
  314. laHash256 MisMatches;
  315. };
  316. STRUCTURE(laTranslationMatch) {
  317. laListItem Item;
  318. char * Target;
  319. char * Replacement;
  320. };
  321. NEED_STRUCTURE(laBaseNode);
  322. typedef void (*laBaseNodeInitF)(laBaseNode*, int NoCreate);
  323. typedef void (*laBaseNodeDestroyF)(laBaseNode*);
  324. typedef int (*laBaseNodeVisitF)(laBaseNode*, laListHandle*);
  325. typedef int (*laBaseNodeEvalF)(laBaseNode*);
  326. STRUCTURE(laBaseNodeType){
  327. laBaseNodeInitF Init;
  328. laBaseNodeDestroyF Destroy;
  329. laBaseNodeVisitF Visit;
  330. laBaseNodeEvalF Eval;
  331. laPropContainer* pc;
  332. char* TypeName;
  333. char* Name;
  334. int Icon;
  335. int NodeSize;
  336. };
  337. NEED_STRUCTURE(laNodeRack);
  338. STRUCTURE(laBaseNode){
  339. laListItem Item;
  340. laSafeString* Name;
  341. laBaseNodeType* Type;
  342. laNodeRack* InRack;
  343. int Gap; int Eval; int InitDone;
  344. };
  345. #define CreateNew(Type) \
  346. calloc(sizeof(Type),1)
  347. #define CreateNew_Size(size) \
  348. calloc(size,1)
  349. #define CreateNewBuffer(Type,Num) \
  350. calloc(sizeof(Type),Num);
  351. #define FreeMem(ptr) \
  352. nutFreeMem((&ptr))
  353. #define elif \
  354. else if
  355. #define LA_UNAVAILABLE_NAME "- Unknown -"
  356. uint32_t laToUnicode(const unsigned char* ch, int* advance);
  357. int laToUTF8(const uint32_t ch, char* out, char** next);
  358. int strToUnicode(uint32_t* target, unsigned char* const src);
  359. int strToUTF8(unsigned char* target, uint32_t* const src);
  360. int strlenU(uint32_t* const str);
  361. int strcpyU(uint32_t* target, uint32_t* const source );
  362. int strcatU(uint32_t* target, uint32_t* const source );
  363. struct tm* laGetFullTime();
  364. void laRecordTime(laTimeRecorder* tr);
  365. real laTimeElapsedSecondsf(laTimeRecorder* End, laTimeRecorder* Begin);
  366. int laTimeElapsedMilliseconds(laTimeRecorder* End, laTimeRecorder* Begin);
  367. void laSetAuthorInfo(char * Name, char * CopyrightString);
  368. void memCreateNUID(char* buf,laMemNodeHyper* Hyper);
  369. NEED_STRUCTURE(laPropPack);
  370. int nutHyperUserCount(void* instance, laProp* p_optional, int *p_count);
  371. void memHyperInfo(laPropPack* pp, char* buf);
  372. void memMakeHyperData(laMemNodeHyper* hi);
  373. void nutFreeMem(void** ptr);
  374. int nutFloatCompare(real l, real r);
  375. int nutSameAddress(void* l, void* r);
  376. void* arrElement(void* head, int i, int size);
  377. int arrEnsureLength(void** head, int next, int* max, size_t ElementSize);
  378. int arrInitLength(void** head, int max, int* pmax, size_t ElementSize);
  379. void arrFree(void** head, int* max);
  380. void lstPushSingle(void** Head, laListSingle* Item);
  381. void* lstPopSingle(void** Head, laListSingle* Item);
  382. void lstClearPrevNext(laListItem* li);
  383. int lstCountElements(laListHandle* Handle);
  384. void lstAppendItem(laListHandle* Handle, void* Item);
  385. void lstPushItem(laListHandle* Handle, void* Item);
  386. void* lstPopItem(laListHandle* Handle) ;
  387. void lstAppendItem2(laListHandle* Handle, void* Item);
  388. void* lstPopItem2(laListHandle* Handle);
  389. void lstPushItem2(laListHandle* Handle, void* Item);
  390. void lstAppendItem3(laListHandle* Handle, void* Item);
  391. void* lstPopItem3(laListHandle* Handle);
  392. void lstPushItem3(laListHandle* Handle, void* Item);
  393. int lstRemoveItem(laListHandle* Handle, laListItem* li) ;
  394. int lstRemoveItem2(laListHandle* Handle, laListItem2* li);
  395. int lstRemoveSegment(laListHandle* Handle, laListItem* Begin, laListItem* End);
  396. void lstInsertItemBefore(laListHandle* Handle, laListItem* toIns, laListItem* pivot);
  397. void lstInsertItemAfter(laListHandle* Handle, laListItem* toIns, laListItem* pivot);
  398. void lstInsertSegmentBefore(laListHandle* Handle, laListItem* Begin, laListItem* End, laListItem* pivot);
  399. void lstInsertSegmentAfter(laListHandle* Handle, laListItem* Begin, laListItem* End, laListItem* pivot);
  400. int lstHaveItemInList(laListHandle* Handle);
  401. /**/ void* lstGetTop(laListHandle* Handle);
  402. void lstPushSimpleItem(void** first, laItemUserLinker* iul);
  403. void* lstPushItemUser(void** first, void* p);
  404. void* lstPushItemUsing(void** first, void* p);
  405. void* lstAppendPointerOnly(laListHandle* h, void* p);
  406. void* lstAppendPointerSizedOnly(laListHandle* h, void* p, int size);
  407. void* lstPushPointerOnly(laListHandle* h, void* p);
  408. void* lstPushPointerSizedOnly(laListHandle* h, void* p, int size);
  409. void lstReverse(laListHandle* h);
  410. int lstHasPointer(laListHandle* h, void *p);
  411. void* lstAppendPointer(laListHandle* h, void* p);
  412. void* lstAppendPointerSized(laListHandle* h, void* p, int size);
  413. void* lstPushPointer(laListHandle* h, void* p);
  414. void* lstPushPointerSized(laListHandle* h, void* p, int size);
  415. void* lstAppendPointerStatic(laListHandle* h, laStaticMemoryPool* smp, void* p);
  416. void* lstAppendPointerStaticSized(laListHandle* h, laStaticMemoryPool* smp, void* p, int size);
  417. void* lstPushPointerStatic(laListHandle* h, laStaticMemoryPool* smp, void* p);
  418. void* lstPushPointerStaticSized(laListHandle* h, laStaticMemoryPool* smp, void* p, int size);
  419. void* lstPopPointerOnly(laListHandle* h);
  420. void lstRemovePointerItemOnly(laListHandle* h, laListItemPointer* lip);
  421. void lstRemovePointerOnly(laListHandle* h, void* p);
  422. void lstClearPointerOnly(laListHandle* h);
  423. void lstGeneratePointerListOnly(laListHandle* from1, laListHandle* from2, laListHandle* to);
  424. void* lstPopPointer(laListHandle* h);
  425. void lstRemovePointerItem(laListHandle* h, laListItemPointer* lip);
  426. void lstRemovePointer(laListHandle* h, void* p);
  427. void lstRemovePointerLeave(laListHandle *h, void *p);
  428. void lstClearPointer(laListHandle* h);
  429. void lstGeneratePointerList(laListHandle* from1, laListHandle* from2, laListHandle* to);
  430. void lstCopyHandle(laListHandle* target, laListHandle* src);
  431. void* lstAppendPointerStaticPool(laStaticMemoryPool* mph, laListHandle* h, void* p);
  432. void* lstPopPointerLeave(laListHandle* h);
  433. void lstRemovePointerItemNoFree(laListHandle* h, laListItemPointer* lip);
  434. void lstMoveUp(laListHandle* h, laListItem* li);
  435. void lstMoveDown(laListHandle* h, laListItem* li);
  436. void lstForAllItemsDo(laListDoFunc func, laListHandle* hList);
  437. void lstForAllItemsDoLNRR(laListNonRecursiveDoFunc func, laListHandle* hList);
  438. void lstForAllItemsDo_DirectFree(laListDoFunc func, laListHandle* hList);
  439. void lstForAllItemsDo_arg_ptr(laListDoFuncArgp func, laListHandle* hList, void* arg);
  440. void lstForAllItemsDo_NonRecursive_Root(laListHandle* FirstHandle, laListNonRecursiveDoFunc func, int bFreeItem, void* custom_data, laListCustomDataRemover remover);
  441. void lstCopy_NonRecursive_Root(laListHandle* FromHandle, laListHandle* ToHandle, int SizeEachNode, laListNonRecursiveCopyFunc func, void* custom_data, laListCustomDataRemover remover);
  442. void lstAddNonRecursiveListHandle(laListNonRecursiveRoot* root, laListHandle* newHandle, laListNonRecursiveDoFunc nrFunc, int bFreeList, void* custom_data, laListCustomDataRemover remover);
  443. void lstAddNonRecursiveListCopier(laListNonRecursiveRoot* root, laListHandle* oldHandle, laListHandle* newHandle, int sizeEach, laListNonRecursiveCopyFunc nrCpyFunc, void* custom_data, laListCustomDataRemover remover);
  444. void* lstFindItem(void* CmpData, laCompareFunc func, laListHandle* hList);
  445. void lstCombineLists(laListHandle* dest, laListHandle* src);
  446. void lstDestroyList(laListHandle* hlst);
  447. void* lstReMatch(laListHandle* SearchHandle, laListHandle* CurrentHandle, void* ItemToFind);
  448. typedef int(*MatcherFunc)(void*, void*);
  449. void* lstReMatchEx(laListHandle* SearchHandle, laListHandle* CurrentHandle, void* ItemToFind, MatcherFunc func);
  450. void lstAddElement(laListHandle* hlst, void* ext);
  451. void lstDestroyElementList(laListHandle* hlst);
  452. void hsh256InsertItemCSTR(laHash256* hash, laListItem* li, char * buckle);
  453. void hsh256InsertItem(laHash256* hash, laListItem* li, char buckle);
  454. void hsh65536InsertItem(laHash65536* hash, laListItem* li, long buckle);
  455. void hsh65536Init(laHash65536** h);
  456. void hshFree(laHash65536** h);
  457. laListHandle* hsh65536DoHashLongPtr(laHash65536* hash, unsigned long long buckle);
  458. laListHandle* hsh65536DoHashNUID(laHash65536* hash, char * NUID);
  459. laListHandle* hsh16MDoHashLongPtr(laHash16M* hash, long long buckle);
  460. laListHandle* hsh16MDoHashNUID(laHash16M* hash, char * NUID);
  461. laListItem* hsh256FindItemSTR(laHash256* hash, laCompareFunc func, char * buckle);
  462. unsigned char hsh256DoHashSTR(char * buckle);
  463. void memResetByteCount();
  464. int memGetByteCount();
  465. void* memGetHead(void* UserMem, int* HyperLevel);
  466. laListHandle* memGetUserList(void* UserMem);
  467. laMemoryPool *memInitPool(int NodeSize, int HyperLevel);
  468. void memInitPoolSmall(laMemoryPool* mph, int NodeSize);
  469. laMemoryPoolPart* memNewPoolPart(laMemoryPool* mph);
  470. void* memAcquireH(laMemoryPool* Handle);
  471. void* memAcquireSimple(int Size);
  472. void* memAcquireNoAppend(int Size);
  473. void* memAcquireHyperNoAppend(int Size);
  474. void* memAcquire(int Size);
  475. void* memAcquireHyper(int Size);
  476. void memFree(void* Data);
  477. void memDestroyPool(laMemoryPool* Handle);
  478. void memNoLonger();
  479. void memMarkClean(void* HyperUserMem);
  480. void memLeave(void *Data);
  481. void memTake(void* Data);
  482. void memFreeRemainingLeftNodes();
  483. laStaticMemoryPoolNode* memNewStaticPool(laStaticMemoryPool* smp);
  484. void* memStaticAcquire(laStaticMemoryPool*smp, int size);
  485. void* memStaticAcquireThread(laStaticMemoryPool*smp, int size);
  486. void* memStaticDestroy(laStaticMemoryPool*smp);
  487. NEED_STRUCTURE(laSubProp);
  488. void memAssignRef(void* This, void** ptr, void* instance);
  489. void memAssignRefSafe(laSubProp* sp, void* This, void** ptr, void* instance);
  490. char * strSub(char *input, char *substring, char *replace);
  491. int strGetStringTerminateBy(char * content, char terminator, char * Out);
  492. int strHeadOfStringMatch(char * Str, char * SubStr);
  493. int strSkipSegmet(char ** pivot, char * content);
  494. char * strGetLastSegment(char * Content, char Seperator);
  495. void strDiscardLastSegmentSeperateBy(char * Content, char Seperator);
  496. void strDiscardSameBeginningSeperatedBy(char * s1, char * s2, char ** Result1, char ** Result2, char Seperator);
  497. int strCountSegmentSeperateBy(char * Content, char Seperator);
  498. void strMakeDifferentName(char * Target);
  499. void strReplaceCharacter(char * Str, char Find, char Replace);
  500. void strToUpper(char * Str);
  501. void strToLower(char * Str);
  502. laStringSplitor *strSplitPath(char *path,char terminator);
  503. int strMakeInstructions(laStringSplitor** result,char * content);
  504. laStringPart* strGetArgument(laStringSplitor* ss, char * content);
  505. char * strGetArgumentString(laStringSplitor* ss, char * content);
  506. int strArgumentMatch(laStringSplitor* ss, char * id, char * value);
  507. int strDestroyStringSplitor(laStringSplitor** ss);
  508. int strGetIntSimple(char * content);
  509. real strGetFloatSimple(char * content);
  510. void strConvInt_CString(int src, char * dest, int lenth);
  511. void strConvFloat_CString(real src, char * dest, int lenth);
  512. void strCopyFull(char * dest, char * src);
  513. void strCopySized(char * dest, int LenthLim, char * src);
  514. #define strAppend strcat
  515. void strPrintFloatAfter(char * dest, int LenthLim, int bits, real data);
  516. void strPrintIntAfter(char * dest, int LenthLim, int data);
  517. int strSame(char * src, char *dest);
  518. void strEscapePath(char* OutCanBeSame, char* path);
  519. void strSafeDestroy(laSafeString** ss);
  520. void strSafeSet(laSafeString** ss, char * Content);
  521. void strSafeAppend(laSafeString **ss, char *Content);
  522. void strSafePrint(laSafeString **ss, char *Format, ...);
  523. void strSafePrintV(laSafeString **ss, char *Format, va_list arg);
  524. void strSafeDump();
  525. void strBeginEdit(laStringEdit** se, char * FullStr);
  526. char* strGetEditString(laStringEdit *se, int SelectionOnly);
  527. char* strEndEdit(laStringEdit** se, int FreeString);
  528. void strSetEditViewRange(laStringEdit* se, int Lines, int Cols);
  529. void strEnsureCursorVisible(laStringEdit* se);
  530. void strRemoveLine(laStringEdit* se, laStringLine* sl);
  531. void strRemoveLineI(laStringEdit* se, int LineIndex);
  532. void strSetCursor(laStringEdit* se, int LineIndex, int BeforeIndex);
  533. void strMoveCursor(laStringEdit* se, int Left, int Select);
  534. void strMoveCursorLine(laStringEdit *se, int Up, int Select);
  535. int strHasSelection(laStringEdit* se);
  536. void strCancelSelect(laStringEdit *se);
  537. void strLazySelect(laStringEdit *se);
  538. void strEndSelect(laStringEdit *se);
  539. void strSelectLineAll(laStringEdit* se);
  540. void strDeselectAll(laStringEdit* se);
  541. void strPanFoward(uint32_t * str, int Before, int Offset);
  542. void strSquishBackward(uint32_t * str, int Before, int EndBefore);
  543. void strClearSelection(laStringEdit* se);
  544. laStringLine *strGetCursorLine(laStringEdit *se, int* IndexIfLast);
  545. laStringLine* strGetBeginLine(laStringEdit* se);
  546. void strInsertChar(laStringEdit* se, uint32_t a);
  547. void strBackspace(laStringEdit* se);
  548. void strMoveView(laStringEdit *se, int DownLines, int RightCharacters);
  549. int laCopyFile(char *to, char *from);
  550. void transNewLanguage(const char * LanguageID);
  551. void transSetLanguage(const char * LanguageID);
  552. void transDumpMissMatchRecord(const char * filename);
  553. void transNewEntry(const char * Target, const char * replacement);
  554. char * transLate(char * Target);
  555. void transState(void* UNUSED, int val);
  556. void transInitTranslation_zh_cn();
  557. void laOpenInternetLink(char* url);
  558. #define SEND_PANIC_ERROR(msg) \
  559. {printf(msg); exit(0);}