/*ProfiPacket - packet radio terminal program
  Copyright (C) 1999  Alexander Feigl

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

  Author:

  Alexander Feigl
  Burachstraße 51

  D-88250 Weingarten

  Mail : Alexander.Feigl@gmx.de
*/


#ifndef INCLUDED_MCC_EDITOR
#define INCLUDED_MCC_EDITOR

#include <libraries/mui.h>


extern struct MUI_CustomClass *EditorClass;
extern struct MUI_CustomClass *EditorPrefClass;

#define EditorObject NewObject(EditorClass->mcc_Class,NULL
#define EditorPrefObject NewObject(EditorPrefClass->mcc_Class,NULL


#define EDCL_TagBase 0xf9f60001


/* MCC_Editor Structures */


/**********************************************************************
  ANSI Stream structure

  Intended for public use of EDCLM_ANSIToStream and EDCLM_StreamToANSI.
  With these methods you are able to parse ANSI strings into text and
  style infos. You are able to break parsing within an ANSI command
  without memorizing anything yourself. You have to supply the correct
  values in the structure. See comments in structure. 
  ATS means : You have to set it for EDCLM_ANSIToStream / get it for
              EDCLM_StreamToANSI.
  STA means : You have to set it for EDCLM_StreamToANSI / get it for
              EDCLM_ANSIToStream
    
**********************************************************************/

struct ANSIStream {
                   unsigned char *TextBuffer;           
                   /*ANSI text buffer for ANSI <--> Stream conversions */

                   unsigned long  TextBufferSize;       
                   /*set to your ANSIStream.TextBuffer size */

                   unsigned long  TextLength;
                   /*ATS - ANSI text length in buffer */

                   unsigned char *CharBuffer;
                   /*Char buffer for one line of stream */

                   unsigned long  CharBufferSize;
                   /*set to your ANSIStream.CharBuffer size */

                   unsigned long  CharLength;
                   /*STA - Stream chars in buffer */

                   struct StyleInfo *Styles;
                   /*StyleInfo buffer for one line of stream */

                   unsigned long  StyleSize;
                   /*set size of ANSI.Stream.Styles (in StyleInfo structs)*/

                   unsigned long  UsedStyles;
                   /*STA - Style infos in Stream */

                   unsigned long  CurrentColumn;
                   /*Initialize with starting column each line of stream*/
       
                   unsigned char  ForegroundColor;
                   /*ATS - style at start of ANSI string */

                   unsigned char  BackgroundColor;
                   /*ATS - style at start of ANSI string */
 
                   unsigned char  TextStyle;
                   /*ATS - style at start of ANSI string */
                   
                   unsigned char  Pad1;

                   unsigned short StreamCR;
                   /*STA - Carriage return at end of stream */

                   unsigned short ANSICmdState;
                   /*Initialize with 0 at first call of an ANSI stream*/

                   unsigned char  ANSICommand[32];
                   /*Private space for ANSI parser - don't set/modify */

                  };



/**********************************************************************
  StyleInfo structure

  Intended for public use of EDCLM_ANSIToStream and EDCLM_StreamToANSI.
  You will receive style infos for EDCLM_ANSIToStream parsed lines and
  you have to support EDCLM_StreamToANSI with style infos in order to
  make ANSI sequences. ForegroundColor and BackgroundColor are ANSI
  colors from 0 to 7. TextStyle is a Gfx-Library Softstyle compatible
  mask. StartColumn is the first column of a line which this style
  is applied. You are not allowd to supply EDCLM_StreamToANSI with
  incorrect values! Pad1 is reserved for future. Set it to 0 when
  generating a StyleInfo Structure
  
**********************************************************************/

struct StyleInfo {
                  unsigned char ForegroundColor;
                  unsigned char BackgroundColor;
                  unsigned char TextStyle;
                  unsigned char Pad1;
                  unsigned long StartColumn;
                 };





/* MCC_Editor attributes */

#define MUIA_Editor_BufferSize     EDCL_TagBase+0  
/*Buffer size in bytes for each page (default 4096 bytes)   (I-G) */

#define MUIA_Editor_Pages          EDCL_TagBase+1
/*Number of pages (1-128)            (default 1 page)       (I-G) */

#define MUIA_Editor_NumLockStatus  EDCL_TagBase+2
/*Status of numlock key              (default false)        (ISG) */

#define MUIA_Editor_NumLock        EDCL_TagBase+3
/*Alloc num lock switching           (default true)         (ISG) */

#define MUIA_Editor_AltAscii       EDCL_TagBase+4
/*Allow alt ascii input              (default true)         (ISG) */

