Changeset 140


Ignore:
Timestamp:
Apr 30, 2007, 9:01:02 PM (18 years ago)
Author:
RBRi
Message:

more refactoring

Location:
trunk/NewView
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/NewView/HelpFile.pas

    r124 r140  
    157157  BseErr,
    158158  StringUtilsUnit,
     159  CharUtilsUnit,
    159160  DebugUnit,
    160   ACLStringUtility,
    161161  ACLFileIOUtility,
    162162  ACLLanguageUnit;
     
    964964  i: longint;
    965965  pFontSpec: pTHelpFontSpec;
     966  tmpSubstitutionItems : TStringList;
     967  tmpCounter : integer;
     968  tmpDimensionParts : TStringList;
    966969begin
    967970  ParseFontTable; // (re)load table from raw data
    968971
    969   while Substitutions <> '' do
    970   begin
    971     Item := ExtractNextValue( Substitutions, ';' );
     972  tmpSubstitutionItems := TStringList.Create;
     973  StrExtractStrings(tmpSubstitutionItems, Substitutions, [';'], #0);
     974
     975  for tmpCounter := 0 to tmpSubstitutionItems.Count - 1 do
     976  begin
     977    Item := tmpSubstitutionItems[tmpCounter];
    972978    try
    973979      if Item <> '' then
     
    975981        // Look for space in xxxx WxH
    976982
    977         SpacePos := FindCharFromEnd( Item, ' ' );
     983        SpacePos := LastPosOfChar(' ', Item);
    978984        if SpacePos > 0 then
    979985        begin
     
    981987          FontName := StrLeft( Item, SpacePos - 1 );
    982988          Delete( Item, 1, SpacePos );
     989
    983990          // width and height after, with an X between
    984           W := StrToInt( ExtractNextValue( Item, 'x' ) );
    985           H := StrToInt( Item );
     991          tmpDimensionParts := TStringList.Create;
     992          StrExtractStrings(tmpDimensionParts, Item, ['x'], #0);
     993          W := StrToInt(tmpDimensionParts[0]);
     994          H := StrToInt(tmpDimensionParts[1]);
     995          tmpDimensionParts.Destroy;
    986996          if ( W > 0 ) and ( H > 0 ) then
    987997          begin
     
    9901000            begin
    9911001              pFontSpec := _FontTable[ i ];
    992               if StrNPas( pFontSpec ^. FaceName,
    993                           sizeof( pFontSpec ^. FaceName ) ) = FontName then
     1002              if StrPasWithLength( pFontSpec^.FaceName, sizeof( pFontSpec^.FaceName ) ) = FontName then
    9941003              begin
    9951004                // same face name...
     
    10071016    end;
    10081017  end;
     1018
     1019  tmpSubstitutionItems.Destroy;
    10091020end;
    10101021
     
    10261037  Result := '';
    10271038
    1028   if    StringsSame( Ext, '.inf' )
    1029      or StringsSame( Ext, '.hlp' ) then
     1039  if    StrEqualIgnoringCase( Ext, '.inf' )
     1040     or StrEqualIgnoringCase( Ext, '.hlp' ) then
    10301041  begin
    10311042    szName := Filename;
  • trunk/NewView/HelpTopic.pas

    r127 r140  
    253253  NewViewConstantsUnit,
    254254  ACLUtility,
    255   ACLStringUtility,
    256255  ACLFileIOUtility,
    257256  AStringUtilityUnit,
    258257  ACLLanguageUnit,
    259258  StringUtilsUnit,
     259  CharUtilsUnit,
    260260  SettingsUnit;
    261261
     
    565565
    566566  Write( F, ':artwork name=' );
    567   Write( F, StrQuote( 'img' + IntToStr( ImageIndex ) + '.bmp' ) );
     567  Write( F, StrInSingleQuotes('img' + IntToStr(ImageIndex) + '.bmp') );
    568568
    569569  case BitmapFlags and 7 of
     
    826826end;
    827827
     828// TODO
    828829function FullDoubleQuote( const s: string ): string;
    829830begin
    830   Result := DoubleQuote
    831             + InsertDuplicateChars( s,
    832                                     DoubleQuote )
    833             + DoubleQuote;
     831  Result := StrDoubleQuote
     832            + StrEscapeAllCharsBy(s, [], CharDoubleQuote)
     833            + StrDoubleQuote;
    834834end;
    835835
     
    906906  ProgramFilename: string;
    907907  ProgramInfo : TSerializableStringList;
     908  tmpProgramLinkParts : TStringList;
    908909
    909910  OutputString: string;
     
    10311032      // :link reftype=hd refid=... database=<filename>
    10321033      ExternalLinkFileIndex := ( pData + 2 )^;
    1033       ExternalLinkTopicID := StrNPas( pchar( pData + 4 ), ( pData + 3 )^ );
     1034      ExternalLinkTopicID := StrPasWithLength( pchar( pData + 4 ), ( pData + 3 )^ );
    10341035      OutputString := '<blue><link ' + PARAM_LINK_EXTERNAL + ' '
    10351036                      + IntToStr( ExternalLinkFileIndex )
     
    10431044    begin
    10441045      CheckForAutoURL( Text, State );
    1045       ProgramLink := StrNPas( pchar( pData + 3 ), EscapeLen - 3 );
    1046       ProgramPath := ExtractNextValue( ProgramLink, ' ' );
     1046      ProgramLink := StrPasWithLength( pchar( pData + 3 ), EscapeLen - 3 );
     1047
     1048      tmpProgramLinkParts := TStringList.Create;
     1049      StrExtractStrings(tmpProgramLinkParts, ProgramLink, [' '], #0);
     1050      ProgramPath := tmpProgramLinkParts[0];
     1051      tmpProgramLinkParts.Destroy;
     1052
    10471053      ProgramFilename := ExtractFilename( ProgramPath );
    1048       if    StrStarts( 'netscape', ProgramFilename )
    1049          or StrStarts( 'explore', ProgramFilename ) // web explorer?
    1050          or StrStarts( 'mozilla', ProgramFilename )
     1054
     1055      if    StrStartsWithIgnoringCase(PRGM_EXPLORER, ProgramFilename ) // web explorer?
     1056         or StrStartsWithIgnoringCase(PRGM_NETSCAPE, ProgramFilename )
     1057         or StrStartsWithIgnoringCase(PRGM_MOZILLA, ProgramFilename )
     1058         or StrStartsWithIgnoringCase(PRGM_FIREFOX, ProgramFilename )
    10511059         then
    10521060      begin
     
    12011209        begin
    12021210          pFontSpec := _FontTable[ FontIndex ];
    1203           FaceName := StrNPas( pFontSpec ^. FaceName,
     1211          FaceName := StrPasWithLength( pFontSpec ^. FaceName,
    12041212                               sizeof( pFontSpec ^. FaceName ) );
    12051213          // arbitrarily and capriciously use specified height * 2/3
     
    15111519
    15121520        // s := pstring( _GlobalDictionary[ DictIndex ] )^; // for debug only
    1513         if not IsSpaces( pstring( _GlobalDictionary[ DictIndex ] )^ ) then
     1521        if not StrIsEmptyOrSpaces( pstring( _GlobalDictionary[ DictIndex ] )^ ) then
    15141522        begin
    15151523          if pSequenceStepWords^[ DictIndex ] = 0 then
     
    16381646          StringToAdd := '';
    16391647
    1640         if IsSpaces( StringToAdd ) then
     1648        if StrIsEmptyOrSpaces( StringToAdd ) then
    16411649        begin
    16421650          // spaces only...
     
    20222030
    20232031      if GlobalDictIndex < _GlobalDictionary.Count then
    2024         if not IsSpaces( pstring( _GlobalDictionary[ GlobalDictIndex ] )^ ) then;
     2032        if not StrIsEmptyOrSpaces( pstring( _GlobalDictionary[ GlobalDictIndex ] )^ ) then;
    20252033          WordRelevance := pStepWordRelevances[ GlobalDictIndex ];
    20262034
     
    22652273  ProgramLink: string;
    22662274  ProgramPath: string;
     2275  tmpProgramLinkParts : TStringList;
    22672276
    22682277  OutputString: string;
     
    23722381    begin
    23732382      ExternalLinkFileIndex := ( pData + 2 )^;
    2374       ExternalLinkTopicID := StrNPas( pchar( pData + 4 ), ( pData + 3 )^ );
     2383      ExternalLinkTopicID := StrPasWithLength( pchar( pData + 4 ), ( pData + 3 )^ );
    23752384      Write( F, ':link reftype=hd '
    2376              + ' refid=' + StrQuote( ExternalLinkTopicID )
    2377              + ' database=' + StrQuote( _ReferencedFiles[ ExternalLinkFileIndex ] )
     2385             + ' refid=' + StrInSingleQuotes( ExternalLinkTopicID )
     2386             + ' database=' + StrInSingleQuotes( _ReferencedFiles[ ExternalLinkFileIndex ] )
    23782387             + '.' );
    23792388
     
    23822391    ecProgramLink:
    23832392    begin
    2384       ProgramLink := StrNPas( pchar( pData + 3 ), EscapeLen - 3 );
    2385       ProgramPath := ExtractNextValue( ProgramLink, ' ' );
     2393      ProgramLink := StrPasWithLength( pchar( pData + 3 ), EscapeLen - 3 );
     2394
     2395      tmpProgramLinkParts := TStringList.Create;
     2396      StrExtractStrings(tmpProgramLinkParts, ProgramLink, [' '], #0);
     2397      ProgramPath := tmpProgramLinkParts[0];
     2398      tmpProgramLinkParts.Destroy;
     2399
    23862400      Write( F, ':link reftype=launch'
    2387              + ' object=' + StrQuote( ProgramPath )
    2388              + ' data=' + StrQuote( ProgramLink )
     2401             + ' object=' + StrInSingleQuotes( ProgramPath )
     2402             + ' data=' + StrInSingleQuotes( ProgramLink )
    23892403             + '.' );
    23902404    end;
     
    25062520        begin
    25072521          pFontSpec := _FontTable[ FontIndex ];
    2508           FaceName := StrNPas( pFontSpec ^. FaceName,
     2522          FaceName := StrPasWithLength( pFontSpec ^. FaceName,
    25092523                               sizeof( pFontSpec ^. FaceName ) );
    25102524          Write( F,
    2511                  ':font facename=' + StrQuote( FaceName )
     2525                 ':font facename=' + StrInSingleQuotes( FaceName )
    25122526                 + ' size=' + IntToStr( pFontSpec ^. Height )
    25132527                   + 'x' + IntToStr( pFontSpec ^. Width )
  • trunk/NewView/NewViewConstantsUnit.pas

    r127 r140  
    1616  PARAM_LINK_EXTERNAL = 'external';
    1717
     18  PRGM_EXPLORER = 'explore'; // web explorer
     19  PRGM_NETSCAPE = 'netscape';
     20  PRGM_MOZILLA = 'mozilla';
     21  PRGM_FIREFOX = 'firefox';
     22
     23
    1824Implementation
    1925
  • trunk/NewView/ViewStub.pas

    r78 r140  
    6868    result := NULLHANDLE;
    6969
    70     if aCmdLineParameters.getFileNames = '' then
     70    if aCmdLineParameters.getFileNames(false) = '' then
    7171      // not loading files; nothing to check
    7272      exit;
     
    7575    tmpFilenames := TStringList.Create;
    7676
    77     StrExtractStrings(tmpFileItems, aCmdLineParameters.getFileNames, ['+'], #0);
     77    StrExtractStrings(tmpFileItems, aCmdLineParameters.getFileNames(false), ['+'], #0);
    7878    TranslateIPFEnvironmentVars(tmpFileItems, tmpFileNames );
    7979
Note: See TracChangeset for help on using the changeset viewer.