1 /* $Id: textDisp.h,v 1.31 2008/01/04 22:11:04 yooden Exp $ */
2 /*******************************************************************************
4 * textDisp.h -- Nirvana Editor Text Diplay Header File *
6 * Copyright 2003 The NEdit Developers *
8 * This is free software; you can redistribute it and/or modify it under the *
9 * terms of the GNU General Public License as published by the Free Software *
10 * Foundation; either version 2 of the License, or (at your option) any later *
11 * version. In addition, you may distribute versions of this program linked to *
12 * Motif or Open Motif. See README for details. *
14 * This software is distributed in the hope that it will be useful, but WITHOUT *
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
19 * You should have received a copy of the GNU General Public License along with *
20 * software; if not, write to the Free Software Foundation, Inc., 59 Temple *
21 * Place, Suite 330, Boston, MA 02111-1307 USA *
23 * Nirvana Text Editor *
26 *******************************************************************************/
28 #ifndef NEDIT_TEXTDISP_H_INCLUDED
29 #define NEDIT_TEXTDISP_H_INCLUDED
33 #include <X11/Intrinsic.h>
37 enum cursorStyles
{NORMAL_CURSOR
, CARET_CURSOR
, DIM_CURSOR
, BLOCK_CURSOR
,
54 char *bgColorName
; /* background style coloring (name may be NULL) */
56 unsigned short bgGreen
;
57 unsigned short bgBlue
;
61 typedef struct graphicExposeTranslationEntry
{
64 struct graphicExposeTranslationEntry
*next
;
65 } graphicExposeTranslationEntry
;
67 typedef void (*unfinishedStyleCBProc
)();
69 typedef struct _calltipStruct
{
70 int ID
; /* ID of displayed calltip. Equals
71 zero if none is displayed. */
72 Boolean anchored
; /* Is it anchored to a position */
73 int pos
; /* Position tip is anchored to */
74 int hAlign
; /* horizontal alignment */
75 int vAlign
; /* vertical alignment */
76 int alignMode
; /* Strict or sloppy alignment */
79 typedef struct _textDisp
{
81 int top
, left
, width
, height
, lineNumLeft
, lineNumWidth
;
84 int cursorX
, cursorY
; /* X, Y pos. of last drawn cursor
85 Note: these are used for *drawing*
86 and are not generally reliable
87 for finding the insert position's
89 int cursorToHint
; /* Tells the buffer modified callback
90 where to move the cursor, to reduce
91 the number of redraw calls */
92 int cursorStyle
; /* One of enum cursorStyles above */
93 int cursorPreferredCol
; /* Column for vert. cursor movement */
94 int nVisibleLines
; /* # of visible (displayed) lines */
95 int nBufferLines
; /* # of newlines in the buffer */
96 textBuffer
*buffer
; /* Contains text to be displayed */
97 textBuffer
*styleBuffer
; /* Optional parallel buffer containing
98 color and font information */
99 int firstChar
, lastChar
; /* Buffer positions of first and last
100 displayed character (lastChar points
101 either to a newline or one character
102 beyond the end of the buffer) */
103 int continuousWrap
; /* Wrap long lines when displaying */
104 int wrapMargin
; /* Margin in # of char positions for
105 wrapping in continuousWrap mode */
107 int topLineNum
; /* Line number of top displayed line
108 of file (first line of file is 1) */
109 int absTopLineNum
; /* In continuous wrap mode, the line
110 number of the top line if the text
111 were not wrapped (note that this is
112 only maintained as needed). */
113 int needAbsTopLineNum
; /* Externally settable flag to continue
114 maintaining absTopLineNum even if
115 it isn't needed for line # display */
116 int horizOffset
; /* Horizontal scroll pos. in pixels */
117 int visibility
; /* Window visibility (see XVisibility event) */
118 int nStyles
; /* Number of entries in styleTable */
119 styleTableEntry
*styleTable
; /* Table of fonts and colors for
120 coloring/syntax-highlighting */
121 char unfinishedStyle
; /* Style buffer entry which triggers
122 on-the-fly reparsing of region */
123 unfinishedStyleCBProc
/* Callback to parse "unfinished" */
124 unfinishedHighlightCB
; /* regions */
125 void *highlightCBArg
; /* Arg to unfinishedHighlightCB */
126 XFontStruct
*fontStruct
; /* Font structure for primary font */
127 int ascent
, descent
; /* Composite ascent and descent for
128 primary font + all-highlight fonts */
129 int fixedFontWidth
; /* Font width if all current fonts are
130 fixed and match in width, else -1 */
131 Widget hScrollBar
, vScrollBar
;
132 GC gc
, selectGC
, highlightGC
; /* GCs for drawing text */
133 GC selectBGGC
, highlightBGGC
; /* GCs for erasing text */
134 GC cursorFGGC
; /* GC for drawing the cursor */
135 GC lineNumGC
; /* GC for drawing line numbers */
136 GC styleGC
; /* GC with color and font unspecified
137 for drawing colored/styled text */
138 Pixel fgPixel
, bgPixel
; /* Foreground/Background colors */
139 Pixel selectFGPixel
, /* Foreground select color */
140 selectBGPixel
; /* Background select color */
141 Pixel highlightFGPixel
, /* Highlight colors are used when */
142 highlightBGPixel
; /* flashing matching parens */
143 Pixel lineNumFGPixel
; /* Color for drawing line numbers */
145 Pixel
*bgClassPixel
; /* table of colors for each BG class */
146 unsigned char *bgClass
; /* obtains index into bgClassPixel[] */
148 Widget calltipW
; /* The Label widget for the calltip */
149 Widget calltipShell
; /* The Shell that holds the calltip */
150 calltipStruct calltip
; /* The info for the calltip itself */
151 Pixel calltipFGPixel
;
152 Pixel calltipBGPixel
;
153 int suppressResync
; /* Suppress resynchronization of line
154 starts during buffer updates */
155 int nLinesDeleted
; /* Number of lines deleted during
156 buffer modification (only used
157 when resynchronization is
159 int modifyingTabDist
; /* Whether tab distance is being
161 Boolean pointerHidden
; /* true if the mouse pointer is
163 graphicExposeTranslationEntry
*graphicsExposeQueue
;
166 textDisp
*TextDCreate(Widget widget
, Widget hScrollBar
, Widget vScrollBar
,
167 Position left
, Position top
, Position width
, Position height
,
168 Position lineNumLeft
, Position lineNumWidth
, textBuffer
*buffer
,
169 XFontStruct
*fontStruct
, Pixel bgPixel
, Pixel fgPixel
,
170 Pixel selectFGPixel
, Pixel selectBGPixel
, Pixel highlightFGPixel
,
171 Pixel highlightBGPixel
, Pixel cursorFGPixel
, Pixel lineNumFGPixel
,
172 int continuousWrap
, int wrapMargin
, XmString bgClassString
,
173 Pixel calltipFGPixel
, Pixel calltipBGPixel
);
174 void TextDFree(textDisp
*textD
);
175 void TextDSetBuffer(textDisp
*textD
, textBuffer
*buffer
);
176 void TextDAttachHighlightData(textDisp
*textD
, textBuffer
*styleBuffer
,
177 styleTableEntry
*styleTable
, int nStyles
, char unfinishedStyle
,
178 unfinishedStyleCBProc unfinishedHighlightCB
, void *cbArg
);
179 void TextDSetColors(textDisp
*textD
, Pixel textFgP
, Pixel textBgP
,
180 Pixel selectFgP
, Pixel selectBgP
, Pixel hiliteFgP
, Pixel hiliteBgP
,
181 Pixel lineNoFgP
, Pixel cursorFgP
);
182 void TextDSetFont(textDisp
*textD
, XFontStruct
*fontStruct
);
183 int TextDMinFontWidth(textDisp
*textD
, Boolean considerStyles
);
184 int TextDMaxFontWidth(textDisp
*textD
, Boolean considerStyles
);
185 void TextDResize(textDisp
*textD
, int width
, int height
);
186 void TextDRedisplayRect(textDisp
*textD
, int left
, int top
, int width
,
188 void TextDSetScroll(textDisp
*textD
, int topLineNum
, int horizOffset
);
189 void TextDGetScroll(textDisp
*textD
, int *topLineNum
, int *horizOffset
);
190 void TextDInsert(textDisp
*textD
, char *text
);
191 void TextDOverstrike(textDisp
*textD
, char *text
);
192 void TextDSetInsertPosition(textDisp
*textD
, int newPos
);
193 int TextDGetInsertPosition(textDisp
*textD
);
194 int TextDXYToPosition(textDisp
*textD
, int x
, int y
);
195 int TextDXYToCharPos(textDisp
*textD
, int x
, int y
);
196 void TextDXYToUnconstrainedPosition(textDisp
*textD
, int x
, int y
, int *row
,
198 int TextDLineAndColToPos(textDisp
*textD
, int lineNum
, int column
);
199 int TextDOffsetWrappedColumn(textDisp
*textD
, int row
, int column
);
200 int TextDOffsetWrappedRow(textDisp
*textD
, int row
);
201 int TextDPositionToXY(textDisp
*textD
, int pos
, int *x
, int *y
);
202 int TextDPosToLineAndCol(textDisp
*textD
, int pos
, int *lineNum
, int *column
);
203 int TextDInSelection(textDisp
*textD
, int x
, int y
);
204 void TextDMakeInsertPosVisible(textDisp
*textD
);
205 int TextDMoveRight(textDisp
*textD
);
206 int TextDMoveLeft(textDisp
*textD
);
207 int TextDMoveUp(textDisp
*textD
, int absolute
);
208 int TextDMoveDown(textDisp
*textD
, int absolute
);
209 void TextDBlankCursor(textDisp
*textD
);
210 void TextDUnblankCursor(textDisp
*textD
);
211 void TextDSetCursorStyle(textDisp
*textD
, int style
);
212 void TextDSetWrapMode(textDisp
*textD
, int wrap
, int wrapMargin
);
213 int TextDEndOfLine(const textDisp
* textD
, const int pos
,
214 const Boolean startPosIsLineStart
);
215 int TextDStartOfLine(const textDisp
* textD
, const int pos
);
216 int TextDCountForwardNLines(const textDisp
* textD
, const int startPos
,
217 const unsigned nLines
, const Boolean startPosIsLineStart
);
218 int TextDCountBackwardNLines(textDisp
*textD
, int startPos
, int nLines
);
219 int TextDCountLines(textDisp
*textD
, int startPos
, int endPos
,
220 int startPosIsLineStart
);
221 void TextDSetupBGClasses(Widget w
, XmString str
, Pixel
**pp_bgClassPixel
,
222 unsigned char **pp_bgClass
, Pixel bgPixelDefault
);
223 void TextDSetLineNumberArea(textDisp
*textD
, int lineNumLeft
, int lineNumWidth
,
225 void TextDMaintainAbsLineNum(textDisp
*textD
, int state
);
226 int TextDPosOfPreferredCol(textDisp
*textD
, int column
, int lineStartPos
);
227 int TextDPreferredColumn(textDisp
*textD
, int *visLineNum
, int *lineStartPos
);
229 #ifdef VMS /* VMS linker doesn't like long names (>31 chars) */
230 #define TextDImposeGraphicsExposeTranslation TextDGraphicsExposeTranslation
233 void TextDImposeGraphicsExposeTranslation(textDisp
*textD
, int *xOffset
, int *yOffset
);
234 Boolean
TextDPopGraphicExposeQueueEntry(textDisp
*textD
);
235 void TextDTranlateGraphicExposeQueue(textDisp
*textD
, int xOffset
, int yOffset
, Boolean appendEntry
);
237 #endif /* NEDIT_TEXTDISP_H_INCLUDED */