more refact using helpers

This commit is contained in:
Basile Burg 2016-01-31 12:13:48 +01:00
parent 7d1bfc6214
commit e0e9cbac8f
23 changed files with 90 additions and 85 deletions

View File

@ -28,9 +28,6 @@ type
TCECompiler = (dmd, gdc, ldc); TCECompiler = (dmd, gdc, ldc);
type
// aliased to get a custom prop inspector // aliased to get a custom prop inspector
TCEPathname = type string; TCEPathname = type string;
TCEFilename = type string; TCEFilename = type string;
@ -58,6 +55,7 @@ type
function fileExists: boolean; function fileExists: boolean;
function dirExists: boolean; function dirExists: boolean;
function upperCase: string; function upperCase: string;
function length: integer;
end; end;
(** (**
@ -368,6 +366,11 @@ begin
exit(sysutils.upperCase(self)); exit(sysutils.upperCase(self));
end; end;
function TStringHelper.length: integer;
begin
exit(system.length(self));
end;
{$IFDEF LINUX} {$IFDEF LINUX}
constructor TCheckedAsyncProcess.Create(aOwner: TComponent); constructor TCheckedAsyncProcess.Create(aOwner: TComponent);
begin begin
@ -495,8 +498,8 @@ var
dir: string; dir: string;
begin begin
dir := ExtractFileDrive(src); dir := ExtractFileDrive(src);
if length(dir) > 0 then if dir.length > 0 then
result := src[length(dir)+1..length(src)] result := src[dir.length+1..src.length]
else else
result := src; result := src;
i := pos(invalid, result); i := pos(invalid, result);
@ -595,20 +598,20 @@ var
drv: string; drv: string;
pth1: string; pth1: string;
begin begin
if length(aPath) <= charThresh then if aPath.length <= charThresh then
exit(aPath); exit(aPath);
drv := extractFileDrive(aPath); drv := extractFileDrive(aPath);
i := length(aPath); i := aPath.length;
while(i <> length(drv)+1) do while(i <> drv.length+1) do
begin begin
Inc(sepCnt, Byte(aPath[i] = directorySeparator)); Inc(sepCnt, Byte(aPath[i] = directorySeparator));
if sepCnt = 2 then if sepCnt = 2 then
break; break;
Dec(i); Dec(i);
end; end;
pth1 := aPath[i..length(aPath)]; pth1 := aPath[i..aPath.length];
exit( format('%s%s...%s',[drv,directorySeparator,pth1]) ); exit(format('%s%s...%s', [drv, directorySeparator, pth1]));
end; end;
function getUserDataPath: string; function getUserDataPath: string;
@ -624,7 +627,7 @@ begin
{$ENDIF} {$ENDIF}
if not DirectoryExists(result) then if not DirectoryExists(result) then
raise Exception.Create('Coedit failed to retrieve the user data folder'); raise Exception.Create('Coedit failed to retrieve the user data folder');
if result[length(result)] <> DirectorySeparator then if result[result.length] <> DirectorySeparator then
result += directorySeparator; result += directorySeparator;
end; end;
@ -708,11 +711,11 @@ begin
if aPath.isEmpty then if aPath.isEmpty then
exit; exit;
// //
if aPath[length(aPath)] = '*' then if aPath[aPath.length] = '*' then
begin begin
pth := aPath[1..length(aPath)-1]; pth := aPath[1..aPath.length-1];
if pth[length(pth)] in ['/', '\'] then if pth[pth.length] in ['/', '\'] then
pth := pth[1..length(pth)-1]; pth := pth[1..pth.length-1];
if not pth.dirExists then exit(false); if not pth.dirExists then exit(false);
// //
files := TStringList.Create; files := TStringList.Create;
@ -930,7 +933,7 @@ var
value: char = #0; value: char = #0;
le: string = LineEnding; le: string = LineEnding;
begin begin
result := length(le); result := le.length;
if not fileExists(aFilename) then if not fileExists(aFilename) then
exit; exit;
with TMemoryStream.Create do with TMemoryStream.Create do
@ -1139,7 +1142,7 @@ begin
exit; exit;
if str[1] = ';' then if str[1] = ';' then
result := true; result := true;
if (length(str) > 1) and (str[1..2] = '//') then if (str.length > 1) and (str[1..2] = '//') then
result := true; result := true;
end; end;

View File

@ -238,7 +238,7 @@ end;
procedure TCEDcdWrapper.writeSourceToInput; procedure TCEDcdWrapper.writeSourceToInput;
begin begin
fInputSource := fDoc.Text; fInputSource := fDoc.Text;
fClient.Input.Write(fInputSource[1], length(fInputSource)); fClient.Input.Write(fInputSource[1], fInputSource.length);
fClient.CloseInput; fClient.CloseInput;
end; end;
@ -279,7 +279,7 @@ begin
// //
fTempLines.Delete(0); fTempLines.Delete(0);
tips := fTempLines.Text; tips := fTempLines.Text;
tips := tips[1..length(tips)-1]; tips := tips[1..tips.length-1];
end; end;
procedure TCEDcdWrapper.getComplAtCursor(aList: TStrings); procedure TCEDcdWrapper.getComplAtCursor(aList: TStrings);
@ -312,8 +312,8 @@ begin
for i := 1 to fTempLines.Count-1 do for i := 1 to fTempLines.Count-1 do
begin begin
item := fTempLines.Strings[i]; item := fTempLines.Strings[i];
kind := item[length(item)]; kind := item[item.length];
setLength(item, length(item)-2); setLength(item, item.length-2);
case kind of case kind of
'c': item += ' (class) '; 'c': item += ' (class) ';
'i': item += ' (interface) '; 'i': item += ' (interface) ';
@ -402,7 +402,7 @@ begin
i := Pos(#9, str); i := Pos(#9, str);
if i = -1 then if i = -1 then
exit; exit;
loc := str[i+1..length(str)]; loc := str[i+1..str.length];
aFilename := str[1..i-1]; aFilename := str[1..i-1];
loc := ReplaceStr(loc, LineEnding, ''); loc := ReplaceStr(loc, LineEnding, '');
aPosition := strToIntDef(loc, -1); aPosition := strToIntDef(loc, -1);

View File

@ -264,7 +264,7 @@ begin
prc.Executable:= exeFullName('dfmt' + exeExt); prc.Executable:= exeFullName('dfmt' + exeExt);
prc.Execute; prc.Execute;
inp := fDoc.Lines.Text; inp := fDoc.Lines.Text;
prc.Input.Write(inp[1], length(inp)); prc.Input.Write(inp[1], inp.length);
prc.CloseInput; prc.CloseInput;
while prc.Running do (*!*); while prc.Running do (*!*);
try try

View File

@ -247,7 +247,7 @@ begin
saver.WriteDWord($00BFBBEF); saver.WriteDWord($00BFBBEF);
saver.Position:=saver.Position-1; saver.Position:=saver.Position-1;
end; end;
saver.Write(str[1], length(str)); saver.Write(str[1], str.length);
saver.SaveToFile(fFilename); saver.SaveToFile(fFilename);
finally finally
saver.Free; saver.Free;

View File

@ -446,7 +446,7 @@ begin
len := getLineEndingLength(fDoc.fileName); len := getLineEndingLength(fDoc.fileName);
for i := 0 to fDoc.Lines.Count-1 do for i := 0 to fDoc.Lines.Count-1 do
begin begin
linelen := length(fDoc.Lines.Strings[i]); linelen := fDoc.Lines.Strings[i].length;
if sum + linelen + len > srcpos then if sum + linelen + len > srcpos then
begin begin
fDoc.CaretY := i + 1; fDoc.CaretY := i + 1;

View File

@ -483,8 +483,8 @@ begin
category := 'Code editor'; category := 'Code editor';
identifier:= shrct.actionName; identifier:= shrct.actionName;
// SynEdit shortcuts start with 'ec' // SynEdit shortcuts start with 'ec'
if length(identifier) > 2 then if identifier.length > 2 then
identifier := identifier[3..length(identifier)]; identifier := identifier[3..identifier.length];
aShortcut := shrct.shortcut; aShortcut := shrct.shortcut;
// //
fShortcutCount += 1; fShortcutCount += 1;
@ -501,9 +501,9 @@ begin
for i:= 0 to fShortCuts.Count-1 do for i:= 0 to fShortCuts.Count-1 do
begin begin
shc := TCEPersistentShortcut(fShortCuts.Items[i]); shc := TCEPersistentShortcut(fShortCuts.Items[i]);
if length(shc.actionName) > 2 then if shc.actionName.length > 2 then
begin begin
if shc.actionName[3..length(shc.actionName)] <> identifier then if shc.actionName[3..shc.actionName.length] <> identifier then
continue; continue;
end else if shc.actionName <> identifier then end else if shc.actionName <> identifier then
continue; continue;

View File

@ -286,7 +286,7 @@ begin
for i:= 0 to fFileLineBrks.Count-1 do for i:= 0 to fFileLineBrks.Count-1 do
begin begin
str := 'break ' + fFileLineBrks.Strings[i] + ':' + intToStr(PtrUInt(fFileLineBrks.Objects[i])) + #10; str := 'break ' + fFileLineBrks.Strings[i] + ':' + intToStr(PtrUInt(fFileLineBrks.Objects[i])) + #10;
fGdb.Input.Write(str[1], length(str)); fGdb.Input.Write(str[1], str.length);
end; end;
// break on druntime exceptions heper + throw' // break on druntime exceptions heper + throw'
fGdb.OnReadData := @processSilently; fGdb.OnReadData := @processSilently;
@ -354,7 +354,7 @@ begin
aCommand += #10; aCommand += #10;
if assigned(outputCatcher) then if assigned(outputCatcher) then
fGdb.OnReadData := outputCatcher; fGdb.OnReadData := outputCatcher;
fGdb.Input.Write(aCommand[1], length(aCommand)); fGdb.Input.Write(aCommand[1], aCommand.length);
end; end;
procedure TCEGdbWidget.infoRegs; procedure TCEGdbWidget.infoRegs;

View File

@ -181,8 +181,8 @@ begin
lst := TStringList.Create; lst := TStringList.Create;
try try
dir := itm.libFile; dir := itm.libFile;
if itm.libFile[length(dir)] = DirectorySeparator then if itm.libFile[dir.length] = DirectorySeparator then
dir := dir[1..length(dir)-1]; dir := dir[1..dir.length-1];
listFiles(lst, dir); listFiles(lst, dir);
for j:= 0 to lst.Count-1 do for j:= 0 to lst.Count-1 do
begin begin

View File

@ -1849,7 +1849,7 @@ begin
if (j > -1) and (j < i) then if (j > -1) and (j < i) then
continue; continue;
// not a switch // not a switch
if length(cur) < 2 then if cur.length < 2 then
continue; continue;
if cur[1] <> '-' then if cur[1] <> '-' then
continue; continue;
@ -1861,8 +1861,8 @@ begin
RemoveTrailingChars(cur, [#0..#30]); RemoveTrailingChars(cur, [#0..#30]);
fRunnableSw += (cur + #13); fRunnableSw += (cur + #13);
end; end;
if fRunnableSw.isNotEmpty and (fRunnableSw[length(fRunnableSw)] = #13) then if fRunnableSw.isNotEmpty and (fRunnableSw[fRunnableSw.length] = #13) then
fRunnableSw := fRunnableSw[1..length(fRunnableSw)-1]; fRunnableSw := fRunnableSw[1..fRunnableSw.length-1];
if fRunnableSw.isEmpty then if fRunnableSw.isEmpty then
fRunnableSw := '-vcolumns'#13'-w'#13'-wi'; fRunnableSw := '-vcolumns'#13'-w'#13'-wi';
// //
@ -1884,7 +1884,7 @@ begin
if fDoc.Lines.Count = 0 then exit; if fDoc.Lines.Count = 0 then exit;
firstlineFlags := fDoc.Lines[0]; firstlineFlags := fDoc.Lines[0];
i := length(firstlineFlags); i := firstlineFlags.length;
if ( i > 18) then if ( i > 18) then
begin begin
if firstlineFlags.upperCase[1..17] = '#!RUNNABLE-FLAGS:' then if firstlineFlags.upperCase[1..17] = '#!RUNNABLE-FLAGS:' then

View File

@ -801,7 +801,7 @@ begin
for i := 0 to fToDemangle.Count-1 do for i := 0 to fToDemangle.Count-1 do
begin begin
str := fToDemangle.Strings[i] + LineEnding; str := fToDemangle.Strings[i] + LineEnding;
fDemangler.Input.Write(str[1], length(str)); fDemangler.Input.Write(str[1], str.length);
end; end;
fDemangler.CloseInput; fDemangler.CloseInput;
end; end;
@ -954,7 +954,7 @@ begin
result := amkBub; result := amkBub;
while(true) do while(true) do
begin begin
if pos > length(aMessg) then if pos > aMessg.length then
exit; exit;
if aMessg[pos] in [#0..#32, ',', ':', ';'] then if aMessg[pos] in [#0..#32, ',', ':', ';'] then
begin begin
@ -988,16 +988,16 @@ begin
i := 1; i := 1;
while (true) do while (true) do
begin begin
if i > length(aMessage) then exit; if i > aMessage.length then exit;
if aMessage[i] = '(' then if aMessage[i] = '(' then
begin begin
inc(i); inc(i);
if i > length(aMessage) then exit; if i > aMessage.length then exit;
while( isNumber(aMessage[i]) or (aMessage[i] = ',') or (aMessage[i] = ':')) do while( isNumber(aMessage[i]) or (aMessage[i] = ',') or (aMessage[i] = ':')) do
begin begin
ident += aMessage[i]; ident += aMessage[i];
inc(i); inc(i);
if i > length(aMessage) then exit; if i > aMessage.length then exit;
end; end;
if aMessage[i] = ')' then if aMessage[i] = ')' then
begin begin
@ -1008,7 +1008,7 @@ begin
else else
begin begin
result.y := strToIntDef(ident[1..j-1], -1); result.y := strToIntDef(ident[1..j-1], -1);
result.x := strToIntDef(ident[j+1..length(ident)], -1); result.x := strToIntDef(ident[j+1..ident.length], -1);
end; end;
exit; exit;
end; end;
@ -1027,12 +1027,12 @@ begin
while (true) do while (true) do
begin begin
inc(i); inc(i);
if i > length(aMessage) then if i > aMessage.length then
exit; exit;
// '(': line will be indicated after fname // '(': line will be indicated after fname
// -mixin: dmd, error in mixin(token string) '<fname>-mixinXX<index>(' // -mixin: dmd, error in mixin(token string) '<fname>-mixinXX<index>('
if isEditable(ident.extractFileExt) and ((aMessage[i] = '(') or if isEditable(ident.extractFileExt) and ((aMessage[i] = '(') or
((aMessage[i] = '-') and (i < length(aMessage)-5) ((aMessage[i] = '-') and (i < aMessage.length-5)
and (aMessage[i..i+5] = '-mixin'))) then and (aMessage[i..i+5] = '-mixin'))) then
begin begin
// absolute fname // absolute fname

View File

@ -466,7 +466,7 @@ begin
fname := PString(lstFiles.Selected.Data)^; fname := PString(lstFiles.Selected.Data)^;
if not fname.fileExists then exit; if not fname.fileExists then exit;
{$IFNDEF WINDOWS} {$IFNDEF WINDOWS}
fname := fname[2..length(fname)]; fname := fname[2..fname.length];
{$ENDIF} {$ENDIF}
if isValidNativeProject(fname) then if isValidNativeProject(fname) then
begin begin
@ -572,7 +572,7 @@ begin
for drv in lst do for drv in lst do
begin begin
itm := Tree.Items.Add(nil, drv); itm := Tree.Items.Add(nil, drv);
itm.Data := NewStr(drv[1..length(drv)-1]); itm.Data := NewStr(drv[1..drv.length-1]);
treeScanSubFolders(itm); treeScanSubFolders(itm);
end; end;
finally finally
@ -662,7 +662,7 @@ var
begin begin
result := false; result := false;
{$IFDEF LINUX} {$IFDEF LINUX}
if (length(aPath) >= 2) and (aPath[2] <> '/') then if (aPath.length >= 2) and (aPath[2] <> '/') then
aPath := '/' + aPath; aPath := '/' + aPath;
{$ENDIF} {$ENDIF}
for i := 0 to aRoot.Count-1 do for i := 0 to aRoot.Count-1 do
@ -670,7 +670,7 @@ begin
if aRoot.Items[i].Data.isNil then if aRoot.Items[i].Data.isNil then
continue; continue;
str := PString(aRoot.Items[i].Data)^; str := PString(aRoot.Items[i].Data)^;
if SameText(LeftStr(aPath, length(str)), str) then if SameText(LeftStr(aPath, str.length), str) then
begin begin
result := true; result := true;
Tree.Selected := aRoot.Items[i]; Tree.Selected := aRoot.Items[i];

View File

@ -498,7 +498,7 @@ var
// hint for the common dir // hint for the common dir
dirHint := fSrcs.Strings[i]; dirHint := fSrcs.Strings[i];
while (dirHint[1] = '.') or (dirHint[1] = DirectorySeparator) do while (dirHint[1] = '.') or (dirHint[1] = DirectorySeparator) do
dirHint := dirHint[2..length(dirHint)]; dirHint := dirHint[2..dirHint.length];
ini := fFilename.extractFilePath; ini := fFilename.extractFilePath;
if not selectDirectory( format('select the folder (that contains "%s")',[dirHint]), ini, newdir) then if not selectDirectory( format('select the folder (that contains "%s")',[dirHint]), ini, newdir) then
exit; exit;
@ -506,7 +506,7 @@ var
begin begin
src := fSrcs.Strings[i]; src := fSrcs.Strings[i];
while (src[1] = '.') or (src[1] = DirectorySeparator) do while (src[1] = '.') or (src[1] = DirectorySeparator) do
src := src[2..length(src)]; src := src[2..src.length];
if fileExists(expandFilenameEx(fBasePath, newdir + DirectorySeparator + src)) then if fileExists(expandFilenameEx(fBasePath, newdir + DirectorySeparator + src)) then
fSrcs.Strings[i] := ExtractRelativepath(fBasePath, newdir + DirectorySeparator + src); fSrcs.Strings[i] := ExtractRelativepath(fBasePath, newdir + DirectorySeparator + src);
hasPatched := true; hasPatched := true;

View File

@ -250,7 +250,7 @@ begin
if aEditor.GetComponent(0) is TComponent then if aEditor.GetComponent(0) is TComponent then
begin begin
nme := aEditor.GetPropInfo^.Name; nme := aEditor.GetPropInfo^.Name;
len := length(nme); len := nme.length;
// TODO-cbugfix: filtering does not work on sub componenets 'e.g D2HL options) // TODO-cbugfix: filtering does not work on sub componenets 'e.g D2HL options)
if (len > 2) and (nme[len - 2 .. len] = 'Tag') then if (len > 2) and (nme[len - 2 .. len] = 'Tag') then
aShow := false aShow := false

View File

@ -119,7 +119,7 @@ begin
inp := symbolExpander.get(txtInp.Text) + lineEnding inp := symbolExpander.get(txtInp.Text) + lineEnding
else else
inp := txtInp.Text + lineEnding; inp := txtInp.Text + lineEnding;
fProc.Input.Write(inp[1], length(inp)); fProc.Input.Write(inp[1], inp.length);
txtInp.Text := ''; txtInp.Text := '';
end; end;

View File

@ -186,10 +186,10 @@ var
begin begin
inherited; inherited;
for i := fMrReplacements.Count-1 downto 0 do for i := fMrReplacements.Count-1 downto 0 do
if length(fMrReplacements[i]) > 128 then if fMrReplacements[i].length > 128 then
fMrReplacements.Delete(i); fMrReplacements.Delete(i);
for i := fMrSearches.Count-1 downto 0 do for i := fMrSearches.Count-1 downto 0 do
if length(fMrSearches[i]) > 128 then if fMrSearches[i].length > 128 then
fMrSearches.Delete(i); fMrSearches.Delete(i);
end; end;
{$ENDREGION} {$ENDREGION}
@ -384,7 +384,7 @@ begin
if chkBack.Checked then if chkBack.Checked then
fDoc.CaretX := fDoc.CaretX - 1 fDoc.CaretX := fDoc.CaretX - 1
else else
fDoc.CaretX := fDoc.CaretX + length(fToFind); fDoc.CaretX := fDoc.CaretX + fToFind.length;
end; end;
if fDoc.SearchReplace(fToFind, '', getOptions) = 0 then if fDoc.SearchReplace(fToFind, '', getOptions) = 0 then
dlgOkInfo('the expression cannot be found') dlgOkInfo('the expression cannot be found')
@ -420,7 +420,7 @@ begin
if chkBack.Checked then if chkBack.Checked then
fDoc.CaretX := fDoc.CaretX - 1 fDoc.CaretX := fDoc.CaretX - 1
else else
fDoc.CaretX := fDoc.CaretX + length(fToFind); fDoc.CaretX := fDoc.CaretX + fToFind.length;
end; end;
if fDoc.SearchReplace(fToFind, fReplaceWth, getOptions + [ssoReplace]) <> 0 then if fDoc.SearchReplace(fToFind, fReplaceWth, getOptions + [ssoReplace]) <> 0 then
fHasSearched := true; fHasSearched := true;

View File

@ -6,6 +6,8 @@ object CEShortcutEditor: TCEShortcutEditor
ClientHeight = 463 ClientHeight = 463
ClientWidth = 424 ClientWidth = 424
TabOrder = 0 TabOrder = 0
DesignLeft = 678
DesignTop = 216
object Panel1: TPanel object Panel1: TPanel
Left = 0 Left = 0
Height = 463 Height = 463

View File

@ -6,7 +6,7 @@ interface
uses uses
Classes, SysUtils, FileUtil, TreeFilterEdit, Forms, Controls, Menus, Graphics, Classes, SysUtils, FileUtil, TreeFilterEdit, Forms, Controls, Menus, Graphics,
ExtCtrls, LCLProc, ComCtrls, StdCtrls, Buttons, LCLType, ExtCtrls, LCLProc, ComCtrls, StdCtrls, Buttons, LCLType, PropEdits,
ce_sharedres, ce_observer, ce_interfaces, ce_common, ce_writableComponent, ce_sharedres, ce_observer, ce_interfaces, ce_common, ce_writableComponent,
ce_dialogs; ce_dialogs;

View File

@ -354,12 +354,12 @@ begin
for i := fMacros.Count-1 downto 0 do for i := fMacros.Count-1 downto 0 do
begin begin
text := fMacros.Strings[i]; text := fMacros.Strings[i];
if length(text) >= 4 then if text.length >= 4 then
if text[1] = '$' then if text[1] = '$' then
if Pos('=', text) > 2 then if Pos('=', text) > 2 then
begin begin
macro := fMacros.Names[i]; macro := fMacros.Names[i];
if (macro[length(macro)] in ['a'..'z', 'A'..'Z', '0'..'9']) then if (macro[macro.length] in ['a'..'z', 'A'..'Z', '0'..'9']) then
continue; continue;
end; end;
fMacros.Delete(i); fMacros.Delete(i);

View File

@ -671,7 +671,7 @@ begin
fToolProc.CurrentDirectory := ExtractFileDir(Application.ExeName); fToolProc.CurrentDirectory := ExtractFileDir(Application.ExeName);
fToolProc.Execute; fToolProc.Execute;
str := fDoc.Text; str := fDoc.Text;
fToolProc.Input.Write(str[1], length(str)); fToolProc.Input.Write(str[1], str.length);
fToolProc.CloseInput; fToolProc.CloseInput;
end; end;

View File

@ -144,7 +144,6 @@ begin
exit; exit;
fNeedUpdate := true; fNeedUpdate := true;
end; end;
{$ENDREGION} {$ENDREGION}
{$REGION Symbol things ---------------------------------------------------------} {$REGION Symbol things ---------------------------------------------------------}
@ -259,7 +258,7 @@ begin
end; end;
end; end;
until until
i = length(symString); i = symString.length;
elems.Add(elem); elems.Add(elem);
elem := ''; elem := '';
for i := 0 to elems.Count - 1 do for i := 0 to elems.Count - 1 do

View File

@ -376,7 +376,7 @@ begin
fname := getCoeditDocPath + 'editorcache' + DirectorySeparator; fname := getCoeditDocPath + 'editorcache' + DirectorySeparator;
ForceDirectories(fname); ForceDirectories(fname);
chksm := crc32(0, nil, 0); chksm := crc32(0, nil, 0);
chksm := crc32(chksm, @tempn[1], length(tempn)); chksm := crc32(chksm, @tempn[1], tempn.length);
fname := fname + format('%.8X.txt', [chksm]); fname := fname + format('%.8X.txt', [chksm]);
saveToFile(fname); saveToFile(fname);
end; end;
@ -392,7 +392,7 @@ begin
// //
fname := getCoeditDocPath + 'editorcache' + DirectorySeparator; fname := getCoeditDocPath + 'editorcache' + DirectorySeparator;
chksm := crc32(0, nil, 0); chksm := crc32(0, nil, 0);
chksm := crc32(chksm, @tempn[1], length(tempn)); chksm := crc32(chksm, @tempn[1], tempn.length);
fname := fname + format('%.8X.txt', [chksm]); fname := fname + format('%.8X.txt', [chksm]);
// //
if not fname.fileExists then exit; if not fname.fileExists then exit;
@ -765,9 +765,9 @@ begin
if beg.isEmpty then exit; if beg.isEmpty then exit;
while true do while true do
begin begin
if (i > length(beg)) or not (beg[i] in blk) then if (i > beg.length) or not (beg[i] in blk) then
break; break;
i += 1 i += 1;
end; end;
i -= 1; i -= 1;
editor.BeginUndoBlock; editor.BeginUndoBlock;
@ -958,7 +958,7 @@ procedure TCESynMemo.completionCodeCompletion(var Value: string;
Shift: TShiftState); Shift: TShiftState);
begin begin
// warning: '20' depends on ce_dcd, case knd of, string literals length // warning: '20' depends on ce_dcd, case knd of, string literals length
Value := Value[1..length(Value)-20]; Value := Value[1..Value.length-20];
end; end;
function TCESynMemo.completionItemPaint(const AKey: string; ACanvas: TCanvas;X, Y: integer; function TCESynMemo.completionItemPaint(const AKey: string; ACanvas: TCanvas;X, Y: integer;
@ -972,8 +972,8 @@ begin
// otherwise always at least 20 chars but... // otherwise always at least 20 chars but...
// ... '20' depends on ce_dcd, case knd of, string literals length // ... '20' depends on ce_dcd, case knd of, string literals length
result := true; result := true;
lft := AKey[1 .. length(AKey)-20]; lft := AKey[1 .. AKey.length-20];
rgt := AKey[length(AKey)-19 .. length(AKey)]; rgt := AKey[AKey.length-19 .. AKey.length];
ACanvas.Font.Style := [fsBold]; ACanvas.Font.Style := [fsBold];
len := ACanvas.TextExtent(lft).cx; len := ACanvas.TextExtent(lft).cx;
ACanvas.TextOut(2 + X , Y, lft); ACanvas.TextOut(2 + X , Y, lft);
@ -1010,19 +1010,19 @@ var
i: integer; i: integer;
begin begin
fIdentifier := GetWordAtRowCol(LogicalCaretXY); fIdentifier := GetWordAtRowCol(LogicalCaretXY);
if (length(fIdentifier) > 2) and (not SelAvail) then if (fIdentifier.length > 2) and (not SelAvail) then
SetHighlightSearch(fIdentifier, fMatchIdentOpts) SetHighlightSearch(fIdentifier, fMatchIdentOpts)
else if SelAvail then else if SelAvail then
begin begin
str := SelText; str := SelText;
for i := 1 to length(str) do for i := 1 to str.length do
begin begin
if not (str[i] in [' ', #10, #13]) then if not (str[i] in [' ', #10, #13]) then
begin begin
SetHighlightSearch(str, fMatchSelectionOpts); SetHighlightSearch(str, fMatchSelectionOpts);
break; break;
end; end;
if i = length(str) then if i = str.length then
SetHighlightSearch('', []); SetHighlightSearch('', []);
end; end;
end end
@ -1194,7 +1194,7 @@ var
begin begin
result := 0; result := 0;
if fMousePos.y-1 > Lines.Count-1 then exit; if fMousePos.y-1 > Lines.Count-1 then exit;
llen := length(Lines.Strings[fMousePos.y-1]); llen := Lines.Strings[fMousePos.y-1].length;
if fMousePos.X > llen then exit; if fMousePos.X > llen then exit;
// //
// something note really clear: // something note really clear:
@ -1202,7 +1202,7 @@ begin
// TCESynMemo.getMouseFileBytePos works when using the line ending from the system. // TCESynMemo.getMouseFileBytePos works when using the line ending from the system.
len := getSysLineEndLen; len := getSysLineEndLen;
for i:= 0 to fMousePos.y-2 do for i:= 0 to fMousePos.y-2 do
result += length(Lines.Strings[i]) + len; result += Lines.Strings[i].length + len;
result += fMousePos.x; result += fMousePos.x;
end; end;
{$ENDREGION --------------------------------------------------------------------} {$ENDREGION --------------------------------------------------------------------}
@ -1270,7 +1270,7 @@ begin
begin begin
if fAutoCloseCurlyBrace = autoCloseAlways then if fAutoCloseCurlyBrace = autoCloseAlways then
curlyBraceCloseAndIndent(self) curlyBraceCloseAndIndent(self)
else if (CaretY = Lines.Count) and (CaretX = length(LineText)+1) then else if (CaretY = Lines.Count) and (CaretX = LineText.length+1) then
curlyBraceCloseAndIndent(self); curlyBraceCloseAndIndent(self);
end; end;
end; end;

View File

@ -224,8 +224,8 @@ begin
begin begin
setLength(inp, previous.process.OutputStack.Size); setLength(inp, previous.process.OutputStack.Size);
previous.process.OutputStack.Position:=0; previous.process.OutputStack.Position:=0;
previous.process.OutputStack.Read(inp[1], length(inp)); previous.process.OutputStack.Read(inp[1], inp.length);
fProcess.Input.Write(inp[1], length(inp)); fProcess.Input.Write(inp[1], inp.length);
fProcess.CloseInput; fProcess.CloseInput;
end; end;
end; end;
@ -420,7 +420,7 @@ begin
and aTool.fProcess.Input.isNotNil then and aTool.fProcess.Input.isNotNil then
begin begin
txt := fDoc.Text; txt := fDoc.Text;
aTool.fProcess.Input.Write(txt[1], length(txt)); aTool.fProcess.Input.Write(txt[1], txt.length);
aTool.fProcess.CloseInput; aTool.fProcess.CloseInput;
end; end;
end; end;

View File

@ -298,9 +298,9 @@ To do so, the application option _Native project compiler_ must be set according
# DUB projects. # DUB projects.
Since the version 2 alpha 1, Coedit also handles DUB projects. Since the version 2 alpha 1, Coedit also handles [DUB](http://code.dlang.org/getting_started) projects.
DUB project description must be in JSON format, SDL in not supported. DUB project description must be in [JSON format](http://code.dlang.org/package-format?lang=json), [SDL](http://code.dlang.org/package-format?lang=sdl) in not supported.
DUB projects are handled exactly as CE projects are. The _project_ menu proposes the same features. DUB projects are handled exactly as CE projects are. The _project_ menu proposes the same features.
However the configuration is done in another widget, see the [dedicated paragraph][lnk_widg_dub]. However the configuration is done in another widget, see the [dedicated paragraph][lnk_widg_dub].
@ -541,7 +541,7 @@ Coedit handles the task automatically (see later in the project configuration wi
- ![](https://raw.githubusercontent.com/BBasile/Coedit/master/icons/arrow/arrow_up.png) **/** ![](https://raw.githubusercontent.com/BBasile/Coedit/master/icons/arrow/arrow_down.png): change selected entry position. - ![](https://raw.githubusercontent.com/BBasile/Coedit/master/icons/arrow/arrow_up.png) **/** ![](https://raw.githubusercontent.com/BBasile/Coedit/master/icons/arrow/arrow_down.png): change selected entry position.
- ![](https://raw.githubusercontent.com/BBasile/Coedit/master/icons/book/book_link.png): if the current project _binaryKind_ is set to _staticlib_ then the _libman_ will use its parameters to create an entry. This avoids to browse in the dialogs, for example if you wish to setup several [_metad_][lnk_metad] items. Note that sometimes the sources root folder has to be adjusted. - ![](https://raw.githubusercontent.com/BBasile/Coedit/master/icons/book/book_link.png): if the current project _binaryKind_ is set to _staticlib_ then the _libman_ will use its parameters to create an entry. This avoids to browse in the dialogs, for example if you wish to setup several [_metad_][lnk_metad] items. Note that sometimes the sources root folder has to be adjusted.
- ![](https://raw.githubusercontent.com/BBasile/Coedit/master/icons/book/book_open.png): if the selected item defines a _project_ then closes current project and opens the one matching to the entry. - ![](https://raw.githubusercontent.com/BBasile/Coedit/master/icons/book/book_open.png): if the selected item defines a _project_ then closes current project and opens the one matching to the entry.
- ![](https://raw.githubusercontent.com/BBasile/Coedit/master/icons/other/dub_small.png): allows to fetch the master version of a DUB registry item. When the button is clicked, an input field allows to type the library name, after what, if the name is valid, the library will be downloaded, compiled and a new entry automatically filled. This features is actually more useful for the CE projects and the runnable modules as the dependencies of a DUB projects are handled automatically. It allows to use every DUB library in a CE project, even if the package doesn't include a CE project file. - ![](https://raw.githubusercontent.com/BBasile/Coedit/master/icons/other/dub_small.png): allows to fetch the master version of a [DUB registry item](http://code.dlang.org/). When the button is clicked, an input field allows to type the library name, after what, if the name is valid, the library will be downloaded, compiled and a new entry automatically filled. This features is actually more useful for the CE projects and the runnable modules as the dependencies of a DUB projects are handled automatically. It allows to use every DUB library in a CE project, even if the package doesn't include a CE project file.
- ![](https://raw.githubusercontent.com/BBasile/Coedit/master/icons/book/book_edit.png): edit the item alias. - ![](https://raw.githubusercontent.com/BBasile/Coedit/master/icons/book/book_edit.png): edit the item alias.
- ![](https://raw.githubusercontent.com/BBasile/Coedit/master/icons/folder/folder_brick.png): select the library file. In some rare case, this field can be omitted (for example if the library file is set in the _sc.ini_). - ![](https://raw.githubusercontent.com/BBasile/Coedit/master/icons/folder/folder_brick.png): select the library file. In some rare case, this field can be omitted (for example if the library file is set in the _sc.ini_).
This can be skipped if the library is only a small orphan _d_ source that's not been compiled as a static library or if the entry is only used for the [DCD][lnk_dcd] completion. This can be skipped if the library is only a small orphan _d_ source that's not been compiled as a static library or if the entry is only used for the [DCD][lnk_dcd] completion.
@ -753,7 +753,8 @@ The DUB project editor is widget is divided in two panels:
![](https://raw.githubusercontent.com/BBasile/CoeditWikiData/master/dub_inspect.png) ![](https://raw.githubusercontent.com/BBasile/CoeditWikiData/master/dub_inspect.png)
The first panel displays the sources list and the combination of _each build type_ with each _build configuration_. Sources can be opened in a new editor by double clicking. To select a configuration defines which type and which configuration will be build by DUB when clicking _compile_ in the _project_ menu. The first panel displays the sources list and the combination of _each build type_ with each _build configuration_. Sources can be opened in a new editor by double clicking.
Selecting a configuration defines which _buildType_ type and which _configuration_ will be build by DUB when clicking _compile_ in the _project_ menu.
Note that it's possible to specify which compiler DUB uses in the application options _dubCompiler_. Note that it's possible to specify which compiler DUB uses in the application options _dubCompiler_.
#### Editor #### Editor
@ -765,7 +766,7 @@ The second panel displays the tree of the project properties. The can be modifie
New properties can be added or removed: New properties can be added or removed:
* ![](https://raw.githubusercontent.com/BBasile/Coedit/master/icons/other/textfield_delete.png): removes the selected property. Note that the effect is not reflected until the project is saved as a file (since Coedit does not communicate directly with DUB). * ![](https://raw.githubusercontent.com/BBasile/Coedit/master/icons/other/textfield_delete.png): removes the selected property. Note that the effect is not reflected until the project is saved as a file (since Coedit does not communicate directly with DUB).
* ![](https://raw.githubusercontent.com/BBasile/Coedit/master/icons/other/textfield_add.png): show a small dialog that allows to add a new value, a new array or new object. This requires to master the DUB format. In the dialog, the value of the text field is only used when an object or a value is added. It matches to the _key_, not the value itself. * ![](https://raw.githubusercontent.com/BBasile/Coedit/master/icons/other/textfield_add.png): shows a small dialog that allows to add a new value, a new array or a new object. This requires to master the [DUB JSON format](http://code.dlang.org/package-format?lang=json). In the dialog, the value of the text field is only used when an object or a value is added. It matches to the _key_, not the value itself.
![](https://raw.githubusercontent.com/BBasile/CoeditWikiData/master/dub_edit2.png) ![](https://raw.githubusercontent.com/BBasile/CoeditWikiData/master/dub_edit2.png)
@ -842,7 +843,7 @@ Toolbar:
A tool can be selected from the left side of the widget. If selected, a property inspector displays the options that can be edited: A tool can be selected from the left side of the widget. If selected, a property inspector displays the options that can be edited:
- clearMessages: if the tool standard output is redirected to the [messages widget][lnk_widg_msg] then the previous messages are cleared before the execution. The output is redirected to the messages when **popUsePipes** is set and if the **nextToolALias** is empty. - clearMessages: if the tool standard output is redirected to the [messages widget][lnk_widg_msg] then the previous messages are cleared before the execution. The output is redirected to the messages when **popUsePipes** is set and if the **nextToolAlias** is empty.
- editorToInput: when set, the content of the current editor is streamed to the tool standard input. - editorToInput: when set, the content of the current editor is streamed to the tool standard input.
- executable: the tool file name. If the system cannot find its path in the environment variables then it must be included. The field can include a [symbolic string][lnk_sym]. - executable: the tool file name. If the system cannot find its path in the environment variables then it must be included. The field can include a [symbolic string][lnk_sym].
- nextToolAlias: defines the alias of another tool that will be launched after this one returns. - nextToolAlias: defines the alias of another tool that will be launched after this one returns.