Ignore:
Timestamp:
Apr 26, 2007, 1:56:19 PM (18 years ago)
Author:
RBRi
Message:

changed to use StringUtilsUnit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NewView/MainForm.pas

    r101 r120  
    5757
    5858  MAIN_WINDOW_CLASS_NAME = 'NewViewMainForm';
     59
     60  PARAM_LINK_NOTE = 'note';
     61  PARAM_LINK_PROGRAM = 'program';
     62  PARAM_LINK_URL = 'url';
     63  PARAM_LINK_EXTERNAL = 'external';
    5964
    6065Type
     
    826831
    827832  // Library
    828   ACLStringUtility,
     833//  ACLStringUtility,
    829834  ACLFileIOUtility,
    830835  ACLUtility,
     
    832837  RunProgramUnit,
    833838  StringUtilsUnit,
     839  CharUtilsUnit,
    834840  DebugUnit,
    835841
     
    10341040  Topic: TTopic;
    10351041
     1042  tmpParts : TStringList;
    10361043Begin
    10371044  if not DoInputQuery( 'Binary Find',
     
    10401047    exit;
    10411048
    1042   DataLen := 0;
    1043   while Length( DataStr ) > 0 do
    1044   begin
    1045     Data[ DataLen ] := StrToInt( ExtractNextValue( DataStr, ' ' ) );
    1046     inc( DataLen );
    1047   end;
     1049  tmpParts := TStringList.Create;
     1050  StrExtractStringsIgnoreEmpty(tmpParts, DataStr, [' '], #0);
     1051  for i := 0 to tmpParts.count-1 do
     1052  begin
     1053    Data[i] := StrToInt(tmpParts[i]);
     1054  end;
     1055  DataLen := tmpParts.count;
     1056  tmpParts.Destroy;
    10481057
    10491058  ShowTab( piSearch );
     
    10561065    begin
    10571066      Topic := HelpFile.Topics[ i ];
    1058       if Topic.SearchForData( Addr( Data ), DataLen ) then
     1067      if Topic.SearchForData( Addr(Data), DataLen) then
    10591068      begin
    10601069        SearchResultsListBox.Items.AddObject( Topic.Title, Topic );
     
    13521361begin
    13531362  if    ( Trim( MainTitle ) = '' )
    1354      or ( StringsSame( Trim( MainTitle ), HelpProgramTitle ) ) then
     1363     or ( StrEqualIgnoringCase( Trim( MainTitle ), HelpProgramTitle ) ) then
    13551364    // supress "Help - " or "Help - Help"
    13561365    Caption := HelpProgramTitle
     
    14751484  Language.LL( Apply, FilesInfoTitle, 'FilesInfoTitle', 'Open Files Information' );
    14761485  Language.LL( Apply, FilesInfoOverallTitle, 'FilesInfoOverallTitle', 'Title: ' );
    1477   Language.LL( Apply, FilesInfoFilename, 'FilesInfoFilename', 'Filename: ' );
     1486  Language.LL( Apply, FilesInfoFilename, 'FilesInfoFilename', 'File name: ' );
    14781487  Language.LL( Apply, FilesInfoFileTitle, 'FilesInfoFileTitle', '  Title: ' );
    14791488  Language.LL( Apply, FilesInfoTopicCount, 'FilesInfoTopicCount', '  Topic Count: ' );
     
    15021511  Language.LL( Apply, UsageTitle, 'UsageTitle', 'NewView Command Line' );
    15031512  Language.LL( Apply, UsageText1, 'UsageText1', 'Usage: ' );
    1504   Language.LL( Apply, UsageText2, 'UsageText2', 'NewView <filename> [<topic>]' );
     1513  Language.LL( Apply, UsageText2, 'UsageText2', 'NewView <file name> [<topic>]' );
    15051514  Language.LL( Apply, UsageText3, 'UsageText3', ' /s Do search for <topic>' );
    15061515  Language.LL( Apply, UsageText4, 'UsageText4', ' /g Do global search for <topic>' );
     
    16611670begin
    16621671  Filenames := TStringList.Create;
    1663   StringToList( TextList, Filenames, '+' );
     1672  StrExtractStringsIgnoreEmpty(Filenames, TextList, ['+'], #0);
    16641673  if Filenames.Count > 0 then
    16651674  begin
     
    23732382  Filename := THelpFile( CurrentOpenFiles[ 0 ] ).Filename;
    23742383  NamePart := ExtractFileName( Filename );
    2375   Result := StrStarts( 'newview', NamePart );
     2384  Result := StrStartsWithIgnoringCase('newview', NamePart);
    23762385end;
    23772386
     
    26862695              + g_ExternalLinkFilename;
    26872696
    2688   if not StringsSame( FilePath, g_ExternalLinkSourceFilename ) then
     2697  if not StrEqualIgnoringCase( FilePath, g_ExternalLinkSourceFilename ) then
    26892698  begin
    26902699    // different file - try and open it
     
    37273736  System.Close( F );
    37283737
    3729   TheText := ApplicationErrorA + EndLine
    3730              + EndLine
    3731              + E.Message + EndLine
     3738  TheText := ApplicationErrorA + StrCRLF
     3739             + StrCRLF
     3740             + E.Message + StrCRLF
    37323741             + ApplicationErrorB
    37333742             + LogFilename
    3734              + ')' + EndLine
    3735              + EndLine
     3743             + ')' + StrCRLF
     3744             + StrCRLF
    37363745             + ApplicationErrorC
    3737              + EndLine;
     3746             + StrCRLF;
    37383747
    37393748  if DoYesNoDlg( ApplicationErrorTitle,
     
    38023811Procedure TMainForm.MainFormOnCreate (Sender: TObject);
    38033812var
    3804   tmpCmdLine: String;
     3813  tmpCmdLine: AnsiString;
    38053814Begin
    38063815  LogEvent(LogStartup, 'MainFormOnCreate');
     
    40614070  begin
    40624071    LogEvent(LogStartup, '  Help Manager Title: '
    4063                   + StrNPas( pSharedStruct ^. Title,
     4072                  + StrPasWithLength( pSharedStruct ^. Title,
    40644073                             SHARED_STRUCT_TITLE_SIZE ) );
    4065     HelpManagerVersion := StrNPas( pSharedStruct ^. Version,
     4074    HelpManagerVersion := StrPasWithLength( pSharedStruct ^. Version,
    40664075                                   SHARED_STRUCT_VERSION_SIZE );
    40674076    LogEvent(LogStartup, '  Help Manager Version: ' + HelpManagerVersion );
     
    41164125                 + EnvironmentVarUndefined
    41174126                 + BookshelfEnvironmentVar
    4118                  + EndLine;
     4127                 + StrCRLF;
    41194128
    41204129  if not HelpOK then
     
    41224131                 + EnvironmentVarUndefined
    41234132                 + HelpPathEnvironmentVar
    4124                  + EndLine;
     4133                 + StrCRLF;
    41254134
    41264135  DoWarningDlg( EnvironmentVarErrorTitle,
    41274136                EnvironmentVarError
    4128                 + EndLine
    4129                 + EndLine
     4137                + StrCRLF
     4138                + StrCRLF
    41304139                + ErrorText );
    41314140
     
    42004209    Filenames := TStringList.Create;
    42014210
    4202     // TODO use StrExtractStrings
    4203     StringToList(cmdLineParameters.getFileNames, Filenames, '+' );
     4211    StrExtractStringsIgnoreEmpty(Filenames, cmdLineParameters.getFileNames, ['+'], #0);
    42044212
    42054213    LogEvent(LogStartup, 'Call OpenFiles');
     
    45134521  for IndexIndex:= 0 to DisplayedIndex.Count - 1 do
    45144522  begin
    4515     if StrStarts( SearchText, DisplayedIndex[ IndexIndex ] ) then //IndexEntry ) then
     4523    if StrStartsWithIgnoringCase( SearchText, DisplayedIndex[ IndexIndex ] ) then //IndexEntry ) then
    45164524    begin
    45174525      MatchIndex:= IndexIndex;
     
    48034811             + IntToStr( SearchResultsListBox.Items.Count )
    48044812             + SearchFoundMsgB
    4805              + StrDoubleQuote( SearchText ) );
     4813             + StrInDoubleQuotes(SearchText)
     4814             );
    48064815
    48074816  ClearWaitCursor;
     
    48974906begin
    48984907  DoMessageDlg( UsageTitle,
    4899                   UsageText1 + EndLine
    4900                 + UsageText2 + EndLine
    4901                 + UsageText3 + EndLine
    4902                 + UsageText4 + EndLine
    4903                 + UsageText5 + EndLine
    4904                 + UsageText6 + EndLine
    4905                 + UsageText7 + EndLine
     4908                  UsageText1 + StrCRLF
     4909                + UsageText2 + StrCRLF
     4910                + UsageText3 + StrCRLF
     4911                + UsageText4 + StrCRLF
     4912                + UsageText5 + StrCRLF
     4913                + UsageText6 + StrCRLF
     4914                + UsageText7 + StrCRLF
    49064915                + UsageText8 );
    49074916end;
     
    51615170    MenuItem.Caption := PageHistory[ i ];
    51625171    MenuItem.Hint := GoBackHint
    5163                      + StrDoubleQuote( PageHistory[ i ] );
     5172                     + StrInDoubleQuotes( PageHistory[ i ] );
    51645173    MenuItem.OnClick := OnNavigateToMenuItemClick;
    51655174    MenuItem.Tag := i;
     
    52595268        if Element.ElementType = teTextEnd then
    52605269          break;
    5261         TextIndex := PCharDiff( p, Text );
     5270        TextIndex := PCharPointerDiff( p, Text );
    52625271        if TextIndex >= Note.InsertPoint then
    52635272        begin
     
    53875396  Filename: string;
    53885397  SourceFile: THelpFile;
    5389   LinkedProgram: string;
    53905398  URL: string;
    53915399  LinkDetails: string;
     5400  tmpLinkDetails : TStringList;
    53925401  ProgramInfo : TSerializableStringList;
    53935402  ProgramPath, ProgramLink : string;
    53945403Begin
    5395   if StrLeft( LinkString, 4 ) = 'note' then
     5404  LogEvent(LogDebug, 'OnOverLink: "' + LinkString + '"');
     5405
     5406  if StrStartsWith(LinkString, PARAM_LINK_NOTE) then
    53965407  begin
    53975408    SetStatus( EditNoteMsg )
    53985409  end
    5399   else if StrLeft( LinkString, 7 ) = 'program' then
     5410  else if StrStartsWith(LinkString, PARAM_LINK_PROGRAM) then
    54005411  begin
    54015412    ProgramInfo := TSerializableStringList.create;
    5402     ProgramInfo.readValuesFromSerializedString(StrRightFrom( LinkString, 9 ));
     5413// TODO check param here
     5414
     5415    ProgramInfo.readValuesFromSerializedString(StrSubstringFrom(LinkString, Length(PARAM_LINK_PROGRAM) + 1));
    54035416    ProgramPath := ProgramInfo.get(0);
    54045417    ProgramLink := ProgramInfo.get(1);
    54055418    TSerializableStringList.destroy;
     5419
    54065420    // call LaunchProgram here to inherit the environment
    5407 
    5408     LinkedProgram := StrRightFrom( LinkString, 9 );
    54095421    SetStatus( LinkMsg + ' ' + ProgramPath + ' ' + ProgramLink);
    54105422  end
    5411   else if StrLeft( LinkString, 3 ) = 'url' then
    5412   begin
    5413     URL := StrRightFrom( LinkString, 5 );
    5414     SetStatus( LinkMsg
    5415                + URL );
     5423  else if StrStartsWith(LinkString, PARAM_LINK_URL) then
     5424  begin
     5425    URL := StrSubstringFrom( LinkString, 5 );
     5426    SetStatus( LinkMsg + URL );
    54165427  end
    5417   else if StrLeft( LinkString, 8 ) = 'external' then
    5418   begin
    5419     LinkDetails := StrRightFrom( LinkString, 10 );
    5420     LinkIndex := StrToInt( ExtractNextValue( LinkDetails, ' ' ) );
     5428  else if StrStartsWith(LinkString, PARAM_LINK_EXTERNAL) then
     5429  begin
     5430    LinkDetails := StrSubstringFrom(LinkString, 10);
     5431
     5432    tmpLinkDetails := TStringList.Create;
     5433    StrExtractStrings(tmpLinkDetails, LinkDetails, [' '], #0);
     5434    LinkIndex := StrToInt(tmpLinkDetails[0]);
     5435    tmpLinkDetails.Destroy;
     5436
    54215437    Window := FindWindowFromView( Sender, Windows );
    54225438    SourceFile := Window.Topic.HelpFile as THelpFile;
    54235439    Filename := SourceFile.ReferencedFiles[ LinkIndex ];
    54245440    SetStatus( LinkMsg
    5425                + StrDoubleQuote( Filename ) );
     5441               + StrInDoubleQuotes( Filename ) );
    54265442  end
    54275443  else
     
    54425458      begin
    54435459        SetStatus( LinkMsg
    5444                    + StrDoubleQuote( Trim( LinkedTopic.Title ) ) );
     5460                   + StrInDoubleQuotes( Trim( LinkedTopic.Title ) ) );
    54455461      end
    54465462      else
     
    54695485  URL: string;
    54705486  LinkDetails: string;
     5487  tmpLinkDetails : TStringList;
    54715488  ProgramInfo : TSerializableStringList;
    54725489Begin
    5473   if StrLeft( LinkString, 4 ) = 'note' then
    5474   begin
    5475     NoteIndex := StrToInt( StrRightFrom( LinkString, 5 ) );
     5490  LogEvent(LogDebug, 'OnClickLink: "' + LinkString + '"');
     5491
     5492  if StrStartsWith(LinkString, PARAM_LINK_NOTE) then
     5493  begin
     5494    NoteIndex := StrToInt(StrSubstringFrom(LinkString, Length(PARAM_LINK_NOTE) + 1) );
    54765495    NotesListBox.ItemIndex := NoteIndex;
    54775496    EditNote( NoteIndex );
    54785497  end
    5479   else if StrLeft( LinkString, 7 ) = 'program' then
     5498  else if StrStartsWith(LinkString, PARAM_LINK_PROGRAM) then
    54805499  begin
    54815500    ProgramInfo := TSerializableStringList.create;
    5482     ProgramInfo.readValuesFromSerializedString(StrRightFrom( LinkString, 9 ));
     5501    ProgramInfo.readValuesFromSerializedString(StrSubstringFrom(LinkString, 9));
    54835502    ProgramPath := ProgramInfo.get(0);
    54845503    ProgramLink := ProgramInfo.get(1);
    54855504    TSerializableStringList.destroy;
     5505
    54865506    // call LaunchProgram here to inherit the environment
    54875507    LogEvent(LogDisplay, 'LaunchProgram: "' + ProgramPath + '" "' + ProgramLink + '"');
    54885508    LaunchProgram(ProgramPath, ProgramLink, '');
     5509    // TODO i18n
    54895510    SetStatus( 'Launched ' + ProgramPath );
    54905511  end
    5491   else if StrLeft( LinkString, 3 ) = 'url' then
    5492   begin
    5493     URL := StrRightFrom(LinkString, 5);
     5512  else if StrLeft( LinkString, 3 ) = PARAM_LINK_URL then
     5513  begin
     5514    URL := StrSubstringFrom(LinkString, 5);
    54945515
    54955516    try
     
    55035524    end;
    55045525
     5526    // TODO i18n
    55055527    SetStatus('Opened ' + URL );
    55065528  end
    5507   else if StrLeft( LinkString, 8 ) = 'external' then
    5508   begin
    5509     LinkDetails := StrRightFrom( LinkString, 10 );
    5510     LinkIndex := StrToInt( ExtractNextValue( LinkDetails, ' ' ) );
     5529  else if StrLeft( LinkString, 8 ) = PARAM_LINK_EXTERNAL then
     5530  begin
     5531    LinkDetails := StrSubstringFrom( LinkString, 10 );
     5532
     5533    tmpLinkDetails := TStringList.Create;
     5534    StrExtractStrings(tmpLinkDetails, LinkDetails, [' '], #0);
     5535    LinkIndex := StrToInt(tmpLinkDetails[0]);
     5536    tmpLinkDetails.Destroy;
     5537
    55115538    Window := FindWindowFromView( Sender, Windows );
    55125539    SourceFile := Window.Topic.HelpFile as THelpFile;
     
    56345661        FileName := ExtractFileName( FileName );
    56355662        FileName := ChangeFileExt( FileName, '' );// remove extension
    5636         AddToListString( MRUText,
    5637                          FileName,
    5638                          '+' );
     5663
     5664        if FileNameIndex > 0 then
     5665        begin
     5666          MRUText := MRUText + '+';
     5667        end;
     5668        MRUText := MRUText + FileName;
    56395669
    56405670        // stop after 50 chars
     
    58705900    DoErrorDlg( SaveNotesTitle,
    58715901                SaveNotesError
    5872                 + EndLine
     5902                + StrCRLF
    58735903                + NotesFileName
    5874                 + EndLine
     5904                + StrCRLF
    58755905                + SysErrorMessage( rc ) );
    58765906    exit;
     
    59475977    DoErrorDlg( LoadNotesTitle,
    59485978                LoadNotesError
    5949                 + EndLine
     5979                + StrCRLF
    59505980                + NotesFileName
    5951                 + EndLine
     5981                + StrCRLF
    59525982                + SysErrorMessage( rc ) );
    59535983    exit;
     
    61656195  begin
    61666196    Result:= CurrentOpenFiles[ FileIndex ];
    6167     if StringsSame( Result.Filename, FileName ) then
     6197    if StrEqualIgnoringCase( Result.Filename, FileName ) then
    61686198      // found
    61696199      exit;
     
    64526482    result := DoYesNoDlg( WindowsHelpTitle,
    64536483                          WindowsHelpPrompt
    6454                           + EndLine
     6484                          + StrCRLF
    64556485                          + FileName );
    64566486  if not result then
Note: See TracChangeset for help on using the changeset viewer.