diff options
author | B. Watson <urchlay@slackware.uk> | 2025-03-31 21:02:09 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2025-03-31 21:02:09 -0400 |
commit | 867488d6bf2c3f868b329a8bcb5f08e2041f599b (patch) | |
tree | 6f8c8d81450bbbd6246306aaa9dc04ed41e99012 /atascii.h | |
parent | 80be916389299e76aa84e904b3871a5d0c50b80e (diff) | |
download | bw-atari8-tools-867488d6bf2c3f868b329a8bcb5f08e2041f599b.tar.gz |
a8cat: library-ize the conversion logic so we can use it in listbas and listamsb eventually.
Diffstat (limited to 'atascii.h')
-rw-r--r-- | atascii.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/atascii.h b/atascii.h new file mode 100644 index 0000000..ffa5d32 --- /dev/null +++ b/atascii.h @@ -0,0 +1,42 @@ +#ifndef ATASCII_H +#define ATASCII_H + +#include <stdio.h> +#include <string.h> +#include "atables.h" + +#define ATA_MODE_UTF8 0 /* default */ +#define ATA_MODE_MAGAZINE 1 +/* TODO: #define ATA_MODE_DOTS 2 */ + +#define ATA_FLAG_NONE 0 /* default */ +#define ATA_FLAG_UNDERLINE 1 +#define ATA_FLAG_ICS 2 +#define ATA_FLAG_TEXTMODE 4 +#define ATA_FLAG_STRIP_INVERSE 8 + +#define ATA_CHR_FINISH -1 + +extern const char *atascii_inverse_on; +extern const char *atascii_inverse_off; + +typedef struct { + int mode; + int flags; + int inv; + int lines; + const char **table; +} atascii_ctx; + +/* returns true if mode and flags are valid, 0 otherwise. */ +extern int atascii_context_init(atascii_ctx *ctx, int mode, int flags); + +/* obeys all the flags and modes. + result goes in dest, which needs to be 9 bytes in utf-8 mode (big + enough to handle up to 4 bytes of UTF-8 plus 4 bytes of ANSI escape + code plus a terminating null), or 12 bytes in magazine mode. + the return value is dest. + */ +extern char *atascii_a2utf(atascii_ctx *ctx, int src, char *dest); + +#endif |