Op 2020-12-22 om 00:42 schreef gabor via fpc-pascal:
W dniu 2020-12-21 o 23:41, Sven Barth via fpc-pascal pisze:
> The main restriction is that it only supports ShortString and thus has
> no Unicode support.

I wonder which type would be best suited to store a unicode character (code point) for the screen buffer?

type
  TScreenBuffer = array of record
    Character: TypeForUnicodeCodepoint;
    AttributeAndColor: TAttributeAndColor;
  end;


The problem is that multiple unicode codepoints might translate to one character. But that character might have variable width (1, 1.5, 2).  And the rendering of codepoints to characters is output device (terminal, GUI canvas) dependent.

First and for all, I would keep the buffer private. This allows to keep the buffer in a format suitable to quickly convert to the output device, and access won't be simple array like anyway. This also abstracts final writing API and end device encoding.

Maybe have multiple arrays, one for one codepoint per character, and one larger ones for additional ones.

This way you can simply scan the larger array if there are additional ones, and if not, emit the primary one in a straightforward way.


_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to