*/}}

la_util.h 20 KB

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