Browse Source

+ implemented GetSupportedCodePageCount/GetSupportedCodePage for unicode consoles

git-svn-id: branches/unicodekvm@48913 -
nickysn 4 years ago
parent
commit
c6bce8915f

+ 1 - 1
packages/rtl-console/src/amicommon/video.pp

@@ -55,7 +55,7 @@ var
 implementation
 implementation
 
 
 uses
 uses
-   exec, agraphics, graphemebreakproperty, eastasianwidth;
+   exec, agraphics, graphemebreakproperty, eastasianwidth, charset;
 
 
 procedure SysUpdateScreen(Force: Boolean); forward;
 procedure SysUpdateScreen(Force: Boolean); forward;
 
 

+ 1 - 1
packages/rtl-console/src/go32v2/video.pp

@@ -28,7 +28,7 @@ implementation
 uses
 uses
   mouse,
   mouse,
   go32,
   go32,
-  graphemebreakproperty,eastasianwidth;
+  graphemebreakproperty,eastasianwidth,charset;
 
 
 {$i video.inc}
 {$i video.inc}
 
 

+ 34 - 9
packages/rtl-console/src/inc/video.inc

@@ -531,15 +531,21 @@ begin
     Result := DefaultSystemCodePage;
     Result := DefaultSystemCodePage;
 end;
 end;
 
 
-procedure ActivateCodePage(CodePage: TSystemCodePage);
+{ disallowed codepages (variable length), code points larger than an 8-bit byte, etc. }
+function IsDisallowedCodePage(CodePage: TSystemCodePage): Boolean;
 const
 const
   CP_UTF32LE=12000;
   CP_UTF32LE=12000;
   CP_UTF32BE=12001;
   CP_UTF32BE=12001;
 begin
 begin
-  { disallowed codepages (variable length), code points larger than an 8-bit byte, etc. }
-  if (CodePage=CP_UTF8) or (CodePage=CP_UTF7) or
-     (CodePage=CP_UTF16) or (CodePage=CP_UTF16BE) or
-     (CodePage=CP_UTF32LE) or (CodePage=CP_UTF32BE) then
+  Result:=(CodePage=CP_ACP) or (CodePage=CP_OEMCP) or (CodePage=CP_NONE) or
+          (CodePage=CP_UTF8) or (CodePage=CP_UTF7) or
+          (CodePage=CP_UTF16) or (CodePage=CP_UTF16BE) or
+          (CodePage=CP_UTF32LE) or (CodePage=CP_UTF32BE);
+end;
+
+procedure ActivateCodePage(CodePage: TSystemCodePage);
+begin
+  if IsDisallowedCodePage(CodePage) then
     exit;
     exit;
   if EnhancedVideoInitialized then
   if EnhancedVideoInitialized then
     CurrentLegacy2EnhancedTranslationCodePage := CodePage
     CurrentLegacy2EnhancedTranslationCodePage := CodePage
@@ -547,12 +553,30 @@ begin
     CurrentVideoDriver.ActivateCodePage(CodePage);
     CurrentVideoDriver.ActivateCodePage(CodePage);
 end;
 end;
 
 
+var
+  SupportedCodePagesCount: Integer = -1;
+  SupportedCodePages: array of TSystemCodePage;
+
+procedure InitSupportedCodePages;
+var
+  CP: TSystemCodePage;
+begin
+  SetLength(SupportedCodePages, 0);
+  for CP:=Low(TSystemCodePage) to High(TSystemCodePage) do
+    if (not IsDisallowedCodePage(CP)) and MappingAvailable(CP) then
+      begin
+        SetLength(SupportedCodePages,Length(SupportedCodePages)+1);
+        SupportedCodePages[High(SupportedCodePages)]:=CP;
+      end;
+end;
+
 function GetSupportedCodePageCount: Integer;
 function GetSupportedCodePageCount: Integer;
 begin
 begin
   if EnhancedVideoInitialized then
   if EnhancedVideoInitialized then
     begin
     begin
