Bläddra i källkod

* improved paging of help pages so that lines are not missed with 80x25 windows due to lines overflowing the window width

git-svn-id: trunk@30026 -
Tomas Hajny 10 år sedan
förälder
incheckning
1ecf8dcfa1
2 ändrade filer med 36 tillägg och 3 borttagningar
  1. 11 3
      compiler/options.pas
  2. 25 0
      compiler/widestr.pas

+ 11 - 3
compiler/options.pas

@@ -96,6 +96,7 @@ uses
 
 const
   page_size = 24;
+  page_width = 80;
 
 var
   option     : toption;
@@ -603,10 +604,12 @@ var
   lastident,
   j,outline,
   ident,
+  HelpLineHeight,
   lines : longint;
   show  : boolean;
   opt   : string[32];
   input,
+  HelpLine,
   s     : string;
   p     : pchar;
 begin
@@ -730,8 +733,13 @@ begin
            Comment(V_Normal,'');
            inc(Lines);
          end;
+        HelpLine := PadEnd('',ident)+opt+Copy(s,j+1,255);
+        if HelpLine = '' then
+         HelpLineHeight := 1
+        else
+         HelpLineHeight := Succ (CharLength (HelpLine) div Page_Width);
       { page full ? }
-        if (lines >= page_size - 1) then
+        if (lines + HelpLineHeight >= page_size - 1) then
          begin
            if not NoPressEnter then
             begin
@@ -742,9 +750,9 @@ begin
             end;
            lines:=0;
          end;
-        Comment(V_Normal,PadEnd('',ident)+opt+Copy(s,j+1,255));
+        Comment(V_Normal,HelpLine);
         LastIdent:=Ident;
-        inc(Lines);
+        Inc (Lines, HelpLineHeight);
       end;
    end;
   StopOptions(0);

+ 25 - 0
compiler/widestr.pas

@@ -63,6 +63,8 @@ unit widestr;
       d : pchar; dcp : tstringencoding
     );
     function codepagebyname(const s : string) : tstringencoding;
+    function CharLength (P: PChar; L: SizeInt): SizeInt;
+    function CharLength (const S: string): SizeInt;
 
   implementation
 
@@ -342,4 +344,27 @@ unit widestr;
           Result:=p^.cp;
       end;
 
+    function CharLength (P: PChar; L: SizeInt): SizeInt;
+      var
+        P2: PChar;
+      begin
+        if L = 0 then
+         begin
+          Result := 0;
+          Exit;
+         end;
+        GetMem (P2, Succ (L));
+{ Length of the string converted to a SBCS codepage (e.g. ISO 8859-1)
+  should be equal to the amount of characters in the source string. }
+        ChangeCodePage (P, L, DefaultSystemCodepage, P2, 28591);
+        P2 [L] := #0;
+        Result := StrLen (P2);
+        FreeMem (P2, Succ (L));
+      end;
+
+    function CharLength (const S: string): SizeInt;
+      begin
+        Result := CharLength (@S [1], Length (S));
+      end;
+
 end.