Переглянути джерело

+ prompt with dialogs for tools

peter 26 роки тому
батько
коміт
e9d03b7506

+ 5 - 1
ide/text/fp.pas

@@ -72,6 +72,7 @@ BEGIN
   {$ifdef DEV}HeapLimit:=4096;{$endif}
   writeln('þ Free Pascal IDE  Version '+VersionStr);
   StartupDir:=CompleteDir(FExpand('.'));
+  IDEDir:=CompleteDir(DirOf(Paramstr(0)));
 
   ProcessParams(true);
 
@@ -114,7 +115,10 @@ BEGIN
 END.
 {
   $Log$
-  Revision 1.14  1999-03-05 17:53:00  pierre
+  Revision 1.15  1999-03-08 14:58:08  peter
+    + prompt with dialogs for tools
+
+  Revision 1.14  1999/03/05 17:53:00  pierre
    + saving and opening of open files on exit
 
   Revision 1.13  1999/03/01 15:41:48  peter

+ 7 - 4
ide/text/fpini.pas

@@ -332,7 +332,7 @@ begin
         TryToOpenFile(@R,S1,X,Y)
       else
         TryToOpenFile(nil,S1,X,Y);
-      { remove it because otherwise we allways keep old files }  
+      { remove it because otherwise we allways keep old files }
       INIFile^.DeleteEntry(secFiles,ieOpenFile+IntToStr(I));
     end;
   Dispose(INIFile, Done);
@@ -385,11 +385,11 @@ begin
             Inc(I);
             OpenFileCount:=I-1;
           end;
-          
+
         PW:=PSourceWindow(PW^.next);
         While assigned(PW) and (PW<>PPW) and (PW^.HelpCtx<>hcSourceWindow) do
           PW:=PSourceWindow(PW^.next);
-        If PW=PPW then                                                                                                                                                                                                                                         
+        If PW=PPW then
           break;
       end;
   INIFile^.SetIntEntry(secFiles,ieOpenFileCount,OpenFileCount);
@@ -461,7 +461,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.15  1999-03-05 17:53:02  pierre
+  Revision 1.16  1999-03-08 14:58:09  peter
+    + prompt with dialogs for tools
+
+  Revision 1.15  1999/03/05 17:53:02  pierre
    + saving and opening of open files on exit
 
   Revision 1.14  1999/03/01 15:41:55  peter

+ 5 - 5
ide/text/fpredir.pas

@@ -157,7 +157,6 @@ end;
 {............................................................................}
 
 function ChangeRedirOut(Const Redir : String; AppendToFile : Boolean) : Boolean;
-  var temp : byte;
   begin
     ChangeRedirOut:=False;
     If Redir = '' then Exit;
@@ -185,7 +184,6 @@ function ChangeRedirOut(Const Redir : String; AppendToFile : Boolean) : Boolean;
   end;
 
 function ChangeRedirIn(Const Redir : String) : Boolean;
-  var temp : byte;
   begin
     ChangeRedirIn:=False;
     If Redir = '' then Exit;
@@ -209,7 +207,6 @@ function ChangeRedirIn(Const Redir : String) : Boolean;
   end;
 
 function ChangeRedirError(Const Redir : String; AppendToFile : Boolean) : Boolean;
-  var temp : byte;
   begin
     ChangeRedirError:=False;
     If Redir = '' then Exit;
@@ -413,11 +410,14 @@ end;
 End.
 {
   $Log$
-  Revision 1.11  1999-03-01 15:42:01  peter
+  Revision 1.12  1999-03-08 14:58:10  peter
+    + prompt with dialogs for tools
+
+  Revision 1.11  1999/03/01 15:42:01  peter
     + Added dummy entries for functions not yet implemented
     * MenuBar didn't update itself automatically on command-set changes
     * Fixed Debugging/Profiling options dialog
-    * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
 set
+    * TCodeEditor converts spaces to tabs at save only if efUseTabChars is set
     * efBackSpaceUnindents works correctly
     + 'Messages' window implemented
     + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros

+ 8 - 4
ide/text/fptemplt.pas

@@ -35,7 +35,7 @@ uses
 {$else}
   WEditor,
 {$endif}
-  FPUtils;
+  FPVars,FPUtils;
 
 type
     PTemplate = ^TTemplate;
@@ -148,7 +148,7 @@ procedure InitTemplates;
 begin
   New(Templates, Init(10,10));
   ScanDir('.');
-  ScanDir(DirOf(ParamStr(0)));
+  ScanDir(IDEDir);
 end;
 
 
@@ -164,11 +164,15 @@ end;
 END.
 {
   $Log$
-  Revision 1.6  1999-03-01 15:42:03  peter
+  Revision 1.7  1999-03-08 14:58:11  peter
+    + prompt with dialogs for tools
+
+  Revision 1.6  1999/03/01 15:42:03  peter
     + Added dummy entries for functions not yet implemented
     * MenuBar didn't update itself automatically on command-set changes
     * Fixed Debugging/Profiling options dialog
-    * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
 set
+    * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
+ set
     * efBackSpaceUnindents works correctly
     + 'Messages' window implemented
     + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros

+ 370 - 6
ide/text/fptools.pas

@@ -140,6 +140,7 @@ implementation
 
 uses Dos,
      Commands,App,MsgBox,
+     WINI,WEditor,
      FPConst,FPVars,FPUtils;
 
 type
@@ -149,9 +150,9 @@ type
     end;
 
 const
-     HotKeys : array[0..8] of THotKeyDef =
+     HotKeys : array[0..9] of THotKeyDef =
       ( (Name : '~U~nassigned' ; KeyCode : kbNoKey   ),
-{        (Name : 'Shift+F~2~'   ; KeyCode : kbShiftF2 ), }
+        (Name : 'Shift+F~2~'   ; KeyCode : kbShiftF2 ),
         (Name : 'Shift+F~3~'   ; KeyCode : kbShiftF3 ),
         (Name : 'Shift+F~4~'   ; KeyCode : kbShiftF4 ),
         (Name : 'Shift+F~5~'   ; KeyCode : kbShiftF5 ),
@@ -162,6 +163,7 @@ const
         (Name : 'Shift+F~1~0'  ; KeyCode : kbShiftF10));
 
      Tools     : PToolCollection = nil;
+     AbortTool : boolean         = false;
 
 function GetHotKeyCount: integer;
 begin
@@ -547,6 +549,354 @@ begin
   until I=0;
 end;
 
+function GetCoordEntry(F: PINIFile; Section, Entry: string; var P: TPoint): boolean;
+var OK: boolean;
+    S: string;
+    Px: integer;
+begin
+  S:=F^.GetEntry(Section,Entry,'');
+  S:=Trim(S);
+  OK:=(S<>'') and (S[1]='(') and (S[length(S)]=')');
+  if OK then S:=copy(S,2,length(S)-2);
+  Px:=Pos(',',S);
+  OK:=OK and (Px>0);
+  if OK then P.X:=StrToInt(copy(S,1,Px-1));
+  OK:=OK and (LastStrToIntResult=0);
+  if OK then P.Y:=StrToInt(copy(S,Px+1,255));
+  OK:=OK and (LastStrToIntResult=0);
+  GetCoordEntry:=OK;
+end;
+
+function ExecutePromptDialog(const FileName: string; var Params: string): boolean;
+const
+      MaxViews         = 20;
+      MaxViewNameLen   = 40;
+      MaxValueLen      = 80;
+
+      secMain          = 'MAIN';
+      { Main section entries }
+      tmeTitle         = 'TITLE';
+      tmeCommandLine   = 'COMMANDLINE';
+      tmeSize          = 'SIZE';
+      tmeDefaultView   = 'DEFAULT';
+      { View section entries }
+      tieType          = 'TYPE';
+      tieOrigin        = 'ORIGIN';
+      tieSize          = 'SIZE';
+  {*} tieDefault       = 'DEFAULT';
+      tieValue         = 'VALUE';
+      { Additional CheckBox view section entries }
+      tieName          = 'NAME';
+      tieOnParm        = 'ON';
+      tieOffParm       = 'OFF';
+      { Additional CheckBox view section entries }
+      tieItem          = 'ITEM';
+      tieParam         = 'PARAM';
+      { Additional InputLine view section entries }
+      tieMaxLen        = 'MAXLEN';
+      { Additional Label view section entries }
+      tieLink          = 'LINK';
+      tieText          = 'TEXT';
+
+      { View types }
+      vtCheckBox       = 1;
+      vtRadioButton    = 2;
+      vtInputLine      = 3;
+      vtLabel          = 127;
+
+      vtsCheckBox      = 'CHECKBOX';
+      vtsRadioButton   = 'RADIOBUTTON';
+      vtsInputLine     = 'INPUTLINE';
+      vtsLabel         = 'LABEL';
+
+var Title        : string;
+    DSize        : TPoint;
+    CmdLine      : string;
+    ViewCount    : Sw_integer;
+    ViewNames    : array[0..MaxViews-1] of string[MaxViewNameLen];
+    ViewTypes    : array[0..MaxViews-1] of byte;
+    ViewBounds   : array[0..MaxViews-1] of TRect;
+    ViewPtrs     : array[0..MaxViews-1] of PView;
+    ViewValues   : array[0..MaxViews-1] of string[MaxValueLen];
+    ViewItemCount: array[0..MaxViews-1] of sw_integer;
+
+function BuildPromptDialogInfo(F: PINIFile): boolean;
+var
+  OK: boolean;
+  _IS: PINISection;
+
+  procedure ProcessSection(Sec: PINISection);{$ifndef FPC}far;{$endif}
+  var P1,P2: TPoint;
+      Typ: string;
+      Count: sw_integer;
+  begin
+    if (OK=false) or
+       ( (UpcaseStr(Sec^.GetName)=secMain) or
+         (UpcaseStr(Sec^.GetName)=UpcaseStr(MainSectionName)) ) then
+      Exit;
+
+    ViewItemCount[ViewCount]:=0;
+
+    OK:=(Sec^.SearchEntry(tieType)<>nil) and
+        (Sec^.SearchEntry(tieOrigin)<>nil) and
+        (Sec^.SearchEntry(tieSize)<>nil);
+    if OK=false then
+      begin ErrorBox('Required property missing in ['+Sec^.GetName+']',nil); Exit; end;
+
+    Typ:=UpcaseStr(Trim(F^.GetEntry(Sec^.GetName,tieType,'')));
+    if Typ=vtsCheckBox    then ViewTypes[ViewCount]:=vtCheckBox    else
+    if Typ=vtsRadioButton then ViewTypes[ViewCount]:=vtRadioButton else
+    if Typ=vtsInputLine   then ViewTypes[ViewCount]:=vtInputLine   else
+    if Typ=vtsLabel       then ViewTypes[ViewCount]:=vtLabel       else
+     begin OK:=false; ErrorBox('Unknown type in ['+Sec^.GetName+']',nil); Exit; end;
+
+    ViewNames[ViewCount]:=Sec^.GetName;
+    GetCoordEntry(F,Sec^.GetName,tieOrigin,P1);
+    GetCoordEntry(F,Sec^.GetName,tieSize,P2);
+    ViewBounds[ViewCount].Assign(P1.X,P1.Y,P1.X+P2.X,P1.Y+P2.Y);
+    ViewValues[ViewCount]:=F^.GetEntry(Sec^.GetName,tieValue,'');
+
+    case ViewTypes[ViewCount] of
+      vtLabel      :
+        begin
+          OK:=OK and (Sec^.SearchEntry(tieLink)<>nil) and
+                     (Sec^.SearchEntry(tieText)<>nil);
+          if OK=false then
+            begin ErrorBox('Required property missing in ['+Sec^.GetName+']',nil); Exit; end;
+        end;
+      vtInputLine  : ;
+      vtCheckBox   :
+        begin
+          OK:=OK and (Sec^.SearchEntry(tieName)<>nil);
+          if OK=false then
+            begin ErrorBox(tieName+' property missing in ['+Sec^.GetName+']',nil); Exit; end;
+        end;
+      vtRadioButton:
+        begin
+          Count:=0;
+          while Sec^.SearchEntry(tieItem+IntToStr(Count+1))<>nil do
+            Inc(Count);
+          ViewItemCount[ViewCount]:=Count;
+          OK:=Count>0;
+          if OK=false then
+            begin ErrorBox('Invalid number of items in ['+Sec^.GetName+']',nil); Exit; end;
+        end;
+    end;
+
+    if OK then Inc(ViewCount);
+  end;
+
+begin
+  BuildPromptDialogInfo:=false;
+  _IS:=F^.SearchSection(secMain);
+  OK:=_IS<>nil;
+  if OK then OK:=(_IS^.SearchEntry(tmeTitle)<>nil) and
+                 (_IS^.SearchEntry(tmeSize)<>nil) and
+                 (_IS^.SearchEntry(tmeCommandLine)<>nil);
+  if OK then
+  begin
+    Title:=F^.GetEntry(secMain,tmeTitle,'');
+    OK:=OK and GetCoordEntry(F,secMain,tmeSize,DSize);
+    CmdLine:=F^.GetEntry(secMain,tmeCommandLine,'');
+    OK:=OK and (CmdLine<>'');
+  end;
+  if OK=false then
+    begin ErrorBox('Required property missing in ['+_IS^.GetName+']',nil); Exit; end;
+
+  if OK then
+    begin
+      ViewCount:=0;
+      F^.ForEachSection(@ProcessSection);
+    end;
+  BuildPromptDialogInfo:=OK;
+end;
+function SearchViewByName(Name: string): integer;
+var I,Idx: Sw_integer;
+begin
+  Idx:=-1; Name:=UpcaseStr(Name);
+  for I:=0 to ViewCount-1 do
+    if UpcaseStr(ViewNames[I])=Name then
+      begin
+        Idx:=I;
+        Break;
+      end;
+  SearchViewByName:=Idx;
+end;
+function GetParamValueStr(F: PINIFile; Idx: integer): string;
+var S: string;
+    Entry: string[20];
+begin
+  S:='???';
+  case ViewTypes[Idx] of
+    vtLabel     :
+      S:='';
+    vtInputLine :
+      S:=PInputLine(ViewPtrs[Idx])^.Data^;
+    vtCheckBox  :
+      with PCheckBoxes(ViewPtrs[Idx])^ do
+      begin
+        if Mark(0) then Entry:=tieOnParm else Entry:=tieOffParm;
+        S:=F^.GetEntry(ViewNames[Idx],Entry,'');
+      end;
+    vtRadioButton :
+      with PRadioButtons(ViewPtrs[Idx])^ do
+      begin
+        Entry:=tieParam+IntToStr(Value+1);
+        S:=F^.GetEntry(ViewNames[Idx],Entry,'');
+      end;
+  end;
+  GetParamValueStr:=S;
+end;
+function ExtractPromptDialogParams(F: PINIFile; var Params: string): boolean;
+function ReplacePart(StartP,EndP: integer; const S: string): integer;
+begin
+  Params:=copy(Params,1,StartP-1)+S+copy(Params,EndP+1,255);
+  ReplacePart:=length(S)-(EndP-StartP+1);
+end;
+var OptName: string;
+    OK: boolean;
+    C: char;
+    OptStart: integer;
+    InOpt: boolean;
+    I,Idx: integer;
+    S: string;
+begin
+  Params:=CmdLine;
+  I:=1; InOpt:=false; OK:=true;
+  while OK and (I<=length(Params)) do
+    begin
+      C:=Params[I];
+      if C='%' then
+        begin
+          InOpt:=not InOpt;
+          if InOpt then
+            begin
+              OptName:='';
+              OptStart:=I;
+            end
+          else
+            begin
+              OptName:=UpcaseStr(OptName);
+              Idx:=SearchViewByName(OptName);
+              OK:=Idx<>-1;
+              if OK then
+                begin
+                  S:=GetParamValueStr(F,Idx);
+                  if (S='') and (Params[I+1]=' ') then Inc(I);
+                  I:=I+ReplacePart(OptStart,I,S);
+                end;
+            end;
+        end
+      else
+        if InOpt then
+          OptName:=OptName+C;
+      Inc(I);
+    end;
+  ExtractPromptDialogParams:=OK;
+end;
+function ExecPromptDialog(F: PINIFile): boolean;
+var R: TRect;
+    PromptDialog: PCenterDialog;
+    Re: integer;
+    OK: boolean;
+    I,J,MaxLen: integer;
+    IL: PInputLine;
+    CB: PCheckBoxes;
+    RB: PRadioButtons;
+    LV: PLabel;
+    SI: PSItem;
+    S: string;
+    P: PView;
+begin
+  R.Assign(0,0,DSize.X,DSize.Y);
+  New(PromptDialog, Init(R, Title));
+  with PromptDialog^ do
+  begin
+    for I:=0 to ViewCount-1 do
+      begin
+        case ViewTypes[I] of
+          vtLabel :
+            begin
+              S:=F^.GetEntry(ViewNames[I],tieLink,'');
+              J:=SearchViewByName(S);
+              if J=-1 then P:=nil else
+                P:=ViewPtrs[J];
+              S:=F^.GetEntry(ViewNames[I],tieText,'');
+              New(LV, Init(ViewBounds[I], S, P));
+              ViewPtrs[I]:=LV;
+            end;
+          vtInputLine :
+            begin
+              MaxLen:=F^.GetIntEntry(ViewNames[I],tieMaxLen,80);
+              New(IL, Init(ViewBounds[I], MaxLen));
+              IL^.Data^:=ViewValues[I];
+              ViewPtrs[I]:=IL;
+            end;
+          vtCheckBox :
+            begin
+              New(CB, Init(ViewBounds[I],
+               NewSItem(
+                F^.GetEntry(ViewNames[I],tieName,''),
+                nil)));
+              if StrToInt(ViewValues[I])=1 then
+                CB^.Press(0);
+              ViewPtrs[I]:=CB;
+            end;
+          vtRadioButton :
+            begin
+              SI:=nil;
+              for J:=ViewItemCount[I] downto 1 do
+                SI:=NewSItem(F^.GetEntry(ViewNames[I],tieItem+IntToStr(J),''),SI);
+              New(RB, Init(ViewBounds[I], SI));
+              RB^.Press(StrToInt(ViewValues[I]));
+              ViewPtrs[I]:=RB;
+            end;
+        end;
+        Insert(ViewPtrs[I]);
+      end;
+  end;
+  InsertButtons(PromptDialog);
+  S:=F^.GetEntry(secMain,tmeDefaultView,'');
+  if S<>'' then
+    begin
+      S:=UpcaseStr(S);
+      I:=0;
+      while (I<ViewCount) and (UpcaseStr(ViewNames[I])<>S) do
+        Inc(I);
+      if UpcaseStr(ViewNames[I])=S then
+        ViewPtrs[I]^.Select;
+    end;
+  Re:=Desktop^.ExecView(PromptDialog);
+  OK:=OK and (Re=cmOK);
+  AbortTool:=(Re<>cmOK);
+  if OK then OK:=ExtractPromptDialogParams(F,Params);
+  if PromptDialog<>nil then Dispose(PromptDialog, Done);
+  ExecPromptDialog:=OK;
+end;
+var OK: boolean;
+    F: PINIFile;
+    Fn : string;
+begin
+  Fn:=LocateFile(FileName);
+  if Fn='' then
+   Fn:=FileName;
+  if not ExistsFile(Fn) then
+    ErrorBox('Can''t read '+Fn,nil)
+  else
+    begin
+      New(F, Init(Fn));
+      OK:=F<>nil;
+      if OK then
+        begin
+          OK:=BuildPromptDialogInfo(F);
+          if OK then
+            OK:=ExecPromptDialog(F);
+        end;
+      if F<>nil then Dispose(F, Done);
+    end;
+  ExecutePromptDialog:=OK;
+end;
+
 function ParseToolParams(var Params: string; CheckOnly: boolean): integer;
 var Err: integer;
     W: PSourceWindow;
@@ -753,7 +1103,12 @@ begin
                   if ReadTill(S,')')=false then Err:=I else
                   begin
                     Consume(')');
-
+                    if S='' then Err:=I-1 else
+                      if CheckOnly=false then
+                        if ExecutePromptDialog(S,S)=false then
+                          Err:=I
+                        else
+                          I:=I+ReplacePart(LastWordStart,I-1,S);
                   end;
                 end
               else { just prompt for parms }
@@ -814,6 +1169,7 @@ begin
 end;
 var Pass: sw_integer;
 begin
+  AbortTool:=false;
   CaptureToolTo:=capNone;
   ToolFilter:='';
   W:=FirstEditorWindow;
@@ -823,6 +1179,7 @@ begin
       ParseParams(Pass);
       if Err<>0 then Break;
     end;
+  if AbortTool then Err:=-1;
   ParseToolParams:=Err;
 end;
 
@@ -958,6 +1315,7 @@ procedure TToolMessageListBox.Clear;
 begin
   ClearToolMessages;
   Update;
+  Message(Application,evBroadcast,cmClearLineHighlights,@Self);
 end;
 
 function TToolMessageListBox.GetPalette: PPalette;
@@ -1006,7 +1364,10 @@ begin
       case Event.Command of
         cmListFocusChanged :
           if Event.InfoPtr=MsgLB then
-            LastToolMessageFocused:=MsgLB^.List^.At(MsgLB^.Focused);
+            begin
+              LastToolMessageFocused:=MsgLB^.List^.At(MsgLB^.Focused);
+              Message(Application,evBroadcast,cmClearLineHighlights,@Self);
+            end;
       end;
   end;
   inherited HandleEvent(Event);
@@ -1027,11 +1388,14 @@ end;
 END.
 {
   $Log$
-  Revision 1.4  1999-03-01 15:42:04  peter
+  Revision 1.5  1999-03-08 14:58:12  peter
+    + prompt with dialogs for tools
+
+  Revision 1.4  1999/03/01 15:42:04  peter
     + Added dummy entries for functions not yet implemented
     * MenuBar didn't update itself automatically on command-set changes
     * Fixed Debugging/Profiling options dialog
-    * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
 set
+    * TCodeEditor converts spaces to tabs at save only if efUseTabChars is set
     * efBackSpaceUnindents works correctly
     + 'Messages' window implemented
     + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros

+ 55 - 31
ide/text/fputils.pas

@@ -46,15 +46,15 @@ function SmartPath(Path: string): string;
 Function FixPath(s:string;allowdot:boolean):string;
 function FixFileName(const s:string):string;
 function MakeExeName(const fn:string):string;
-function LExpand(S: string; MinLen: byte): string;
-function RExpand(S: string; MinLen: byte): string;
+function LExpand(const S: string; MinLen: byte): string;
+function RExpand(const S: string; MinLen: byte): string;
 function FitStr(const S: string; Len: byte): string;
-function LTrim(S: string): string;
-function RTrim(S: string): string;
-function Trim(S: string): string;
+function LTrim(const S: string): string;
+function RTrim(const S: string): string;
+function Trim(const S: string): string;
 function KillTilde(S: string): string;
-function UpcaseStr(S: string): string;
-function LowerCaseStr(S: string): string;
+function UpcaseStr(const S: string): string;
+function LowercaseStr(const S: string): string;
 function Max(A,B: longint): longint;
 function Min(A,B: longint): longint;
 function DirOf(const S: string): string;
@@ -195,17 +195,21 @@ begin
 end;
 
 
-function LExpand(S: string; MinLen: byte): string;
+function LExpand(const S: string; MinLen: byte): string;
 begin
-  if length(S)<MinLen then S:=CharStr(' ',MinLen-length(S))+S;
-  LExpand:=S;
+  if length(S)<MinLen then
+    LExpand:=CharStr(' ',MinLen-length(S))+S
+  else
+    LExpand:=S;
 end;
 
 
-function RExpand(S: string; MinLen: byte): string;
+function RExpand(const S: string; MinLen: byte): string;
 begin
-  if length(S)<MinLen then S:=S+CharStr(' ',MinLen-length(S));
-  RExpand:=S;
+  if length(S)<MinLen then
+    RExpand:=S+CharStr(' ',MinLen-length(S))
+  else
+    RExpand:=S;
 end;
 
 
@@ -226,20 +230,28 @@ begin
   KillTilde:=S;
 end;
 
-function UpcaseStr(S: string): string;
-var I: Longint;
+function UpcaseStr(const S: string): string;
+var
+  I: Longint;
 begin
   for I:=1 to length(S) do
-      S[I]:=Upcase(S[I]);
-  UpcaseStr:=S;
+    if S[I] in ['a'..'z'] then
+      UpCaseStr[I]:=chr(ord(S[I])-32)
+    else
+      UpCaseStr[I]:=S[I];
+  UpcaseStr[0]:=S[0];
 end;
 
-function LowerCaseStr(S: string): string;
-var I: byte;
+function LowerCaseStr(const S: string): string;
+var
+  I: Longint;
 begin
   for I:=1 to length(S) do
-    if S[I] in ['A'..'Z'] then S[I]:=chr(ord(S[I])+32);
-  LowerCaseStr:=S;
+    if S[I] in ['A'..'Z'] then
+      LowerCaseStr[I]:=chr(ord(S[I])+32)
+    else
+      LowerCaseStr[I]:=S[I];
+  LowercaseStr[0]:=S[0];
 end;
 
 function Max(A,B: longint): longint;
@@ -355,19 +367,27 @@ begin
   IntToHexL:=S;
 end;
 
-function LTrim(S: string): string;
+function LTrim(const S: string): string;
+var
+  i : longint;
 begin
-  while copy(S,1,1)=' ' do Delete(S,1,1);
-  LTrim:=S;
+  i:=1;
+  while (i<length(s)) and (s[i]=' ') do
+   inc(i);
+  LTrim:=Copy(s,i,255);
 end;
 
-function RTrim(S: string): string;
+function RTrim(const S: string): string;
+var
+  i : longint;
 begin
-  while copy(S,length(S),1)=' ' do Delete(S,length(S),1);
-  RTrim:=S;
+  i:=length(s);
+  while (i>0) and (s[i]=' ') do
+   dec(i);
+  RTrim:=Copy(s,1,i);
 end;
 
-function Trim(S: string): string;
+function Trim(const S: string): string;
 begin
   Trim:=RTrim(LTrim(S));
 end;
@@ -469,7 +489,7 @@ var OK: boolean;
 begin
   OK:=CheckFile(FExpand('.'),FileName);
   if OK=false then OK:=CheckFile(StartupDir,FileName);
-  if OK=false then OK:=CheckFile(DirOf(FExpand(ParamStr(0))),FileName);
+  if OK=false then OK:=CheckFile(IDEDir,FileName);
   LocateSingleFile:=OK;
 end;
 var P: integer;
@@ -585,11 +605,15 @@ end;
 END.
 {
   $Log$
-  Revision 1.9  1999-03-01 15:42:06  peter
+  Revision 1.10  1999-03-08 14:58:14  peter
+    + prompt with dialogs for tools
+
+  Revision 1.9  1999/03/01 15:42:06  peter
     + Added dummy entries for functions not yet implemented
     * MenuBar didn't update itself automatically on command-set changes
     * Fixed Debugging/Profiling options dialog
-    * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
 set
+    * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
+ set
     * efBackSpaceUnindents works correctly
     + 'Messages' window implemented
     + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros

+ 7 - 2
ide/text/fpvars.pas

@@ -48,6 +48,7 @@ const ClipboardWindow  : PClipboardWindow = nil;
       HelpFiles        : WUtils.PUnsortedStringCollection = nil;
       ShowStatusOnError: boolean = true;
       StartupDir       : string = '.'+DirSep;
+      IDEDir           : string = '.'+DirSep;
       INIPath          : string = ININame;
       SwitchesPath     : string = SwitchesName;
       CtrlMouseAction  : integer = acTopicSearch;
@@ -69,11 +70,15 @@ implementation
 END.
 {
   $Log$
-  Revision 1.10  1999-03-01 15:42:07  peter
+  Revision 1.11  1999-03-08 14:58:15  peter
+    + prompt with dialogs for tools
+
+  Revision 1.10  1999/03/01 15:42:07  peter
     + Added dummy entries for functions not yet implemented
     * MenuBar didn't update itself automatically on command-set changes
     * Fixed Debugging/Profiling options dialog
-    * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
 set
+    * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
+ set
     * efBackSpaceUnindents works correctly
     + 'Messages' window implemented
     + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros

+ 17 - 2
ide/text/fpviews.pas

@@ -91,6 +91,8 @@ type
 
     PSourceEditor = ^TSourceEditor;
     TSourceEditor = object(TFileEditor)
+      constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
+          PScrollBar; AIndicator: PIndicator;const AFileName: string);
 {$ifndef EDITORS}
       function  IsReservedWord(const S: string): boolean; virtual;
       function  GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer; virtual;
@@ -641,6 +643,13 @@ begin
   GetSpecSymbol:=S;
 end;
 
+constructor TSourceEditor.Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
+          PScrollBar; AIndicator: PIndicator;const AFileName: string);
+begin
+  inherited Init(Bounds,AHScrollBar,AVScrollBar,AIndicator,AFileName);
+  StoreUndo:=true;
+end;
+
 function TSourceEditor.IsReservedWord(const S: string): boolean;
 begin
   IsReservedWord:=IsFPReservedWord(S);
@@ -1248,6 +1257,7 @@ begin
   if List<>nil then Dispose(List, Done); List:=nil; MaxWidth:=0;
   if ModuleNames<>nil then ModuleNames^.FreeAll;
   SetRange(0); DrawView;
+  Message(Application,evBroadcast,cmClearLineHighlights,@Self);
 end;
 
 procedure TMessageListBox.TrackSource;
@@ -1256,6 +1266,7 @@ var W: PSourceWindow;
     R: TRect;
     Row,Col: sw_integer;
 begin
+  Message(Application,evBroadcast,cmClearLineHighlights,@Self);
   if Range=0 then Exit;
   P:=List^.At(Focused);
   if P^.Row=0 then Exit;
@@ -1292,6 +1303,7 @@ var W: PSourceWindow;
     P: PMessageItem;
     Row,Col: sw_integer;
 begin
+  Message(Application,evBroadcast,cmClearLineHighlights,@Self);
   if Range=0 then Exit;
   P:=List^.At(Focused);
   if P^.Row=0 then Exit;
@@ -2394,11 +2406,14 @@ end;
 END.
 {
   $Log$
-  Revision 1.20  1999-03-01 15:42:08  peter
+  Revision 1.21  1999-03-08 14:58:16  peter
+    + prompt with dialogs for tools
+
+  Revision 1.20  1999/03/01 15:42:08  peter
     + Added dummy entries for functions not yet implemented
     * MenuBar didn't update itself automatically on command-set changes
     * Fixed Debugging/Profiling options dialog
-    * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
 set
+    * TCodeEditor converts spaces to tabs at save only if efUseTabChars is set
     * efBackSpaceUnindents works correctly
     + 'Messages' window implemented
     + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros

+ 59 - 0
ide/text/grep.tdf

@@ -0,0 +1,59 @@
+[Main]
+Title="GNU Grep"
+Size=(56,9)
+CommandLine="-n %l% %v% %i% %w% %searchstr% %filemask%"
+Default="searchstr"
+
+[searchstr]
+Type=InputLine
+Origin=(2,2)
+Size=(52,1)
+
+[label1]
+Type=Label
+Origin=(2,1)
+Size=(52,1)
+Text="~T~ext to find"
+Link="searchstr"
+
+[filemask]
+Type=InputLine
+Origin=(2,4)
+Size=(22,1)
+Value="*.pas *.pp *.inc"
+
+[label2]
+Type=Label
+Origin=(2,3)
+Size=(22,1)
+Text="File ~m~ask"
+Link="filemask"
+
+[i]
+Type=CheckBox
+Name="~C~ase sensitive"
+Origin=(2,6)
+Size=(25,1)
+Default=On
+On="-i"
+
+[v]
+Type=CheckBox
+Name="~N~on-matching lines"
+Origin=(2,7)
+Size=(25,1)
+On="-v"
+
+[l]
+Type=CheckBox
+Name="~F~ile names only"
+Origin=(29,6)
+Size=(25,1)
+On="-l"
+
+[w]
+Type=CheckBox
+Name="Whole ~w~ords only"
+Origin=(29,7)
+Size=(25,1)
+On="-w"

+ 88 - 0
ide/text/tpgrep.tdf

@@ -0,0 +1,88 @@
+[Main]
+Title="Turbo Grep"
+Size=(56,10)
+CommandLine="%r% %l% %v% %i% %d% %w% %o% %searchstr% %filemask%"
+Default="searchstr"
+
+[searchstr]
+Type=InputLine
+Origin=(2,2)
+Size=(52,1)
+
+[label1]
+Type=Label
+Origin=(2,1)
+Size=(52,1)
+Text="~T~ext to find"
+Link="searchstr"
+
+[filemask]
+Type=InputLine
+Origin=(2,4)
+Size=(22,1)
+Value="*.pas"
+
+[label2]
+Type=Label
+Origin=(2,3)
+Size=(22,1)
+Text="File ~m~ask"
+Link="filemask"
+
+[d]
+Type=CheckBox
+Origin=(26,4)
+Size=(28,1)
+Name="Search ~s~ubdirectories"
+On="-d+"
+;Off="-d-"
+
+[r]
+Type=CheckBox
+Name="~R~egular expression"
+Origin=(2,6)
+Size=(25,1)
+On="-r+"
+;Off="-r-"
+Value=1
+
+[v]
+Type=CheckBox
+Name="~N~on-matching lines"
+Origin=(2,7)
+Size=(25,1)
+On="-v+"
+;Off="-v-"
+
+[o]
+Type=CheckBox
+Name="~U~NIX output format"
+Origin=(2,8)
+Size=(25,1)
+On="-o+"
+;Off="-o-"
+
+[l]
+Type=CheckBox
+Name="~F~ile names only"
+Origin=(29,6)
+Size=(25,1)
+On="-l+"
+;Off="-l-"
+
+[i]
+Type=CheckBox
+Name="~C~ase sensitive"
+Origin=(29,7)
+Size=(25,1)
+On="-i-"
+Off="-i+"
+
+[w]
+Type=CheckBox
+Name="Whole ~w~ords only"
+Origin=(29,8)
+Size=(25,1)
+On="-w+"
+;Off="-w-"
+

+ 17 - 43
ide/text/weditor.pas

@@ -17,10 +17,6 @@ unit WEditor;
 
 interface
 
-{$ifndef FPC}
-  {$define TPUNIXLF}
-{$endif}
-
 uses
   Objects,Drivers,Views,Menus,Commands;
 
@@ -114,6 +110,7 @@ const
       eaInsertText        = 3;
       eaDeleteLine        = 4;
       eaDeleteText        = 5;
+      eaSelectionChanged  = 6;
 
       CIndicator    = #2#3#1;
       CEditor       = #33#34#35#36#37#38#39#40#41#42#43#44#45#46#47#48#49;
@@ -179,6 +176,7 @@ type
       Highlight  : TRect;
       CurPos     : TPoint;
       CanUndo    : Boolean;
+      StoreUndo  : boolean;
       Modified   : Boolean;
       IsReadOnly : Boolean;
       NoSelect   : Boolean;
@@ -341,8 +339,10 @@ const
 
 implementation
 
-uses Dos,MsgBox,Dialogs,App,StdDlg,HistList,Validate,
-     WViews;
+uses
+  Dos,
+  MsgBox,Dialogs,App,StdDlg,HistList,Validate,
+  WUtils,WViews;
 
 type
      TFindDialogRec = packed record
@@ -867,6 +867,7 @@ begin
   if Item<>nil then DisposeLine(Item);
 end;
 
+
 constructor TIndicator.Init(var Bounds: TRect);
 begin
   inherited Init(Bounds);
@@ -942,6 +943,7 @@ constructor TCodeEditor.Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
           PScrollBar; AIndicator: PIndicator; AbufSize:Sw_Word);
 begin
   inherited Init(Bounds,AHScrollBar,AVScrollBar);
+  StoreUndo:=false;
   New(Actions, Init(500,1000));
   New(Lines, Init(500,1000));
   { we have always need at least 1 line }
@@ -952,6 +954,7 @@ begin
   SetState(sfCursorVis,true);
   SetFlags(DefaultCodeEditorFlags); TabSize:=DefaultTabSize;
   SetHighlightRow(-1);
+  SetCurPtr(0,0);
   Indicator:=AIndicator;
   UpdateIndicator; LimitsChanged;
 end;
@@ -2911,7 +2914,7 @@ end;
 
 procedure TCodeEditor.AddAction(AAction: byte; AStartPos, AEndPos: TPoint; AText: string);
 begin
-  if (Actions=nil) then Exit;
+  if (Actions=nil) or (not StoreUndo) then Exit;
   Actions^.Insert(NewEditorAction(AAction,AStartPos,AEndPos,AText));
 end;
 
@@ -2977,7 +2980,8 @@ end;
 destructor TCodeEditor.Done;
 begin
   inherited Done;
-  Dispose(Lines, Done);
+  if assigned(Lines) then
+    Dispose(Lines, Done);
   If assigned(Actions) then
     Dispose(Actions, Done);
 end;
@@ -2998,37 +3002,6 @@ begin
 end;
 
 function TFileEditor.LoadFile: boolean;
-{$ifdef TPUNIXLF}
-  var
-    OnlyLF: boolean;
-  procedure readln(var t:text;var s:string);
-  var
-    c : char;
-    i : longint;
-  begin
-    if OnlyLF=false then system.readln(t,s) else
-   begin
-    c:=#0;
-    i:=0;
-    while (not eof(t)) and (c<>#10) do
-     begin
-       read(t,c);
-       if c<>#10 then
-   begin
-     inc(i);
-     s[i]:=c;
-   end;
-     end;
-    if (i>0) and (s[i]=#13) then
-     begin
-       dec(i);
-       OnlyLF:=false;
-     end;
-    s[0]:=chr(i);
-   end;
-  end;
-{$endif}
-
 var S: string;
     OK: boolean;
     f: text;
@@ -3042,7 +3015,6 @@ begin
   Assign(f,FileName);
   SetTextBuf(f,Buf^,EditorTextBufSize);
   Reset(f);
-  {$ifdef TPUNIXLF}OnlyLF:=true;{$endif}
   OK:=(IOResult=0);
   if Eof(f) then
    AddLine('')
@@ -3433,7 +3405,10 @@ end;
 END.
 {
   $Log$
-  Revision 1.26  1999-03-07 22:58:57  pierre
+  Revision 1.27  1999-03-08 14:58:17  peter
+    + prompt with dialogs for tools
+
+  Revision 1.26  1999/03/07 22:58:57  pierre
    * FindRec needs longint for CheckBoxes
 
   Revision 1.25  1999/03/05 17:39:39  pierre
@@ -3446,8 +3421,7 @@ END.
     + Added dummy entries for functions not yet implemented
     * MenuBar didn't update itself automatically on command-set changes
     * Fixed Debugging/Profiling options dialog
-    * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
- set
+    * TCodeEditor converts spaces to tabs at save only if efUseTabChars is set
     * efBackSpaceUnindents works correctly
     + 'Messages' window implemented
     + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros

+ 10 - 1
ide/text/whelp.pas

@@ -389,6 +389,7 @@ end;
 function THelpFile.LoadIndex: boolean;
 begin
   Abstract;
+  LoadIndex:=false; { remove warning }
 end;
 
 function THelpFile.SearchTopic(HelpCtx: THelpCtx): PTopic;
@@ -401,6 +402,7 @@ end;
 function THelpFile.ReadTopic(T: PTopic): boolean;
 begin
   Abstract;
+  ReadTopic:=false; { remove warning }
 end;
 
 procedure THelpFile.MaintainTopicCache;
@@ -620,7 +622,11 @@ begin
   case N of
     $00       : C:=#0;
     $01..$0D  : C:=chr(Compression.CharTable[N]);
+{$ifdef FPC}
+    ncRawChar : C:=chr(GetNextNibble shl 4+GetNextNibble);
+{$else}
     ncRawChar : C:=chr(GetNextNibble+GetNextNibble shl 4);
+{$endif}
     ncRepChar : begin
                   Cnt:=2+GetNextNibble;
                   C:=GetNextChar{$ifdef FPC}(){$endif};
@@ -913,7 +919,10 @@ end;
 END.
 {
   $Log$
-  Revision 1.9  1999-03-03 16:44:05  pierre
+  Revision 1.10  1999-03-08 14:58:19  peter
+    + prompt with dialogs for tools
+
+  Revision 1.9  1999/03/03 16:44:05  pierre
    * TPH reader fix from Peter
 
   Revision 1.8  1999/03/01 15:42:11  peter

+ 7 - 4
ide/text/whlpview.pas

@@ -1039,7 +1039,8 @@ end;
 destructor THelpViewer.Done;
 begin
   inherited Done;
-  Dispose(WordList, Done);
+  if assigned(WordList) then
+    Dispose(WordList, Done);
 end;
 
 function THelpFrame.GetPalette: PPalette;
@@ -1049,7 +1050,6 @@ begin
 end;
 
 constructor THelpWindow.Init(var Bounds: TRect; ATitle: TTitleStr; ASourceFileID: word; AContext: THelpCtx; ANumber: Integer);
-var R: TRect;
 begin
   inherited Init(Bounds, ATitle, ANumber);
   InitScrollBars;
@@ -1125,11 +1125,14 @@ end;
 END.
 {
   $Log$
-  Revision 1.6  1999-03-01 15:42:13  peter
+  Revision 1.7  1999-03-08 14:58:20  peter
+    + prompt with dialogs for tools
+
+  Revision 1.6  1999/03/01 15:42:13  peter
     + Added dummy entries for functions not yet implemented
     * MenuBar didn't update itself automatically on command-set changes
     * Fixed Debugging/Profiling options dialog
-    * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
 set
+    * TCodeEditor converts spaces to tabs at save only if efUseTabChars is set
     * efBackSpaceUnindents works correctly
     + 'Messages' window implemented
     + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros

+ 24 - 17
ide/text/wini.pas

@@ -62,6 +62,7 @@ type
       function    IsModified: boolean; virtual;
       function    SearchSection(Section: string): PINISection; virtual;
       function    SearchEntry(const Section, Tag: string): PINIEntry; virtual;
+      procedure   ForEachSection(EnumProc: pointer); virtual;
       procedure   ForEachEntry(const Section: string; EnumProc: pointer); virtual;
       function    GetEntry(const Section, Tag, Default: string): string; virtual;
       procedure   SetEntry(const Section, Tag, Value: string); virtual;
@@ -81,9 +82,9 @@ const MainSectionName : string[40] = 'MainSection';
 
 implementation
 
-uses WUtils
-{$ifdef FPC},callspec{$endif}
-     ;
+uses
+  CallSpec,
+  WUtils;
 
 constructor TINIEntry.Init(const ALine: string);
 begin
@@ -201,6 +202,17 @@ begin
   AddEntry:=E;
 end;
 
+procedure TINIFile.ForEachSection(EnumProc: pointer);
+var I: Sw_integer;
+   S: PINISection;
+begin
+  for I:=0 to Sections^.Count-1 do
+    begin
+      S:=Sections^.At(I);
+      CallPointerLocal(EnumProc,PreviousFramePointer,S);
+    end;
+end;
+
 procedure TINISection.ForEachEntry(EnumProc: pointer);
 var I: integer;
     E: PINIEntry;
@@ -208,16 +220,7 @@ begin
   for I:=0 to Entries^.Count-1 do
     begin
       E:=Entries^.At(I);
-      {$ifdef FPC}
-        CallPointerMethodLocal(EnumProc,CurrentFramePointer,@Self,E);
-      {$else}
-      asm
-        push E.word[2]
-        push E.word[0]
-        push word ptr [bp]
-        call EnumProc
-      end;
-      {$endif}
+      CallPointerLocal(EnumProc,PreviousFramePointer,E);
     end;
 end;
 
@@ -233,7 +236,7 @@ end;
 
 procedure TINISection.DeleteEntry(Tag: string);
 var
-  P : PIniEntry; 
+  P : PIniEntry;
 begin
   P:=SearchEntry(Tag);
   if assigned(P) then
@@ -460,7 +463,7 @@ begin
   if P<>nil then
     P^.DeleteEntry(Tag);
 end;
-                                                                                                                                                                                                                                                               
+
 destructor TINIFile.Done;
 begin
   if IsModified then
@@ -475,14 +478,18 @@ end;
 END.
 {
   $Log$
-  Revision 1.7  1999-03-05 17:53:03  pierre
+  Revision 1.8  1999-03-08 14:58:21  peter
+    + prompt with dialogs for tools
+
+  Revision 1.7  1999/03/05 17:53:03  pierre
    + saving and opening of open files on exit
 
   Revision 1.6  1999/03/01 15:42:15  peter
     + Added dummy entries for functions not yet implemented
     * MenuBar didn't update itself automatically on command-set changes
     * Fixed Debugging/Profiling options dialog
-    * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
 set
+    * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
+ set
     * efBackSpaceUnindents works correctly
     + 'Messages' window implemented
     + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros

+ 119 - 36
ide/text/wutils.pas

@@ -15,29 +15,40 @@ unit WUtils;
 
 interface
 
-uses Objects;
+{$ifndef FPC}
+  {$define TPUNIXLF}
+{$endif}
+
+
+uses
+  Objects;
 
 type
-     PByteArray = ^TByteArray;
-     TByteArray = array[0..65520] of byte;
+  PByteArray = ^TByteArray;
+  TByteArray = array[0..65520] of byte;
+
+  PUnsortedStringCollection = ^TUnsortedStringCollection;
+  TUnsortedStringCollection = object(TCollection)
+    function  At(Index: Integer): PString;
+    procedure FreeItem(Item: Pointer); virtual;
+  end;
+
+{$ifdef TPUNIXLF}
+  procedure readln(var t:text;var s:string);
+{$endif}
 
-    PUnsortedStringCollection = ^TUnsortedStringCollection;
-    TUnsortedStringCollection = object(TCollection)
-      function  At(Index: Integer): PString;
-      procedure FreeItem(Item: Pointer); virtual;
-    end;
 
 function Min(A,B: longint): longint;
 function Max(A,B: longint): longint;
 
 function CharStr(C: char; Count: byte): string;
-function Trim(S: string): string;
-function UpcaseStr(S: string): string;
-function RExpand(S: string; MinLen: byte): string;
-function LTrim(S: string): string;
-function RTrim(S: string): string;
+function UpcaseStr(const S: string): string;
+function RExpand(const S: string; MinLen: byte): string;
+function LTrim(const S: string): string;
+function RTrim(const S: string): string;
+function Trim(const S: string): string;
 function IntToStr(L: longint): string;
-function StrToInt(S: string): longint;
+function StrToInt(const S: string): longint;
 function GetStr(P: PString): string;
 
 function EatIO: integer;
@@ -46,47 +57,116 @@ const LastStrToIntResult : integer = 0;
 
 implementation
 
-function Min(A,B: longint): longint; begin if A<B then Min:=A else Min:=B; end;
-function Max(A,B: longint): longint; begin if A>B then Max:=A else Max:=B; end;
+uses
+  Dos;
+
+{$ifdef TPUNIXLF}
+  procedure readln(var t:text;var s:string);
+  var
+    c : char;
+    i : longint;
+  begin
+    if TextRec(t).UserData[1]=2 then
+      system.readln(t,s)
+    else
+     begin
+      c:=#0;
+      i:=0;
+      while (not eof(t)) and (c<>#10) do
+       begin
+         read(t,c);
+         if c<>#10 then
+          begin
+            inc(i);
+            s[i]:=c;
+          end;
+       end;
+      if (i>0) and (s[i]=#13) then
+       begin
+         dec(i);
+         TextRec(t).UserData[1]:=2;
+       end;
+      s[0]:=chr(i);
+     end;
+  end;
+{$endif}
+
+
+function Max(A,B: longint): longint;
+begin
+  if A>B then Max:=A else Max:=B;
+end;
+
+function Min(A,B: longint): longint;
+begin
+  if A<B then Min:=A else Min:=B;
+end;
+
 function CharStr(C: char; Count: byte): string;
 var S: string;
-begin S[0]:=chr(Count); if Count>0 then FillChar(S[1],Count,C); CharStr:=S; end;
+begin
+  S[0]:=chr(Count);
+  FillChar(S[1],Count,C);
+  CharStr:=S;
+end;
 
-function UpcaseStr(S: string): string;
-var I: integer;
+function UpcaseStr(const S: string): string;
+var
+  I: Longint;
 begin
   for I:=1 to length(S) do
-      S[I]:=Upcase(S[I]);
-  UpcaseStr:=S;
+    if S[I] in ['a'..'z'] then
+      UpCaseStr[I]:=chr(ord(S[I])-32)
+    else
+      UpCaseStr[I]:=S[I];
+  UpcaseStr[0]:=S[0];
 end;
 
-function RExpand(S: string; MinLen: byte): string;
+function LowerCaseStr(S: string): string;
+var
+  I: Longint;
 begin
-  if length(S)<MinLen then
-     S:=S+CharStr(' ',MinLen-length(S));
-  RExpand:=S;
+  for I:=1 to length(S) do
+    if S[I] in ['A'..'Z'] then
+      LowerCaseStr[I]:=chr(ord(S[I])+32)
+    else
+      LowerCaseStr[I]:=S[I];
+  LowercaseStr[0]:=S[0];
 end;
 
-
-function LTrim(S: string): string;
+function RExpand(const S: string; MinLen: byte): string;
 begin
-  while copy(S,1,1)=' ' do Delete(S,1,1);
-  LTrim:=S;
+  if length(S)<MinLen then
+    RExpand:=S+CharStr(' ',MinLen-length(S))
+  else
+    RExpand:=S;
 end;
 
-function RTrim(S: string): string;
+function LTrim(const S: string): string;
+var
+  i : longint;
 begin
-  while copy(S,length(S),1)=' ' do Delete(S,length(S),1);
-  RTrim:=S;
+  i:=1;
+  while (i<length(s)) and (s[i]=' ') do
+   inc(i);
+  LTrim:=Copy(s,i,255);
 end;
 
+function RTrim(const S: string): string;
+var
+  i : longint;
+begin
+  i:=length(s);
+  while (i>0) and (s[i]=' ') do
+   dec(i);
+  RTrim:=Copy(s,1,i);
+end;
 
-function Trim(S: string): string;
+function Trim(const S: string): string;
 begin
   Trim:=RTrim(LTrim(S));
 end;
 
-
 function IntToStr(L: longint): string;
 var S: string;
 begin
@@ -95,7 +175,7 @@ begin
 end;
 
 
-function StrToInt(S: string): longint;
+function StrToInt(const S: string): longint;
 var L: longint;
     C: integer;
 begin
@@ -130,7 +210,10 @@ end;
 END.
 {
   $Log$
-  Revision 1.1  1999-03-01 15:51:43  peter
+  Revision 1.2  1999-03-08 14:58:22  peter
+    + prompt with dialogs for tools
+
+  Revision 1.1  1999/03/01 15:51:43  peter
     + Log
 
 }

+ 7 - 1
ide/text/wviews.pas

@@ -927,8 +927,11 @@ begin
 end;
 
 procedure TAdvancedListBox.FocusItem(Item: sw_integer);
+var OFocused: sw_integer;
 begin
+  OFocused:=Focused;
   inherited FocusItem(Item);
+  if Focused<>OFocused then
   Message(Owner,evBroadcast,cmListFocusChanged,@Self);
 end;
 
@@ -1374,7 +1377,10 @@ end;
 END.
 {
   $Log$
-  Revision 1.1  1999-03-01 15:51:43  peter
+  Revision 1.2  1999-03-08 14:58:23  peter
+    + prompt with dialogs for tools
+
+  Revision 1.1  1999/03/01 15:51:43  peter
     + Log
 
 }