wutils.pas 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998 by Berczi Gabor
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. unit WUtils;
  12. interface
  13. {$ifndef FPC}
  14. {$define TPUNIXLF}
  15. {$endif}
  16. uses
  17. {$ifdef win32}
  18. windows,
  19. {$endif win32}
  20. {$ifdef Unix}
  21. {$ifdef VER1_0}
  22. linux,
  23. {$else}
  24. unix,
  25. {$endif}
  26. {$endif Unix}
  27. Dos,Objects;
  28. const
  29. kbCtrlGrayPlus = $9000;
  30. kbCtrlGrayMinus = $8e00;
  31. kbCtrlGrayMul = $9600;
  32. TempFirstChar = {$ifndef Unix}'~'{$else}'_'{$endif};
  33. TempExt = '.tmp';
  34. TempNameLen = 8;
  35. EOL : String[2] = {$ifdef Unix}#10;{$else}#13#10;{$endif}
  36. type
  37. PByteArray = ^TByteArray;
  38. TByteArray = array[0..MaxBytes] of byte;
  39. PNoDisposeCollection = ^TNoDisposeCollection;
  40. TNoDisposeCollection = object(TCollection)
  41. procedure FreeItem(Item: Pointer); virtual;
  42. end;
  43. PUnsortedStringCollection = ^TUnsortedStringCollection;
  44. TUnsortedStringCollection = object(TCollection)
  45. constructor CreateFrom(ALines: PUnsortedStringCollection);
  46. procedure Assign(ALines: PUnsortedStringCollection);
  47. function At(Index: Sw_Integer): PString;
  48. procedure FreeItem(Item: Pointer); virtual;
  49. function GetItem(var S: TStream): Pointer; virtual;
  50. procedure PutItem(var S: TStream; Item: Pointer); virtual;
  51. procedure InsertStr(const S: string);
  52. end;
  53. PNulStream = ^TNulStream;
  54. TNulStream = object(TStream)
  55. constructor Init;
  56. function GetPos: Longint; virtual;
  57. function GetSize: Longint; virtual;
  58. procedure Read(var Buf; Count: Word); virtual;
  59. procedure Seek(Pos: Longint); virtual;
  60. procedure Write(var Buf; Count: Word); virtual;
  61. end;
  62. PSubStream = ^TSubStream;
  63. TSubStream = object(TStream)
  64. constructor Init(AStream: PStream; AStartPos, ASize: longint);
  65. function GetPos: Longint; virtual;
  66. function GetSize: Longint; virtual;
  67. procedure Read(var Buf; Count: Word); virtual;
  68. procedure Seek(Pos: Longint); virtual;
  69. procedure Write(var Buf; Count: Word); virtual;
  70. private
  71. StartPos: longint;
  72. S : PStream;
  73. end;
  74. PFastBufStream = ^TFastBufStream;
  75. TFastBufStream = object(TBufStream)
  76. procedure Seek(Pos: Longint); virtual;
  77. private
  78. BasePos: longint;
  79. end;
  80. PTextCollection = ^TTextCollection;
  81. TTextCollection = object(TStringCollection)
  82. function LookUp(const S: string; var Idx: sw_integer): string;
  83. function Compare(Key1, Key2: Pointer): sw_Integer; virtual;
  84. end;
  85. PIntCollection = ^TIntCollection;
  86. TIntCollection = object(TSortedCollection)
  87. function Compare(Key1, Key2: Pointer): sw_Integer; virtual;
  88. procedure FreeItem(Item: Pointer); virtual;
  89. procedure Add(Item: longint);
  90. function Contains(Item: longint): boolean;
  91. function AtInt(Index: sw_integer): longint;
  92. end;
  93. {$ifdef TPUNIXLF}
  94. procedure readln(var t:text;var s:string);
  95. {$endif}
  96. procedure ReadlnFromStream(Stream: PStream; var s:string;var linecomplete,hasCR : boolean);
  97. function eofstream(s: pstream): boolean;
  98. function Min(A,B: longint): longint;
  99. function Max(A,B: longint): longint;
  100. function CharStr(C: char; Count: integer): string;
  101. function UpcaseStr(const S: string): string;
  102. function LowCase(C: char): char;
  103. function LowcaseStr(S: string): string;
  104. function RExpand(const S: string; MinLen: byte): string;
  105. function LExpand(const S: string; MinLen: byte): string;
  106. function LTrim(const S: string): string;
  107. function RTrim(const S: string): string;
  108. function Trim(const S: string): string;
  109. function IntToStr(L: longint): string;
  110. function IntToStrL(L: longint; MinLen: sw_integer): string;
  111. function IntToStrZ(L: longint; MinLen: sw_integer): string;
  112. function StrToInt(const S: string): longint;
  113. function StrToCard(const S: string): cardinal;
  114. function FloatToStr(D: Double; Decimals: byte): string;
  115. function FloatToStrL(D: Double; Decimals: byte; MinLen: byte): string;
  116. function HexToInt(S: string): longint;
  117. function HexToCard(S: string): cardinal;
  118. function IntToHex(L: longint; MinLen: integer): string;
  119. function GetStr(P: PString): string;
  120. function GetPChar(P: PChar): string;
  121. function BoolToStr(B: boolean; const TrueS, FalseS: string): string;
  122. function LExtendString(S: string; MinLen: byte): string;
  123. function DirOf(const S: string): string;
  124. function ExtOf(const S: string): string;
  125. function NameOf(const S: string): string;
  126. function NameAndExtOf(const S: string): string;
  127. function DirAndNameOf(const S: string): string;
  128. { return Dos GetFTime value or -1 if the file does not exist }
  129. function GetFileTime(const FileName: string): longint;
  130. { copied from compiler global unit }
  131. function GetShortName(const n:string):string;
  132. function GetLongName(const n:string):string;
  133. function TrimEndSlash(const Path: string): string;
  134. function CompleteDir(const Path: string): string;
  135. function GetCurDir: string;
  136. function OptimizePath(Path: string; MaxLen: integer): string;
  137. function CompareText(S1, S2: string): integer;
  138. function ExistsDir(const DirName: string): boolean;
  139. function ExistsFile(const FileName: string): boolean;
  140. function DeleteFile(const FileName: string): integer;
  141. function CopyFile(const SrcFileName, DestFileName: string): boolean;
  142. function GenTempFileName: string;
  143. function FormatPath(Path: string): string;
  144. function CompletePath(const Base, InComplete: string): string;
  145. function CompleteURL(const Base, URLRef: string): string;
  146. function EatIO: integer;
  147. function Now: longint;
  148. function FormatDateTimeL(L: longint; const Format: string): string;
  149. function FormatDateTime(const D: DateTime; const Format: string): string;
  150. {$ifdef TP}
  151. function StrPas(C: PChar): string;
  152. {$endif}
  153. function MemToStr(var B; Count: byte): string;
  154. procedure StrToMem(S: string; var B);
  155. procedure GiveUpTimeSlice;
  156. const LastStrToIntResult : integer = 0;
  157. LastHexToIntResult : integer = 0;
  158. LastStrToCardResult : integer = 0;
  159. LastHexToCardResult : integer = 0;
  160. DirSep : char = {$ifdef Unix}'/'{$else}'\'{$endif};
  161. procedure RegisterWUtils;
  162. implementation
  163. uses
  164. {$IFDEF OS2}
  165. DosCalls,
  166. {$ENDIF OS2}
  167. Strings;
  168. {$ifndef NOOBJREG}
  169. const
  170. SpaceStr = ' '+
  171. ' '+
  172. ' '+
  173. ' ' ;
  174. RUnsortedStringCollection: TStreamRec = (
  175. ObjType: 22500;
  176. VmtLink: Ofs(TypeOf(TUnsortedStringCollection)^);
  177. Load: @TUnsortedStringCollection.Load;
  178. Store: @TUnsortedStringCollection.Store
  179. );
  180. {$endif}
  181. {$ifdef TPUNIXLF}
  182. procedure readln(var t:text;var s:string);
  183. var
  184. c : char;
  185. i : longint;
  186. begin
  187. if TextRec(t).UserData[1]=2 then
  188. system.readln(t,s)
  189. else
  190. begin
  191. c:=#0;
  192. i:=0;
  193. while (not eof(t)) and (c<>#10) and (i<High(S)) do
  194. begin
  195. read(t,c);
  196. if c<>#10 then
  197. begin
  198. inc(i);
  199. s[i]:=c;
  200. end;
  201. end;
  202. if (i>0) and (s[i]=#13) then
  203. begin
  204. dec(i);
  205. TextRec(t).UserData[1]:=2;
  206. end;
  207. s[0]:=chr(i);
  208. end;
  209. end;
  210. {$endif}
  211. function eofstream(s: pstream): boolean;
  212. begin
  213. eofstream:=(s^.getpos>=s^.getsize);
  214. end;
  215. procedure ReadlnFromStream(Stream: PStream; var S:string;var linecomplete,hasCR : boolean);
  216. var
  217. c : char;
  218. i,pos : longint;
  219. begin
  220. linecomplete:=false;
  221. c:=#0;
  222. i:=0;
  223. { this created problems for lines longer than 255 characters
  224. now those lines are cutted into pieces without warning PM }
  225. { changed implicit 255 to High(S), so it will be automatically extended
  226. when longstrings eventually become default - Gabor }
  227. while (not eofstream(stream)) and (c<>#10) and (i<High(S)) do
  228. begin
  229. stream^.read(c,sizeof(c));
  230. if c<>#10 then
  231. begin
  232. inc(i);
  233. s[i]:=c;
  234. end;
  235. end;
  236. { if there was a CR LF then remove the CR Dos newline style }
  237. if (i>0) and (s[i]=#13) then
  238. begin
  239. dec(i);
  240. end;
  241. if (c=#13) and (not eofstream(stream)) then
  242. stream^.read(c,sizeof(c));
  243. if (i=High(S)) and not eofstream(stream) then
  244. begin
  245. pos:=stream^.getpos;
  246. stream^.read(c,sizeof(c));
  247. if (c=#13) and not eofstream(stream) then
  248. stream^.read(c,sizeof(c));
  249. if c<>#10 then
  250. stream^.seek(pos);
  251. end;
  252. if (c=#10) or eofstream(stream) then
  253. linecomplete:=true;
  254. if (c=#10) then
  255. hasCR:=true;
  256. s[0]:=chr(i);
  257. end;
  258. {$ifdef TP}
  259. { TP's own StrPas() is buggy, because it causes GPF with strings longer than
  260. 255 chars }
  261. function StrPas(C: PChar): string;
  262. var S: string;
  263. I: longint;
  264. begin
  265. if Assigned(C)=false then
  266. S:=''
  267. else
  268. begin
  269. I:=StrLen(C); if I>High(S) then I:=High(S);
  270. S[0]:=chr(I); Move(C^,S[1],I);
  271. end;
  272. StrPas:=S;
  273. end;
  274. {$endif}
  275. function MemToStr(var B; Count: byte): string;
  276. var S: string;
  277. begin
  278. S[0]:=chr(Count);
  279. if Count>0 then Move(B,S[1],Count);
  280. MemToStr:=S;
  281. end;
  282. procedure StrToMem(S: string; var B);
  283. begin
  284. if length(S)>0 then Move(S[1],B,length(S));
  285. end;
  286. function Max(A,B: longint): longint;
  287. begin
  288. if A>B then Max:=A else Max:=B;
  289. end;
  290. function Min(A,B: longint): longint;
  291. begin
  292. if A<B then Min:=A else Min:=B;
  293. end;
  294. function CharStr(C: char; Count: integer): string;
  295. {$ifndef FPC}
  296. var S: string;
  297. {$endif}
  298. begin
  299. if Count<=0 then
  300. begin
  301. CharStr:='';
  302. exit;
  303. end
  304. else if Count>255 then
  305. Count:=255;
  306. {$ifdef FPC}
  307. CharStr[0]:=chr(Count);
  308. FillChar(CharStr[1],Count,C);
  309. {$else}
  310. S[0]:=chr(Count);
  311. FillChar(S[1],Count,C);
  312. CharStr:=S;
  313. {$endif}
  314. end;
  315. function UpcaseStr(const S: string): string;
  316. var
  317. I: Longint;
  318. begin
  319. for I:=1 to length(S) do
  320. if S[I] in ['a'..'z'] then
  321. UpCaseStr[I]:=chr(ord(S[I])-32)
  322. else
  323. UpCaseStr[I]:=S[I];
  324. UpcaseStr[0]:=S[0];
  325. end;
  326. function RExpand(const S: string; MinLen: byte): string;
  327. begin
  328. if length(S)<MinLen then
  329. RExpand:=S+CharStr(' ',MinLen-length(S))
  330. else
  331. RExpand:=S;
  332. end;
  333. function LExpand(const S: string; MinLen: byte): string;
  334. begin
  335. if length(S)<MinLen then
  336. LExpand:=CharStr(' ',MinLen-length(S))+S
  337. else
  338. LExpand:=S;
  339. end;
  340. function LTrim(const S: string): string;
  341. var
  342. i : longint;
  343. begin
  344. i:=1;
  345. while (i<length(s)) and (s[i]=' ') do
  346. inc(i);
  347. LTrim:=Copy(s,i,High(S));
  348. end;
  349. function RTrim(const S: string): string;
  350. var
  351. i : longint;
  352. begin
  353. i:=length(s);
  354. while (i>0) and (s[i]=' ') do
  355. dec(i);
  356. RTrim:=Copy(s,1,i);
  357. end;
  358. function Trim(const S: string): string;
  359. var
  360. i,j : longint;
  361. begin
  362. i:=1;
  363. while (i<length(s)) and (s[i]=' ') do
  364. inc(i);
  365. j:=length(s);
  366. while (j>0) and (s[j]=' ') do
  367. dec(j);
  368. Trim:=Copy(S,i,j-i+1);
  369. end;
  370. function IntToStr(L: longint): string;
  371. var S: string;
  372. begin
  373. Str(L,S);
  374. IntToStr:=S;
  375. end;
  376. function IntToStrL(L: longint; MinLen: sw_integer): string;
  377. begin
  378. IntToStrL:=LExpand(IntToStr(L),MinLen);
  379. end;
  380. function IntToStrZ(L: longint; MinLen: sw_integer): string;
  381. var S: string;
  382. begin
  383. S:=IntToStr(L);
  384. if length(S)<MinLen then
  385. S:=CharStr('0',MinLen-length(S))+S;
  386. IntToStrZ:=S;
  387. end;
  388. function StrToInt(const S: string): longint;
  389. var L: longint;
  390. C: integer;
  391. begin
  392. Val(S,L,C); if C<>0 then L:=-1;
  393. LastStrToIntResult:=C;
  394. StrToInt:=L;
  395. end;
  396. function StrToCard(const S: string): cardinal;
  397. var L: cardinal;
  398. C: integer;
  399. begin
  400. Val(S,L,C); if C<>0 then L:=$ffffffff;
  401. LastStrToCardResult:=C;
  402. StrToCard:=L;
  403. end;
  404. function HexToInt(S: string): longint;
  405. var L,I: longint;
  406. C: char;
  407. const HexNums: string[16] = '0123456789ABCDEF';
  408. begin
  409. S:=Trim(S); L:=0; I:=1; LastHexToIntResult:=0;
  410. while (I<=length(S)) and (LastHexToIntResult=0) do
  411. begin
  412. C:=Upcase(S[I]);
  413. if C in['0'..'9','A'..'F'] then
  414. begin
  415. L:=L*16+(Pos(C,HexNums)-1);
  416. end else LastHexToIntResult:=I;
  417. Inc(I);
  418. end;
  419. HexToInt:=L;
  420. end;
  421. function HexToCard(S: string): cardinal;
  422. var L,I: cardinal;
  423. C: char;
  424. const HexNums: string[16] = '0123456789ABCDEF';
  425. begin
  426. S:=Trim(S); L:=0; I:=1; LastHexToCardResult:=0;
  427. while (I<=length(S)) and (LastHexToCardResult=0) do
  428. begin
  429. C:=Upcase(S[I]);
  430. if C in['0'..'9','A'..'F'] then
  431. begin
  432. L:=L*16+(Pos(C,HexNums)-1);
  433. end else LastHexToCardResult:=I;
  434. Inc(I);
  435. end;
  436. HexToCard:=L;
  437. end;
  438. function IntToHex(L: longint; MinLen: integer): string;
  439. const HexNums : string[16] = '0123456789ABCDEF';
  440. var S: string;
  441. R: real;
  442. function DivF(Mit,Mivel: real): longint;
  443. begin
  444. DivF:=trunc(Mit/Mivel);
  445. end;
  446. function ModF(Mit,Mivel: real): longint;
  447. begin
  448. ModF:=trunc(Mit-DivF(Mit,Mivel)*Mivel);
  449. end;
  450. begin
  451. S:='';
  452. R:=L; if R<0 then begin R:=R+2147483647+2147483647+2; end;
  453. repeat
  454. Insert(HexNums[ModF(R,16)+1],S,1);
  455. R:=DivF(R,16);
  456. until R=0;
  457. while length(S)<MinLen do
  458. Insert('0',S,1);
  459. IntToHex:=S;
  460. end;
  461. function FloatToStr(D: Double; Decimals: byte): string;
  462. var S: string;
  463. L: byte;
  464. begin
  465. Str(D:0:Decimals,S);
  466. if length(S)>0 then
  467. while (S[1]=' ') do Delete(S,1,1);
  468. FloatToStr:=S;
  469. end;
  470. function FloatToStrL(D: Double; Decimals: byte; MinLen: byte): string;
  471. begin
  472. FloatToStrL:=LExtendString(FloatToStr(D,Decimals),MinLen);
  473. end;
  474. function LExtendString(S: string; MinLen: byte): string;
  475. begin
  476. LExtendString:=copy(SpaceStr,1,MinLen-length(S))+S;
  477. end;
  478. function GetStr(P: PString): string;
  479. begin
  480. if P=nil then GetStr:='' else GetStr:=P^;
  481. end;
  482. function GetPChar(P: PChar): string;
  483. begin
  484. if P=nil then GetPChar:='' else GetPChar:=StrPas(P);
  485. end;
  486. function DirOf(const S: string): string;
  487. var D: DirStr; E: ExtStr; N: NameStr;
  488. begin
  489. FSplit(S,D,N,E);
  490. if (D<>'') and (D[Length(D)]<>DirSep) then
  491. DirOf:=D+DirSep
  492. else
  493. DirOf:=D;
  494. end;
  495. function ExtOf(const S: string): string;
  496. var D: DirStr; E: ExtStr; N: NameStr;
  497. begin
  498. FSplit(S,D,N,E);
  499. ExtOf:=E;
  500. end;
  501. function NameOf(const S: string): string;
  502. var D: DirStr; E: ExtStr; N: NameStr;
  503. begin
  504. FSplit(S,D,N,E);
  505. NameOf:=N;
  506. end;
  507. function NameAndExtOf(const S: string): string;
  508. var D: DirStr; E: ExtStr; N: NameStr;
  509. begin
  510. FSplit(S,D,N,E);
  511. NameAndExtOf:=N+E;
  512. end;
  513. function DirAndNameOf(const S: string): string;
  514. var D: DirStr; E: ExtStr; N: NameStr;
  515. begin
  516. FSplit(S,D,N,E);
  517. DirAndNameOf:=D+N;
  518. end;
  519. { return Dos GetFTime value or -1 if the file does not exist }
  520. function GetFileTime(const FileName: string): longint;
  521. var T: longint;
  522. f: file;
  523. FM: integer;
  524. begin
  525. if FileName='' then
  526. T:=-1
  527. else
  528. begin
  529. FM:=FileMode; FileMode:=0;
  530. EatIO; Dos.DosError:=0;
  531. Assign(f,FileName);
  532. {$I-}
  533. Reset(f);
  534. if InOutRes=0 then
  535. begin
  536. GetFTime(f,T);
  537. Close(f);
  538. end;
  539. {$I+}
  540. if (EatIO<>0) or (Dos.DosError<>0) then T:=-1;
  541. FileMode:=FM;
  542. end;
  543. GetFileTime:=T;
  544. end;
  545. function GetShortName(const n:string):string;
  546. {$ifdef win32}
  547. var
  548. hs,hs2 : string;
  549. i : longint;
  550. {$endif}
  551. {$ifdef go32v2}
  552. var
  553. hs : string;
  554. {$endif}
  555. begin
  556. GetShortName:=n;
  557. {$ifdef win32}
  558. hs:=n+#0;
  559. i:=Windows.GetShortPathName(@hs[1],@hs2[1],high(hs2));
  560. if (i>0) and (i<=high(hs2)) then
  561. begin
  562. hs2[0]:=chr(strlen(@hs2[1]));
  563. GetShortName:=hs2;
  564. end;
  565. {$endif}
  566. {$ifdef go32v2}
  567. hs:=n;
  568. if Dos.GetShortName(hs) then
  569. GetShortName:=hs;
  570. {$endif}
  571. end;
  572. function GetLongName(const n:string):string;
  573. {$ifdef win32}
  574. var
  575. hs : string;
  576. hs2 : Array [0..255] of char;
  577. i : longint;
  578. j : pchar;
  579. {$endif}
  580. {$ifdef go32v2}
  581. var
  582. hs : string;
  583. {$endif}
  584. begin
  585. GetLongName:=n;
  586. {$ifdef win32}
  587. hs:=n+#0;
  588. i:=Windows.GetFullPathName(@hs[1],256,hs2,j);
  589. if (i>0) and (i<=high(hs)) then
  590. begin
  591. hs:=strpas(hs2);
  592. GetLongName:=hs;
  593. end;
  594. {$endif}
  595. {$ifdef go32v2}
  596. hs:=n;
  597. if Dos.GetLongName(hs) then
  598. GetLongName:=hs;
  599. {$endif}
  600. end;
  601. function EatIO: integer;
  602. begin
  603. EatIO:=IOResult;
  604. end;
  605. function LowCase(C: char): char;
  606. begin
  607. if ('A'<=C) and (C<='Z') then C:=chr(ord(C)+32);
  608. LowCase:=C;
  609. end;
  610. function LowcaseStr(S: string): string;
  611. var I: Longint;
  612. begin
  613. for I:=1 to length(S) do
  614. S[I]:=Lowcase(S[I]);
  615. LowcaseStr:=S;
  616. end;
  617. function BoolToStr(B: boolean; const TrueS, FalseS: string): string;
  618. begin
  619. if B then BoolToStr:=TrueS else BoolToStr:=FalseS;
  620. end;
  621. procedure TNoDisposeCollection.FreeItem(Item: Pointer);
  622. begin
  623. { don't do anything here }
  624. end;
  625. constructor TUnsortedStringCollection.CreateFrom(ALines: PUnsortedStringCollection);
  626. begin
  627. if Assigned(ALines)=false then Fail;
  628. inherited Init(ALines^.Count,ALines^.Count div 10);
  629. Assign(ALines);
  630. end;
  631. procedure TUnsortedStringCollection.Assign(ALines: PUnsortedStringCollection);
  632. procedure AddIt(P: PString); {$ifndef FPC}far;{$endif}
  633. begin
  634. Insert(NewStr(GetStr(P)));
  635. end;
  636. begin
  637. FreeAll;
  638. if Assigned(ALines) then
  639. ALines^.ForEach(@AddIt);
  640. end;
  641. procedure TUnsortedStringCollection.InsertStr(const S: string);
  642. begin
  643. Insert(NewStr(S));
  644. end;
  645. function TUnsortedStringCollection.At(Index: Sw_Integer): PString;
  646. begin
  647. At:=inherited At(Index);
  648. end;
  649. procedure TUnsortedStringCollection.FreeItem(Item: Pointer);
  650. begin
  651. if Item<>nil then DisposeStr(Item);
  652. end;
  653. function TUnsortedStringCollection.GetItem(var S: TStream): Pointer;
  654. begin
  655. GetItem:=S.ReadStr;
  656. end;
  657. procedure TUnsortedStringCollection.PutItem(var S: TStream; Item: Pointer);
  658. begin
  659. S.WriteStr(Item);
  660. end;
  661. function TIntCollection.Contains(Item: longint): boolean;
  662. var Index: sw_integer;
  663. begin
  664. Contains:=Search(pointer(Item),Index);
  665. end;
  666. function TIntCollection.AtInt(Index: sw_integer): longint;
  667. begin
  668. AtInt:=longint(At(Index));
  669. end;
  670. procedure TIntCollection.Add(Item: longint);
  671. begin
  672. Insert(pointer(Item));
  673. end;
  674. function TIntCollection.Compare(Key1, Key2: Pointer): sw_Integer;
  675. var K1: longint absolute Key1;
  676. K2: longint absolute Key2;
  677. R: integer;
  678. begin
  679. if K1<K2 then R:=-1 else
  680. if K1>K2 then R:= 1 else
  681. R:=0;
  682. Compare:=R;
  683. end;
  684. procedure TIntCollection.FreeItem(Item: Pointer);
  685. begin
  686. { do nothing here }
  687. end;
  688. constructor TNulStream.Init;
  689. begin
  690. inherited Init;
  691. Position:=0;
  692. end;
  693. function TNulStream.GetPos: Longint;
  694. begin
  695. GetPos:=Position;
  696. end;
  697. function TNulStream.GetSize: Longint;
  698. begin
  699. GetSize:=Position;
  700. end;
  701. procedure TNulStream.Read(var Buf; Count: Word);
  702. begin
  703. Error(stReadError,0);
  704. end;
  705. procedure TNulStream.Seek(Pos: Longint);
  706. begin
  707. if Pos<=Position then
  708. Position:=Pos;
  709. end;
  710. procedure TNulStream.Write(var Buf; Count: Word);
  711. begin
  712. Inc(Position,Count);
  713. end;
  714. constructor TSubStream.Init(AStream: PStream; AStartPos, ASize: longint);
  715. begin
  716. inherited Init;
  717. if Assigned(AStream)=false then Fail;
  718. S:=AStream; StartPos:=AStartPos; StreamSize:=ASize;
  719. Seek(0);
  720. end;
  721. function TSubStream.GetPos: Longint;
  722. var Pos: longint;
  723. begin
  724. Pos:=S^.GetPos; Dec(Pos,StartPos);
  725. GetPos:=Pos;
  726. end;
  727. function TSubStream.GetSize: Longint;
  728. begin
  729. GetSize:=StreamSize;
  730. end;
  731. procedure TSubStream.Read(var Buf; Count: Word);
  732. var Pos: longint;
  733. RCount: word;
  734. begin
  735. Pos:=GetPos;
  736. if Pos+Count>StreamSize then RCount:=StreamSize-Pos else RCount:=Count;
  737. S^.Read(Buf,RCount);
  738. if RCount<Count then
  739. Error(stReadError,0);
  740. end;
  741. procedure TSubStream.Seek(Pos: Longint);
  742. var RPos: longint;
  743. begin
  744. if (Pos<=StreamSize) then RPos:=Pos else RPos:=StreamSize;
  745. S^.Seek(StartPos+RPos);
  746. end;
  747. procedure TSubStream.Write(var Buf; Count: Word);
  748. begin
  749. S^.Write(Buf,Count);
  750. end;
  751. procedure TFastBufStream.Seek(Pos: Longint);
  752. function BufStartPos: longint;
  753. begin
  754. BufStartPos:=Position-BufPtr;
  755. end;
  756. var RelOfs: longint;
  757. begin
  758. RelOfs:=Pos-{BufStartPos}BasePos;
  759. if (RelOfs<0) or (RelOfs>=BufEnd) or (BufEnd=0) then
  760. begin
  761. inherited Seek(Pos);
  762. BasePos:=Pos-BufPtr;
  763. end
  764. else
  765. begin
  766. BufPtr:=RelOfs;
  767. Position:=Pos;
  768. end;
  769. end;
  770. function TTextCollection.Compare(Key1, Key2: Pointer): Sw_Integer;
  771. var K1: PString absolute Key1;
  772. K2: PString absolute Key2;
  773. R: Sw_integer;
  774. S1,S2: string;
  775. begin
  776. S1:=UpCaseStr(K1^);
  777. S2:=UpCaseStr(K2^);
  778. if S1<S2 then R:=-1 else
  779. if S1>S2 then R:=1 else
  780. R:=0;
  781. Compare:=R;
  782. end;
  783. function TTextCollection.LookUp(const S: string; var Idx: sw_integer): string;
  784. var OLI,ORI,Left,Right,Mid: integer;
  785. {LeftP,RightP,}MidP: PString;
  786. {LeftS,}MidS{,RightS}: string;
  787. FoundS: string;
  788. UpS : string;
  789. begin
  790. Idx:=-1; FoundS:='';
  791. Left:=0; Right:=Count-1;
  792. UpS:=UpCaseStr(S);
  793. while Left<=Right do
  794. begin
  795. OLI:=Left; ORI:=Right;
  796. Mid:=Left+(Right-Left) div 2;
  797. MidP:=At(Mid);
  798. MidS:=UpCaseStr(MidP^);
  799. if copy(MidS,1,length(UpS))=UpS then
  800. begin
  801. Idx:=Mid; FoundS:=GetStr(MidP);
  802. { exit immediately if exact match PM }
  803. If Length(MidS)=Length(UpS) then
  804. break;
  805. end;
  806. if UpS<MidS then
  807. Right:=Mid
  808. else
  809. Left:=Mid;
  810. if (OLI=Left) and (ORI=Right) then
  811. begin
  812. if (Left<Right) then
  813. Left:=Right
  814. else
  815. Break;
  816. end;
  817. end;
  818. LookUp:=FoundS;
  819. end;
  820. function TrimEndSlash(const Path: string): string;
  821. var S: string;
  822. begin
  823. S:=Path;
  824. if (length(S)>0) and (S<>DirSep) and (copy(S,length(S),1)=DirSep) and
  825. (S[length(S)-1]<>':') then
  826. S:=copy(S,1,length(S)-1);
  827. TrimEndSlash:=S;
  828. end;
  829. function CompareText(S1, S2: string): integer;
  830. var R: integer;
  831. begin
  832. S1:=UpcaseStr(S1); S2:=UpcaseStr(S2);
  833. if S1<S2 then R:=-1 else
  834. if S1>S2 then R:= 1 else
  835. R:=0;
  836. CompareText:=R;
  837. end;
  838. function FormatPath(Path: string): string;
  839. var P: sw_integer;
  840. SC: char;
  841. begin
  842. if ord(DirSep)=ord('/') then
  843. SC:='\'
  844. else
  845. SC:='/';
  846. repeat
  847. P:=Pos(SC,Path);
  848. if P>0 then Path[P]:=DirSep;
  849. until P=0;
  850. FormatPath:=Path;
  851. end;
  852. function CompletePath(const Base, InComplete: string): string;
  853. var Drv,BDrv: string[40]; D,BD: DirStr; N,BN: NameStr; E,BE: ExtStr;
  854. P: sw_integer;
  855. Complete: string;
  856. begin
  857. Complete:=FormatPath(InComplete);
  858. FSplit(FormatPath(InComplete),D,N,E);
  859. P:=Pos(':',D); if P=0 then Drv:='' else begin Drv:=copy(D,1,P); Delete(D,1,P); end;
  860. FSplit(FormatPath(Base),BD,BN,BE);
  861. P:=Pos(':',BD); if P=0 then BDrv:='' else begin BDrv:=copy(BD,1,P); Delete(BD,1,P); end;
  862. if copy(D,1,1)<>DirSep then
  863. Complete:=BD+D+N+E;
  864. if Drv='' then
  865. Complete:=BDrv+Complete;
  866. Complete:=FExpand(Complete);
  867. CompletePath:=Complete;
  868. end;
  869. function CompleteURL(const Base, URLRef: string): string;
  870. var P: integer;
  871. Drive: string[20];
  872. IsComplete: boolean;
  873. S: string;
  874. Ref: string;
  875. Bookmark: string;
  876. begin
  877. IsComplete:=false; Ref:=URLRef;
  878. P:=Pos(':',Ref);
  879. if P=0 then Drive:='' else Drive:=UpcaseStr(copy(Ref,1,P-1));
  880. if Drive<>'' then
  881. if (Drive='MAILTO') or (Drive='FTP') or (Drive='HTTP') or
  882. (Drive='GOPHER') or (Drive='FILE') then
  883. IsComplete:=true;
  884. if IsComplete then S:=Ref else
  885. begin
  886. P:=Pos('#',Ref);
  887. if P=0 then
  888. Bookmark:=''
  889. else
  890. begin
  891. Bookmark:=copy(Ref,P+1,length(Ref));
  892. Ref:=copy(Ref,1,P-1);
  893. end;
  894. S:=CompletePath(Base,Ref);
  895. if Bookmark<>'' then
  896. S:=S+'#'+Bookmark;
  897. end;
  898. CompleteURL:=S;
  899. end;
  900. function OptimizePath(Path: string; MaxLen: integer): string;
  901. var i : integer;
  902. BackSlashs : array[1..20] of integer;
  903. BSCount : integer;
  904. Jobbra : boolean;
  905. Jobb, Bal : byte;
  906. Hiba : boolean;
  907. begin
  908. if length(Path)>MaxLen then
  909. begin
  910. BSCount:=0; Jobbra:=true;
  911. for i:=1 to length(Path) do if Path[i]=DirSep then
  912. begin
  913. Inc(BSCount);
  914. BackSlashs[BSCount]:=i;
  915. end;
  916. i:=BSCount div 2;
  917. Hiba:=false;
  918. Bal:=i; Jobb:=i+1;
  919. case i of 0 : ;
  920. 1 : Path:=copy(Path, 1, BackSlashs[1])+'..'+
  921. copy(Path, BackSlashs[2], length(Path));
  922. else begin
  923. while (BackSlashs[Bal]+(length(Path)-BackSlashs[Jobb]) >=
  924. MaxLen) and not Hiba do
  925. begin
  926. if Jobbra then begin
  927. if Jobb<BSCount then inc(Jobb)
  928. else Hiba:=true;
  929. Jobbra:=false;
  930. end
  931. else begin
  932. if Bal>1 then dec(Bal)
  933. else Hiba:=true;
  934. Jobbra:=true;
  935. end;
  936. end;
  937. Path:=copy(Path, 1, BackSlashs[Bal])+'..'+
  938. copy(Path, BackSlashs[Jobb], length(Path));
  939. end;
  940. end;
  941. end;
  942. if length(Path)>MaxLen then
  943. begin
  944. i:=Pos('\..\',Path);
  945. if i>0 then Path:=copy(Path,1,i-1)+'..'+copy(Path,i+length('\..\'),length(Path));
  946. end;
  947. OptimizePath:=Path;
  948. end;
  949. function Now: longint;
  950. var D: DateTime;
  951. W: word;
  952. L: longint;
  953. begin
  954. FillChar(D,sizeof(D),0);
  955. GetDate(D.Year,D.Month,D.Day,W);
  956. GetTime(D.Hour,D.Min,D.Sec,W);
  957. PackTime(D,L);
  958. Now:=L;
  959. end;
  960. function FormatDateTimeL(L: longint; const Format: string): string;
  961. var D: DateTime;
  962. begin
  963. UnpackTime(L,D);
  964. FormatDateTimeL:=FormatDateTime(D,Format);
  965. end;
  966. function FormatDateTime(const D: DateTime; const Format: string): string;
  967. var I: sw_integer;
  968. CurCharStart: sw_integer;
  969. CurChar: char;
  970. CurCharCount: integer;
  971. DateS: string;
  972. C: char;
  973. procedure FlushChars;
  974. var S: string;
  975. I: sw_integer;
  976. begin
  977. S:='';
  978. for I:=1 to CurCharCount do
  979. S:=S+CurChar;
  980. case CurChar of
  981. 'y' : S:=IntToStrL(D.Year,length(S));
  982. 'm' : S:=IntToStrZ(D.Month,length(S));
  983. 'd' : S:=IntToStrZ(D.Day,length(S));
  984. 'h' : S:=IntToStrZ(D.Hour,length(S));
  985. 'n' : S:=IntToStrZ(D.Min,length(S));
  986. 's' : S:=IntToStrZ(D.Sec,length(S));
  987. end;
  988. DateS:=DateS+S;
  989. end;
  990. begin
  991. DateS:='';
  992. CurCharStart:=-1; CurCharCount:=0; CurChar:=#0;
  993. for I:=1 to length(Format) do
  994. begin
  995. C:=Format[I];
  996. if (C<>CurChar) or (CurCharStart=-1) then
  997. begin
  998. if CurCharStart<>-1 then FlushChars;
  999. CurCharCount:=1; CurCharStart:=I;
  1000. end
  1001. else
  1002. Inc(CurCharCount);
  1003. CurChar:=C;
  1004. end;
  1005. FlushChars;
  1006. FormatDateTime:=DateS;
  1007. end;
  1008. function DeleteFile(const FileName: string): integer;
  1009. var f: file;
  1010. begin
  1011. {$I-}
  1012. Assign(f,FileName);
  1013. Erase(f);
  1014. DeleteFile:=EatIO;
  1015. {$I+}
  1016. end;
  1017. function ExistsFile(const FileName: string): boolean;
  1018. var
  1019. Dir : SearchRec;
  1020. begin
  1021. Dos.FindFirst(FileName,Archive+ReadOnly,Dir);
  1022. ExistsFile:=(Dos.DosError=0);
  1023. {$ifdef FPC}
  1024. Dos.FindClose(Dir);
  1025. {$endif def FPC}
  1026. end;
  1027. function ExistsDir(const DirName: string): boolean;
  1028. var
  1029. Dir : SearchRec;
  1030. begin
  1031. Dos.FindFirst(TrimEndSlash(DirName),Directory,Dir);
  1032. { if a file is found it is also reported
  1033. at least for some Dos version
  1034. so we need to check the attributes PM }
  1035. ExistsDir:=(Dos.DosError=0) and ((Dir.attr and Directory) <> 0);
  1036. {$ifdef FPC}
  1037. Dos.FindClose(Dir);
  1038. {$endif def FPC}
  1039. end;
  1040. function CompleteDir(const Path: string): string;
  1041. begin
  1042. { keep c: untouched PM }
  1043. if (Path<>'') and (Path[Length(Path)]<>DirSep) and
  1044. (Path[Length(Path)]<>':') then
  1045. CompleteDir:=Path+DirSep
  1046. else
  1047. CompleteDir:=Path;
  1048. end;
  1049. function GetCurDir: string;
  1050. var S: string;
  1051. begin
  1052. GetDir(0,S);
  1053. if copy(S,length(S),1)<>DirSep then S:=S+DirSep;
  1054. GetCurDir:=S;
  1055. end;
  1056. function GenTempFileName: string;
  1057. var Dir: string;
  1058. Name: string;
  1059. I: integer;
  1060. OK: boolean;
  1061. Path: string;
  1062. begin
  1063. Dir:=GetEnv('TEMP');
  1064. if Dir='' then Dir:=GetEnv('TMP');
  1065. if (Dir<>'') then if not ExistsDir(Dir) then Dir:='';
  1066. if Dir='' then Dir:=GetCurDir;
  1067. repeat
  1068. Name:=TempFirstChar;
  1069. for I:=2 to TempNameLen do
  1070. Name:=Name+chr(ord('a')+random(ord('z')-ord('a')+1));
  1071. Name:=Name+TempExt;
  1072. Path:=CompleteDir(Dir)+Name;
  1073. OK:=not ExistsFile(Path);
  1074. until OK;
  1075. GenTempFileName:=Path;
  1076. end;
  1077. function CopyFile(const SrcFileName, DestFileName: string): boolean;
  1078. var SrcF,DestF: PBufStream;
  1079. OK: boolean;
  1080. begin
  1081. SrcF:=nil; DestF:=nil;
  1082. New(SrcF, Init(SrcFileName,stOpenRead,4096));
  1083. OK:=Assigned(SrcF) and (SrcF^.Status=stOK);
  1084. if OK then
  1085. begin
  1086. New(DestF, Init(DestFileName,stCreate,1024));
  1087. OK:=Assigned(DestF) and (DestF^.Status=stOK);
  1088. end;
  1089. if OK then DestF^.CopyFrom(SrcF^,SrcF^.GetSize);
  1090. if Assigned(DestF) then Dispose(DestF, Done);
  1091. if Assigned(SrcF) then Dispose(SrcF, Done);
  1092. CopyFile:=OK;
  1093. end;
  1094. procedure GiveUpTimeSlice;
  1095. {$ifdef GO32V2}{$define DOS}{$endif}
  1096. {$ifdef TP}{$define DOS}{$endif}
  1097. {$ifdef DOS}
  1098. var r: registers;
  1099. begin
  1100. r.ax:=$1680;
  1101. intr($2f,r);
  1102. end;
  1103. {$endif}
  1104. {$ifdef Unix}
  1105. var
  1106. req,rem : timespec;
  1107. begin
  1108. req.tv_sec:=0;
  1109. req.tv_nsec:=10000000;{ 10 ms }
  1110. nanosleep(req,rem);
  1111. end;
  1112. {$endif}
  1113. {$IFDEF OS2}
  1114. begin
  1115. DosSleep (5);
  1116. end;
  1117. {$ENDIF}
  1118. {$ifdef Win32}
  1119. begin
  1120. { if the return value of this call is non zero then
  1121. it means that a ReadFileEx or WriteFileEx have completed
  1122. unused for now ! }
  1123. { wait for 10 ms }
  1124. if SleepEx(10,true)=WAIT_IO_COMPLETION then
  1125. begin
  1126. { here we should handle the completion of the routines
  1127. if we use them }
  1128. end;
  1129. end;
  1130. {$endif}
  1131. {$undef DOS}
  1132. procedure RegisterWUtils;
  1133. begin
  1134. {$ifndef NOOBJREG}
  1135. RegisterType(RUnsortedStringCollection);
  1136. {$endif}
  1137. end;
  1138. BEGIN
  1139. Randomize;
  1140. END.
  1141. {
  1142. $Log$
  1143. Revision 1.9 2002-05-13 13:44:33 peter
  1144. * fixed range error
  1145. Revision 1.8 2002/04/02 13:23:02 pierre
  1146. + HextToCard StrToCard new functions
  1147. Revision 1.7 2002/03/22 16:43:27 pierre
  1148. * avoid that constructor is proposed for code complete if const is given
  1149. Revision 1.6 2002/03/20 13:48:31 pierre
  1150. * avoid stack corruption in CharStr if count > 255
  1151. Revision 1.5 2001/11/18 20:18:54 peter
  1152. * use cp_value_equal_const instead of cp_all
  1153. Revision 1.4 2001/09/18 15:36:58 pierre
  1154. * avoid bug 1610
  1155. Revision 1.3 2001/08/12 00:04:50 pierre
  1156. * some speed improvements for string operations
  1157. Revision 1.2 2001/08/05 02:01:49 peter
  1158. * FVISION define to compile with fvision units
  1159. Revision 1.1 2001/08/04 11:30:26 peter
  1160. * ide works now with both compiler versions
  1161. Revision 1.1.2.14 2001/06/20 22:56:31 pierre
  1162. * check that the Dir in ExistsDir is really a directory and not a file
  1163. Revision 1.1.2.13 2001/02/05 14:45:42 pierre
  1164. * fix for bug 1370
  1165. Revision 1.1.2.12 2000/11/29 18:28:54 pierre
  1166. + add save to file capability for list boxes
  1167. Revision 1.1.2.11 2000/11/27 12:06:52 pierre
  1168. New bunch of Gabor fixes
  1169. Revision 1.1.2.10 2000/11/14 09:08:51 marco
  1170. * First batch IDE renamefest
  1171. Revision 1.1.2.9 2000/11/13 16:59:10 pierre
  1172. * some function in double removed from fputils unit
  1173. Revision 1.1.2.8 2000/11/12 19:50:36 hajny
  1174. * OS/2 changes from the main branch merged
  1175. Revision 1.1.2.7 2000/11/06 17:19:58 pierre
  1176. * avoid eating of last carriage return
  1177. Revision 1.1.2.6 2000/10/24 12:31:40 pierre
  1178. * fix the last commit for linux
  1179. Revision 1.1.2.5 2000/10/24 12:24:03 pierre
  1180. + GiveUpTimeSlice for linux and win32
  1181. Revision 1.1.2.4 2000/09/18 13:20:56 pierre
  1182. New bunch of Gabor changes
  1183. Revision 1.2 2000/08/22 09:41:42 pierre
  1184. * first big merge from fixes branch
  1185. Revision 1.1.2.3 2000/08/20 15:00:23 peter
  1186. * windows fix
  1187. Revision 1.1.2.2 2000/08/16 18:46:15 peter
  1188. [*] double clicking on a droplistbox caused GPF (due to invalid recurson)
  1189. [*] Make, Build now possible even in Compiler Messages Window
  1190. [+] when started in a new dir the IDE now ask whether to create a local
  1191. config, or to use the one located in the IDE dir
  1192. Revision 1.1.2.1 2000/07/20 11:02:16 michael
  1193. + Fixes from gabor. See fixes.txt
  1194. Revision 1.1 2000/07/13 09:48:37 michael
  1195. + Initial import
  1196. Revision 1.27 2000/07/03 08:54:54 pierre
  1197. * Some enhancements for WinHelp support by G abor
  1198. Revision 1.26 2000/06/26 07:29:23 pierre
  1199. * new bunch of Gabor's changes
  1200. Revision 1.25 2000/06/22 09:07:15 pierre
  1201. * Gabor changes: see fixes.txt
  1202. Revision 1.24 2000/06/16 21:16:41 pierre
  1203. * allow to read until 255 chars per line
  1204. Revision 1.23 2000/06/16 08:50:45 pierre
  1205. + new bunch of Gabor's changes
  1206. Revision 1.22 2000/05/29 11:09:14 pierre
  1207. + New bunch of Gabor's changes: see fixes.txt
  1208. Revision 1.21 2000/05/02 08:42:29 pierre
  1209. * new set of Gabor changes: see fixes.txt
  1210. Revision 1.20 2000/04/25 08:42:36 pierre
  1211. * New Gabor changes : see fixes.txt
  1212. Revision 1.19 2000/04/18 11:42:39 pierre
  1213. lot of Gabor changes : see fixes.txt
  1214. Revision 1.18 2000/03/21 23:19:13 pierre
  1215. + TrimEndSlash and CompareText by Gabor
  1216. Revision 1.17 2000/03/20 19:19:45 pierre
  1217. * LFN support in streams
  1218. Revision 1.16 2000/03/14 13:36:12 pierre
  1219. * error for unexistant file in GetFileTime fixed
  1220. Revision 1.15 2000/02/07 11:45:11 pierre
  1221. + TUnsortedStringCollection CreateFrom/Assign/GetItem/PutItem from Gabor
  1222. Revision 1.14 2000/01/20 00:30:32 pierre
  1223. * Result of GetShortPathName is checked
  1224. Revision 1.13 2000/01/17 12:20:03 pierre
  1225. * uses windows needed for GetShortName
  1226. Revision 1.12 2000/01/14 15:36:43 pierre
  1227. + GetShortFileName used for tcodeeditor file opening
  1228. Revision 1.11 2000/01/05 17:27:20 pierre
  1229. + linecomplete arg for ReadlnFromStream
  1230. Revision 1.10 2000/01/03 11:38:35 michael
  1231. Changes from Gabor
  1232. Revision 1.9 1999/12/01 16:19:46 pierre
  1233. + GetFileTime moved here
  1234. Revision 1.8 1999/10/25 16:39:03 pierre
  1235. + GetPChar to avoid nil pointer problems
  1236. Revision 1.7 1999/09/13 11:44:00 peter
  1237. * fixes from gabor, idle event, html fix
  1238. Revision 1.6 1999/08/24 22:01:48 pierre
  1239. * readlnfromstream length check added
  1240. Revision 1.5 1999/08/03 20:22:45 peter
  1241. + TTab acts now on Ctrl+Tab and Ctrl+Shift+Tab...
  1242. + Desktop saving should work now
  1243. - History saved
  1244. - Clipboard content saved
  1245. - Desktop saved
  1246. - Symbol info saved
  1247. * syntax-highlight bug fixed, which compared special keywords case sensitive
  1248. (for ex. 'asm' caused asm-highlighting, while 'ASM' didn't)
  1249. * with 'whole words only' set, the editor didn't found occourences of the
  1250. searched text, if the text appeared previously in the same line, but didn't
  1251. satisfied the 'whole-word' condition
  1252. * ^QB jumped to (SelStart.X,SelEnd.X) instead of (SelStart.X,SelStart.Y)
  1253. (ie. the beginning of the selection)
  1254. * when started typing in a new line, but not at the start (X=0) of it,
  1255. the editor inserted the text one character more to left as it should...
  1256. * TCodeEditor.HideSelection (Ctrl-K+H) didn't update the screen
  1257. * Shift shouldn't cause so much trouble in TCodeEditor now...
  1258. * Syntax highlight had problems recognizing a special symbol if it was
  1259. prefixed by another symbol character in the source text
  1260. * Auto-save also occours at Dos shell, Tool execution, etc. now...
  1261. Revision 1.4 1999/04/07 21:56:06 peter
  1262. + object support for browser
  1263. * html help fixes
  1264. * more desktop saving things
  1265. * NODEBUG directive to exclude debugger
  1266. Revision 1.2 1999/03/08 14:58:22 peter
  1267. + prompt with dialogs for tools
  1268. Revision 1.1 1999/03/01 15:51:43 peter
  1269. + Log
  1270. }