#define MUIA_Editor_InsertMode     EDCL_TagBase+5
/*Insert mode status                 (default true)         (ISG) */

#define MUIA_Editor_ActivePage     EDCL_TagBase+6
/*Displayed page of editor           (default page 0)       (ISG) */

#define MUIA_Editor_Unprintable    EDCL_TagBase+7
/*Mapping of unprintable 32bitarray  (default MAPALL)       (---) */

#define MUIA_Editor_EditorType     EDCL_TagBase+8
/*Editor type                        (default 0)            (I-G) */

#define MUIA_Editor_EditorMarkable EDCL_TagBase+9
/*Editor can "clipboard"             (default true)         (---) */

#define MUIA_Editor_InputMask      EDCL_TagBase+10
/*Masing of input modes              (default 3847)         (ISG) */

#define MUIA_Editor_AltAsciiMode   EDCL_TagBase+11
/*Boolean : Editor in Alt Ascii mode                        (--G) */

#define MUIA_Editor_FreeMoving     EDCL_TagBase+12               
/*Cursor can move over EOF           (default false)        (I-G) */      

#define MUIA_Editor_MaxLines       EDCL_TagBase+13
/*Max # of textlines                 (default 0)            (---) */

#define MUIA_Editor_PCFontKeymap   EDCL_TagBase+14         
/*Automatic key conversion in PCFont (default FALSE)        (ISG) */

#define MUIA_Editor_LineWrap       EDCL_TagBase+15             
/*Wrap lines on return / join lines  (default TRUE)         (I-G) */

#define MUIA_Editor_WordWrap       EDCL_TagBase+16
/*Word wrapping in column # x        (default 0 = NONE)     (ISG) */

#define MUIA_Editor_GarbageEditor  EDCL_TagBase+17
/*Old lines will deleted on lowmem   (default FALSE)        (I-G) */

#define MUIA_Editor_Interactive    EDCL_TagBase+18
/*Allow input/output like CLI window (default FALSE)        (I-G) */

#define MUIA_Editor_AskInputStream EDCL_TagBase+19
/*Broadcast input as stream          (default FALSE)        (ISG) */

#define MUIA_Editor_AskInputANSI   EDCL_TagBase+20
/*Boradcast input as ANSI string     (default FALSE)        (ISG) */

#define MUIA_Editor_NotifyStream   EDCL_TagBase+21
/*Notify attrib for Input streams                           (---N)*/

#define MUIA_Editor_NotifyANSI     EDCL_TagBase+22
/*Notify attrib for ANSI Inputs                             (---N)*/

#define MUIA_Editor_NotifyFKey     EDCL_TagBase+23               
/*Notify function keys                                            */


#define MUIA_Editor_NotifyPrPa     EDCL_TagBase+24              
/*Notify ProfiPacket hotkeys (ProfiPacket specific)         (I--N)*/


#define MUIA_Editor_DisableRedraw  EDCL_TagBase+25
/*Disable redraw of the editor contents                     (ISG)*/

#define MUIA_Editor_SolidBackground EDCL_TagBase+26
/*Use a solid background for Editor (faster)                (I--)*/

/* Base key numbers for NotifyFKey */

#define MUIV_Editor_NotifyFKey_StdBase     0
#define MUIV_Editor_NotifyFKey_ShiftBase   10
#define MUIV_Editor_NotifyFKey_CtrlBase    20
#define MUIV_Editor_NotifyFKey_AltBase     30
#define MUIV_Editor_NotifyFKey_AmigaBase   40


/* Masking bits for InputMode*/

#define MUIV_Editor_InputMask_Cursor      1
#define MUIV_Editor_InputMask_CursorPage  2
#define MUIV_Editor_InputMask_CursorLimit 4
#define MUIV_Editor_InputMask_FKeys       8
#define MUIV_Editor_InputMask_FKeysShift  16
#define MUIV_Editor_InputMask_FKeysCtrl   32
#define MUIV_Editor_InputMask_FKeysAlt    64
#define MUIV_Editor_InputMask_FKeysAmiga  128
#define MUIV_Editor_InputMask_FKeysFColor 256
#define MUIV_Editor_InputMask_FKeysBColor 512
#define MUIV_Editor_InputMask_FKeysStyle  1024
#define MUIV_Editor_InputMask_NumericPad  2048


/* MCC_Editor methods */

#define MUIM_Editor_BlinkCursor    EDCL_TagBase+128
/*private method                                                  */

#define MUIM_Editor_ANSIToStream   EDCL_TagBase+129
/* Convert an ANSI string to an text/style stream
   [struct ANSIStream *]                                          */

