Changeset 118 for trunk


Ignore:
Timestamp:
Feb 18, 2022, 10:31:00 AM (3 years ago)
Author:
chronos
Message:
  • Modified: Highlight also floating numbers with decimal point.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UVCardHighlighter.pas

    r115 r118  
    157157var
    158158  I: Integer;
    159 begin
     159  DecimalPointUsed: Boolean;
     160begin
     161  DecimalPointUsed := False;
    160162  if Length(Text) > 0 then begin
    161163    Result := True;
    162164    for I := 1 to Length(Text) do begin
    163       if not IsDigit(Text[I]) then begin
     165      if not IsDigit(Text[I]) and not (not DecimalPointUsed and (Text[I] = '.')) then begin
    164166        Result := False;
    165167        Break;
    166168      end;
     169      if Text[I] = '.' then DecimalPointUsed := True;
    167170    end;
    168171  end else Result := False;
     
    215218var
    216219  L: Integer;
     220  DecimalPointUsed: Boolean;
    217221begin
    218222  // FTokenEnd should be at the start of the next Token (which is the Token we want)
     
    227231
    228232  L := Length(FLineText);
    229   If FTokenPos > L then
     233  If FTokenPos > L then begin
    230234    // At line end
    231     Exit
     235    Exit;
     236  end
    232237  else
    233238  if FLineText[FTokenEnd] in [#9, ' '] then begin
     
    240245  end else
    241246  if IsDigit(FLineText[FTokenEnd]) then begin
    242     while (FTokenEnd <= L) and IsDigit(FLineText[FTokenEnd]) do
     247    DecimalPointUsed := False;
     248    while (FTokenEnd <= L) and (IsDigit(FLineText[FTokenEnd]) or
     249    (not DecimalPointUsed and (FLineText[FTokenEnd] = '.'))) do begin
     250      if FLineText[FTokenEnd] = '.' then DecimalPointUsed := True;
    243251      Inc(FTokenEnd);
     252    end;
    244253  end else begin
    245254    // At None-Space? Find end of None-spaces
Note: See TracChangeset for help on using the changeset viewer.