stylefix and cleanup

This commit is contained in:
Basile Burg 2014-11-10 16:21:42 +01:00
parent aea4d3c945
commit 084a476e5f
9 changed files with 113 additions and 70 deletions

View File

@ -98,9 +98,11 @@ var
outname: string;
begin
lstCdbOut.Clear;
if fProject = nil then exit;
if fProject = nil then
exit;
outname := fProject.outputFilename;
if not fileExists(outname) then exit;
if not fileExists(outname) then
exit;
//
killProcess(fCdbProc);
fCdbProc := TAsyncProcess.create(nil);
@ -120,7 +122,8 @@ procedure TCECdbWidget.btnStepClick(Sender: TObject);
const
cmd = 'p'#13#10;
begin
if fCdbProc = nil then exit;
if fCdbProc = nil then
exit;
fCdbProc.Input.Write(cmd[1], length(cmd));
end;
@ -128,7 +131,8 @@ procedure TCECdbWidget.btnGoClick(Sender: TObject);
const
cmd = 'g'#13#10;
begin
if fCdbProc = nil then exit;
if fCdbProc = nil then
exit;
fCdbProc.Input.Write(cmd[1], length(cmd));
end;
@ -136,7 +140,8 @@ procedure TCECdbWidget.btnDisasmClick(Sender: TObject);
const
cmd = 'u'#13#10;
begin
if fCdbProc = nil then exit;
if fCdbProc = nil then
exit;
fCdbProc.Input.Write(cmd[1], length(cmd));
end;
@ -144,7 +149,8 @@ procedure TCECdbWidget.btnStopClick(Sender: TObject);
const
cmd = 'q'#13#10;
begin
if fCdbProc <> nil then
if fCdbProc <> nil
then
fCdbProc.Input.Write(cmd[1], length(cmd));
killProcess(fCdbProc);
end;
@ -171,7 +177,8 @@ var
lst: TStringList;
cnt: Integer;
begin
if fCdbProc = nil then exit;
if fCdbProc = nil then
exit;
//
lst := TStringList.Create;
try

View File

