*/}}

la_util.h 20 KB

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