/***********************************************************/
/* Header file for Amiga kanji routine library.            */
/* "AK_globals.h" copyright Roger Ang May 1995             */
/*                                                         */
/* This file should be used by external files.		   */
/***********************************************************/

#include <exec/types.h>

#if INCLUDE_VERSION >= 36
#include <dos/dos.h>
#include <clib/alib_protos.h> 
#else 
#include <dos.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
#include <fcntl.h>
#include <string.h>
#include <devices/conunit.h>
#include <exec/memory.h>
#include <intuition/intuitionbase.h>
#include <libraries/dosextens.h>
#include <proto/diskfont.h>
#include <proto/dos.h>
#include <proto/exec.h> 
#include <proto/graphics.h>
#include <proto/intuition.h>

#ifndef AK_H
#define AK_H

/***
 * Globals/public
 ***/

struct IntuitionBase *IntuitionBase = NULL;
struct GfxBase *GfxBase = NULL;
struct Library *DiskfontBase = NULL;

/* Pointers to the kanji fonts.  Not all of these pointers are used 
   since there are undefined areas in the JIS character set, but this 
   array makes accessing/decoding easier. */
struct TextFont* AK_font[44];
struct TextAttr AK_font_attr[44];

#define AK_ASCII 0

struct Window    *AK_window;   /* Pointer to the CLI window. */
struct RastPort  *AK_rp;       /* RastPort of CLI window */
struct ConUnit   *AK_conUnit;  /* Console of CLI window */

typedef enum {UNKNOWN=0, JIS83, JIS78, SJIS, EUC} AK_kanji_type;

AK_kanji_type AK_curr_encoding;

/* original font of window, for restoring CLI font */
struct TextFont *AK_old_font;	

/* Kanji cursor coords. in characters.  Upper left is 0, 0 */
short AK_crow, AK_ccol;

short AK_tab_width = 8;

/* Treat linefeed as LF+CR */
BOOL AK_LFisNL = TRUE;

BOOL _AK_cust_wind = FALSE;
int _AK_font_size = 0;

#endif

/* Routines */
extern int AK_init(struct Window *wind, int font_size, BOOL no_kanji);
extern void AK_cleanup(char *message);
extern AK_kanji_type AK_guess_encoding(unsigned char *a_str);
extern void AK_get_cursor_pos(int *xpix, int *ypix);
extern int AK_decode_char(unsigned char *jbyte1, unsigned char *jbyte2, 
			  unsigned short rawcode, AK_kanji_type encoding);
extern int AK_strlen(unsigned char *astr);
extern void AK_Text(struct RastPort *rp, unsigned char *astr, int len);
extern int AK_putchar(unsigned short ch);
extern int AK_puts(unsigned char *astr);
extern int AK_printf(char *format, ...);
extern int AK_getconfig(void);