@ -232,7 +232,8 @@ end;
procedure TReaderEx.ReadPersistent(aValue: TPersistent);
begin
ReadListBegin;
while not EndOfList do ReadProperty(aValue);
while not EndOfList do
ReadProperty(aValue);
ReadListEnd;
end;
@ -250,13 +251,16 @@ end;
procedure TMRUList.clearOutOfRange;
begin
while Count > fMaxCount do delete(Count-1);
while Count > fMaxCount do
delete(Count-1);
end;
procedure TMRUList.setMaxCount(aValue: Integer);
begin
if aValue < 0 then aValue := 0;
if fMaxCount = aValue then exit;
if aValue < 0 then
aValue := 0;
if fMaxCount = aValue then
exit;
clearOutOfRange;
end;
@ -265,30 +269,36 @@ var
i: NativeInt;
begin
i := indexOf(S);
if i = -1 then exit(true);
if i = 0 then exit(false);
if Count < 2 then exit(false);
if i = -1 then
exit(true);
if i = 0 then
exit(false);
if Count < 2 then
exit(false);
exchange(i, i-1);
exit( false);
end;
procedure TMRUList.Put(Index: Integer; const S: string);
begin
if not (checkItem(S)) then exit;
if not (checkItem(S)) then
exit;
inherited;
clearOutOfRange;
end;
procedure TMRUList.InsertItem(Index: Integer; const S: string);
begin
if not (checkItem(S)) then exit;
if not (checkItem(S)) then
exit;
inherited;
clearOutOfRange;
end;
procedure TMRUList.Insert(Index: Integer; const S: string);
begin
if not (checkItem(S)) then exit;
if not (checkItem(S)) then
exit;
inherited;
clearOutOfRange;
end;
@ -299,7 +309,8 @@ var
begin
inherited;
for i := Count-1 downto 0 do
if not fileExists(Strings[i]) then Delete(i);
if not fileExists(Strings[i]) then
Delete(i);
end;
function TMRUFileList.checkItem(const S: string): boolean;
@ -498,7 +509,8 @@ begin
while(i <> length(drv)+1) do
begin
Inc(sepCnt, Byte(aPath[i] = directorySeparator));
if sepCnt = 2 then break;
if sepCnt = 2 then
break;
Dec(i);
end;
pth1 := aPath[i..length(aPath)];
@ -518,7 +530,7 @@ begin
PIDL := nil;
SHGetSpecialFolderLocation(0, CSIDL_APPDATA, PIDL);
SHGetPathFromIDList(PIDL, Folder);
result:=Folder;
result := Folder;
{$ENDIF}
{$IFDEF UNIX}
result := ExpandFileName('~/');
@ -600,7 +612,7 @@ begin
if aPath[length(aPath)] = '*' then
begin
pth := aPath[1..length(aPath)-1];
if pth[length(pth)] in ['/','\'] then
if pth[length(pth)] in ['/', '\'] then
pth := pth[1..length(pth)-1];
if not directoryExists(pth) then exit(false);
//

View File

@ -78,10 +78,10 @@ begin
if not dcdOn then exit;
//
if not DCD_server.Running then
DCD_server.Parameters.Add('-I'+ aFilename)
DCD_server.Parameters.Add('-I' + aFilename)
else if DCD_client <> nil then begin
DCD_client.Parameters.Clear;
DCD_client.Parameters.Add('-I'+ aFilename);
DCD_client.Parameters.Add('-I' + aFilename);
DCD_client.Execute;
end;
end;
@ -93,7 +93,8 @@ var
item: string;
asComp, asTips: boolean;
begin
if not dcdOn then exit;
if not dcdOn then
exit;
lazyServerStart;
//
DCD_client.Parameters.Clear;
@ -144,10 +145,11 @@ var
i: Integer;
str: string;
begin
if not dcdOn then exit;
if not dcdOn then
exit;
lazyServerStart;
//
if DCD_client.Running then exit;
if DCD_client.Running then
exit;
//
DCD_client.Parameters.Clear;
DCD_client.Parameters.Add('-c');
@ -169,10 +171,11 @@ var
i: Integer;
str, loc: string;
begin
if not dcdOn then exit;
if not dcdOn then
exit;
lazyServerStart;
//
if DCD_client.Running then exit;
if DCD_client.Running then
exit;
//
DCD_client.Parameters.Clear;
DCD_client.Parameters.Add('-l');
@ -188,7 +191,8 @@ begin
if str <> '' then
begin
i := Pos(#9, str);
if i = -1 then exit;
if i = -1 then
exit;
loc := str[i+1..length(str)];
str := str[1..i-1];
aFilename := str;

View File

@ -280,7 +280,8 @@ var
begin
savedReader := aReader;
savedPos := aPosition;
if readDelim(aReader, aPosition, aDelim) then exit(true);
if readDelim(aReader, aPosition, aDelim) then
exit(true);
aReader := savedReader;
aPosition := savedPos;
exit(false);
@ -293,7 +294,8 @@ var
begin
savedReader := aReader;
savedPos := aPosition;
if readDelim(aReader, aPosition, aDelim) then exit(true);
if readDelim(aReader, aPosition, aDelim) then
exit(true);
aReader := savedReader;
aPosition := savedPos;
exit(false);

View File

@ -360,10 +360,14 @@ end;
{$REGION TDocOpts --------------------------------------------------------------}
procedure TDocOpts.getOpts(const aList: TStrings);
begin
if fGenDoc then aList.Add('-D');
if fGenJson then aList.Add('-X');
if fDocDir <> '' then aList.Add('-Dd' + CEMainForm.expandSymbolicString(fDocDir));
if fJsonFname <> '' then aList.Add('-Xf' + CEMainForm.expandSymbolicString(fJsonFname));
if fGenDoc then
aList.Add('-D');
if fGenJson then
aList.Add('-X');
if fDocDir <> '' then
aList.Add('-Dd' + CEMainForm.expandSymbolicString(fDocDir));
if fJsonFname <> '' then
aList.Add('-Xf' + CEMainForm.expandSymbolicString(fJsonFname));
end;
procedure TDocOpts.assign(aValue: TPersistent);
@ -389,7 +393,8 @@ begin
exit;
end;
//
if fGenDoc = aValue then exit;
if fGenDoc = aValue then
exit;
fGenDoc := aValue;
doChanged;
end;
@ -402,24 +407,29 @@ begin
exit;
end;
//
if fGenJson = aValue then exit;
if fGenJson = aValue then
exit;
fGenJson := aValue;
doChanged;
end;
procedure TDocOpts.setDocDir(const aValue: string);
begin
if fDocDir = aValue then exit;
if fDocDir = aValue then
exit;
fDocDir := patchPlateformPath(aValue);
if fDocDir <> '' then setGenDoc(true);
if fDocDir <> '' then
setGenDoc(true);
doChanged;
end;
procedure TDocOpts.setJSONFile(const aValue: string);
begin
if fJsonFname = aValue then exit;
if fJsonFname = aValue then
exit;
fJsonFname := patchPlateformPath(aValue);
if fJsonFname <> '' then setGenJSON(true);
if fJsonFname <> '' then
setGenJSON(true);
doChanged;
end;
{$ENDREGION}
@ -849,7 +859,6 @@ end;
procedure TPathsOpts.assign(aValue: TPersistent);
var
src: TPathsOpts;
i: Integer;
begin
if (aValue is TPathsOpts) then
begin

View File

@ -79,7 +79,7 @@ implementation
{$R *.lfm}
uses
ce_main, ce_messages;
ce_main;
{$REGION Standard Comp/Obj------------------------------------------------------}
constructor TCEEditorWidget.create(aOwner: TComponent);
@ -182,7 +182,8 @@ function TCEEditorWidget.getEditorIndex: NativeInt;
begin
if pageControl.PageCount > 0 then
result := pageControl.PageIndex
else result := -1;
else
result := -1;
end;
function TCEEditorWidget.getEditor(index: NativeInt): TCESynMemo;
@ -217,7 +218,7 @@ procedure TCEEditorWidget.completionCodeCompletion(var Value: string;
SourceValue: string; var SourceStart, SourceEnd: TPoint; KeyChar: TUTF8Char;
Shift: TShiftState);
begin
// warning: '20' depends on ce_dcd, case knd of...
// warning: '20' depends on ce_dcd, case knd of, string literals length
Value := Value[1..length(Value)-20];
end;
@ -383,7 +384,7 @@ const
begin
if fDoc = nil then exit;
//
editorStatus.Panels[0].Text := format('%d : %d',[fDoc.CaretY, fDoc.CaretX]);
editorStatus.Panels[0].Text := format('%d : %d', [fDoc.CaretY, fDoc.CaretX]);
editorStatus.Panels[1].Text := modstr[fDoc.modified];
editorStatus.Panels[2].Text := fDoc.fileName;
end;

View File

@ -137,7 +137,7 @@ begin
if LibraryManager = nil then exit;
for i:= 0 to LibraryManager.libraries.Count-1 do
begin
itm := TLibraryItem( LibraryManager.libraries.Items[i]);
itm := TLibraryItem(LibraryManager.libraries.Items[i]);
row := List.Items.Add;
row.Caption := itm.libAlias;
row.SubItems.Add(itm.libFile);

View File

@ -11,7 +11,6 @@ uses
type
(**
* the struct linked to a log message. allow to be filtered.
*)
@ -90,8 +89,6 @@ type
procedure lmClearbyData(aData: Pointer);
end;
TMessageKind = (msgkUnknown, msgkInfo, msgkHint, msgkWarn, msgkError);
function guessMessageKind(const aMessg: string): TCEAppMessageKind;
function getLineFromDmdMessage(const aMessage: string): TPoint;
function openFileFromDmdMessage(const aMessage: string): boolean;
@ -197,9 +194,12 @@ end;
{$REGION ICESessionOptionsObserver ------------------------------------------------------}
procedure TCEMessagesWidget.setMaxMessageCount(aValue: Integer);
begin
if aValue < 10 then aValue := 10;
if aValue > 1023 then aValue := 1023;
if fMaxMessCnt = aValue then exit;
if aValue < 10 then
aValue := 10;
if aValue > 1023 then
aValue := 1023;
if fMaxMessCnt = aValue then
exit;
fMaxMessCnt := aValue;
clearOutOfRangeMessg;
end;
@ -217,7 +217,8 @@ end;
procedure TCEMessagesWidget.sesoptDeclareProperties(aFiler: TFiler);
begin
inherited;
aFiler.DefineProperty(Name + '_MaxMessageCount', @optset_MaxMessageCount, @optget_MaxMessageCount, true);
aFiler.DefineProperty(Name + '_MaxMessageCount', @optset_MaxMessageCount,
@optget_MaxMessageCount, true);
end;
{$ENDREGION}
@ -260,8 +261,9 @@ var
str: string;
begin
str := '';
for i := 0 to List.Items.Count-1 do if List.Items[i].MultiSelected then
str += List.Items[i].Text + LineEnding;
for i := 0 to List.Items.Count-1 do
if List.Items[i].MultiSelected then
str += List.Items[i].Text + LineEnding;
Clipboard.AsText := str;
end;
@ -428,7 +430,8 @@ end;
procedure TCEMessagesWidget.scrollToBack;
begin
if not Visible then exit;
if not Visible then
exit;
if List.BottomItem <> nil then
List.BottomItem.MakeVisible;
end;
@ -438,12 +441,15 @@ var
pos: TPoint;
msg: string;
begin
if List.Selected = nil then exit;
if List.Selected = nil then
exit;
msg := List.Selected.Text;
if not openFileFromDmdMessage(msg) then exit;
// from here since a doc has the focus, List.Selected is nil
if not openFileFromDmdMessage(msg) then
exit;
// from here, since a doc has the focus, List.Selected is nil
pos := getLineFromDmdMessage(msg);
if fDoc = nil then exit;
if fDoc = nil then
exit;
fDoc.CaretXY := pos;
fDoc.SelectLine;
end;
@ -454,7 +460,8 @@ var
itm: TTreeNode;
i: NativeInt;
begin
if updating then exit;
if updating then
exit;
for i := 0 to List.Items.Count-1 do
begin
itm := List.Items[i];
@ -502,12 +509,14 @@ begin
result := amkBub;
while(true) do
begin
if pos > length(aMessg) then exit;
if pos > length(aMessg) then
exit;
if aMessg[pos] in [#0..#32] then
begin
Inc(pos);
result := checkIdent;
if result <> amkBub then exit;
if result <> amkBub then
exit;
idt := '';
continue;
end;
@ -592,7 +601,7 @@ begin
if not fileExists(ident) then
exit;
ext := extractFileExt(ident);
// import(file) : ext may be different
// error in import(file) content: ext may be different
if not dExtList.IndexOf(ext) = -1 then
exit;
CEMainForm.openFile(ident);

View File

@ -5,9 +5,8 @@ unit ce_miniexplorer;
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
Menus, ComCtrls, Buttons, lcltype, strutils, ce_widget, ce_common,
ce_interfaces, ce_observer;
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, ExtCtrls, Menus, ComCtrls,
Buttons, lcltype, strutils, ce_widget, ce_common, ce_interfaces, ce_observer;
type
TCEMiniExplorerWidget = class(TCEWidget)