-      { todo... }
-      Result := 0;
+      if SupportedCodePagesCount = -1 then
+        InitSupportedCodePages;
+      Result := SupportedCodePagesCount;
     end
     end
   else if VideoInitialized and Assigned(CurrentVideoDriver.GetSupportedCodePageCount) then
   else if VideoInitialized and Assigned(CurrentVideoDriver.GetSupportedCodePageCount) then
     Result := CurrentVideoDriver.GetSupportedCodePageCount()
     Result := CurrentVideoDriver.GetSupportedCodePageCount()
@@ -564,8 +588,9 @@ function GetSupportedCodePage(Index: Integer): TSystemCodePage;
 begin
 begin
   if EnhancedVideoInitialized then
   if EnhancedVideoInitialized then
     begin
     begin
-      { todo... }
-      Result := 0;
+      if SupportedCodePagesCount = -1 then
+        InitSupportedCodePages;
+      Result := SupportedCodePages[Index];
     end
     end
   else if VideoInitialized and Assigned(CurrentVideoDriver.GetSupportedCodePage) then
   else if VideoInitialized and Assigned(CurrentVideoDriver.GetSupportedCodePage) then
     Result := CurrentVideoDriver.GetSupportedCodePage(Index)
     Result := CurrentVideoDriver.GetSupportedCodePage(Index)

+ 1 - 1
packages/rtl-console/src/msdos/video.pp

@@ -28,7 +28,7 @@ implementation
 uses
 uses
   mouse,
   mouse,
   dos,
   dos,
-  graphemebreakproperty,eastasianwidth;
+  graphemebreakproperty,eastasianwidth,charset;
 
 
 {$i video.inc}
 {$i video.inc}
 
 

+ 1 - 1
packages/rtl-console/src/netware/video.pp

@@ -23,7 +23,7 @@ interface
 implementation
 implementation
 
 
 uses
 uses
-  dos,graphemebreakproperty,eastasianwidth;
+  dos,graphemebreakproperty,eastasianwidth,charset;
 
 
 {$i video.inc}
 {$i video.inc}
 {$i nwsys.inc}
 {$i nwsys.inc}

+ 1 - 1
packages/rtl-console/src/netwlibc/video.pp

@@ -22,7 +22,7 @@ interface
 implementation
 implementation
 
 
 uses
 uses
-  Libc,graphemebreakproperty,eastasianwidth;
+  Libc,graphemebreakproperty,eastasianwidth,charset;
 
 
 {$i video.inc}
 {$i video.inc}
 
 

+ 1 - 1
packages/rtl-console/src/os2commn/video.pp

@@ -22,7 +22,7 @@ interface
 implementation
 implementation
 
 
 uses
 uses
-  DosCalls, VioCalls, Mouse, graphemebreakproperty, eastasianwidth;
+  DosCalls, VioCalls, Mouse, graphemebreakproperty, eastasianwidth, charset;
 
 
 {$i video.inc}
 {$i video.inc}
 
 

+ 1 - 0
packages/rtl-console/src/unix/video.pp

@@ -59,6 +59,7 @@ var internal_codepage,external_codepage:Tencoding;
 {*****************************************************************************}
 {*****************************************************************************}
 
 
 uses  baseunix,termio,strings,unixkvmbase,graphemebreakproperty,eastasianwidth
 uses  baseunix,termio,strings,unixkvmbase,graphemebreakproperty,eastasianwidth
+     ,charset
      {$ifdef linux},linuxvcs{$endif};
      {$ifdef linux},linuxvcs{$endif};
 
 
 {$i video.inc}
 {$i video.inc}

+ 1 - 1
packages/rtl-console/src/win/video.pp

@@ -23,7 +23,7 @@ procedure VideoSetConsoleOutHandle (NewHandle: THandle);
 implementation
 implementation
 
 
 uses
 uses
-  windows,dos,graphemebreakproperty,eastasianwidth;
+  windows,dos,graphemebreakproperty,eastasianwidth,charset;
 
 
 {$i video.inc}
 {$i video.inc}
 
 

+ 1 - 1
packages/rtl-console/src/win16/video.pp

@@ -31,7 +31,7 @@ var
 implementation
 implementation
 
 
 uses
 uses
-  WinProcs, graphemebreakproperty, eastasianwidth;
+  WinProcs, graphemebreakproperty, eastasianwidth, charset;
 
 
 {$I video.inc}
 {$I video.inc}