UNIXworkcode

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 #include <X11/Xft/Xft.h> 36 37 /* Resource strings */ 38 //define textNfont "font" 39 //define textCFont "Font" 40 #define textNXftFont "XftFont" 41 #define textCXftFont "XftFont" 42 #define textNXftBoldFont "XftBoldFont" 43 #define textCXftBoldFont "XftBoldFont" 44 #define textNXftItalicFont "XftItalicFont" 45 #define textCXftItalicFont "XftItalicFont" 46 #define textNXftBoldItalicFont "XftBoldItalicFont" 47 #define textCXftBoldItalicFont "XftBoldItalicFont" 48 #define textTXftFont "TextXftFont" 49 #define textNrows "rows" 50 #define textCRows "Rows" 51 #define textNcolumns "columns" 52 #define textCColumns "Columns" 53 #define textNmarginWidth "marginWidth" 54 #define textCMarginWidth "MarginWidth" 55 #define textNmarginHeight "marginHeight" 56 #define textCMarginHeight "MarginHeight" 57 #define textNselectForeground "selectForeground" 58 #define textCSelectForeground "SelectForeground" 59 #define textNselectBackground "selectBackground" 60 #define textCSelectBackground "SelectBackground" 61 #define textNhighlightForeground "highlightForeground" 62 #define textCHighlightForeground "HighlightForeground" 63 #define textNhighlightBackground "highlightBackground" 64 #define textCHighlightBackground "HighlightBackground" 65 #define textNcursorForeground "cursorForeground" 66 #define textCCursorForeground "CursorForeground" 67 #define textNlineNumForeground "lineNumForeground" 68 #define textCLineNumForeground "LineNumForeground" 69 #define textNlineNumBackground "lineNumForeground" 70 #define textCLineNumBackground "LineNumBackground" 71 #define textNlineHighlightBackground "lineHighlightBackground" 72 #define textClineHighlightBackground "LineHighlightBackground" 73 #define textNcalltipForeground "calltipForeground" 74 #define textCcalltipForeground "CalltipForeground" 75 #define textNcalltipBackground "calltipBackground" 76 #define textCcalltipBackground "CalltipBackground" 77 #define textNpendingDelete "pendingDelete" 78 #define textCPendingDelete "PendingDelete" 79 #define textNhScrollBar "hScrollBar" 80 #define textCHScrollBar "HScrollBar" 81 #define textNvScrollBar "vScrollBar" 82 #define textCVScrollBar "VScrollBar" 83 #define textNlineNumCols "lineNumCols" 84 #define textCLineNumCols "LineNumCols" 85 #define textNautoShowInsertPos "autoShowInsertPos" 86 #define textCAutoShowInsertPos "AutoShowInsertPos" 87 #define textNautoWrapPastedText "autoWrapPastedText" 88 #define textCAutoWrapPastedText "AutoWrapPastedText" 89 #define textNwordDelimiters "wordDelimiters" 90 #define textCWordDelimiters "WordDelimiters" 91 #define textNblinkRate "blinkRate" 92 #define textCBlinkRate "BlinkRate" 93 #define textNfocusCallback "focusCallback" 94 #define textCFocusCallback "FocusCallback" 95 #define textNlosingFocusCallback "losingFocusCallback" 96 #define textCLosingFocusCallback "LosingFocusCallback" 97 #define textNcursorMovementCallback "cursorMovementCallback" 98 #define textCCursorMovementCallback "CursorMovementCallback" 99 #define textNdragStartCallback "dragStartCallback" 100 #define textCDragStartCallback "DragStartCallback" 101 #define textNdragEndCallback "dragEndCallback" 102 #define textCDragEndCallback "DragEndCallback" 103 #define textNsmartIndentCallback "smartIndentCallback" 104 #define textCSmartIndentCallback "SmartIndentCallback" 105 #define textNautoWrap "autoWrap" 106 #define textCAutoWrap "AutoWrap" 107 #define textNcontinuousWrap "continuousWrap" 108 #define textCContinuousWrap "ContinuousWrap" 109 #define textNwrapMargin "wrapMargin" 110 #define textCWrapMargin "WrapMargin" 111 #define textNautoIndent "autoIndent" 112 #define textCAutoIndent "AutoIndent" 113 #define textNsmartIndent "smartIndent" 114 #define textCSmartIndent "SmartIndent" 115 #define textNoverstrike "overstrike" 116 #define textCOverstrike "Overstrike" 117 #define textNheavyCursor "heavyCursor" 118 #define textCHeavyCursor "HeavyCursor" 119 #define textNreadOnly "readOnly" 120 #define textCReadOnly "ReadOnly" 121 #define textNhidePointer "hidePointer" 122 #define textCHidePointer "HidePointer" 123 #define textNemulateTabs "emulateTabs" 124 #define textCEmulateTabs "EmulateTabs" 125 #define textNcursorVPadding "cursorVPadding" 126 #define textCCursorVPadding "CursorVPadding" 127 #define textNbacklightCharTypes "backlightCharTypes" 128 #define textCBacklightCharTypes "BacklightCharTypes" 129 #define textNindentRainbow "indentRainbow" 130 #define textCindentRainbow "indentRainbow" 131 #define textNhighlightCursorLine "highlightCursorLine" 132 #define textChighlightCursorLine "highlightCursorLine" 133 #define textNansiColors "ansiColors" 134 #define textCansiColors "ansiColors" 135 #define textNansiColorList "ansiColorList" 136 #define textCansiColorList "ansiColorList" 137 138 139 extern WidgetClass textWidgetClass; 140 141 struct _TextClassRec; 142 struct _TextRec; 143 144 typedef struct _TextRec *TextWidget; 145 146 typedef struct { 147 int startPos; 148 int nCharsDeleted; 149 int nCharsInserted; 150 char *deletedText; 151 } dragEndCBStruct; 152 153 enum smartIndentCallbackReasons {NEWLINE_INDENT_NEEDED, CHAR_TYPED}; 154 typedef struct { 155 int reason; 156 int pos; 157 int indentRequest; 158 char *charsTyped; 159 } smartIndentCBStruct; 160 161 162 Widget XNECreateTextField(Widget parent, char *name, ArgList arglist, Cardinal argcount); 163 164 void TextWidgetClassInit(Display *dp, const char *fontname); 165 166 /* User callable routines */ 167 void TextSetBuffer(Widget w, textBuffer *buffer); 168 textBuffer *TextGetBuffer(Widget w); 169 int TextLineAndColToPos(Widget w, int lineNum, int column); 170 int TextPosToLineAndCol(Widget w, int pos, int *lineNum, int *column); 171 int TextPosToXY(Widget w, int pos, int *x, int *y); 172 int TextGetCursorPos(Widget w); 173 void TextSetCursorPos(Widget w, int pos); 174 void TextSetCursors(Widget w, size_t *cursors, size_t ncursors); 175 int TextGetLastCursorPos(Widget w); 176 void TextSetLastCursorPos(Widget w, int pos); 177 int TextNumCursors(Widget w); 178 void TextChangeCursors(Widget w, int startPos, int diff); 179 void TextClearMultiCursors(Widget w); 180 void TextGetScroll(Widget w, int *topLineNum, int *horizOffset); 181 void TextSetScroll(Widget w, int topLineNum, int horizOffset); 182 int TextGetMinFontWidth(Widget w, Boolean considerStyles); 183 int TextGetMaxFontWidth(Widget w, Boolean considerStyles); 184 void TextHandleXSelections(Widget w); 185 void TextPasteClipboard(Widget w, Time time); 186 void TextColPasteClipboard(Widget w, Time time); 187 void TextCopyClipboard(Widget w, Time time); 188 void TextCutClipboard(Widget w, Time time); 189 int TextFirstVisibleLine(Widget w); 190 int TextNumVisibleLines(Widget w); 191 int TextVisibleWidth(Widget w); 192 void TextInsertAtCursor(Widget w, char *chars, XEvent *event, 193 int allowPendingDelete, int allowWrap); 194 int TextFirstVisiblePos(Widget w); 195 int TextLastVisiblePos(Widget w); 196 char *TextGetWrapped(Widget w, int startPos, int endPos, int *length); 197 XtActionsRec *TextGetActions(int *nActions); 198 void ShowHidePointer(TextWidget w, Boolean hidePointer); 199 void ResetCursorBlink(TextWidget textWidget, Boolean startsBlanked); 200 XftColor TextGetFGColor(Widget w); 201 XftColor TextGetBGColor(Widget w); 202 int TextLookupString( 203 Widget w, 204 XKeyPressedEvent *event, 205 char* buffer_return, 206 int bytes_buffer, 207 KeySym* keysym_return, 208 Status* status); 209 210 /* void TextPrintXIMError(void); */ 211 212 void HandleAllPendingGraphicsExposeNoExposeEvents(TextWidget w, XEvent *event); 213 214 #endif /* NEDIT_TEXT_H_INCLUDED */ 215