#ifndef NEDIT_TEXTDISP_H_INCLUDED
#define NEDIT_TEXTDISP_H_INCLUDED
#include "textBuf.h"
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <Xm/Xm.h>
#include "colorprofile.h"
#include <X11/Xft/Xft.h>
enum cursorStyles {
NORMAL_CURSOR,
CARET_CURSOR,
DIM_CURSOR,
BLOCK_CURSOR,
HEAVY_CURSOR};
#define NO_HINT -
1
typedef struct _textDisp textDisp;
typedef struct NFont NFont;
typedef struct NFontList NFontList;
typedef struct NCharSetList NCharSetList;
struct NFontList {
XftFont *font;
NFontList *next;
};
struct NCharSetList {
FcCharSet *charset;
NCharSetList *next;
};
struct NFont {
NFontList *fonts;
NCharSetList *fail;
Display *display;
FcPattern *pattern;
double size;
int minWidth;
int maxWidth;
unsigned int ref;
};
typedef struct {
char *highlightName;
char *styleName;
char *colorName;
char isBold;
char isItalic;
XftColor color;
Boolean underline;
NFont *font;
char *bgColorName;
XftColor bgColor;
} styleTableEntry;
typedef struct graphicExposeTranslationEntry {
int horizontal;
int vertical;
struct graphicExposeTranslationEntry *next;
} graphicExposeTranslationEntry;
typedef struct ansiStyle {
short fg;
short bg;
short bold;
short italic;
short fg_r;
short fg_g;
short fg_b;
short bg_r;
short bg_g;
short bg_b;
} ansiStyle;
typedef void (*unfinishedStyleCBProc)(
const textDisp *textD,
int pos,
const void *highlightCBArg);
typedef struct _calltipStruct {
int ID;
Boolean anchored;
int pos;
int hAlign;
int vAlign;
int alignMode;
} calltipStruct;
typedef struct _textCursor {
int cursorPos;
int cursorPosCache;
int cursorPosCacheLeft;
int cursorPosCacheRight;
int cursorPreferredCol;
int x;
int y;
} textCursor;
struct _textDisp {
Widget w;
XftDraw *d;
int top, left, width, height, lineNumLeft, lineNumWidth;
textCursor *cursor;
textCursor *newcursor;
textCursor *multicursor;
size_t mcursorAlloc;
size_t mcursorSize;
size_t mcursorSizeReal;
int cursorOn;
int cursorToHint;
int cursorStyle;
Position marginWidth;
int xic_x;
int xic_y;
int nVisibleLines;
int nBufferLines;
textBuffer *buffer;
textBuffer *styleBuffer;
int firstChar, lastChar;
int continuousWrap;
int wrapMargin;
int *lineStarts;
int topLineNum;
int absTopLineNum;
int needAbsTopLineNum;
int horizOffset;
int visibility;
int nStyles;
styleTableEntry *styleTable;
char unfinishedStyle;
unfinishedStyleCBProc
unfinishedHighlightCB;
void *highlightCBArg;
NFont *font;
NFont *boldFont;
NFont *italicFont;
NFont *boldItalicFont;
int ascent, descent;
int fixedFontWidth;
Widget hScrollBar, vScrollBar;
GC gc;
GC cursorFGGC;
XftColor styleGC;
XftColor *bgClassPixel;
unsigned char *bgClass;
Boolean indentRainbow;
Boolean ansiColors;
ColorProfile *colorProfile;
Widget calltipW;
Widget calltipShell;
calltipStruct calltip;
Pixel calltipFGPixel;
Pixel calltipBGPixel;
int suppressResync;
int nLinesDeleted;
int modifyingTabDist;
Boolean mcursorOn;
Boolean pointerHidden;
Boolean disableRedisplay;
Boolean highlightCursorLine;
Boolean fixLeftClipAfterResize;
Boolean redrawCursorLine;
graphicExposeTranslationEntry *graphicsExposeQueue;
size_t cacheNoWrappingWidth;
Boolean cacheNoWrapping;
};
textDisp *TextDCreate(Widget widget, Widget hScrollBar, Widget vScrollBar,
Position left, Position top, Position width, Position height,
Position lineNumLeft, Position lineNumWidth, Position marginWidth,
textBuffer *buffer, NFont *font, NFont *bold, NFont *italic,
NFont *boldItalic, ColorProfile *colorProfile,
int continuousWrap,
int wrapMargin, XmString bgClassString, Pixel calltipFGPixel,
Pixel calltipBGPixel, Pixel lineHighlightBGPixel, Boolean indentRainbow,
Boolean highlightCursorLine, Boolean ansiColors);
void TextDInitXft(textDisp *textD);
void TextDFree(textDisp *textD);
void TextDSetBuffer(textDisp *textD, textBuffer *buffer);
void TextDAttachHighlightData(textDisp *textD, textBuffer *styleBuffer,
styleTableEntry *styleTable,
int nStyles,
char unfinishedStyle,
unfinishedStyleCBProc unfinishedHighlightCB,
void *cbArg);
void TextDSetColorProfile(textDisp *textD, ColorProfile *profile);
void TextDSetFont(textDisp *textD, NFont *fontStruct);
void TextDSetBoldFont(textDisp *textD, NFont *boldFont);
void TextDSetItalicFont(textDisp *textD, NFont *boldFont);
void TextDSetBoldItalicFont(textDisp *textD, NFont *boldFont);
int TextDMinFontWidth(textDisp *textD, Boolean considerStyles);
int TextDMaxFontWidth(textDisp *textD, Boolean considerStyles);
void TextDResize(textDisp *textD,
int width,
int height);
void TextDRedisplayRect(textDisp *textD,
int left,
int top,
int width,
int height);
void TextDSetScroll(textDisp *textD,
int topLineNum,
int horizOffset);
void TextDGetScroll(textDisp *textD,
int *topLineNum,
int *horizOffset);
void TextDInsert(textDisp *textD,
char *text);
void TextDOverstrike(textDisp *textD,
char *text);
void TextDSetInsertPosition(textDisp *textD,
int newPos);
void TextDChangeCursors(textDisp *textD,
int startPos,
int diff);
int TextDAddCursor(textDisp *textD,
int newMultiCursorPos);
void TextDRemoveCursor(textDisp *textD,
int cursorIndex);
void TextDSetCursors(textDisp *textD,
size_t *cursors,
size_t ncursors);
int TextDClearMultiCursor(textDisp *textD);
void TextDCheckCursorDuplicates(textDisp *textD);
int TextDGetInsertPosition(textDisp *textD);
int TextDXYToPosition(textDisp *textD,
int x,
int y);
int TextDXYToCharPos(textDisp *textD,
int x,
int y);
void TextDXYToUnconstrainedPosition(textDisp *textD,
int x,
int y,
int *row,
int *column);
int TextDLineAndColToPos(textDisp *textD,
int lineNum,
int column);
int TextDOffsetWrappedColumn(textDisp *textD,
int row,
int column);
int TextDOffsetWrappedRow(textDisp *textD,
int row);
int TextDPositionToXY(textDisp *textD,
int pos,
int *x,
int *y);
int TextDPosToLineAndCol(textDisp *textD,
int pos,
int *lineNum,
int *column);
int TextDInSelection(textDisp *textD,
int x,
int y);
void TextDMakeInsertPosVisible(textDisp *textD);
int TextDMoveRight(textDisp *textD);
int TextDMoveLeft(textDisp *textD);
int TextDMoveUp(textDisp *textD,
int absolute);
int TextDMoveDown(textDisp *textD,
int absolute);
void TextDBlankCursor(textDisp *textD);
void TextDUnblankCursor(textDisp *textD);
void TextDSetCursorStyle(textDisp *textD,
int style);
Boolean TextDPosHasCursor(textDisp *textD,
int pos,
int *index);
Boolean TextDRangeHasCursor(textDisp *textD,
int start,
int end);
void TextDSetWrapMode(textDisp *textD,
int wrap,
int wrapMargin);
int TextDEndOfLine(
const textDisp* textD,
int pos,
Boolean startPosIsLineStart);
int TextDStartOfLine(
const textDisp* textD,
int pos);
int TextDCountForwardNLines(
const textDisp* textD,
int startPos,
unsigned nLines, Boolean startPosIsLineStart);
int TextDCountBackwardNLines(textDisp *textD,
int startPos,
int nLines);
int TextDCountLines(textDisp *textD,
int startPos,
int endPos,
int startPosIsLineStart);
int TextDCountLinesW(textDisp *textD,
int startPos,
int endPos,
int startPosIsLineStart, Boolean *retWrapped);
void TextDSetupBGClasses(Widget w, XmString str, XftColor **pp_bgClassPixel,
unsigned char **pp_bgClass, XftColor bgPixelDefault);
void TextDSetLineNumberArea(textDisp *textD,
int lineNumLeft,
int lineNumWidth,
int textLeft);
void TextDMaintainAbsLineNum(textDisp *textD,
int state);
int TextDPosOfPreferredCol(textDisp *textD,
int column,
int lineStartPos);
int TextDPreferredColumn(textDisp *textD,
int *visLineNum,
int *lineStartPos);
void TextDSetHighlightCursorLine(textDisp *textD, Boolean state);
void TextDSetIndentRainbow(textDisp *textD, Boolean indentRainbow);
void TextDCursorLR(textDisp *textD,
int *left,
int *right);
textCursor TextDPos2Cursor(textDisp *textD,
int pos);
void TextDSetAnsiColors(textDisp *textD, Boolean ansiColors);
NFont *FontCreate(Display *dp, FcPattern *pattern);
NFont *FontFromName(Display *dp,
const char *name);
XftFont *FontListAddFontForChar(NFont *f, FcChar32 c);
XftFont *FontDefault(NFont *f);
void FontAddFail(NFont *f, FcCharSet *c);
XftFont *FindFont(NFont *f, FcChar32 c);
void FontDestroy(NFont *f);
NFont *FontRef(NFont *font);
void FontUnref(NFont *font);
XftColor PixelToColor(Widget w, Pixel p);
XftColor RGBToColor(
short r,
short g,
short b);
void TextDImposeGraphicsExposeTranslation(textDisp *textD,
int *xOffset,
int *yOffset);
Boolean TextDPopGraphicExposeQueueEntry(textDisp *textD);
void TextDTranlateGraphicExposeQueue(textDisp *textD,
int xOffset,
int yOffset, Boolean appendEntry);
#endif