Browse Source

+ added functions for getting/setting the current code page, when using the
legacy (non-Unicode) video buffer

git-svn-id: branches/unicodekvm@48908 -

nickysn 4 years ago
parent
commit
2abcf62a95
2 changed files with 41 additions and 2 deletions
  1. 33 2
      packages/rtl-console/src/inc/video.inc
  2. 8 0
      packages/rtl-console/src/inc/videoh.inc

+ 33 - 2
packages/rtl-console/src/inc/video.inc

@@ -115,6 +115,7 @@ end;
 Var
   CurrentVideoDriver : TVideoDriver;
   NextVideoMode      : TVideoMode;
+  CurrentLegacy2EnhancedTranslationCodePage: TSystemCodePage;
 
 Const
   VideoInitialized : Boolean = False;
@@ -241,7 +242,10 @@ begin
   if not VideoInitialized then
     begin
       if Assigned(CurrentVideoDriver.InitEnhancedDriver) then
-        CurrentVideoDriver.InitEnhancedDriver
+        begin
+          CurrentLegacy2EnhancedTranslationCodePage := 437;
+          CurrentVideoDriver.InitEnhancedDriver;
+        end
       else if Assigned(CurrentVideoDriver.InitDriver) then
         CurrentVideoDriver.InitDriver;
       if errorcode=viook then
@@ -352,7 +356,7 @@ begin
     begin
       SetLength(tmpS, 1);
       tmpS[1]:=Ch;
-      System.SetCodePage(tmpS,CP_OEMCP,False);
+      System.SetCodePage(tmpS,CurrentLegacy2EnhancedTranslationCodePage,False);
       Result:=tmpS;
     end;
 end;
@@ -517,6 +521,33 @@ begin
     Inc(Result, ExtendedGraphemeClusterDisplayWidth(EGC));
 end;
 
+function GetActiveCodePage: TSystemCodePage;
+begin
+  if EnhancedVideoInitialized then
+    Result := CurrentLegacy2EnhancedTranslationCodePage
+  else
+    {todo: get this from the driver}
+    Result := DefaultSystemCodePage;
+end;
+
+procedure ActivateCodePage(CodePage: TSystemCodePage);
+begin
+  if EnhancedVideoInitialized then
+    CurrentLegacy2EnhancedTranslationCodePage := CodePage;
+end;
+
+function GetSupportedCodePageCount: Integer;
+begin
+  { todo... }
+  Result := 0;
+end;
+
+function GetSupportedCodePage(Index: Integer): TSystemCodePage;
+begin
+  { todo... }
+  Result := 0;
+end;
+
 { ---------------------------------------------------------------------
     General functions
   ---------------------------------------------------------------------}

+ 8 - 0
packages/rtl-console/src/inc/videoh.inc

@@ -180,6 +180,14 @@ function ExtendedGraphemeClusterDisplayWidth(const EGC: UnicodeString): Integer;
 { Returns the number of display columns needed for the given extended grapheme cluster }
 function StringDisplayWidth(const S: UnicodeString): Integer;
 { Returns the number of display columns needed for the given string }
+function GetActiveCodePage: TSystemCodePage;
+{ Returns the current active legacy code page }
+procedure ActivateCodePage(CodePage: TSystemCodePage);
+{ Activates a specified legacy code page (if supported) }
+function GetSupportedCodePageCount: Integer;
+{ Get the number of code pages supported by this driver }
+function GetSupportedCodePage(Index: Integer): TSystemCodePage;
+{ Get the supported code page with index Index. Index is zero based. }
 
 procedure GetVideoMode(var Mode: TVideoMode);
 { Return dimensions of the current video mode }