Changeset 54


Ignore:
Timestamp:
Jan 11, 2007, 9:08:05 PM (19 years ago)
Author:
RBRi
Message:

refactoring to simplify command line handling in MainForm
some tests fixed

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/NewView/CmdLineParameterUnit.pas

    r45 r54  
    7474
    7575       PROCEDURE parseCmdLine(aCmdLineString : String);
     76
     77       FUNCTION getInterpretedFileNames: String;
     78       FUNCTION getInterpretedSearchText: String;
    7679     private
    7780       PROCEDURE parseSwitch(aCmdLineString : String);
    7881  end;
    7982
     83  FUNCTION getOwnHelpFileName: String;
     84
    8085  // returns a string containing the whole
    8186  // command line parametes
    82   FUNCTION nativeOS2GetCmdLineParameter : STRING;
     87  FUNCTION nativeOS2GetCmdLineParameter : String;
    8388
    8489
    8590Implementation
     91uses
     92  ACLFileUtility;
     93
     94  FUNCTION TCmdLineParameters.getInterpretedFileNames: String;
     95  var
     96    tmpOwnHelpFileName : String;
     97  begin
     98    result := getFileNames;
     99
     100    if getGlobalSearchFlag
     101       AND (getSearchText = '')
     102    then
     103    begin
     104      result := '';
     105      exit;
     106    end;
     107
     108
     109    tmpOwnHelpFileName := FindDefaultLanguageHelpFile('NewView');
     110    if (result = '') AND
     111      FileExists(tmpOwnHelpFileName)
     112    then
     113      result := tmpOwnHelpFileName;
     114  end;
     115
     116
     117  FUNCTION TCmdLineParameters.getInterpretedSearchText: String;
     118  begin
     119    result := getSearchText;
     120
     121    if getGlobalSearchFlag
     122       AND (result = '')
     123    then
     124      result := getFileNamesRaw;
     125  end;
     126
    86127
    87128  FUNCTION TCmdLineParameters.setHelpManagerFlag(aNewValue : boolean) : boolean;
     
    456497
    457498
     499  FUNCTION getOwnHelpFileName: String;
     500  begin
     501    result := FindDefaultLanguageHelpFile('NewView');
     502  end;
     503
     504
    458505  FUNCTION nativeOS2GetCmdLineParameter : STRING;
    459506  VAR
  • trunk/NewView/MainForm.pas

    r49 r54  
    41904190      LogEvent(LogStartup, 'Showing usage');
    41914191      ShowUsage;
    4192 
    4193       if FileExists( GetOwnHelpFileName ) then
    4194         OpenFile( GetOwnHelpFileName, '', true );
    4195 
    4196       exit;
    41974192    end;
    41984193  end;
     
    42004195  HelpManagerWindows.Add( pointer( CmdLineParameters.getHelpManagerWindow ) );
    42014196
    4202   if CmdLineParameters.getFileNames <> '' then
     4197  if CmdLineParameters.getInterpretedFileNames <> '' then
    42034198  begin
    42044199    // open specified files
     
    42064201
    42074202    // TODO use StrExtractStrings
    4208     StringToList(cmdLineParameters.getFileNames, Filenames, '+' );
     4203    StringToList(cmdLineParameters.getInterpretedFileNames, Filenames, '+' );
    42094204
    42104205    LogEvent(LogStartup, 'Call OpenFiles');
     
    42124207    OpenFirstTopic := true;
    42134208
    4214     if ( CmdLineParameters.getSearchText <> '' )
    4215        or CmdLineParameters.getSearchFlag then
     4209    if ( CmdLineParameters.getInterpretedSearchText <> '' )
     4210       OR CmdLineParameters.getSearchFlag
     4211       OR CmdLineParameters.getHelpManagerFlag
     4212    then
    42164213      // if we're going to search, don't open first topic
    4217       OpenFirstTopic := false;
    4218 
    4219     if CmdLineParameters.getHelpManagerFlag then
    4220     begin
    42214214      // don't open first topic if we're online help
    42224215      // in case we are wanting to show a specific topic
    42234216      // - saves time/flicker
    42244217      OpenFirstTopic := false;
    4225     end;
    4226 
    4227     if NOT (  CmdLineParameters.getGlobalSearchFlag
    4228               AND (CmdLineParameters.getSearchText = '')
    4229            )
    4230     then
    4231     begin
     4218
    42324219    OpenFiles( Filenames,
    42334220               CmdLineParameters.getWindowTitle,
    42344221               OpenFirstTopic );
    4235     end;
    42364222
    42374223    Filenames.Destroy;
     
    42394225    if not CmdLineParameters.getSearchFlag
    42404226       and not CmdLineParameters.getGlobalSearchFlag
    4241        and (CmdLineParameters.getSearchText <> '') then
     4227       and (CmdLineParameters.getInterpretedSearchText <> '') then
    42424228    begin
    42434229      // search in contents only!
     
    42524238      DisplaySearch;
    42534239
    4254       SearchFor( CmdLineParameters.getSearchText );
     4240      SearchFor( CmdLineParameters.getInterpretedSearchText );
    42554241    end;
    42564242  end;
    42574243
    4258   if CmdLineParameters.getGlobalSearchFlag then
     4244  if NOT CmdLineParameters.getShowUsageFlag
     4245     AND CmdLineParameters.getGlobalSearchFlag then
    42594246  begin
    42604247    // Global search
    4261     if (CmdLineParameters.getSearchText = '')
    4262       AND (CmdLineParameters.getFileNamesRaw <> '')
    4263     then
    4264     begin
    4265       LogEvent(LogStartup, 'Do global search: ' + CmdLineParameters.getFileNamesRaw );
    4266       DoGlobalSearch( CmdLineParameters.getFileNamesRaw );
    4267     end
    4268     else
    4269     begin
    4270       LogEvent(LogStartup, 'Do global search: ' + CmdLineParameters.getSearchText );
    4271       DoGlobalSearch( CmdLineParameters.getSearchText );
    4272     end;
    4273   end;
    4274 
    4275   if     ( length(CmdLineParameters.getFileNames) = 0 )
    4276      and ( not CmdLineParameters.getSearchFlag ) then
    4277   begin
    4278     // user hasn't requested any particular file
    4279     // at startup, so if the option is still set,
    4280     // load the NewView help file
    4281     if Settings.StartupHelp then
    4282       if FileExists( GetOwnHelpFileName ) then
    4283         OpenFile( GetOwnHelpFileName, '', true );
     4248    LogEvent(LogStartup, 'Do global search: ' + CmdLineParameters.getFileNamesRaw );
     4249    DoGlobalSearch( CmdLineParameters.getInterpretedSearchText );
    42844250  end;
    42854251
  • trunk/NewView/StartupUnit.pas

    r48 r54  
    2727// False if it should immediately exit.
    2828function Startup: boolean;
    29 
    30 function GetOwnHelpFileName: string;
    3129
    3230// Look for any items that are actually specifiying environment
     
    168166end;
    169167
    170 function GetOwnHelpFileName: string;
    171 begin
    172   Result := FindDefaultLanguageHelpFile( 'NewView' );
    173 end;
    174168
    175169// If another instance already has the files open
  • trunk/test/tests.cmd

    r49 r54  
    135135say "*                                                                       *"
    136136say "* Expected                                                              *"
    137 say "* NewView start and shows the 'Command Reference' help                  *"
    138 say "* - left navigation is shown                                            *"
    139 say "* - contents tab is selected                                            *"
    140 say "* - all contents are collapsed                                          *"
    141 say "* - 'Introduction' is selected and visible at the right                 *"
     137say "* NewView start and shows nothing                                       *"
     138say "* - left navigation is NOT shown                                        *"
    142139say "* - The 'Search all fieles' dialog is opend and searches for copy       *"
    143140say "*************************************************************************"
Note: See TracChangeset for help on using the changeset viewer.