//===============================================================================
// Xe UI toolkit
//
// XeText
//  Public header file
//
// AUTHOR:  Gabor Nagy
// DATE:    2023-Aug-18 14:31:45
//
// Copyright (C) 1996-2026 by Gabor Nagy. All rights reserved.
//===============================================================================
#ifndef _XeTextWidget_h
#define _XeTextWidget_h

#include <Xe/TextField.h>

#if defined (__cplusplus) && (!(defined (__CPLUSLIBS)))
extern "C" {
#endif

extern XeWidgetClass*            XeTextWidget_class;
typedef struct _XeTextClassRec*  XeTextWidgetClass;
typedef struct _XeTextRec*       XeTextWidget;


typedef struct
{
	XeTextPosition  Start, End;
	XeTextPosition  StartCol, StartRow, EndCol, EndRow;
	EcRGBAiColor    Color;

#ifdef EX11
	Pixel           X_Color;
#endif
} XeTextHighlight;


extern void     XeText_Redraw(XeWidget PW);

extern EBool    XeText_Cut(XeWidget PW, Time PTime);
extern EBool    XeText_Copy(XeWidget PW, Time PTime);
extern EBool    XeText_Paste(XeWidget PW);

extern void     XeText_SetString(XeWidget PW, char* PString, const EBool PNotify, const EBool PRedraw);
extern char*		XeText_GetString(XeWidget PW, XeTextPosition* PLength);

extern void     XeText_SetStringUTF8(XeWidget PW, const char* PString, const EBool PNotify, const EBool PRedraw);
extern char*    XeText_GetStringUTF8(XeWidget PW, XeTextPosition* PLength);

extern void     XeText_Insert(XeWidget PW, const XeTextPosition PHere, const char* PString,  const EBool PStoreForUndo, const EBool PRedraw);
extern void     XeText_Replace(XeWidget PW, const XeTextPosition PStart, const XeTextPosition PEnd, const char* PString,  const EBool PStoreForUndo, const EBool PRedraw);

extern void     XeText_ClearSelection(XeWidget PW, Time PTime);

extern EBool    XeText_GetSelectionPosition(XeWidget PW, XeTextPosition* PSelStart, XeTextPosition* PSelEnd);
extern void     XeText_SetSelection(XeWidget PW,  const XeTextPosition PStart, const XeTextPosition PEnd,  const EBool PRedraw, const EBool PNotify);
extern char*    XeText_GetSelection(XeWidget PW);

extern XeTextPosition  XeText_GetLastPosition(XeWidget PW);

extern XeTextPosition  XeText_GetInsertionPosition(XeWidget PW);
extern XeTextPosition  XeText_GetInsertionPositionXY(XeWidget PW,  XeTextPosition* PPosX, XeTextPosition* PPosY);

extern void     XeText_SetInsertionPosition(XeWidget PW, XeTextPosition PPos, const EBool PNotify, const EBool PRedraw);

extern XeTextPosition  XeText_GetTopPosition(XeWidget PW);
extern XeTextPosition  XeText_GetTopPositionXY(XeWidget PW,  XeTextPosition* PXP, XeTextPosition* PYP);
extern void     XeText_SetTopPosition(XeWidget PW, const XeTextPosition PTopPos, const EBool PRedrawIn);
extern void     XeText_SetTopPositionAndInsertionPosition(XeWidget PW, XeTextPosition PTopPos, XeTextPosition PCursorPos, const EBool PNotify, const EBool PRedraw);

extern int      XeText_GetVisibleRows(XeWidget PW);
extern int      XeText_GetVisibleCols(XeWidget PW);


extern void     XeText_SetHighlight(XeWidget PW, const XeTextPosition PLeft, const XeTextPosition PRight, const XeHighlightMode PMode,  const EcRGBAiColor PColor, const Pixel PXColor,  const EBool PRedraw);
extern void     XeText_SetHighlights(XeWidget PW, XeTextHighlight* PHighlights, const int PNumOfHighlights, const EBool PRedraw);
extern void     XeText_ClearHighlights(XeWidget PW);

extern int      XeText_Undo(XeWidget PW, EOps** POps);
extern int      XeText_Redo(XeWidget PW, EOps** POps);

extern void     XeText_SetWordTerminators(XeWidget PW, const EBool* PLeft, const EBool* PRight);

extern XeWidget XeScrolledText_New(XeWidget PParentW, const char* PName,  EArg* PArgs, const int PNumOfArgs);

extern EIndex   XeText_PixelXYToTextPos(XeWidget PW,  const XeCoordinate PX, const XeCoordinate PY,  XeTextPosition* PCharX, XeTextPosition* PCharY);
extern int      XeText_GetSubstring(XeWidget PW, const XeTextPosition PStart, const int PNChars, const int PBufSize, char* PBuffer);


#if defined (__cplusplus) && (!(defined (__CPLUSLIBS)))
} // Close scope of 'extern "C"' declaration
#endif

#endif // _XeTextWidget_h