#define MUIM_Editor_StreamToANSI   EDCL_TagBase+130
/* Convert an text/style stream to ANSI string 
   [struct ANSIStream *]                                          */

#define MUIM_Editor_WriteANSI      EDCL_TagBase+131
/* Write ANSI chars into interactive editor or scroller          
   [unsigned long page] [unsigned char *chars] [unsigned long len]*/ 

#define MUIM_Editor_WriteStream    EDCL_TagBase+132
/* Write stream into interactive editor or scroller
   [unsigned long page] [unsigned char *chars[ [unsigned long len]
   [struct StyleInfo *styles] [unsigned long stylelen] [bool CR]  */

#define MUIM_Editor_PutStorage     EDCL_TagBase+133
/* Write buffers into internal buffer file (private format,fast)
   [BPTR file]                                                    */

#define MUIM_Editor_GetStorage     EDCL_TagBase+134
/* Read  buffers from internal buffer file (private format,fast)
   [BPTR file]                                                    */

#define MUIM_Editor_ExportPage     EDCL_TagBase+135
/* Write page as textfile to disk                                 
   [BPTR file] [unsigned long page] [unsigned long mode] 
   [unsigned long marked]                                         */

#define MUIM_Editor_ImportPage     EDCL_TagBase+136
/* Read page from textfile on disk
   [BPTR file] [unsigned long page] [unsigned long mode]          */

#define MUIM_Editor_ClearPage      EDCL_TagBase+137
/* Clear page in editor
   [unsigned long page]                                           */                     

#define MUIM_Editor_ExportStream   EDCL_TagBase+138
/* Write page with a given stream function
   [void *streamdata] [unsigned long page] [unsigned long mode]
   [unsigned long marked] 
   [unsigned long(void *streamdata,char *data,unsigned long length)]
                                                                  */
#define MUIM_Editor_ImportStream   EDCL_TagBase+139
/* Read page with a given stream function
   [void *streamdata] [unsigned long page] [unsigned long mode]
   [unsigned long(void *streamdata,char *data,unsigned long length)]
                                                                  */





/* MCC_Editor Import/Export modes */
/* No line seperator mode means auto detect on import and saving same
   mode at export , same at character set                         */

#define MUIV_Editor_ImExMode_LF      0x01         /* 0x0a as line seperator */
#define MUIV_Editor_ImExMode_CR      0x02         /* 0x0d as line seperator */
#define MUIV_Editor_ImExMode_CRLF    0x04         /* 0x0d + 0x0a as line seperator */

#define MUIV_Editor_ImExMode_NoANSI  0x10         /* disable ANSI characters  */

#define MUIV_Editor_ImExMode_AmChar  0x20         /* Amiga character set */
#define MUIV_Editor_ImExMode_PCChar  0x40         /* PC character set */                                        

/* MCC_Editor return codes (unsigned long )*/

#define MUIV_Editor_Return_OK                   0
#define MUIV_Editor_Return_ANSI_NotFinished     1
#define MUIV_Editor_Return_ANSI_BufferTooSmall  2
#define MUIV_Editor_Return_ANSI_StreamTooSmall  3
#define MUIV_Editor_Return_Write_NoMemory       4
#define MUIV_Editor_Return_Write_NotInteractive 5
#define MUIV_Editor_Return_Write_IllegalPage    6
#define MUIV_Editor_Return_Disk_BuffersTooSmall 7
#define MUIV_Editor_Return_Disk_UnknownFileForm 8
#define MUIV_Editor_Return_Disk_DiskError       9
#define MUIV_Editor_Return_Disk_FileCorrupt     10
#define MUIV_Editor_Return_Disk_NoMarkedText    11
#define MUIV_Editor_Return_Disk_NoMemory        4
#define MUIV_Editor_Return_InvalidPage          6




/* MCC_Editor config items - private */

#define MUICFG_Editor_ANSIPens        EDCL_TagBase+192
#define MUICFG_Editor_ANSIPensExt     EDCL_TagBase+193
#define MUICFG_Editor_CursEditorPen   EDCL_TagBase+194
#define MUICFG_Editor_CursScrollPen   EDCL_TagBase+195
#define MUICFG_Editor_BlinkEditor     EDCL_TagBase+196
#define MUICFG_Editor_BlinkScroller   EDCL_TagBase+197
#define MUICFG_Editor_CursorInsert    EDCL_TagBase+198
#define MUICFG_Editor_CursorOverwr    EDCL_TagBase+199
#define MUICFG_Editor_BlinkFrequency  EDCL_TagBase+200
#define MUICFG_Editor_SolidBackground EDCL_TagBase+201


#endif
