From 7fbd8e2a34d2f5084ce26ad95d7c70ae4de6a233 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Wed, 8 Mar 2000 01:38:23 +0000 Subject: Initial revision --- include/Accessor.h | 76 ++++++++++ include/KeyWords.h | 8 + include/Platform.h | 394 +++++++++++++++++++++++++++++++++++++++++++++++++ include/PropSet.h | 180 +++++++++++++++++++++++ include/SciLexer.h | 172 ++++++++++++++++++++++ include/Scintilla.h | 415 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/WinDefs.h | 218 +++++++++++++++++++++++++++ 7 files changed, 1463 insertions(+) create mode 100644 include/Accessor.h create mode 100644 include/KeyWords.h create mode 100644 include/Platform.h create mode 100644 include/PropSet.h create mode 100644 include/SciLexer.h create mode 100644 include/Scintilla.h create mode 100644 include/WinDefs.h (limited to 'include') diff --git a/include/Accessor.h b/include/Accessor.h new file mode 100644 index 000000000..1bba4af55 --- /dev/null +++ b/include/Accessor.h @@ -0,0 +1,76 @@ +// SciTE - Scintilla based Text Editor +// Accessor.h - rapid easy access to contents of a Scintilla +// Copyright 1998-2000 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +class Accessor { +protected: + // bufferSize is a trade off between time taken to copy the characters and SendMessage overhead + // slopSize positions the buffer before the desired position in case there is some backtracking + enum {bufferSize=4000, slopSize=bufferSize/8}; + char buf[bufferSize+1]; + WindowID id; + PropSet &props; + int startPos; + int endPos; + int lenDoc; + int offset; // Optional but including an offset makes GCC generate better code + void Fill(int position); +public: + Accessor(WindowID id_, PropSet &props_, int offset_=0) : + id(id_), props(props_), startPos(0x7FFFFFFF), endPos(0), + lenDoc(-1), offset(offset_) { + } + char operator[](int position) { + position += offset; + if (position < startPos || position >= endPos) { + Fill(position); + } + return buf[position - startPos]; + } + char SafeGetCharAt(int position, char chDefault=' ') { + // Safe version of operator[], returning a defined value for invalid position + position += offset; + if (position < startPos || position >= endPos) { + Fill(position); + if (position < startPos || position >= endPos) { + // Position is outside range of document + return chDefault; + } + } + return buf[position - startPos]; + } + char StyleAt(int position); + int GetLine(int position); + int LineStart(int line); + int LevelAt(int line); + int Length(); + void Flush() { + startPos = 0x7FFFFFFF; + lenDoc = -1; + } + int GetLineState(int line); + int SetLineState(int line, int state); + PropSet &GetPropSet() { return props; } +}; + +class StylingContext : public Accessor { + char styleBuf[bufferSize]; + int validLen; + char chFlags; + char chWhile; + unsigned int startSeg; +public: + StylingContext(WindowID id_, PropSet &props_, int offset_=0) : + Accessor(id_,props_,offset_), validLen(0), chFlags(0) {} + void StartAt(unsigned int start, char chMask=31); + void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; }; + void ColourSegment(unsigned int start, unsigned int end, int chAttr); + unsigned int GetStartSegment() { return startSeg; } + void StartSegment(unsigned int pos); + void ColourTo(unsigned int pos, int chAttr); + int GetLine(int position); + void SetLevel(int line, int level); + void Flush(); +}; + diff --git a/include/KeyWords.h b/include/KeyWords.h new file mode 100644 index 000000000..2cc03b788 --- /dev/null +++ b/include/KeyWords.h @@ -0,0 +1,8 @@ +// SciTE - Scintilla based Text Editor +// KeyWords.h - colourise for particular languages +// Copyright 1998-2000 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +void ColouriseDoc(int codePage, int startPos, int lengthDoc, int initStyle, + int language, WordList *keywordlists[], StylingContext &styler); + diff --git a/include/Platform.h b/include/Platform.h new file mode 100644 index 000000000..b077e2e34 --- /dev/null +++ b/include/Platform.h @@ -0,0 +1,394 @@ +// Scintilla source code edit control +// Platform.h - interface to platform facilities +// Also includes some basic utilities +// Implemented in PlatGTK.cxx for GTK+/Linux, PlatWin.cxx for Windows, and PlatWX.cxx for wxWindows +// Copyright 1998-2000 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef PLATFORM_H +#define PLATFORM_H + +// PLAT_GTK = GTK+ on Linux, PLAT_WIN = Win32 API on Win32 OS +// PLAT_WX is wxWindows on any supported platform +// Could also have PLAT_GTKWIN = GTK+ on Win32 OS in future + +#define PLAT_GTK 0 +#define PLAT_WIN 0 +#define PLAT_WX 0 + +#if defined(__WX__) +#undef PLAT_WX +#define PLAT_WX 1 + +#elif defined(GTK) +#undef PLAT_GTK +#define PLAT_GTK 1 + +#else +#undef PLAT_WIN +#define PLAT_WIN 1 + +#endif + + +// Include the main header for each platform + +#if PLAT_GTK +#include +#include +#endif + +#if PLAT_WIN +#define _WIN32_WINNT 0x0400 // Otherwise some required stuff gets ifdef'd out +// Vassili Bourdo: shut up annoying Visual C++ warnings: +#ifdef _MSC_VER +#pragma warning(disable: 4800 4244 4309) +#endif +#include +#include +#endif + +#if PLAT_WX +#include +#endif + +// Underlying the implementation of the platform classes are platform specific types. +// Sometimes these need to be passed around by client code so they are defined here + +#if PLAT_GTK +typedef GdkColor ColourID; +typedef GdkFont* FontID; +typedef GdkDrawable* SurfaceID; +typedef GtkWidget* WindowID; +typedef GtkItemFactory* MenuID; +#endif + +#if PLAT_WIN +typedef COLORREF ColourID; +typedef HFONT FontID; +typedef HDC SurfaceID; +typedef HWND WindowID; +typedef HMENU MenuID; +#endif + +#if PLAT_WX +typedef wxColour ColourID; +typedef wxFont* FontID; +typedef wxDC* SurfaceID; +typedef wxWindow* WindowID; +typedef wxMenu* MenuID; +#endif + +#if PLAT_GTK || PLAT_WX +#define SHIFT_PRESSED 1 +#define LEFT_CTRL_PRESSED 2 +#define LEFT_ALT_PRESSED 4 +#endif + +// Point is exactly the same as the Win32 POINT and GTK+ GdkPoint so can be used interchangeably + +class Point { +public: + int x; + int y; + + Point(int x_=0, int y_=0) : x(x_), y(y_) { + } + + // Other automatically defined methods (assignment, copy constructor, destructor) are fine + + static Point FromLong(long lpoint); +}; + +// PRectangle is exactly the same as the Win32 RECT so can be used interchangeably +// PRectangles contain their top and left sides, but not their right and bottom sides +class PRectangle { +public: + int left; + int top; + int right; + int bottom; + + PRectangle(int left_=0, int top_=0, int right_=0, int bottom_ = 0) : + left(left_), top(top_), right(right_), bottom(bottom_) { + } + + // Other automatically defined methods (assignment, copy constructor, destructor) are fine + + bool Contains(Point pt) { + return (pt.x >= left) && (pt.x <= right) && + (pt.y >= top) && (pt.y <= bottom); + } + bool Contains(PRectangle rc) { + return (rc.left >= left) && (rc.right <= right) && + (rc.top >= top) && (rc.bottom <= bottom); + } + bool Intersects(PRectangle other) { + return (right >= other.left) && (left <= other.right) && + (bottom >= other.top) && (top <= other.bottom); + } + int Width() { return right - left; } + int Height() { return bottom - top; } +}; + +#if PLAT_WX +wxRect wxRectFromPRectangle(PRectangle prc); +PRectangle PRectangleFromwxRect(wxRect rc); +#endif + +class Colour { + ColourID co; +public: + Colour(long lcol=0); + Colour(unsigned int red, unsigned int green, unsigned int blue); + bool operator==(const Colour &other) const; + long AsLong() const; + unsigned int GetRed(); + unsigned int GetGreen(); + unsigned int GetBlue(); + + friend class Surface; + friend class Palette; +}; + +// Colour pairs hold a desired colour and the colour that the graphics engine +// allocates to approximate the desired colour. +// To make palette management more automatic, ColourPairs could register at +// construction time with a palette management object. +struct ColourPair { + Colour desired; + Colour allocated; + + ColourPair(Colour desired_=Colour(0,0,0)) { + desired = desired_; + allocated = desired; + } +}; + +class Window; // Forward declaration for Palette + +class Palette { + int used; + enum {numEntries = 100}; + ColourPair entries[numEntries]; +#if PLAT_GTK + GdkColor *allocatedPalette; + int allocatedLen; +#elif PLAT_WIN + HPALETTE hpal; +#elif PLAT_WX + // wxPalette* pal; // **** Is this needed? +#endif +public: + bool allowRealization; + + Palette(); + ~Palette(); + + void Release(); + + // This method either adds a colour to the list of wanted colours (want==true) + // or retrieves the allocated colour back to the ColourPair. + // This is one method to make it easier to keep the code for wanting and retrieving in sync. + void WantFind(ColourPair &cp, bool want); + + void Allocate(Window &w); + + friend class Surface; +}; + +class Font { + FontID id; +#if PLAT_WX + int ascent; +#endif + // Private so Font objects can not be copied + Font(const Font &) {} + Font &operator=(const Font &) { id=0; return *this; } +public: + Font(); + ~Font(); + + void Create(const char *faceName, int size, bool bold=false, bool italic=false); + void Release(); + + FontID GetID() { return id; } + // Alias another font - caller guarantees not to Release + void SetID(FontID id_) { id = id_; } + friend class Surface; +}; + +// A surface abstracts a place to draw +class Surface { +private: +#if PLAT_GTK + GdkDrawable *drawable; + GdkGC *gc; + GdkPixmap *ppixmap; + int x; + int y; + bool inited; + bool createdGC; +#elif PLAT_WIN + HDC hdc; + bool hdcOwned; + HPEN pen; + HPEN penOld; + HBRUSH brush; + HBRUSH brushOld; + HFONT font; + HFONT fontOld; + HBITMAP bitmap; + HBITMAP bitmapOld; + HPALETTE paletteOld; +#elif PLAT_WX + wxDC* hdc; + bool hdcOwned; + wxBitmap* bitmap; + int x; + int y; +#endif + + // Private so Surface objects can not be copied + Surface(const Surface &) {} + Surface &operator=(const Surface &) { return *this; } +#if PLAT_WIN || PLAT_WX + void BrushColor(Colour back); + void SetFont(Font &font_); +#endif +public: + Surface(); + ~Surface(); + + void Init(); + void Init(SurfaceID hdc_); + void InitPixMap(int width, int height, Surface *surface_); + + void Release(); + bool Initialised(); + void PenColour(Colour fore); + int LogPixelsY(); + void MoveTo(int x_, int y_); + void LineTo(int x_, int y_); + void Polygon(Point *pts, int npts, Colour fore, Colour back); + void RectangleDraw(PRectangle rc, Colour fore, Colour back); + void FillRectangle(PRectangle rc, Colour back); + void FillRectangle(PRectangle rc, Surface &surfacePattern); + void RoundedRectangle(PRectangle rc, Colour fore, Colour back); + void Ellipse(PRectangle rc, Colour fore, Colour back); + void Copy(PRectangle rc, Point from, Surface &surfaceSource); + + void DrawText(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back); + void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back); + void MeasureWidths(Font &font_, const char *s, int len, int *positions); + int WidthText(Font &font_, const char *s, int len); + int WidthChar(Font &font_, char ch); + int Ascent(Font &font_); + int Descent(Font &font_); + int InternalLeading(Font &font_); + int ExternalLeading(Font &font_); + int Height(Font &font_); + int AverageCharWidth(Font &font_); + + int SetPalette(Palette *pal, bool inBackGround); + void SetClip(PRectangle rc); +}; + +// Class to hide the details of window manipulation +// Does not own the window which will normally have a longer life than this object +class Window { + friend class ListBox; +protected: + WindowID id; +public: + Window() : id(0) {} + virtual ~Window(); + Window &operator=(WindowID id_) { + id = id_; + return *this; + } + WindowID GetID() { return id; } + bool Created() { return id != 0; } + void Destroy(); + bool HasFocus(); + PRectangle GetPosition(); + void SetPosition(PRectangle rc); + void SetPositionRelative(PRectangle rc, Window relativeTo); + PRectangle GetClientPosition(); + void Show(bool show=true); + void InvalidateAll(); + void InvalidateRectangle(PRectangle rc); + void SetFont(Font &font); + enum Cursor { cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow }; + void SetCursor(Cursor curs); + void SetTitle(const char *s); +#if PLAT_WIN + LRESULT SendMessage(UINT msg, WPARAM wParam=0, LPARAM lParam=0); + int GetDlgCtrlID(); + HINSTANCE GetInstance(); +#endif +}; + +class ListBox : public Window { +#if PLAT_GTK + WindowID list; + WindowID scroller; + int current; +#endif +public: + ListBox(); + virtual ~ListBox(); + ListBox &operator=(WindowID id_) { + id = id_; + return *this; + } + void Create(Window &parent, int ctrlID); + void Clear(); + void Append(char *s); + int Length(); + void Select(int n); + int GetSelection(); + int Find(const char *prefix); + void GetValue(int n, char *value, int len); + void Sort(); +}; + +class Menu { + MenuID id; +public: + Menu(); + MenuID GetID() { return id; } + void CreatePopUp(); + void Destroy(); + void Show(Point pt, Window &w); +}; + +// Platform class used to retrieve system wide parameters such as double click speed +// and chrome colour. Not a creatable object, more of a module with several functions. +class Platform { + // Private so Platform objects can not be copied + Platform(const Platform &) {} + Platform &operator=(const Platform &) { return *this; } +public: + // Should be private because no new Platforms are ever created + // but gcc warns about this + Platform() {} + ~Platform() {} + static Colour Chrome(); + static Colour ChromeHighlight(); + static const char *DefaultFont(); + static int DefaultFontSize(); + static unsigned int DoubleClickTime(); + static void DebugDisplay(const char *s); + static bool IsKeyDown(int key); + static long SendScintilla( + WindowID w, unsigned int msg, unsigned long wParam=0, long lParam=0); + + // These are utility functions not really tied to a platform + static int Minimum(int a, int b); + static int Maximum(int a, int b); + static void DebugPrintf(const char *format, ...); + static int Clamp(int val, int minVal, int maxVal); +}; + +#endif diff --git a/include/PropSet.h b/include/PropSet.h new file mode 100644 index 000000000..31da01f95 --- /dev/null +++ b/include/PropSet.h @@ -0,0 +1,180 @@ +// SciTE - Scintilla based Text Editor +// PropSet.h - a java style properties file module +// Copyright 1998-2000 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef PROPSET_H +#define PROPSET_H + +bool EqualCaseInsensitive(const char *a, const char *b); + +// Define another string class. +// While it would be 'better' to use std::string, that doubles the executable size. + +inline char *StringDup(const char *s) { + if (!s) + return 0; + char *sNew = new char[strlen(s) + 1]; + if (sNew) + strcpy(sNew, s); + return sNew; +} + +class SString { + char *s; +public: + SString() { + s = 0; + } + SString(const SString &source) { + s = StringDup(source.s); + } + SString(const char *s_) { + s = StringDup(s_); + } + SString(int i) { + char number[100]; + sprintf(number, "%0d", i); + //itoa(i, number, 10); + s = StringDup(number); + } + ~SString() { + delete []s; + s = 0; + } + SString &operator=(const SString &source) { + if (this != &source) { + delete []s; + s = StringDup(source.s); + } + return *this; + } + bool operator==(const SString &other) const { + if ((s == 0) && (other.s == 0)) + return true; + if ((s == 0) || (other.s == 0)) + return false; + return strcmp(s, other.s) == 0; + } + bool operator==(const char *sother) const { + if ((s == 0) && (sother == 0)) + return true; + if ((s == 0) || (sother == 0)) + return false; + return strcmp(s, sother) == 0; + } + const char *c_str() const { + if (s) + return s; + else + return ""; + } + int length() const { + if (s) + return strlen(s); + else + return 0; + } + char operator[](int i) { + if (s) + return s[i]; + else + return '\0'; + } + SString &operator +=(const char *sother) { + int len = length(); + int lenOther = strlen(sother); + char *sNew = new char[len + lenOther + 1]; + if (sNew) { + if (s) + memcpy(sNew, s, len); + memcpy(sNew + len, sother, lenOther); + sNew[len + lenOther] = '\0'; + delete []s; + s = sNew; + } + return *this; + } + int value() { + if (s) + return atoi(s); + else + return 0; + } +}; + +class PropSet { +private: + char **vals; + int size; + int used; +public: + PropSet *superPS; + PropSet(); + ~PropSet(); + void EnsureCanAddEntry(); + void Set(const char *key, const char *val); + void Set(char *keyval); + SString Get(const char *key); + int GetInt(const char *key, int defaultValue=0); + SString GetWild(const char *keybase, const char *filename); + SString GetNewExpand(const char *keybase, const char *filename); + void Clear(); + void ReadFromMemory(const char *data, int len); + void Read(const char *filename); +}; + +// This is a fixed length list of strings suitable for display in combo boxes +// as a memory of user entries +template +class EntryMemory { + SString entries[sz]; +public: + void Insert(SString s) { + for (int i=0;i0;j--) { + entries[j] = entries[j-1]; + } + entries[0] = s; + return; + } + } + for (int k=sz-1;k>0;k--) { + entries[k] = entries[k-1]; + } + entries[0] = s; + } + int Length() const { + int len = 0; + for (int i=0;i +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef SCILEXER_H +#define SCILEXER_H + +// SciLexer features - not in standard Scintilla + +#define SCLEX_CONTAINER 0 +#define SCLEX_NULL 1 +#define SCLEX_PYTHON 2 +#define SCLEX_CPP 3 +#define SCLEX_HTML 4 +#define SCLEX_XML 5 +#define SCLEX_PERL 6 +#define SCLEX_SQL 7 +#define SCLEX_VB 8 +#define SCLEX_PROPERTIES 9 +#define SCLEX_ERRORLIST 10 +#define SCLEX_MAKEFILE 11 +#define SCLEX_BATCH 12 + +// Lexical states for SCLEX_PYTHON +#define SCE_P_DEFAULT 0 +#define SCE_P_COMMENTLINE 1 +#define SCE_P_NUMBER 2 +#define SCE_P_STRING 3 +#define SCE_P_CHARACTER 4 +#define SCE_P_WORD 5 +#define SCE_P_TRIPLE 6 +#define SCE_P_TRIPLEDOUBLE 7 +#define SCE_P_CLASSNAME 8 +#define SCE_P_DEFNAME 9 +#define SCE_P_OPERATOR 10 +#define SCE_P_IDENTIFIER 11 +#define SCE_P_COMMENTBLOCK 12 +#define SCE_P_STRINGEOL 13 + +// Lexical states for SCLEX_CPP, SCLEX_VB +#define SCE_C_DEFAULT 0 +#define SCE_C_COMMENT 1 +#define SCE_C_COMMENTLINE 2 +#define SCE_C_COMMENTDOC 3 +#define SCE_C_NUMBER 4 +#define SCE_C_WORD 5 +#define SCE_C_STRING 6 +#define SCE_C_CHARACTER 7 +#define SCE_C_PUNTUATION 8 +#define SCE_C_PREPROCESSOR 9 +#define SCE_C_OPERATOR 10 +#define SCE_C_IDENTIFIER 11 +#define SCE_C_STRINGEOL 12 + +// Lexical states for SCLEX_HTML, SCLEX_xML +#define SCE_H_DEFAULT 0 +#define SCE_H_TAG 1 +#define SCE_H_TAGUNKNOWN 2 +#define SCE_H_ATTRIBUTE 3 +#define SCE_H_ATTRIBUTEUNKNOWN 4 +#define SCE_H_NUMBER 5 +#define SCE_H_DOUBLESTRING 6 +#define SCE_H_SINGLESTRING 7 +#define SCE_H_OTHER 8 +#define SCE_H_COMMENT 9 +#define SCE_H_ENTITY 10 +// XML and ASP +#define SCE_H_TAGEND 11 +#define SCE_H_XMLSTART 12 +#define SCE_H_XMLEND 13 +#define SCE_H_SCRIPT 14 +#define SCE_H_ASP 15 +#define SCE_H_ASPAT 16 +// Embedded Javascript +#define SCE_HJ_START 40 +#define SCE_HJ_DEFAULT 41 +#define SCE_HJ_COMMENT 42 +#define SCE_HJ_COMMENTLINE 43 +#define SCE_HJ_COMMENTDOC 44 +#define SCE_HJ_NUMBER 45 +#define SCE_HJ_WORD 46 +#define SCE_HJ_KEYWORD 47 +#define SCE_HJ_DOUBLESTRING 48 +#define SCE_HJ_SINGLESTRING 49 +#define SCE_HJ_SYMBOLS 50 +#define SCE_HJ_STRINGEOL 51 +// ASP Javascript +#define SCE_HJA_START 55 +#define SCE_HJA_DEFAULT 56 +#define SCE_HJA_COMMENT 57 +#define SCE_HJA_COMMENTLINE 58 +#define SCE_HJA_COMMENTDOC 59 +#define SCE_HJA_NUMBER 60 +#define SCE_HJA_WORD 61 +#define SCE_HJA_KEYWORD 62 +#define SCE_HJA_DOUBLESTRING 63 +#define SCE_HJA_SINGLESTRING 64 +#define SCE_HJA_SYMBOLS 65 +#define SCE_HJA_STRINGEOL 66 +// Embedded VBScript +#define SCE_HB_START 70 +#define SCE_HB_DEFAULT 71 +#define SCE_HB_COMMENTLINE 72 +#define SCE_HB_NUMBER 73 +#define SCE_HB_WORD 74 +#define SCE_HB_STRING 75 +#define SCE_HB_IDENTIFIER 76 +#define SCE_HB_STRINGEOL 77 +// ASP VBScript +#define SCE_HBA_START 80 +#define SCE_HBA_DEFAULT 81 +#define SCE_HBA_COMMENTLINE 82 +#define SCE_HBA_NUMBER 83 +#define SCE_HBA_WORD 84 +#define SCE_HBA_STRING 85 +#define SCE_HBA_IDENTIFIER 86 +#define SCE_HBA_STRINGEOL 87 +// Embedded Python +#define SCE_HP_START 90 +#define SCE_HP_DEFAULT 91 +#define SCE_HP_COMMENTLINE 92 +#define SCE_HP_NUMBER 93 +#define SCE_HP_STRING 94 +#define SCE_HP_CHARACTER 95 +#define SCE_HP_WORD 96 +#define SCE_HP_TRIPLE 97 +#define SCE_HP_TRIPLEDOUBLE 98 +#define SCE_HP_CLASSNAME 99 +#define SCE_HP_DEFNAME 100 +#define SCE_HP_OPERATOR 101 +#define SCE_HP_IDENTIFIER 102 +// ASP Python +#define SCE_HPA_START 105 +#define SCE_HPA_DEFAULT 106 +#define SCE_HPA_COMMENTLINE 107 +#define SCE_HPA_NUMBER 108 +#define SCE_HPA_STRING 109 +#define SCE_HPA_CHARACTER 110 +#define SCE_HPA_WORD 111 +#define SCE_HPA_TRIPLE 112 +#define SCE_HPA_TRIPLEDOUBLE 113 +#define SCE_HPA_CLASSNAME 114 +#define SCE_HPA_DEFNAME 115 +#define SCE_HPA_OPERATOR 116 +#define SCE_HPA_IDENTIFIER 117 + +// Lexical states for SCLEX_PERL +#define SCE_PL_DEFAULT 0 +#define SCE_PL_HERE 1 +#define SCE_PL_COMMENTLINE 2 +#define SCE_PL_POD 3 +#define SCE_PL_NUMBER 4 +#define SCE_PL_WORD 5 +#define SCE_PL_STRING 6 +#define SCE_PL_CHARACTER 7 +#define SCE_PL_PUNCTUATION 8 +#define SCE_PL_PREPROCESSOR 9 +#define SCE_PL_OPERATOR 10 +#define SCE_PL_IDENTIFIER 11 +#define SCE_PL_SCALAR 12 +#define SCE_PL_ARRAY 13 +#define SCE_PL_HASH 14 +#define SCE_PL_SYMBOLTABLE 15 +#define SCE_PL_REF 16 +#define SCE_PL_REGEX 17 +#define SCE_PL_REGSUBST 18 +#define SCE_PL_LONGQUOTE 19 +#define SCE_PL_BACKTICKS 20 +#define SCE_PL_DATASECTION 21 + +#endif diff --git a/include/Scintilla.h b/include/Scintilla.h new file mode 100644 index 000000000..35b5ad2e2 --- /dev/null +++ b/include/Scintilla.h @@ -0,0 +1,415 @@ +// Scintilla source code edit control +// Scintilla.h - interface to the edit control +// Copyright 1998-2000 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef SCINTILLA_H +#define SCINTILLA_H + +// Compile-time configuration options +#define MACRO_SUPPORT 1 // Comment out to remove macro hooks + +#if PLAT_GTK +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define SCINTILLA(obj) GTK_CHECK_CAST (obj, scintilla_get_type (), ScintillaObject) +#define SCINTILLA_CLASS(klass) GTK_CHECK_CLASS_CAS T (klass, scintilla_get_type (), ScintillaClass) +#define IS_SCINTILLA(obj) GTK_CHECK_TYPE (obj, scintilla_get_type ()) + + typedef struct _ScintillaObject ScintillaObject; + typedef struct _ScintillaClass ScintillaClass; + + struct _ScintillaObject + { + GtkFixed vbox; + void *pscin; + }; + + struct _ScintillaClass + { + GtkFixedClass parent_class; + + void (* command) (ScintillaObject *ttt); + void (* notify) (ScintillaObject *ttt); + }; + + guint scintilla_get_type (void); + GtkWidget* scintilla_new (void); + void scintilla_set_id (ScintillaObject *sci,int id); + long scintilla_send_message (ScintillaObject *sci,int iMessage,int wParam,int lParam); + +#include "WinDefs.h" + +#ifdef __cplusplus +} +#endif + +#endif + +#if PLAT_WX +#include "WinDefs.h" +#endif + +// Both GTK and Windows + +#define INVALID_POSITION -1 + +// Define start of Scintilla messages to be greater than all edit (EM_*) messages +// as many EM_ messages can be used. +#define SCI_START 2000 +#define SCI_OPTIONAL_START 3000 +#define SCI_LEXER_START 4000 + +#define SCI_ADDTEXT SCI_START + 1 +#define SCI_ADDSTYLEDTEXT SCI_START + 2 +#define SCI_INSERTTEXT SCI_START + 3 +#define SCI_CLEARALL SCI_START + 4 +#define SCI_GETLENGTH SCI_START + 6 +#define SCI_GETCHARAT SCI_START + 7 +#define SCI_GETCURRENTPOS SCI_START + 8 +#define SCI_GETANCHOR SCI_START + 9 +#define SCI_GETSTYLEAT SCI_START + 10 + +#define SCI_REDO SCI_START + 11 +#define SCI_SETUNDOCOLLECTION SCI_START + 12 +#define SCI_SELECTALL SCI_START + 13 +#define SCI_SETSAVEPOINT SCI_START + 14 +#define SCI_GETSTYLEDTEXT SCI_START + 15 +#define SCI_CANREDO SCI_START + 16 +#define SCI_MARKERLINEFROMHANDLE SCI_START + 17 +#define SCI_MARKERDELETEHANDLE SCI_START + 18 + +#define SC_UNDOCOLLECT_NONE 0 +#define SC_UNDOCOLLECT_AUTOSTART 1 + +#define SCI_GETVIEWWS SCI_START + 20 +#define SCI_SETVIEWWS SCI_START + 21 +#define SCI_CHANGEPOSITION SCI_START + 22 +#define SCI_GOTOLINE SCI_START + 24 +#define SCI_GOTOPOS SCI_START + 25 +#define SCI_SETANCHOR SCI_START + 26 +#define SCI_GETCURLINE SCI_START + 27 +#define SCI_GETENDSTYLED SCI_START + 28 +#define SCI_CONVERTEOLS SCI_START + 29 + +#define SCI_GETEOLMODE SCI_START + 30 +#define SCI_SETEOLMODE SCI_START + 31 + +#define SC_EOL_CRLF 0 +#define SC_EOL_CR 1 +#define SC_EOL_LF 2 + +#define SCI_STARTSTYLING SCI_START + 32 +#define SCI_SETSTYLING SCI_START + 33 + +#define SCI_SETBUFFEREDDRAW SCI_START + 35 +#define SCI_SETTABWIDTH SCI_START + 36 +#define SCI_SETCODEPAGE SCI_START + 37 +#define SCI_SETUSEPALETTE SCI_START + 39 + +#define MARKER_MAX 31 + +#define SC_MARK_CIRCLE 0 +#define SC_MARK_ROUNDRECT 1 +#define SC_MARK_ARROW 2 +#define SC_MARK_SMALLRECT 3 +#define SC_MARK_SHORTARROW 4 +#define SC_MARK_EMPTY 5 +#define SC_MARK_ARROWDOWN 6 +#define SC_MARK_MINUS 7 +#define SC_MARK_PLUS 8 + +#define SCI_MARKERDEFINE SCI_START + 40 +#define SCI_MARKERSETFORE SCI_START + 41 +#define SCI_MARKERSETBACK SCI_START + 42 +#define SCI_MARKERADD SCI_START + 43 +#define SCI_MARKERDELETE SCI_START + 44 +#define SCI_MARKERDELETEALL SCI_START + 45 +#define SCI_MARKERGET SCI_START + 46 +#define SCI_MARKERNEXT SCI_START + 47 +#define SCI_MARKERPREVIOUS SCI_START + 48 + +#define SC_MARKNUM_FOLDER 30 +#define SC_MARKNUM_FOLDEROPEN 31 + +#define SC_MASK_FOLDERS ((1< +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef WINDEFS_H +#define WINDEFS_H + +#define WORD short +#define WPARAM unsigned long +#define LPARAM long +#define LRESULT long +#define DWORD long + +#define UINT unsigned int +#define LPSTR char * +#define LONG long + +/* RTF control */ +#define EM_CANPASTE (1074) +#define EM_CANUNDO (198) +#define EM_CHARFROMPOS (215) +#define EM_DISPLAYBAND (1075) +#define EM_EMPTYUNDOBUFFER (205) +#define EM_EXGETSEL (1076) +#define EM_EXLIMITTEXT (1077) +#define EM_EXLINEFROMCHAR (1078) +#define EM_EXSETSEL (1079) +#define EM_FINDTEXT (1080) +#define EM_FINDTEXTEX (1103) +#define EM_FINDWORDBREAK (1100) +#define EM_FMTLINES (200) +#define EM_FORMATRANGE (1081) +#define EM_GETCHARFORMAT (1082) +#define EM_GETEVENTMASK (1083) +#define EM_GETFIRSTVISIBLELINE (206) +#define EM_GETHANDLE (189) +#define EM_GETLIMITTEXT (213) +#define EM_GETLINE (196) +#define EM_GETLINECOUNT (186) +#define EM_GETMARGINS (212) +#define EM_GETMODIFY (184) +#define EM_GETIMECOLOR (1129) +#define EM_GETIMEOPTIONS (1131) +#define EM_GETOPTIONS (1102) +#define EM_GETOLEINTERFACE (1084) +#define EM_GETPARAFORMAT (1085) +#define EM_GETPASSWORDCHAR (210) +#define EM_GETPUNCTUATION (1125) +#define EM_GETRECT (178) +#define EM_GETSEL (176) +#define EM_GETSELTEXT (1086) +#define EM_GETTEXTRANGE (1099) +#define EM_GETTHUMB (190) +#define EM_GETWORDBREAKPROC (209) +#define EM_GETWORDBREAKPROCEX (1104) +#define EM_GETWORDWRAPMODE (1127) +#define EM_HIDESELECTION (1087) +#define EM_LIMITTEXT (197) +#define EM_LINEFROMCHAR (201) +#define EM_LINEINDEX (187) +#define EM_LINELENGTH (193) +#define EM_LINESCROLL (182) +#define EM_PASTESPECIAL (1088) +#define EM_POSFROMCHAR (214) +#define EM_REPLACESEL (194) +#define EM_REQUESTRESIZE (1089) +#define EM_SCROLL (181) +#define EM_SCROLLCARET (183) +#define EM_SELECTIONTYPE (1090) +#define EM_SETBKGNDCOLOR (1091) +#define EM_SETCHARFORMAT (1092) +#define EM_SETEVENTMASK (1093) +#define EM_SETHANDLE (188) +#define EM_SETIMECOLOR (1128) +#define EM_SETIMEOPTIONS (1130) +#define EM_SETLIMITTEXT (197) +#define EM_SETMARGINS (211) +#define EM_SETMODIFY (185) +#define EM_SETOLECALLBACK (1094) +#define EM_SETOPTIONS (1101) +#define EM_SETPARAFORMAT (1095) +#define EM_SETPASSWORDCHAR (204) +#define EM_SETPUNCTUATION (1124) +#define EM_SETREADONLY (207) +#define EM_SETRECT (179) +#define EM_SETRECTNP (180) +#define EM_SETSEL (177) +#define EM_SETTABSTOPS (203) +#define EM_SETTARGETDEVICE (1096) +#define EM_SETWORDBREAKPROC (208) +#define EM_SETWORDBREAKPROCEX (1105) +#define EM_SETWORDWRAPMODE (1126) +#define EM_STREAMIN (1097) +#define EM_STREAMOUT (1098) +#define EM_UNDO (199) + +#define WM_NULL (0) +#define WM_CLEAR (771) +#define WM_COMMAND (273) +#define WM_COPY (769) +#define WM_CUT (768) +#define WM_GETTEXT (13) +#define WM_GETTEXTLENGTH (14) +#define WM_NOTIFY (78) +#define WM_PASTE (770) +#define WM_SETTEXT (12) +#define WM_UNDO (772) + +#define EN_CHANGE (768) +#define EN_KILLFOCUS (512) +#define EN_SETFOCUS (256) + +#define EC_LEFTMARGIN 1 +#define EC_RIGHTMARGIN 2 +#define EC_USEFONTINFO 0xffff + +#if PLAT_GTK +#define VK_DOWN GDK_Down +#define VK_UP GDK_Up +#define VK_LEFT GDK_Left +#define VK_RIGHT GDK_Right +#define VK_HOME GDK_Home +#define VK_END GDK_End +#define VK_PRIOR GDK_Page_Up +#define VK_NEXT GDK_Page_Down +#define VK_DELETE GDK_Delete +#define VK_INSERT GDK_Insert +#define VK_ESCAPE GDK_Escape +#define VK_BACK GDK_BackSpace +#define VK_TAB GDK_Tab +#define VK_RETURN GDK_Return +#define VK_ADD GDK_KP_Add +#define VK_SUBTRACT GDK_KP_Subtract +#endif + +#if PLAT_WX +#define VK_DOWN WXK_DOWN +#define VK_UP WXK_UP +#define VK_LEFT WXK_LEFT +#define VK_RIGHT WXK_RIGHT +#define VK_HOME WXK_HOME +#define VK_END WXK_END +#define VK_PRIOR WXK_PRIOR +#define VK_NEXT WXK_NEXT +#define VK_DELETE WXK_DELETE +#define VK_INSERT WXK_INSERT +#define VK_ESCAPE WXK_ESCAPE +#define VK_BACK WXK_BACK +#define VK_TAB WXK_TAB +#define VK_RETURN WXK_RETURN +#define VK_ADD WXK_ADD +#define VK_SUBTRACT WXK_SUBTRACT + +// Are these needed any more +#define LPSTR char * +#define LONG long +#define LPDWORD (long *) +#endif + +/* SELCHANGE structure */ +#define SEL_EMPTY (0) +#define SEL_TEXT (1) +#define SEL_OBJECT (2) +#define SEL_MULTICHAR (4) +#define SEL_MULTIOBJECT (8) + +/* FINDREPLACE structure */ +#define FR_MATCHCASE (0x4) +#define FR_WHOLEWORD (0x2) +#define FR_DOWN (0x1) + +#define SHIFT_PRESSED 1 +#define LEFT_CTRL_PRESSED 2 +#define LEFT_ALT_PRESSED 4 + +struct RECT { + LONG left; + LONG top; + LONG right; + LONG bottom; +}; + +struct CHARRANGE { + LONG cpMin; + LONG cpMax; +}; + +struct TEXTRANGE { + CHARRANGE chrg; + LPSTR lpstrText; +}; + +struct FINDTEXTEX { + CHARRANGE chrg; + LPSTR lpstrText; + CHARRANGE chrgText; +}; + +struct NMHDR { + WindowID hwndFrom; + UINT idFrom; + UINT code; +}; + +struct FORMATRANGE { + SurfaceID hdc; + SurfaceID hdcTarget; + RECT rc; + RECT rcPage; + CHARRANGE chrg; +}; + +#define MAKELONG(a, b) ((a) | ((b) << 16)) +#define LOWORD(x) (x & 0xffff) +#define HIWORD(x) (x >> 16) + +#endif -- cgit v1.2.3