1 /*******************************************************************************
2 *                                                                              *
3 * text.h -- Nirvana Editor Text Widget Header File                            *
4 *                                                                              *
5 * Copyright 2003 The NEdit Developers                                          *
6 *                                                                              *
7 * This is free software; you can redistribute it and/or modify it under the    *
8 * terms of the GNU General Public License as published by the Free Software    *
9 * Foundation; either version 2 of the License, or (at your option) any later   *
10 * version. In addition, you may distribute versions of this program linked to  *
11 * Motif or Open Motif. See README for details.                                 *
12 *                                                                              *
13 * This software is distributed in the hope that it will be useful, but WITHOUT *
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or        *
15 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for    *
16 * more details.                                                                *
17 *                                                                              *
18 * You should have received a copy of the GNU General Public License along with *
19 * software; if not, write to the Free Software Foundation, Inc., 59 Temple     *
20 * Place, Suite 330, Boston, MA  02111-1307 USA                                 *
21 *                                                                              *
22 * Nirvana Text Editor                                                          *
23 * July 31, 2001                                                                *
24 *                                                                              *
25 *******************************************************************************/
26 
27 #ifndef NEDIT_TEXT_H_INCLUDED
28 #define NEDIT_TEXT_H_INCLUDED
29 
30 #include "textBuf.h"
31 
32 #include <X11/Intrinsic.h>
33 #include <X11/X.h>
34 #include <X11/Xlib.h>
35 
36 /* Resource strings */
37 #define textNfont "font"
38 #define textCFont "Font"
39 #define textNrows "rows"
40 #define textCRows "Rows"
41 #define textNcolumns "columns"
42 #define textCColumns "Columns"
43 #define textNmarginWidth "marginWidth"
44 #define textCMarginWidth "MarginWidth"
45 #define textNmarginHeight "marginHeight"
46 #define textCMarginHeight "MarginHeight"
47 #define textNselectForeground "selectForeground"
48 #define textCSelectForeground "SelectForeground"
49 #define textNselectBackground "selectBackground"
50 #define textCSelectBackground "SelectBackground"
51 #define textNhighlightForeground "highlightForeground"
52 #define textCHighlightForeground "HighlightForeground"
53 #define textNhighlightBackground "highlightBackground"
54 #define textCHighlightBackground "HighlightBackground"
55 #define textNcursorForeground "cursorForeground"
56 #define textCCursorForeground "CursorForeground"
57 #define textNlineNumForeground "lineNumForeground"
58 #define textCLineNumForeground "LineNumForeground"
59 #define textNcalltipForeground "calltipForeground"
60 #define textCcalltipForeground "CalltipForeground"
61 #define textNcalltipBackground "calltipBackground"
62 #define textCcalltipBackground "CalltipBackground"
63 #define textNpendingDelete "pendingDelete"
64 #define textCPendingDelete "PendingDelete"
65 #define textNhScrollBar "hScrollBar"
66 #define textCHScrollBar "HScrollBar"
67 #define textNvScrollBar "vScrollBar"
68 #define textCVScrollBar "VScrollBar"
69 #define textNlineNumCols "lineNumCols"
70 #define textCLineNumCols "LineNumCols"
71 #define textNautoShowInsertPos "autoShowInsertPos"
72 #define textCAutoShowInsertPos "AutoShowInsertPos"
73 #define textNautoWrapPastedText "autoWrapPastedText"
74 #define textCAutoWrapPastedText "AutoWrapPastedText"
75 #define textNwordDelimiters "wordDelimiters"
76 #define textCWordDelimiters "WordDelimiters"
77 #define textNblinkRate "blinkRate"
78 #define textCBlinkRate "BlinkRate"
79 #define textNfocusCallback "focusCallback"
80 #define textCFocusCallback "FocusCallback"
81 #define textNlosingFocusCallback "losingFocusCallback"
82 #define textCLosingFocusCallback "LosingFocusCallback"
83 #define textNcursorMovementCallback "cursorMovementCallback"
84 #define textCCursorMovementCallback "CursorMovementCallback"
85 #define textNdragStartCallback "dragStartCallback"
86 #define textCDragStartCallback "DragStartCallback"
87 #define textNdragEndCallback "dragEndCallback"
88 #define textCDragEndCallback "DragEndCallback"
89 #define textNsmartIndentCallback "smartIndentCallback"
90 #define textCSmartIndentCallback "SmartIndentCallback"
91 #define textNautoWrap "autoWrap"
92 #define textCAutoWrap "AutoWrap"
93 #define textNcontinuousWrap "continuousWrap"
94 #define textCContinuousWrap "ContinuousWrap"
95 #define textNwrapMargin "wrapMargin"
96 #define textCWrapMargin "WrapMargin"
97 #define textNautoIndent "autoIndent"
98 #define textCAutoIndent "AutoIndent"
99 #define textNsmartIndent "smartIndent"
100 #define textCSmartIndent "SmartIndent"
101 #define textNoverstrike "overstrike"
102 #define textCOverstrike "Overstrike"
103 #define textNheavyCursor "heavyCursor"
104 #define textCHeavyCursor "HeavyCursor"
105 #define textNreadOnly "readOnly"
106 #define textCReadOnly "ReadOnly"
107 #define textNhidePointer "hidePointer"
108 #define textCHidePointer "HidePointer"
109 #define textNemulateTabs "emulateTabs"
110 #define textCEmulateTabs "EmulateTabs"
111 #define textNcursorVPadding "cursorVPadding"
112 #define textCCursorVPadding "CursorVPadding"
113 #define textNbacklightCharTypes "backlightCharTypes"
114 #define textCBacklightCharTypes "BacklightCharTypes"
115 
116 
117 extern WidgetClass textWidgetClass;
118 
119 struct _TextClassRec;
120 struct _TextRec;
121 
122 typedef struct _TextRec *TextWidget;
123 
124 typedef struct {
125     int startPos;
126     int nCharsDeleted;
127     int nCharsInserted;
128     char *deletedText;
129 } dragEndCBStruct;
130 
131 enum smartIndentCallbackReasons {NEWLINE_INDENT_NEEDED, CHAR_TYPED};
132 typedef struct {
133     int reason;
134     int pos;
135     int indentRequest;
136     char *charsTyped;
137 } smartIndentCBStruct;
138 
139 /* User callable routines */
140 void TextSetBuffer(Widget w, textBuffer *buffer);
141 textBuffer *TextGetBuffer(Widget w);
142 int TextLineAndColToPos(Widget w, int lineNum, int column);
143 int TextPosToLineAndCol(Widget w, int pos, int *lineNum, int *column);
144 int TextPosToXY(Widget w, int pos, int *x, int *y);
145 int TextGetCursorPos(Widget w);
146 void TextSetCursorPos(Widget w, int pos);
147 void TextGetScroll(Widget w, int *topLineNum, int *horizOffset);
148 void TextSetScroll(Widget w, int topLineNum, int horizOffset);
149 int TextGetMinFontWidth(Widget w, Boolean considerStyles);
150 int TextGetMaxFontWidth(Widget w, Boolean considerStyles);
151 void TextHandleXSelections(Widget w);
152 void TextPasteClipboard(Widget w, Time time);
153 void TextColPasteClipboard(Widget w, Time time);
154 void TextCopyClipboard(Widget w, Time time);
155 void TextCutClipboard(Widget w, Time time);
156 int TextFirstVisibleLine(Widget w);
157 int TextNumVisibleLines(Widget w);
158 int TextVisibleWidth(Widget w);
159 void TextInsertAtCursor(Widget w, char *chars, XEvent *event,
160     	int allowPendingDelete, int allowWrap);
161 int TextFirstVisiblePos(Widget w);
162 int TextLastVisiblePos(Widget w);
163 char *TextGetWrapped(Widget w, int startPos, int endPos, int *length);
164 XtActionsRec *TextGetActions(int *nActions);
165 void ShowHidePointer(TextWidget w, Boolean hidePointer);
166 void ResetCursorBlink(TextWidget textWidget, Boolean startsBlanked);
167 
168 #ifdef VMS /* VMS linker doesn't like long names (>31 chars) */
169 #define HandleAllPendingGraphicsExposeNoExposeEvents HandlePendingExpNoExpEvents
170 #endif /* VMS */
171 
172 void HandleAllPendingGraphicsExposeNoExposeEvents(TextWidget w, XEvent *event);
173 
174 #endif /* NEDIT_TEXT_H_INCLUDED */
175