From b8dfa1b8e68946db2ce52deb37c681eccba73418 Mon Sep 17 00:00:00 2001 From: nickysn Date: Sun, 31 Jan 2021 13:57:46 +0000 Subject: [PATCH] + initial attempt at defining an enhanced video cell record for the Unicode support in the video unit git-svn-id: branches/unicodekvm@48465 - --- packages/rtl-console/src/inc/video.inc | 67 +++++++++++++++++++++++++ packages/rtl-console/src/inc/videoh.inc | 27 ++++++++++ 2 files changed, 94 insertions(+) diff --git a/packages/rtl-console/src/inc/video.inc b/packages/rtl-console/src/inc/video.inc index 841a56d569..4cf7680f6c 100644 --- a/packages/rtl-console/src/inc/video.inc +++ b/packages/rtl-console/src/inc/video.inc @@ -11,6 +11,73 @@ **********************************************************************} +{ TEnhancedVideoCell } + +function TEnhancedVideoCell.GetAttribute: Byte; +begin + GetAttribute := Byte(FAttributes); +end; + +procedure TEnhancedVideoCell.SetAttribute(Attr: Byte); +begin + FAttributes := (FAttributes and $FF00) or Attr; +end; + +function TEnhancedVideoCell.GetExtendedGraphemeCluster: WideString; +begin + if (FAttributes and $8000) = 0 then + GetExtendedGraphemeCluster := EGC_SingleChar + else + GetExtendedGraphemeCluster := WideString(EGC_WideStr); +end; + +procedure TEnhancedVideoCell.SetExtendedGraphemeCluster(const AExtendedGraphemeCluster: WideString); +begin + if Length(AExtendedGraphemeCluster) = 1 then + begin + if (FAttributes and $8000) <> 0 then + begin + FAttributes := FAttributes and $7FFF; + WideString(EGC_WideStr) := ''; + end; + EGC_SingleChar := AExtendedGraphemeCluster[1]; + end + else + begin + if (FAttributes and $8000) = 0 then + begin + FAttributes := FAttributes or $8000; + EGC_WideStr := nil; + end; + WideString(EGC_WideStr) := AExtendedGraphemeCluster; + end; +end; + +class operator TEnhancedVideoCell.Initialize(var evc: TEnhancedVideoCell); +begin + evc.FAttributes := 0; +end; + +class operator TEnhancedVideoCell.Finalize(var evc: TEnhancedVideoCell); +begin + if (evc.FAttributes and $8000) <> 0 then + WideString(evc.EGC_WideStr) := ''; +end; + +procedure fpc_WideStr_Incr_Ref(var S: Pointer); external name 'FPC_WIDESTR_INCR_REF'; + +class operator TEnhancedVideoCell.AddRef(var evc: TEnhancedVideoCell); +begin + if (evc.FAttributes and $8000) <> 0 then + fpc_WideStr_Incr_Ref(evc.EGC_WideStr); +end; + +class operator TEnhancedVideoCell.Copy(constref aSrc: TEnhancedVideoCell; var aDst: TEnhancedVideoCell); +begin + aDst.ExtendedGraphemeCluster := aSrc.ExtendedGraphemeCluster; + aDst.FAttributes := aSrc.FAttributes; +end; + Const LockUpdateScreen : Integer = 0; diff --git a/packages/rtl-console/src/inc/videoh.inc b/packages/rtl-console/src/inc/videoh.inc index 5ef02d20d0..45df763c2d 100644 --- a/packages/rtl-console/src/inc/videoh.inc +++ b/packages/rtl-console/src/inc/videoh.inc @@ -11,6 +11,9 @@ **********************************************************************} +{$mode objfpc} +{$modeswitch advancedrecords} + type PVideoMode = ^TVideoMode; TVideoMode = record @@ -25,6 +28,30 @@ type TVideoBuf = array[0..{$ifdef CPU16}16382{$else}32759{$endif}] of TVideoCell; PVideoBuf = ^TVideoBuf; + TEnhancedVideoCell = record + private + class operator Initialize(var evc: TEnhancedVideoCell); + class operator Finalize(var evc: TEnhancedVideoCell); + class operator AddRef(var evc: TEnhancedVideoCell); + class operator Copy(constref aSrc: TEnhancedVideoCell; var aDst: TEnhancedVideoCell); + function GetExtendedGraphemeCluster: WideString; + procedure SetExtendedGraphemeCluster(const AExtendedGraphemeCluster: WideString); + function GetAttribute: Byte; + procedure SetAttribute(Attr: Byte); + public + property ExtendedGraphemeCluster: WideString read GetExtendedGraphemeCluster write SetExtendedGraphemeCluster; + property Attribute: Byte read GetAttribute write SetAttribute; + + private + FAttributes: Word; + case integer of + 0: (EGC_SingleChar: WideChar); + 1: (EGC_WideStr: Pointer); + end; + PEnhancedVideoCell = ^TEnhancedVideoCell; + + TEnhancedVideoBuf = array of TEnhancedVideoCell; + TVideoDriver = Record InitDriver : Procedure; DoneDriver : Procedure;