Changeset 120 for trunk/NewView/MainForm.pas
- Timestamp:
- Apr 26, 2007, 1:56:19 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NewView/MainForm.pas
r101 r120 57 57 58 58 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'; 59 64 60 65 Type … … 826 831 827 832 // Library 828 ACLStringUtility,833 // ACLStringUtility, 829 834 ACLFileIOUtility, 830 835 ACLUtility, … … 832 837 RunProgramUnit, 833 838 StringUtilsUnit, 839 CharUtilsUnit, 834 840 DebugUnit, 835 841 … … 1034 1040 Topic: TTopic; 1035 1041 1042 tmpParts : TStringList; 1036 1043 Begin 1037 1044 if not DoInputQuery( 'Binary Find', … … 1040 1047 exit; 1041 1048 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; 1048 1057 1049 1058 ShowTab( piSearch ); … … 1056 1065 begin 1057 1066 Topic := HelpFile.Topics[ i ]; 1058 if Topic.SearchForData( Addr( Data ), DataLen) then1067 if Topic.SearchForData( Addr(Data), DataLen) then 1059 1068 begin 1060 1069 SearchResultsListBox.Items.AddObject( Topic.Title, Topic ); … … 1352 1361 begin 1353 1362 if ( Trim( MainTitle ) = '' ) 1354 or ( Str ingsSame( Trim( MainTitle ), HelpProgramTitle ) ) then1363 or ( StrEqualIgnoringCase( Trim( MainTitle ), HelpProgramTitle ) ) then 1355 1364 // supress "Help - " or "Help - Help" 1356 1365 Caption := HelpProgramTitle … … 1475 1484 Language.LL( Apply, FilesInfoTitle, 'FilesInfoTitle', 'Open Files Information' ); 1476 1485 Language.LL( Apply, FilesInfoOverallTitle, 'FilesInfoOverallTitle', 'Title: ' ); 1477 Language.LL( Apply, FilesInfoFilename, 'FilesInfoFilename', 'File name: ' );1486 Language.LL( Apply, FilesInfoFilename, 'FilesInfoFilename', 'File name: ' ); 1478 1487 Language.LL( Apply, FilesInfoFileTitle, 'FilesInfoFileTitle', ' Title: ' ); 1479 1488 Language.LL( Apply, FilesInfoTopicCount, 'FilesInfoTopicCount', ' Topic Count: ' ); … … 1502 1511 Language.LL( Apply, UsageTitle, 'UsageTitle', 'NewView Command Line' ); 1503 1512 Language.LL( Apply, UsageText1, 'UsageText1', 'Usage: ' ); 1504 Language.LL( Apply, UsageText2, 'UsageText2', 'NewView <file name> [<topic>]' );1513 Language.LL( Apply, UsageText2, 'UsageText2', 'NewView <file name> [<topic>]' ); 1505 1514 Language.LL( Apply, UsageText3, 'UsageText3', ' /s Do search for <topic>' ); 1506 1515 Language.LL( Apply, UsageText4, 'UsageText4', ' /g Do global search for <topic>' ); … … 1661 1670 begin 1662 1671 Filenames := TStringList.Create; 1663 Str ingToList( TextList, Filenames, '+');1672 StrExtractStringsIgnoreEmpty(Filenames, TextList, ['+'], #0); 1664 1673 if Filenames.Count > 0 then 1665 1674 begin … … 2373 2382 Filename := THelpFile( CurrentOpenFiles[ 0 ] ).Filename; 2374 2383 NamePart := ExtractFileName( Filename ); 2375 Result := StrStarts ( 'newview', NamePart);2384 Result := StrStartsWithIgnoringCase('newview', NamePart); 2376 2385 end; 2377 2386 … … 2686 2695 + g_ExternalLinkFilename; 2687 2696 2688 if not Str ingsSame( FilePath, g_ExternalLinkSourceFilename ) then2697 if not StrEqualIgnoringCase( FilePath, g_ExternalLinkSourceFilename ) then 2689 2698 begin 2690 2699 // different file - try and open it … … 3727 3736 System.Close( F ); 3728 3737 3729 TheText := ApplicationErrorA + EndLine3730 + EndLine3731 + E.Message + EndLine3738 TheText := ApplicationErrorA + StrCRLF 3739 + StrCRLF 3740 + E.Message + StrCRLF 3732 3741 + ApplicationErrorB 3733 3742 + LogFilename 3734 + ')' + EndLine3735 + EndLine3743 + ')' + StrCRLF 3744 + StrCRLF 3736 3745 + ApplicationErrorC 3737 + EndLine;3746 + StrCRLF; 3738 3747 3739 3748 if DoYesNoDlg( ApplicationErrorTitle, … … 3802 3811 Procedure TMainForm.MainFormOnCreate (Sender: TObject); 3803 3812 var 3804 tmpCmdLine: String;3813 tmpCmdLine: AnsiString; 3805 3814 Begin 3806 3815 LogEvent(LogStartup, 'MainFormOnCreate'); … … 4061 4070 begin 4062 4071 LogEvent(LogStartup, ' Help Manager Title: ' 4063 + Str NPas( pSharedStruct ^. Title,4072 + StrPasWithLength( pSharedStruct ^. Title, 4064 4073 SHARED_STRUCT_TITLE_SIZE ) ); 4065 HelpManagerVersion := Str NPas( pSharedStruct ^. Version,4074 HelpManagerVersion := StrPasWithLength( pSharedStruct ^. Version, 4066 4075 SHARED_STRUCT_VERSION_SIZE ); 4067 4076 LogEvent(LogStartup, ' Help Manager Version: ' + HelpManagerVersion ); … … 4116 4125 + EnvironmentVarUndefined 4117 4126 + BookshelfEnvironmentVar 4118 + EndLine;4127 + StrCRLF; 4119 4128 4120 4129 if not HelpOK then … … 4122 4131 + EnvironmentVarUndefined 4123 4132 + HelpPathEnvironmentVar 4124 + EndLine;4133 + StrCRLF; 4125 4134 4126 4135 DoWarningDlg( EnvironmentVarErrorTitle, 4127 4136 EnvironmentVarError 4128 + EndLine4129 + EndLine4137 + StrCRLF 4138 + StrCRLF 4130 4139 + ErrorText ); 4131 4140 … … 4200 4209 Filenames := TStringList.Create; 4201 4210 4202 // TODO use StrExtractStrings 4203 StringToList(cmdLineParameters.getFileNames, Filenames, '+' ); 4211 StrExtractStringsIgnoreEmpty(Filenames, cmdLineParameters.getFileNames, ['+'], #0); 4204 4212 4205 4213 LogEvent(LogStartup, 'Call OpenFiles'); … … 4513 4521 for IndexIndex:= 0 to DisplayedIndex.Count - 1 do 4514 4522 begin 4515 if StrStarts ( SearchText, DisplayedIndex[ IndexIndex ] ) then //IndexEntry ) then4523 if StrStartsWithIgnoringCase( SearchText, DisplayedIndex[ IndexIndex ] ) then //IndexEntry ) then 4516 4524 begin 4517 4525 MatchIndex:= IndexIndex; … … 4803 4811 + IntToStr( SearchResultsListBox.Items.Count ) 4804 4812 + SearchFoundMsgB 4805 + StrDoubleQuote( SearchText ) ); 4813 + StrInDoubleQuotes(SearchText) 4814 ); 4806 4815 4807 4816 ClearWaitCursor; … … 4897 4906 begin 4898 4907 DoMessageDlg( UsageTitle, 4899 UsageText1 + EndLine4900 + UsageText2 + EndLine4901 + UsageText3 + EndLine4902 + UsageText4 + EndLine4903 + UsageText5 + EndLine4904 + UsageText6 + EndLine4905 + UsageText7 + EndLine4908 UsageText1 + StrCRLF 4909 + UsageText2 + StrCRLF 4910 + UsageText3 + StrCRLF 4911 + UsageText4 + StrCRLF 4912 + UsageText5 + StrCRLF 4913 + UsageText6 + StrCRLF 4914 + UsageText7 + StrCRLF 4906 4915 + UsageText8 ); 4907 4916 end; … … 5161 5170 MenuItem.Caption := PageHistory[ i ]; 5162 5171 MenuItem.Hint := GoBackHint 5163 + Str DoubleQuote( PageHistory[ i ] );5172 + StrInDoubleQuotes( PageHistory[ i ] ); 5164 5173 MenuItem.OnClick := OnNavigateToMenuItemClick; 5165 5174 MenuItem.Tag := i; … … 5259 5268 if Element.ElementType = teTextEnd then 5260 5269 break; 5261 TextIndex := PChar Diff( p, Text );5270 TextIndex := PCharPointerDiff( p, Text ); 5262 5271 if TextIndex >= Note.InsertPoint then 5263 5272 begin … … 5387 5396 Filename: string; 5388 5397 SourceFile: THelpFile; 5389 LinkedProgram: string;5390 5398 URL: string; 5391 5399 LinkDetails: string; 5400 tmpLinkDetails : TStringList; 5392 5401 ProgramInfo : TSerializableStringList; 5393 5402 ProgramPath, ProgramLink : string; 5394 5403 Begin 5395 if StrLeft( LinkString, 4 ) = 'note' then 5404 LogEvent(LogDebug, 'OnOverLink: "' + LinkString + '"'); 5405 5406 if StrStartsWith(LinkString, PARAM_LINK_NOTE) then 5396 5407 begin 5397 5408 SetStatus( EditNoteMsg ) 5398 5409 end 5399 else if Str Left( LinkString, 7 ) = 'program'then5410 else if StrStartsWith(LinkString, PARAM_LINK_PROGRAM) then 5400 5411 begin 5401 5412 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)); 5403 5416 ProgramPath := ProgramInfo.get(0); 5404 5417 ProgramLink := ProgramInfo.get(1); 5405 5418 TSerializableStringList.destroy; 5419 5406 5420 // call LaunchProgram here to inherit the environment 5407 5408 LinkedProgram := StrRightFrom( LinkString, 9 );5409 5421 SetStatus( LinkMsg + ' ' + ProgramPath + ' ' + ProgramLink); 5410 5422 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 ); 5416 5427 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 5421 5437 Window := FindWindowFromView( Sender, Windows ); 5422 5438 SourceFile := Window.Topic.HelpFile as THelpFile; 5423 5439 Filename := SourceFile.ReferencedFiles[ LinkIndex ]; 5424 5440 SetStatus( LinkMsg 5425 + Str DoubleQuote( Filename ) );5441 + StrInDoubleQuotes( Filename ) ); 5426 5442 end 5427 5443 else … … 5442 5458 begin 5443 5459 SetStatus( LinkMsg 5444 + Str DoubleQuote( Trim( LinkedTopic.Title ) ) );5460 + StrInDoubleQuotes( Trim( LinkedTopic.Title ) ) ); 5445 5461 end 5446 5462 else … … 5469 5485 URL: string; 5470 5486 LinkDetails: string; 5487 tmpLinkDetails : TStringList; 5471 5488 ProgramInfo : TSerializableStringList; 5472 5489 Begin 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) ); 5476 5495 NotesListBox.ItemIndex := NoteIndex; 5477 5496 EditNote( NoteIndex ); 5478 5497 end 5479 else if Str Left( LinkString, 7 ) = 'program'then5498 else if StrStartsWith(LinkString, PARAM_LINK_PROGRAM) then 5480 5499 begin 5481 5500 ProgramInfo := TSerializableStringList.create; 5482 ProgramInfo.readValuesFromSerializedString(Str RightFrom( LinkString, 9));5501 ProgramInfo.readValuesFromSerializedString(StrSubstringFrom(LinkString, 9)); 5483 5502 ProgramPath := ProgramInfo.get(0); 5484 5503 ProgramLink := ProgramInfo.get(1); 5485 5504 TSerializableStringList.destroy; 5505 5486 5506 // call LaunchProgram here to inherit the environment 5487 5507 LogEvent(LogDisplay, 'LaunchProgram: "' + ProgramPath + '" "' + ProgramLink + '"'); 5488 5508 LaunchProgram(ProgramPath, ProgramLink, ''); 5509 // TODO i18n 5489 5510 SetStatus( 'Launched ' + ProgramPath ); 5490 5511 end 5491 else if StrLeft( LinkString, 3 ) = 'url'then5492 begin 5493 URL := Str RightFrom(LinkString, 5);5512 else if StrLeft( LinkString, 3 ) = PARAM_LINK_URL then 5513 begin 5514 URL := StrSubstringFrom(LinkString, 5); 5494 5515 5495 5516 try … … 5503 5524 end; 5504 5525 5526 // TODO i18n 5505 5527 SetStatus('Opened ' + URL ); 5506 5528 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 5511 5538 Window := FindWindowFromView( Sender, Windows ); 5512 5539 SourceFile := Window.Topic.HelpFile as THelpFile; … … 5634 5661 FileName := ExtractFileName( FileName ); 5635 5662 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; 5639 5669 5640 5670 // stop after 50 chars … … 5870 5900 DoErrorDlg( SaveNotesTitle, 5871 5901 SaveNotesError 5872 + EndLine5902 + StrCRLF 5873 5903 + NotesFileName 5874 + EndLine5904 + StrCRLF 5875 5905 + SysErrorMessage( rc ) ); 5876 5906 exit; … … 5947 5977 DoErrorDlg( LoadNotesTitle, 5948 5978 LoadNotesError 5949 + EndLine5979 + StrCRLF 5950 5980 + NotesFileName 5951 + EndLine5981 + StrCRLF 5952 5982 + SysErrorMessage( rc ) ); 5953 5983 exit; … … 6165 6195 begin 6166 6196 Result:= CurrentOpenFiles[ FileIndex ]; 6167 if Str ingsSame( Result.Filename, FileName ) then6197 if StrEqualIgnoringCase( Result.Filename, FileName ) then 6168 6198 // found 6169 6199 exit; … … 6452 6482 result := DoYesNoDlg( WindowsHelpTitle, 6453 6483 WindowsHelpPrompt 6454 + EndLine6484 + StrCRLF 6455 6485 + FileName ); 6456 6486 if not result then
Note:
See TracChangeset
for help on using the changeset viewer.