Compare commits
1 Commits
wxPy_2_2_2
...
wxPython-0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cd630ed42e |
File diff suppressed because it is too large
Load Diff
@@ -1,56 +0,0 @@
|
||||
###############################################################################
|
||||
# Purpose: Makefile.in for STC contrib for Unix with autoconf
|
||||
# Created: 14.03.00
|
||||
# Author: VZ
|
||||
# Version: $Id$
|
||||
###############################################################################
|
||||
|
||||
top_srcdir = @top_srcdir@/..
|
||||
top_builddir = ../../..
|
||||
|
||||
scintilla_dir = $(top_srcdir)/contrib/src/stc/scintilla
|
||||
libsrc_dir = contrib/src/stc@PATH_IFS@$(scintilla_dir)/src
|
||||
|
||||
TARGET_LIBNAME=libstc
|
||||
|
||||
LIBVERSION_CURRENT=1
|
||||
LIBVERSION_REVISION=0
|
||||
LIBVERSION_AGE=0
|
||||
|
||||
HEADER_PATH=$(top_srcdir)/contrib/include/wx
|
||||
HEADER_SUBDIR=stc
|
||||
|
||||
HEADERS=stc.h
|
||||
|
||||
OBJECTS=PlatWX.o ScintillaWX.o stc.o \
|
||||
DocumentAccessor.o \
|
||||
LexCPP.o \
|
||||
LexHTML.o \
|
||||
LexLua.o \
|
||||
LexOthers.o \
|
||||
LexPerl.o \
|
||||
LexPython.o \
|
||||
LexSQL.o \
|
||||
LexVB.o \
|
||||
UniConversion.o \
|
||||
WindowAccessor.o \
|
||||
AutoComplete.o \
|
||||
CallTip.o \
|
||||
CellBuffer.o \
|
||||
ContractionState.o \
|
||||
Document.o \
|
||||
Editor.o \
|
||||
Indicator.o \
|
||||
KeyMap.o \
|
||||
KeyWords.o \
|
||||
LineMarker.o \
|
||||
PropSet.o \
|
||||
ScintillaBase.o \
|
||||
Style.o \
|
||||
ViewStyle.o \
|
||||
PosRegExp.o \
|
||||
|
||||
|
||||
APPEXTRADEFS=-D__WX__ -DSCI_LEXER -I$(scintilla_dir)/src -I$(scintilla_dir)/include -I$(top_srcdir)/contrib/include
|
||||
|
||||
include $(top_builddir)/src/makelib.env
|
||||
@@ -1,712 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// PlatWX.cxx - implementation of platform facilities on wxWindows
|
||||
// Copyright 1998-1999 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Robin Dunn <robin@aldunn.com>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include "Platform.h"
|
||||
#include "wx/stc/stc.h"
|
||||
|
||||
|
||||
#ifdef __WXGTK__
|
||||
#include <gtk/gtk.h>
|
||||
#endif
|
||||
|
||||
Point Point::FromLong(long lpoint) {
|
||||
return Point(lpoint & 0xFFFF, lpoint >> 16);
|
||||
}
|
||||
|
||||
wxRect wxRectFromPRectangle(PRectangle prc) {
|
||||
wxRect rc(prc.left, prc.top,
|
||||
prc.right-prc.left, prc.bottom-prc.top);
|
||||
return rc;
|
||||
}
|
||||
|
||||
PRectangle PRectangleFromwxRect(wxRect rc) {
|
||||
return PRectangle(rc.GetLeft(), rc.GetTop(), rc.GetRight(), rc.GetBottom());
|
||||
}
|
||||
|
||||
Colour::Colour(long lcol) {
|
||||
co.Set(lcol & 0xff, (lcol >> 8) & 0xff, (lcol >> 16) & 0xff);
|
||||
}
|
||||
|
||||
Colour::Colour(unsigned int red, unsigned int green, unsigned int blue) {
|
||||
co.Set(red, green, blue);
|
||||
}
|
||||
|
||||
bool Colour::operator==(const Colour &other) const {
|
||||
return co == other.co;
|
||||
}
|
||||
|
||||
long Colour::AsLong() const {
|
||||
return (((long)co.Blue() << 16) |
|
||||
((long)co.Green() << 8) |
|
||||
((long)co.Red()));
|
||||
}
|
||||
|
||||
unsigned int Colour::GetRed() {
|
||||
return co.Red();
|
||||
}
|
||||
|
||||
unsigned int Colour::GetGreen() {
|
||||
return co.Green();
|
||||
}
|
||||
|
||||
unsigned int Colour::GetBlue() {
|
||||
return co.Blue();
|
||||
}
|
||||
|
||||
Palette::Palette() {
|
||||
used = 0;
|
||||
allowRealization = false;
|
||||
}
|
||||
|
||||
Palette::~Palette() {
|
||||
Release();
|
||||
}
|
||||
|
||||
void Palette::Release() {
|
||||
used = 0;
|
||||
}
|
||||
|
||||
// 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 Palette::WantFind(ColourPair &cp, bool want) {
|
||||
if (want) {
|
||||
for (int i=0; i < used; i++) {
|
||||
if (entries[i].desired == cp.desired)
|
||||
return;
|
||||
}
|
||||
|
||||
if (used < numEntries) {
|
||||
entries[used].desired = cp.desired;
|
||||
entries[used].allocated = cp.desired;
|
||||
used++;
|
||||
}
|
||||
} else {
|
||||
for (int i=0; i < used; i++) {
|
||||
if (entries[i].desired == cp.desired) {
|
||||
cp.allocated = entries[i].allocated;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cp.allocated = cp.desired;
|
||||
}
|
||||
}
|
||||
|
||||
void Palette::Allocate(Window &) {
|
||||
if (allowRealization) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Font::Font() {
|
||||
id = 0;
|
||||
ascent = 0;
|
||||
}
|
||||
|
||||
Font::~Font() {
|
||||
}
|
||||
|
||||
void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic) {
|
||||
Release();
|
||||
id = new wxFont(size,
|
||||
wxDEFAULT,
|
||||
italic ? wxITALIC : wxNORMAL,
|
||||
bold ? wxBOLD : wxNORMAL,
|
||||
false,
|
||||
faceName,
|
||||
wxFONTENCODING_DEFAULT);
|
||||
}
|
||||
|
||||
|
||||
void Font::Release() {
|
||||
if (id)
|
||||
delete id;
|
||||
id = 0;
|
||||
}
|
||||
|
||||
|
||||
Surface::Surface() :
|
||||
hdc(0), hdcOwned(0), bitmap(0),
|
||||
x(0), y(0) {
|
||||
}
|
||||
|
||||
Surface::~Surface() {
|
||||
Release();
|
||||
}
|
||||
|
||||
void Surface::Release() {
|
||||
if (bitmap) {
|
||||
((wxMemoryDC*)hdc)->SelectObject(wxNullBitmap);
|
||||
delete bitmap;
|
||||
bitmap = 0;
|
||||
}
|
||||
if (hdcOwned) {
|
||||
delete hdc;
|
||||
hdc = 0;
|
||||
hdcOwned = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Surface::Initialised() {
|
||||
return hdc != 0;
|
||||
}
|
||||
|
||||
void Surface::Init() {
|
||||
Release();
|
||||
hdc = new wxMemoryDC();
|
||||
hdcOwned = true;
|
||||
// **** ::SetTextAlign(hdc, TA_BASELINE);
|
||||
}
|
||||
|
||||
void Surface::Init(SurfaceID hdc_) {
|
||||
Release();
|
||||
hdc = hdc_;
|
||||
// **** ::SetTextAlign(hdc, TA_BASELINE);
|
||||
}
|
||||
|
||||
void Surface::InitPixMap(int width, int height, Surface *surface_) {
|
||||
Release();
|
||||
hdc = new wxMemoryDC(surface_->hdc);
|
||||
hdcOwned = true;
|
||||
bitmap = new wxBitmap(width, height);
|
||||
((wxMemoryDC*)hdc)->SelectObject(*bitmap);
|
||||
// **** ::SetTextAlign(hdc, TA_BASELINE);
|
||||
}
|
||||
|
||||
void Surface::PenColour(Colour fore) {
|
||||
hdc->SetPen(wxPen(fore.co, 1, wxSOLID));
|
||||
}
|
||||
|
||||
void Surface::BrushColor(Colour back) {
|
||||
hdc->SetBrush(wxBrush(back.co, wxSOLID));
|
||||
}
|
||||
|
||||
void Surface::SetFont(Font &font_) {
|
||||
if (font_.GetID()) {
|
||||
hdc->SetFont(*font_.GetID());
|
||||
}
|
||||
}
|
||||
|
||||
int Surface::LogPixelsY() {
|
||||
return hdc->GetPPI().y;
|
||||
}
|
||||
|
||||
|
||||
int Surface::DeviceHeightFont(int points) {
|
||||
return points * LogPixelsY() / 72;
|
||||
}
|
||||
|
||||
|
||||
void Surface::MoveTo(int x_, int y_) {
|
||||
x = x_;
|
||||
y = y_;
|
||||
}
|
||||
|
||||
void Surface::LineTo(int x_, int y_) {
|
||||
hdc->DrawLine(x,y, x_,y_);
|
||||
x = x_;
|
||||
y = y_;
|
||||
}
|
||||
|
||||
void Surface::Polygon(Point *pts, int npts, Colour fore,
|
||||
Colour back) {
|
||||
PenColour(fore);
|
||||
BrushColor(back);
|
||||
hdc->DrawPolygon(npts, (wxPoint*)pts);
|
||||
}
|
||||
|
||||
void Surface::RectangleDraw(PRectangle rc, Colour fore, Colour back) {
|
||||
PenColour(fore);
|
||||
BrushColor(back);
|
||||
hdc->DrawRectangle(wxRectFromPRectangle(rc));
|
||||
}
|
||||
|
||||
void Surface::FillRectangle(PRectangle rc, Colour back) {
|
||||
BrushColor(back);
|
||||
hdc->SetPen(*wxTRANSPARENT_PEN);
|
||||
hdc->DrawRectangle(wxRectFromPRectangle(rc));
|
||||
}
|
||||
|
||||
void Surface::FillRectangle(PRectangle rc, Surface &surfacePattern) {
|
||||
wxBrush br;
|
||||
if (surfacePattern.bitmap)
|
||||
br = wxBrush(*surfacePattern.bitmap);
|
||||
else // Something is wrong so display in red
|
||||
br = wxBrush(*wxRED, wxSOLID);
|
||||
hdc->SetPen(*wxTRANSPARENT_PEN);
|
||||
hdc->SetBrush(br);
|
||||
hdc->DrawRectangle(wxRectFromPRectangle(rc));
|
||||
}
|
||||
|
||||
void Surface::RoundedRectangle(PRectangle rc, Colour fore, Colour back) {
|
||||
PenColour(fore);
|
||||
BrushColor(back);
|
||||
hdc->DrawRoundedRectangle(wxRectFromPRectangle(rc), 4);
|
||||
}
|
||||
|
||||
void Surface::Ellipse(PRectangle rc, Colour fore, Colour back) {
|
||||
PenColour(fore);
|
||||
BrushColor(back);
|
||||
hdc->DrawEllipse(wxRectFromPRectangle(rc));
|
||||
}
|
||||
|
||||
void Surface::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
|
||||
wxRect r = wxRectFromPRectangle(rc);
|
||||
hdc->Blit(r.x, r.y, r.width, r.height,
|
||||
surfaceSource.hdc, from.x, from.y, wxCOPY);
|
||||
}
|
||||
|
||||
void Surface::DrawText(PRectangle rc, Font &font, int ybase,
|
||||
const char *s, int len, Colour fore, Colour back) {
|
||||
SetFont(font);
|
||||
hdc->SetTextForeground(fore.co);
|
||||
hdc->SetTextBackground(back.co);
|
||||
FillRectangle(rc, back);
|
||||
|
||||
// ybase is where the baseline should be, but wxWin uses the upper left
|
||||
// corner, so I need to calculate the real position for the text...
|
||||
hdc->DrawText(wxString(s, len), rc.left, ybase - font.ascent);
|
||||
}
|
||||
|
||||
void Surface::DrawTextClipped(PRectangle rc, Font &font, int ybase, const char *s, int len, Colour fore, Colour back) {
|
||||
SetFont(font);
|
||||
hdc->SetTextForeground(fore.co);
|
||||
hdc->SetTextBackground(back.co);
|
||||
FillRectangle(rc, back);
|
||||
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
|
||||
|
||||
// see comments above
|
||||
hdc->DrawText(wxString(s, len), rc.left, ybase - font.ascent);
|
||||
hdc->DestroyClippingRegion();
|
||||
}
|
||||
|
||||
int Surface::WidthText(Font &font, const char *s, int len) {
|
||||
SetFont(font);
|
||||
int w;
|
||||
int h;
|
||||
hdc->GetTextExtent(wxString(s, len), &w, &h);
|
||||
return w;
|
||||
}
|
||||
|
||||
void Surface::MeasureWidths(Font &font, const char *s, int len, int *positions) {
|
||||
SetFont(font);
|
||||
int totalWidth = 0;
|
||||
for (int i=0; i<len; i++) {
|
||||
int w;
|
||||
int h;
|
||||
hdc->GetTextExtent(s[i], &w, &h);
|
||||
totalWidth += w;
|
||||
positions[i] = totalWidth;
|
||||
}
|
||||
}
|
||||
|
||||
int Surface::WidthChar(Font &font, char ch) {
|
||||
SetFont(font);
|
||||
int w;
|
||||
int h;
|
||||
hdc->GetTextExtent(ch, &w, &h);
|
||||
return w;
|
||||
}
|
||||
|
||||
#define EXTENT_TEST " `~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
int Surface::Ascent(Font &font) {
|
||||
SetFont(font);
|
||||
int w, h, d, e;
|
||||
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
|
||||
font.ascent = h - d;
|
||||
return font.ascent;
|
||||
}
|
||||
|
||||
int Surface::Descent(Font &font) {
|
||||
SetFont(font);
|
||||
int w, h, d, e;
|
||||
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
|
||||
return d;
|
||||
}
|
||||
|
||||
int Surface::InternalLeading(Font &font) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Surface::ExternalLeading(Font &font) {
|
||||
SetFont(font);
|
||||
int w, h, d, e;
|
||||
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
|
||||
return e;
|
||||
}
|
||||
|
||||
int Surface::Height(Font &font) {
|
||||
SetFont(font);
|
||||
return hdc->GetCharHeight();
|
||||
}
|
||||
|
||||
int Surface::AverageCharWidth(Font &font) {
|
||||
SetFont(font);
|
||||
return hdc->GetCharWidth();
|
||||
}
|
||||
|
||||
int Surface::SetPalette(Palette *pal, bool inBackGround) {
|
||||
return 0; // **** figure out what to do with palettes...
|
||||
}
|
||||
|
||||
void Surface::SetClip(PRectangle rc) {
|
||||
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
|
||||
}
|
||||
|
||||
void Surface::FlushCachedState() {
|
||||
}
|
||||
|
||||
Window::~Window() {
|
||||
}
|
||||
|
||||
void Window::Destroy() {
|
||||
if (id)
|
||||
id->Destroy();
|
||||
id = 0;
|
||||
}
|
||||
|
||||
bool Window::HasFocus() {
|
||||
return wxWindow::FindFocus() == id;
|
||||
}
|
||||
|
||||
PRectangle Window::GetPosition() {
|
||||
wxRect rc(id->GetPosition(), id->GetSize());
|
||||
return PRectangleFromwxRect(rc);
|
||||
}
|
||||
|
||||
void Window::SetPosition(PRectangle rc) {
|
||||
wxRect r = wxRectFromPRectangle(rc);
|
||||
id->SetSize(r);
|
||||
}
|
||||
|
||||
void Window::SetPositionRelative(PRectangle rc, Window) {
|
||||
SetPosition(rc); // ????
|
||||
}
|
||||
|
||||
PRectangle Window::GetClientPosition() {
|
||||
wxSize sz = id->GetClientSize();
|
||||
return PRectangle(0, 0, sz.x, sz.y);
|
||||
}
|
||||
|
||||
void Window::Show(bool show) {
|
||||
id->Show(show);
|
||||
}
|
||||
|
||||
void Window::InvalidateAll() {
|
||||
id->Refresh(false);
|
||||
}
|
||||
|
||||
void Window::InvalidateRectangle(PRectangle rc) {
|
||||
wxRect r = wxRectFromPRectangle(rc);
|
||||
id->Refresh(false, &r);
|
||||
}
|
||||
|
||||
void Window::SetFont(Font &font) {
|
||||
id->SetFont(*font.GetID());
|
||||
}
|
||||
|
||||
void Window::SetCursor(Cursor curs) {
|
||||
int cursorId;
|
||||
|
||||
switch (curs) {
|
||||
case cursorText:
|
||||
cursorId = wxCURSOR_IBEAM;
|
||||
break;
|
||||
case cursorArrow:
|
||||
cursorId = wxCURSOR_ARROW;
|
||||
break;
|
||||
case cursorUp:
|
||||
cursorId = wxCURSOR_ARROW; // ** no up arrow... wxCURSOR_UPARROW;
|
||||
break;
|
||||
case cursorWait:
|
||||
cursorId = wxCURSOR_WAIT;
|
||||
break;
|
||||
case cursorHoriz:
|
||||
cursorId = wxCURSOR_SIZEWE;
|
||||
break;
|
||||
case cursorVert:
|
||||
cursorId = wxCURSOR_SIZENS;
|
||||
break;
|
||||
case cursorReverseArrow:
|
||||
cursorId = wxCURSOR_POINT_RIGHT;
|
||||
break;
|
||||
default:
|
||||
cursorId = wxCURSOR_ARROW;
|
||||
break;
|
||||
}
|
||||
|
||||
id->SetCursor(wxCursor(cursorId));
|
||||
}
|
||||
|
||||
|
||||
void Window::SetTitle(const char *s) {
|
||||
id->SetTitle(s);
|
||||
}
|
||||
|
||||
|
||||
class wxSTCListBox : public wxListBox {
|
||||
public:
|
||||
wxSTCListBox(wxWindow* parent, wxWindowID id)
|
||||
: wxListBox(parent, id, wxDefaultPosition, wxDefaultSize,
|
||||
0, NULL, wxLB_SINGLE | wxLB_SORT | wxSIMPLE_BORDER)
|
||||
{}
|
||||
|
||||
void OnFocus(wxFocusEvent& event) {
|
||||
GetParent()->SetFocus();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
#ifdef __WXGTK__
|
||||
void DoSetFirstItem(int n);
|
||||
#endif
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(wxSTCListBox, wxListBox)
|
||||
EVT_SET_FOCUS(wxSTCListBox::OnFocus)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __WXGTK__
|
||||
// This can be removed after 2.2.2 I think
|
||||
void wxSTCListBox::DoSetFirstItem( int n )
|
||||
{
|
||||
wxCHECK_RET( m_list, wxT("invalid listbox") );
|
||||
|
||||
if (gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_GRAB (m_list))
|
||||
return;
|
||||
|
||||
// terribly efficient
|
||||
const gchar *vadjustment_key = "gtk-vadjustment";
|
||||
guint vadjustment_key_id = g_quark_from_static_string (vadjustment_key);
|
||||
|
||||
GtkAdjustment *adjustment =
|
||||
(GtkAdjustment*) gtk_object_get_data_by_id (GTK_OBJECT (m_list), vadjustment_key_id);
|
||||
wxCHECK_RET( adjustment, wxT("invalid listbox code") );
|
||||
|
||||
GList *target = g_list_nth( m_list->children, n );
|
||||
wxCHECK_RET( target, wxT("invalid listbox index") );
|
||||
|
||||
GtkWidget *item = GTK_WIDGET(target->data);
|
||||
wxCHECK_RET( item, wxT("invalid listbox code") );
|
||||
|
||||
// find the last item before this one which is already realized
|
||||
size_t nItemsBefore;
|
||||
for ( nItemsBefore = 0; item && (item->allocation.y == -1); nItemsBefore++ )
|
||||
{
|
||||
target = target->prev;
|
||||
if ( !target )
|
||||
{
|
||||
// nothing we can do if there are no allocated items yet
|
||||
return;
|
||||
}
|
||||
|
||||
item = GTK_WIDGET(target->data);
|
||||
}
|
||||
|
||||
gtk_adjustment_set_value(adjustment,
|
||||
item->allocation.y +
|
||||
nItemsBefore*item->allocation.height);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
ListBox::ListBox() {
|
||||
}
|
||||
|
||||
ListBox::~ListBox() {
|
||||
}
|
||||
|
||||
void ListBox::Create(Window &parent, int ctrlID) {
|
||||
id = new wxSTCListBox(parent.id, ctrlID);
|
||||
// id = new wxListBox(parent.id, ctrlID, wxDefaultPosition, wxDefaultSize,
|
||||
// 0, NULL, wxLB_SINGLE | wxLB_SORT | wxSIMPLE_BORDER);
|
||||
}
|
||||
|
||||
PRectangle ListBox::GetDesiredRect() {
|
||||
wxSize sz = ((wxListBox*)id)->GetBestSize();
|
||||
PRectangle rc;
|
||||
rc.top = 0;
|
||||
rc.left = 0;
|
||||
if (sz.x > 150) // TODO: A better way to determine these max sizes
|
||||
sz.x = 150;
|
||||
if (sz.y > 100)
|
||||
sz.y = 100;
|
||||
rc.right = sz.x;
|
||||
rc.bottom = sz.y;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
void ListBox::SetAverageCharWidth(int width) {
|
||||
aveCharWidth = width;
|
||||
}
|
||||
|
||||
void ListBox::SetFont(Font &font) {
|
||||
Window::SetFont(font);
|
||||
}
|
||||
|
||||
void ListBox::Clear() {
|
||||
((wxListBox*)id)->Clear();
|
||||
}
|
||||
|
||||
void ListBox::Append(char *s) {
|
||||
((wxListBox*)id)->Append(s);
|
||||
}
|
||||
|
||||
int ListBox::Length() {
|
||||
return ((wxListBox*)id)->Number();
|
||||
}
|
||||
|
||||
void ListBox::Select(int n) {
|
||||
((wxListBox*)id)->SetSelection(n);
|
||||
#ifdef __WXGTK__
|
||||
if (n > 4)
|
||||
n = n - 4;
|
||||
else
|
||||
n = 1;
|
||||
((wxListBox*)id)->SetFirstItem(n);
|
||||
#endif
|
||||
}
|
||||
|
||||
int ListBox::GetSelection() {
|
||||
return ((wxListBox*)id)->GetSelection();
|
||||
}
|
||||
|
||||
int ListBox::Find(const char *prefix) {
|
||||
if (prefix) {
|
||||
for (int x=0; x < ((wxListBox*)id)->Number(); x++) {
|
||||
wxString text = ((wxListBox*)id)->GetString(x);
|
||||
if (text.StartsWith(prefix))
|
||||
return x;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ListBox::GetValue(int n, char *value, int len) {
|
||||
wxString text = ((wxListBox*)id)->GetString(n);
|
||||
strncpy(value, text.c_str(), len);
|
||||
value[len-1] = '\0';
|
||||
}
|
||||
|
||||
void ListBox::Sort() {
|
||||
// wxWindows keeps sorted so no need to sort
|
||||
}
|
||||
|
||||
|
||||
Menu::Menu() : id(0) {
|
||||
}
|
||||
|
||||
void Menu::CreatePopUp() {
|
||||
Destroy();
|
||||
id = new wxMenu();
|
||||
}
|
||||
|
||||
void Menu::Destroy() {
|
||||
if (id)
|
||||
delete id;
|
||||
id = 0;
|
||||
}
|
||||
|
||||
void Menu::Show(Point pt, Window &w) {
|
||||
w.GetID()->PopupMenu(id, pt.x - 4, pt.y);
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
||||
Colour Platform::Chrome() {
|
||||
wxColour c;
|
||||
c = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
|
||||
return Colour(c.Red(), c.Green(), c.Blue());
|
||||
}
|
||||
|
||||
Colour Platform::ChromeHighlight() {
|
||||
wxColour c;
|
||||
c = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DHIGHLIGHT);
|
||||
return Colour(c.Red(), c.Green(), c.Blue());
|
||||
}
|
||||
|
||||
const char *Platform::DefaultFont() {
|
||||
return wxNORMAL_FONT->GetFaceName();
|
||||
}
|
||||
|
||||
int Platform::DefaultFontSize() {
|
||||
return 8;
|
||||
}
|
||||
|
||||
unsigned int Platform::DoubleClickTime() {
|
||||
return 500; // **** ::GetDoubleClickTime();
|
||||
}
|
||||
|
||||
void Platform::DebugDisplay(const char *s) {
|
||||
wxLogDebug(s);
|
||||
}
|
||||
|
||||
bool Platform::IsKeyDown(int key) {
|
||||
return false; // I don't think we'll need this.
|
||||
}
|
||||
|
||||
long Platform::SendScintilla(WindowID w,
|
||||
unsigned int msg,
|
||||
unsigned long wParam,
|
||||
long lParam) {
|
||||
|
||||
wxStyledTextCtrl* stc = (wxStyledTextCtrl*)w;
|
||||
return stc->SendMsg(msg, wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
// These are utility functions not really tied to a platform
|
||||
|
||||
int Platform::Minimum(int a, int b) {
|
||||
if (a < b)
|
||||
return a;
|
||||
else
|
||||
return b;
|
||||
}
|
||||
|
||||
int Platform::Maximum(int a, int b) {
|
||||
if (a > b)
|
||||
return a;
|
||||
else
|
||||
return b;
|
||||
}
|
||||
|
||||
#define TRACE
|
||||
|
||||
void Platform::DebugPrintf(const char *format, ...) {
|
||||
#ifdef TRACE
|
||||
char buffer[2000];
|
||||
va_list pArguments;
|
||||
va_start(pArguments, format);
|
||||
vsprintf(buffer,format,pArguments);
|
||||
va_end(pArguments);
|
||||
Platform::DebugDisplay(buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
int Platform::Clamp(int val, int minVal, int maxVal) {
|
||||
if (val > maxVal)
|
||||
val = maxVal;
|
||||
if (val < minVal)
|
||||
val = minVal;
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
This contrib is the wxStyledTextCtrl, which is a wrapper around the
|
||||
Scintilla edit control. (See www.scintilla.org)
|
||||
|
||||
There is still VERY MUCH to be done, most notable of which is a more
|
||||
advanced sample that exercises more of the code. (I havn't tested
|
||||
AutoComplete or CallTips, or most of the event types at all yet.) And
|
||||
also documentation, adding wrappers for some new scintilla
|
||||
functionality, building and testing on wxGTK, etc. Be patient, it all
|
||||
will get there soon.
|
||||
|
||||
|
||||
|
||||
Let me describe a bit about the architecture I am implementing...
|
||||
Obviously there is the Platform layer which implements the varioius
|
||||
platform classes by using wxWindows classes and filling in where
|
||||
needed. Then there is a ScintillaWX class that is derived from
|
||||
ScintillaBase and implements the necessary virtual methods that
|
||||
Scintilla needs to fully funciton. This class however is not meant to
|
||||
ever be used directly by wx programmers. I call it one end of the
|
||||
bridge between the wx and Scintilla worlds. The other end of the
|
||||
bridge is a class called wxStyledTextCtrl that looks, feels and acts
|
||||
like other classes in wxWindows. Here is a diagram:
|
||||
|
||||
|
||||
+------------------+ +-------------------+
|
||||
| wxStyledTextCtrl |--bridge--| ScintillaWX |
|
||||
+------------------+ +-------------------+
|
||||
| ScintillaBase |
|
||||
+-------------------+
|
||||
| Editor |
|
||||
+-------------------+
|
||||
| PlatWX |
|
||||
+-------------------+
|
||||
|
||||
|
||||
wxStyledTextCtrl derives from wxControl so it has a window that can be
|
||||
drawn upon. When a wxStyledTextCtrl is constructed it constructs a
|
||||
ScintillaWX for itself and passes itself to the scintilla object to be
|
||||
set as the wMain and wDraw attributes. All method calls on the STC
|
||||
are sent over the bridge in the form of calls to ScintiallWX::WndProc.
|
||||
All notifications are sent back over the bridge and turned into
|
||||
wxEvents.
|
||||
|
||||
|
||||
Robin
|
||||
|
||||
|
||||
@@ -1,515 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Name: ScintillaWX.cxx
|
||||
// Purpose: A wxWindows implementation of Scintilla. A class derived
|
||||
// from ScintillaBase that uses the "wx platform" defined in
|
||||
// PlatformWX.cxx This class is one end of a bridge between
|
||||
// the wx world and the Scintilla world. It needs a peer
|
||||
// object of type wxStyledTextCtrl to function.
|
||||
//
|
||||
// Author: Robin Dunn
|
||||
//
|
||||
// Created: 13-Jan-2000
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 by Total Control Software
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include "ScintillaWX.h"
|
||||
#include "wx/stc/stc.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
const int H_SCROLL_MAX = 2000;
|
||||
const int H_SCROLL_STEP = 20;
|
||||
const int H_SCROLL_PAGE = 200;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper classes
|
||||
|
||||
class wxSTCTimer : public wxTimer {
|
||||
public:
|
||||
wxSTCTimer(ScintillaWX* swx) {
|
||||
this->swx = swx;
|
||||
}
|
||||
|
||||
void Notify() {
|
||||
swx->DoTick();
|
||||
}
|
||||
|
||||
private:
|
||||
ScintillaWX* swx;
|
||||
};
|
||||
|
||||
|
||||
|
||||
bool wxSTCDropTarget::OnDropText(wxCoord x, wxCoord y, const wxString& data) {
|
||||
return swx->DoDropText(x, y, data);
|
||||
}
|
||||
|
||||
wxDragResult wxSTCDropTarget::OnEnter(wxCoord x, wxCoord y, wxDragResult def) {
|
||||
return swx->DoDragEnter(x, y, def);
|
||||
}
|
||||
|
||||
wxDragResult wxSTCDropTarget::OnDragOver(wxCoord x, wxCoord y, wxDragResult def) {
|
||||
return swx->DoDragOver(x, y, def);
|
||||
}
|
||||
|
||||
void wxSTCDropTarget::OnLeave() {
|
||||
swx->DoDragLeave();
|
||||
}
|
||||
|
||||
|
||||
class wxSTCCallTip : public wxWindow {
|
||||
public:
|
||||
wxSTCCallTip(wxWindow* parent, int ID, CallTip* ct)
|
||||
: wxWindow(parent, ID)
|
||||
{
|
||||
m_ct = ct;
|
||||
}
|
||||
|
||||
void OnPaint(wxPaintEvent& evt) {
|
||||
wxPaintDC dc(this);
|
||||
Surface surfaceWindow;
|
||||
surfaceWindow.Init(&dc);
|
||||
m_ct->PaintCT(&surfaceWindow);
|
||||
surfaceWindow.Release();
|
||||
}
|
||||
|
||||
CallTip* m_ct;
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(wxSTCCallTip, wxWindow)
|
||||
EVT_PAINT(wxSTCCallTip::OnPaint)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Constructor/Destructor
|
||||
|
||||
|
||||
ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) {
|
||||
capturedMouse = false;
|
||||
wMain = win;
|
||||
wDraw = win;
|
||||
stc = win;
|
||||
Initialise();
|
||||
}
|
||||
|
||||
|
||||
ScintillaWX::~ScintillaWX() {
|
||||
SetTicking(false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// base class virtuals
|
||||
|
||||
|
||||
void ScintillaWX::Initialise() {
|
||||
//ScintillaBase::Initialise();
|
||||
dropTarget = new wxSTCDropTarget;
|
||||
dropTarget->SetScintilla(this);
|
||||
stc->SetDropTarget(dropTarget);
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::Finalise() {
|
||||
ScintillaBase::Finalise();
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::StartDrag() {
|
||||
wxDropSource source(wMain.GetID());
|
||||
wxTextDataObject data(dragChars);
|
||||
wxDragResult result;
|
||||
|
||||
source.SetData(data);
|
||||
result = source.DoDragDrop(TRUE);
|
||||
if (result == wxDragMove && dropWentOutside)
|
||||
ClearSelection();
|
||||
inDragDrop = FALSE;
|
||||
SetDragPosition(invalidPosition);
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::SetTicking(bool on) {
|
||||
wxSTCTimer* steTimer;
|
||||
if (timer.ticking != on) {
|
||||
timer.ticking = on;
|
||||
if (timer.ticking) {
|
||||
steTimer = new wxSTCTimer(this);
|
||||
steTimer->Start(timer.tickSize);
|
||||
timer.tickerID = (int)steTimer;
|
||||
} else {
|
||||
steTimer = (wxSTCTimer*)timer.tickerID;
|
||||
steTimer->Stop();
|
||||
delete steTimer;
|
||||
timer.tickerID = 0;
|
||||
}
|
||||
}
|
||||
timer.ticksToWait = caret.period;
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::SetMouseCapture(bool on) {
|
||||
if (on && !capturedMouse)
|
||||
wMain.GetID()->CaptureMouse();
|
||||
else if (!on && capturedMouse)
|
||||
wMain.GetID()->ReleaseMouse();
|
||||
capturedMouse = on;
|
||||
}
|
||||
|
||||
|
||||
bool ScintillaWX::HaveMouseCapture() {
|
||||
return capturedMouse;
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::ScrollText(int linesToMove) {
|
||||
int dy = vs.lineHeight * (linesToMove);
|
||||
// TODO: calculate the rectangle to refreshed...
|
||||
wMain.GetID()->ScrollWindow(0, dy);
|
||||
}
|
||||
|
||||
void ScintillaWX::SetVerticalScrollPos() {
|
||||
wMain.GetID()->SetScrollPos(wxVERTICAL, topLine);
|
||||
}
|
||||
|
||||
void ScintillaWX::SetHorizontalScrollPos() {
|
||||
wMain.GetID()->SetScrollPos(wxHORIZONTAL, xOffset);
|
||||
}
|
||||
|
||||
|
||||
bool ScintillaWX::ModifyScrollBars(int nMax, int nPage) {
|
||||
bool modified = false;
|
||||
int sbMax = wMain.GetID()->GetScrollRange(wxVERTICAL);
|
||||
int sbThumb = wMain.GetID()->GetScrollThumb(wxVERTICAL);
|
||||
int sbPos = wMain.GetID()->GetScrollPos(wxVERTICAL);
|
||||
|
||||
|
||||
if (sbMax != nMax || sbThumb != nPage) {
|
||||
wMain.GetID()->SetScrollbar(wxVERTICAL, sbPos, nPage, nMax);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
sbMax = wMain.GetID()->GetScrollRange(wxHORIZONTAL);
|
||||
sbThumb = wMain.GetID()->GetScrollThumb(wxHORIZONTAL);
|
||||
if ((sbMax != H_SCROLL_MAX) || (sbThumb != H_SCROLL_STEP)) {
|
||||
wMain.GetID()->SetScrollbar(wxHORIZONTAL, 0, H_SCROLL_STEP, H_SCROLL_MAX);
|
||||
modified = true;
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::NotifyChange() {
|
||||
stc->NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::NotifyParent(SCNotification scn) {
|
||||
stc->NotifyParent(&scn);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ScintillaWX::Copy() {
|
||||
if (currentPos != anchor) {
|
||||
char* text = CopySelectionRange();
|
||||
wxTheClipboard->Open();
|
||||
wxTheClipboard->SetData(new wxTextDataObject(text));
|
||||
wxTheClipboard->Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::Paste() {
|
||||
pdoc->BeginUndoAction();
|
||||
ClearSelection();
|
||||
|
||||
wxTextDataObject data;
|
||||
bool canPaste;
|
||||
|
||||
wxTheClipboard->Open();
|
||||
canPaste = wxTheClipboard->GetData(data);
|
||||
wxTheClipboard->Close();
|
||||
if (canPaste) {
|
||||
wxString str = data.GetText();
|
||||
int len = str.Length();
|
||||
pdoc->InsertString(currentPos, str.c_str(), len);
|
||||
SetEmptySelection(currentPos + len);
|
||||
}
|
||||
|
||||
pdoc->EndUndoAction();
|
||||
NotifyChange();
|
||||
Redraw();
|
||||
}
|
||||
|
||||
|
||||
bool ScintillaWX::CanPaste() {
|
||||
wxTextDataObject data;
|
||||
bool canPaste;
|
||||
|
||||
wxTheClipboard->Open();
|
||||
canPaste = wxTheClipboard->GetData(data);
|
||||
wxTheClipboard->Close();
|
||||
|
||||
return canPaste;
|
||||
}
|
||||
|
||||
void ScintillaWX::CreateCallTipWindow(PRectangle) {
|
||||
ct.wCallTip = new wxSTCCallTip(wDraw.GetID(), -1, &ct);
|
||||
ct.wDraw = ct.wCallTip;
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) {
|
||||
if (!label[0])
|
||||
popup.GetID()->AppendSeparator();
|
||||
else
|
||||
popup.GetID()->Append(cmd, label);
|
||||
|
||||
if (!enabled)
|
||||
popup.GetID()->Enable(cmd, enabled);
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::ClaimSelection() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
long ScintillaWX::DefWndProc(unsigned int /*iMessage*/, unsigned long /*wParam*/, long /*lParam*/) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
long ScintillaWX::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) {
|
||||
// switch (iMessage) {
|
||||
// case EM_CANPASTE:
|
||||
// return CanPaste();
|
||||
// default:
|
||||
return ScintillaBase::WndProc(iMessage, wParam, lParam);
|
||||
// }
|
||||
// return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Event delegates
|
||||
|
||||
void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) {
|
||||
|
||||
paintState = painting;
|
||||
Surface surfaceWindow;
|
||||
surfaceWindow.Init(dc);
|
||||
PRectangle rcPaint = PRectangleFromwxRect(rect);
|
||||
dc->BeginDrawing();
|
||||
Paint(&surfaceWindow, rcPaint);
|
||||
dc->EndDrawing();
|
||||
surfaceWindow.Release();
|
||||
if (paintState == paintAbandoned) {
|
||||
// Painting area was insufficient to cover new styling or brace highlight positions
|
||||
FullPaint();
|
||||
}
|
||||
paintState = notPainting;
|
||||
#ifdef __WXGTK__
|
||||
// On wxGTK the editor window paints can overwrite the listbox...
|
||||
if (ac.Active())
|
||||
((wxWindow*)ac.lb.GetID())->Refresh(TRUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::DoHScroll(int type, int pos) {
|
||||
int xPos = xOffset;
|
||||
switch (type) {
|
||||
case wxEVT_SCROLLWIN_LINEUP:
|
||||
xPos -= H_SCROLL_STEP;
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_LINEDOWN:
|
||||
xPos += H_SCROLL_STEP;
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_PAGEUP:
|
||||
xPos -= H_SCROLL_PAGE;
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_PAGEDOWN:
|
||||
xPos += H_SCROLL_PAGE;
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_TOP:
|
||||
xPos = 0;
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_BOTTOM:
|
||||
xPos = H_SCROLL_MAX;
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_THUMBTRACK:
|
||||
xPos = pos;
|
||||
break;
|
||||
}
|
||||
HorizontalScrollTo(xPos);
|
||||
}
|
||||
|
||||
void ScintillaWX::DoVScroll(int type, int pos) {
|
||||
int topLineNew = topLine;
|
||||
switch (type) {
|
||||
case wxEVT_SCROLLWIN_LINEUP:
|
||||
topLineNew -= 1;
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_LINEDOWN:
|
||||
topLineNew += 1;
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_PAGEUP:
|
||||
topLineNew -= LinesToScroll();
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_PAGEDOWN:
|
||||
topLineNew += LinesToScroll();
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_TOP:
|
||||
topLineNew = 0;
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_BOTTOM:
|
||||
topLineNew = MaxScrollPos();
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_THUMBTRACK:
|
||||
topLineNew = pos;
|
||||
break;
|
||||
}
|
||||
ScrollTo(topLineNew);
|
||||
}
|
||||
|
||||
void ScintillaWX::DoSize(int width, int height) {
|
||||
PRectangle rcClient(0,0,width,height);
|
||||
SetScrollBarsTo(rcClient);
|
||||
DropGraphics();
|
||||
}
|
||||
|
||||
void ScintillaWX::DoLoseFocus(){
|
||||
DropCaret();
|
||||
}
|
||||
|
||||
void ScintillaWX::DoGainFocus(){
|
||||
ShowCaretAtCurrentPosition();
|
||||
}
|
||||
|
||||
void ScintillaWX::DoSysColourChange() {
|
||||
InvalidateStyleData();
|
||||
}
|
||||
|
||||
void ScintillaWX::DoButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) {
|
||||
ButtonDown(pt, curTime, shift, ctrl, alt);
|
||||
}
|
||||
|
||||
void ScintillaWX::DoButtonUp(Point pt, unsigned int curTime, bool ctrl) {
|
||||
ButtonUp(pt, curTime, ctrl);
|
||||
}
|
||||
|
||||
void ScintillaWX::DoButtonMove(Point pt) {
|
||||
ButtonMove(pt);
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::DoAddChar(char ch) {
|
||||
//bool acActiveBeforeCharAdded = ac.Active();
|
||||
AddChar(ch);
|
||||
//if (acActiveBeforeCharAdded)
|
||||
// AutoCompleteChanged(ch);
|
||||
}
|
||||
|
||||
int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt) {
|
||||
switch (key) {
|
||||
case WXK_DOWN: key = SCK_DOWN; break;
|
||||
case WXK_UP: key = SCK_UP; break;
|
||||
case WXK_LEFT: key = SCK_LEFT; break;
|
||||
case WXK_RIGHT: key = SCK_RIGHT; break;
|
||||
case WXK_HOME: key = SCK_HOME; break;
|
||||
case WXK_END: key = SCK_END; break;
|
||||
case WXK_PRIOR: key = SCK_PRIOR; break;
|
||||
case WXK_NEXT: key = SCK_NEXT; break;
|
||||
case WXK_DELETE: key = SCK_DELETE; break;
|
||||
case WXK_INSERT: key = SCK_INSERT; break;
|
||||
case WXK_ESCAPE: key = SCK_ESCAPE; break;
|
||||
case WXK_BACK: key = SCK_BACK; break;
|
||||
case WXK_TAB: key = SCK_TAB; break;
|
||||
case WXK_RETURN: key = SCK_RETURN; break;
|
||||
case WXK_ADD: key = SCK_ADD; break;
|
||||
case WXK_SUBTRACT: key = SCK_SUBTRACT; break;
|
||||
case WXK_DIVIDE: key = SCK_DIVIDE; break;
|
||||
case WXK_CONTROL: key = 0; break;
|
||||
case WXK_ALT: key = 0; break;
|
||||
case WXK_SHIFT: key = 0; break;
|
||||
}
|
||||
|
||||
return KeyDown(key, shift, ctrl, alt);
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::DoCommand(int ID) {
|
||||
Command(ID);
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::DoContextMenu(Point pt) {
|
||||
ContextMenu(pt);
|
||||
}
|
||||
|
||||
void ScintillaWX::DoOnListBox() {
|
||||
AutoCompleteCompleted();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
bool ScintillaWX::DoDropText(long x, long y, const wxString& data) {
|
||||
SetDragPosition(invalidPosition);
|
||||
int movePos = PositionFromLocation(Point(x,y));
|
||||
DropAt(movePos, data, dragResult == wxDragMove, FALSE); // TODO: rectangular?
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
wxDragResult ScintillaWX::DoDragEnter(wxCoord x, wxCoord y, wxDragResult def) {
|
||||
return def;
|
||||
}
|
||||
|
||||
|
||||
wxDragResult ScintillaWX::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
|
||||
SetDragPosition(PositionFromLocation(Point(x, y)));
|
||||
dragResult = def;
|
||||
return def;
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::DoDragLeave() {
|
||||
SetDragPosition(invalidPosition);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Redraw all of text area. This paint will not be abandoned.
|
||||
void ScintillaWX::FullPaint() {
|
||||
paintState = painting;
|
||||
// rcPaint = GetTextRectangle();
|
||||
// wxClientDC dc(wMain.GetID());
|
||||
// Surface surfaceWindow;
|
||||
// surfaceWindow.Init(&dc);
|
||||
// Paint(&surfaceWindow, rcPaint);
|
||||
// surfaceWindow.Release();
|
||||
wMain.GetID()->Refresh(FALSE);
|
||||
paintState = notPainting;
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::DoScrollToLine(int line) {
|
||||
ScrollTo(line);
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::DoScrollToColumn(int column) {
|
||||
HorizontalScrollTo(column * vs.spaceWidth);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------
|
||||
@@ -1,152 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Name: ScintillaWX.h
|
||||
// Purpose: A wxWindows implementation of Scintilla. A class derived
|
||||
// from ScintillaBase that uses the "wx platform" defined in
|
||||
// PlatWX.cpp. This class is one end of a bridge between
|
||||
// the wx world and the Scintilla world. It needs a peer
|
||||
// object of type wxStyledTextCtrl to function.
|
||||
//
|
||||
// Author: Robin Dunn
|
||||
//
|
||||
// Created: 13-Jan-2000
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 by Total Control Software
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __ScintillaWX_h__
|
||||
#define __ScintillaWX_h__
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "Scintilla.h"
|
||||
#ifdef SCI_LEXER
|
||||
#include "SciLexer.h"
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "KeyWords.h"
|
||||
#endif
|
||||
#include "ContractionState.h"
|
||||
#include "SVector.h"
|
||||
#include "CellBuffer.h"
|
||||
#include "CallTip.h"
|
||||
#include "KeyMap.h"
|
||||
#include "Indicator.h"
|
||||
#include "LineMarker.h"
|
||||
#include "Style.h"
|
||||
#include "ViewStyle.h"
|
||||
#include "AutoComplete.h"
|
||||
#include "Document.h"
|
||||
#include "Editor.h"
|
||||
#include "ScintillaBase.h"
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/dataobj.h>
|
||||
#include <wx/clipbrd.h>
|
||||
#include <wx/dnd.h>
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class wxStyledTextCtrl; // forward
|
||||
class ScintillaWX;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper classes
|
||||
|
||||
class wxSTCDropTarget : public wxTextDropTarget {
|
||||
public:
|
||||
void SetScintilla(ScintillaWX* swx) {
|
||||
this->swx = swx;
|
||||
}
|
||||
|
||||
bool OnDropText(wxCoord x, wxCoord y, const wxString& data);
|
||||
wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def);
|
||||
wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
|
||||
void OnLeave();
|
||||
|
||||
private:
|
||||
ScintillaWX* swx;
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class ScintillaWX : public ScintillaBase {
|
||||
public:
|
||||
|
||||
ScintillaWX(wxStyledTextCtrl* win);
|
||||
~ScintillaWX();
|
||||
|
||||
// base class virtuals
|
||||
virtual void Initialise();
|
||||
virtual void Finalise();
|
||||
virtual void StartDrag();
|
||||
virtual void SetTicking(bool on);
|
||||
virtual void SetMouseCapture(bool on);
|
||||
virtual bool HaveMouseCapture();
|
||||
virtual void ScrollText(int linesToMove);
|
||||
virtual void SetVerticalScrollPos();
|
||||
virtual void SetHorizontalScrollPos();
|
||||
virtual bool ModifyScrollBars(int nMax, int nPage);
|
||||
virtual void Copy();
|
||||
virtual void Paste();
|
||||
virtual void CreateCallTipWindow(PRectangle rc);
|
||||
virtual void AddToPopUp(const char *label, int cmd = 0, bool enabled = true);
|
||||
virtual void ClaimSelection();
|
||||
|
||||
virtual long DefWndProc(unsigned int iMessage,
|
||||
unsigned long wParam,
|
||||
long lParam);
|
||||
virtual long WndProc(unsigned int iMessage,
|
||||
unsigned long wParam,
|
||||
long lParam);
|
||||
|
||||
virtual void NotifyChange();
|
||||
virtual void NotifyParent(SCNotification scn);
|
||||
|
||||
|
||||
// Event delegates
|
||||
void DoPaint(wxDC* dc, wxRect rect);
|
||||
void DoHScroll(int type, int pos);
|
||||
void DoVScroll(int type, int pos);
|
||||
void DoSize(int width, int height);
|
||||
void DoLoseFocus();
|
||||
void DoGainFocus();
|
||||
void DoSysColourChange();
|
||||
void DoButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
|
||||
void DoButtonUp(Point pt, unsigned int curTime, bool ctrl);
|
||||
void DoButtonMove(Point pt);
|
||||
void DoAddChar(char ch);
|
||||
int DoKeyDown(int key, bool shift, bool ctrl, bool alt);
|
||||
void DoTick() { Tick(); }
|
||||
|
||||
bool DoDropText(long x, long y, const wxString& data);
|
||||
wxDragResult DoDragEnter(wxCoord x, wxCoord y, wxDragResult def);
|
||||
wxDragResult DoDragOver(wxCoord x, wxCoord y, wxDragResult def);
|
||||
void DoDragLeave();
|
||||
|
||||
void DoCommand(int ID);
|
||||
void DoContextMenu(Point pt);
|
||||
void DoOnListBox();
|
||||
|
||||
|
||||
// helpers
|
||||
void FullPaint();
|
||||
bool CanPaste();
|
||||
bool GetHideSelection() { return hideSelection; }
|
||||
void DoScrollToLine(int line);
|
||||
void DoScrollToColumn(int column);
|
||||
|
||||
private:
|
||||
bool capturedMouse;
|
||||
wxStyledTextCtrl* stc;
|
||||
|
||||
wxSTCDropTarget* dropTarget;
|
||||
wxDragResult dragResult;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -1,250 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="StcVC" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 5.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=StcVC - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "StcVC.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "StcVC.mak" CFG="StcVC - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "StcVC - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "StcVC - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
|
||||
!IF "$(CFG)" == "StcVC - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
RSC=rc.exe
|
||||
# ADD BASE RSC /l 0x809
|
||||
# ADD RSC /l 0x809
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../../include" /I "../../include" /I "scintilla/include" /I "scintilla/src" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D "__WX__" /D "SCI_LEXER" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"..\..\lib\stc.lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "StcVC - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
RSC=rc.exe
|
||||
# ADD BASE RSC /l 0x809
|
||||
# ADD RSC /l 0x809
|
||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "../../../include" /I "../../include" /I "scintilla/include" /I "scintilla/src" /D "_DEBUG" /D DEBUG=1 /D "__WXDEBUG__" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D "__WX__" /D "SCI_LEXER" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"..\..\lib\stcd.lib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "StcVC - Win32 Release"
|
||||
# Name "StcVC - Win32 Debug"
|
||||
# Begin Group "Stc"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PlatWX.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScintillaWX.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScintillaWX.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\stc.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Scintilla"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\Accessor.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\AutoComplete.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\AutoComplete.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\CallTip.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\CallTip.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\CellBuffer.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\CellBuffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\ContractionState.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\ContractionState.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\Document.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\Document.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\Editor.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\Editor.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\Indicator.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\Indicator.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\KeyMap.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\KeyMap.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\KeyWords.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexCPP.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexHTML.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexOthers.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexPerl.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexPython.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexSQL.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexVB.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LineMarker.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LineMarker.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\PropSet.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\ScintillaBase.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\ScintillaBase.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\Style.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\Style.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\SVector.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\ViewStyle.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\ViewStyle.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -1,29 +0,0 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "StcVC"=.\StcVC.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -1,684 +0,0 @@
|
||||
#!/bin/env python
|
||||
#----------------------------------------------------------------------------
|
||||
# Name: gen_iface.py
|
||||
# Purpose: Generate stc.h and stc.cpp from the info in Scintilla.iface
|
||||
#
|
||||
# Author: Robin Dunn
|
||||
#
|
||||
# Created: 5-Sept-2000
|
||||
# RCS-ID: $Id$
|
||||
# Copyright: (c) 2000 by Total Control Software
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
import sys, string, re
|
||||
from fileinput import FileInput
|
||||
|
||||
|
||||
IFACE = './scintilla/include/Scintilla.iface'
|
||||
H_TEMPLATE = './stc.h.in'
|
||||
CPP_TEMPLATE = './stc.cpp.in'
|
||||
H_DEST = '../../include/wx/stc/stc.h' # './stc_test.h' #
|
||||
CPP_DEST = './stc.cpp' #'./stc_test.cpp'
|
||||
|
||||
|
||||
# Value prefixes to convert
|
||||
valPrefixes = [('SCI_', ''),
|
||||
('SC_', ''),
|
||||
('SCN_', None), # just toss these...
|
||||
('SCEN_', None),
|
||||
('SCE_', ''),
|
||||
('SCLEX_', 'LEX_'),
|
||||
('SCK_', 'KEY_'),
|
||||
('SCFIND_', 'FIND_'),
|
||||
('SCWS_', 'WS_'),
|
||||
]
|
||||
|
||||
# Message funcion values that should have a CMD_ constant as well
|
||||
cmdValues = [ (2300, 2350), 2011, 2013, (2176, 2180) ]
|
||||
|
||||
|
||||
# Map some generic typenames to wx types, using return value syntax
|
||||
retTypeMap = {
|
||||
'position': 'int',
|
||||
'string': 'wxString',
|
||||
'colour': 'wxColour',
|
||||
}
|
||||
|
||||
# Map some generic typenames to wx types, using parameter syntax
|
||||
paramTypeMap = {
|
||||
'position': 'int',
|
||||
'string': 'const wxString&',
|
||||
'colour': 'const wxColour&',
|
||||
'keymod': 'int',
|
||||
}
|
||||
|
||||
# Map of method info that needs tweaked. Either the name needs changed, or
|
||||
# the method definition/implementation. Tuple items are:
|
||||
#
|
||||
# 1. New method name. None to skip the method, 0 to leave the
|
||||
# default name.
|
||||
# 2. Method definition for the .h file, 0 to leave alone
|
||||
# 3. Method implementation for the .cpp file, 0 to leave alone.
|
||||
# 4. tuple of Doc string lines, or 0 to leave alone.
|
||||
#
|
||||
methodOverrideMap = {
|
||||
'AddText' : (0,
|
||||
'void %s(const wxString& text);',
|
||||
|
||||
'''void %s(const wxString& text) {
|
||||
SendMsg(%s, text.Len(), (long)text.c_str());''',
|
||||
0),
|
||||
|
||||
'AddStyledText' : (0,
|
||||
'void %s(const wxString& text);',
|
||||
|
||||
'''void %s(const wxString& text) {
|
||||
SendMsg(%s, text.Len(), (long)text.c_str());''',
|
||||
0),
|
||||
|
||||
'GetViewWS' : ( 'GetViewWhiteSpace', 0, 0, 0),
|
||||
'SetViewWS' : ( 'SetViewWhiteSpace', 0, 0, 0),
|
||||
|
||||
'GetStyledText' : (0,
|
||||
'wxString %s(int startPos, int endPos);',
|
||||
|
||||
'''wxString %s(int startPos, int endPos) {
|
||||
wxString text;
|
||||
int len = endPos - startPos;
|
||||
TextRange tr;
|
||||
tr.lpstrText = text.GetWriteBuf(len*2+1);
|
||||
tr.chrg.cpMin = startPos;
|
||||
tr.chrg.cpMax = endPos;
|
||||
SendMsg(%s, 0, (long)&tr);
|
||||
text.UngetWriteBuf(len*2);
|
||||
return text;''',
|
||||
|
||||
('Retrieve a buffer of cells.',)),
|
||||
|
||||
|
||||
'PositionFromPoint' : (0,
|
||||
'int %s(wxPoint pt);',
|
||||
|
||||
'''int %s(wxPoint pt) {
|
||||
return SendMsg(%s, pt.x, pt.y);''',
|
||||
|
||||
0),
|
||||
|
||||
'GetCurLine' : (0,
|
||||
'wxString %s(int* OUTPUT=NULL);',
|
||||
|
||||
'''wxString %s(int* linePos) {
|
||||
wxString text;
|
||||
int len = LineLength(GetCurrentLine());
|
||||
char* buf = text.GetWriteBuf(len+1);
|
||||
|
||||
int pos = SendMsg(%s, len, (long)buf);
|
||||
text.UngetWriteBuf();
|
||||
if (linePos) *linePos = pos;
|
||||
|
||||
return text;''',
|
||||
|
||||
0),
|
||||
|
||||
'SetUsePalette' : (None, 0,0,0),
|
||||
|
||||
'MarkerSetFore' : ('MarkerSetForeground', 0, 0, 0),
|
||||
'MarkerSetBack' : ('MarkerSetBackground', 0, 0, 0),
|
||||
|
||||
'MarkerDefine' : (0,
|
||||
'''void %s(int markerNumber, int markerSymbol,
|
||||
const wxColour& foreground = wxNullColour,
|
||||
const wxColour& background = wxNullColour);''',
|
||||
|
||||
'''void %s(int markerNumber, int markerSymbol,
|
||||
const wxColour& foreground,
|
||||
const wxColour& background) {
|
||||
|
||||
SendMsg(%s, markerNumber, markerSymbol);
|
||||
if (foreground.Ok())
|
||||
MarkerSetForeground(markerNumber, foreground);
|
||||
if (background.Ok())
|
||||
MarkerSetBackground(markerNumber, background);''',
|
||||
|
||||
('Set the symbol used for a particular marker number,',
|
||||
'and optionally the for and background colours.')),
|
||||
|
||||
'SetMarginTypeN' : ('SetMarginType', 0, 0, 0),
|
||||
'GetMarginTypeN' : ('GetMarginType', 0, 0, 0),
|
||||
'SetMarginWidthN' : ('SetMarginWidth', 0, 0, 0),
|
||||
'GetMarginWidthN' : ('GetMarginWidth', 0, 0, 0),
|
||||
'SetMarginMaskN' : ('SetMarginMask', 0, 0, 0),
|
||||
'GetMarginMaskN' : ('GetMarginMask', 0, 0, 0),
|
||||
'SetMarginSensitiveN' : ('SetMarginSensitive', 0, 0, 0),
|
||||
'GetMarginSensitiveN' : ('GetMarginSensitive', 0, 0, 0),
|
||||
|
||||
'StyleSetFore' : ('StyleSetForeground', 0, 0, 0),
|
||||
'StyleSetBack' : ('StyleSetBackground', 0, 0, 0),
|
||||
'SetSelFore' : ('SetSelForeground', 0, 0, 0),
|
||||
'SetSelBack' : ('SetSelBackground', 0, 0, 0),
|
||||
'SetCaretFore' : ('SetCaretForeground', 0, 0, 0),
|
||||
'StyleSetFont' : ('StyleSetFaceName', 0, 0, 0),
|
||||
|
||||
# need to fix this to map between wx and scintilla encoding flags, leave it out for now...
|
||||
'StyleSetCharacterSet' : (None, 0, 0, 0),
|
||||
|
||||
'AssignCmdKey' : ('CmdKeyAssign',
|
||||
'void %s(int key, int modifiers, int cmd);',
|
||||
|
||||
'''void %s(int key, int modifiers, int cmd) {
|
||||
SendMsg(%s, MAKELONG(key, modifiers), cmd);''',
|
||||
|
||||
0),
|
||||
|
||||
'ClearCmdKey' : ('CmdKeyClear',
|
||||
'void %s(int key, int modifiers);',
|
||||
|
||||
'''void %s(int key, int modifiers) {
|
||||
SendMsg(%s, MAKELONG(key, modifiers));''',
|
||||
|
||||
0),
|
||||
|
||||
'ClearAllCmdKeys' : ('CmdKeyClearAll', 0, 0, 0),
|
||||
|
||||
|
||||
'SetStylingEx' : ('SetStyleBytes',
|
||||
'void %s(int length, char* styleBytes);',
|
||||
|
||||
'''void %s(int length, char* styleBytes) {
|
||||
SendMsg(%s, length, (long)styleBytes);''',
|
||||
|
||||
0),
|
||||
|
||||
|
||||
'IndicSetStyle' : ('IndicatorSetStyle', 0, 0, 0),
|
||||
'IndicGetStyle' : ('IndicatorGetStyle', 0, 0, 0),
|
||||
'IndicSetFore' : ('IndicatorSetForeground', 0, 0, 0),
|
||||
'IndicGetFore' : ('IndicatorGetForeground', 0, 0, 0),
|
||||
|
||||
'AutoCShow' : ('AutoCompShow', 0, 0, 0),
|
||||
'AutoCCancel' : ('AutoCompCancel', 0, 0, 0),
|
||||
'AutoCActive' : ('AutoCompActive', 0, 0, 0),
|
||||
'AutoCPosStart' : ('AutoCompPosStart', 0, 0, 0),
|
||||
'AutoCComplete' : ('AutoCompComplete', 0, 0, 0),
|
||||
'AutoCStops' : ('AutoCompStops', 0, 0, 0),
|
||||
'AutoCSetSeparator' : ('AutoCompSetSeparator', 0, 0, 0),
|
||||
'AutoCGetSeparator' : ('AutoCompGetSeparator', 0, 0, 0),
|
||||
'AutoCSelect' : ('AutoCompSelect', 0, 0, 0),
|
||||
'AutoCSetCancelAtStart' : ('AutoCompSetCancelAtStart', 0, 0, 0),
|
||||
'AutoCGetCancelAtStart' : ('AutoCompGetCancelAtStart', 0, 0, 0),
|
||||
'AutoCSetFillUps' : ('AutoCompSetFillUps', 0, 0, 0),
|
||||
'AutoCSetChooseSingle' : ('AutoCompSetChooseSingle', 0, 0, 0),
|
||||
'AutoCGetChooseSingle' : ('AutoCompGetChooseSingle', 0, 0, 0),
|
||||
'AutoCSetIgnoreCase' : ('AutoCompSetIgnoreCase', 0, 0, 0),
|
||||
'AutoCGetIgnoreCase' : ('AutoCompGetIgnoreCase', 0, 0, 0),
|
||||
|
||||
'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0, 0),
|
||||
'GetHScrollBar' : ('GetUseHorizontalScrollBar', 0, 0, 0),
|
||||
|
||||
'GetCaretFore' : ('GetCaretForeground', 0, 0, 0),
|
||||
|
||||
'GetUsePalette' : (None, 0, 0, 0),
|
||||
|
||||
'FindText' : (0,
|
||||
'''int %s(int minPos, int maxPos,
|
||||
const wxString& text,
|
||||
bool caseSensitive, bool wholeWord);''',
|
||||
'''int %s(int minPos, int maxPos,
|
||||
const wxString& text,
|
||||
bool caseSensitive, bool wholeWord) {
|
||||
TextToFind ft;
|
||||
int flags = 0;
|
||||
|
||||
flags |= caseSensitive ? SCFIND_MATCHCASE : 0;
|
||||
flags |= wholeWord ? SCFIND_WHOLEWORD : 0;
|
||||
ft.chrg.cpMin = minPos;
|
||||
ft.chrg.cpMax = maxPos;
|
||||
ft.lpstrText = (char*)text.c_str();
|
||||
|
||||
return SendMsg(%s, flags, (long)&ft);''',
|
||||
0),
|
||||
|
||||
'FormatRange' : (0,
|
||||
'''int %s(bool doDraw,
|
||||
int startPos,
|
||||
int endPos,
|
||||
wxDC* draw,
|
||||
wxDC* target, // Why does it use two? Can they be the same?
|
||||
wxRect renderRect,
|
||||
wxRect pageRect);''',
|
||||
''' int %s(bool doDraw,
|
||||
int startPos,
|
||||
int endPos,
|
||||
wxDC* draw,
|
||||
wxDC* target, // Why does it use two? Can they be the same?
|
||||
wxRect renderRect,
|
||||
wxRect pageRect) {
|
||||
RangeToFormat fr;
|
||||
|
||||
fr.hdc = draw;
|
||||
fr.hdcTarget = target;
|
||||
fr.rc.top = renderRect.GetTop();
|
||||
fr.rc.left = renderRect.GetLeft();
|
||||
fr.rc.right = renderRect.GetRight();
|
||||
fr.rc.bottom = renderRect.GetBottom();
|
||||
fr.rcPage.top = pageRect.GetTop();
|
||||
fr.rcPage.left = pageRect.GetLeft();
|
||||
fr.rcPage.right = pageRect.GetRight();
|
||||
fr.rcPage.bottom = pageRect.GetBottom();
|
||||
fr.chrg.cpMin = startPos;
|
||||
fr.chrg.cpMax = endPos;
|
||||
|
||||
return SendMsg(%s, doDraw, (long)&fr);''',
|
||||
0),
|
||||
|
||||
|
||||
'GetLine' : (0,
|
||||
'wxString %s(int line);',
|
||||
|
||||
'''wxString %s(int line) {
|
||||
wxString text;
|
||||
int len = LineLength(line);
|
||||
char* buf = text.GetWriteBuf(len+1);
|
||||
|
||||
int pos = SendMsg(%s, line, (long)buf);
|
||||
text.UngetWriteBuf();
|
||||
|
||||
return text;''',
|
||||
|
||||
('Retrieve the contents of a line.',)),
|
||||
|
||||
'SetSel' : ('SetSelection', 0, 0, 0),
|
||||
'GetSelText' : ('GetSelectedText',
|
||||
'wxString %s();',
|
||||
|
||||
'''wxString %s() {
|
||||
wxString text;
|
||||
int start;
|
||||
int end;
|
||||
|
||||
GetSelection(&start, &end);
|
||||
int len = end - start;
|
||||
char* buff = text.GetWriteBuf(len+1);
|
||||
|
||||
SendMsg(%s, 0, (long)buff);
|
||||
text.UngetWriteBuf();
|
||||
return text;''',
|
||||
|
||||
('Retrieve the selected text.',)),
|
||||
|
||||
'GetTextRange' : (0,
|
||||
'wxString %s(int startPos, int endPos);',
|
||||
|
||||
'''wxString %s(int startPos, int endPos) {
|
||||
wxString text;
|
||||
int len = endPos - startPos;
|
||||
char* buff = text.GetWriteBuf(len+1);
|
||||
TextRange tr;
|
||||
tr.lpstrText = buff;
|
||||
tr.chrg.cpMin = startPos;
|
||||
tr.chrg.cpMax = endPos;
|
||||
|
||||
SendMsg(%s, 0, (long)&tr);
|
||||
text.UngetWriteBuf();
|
||||
return text;''',
|
||||
|
||||
('Retrieve a range of text.',)),
|
||||
|
||||
'PointXFromPosition' : (None, 0, 0, 0),
|
||||
'PointYFromPosition' : (None, 0, 0, 0),
|
||||
|
||||
'ScrollCaret' : ('EnsureCaretVisible', 0, 0, 0),
|
||||
'ReplaceSel' : ('ReplaceSelection', 0, 0, 0),
|
||||
'Null' : (None, 0, 0, 0),
|
||||
|
||||
'GetText' : (0,
|
||||
'wxString %s();',
|
||||
|
||||
'''wxString %s() {
|
||||
wxString text;
|
||||
int len = GetTextLength();
|
||||
char* buff = text.GetWriteBuf(len+1);
|
||||
|
||||
SendMsg(%s, len, (long)buff);
|
||||
buff[len] = 0;
|
||||
text.UngetWriteBuf();
|
||||
return text;''',
|
||||
|
||||
('Retrieve all the text in the document.', )),
|
||||
|
||||
'GetDirectFunction' : (None, 0, 0, 0),
|
||||
'GetDirectPointer' : (None, 0, 0, 0),
|
||||
|
||||
'CallTipPosStart' : ('CallTipPosAtStart', 0, 0, 0),
|
||||
'CallTipSetHlt' : ('CallTipSetHighlight', 0, 0, 0),
|
||||
'CallTipSetBack' : ('CallTipSetBackground', 0, 0, 0),
|
||||
|
||||
|
||||
# Remove all methods that are key commands since they can be
|
||||
# executed with CmdKeyExecute
|
||||
'LineDown' : (None, 0, 0, 0),
|
||||
'LineDownExtend' : (None, 0, 0, 0),
|
||||
'LineUp' : (None, 0, 0, 0),
|
||||
'LineUpExtend' : (None, 0, 0, 0),
|
||||
'CharLeft' : (None, 0, 0, 0),
|
||||
'CharLeftExtend' : (None, 0, 0, 0),
|
||||
'CharRight' : (None, 0, 0, 0),
|
||||
'CharRightExtend' : (None, 0, 0, 0),
|
||||
'WordLeft' : (None, 0, 0, 0),
|
||||
'WordLeftExtend' : (None, 0, 0, 0),
|
||||
'WordRight' : (None, 0, 0, 0),
|
||||
'WordRightExtend' : (None, 0, 0, 0),
|
||||
'Home' : (None, 0, 0, 0),
|
||||
'HomeExtend' : (None, 0, 0, 0),
|
||||
'LineEnd' : (None, 0, 0, 0),
|
||||
'LineEndExtend' : (None, 0, 0, 0),
|
||||
'DocumentStart' : (None, 0, 0, 0),
|
||||
'DocumentStartExtend' : (None, 0, 0, 0),
|
||||
'DocumentEnd' : (None, 0, 0, 0),
|
||||
'DocumentEndExtend' : (None, 0, 0, 0),
|
||||
'PageUp' : (None, 0, 0, 0),
|
||||
'PageUpExtend' : (None, 0, 0, 0),
|
||||
'PageDown' : (None, 0, 0, 0),
|
||||
'PageDownExtend' : (None, 0, 0, 0),
|
||||
'EditToggleOvertype' : (None, 0, 0, 0),
|
||||
'Cancel' : (None, 0, 0, 0),
|
||||
'DeleteBack' : (None, 0, 0, 0),
|
||||
'Tab' : (None, 0, 0, 0),
|
||||
'BackTab' : (None, 0, 0, 0),
|
||||
'NewLine' : (None, 0, 0, 0),
|
||||
'FormFeed' : (None, 0, 0, 0),
|
||||
'VCHome' : (None, 0, 0, 0),
|
||||
'VCHomeExtend' : (None, 0, 0, 0),
|
||||
'ZoomIn' : (None, 0, 0, 0),
|
||||
'ZoomOut' : (None, 0, 0, 0),
|
||||
'DelWordLeft' : (None, 0, 0, 0),
|
||||
'DelWordRight' : (None, 0, 0, 0),
|
||||
'LineCut' : (None, 0, 0, 0),
|
||||
'LineDelete' : (None, 0, 0, 0),
|
||||
'LineTranspose' : (None, 0, 0, 0),
|
||||
'LowerCase' : (None, 0, 0, 0),
|
||||
'UpperCase' : (None, 0, 0, 0),
|
||||
'LineScrollDown' : (None, 0, 0, 0),
|
||||
'LineScrollUp' : (None, 0, 0, 0),
|
||||
|
||||
|
||||
'GetDocPointer' : (0,
|
||||
'void* %s();',
|
||||
'''void* %s() {
|
||||
return (void*)SendMsg(%s);''',
|
||||
0),
|
||||
|
||||
'SetDocPointer' : (0,
|
||||
'void %s(void* docPointer);',
|
||||
'''void %s(void* docPointer) {
|
||||
SendMsg(%s, (long)docPointer);''',
|
||||
0),
|
||||
|
||||
'CreateDocument' : (0,
|
||||
'void* %s();',
|
||||
'''void* %s() {
|
||||
return (void*)SendMsg(%s);''',
|
||||
0),
|
||||
|
||||
'AddRefDocument' : (0,
|
||||
'void %s(void* docPointer);',
|
||||
'''void %s(void* docPointer) {
|
||||
SendMsg(%s, (long)docPointer);''',
|
||||
0),
|
||||
|
||||
'ReleaseDocument' : (0,
|
||||
'void %s(void* docPointer);',
|
||||
'''void %s(void* docPointer) {
|
||||
SendMsg(%s, (long)docPointer);''',
|
||||
0),
|
||||
|
||||
'GrabFocus' : (None, 0, 0, 0),
|
||||
|
||||
'' : ('', 0, 0, 0),
|
||||
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
def processIface(iface, h_tmplt, cpp_tmplt, h_dest, cpp_dest):
|
||||
curDocStrings = []
|
||||
values = []
|
||||
methods = []
|
||||
|
||||
# parse iface file
|
||||
fi = FileInput(iface)
|
||||
for line in fi:
|
||||
line = line[:-1]
|
||||
if line[:2] == '##' or line == '':
|
||||
#curDocStrings = []
|
||||
continue
|
||||
|
||||
op = line[:4]
|
||||
if line[:2] == '# ': # a doc string
|
||||
curDocStrings.append(line[2:])
|
||||
|
||||
elif op == 'val ':
|
||||
parseVal(line[4:], values, curDocStrings)
|
||||
curDocStrings = []
|
||||
|
||||
elif op == 'fun ' or op == 'set ' or op == 'get ':
|
||||
parseFun(line[4:], methods, curDocStrings, values)
|
||||
curDocStrings = []
|
||||
|
||||
elif op == 'cat ':
|
||||
if string.strip(line[4:]) == 'Deprecated':
|
||||
break # skip the rest of the file
|
||||
|
||||
elif op == 'evt ':
|
||||
pass
|
||||
|
||||
else:
|
||||
print '***** Unknown line type: ', line
|
||||
|
||||
|
||||
# process templates
|
||||
data = {}
|
||||
data['VALUES'] = processVals(values)
|
||||
defs, imps = processMethods(methods)
|
||||
data['METHOD_DEFS'] = defs
|
||||
data['METHOD_IMPS'] = imps
|
||||
|
||||
# get template text
|
||||
h_text = open(h_tmplt).read()
|
||||
cpp_text = open(cpp_tmplt).read()
|
||||
|
||||
# do the substitutions
|
||||
h_text = h_text % data
|
||||
cpp_text = cpp_text % data
|
||||
|
||||
# write out destination files
|
||||
open(h_dest, 'w').write(h_text)
|
||||
open(cpp_dest, 'w').write(cpp_text)
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
def processVals(values):
|
||||
text = []
|
||||
for name, value, docs in values:
|
||||
if docs:
|
||||
text.append('')
|
||||
for x in docs:
|
||||
text.append('// ' + x)
|
||||
text.append('#define %s %s' % (name, value))
|
||||
return string.join(text, '\n')
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
def processMethods(methods):
|
||||
defs = []
|
||||
imps = []
|
||||
|
||||
for retType, name, number, param1, param2, docs in methods:
|
||||
retType = retTypeMap.get(retType, retType)
|
||||
params = makeParamString(param1, param2)
|
||||
|
||||
name, theDef, theImp, docs = checkMethodOverride(name, number, docs)
|
||||
|
||||
if name is None:
|
||||
continue
|
||||
|
||||
# Build the method definition for the .h file
|
||||
if docs:
|
||||
defs.append('')
|
||||
for x in docs:
|
||||
defs.append(' // ' + x)
|
||||
if not theDef:
|
||||
theDef = ' %s %s(%s);' % (retType, name, params)
|
||||
defs.append(theDef)
|
||||
|
||||
# Build the method implementation string
|
||||
if docs:
|
||||
imps.append('')
|
||||
for x in docs:
|
||||
imps.append('// ' + x)
|
||||
if not theImp:
|
||||
theImp = '%s wxStyledTextCtrl::%s(%s) {\n ' % (retType, name, params)
|
||||
|
||||
if retType == 'wxColour':
|
||||
theImp = theImp + 'long c = '
|
||||
elif retType != 'void':
|
||||
theImp = theImp + 'return '
|
||||
theImp = theImp + 'SendMsg(%s, %s, %s)' % (number,
|
||||
makeArgString(param1),
|
||||
makeArgString(param2))
|
||||
if retType == 'bool':
|
||||
theImp = theImp + ' != 0'
|
||||
if retType == 'wxColour':
|
||||
theImp = theImp + ';\n return wxColourFromLong(c)'
|
||||
|
||||
theImp = theImp + ';\n}'
|
||||
imps.append(theImp)
|
||||
|
||||
|
||||
return string.join(defs, '\n'), string.join(imps, '\n')
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
def checkMethodOverride(name, number, docs):
|
||||
theDef = theImp = None
|
||||
if methodOverrideMap.has_key(name):
|
||||
item = methodOverrideMap[name]
|
||||
|
||||
if item[0] != 0:
|
||||
name = item[0]
|
||||
if item[1] != 0:
|
||||
theDef = ' ' + (item[1] % name)
|
||||
if item[2] != 0:
|
||||
theImp = item[2] % ('wxStyledTextCtrl::'+name, number) + '\n}'
|
||||
if item[3] != 0:
|
||||
docs = item[3]
|
||||
|
||||
return name, theDef, theImp, docs
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
def makeArgString(param):
|
||||
if not param:
|
||||
return '0'
|
||||
|
||||
typ, name = param
|
||||
|
||||
if typ == 'string':
|
||||
return '(long)%s.c_str()' % name
|
||||
if typ == 'colour':
|
||||
return 'wxColourAsLong(%s)' % name
|
||||
|
||||
return name
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
def makeParamString(param1, param2):
|
||||
def doOne(param):
|
||||
if param:
|
||||
aType = paramTypeMap.get(param[0], param[0])
|
||||
return aType + ' ' + param[1]
|
||||
else:
|
||||
return ''
|
||||
|
||||
st = doOne(param1)
|
||||
if st and param2:
|
||||
st = st + ', '
|
||||
st = st + doOne(param2)
|
||||
return st
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
def parseVal(line, values, docs):
|
||||
name, val = string.split(line, '=')
|
||||
|
||||
# remove prefixes such as SCI, etc.
|
||||
for old, new in valPrefixes:
|
||||
lo = len(old)
|
||||
if name[:lo] == old:
|
||||
if new is None:
|
||||
return
|
||||
name = new + name[lo:]
|
||||
|
||||
# add it to the list
|
||||
values.append( ('wxSTC_' + name, val, docs) )
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
funregex = re.compile(r'\s*([a-zA-Z0-9_]+)' # <ws>return type
|
||||
'\s+([a-zA-Z0-9_]+)=' # <ws>name=
|
||||
'([0-9]+)' # number
|
||||
'\(([ a-zA-Z0-9_]*),' # (param,
|
||||
'([ a-zA-Z0-9_]*)\)') # param)
|
||||
|
||||
def parseFun(line, methods, docs, values):
|
||||
def parseParam(param):
|
||||
param = string.strip(param)
|
||||
if param == '':
|
||||
param = None
|
||||
else:
|
||||
param = tuple(string.split(param))
|
||||
return param
|
||||
|
||||
mo = funregex.match(line)
|
||||
if mo is None:
|
||||
print "***** Line doesn't match! : " + line
|
||||
|
||||
retType, name, number, param1, param2 = mo.groups()
|
||||
|
||||
param1 = parseParam(param1)
|
||||
param2 = parseParam(param2)
|
||||
|
||||
# Special case. For the key command functionss we want a value defined too
|
||||
num = string.atoi(number)
|
||||
for v in cmdValues:
|
||||
if (type(v) == type(()) and v[0] <= num < v[1]) or v == num:
|
||||
parseVal('CMD_%s=%s' % (string.upper(name), number), values, ())
|
||||
|
||||
#if retType == 'void' and not param1 and not param2:
|
||||
|
||||
methods.append( (retType, name, number, param1, param2, tuple(docs)) )
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
def main(args):
|
||||
# TODO: parse command line args to replace default input/output files???
|
||||
|
||||
# Now just do it
|
||||
processIface(IFACE, H_TEMPLATE, CPP_TEMPLATE, H_DEST, CPP_DEST)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv)
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
#
|
||||
# File: makefile.b32
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright:
|
||||
#
|
||||
# Makefile : Builds wxMMedia library for 32-bit BC++
|
||||
|
||||
# N.B. use:
|
||||
# make -f makefile.b32 stc.cfg
|
||||
# make -f makefile.b32
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
SCINTILLA=.\scintilla
|
||||
S=$(SCINTILLA)\src
|
||||
|
||||
STCEXTRACPPFLAGS=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S)
|
||||
|
||||
LIBTARGET=$(WXDIR)\contrib\lib\stc.lib
|
||||
|
||||
OBJECTS = \
|
||||
Accessor.obj \
|
||||
AutoComplete.obj \
|
||||
CallTip.obj \
|
||||
CellBuffer.obj \
|
||||
ContractionState.obj \
|
||||
Document.obj \
|
||||
DocumentAccessor.obj \
|
||||
Editor.obj \
|
||||
Indicator.obj \
|
||||
KeyMap.obj \
|
||||
KeyWords.obj \
|
||||
LexCPP.obj \
|
||||
LexHTML.obj \
|
||||
LexLua.obj \
|
||||
LexOthers.obj \
|
||||
LexPerl.obj \
|
||||
LexPython.obj \
|
||||
LexSQL.obj \
|
||||
LexVB.obj \
|
||||
LineMarker.obj \
|
||||
PropSet.obj \
|
||||
PosRegExp.obj \
|
||||
ScintillaBase.obj \
|
||||
Style.obj \
|
||||
UniConversion.obj \
|
||||
ViewStyle.obj \
|
||||
WindowAccessor.obj \
|
||||
\
|
||||
PlatWX.obj \
|
||||
ScintillaWX.obj \
|
||||
stc.obj \
|
||||
|
||||
|
||||
!include $(WXDIR)\src\makelib.b32
|
||||
|
||||
CFG = stc.cfg
|
||||
CPPFLAGS=$(DLL_FLAGS) $(EXTRACPPFLAGS) @$(CFG)
|
||||
|
||||
{$(S)}.cxx.obj:
|
||||
bcc32 $(CPPFLAGS) -P -c {$< }
|
||||
|
||||
$(CFG): makefile.b32
|
||||
copy &&!
|
||||
-H=$(WXDIR)\src\msw\wx32.csm
|
||||
-3
|
||||
-d
|
||||
-a1 # byte alignment
|
||||
-R-
|
||||
-X
|
||||
-w-par
|
||||
-w-aus
|
||||
-w-hid # virtual function A hides virtual function B
|
||||
-WE
|
||||
-tWM
|
||||
|
||||
-I$(WXINC);$(BCCDIR)\include;$(WXDIR)/src/generic;$(WXDIR)/src/png;$(WXDIR)/src/jpeg;$(WXDIR)/src/zlib;$(WXDIR)/src/xpm;$(WXDIR)/src/tiff
|
||||
-I$(WXDIR)\include\wx\msw\gnuwin32
|
||||
|
||||
-L$(BCCDIR)\lib
|
||||
-D__WXWIN__
|
||||
-D__WXMSW__
|
||||
-D__WINDOWS__
|
||||
-DWIN32
|
||||
$(OPT)
|
||||
$(DEBUG_FLAGS)
|
||||
$(WIN95FLAG)
|
||||
$(STCEXTRACPPFLAGS)
|
||||
! $(CFG)
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
# File: makefile.g95 For stectrl
|
||||
# Author: Robin Dunn
|
||||
# Created: 1-Feb-2000
|
||||
# Updated:
|
||||
|
||||
WXDIR = ../../..
|
||||
|
||||
SCINTILLA=$(WXDIR)/contrib/src/stc/scintilla
|
||||
S=$(SCINTILLA)/src
|
||||
EXTRAINC=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)/contrib/include
|
||||
|
||||
OBJECTS = \
|
||||
$(S)/Accessor.$(OBJSUFF) \
|
||||
$(S)/AutoComplete.$(OBJSUFF) \
|
||||
$(S)/CallTip.$(OBJSUFF) \
|
||||
$(S)/CellBuffer.$(OBJSUFF) \
|
||||
$(S)/ContractionState.$(OBJSUFF)\
|
||||
$(S)/Document.$(OBJSUFF) \
|
||||
$(S)/Editor.$(OBJSUFF) \
|
||||
$(S)/Indicator.$(OBJSUFF) \
|
||||
$(S)/KeyMap.$(OBJSUFF) \
|
||||
$(S)/KeyWords.$(OBJSUFF) \
|
||||
$(S)/LineMarker.$(OBJSUFF) \
|
||||
$(S)/PropSet.$(OBJSUFF) \
|
||||
$(S)/ScintillaBase.$(OBJSUFF) \
|
||||
$(S)/Style.$(OBJSUFF) \
|
||||
$(S)/ViewStyle.$(OBJSUFF) \
|
||||
$(S)/LexCPP.$(OBJSUFF) \
|
||||
$(S)/LexHTML.$(OBJSUFF) \
|
||||
$(S)/LexLua.$(OBJSUFF) \
|
||||
$(S)/LexOthers.$(OBJSUFF) \
|
||||
$(S)/LexPerl.$(OBJSUFF) \
|
||||
$(S)/LexPython.$(OBJSUFF) \
|
||||
$(S)/LexSQL.$(OBJSUFF) \
|
||||
$(S)/LexVB.$(OBJSUFF) \
|
||||
$(S)/DocumentAccessor.$(OBJSUFF)\
|
||||
$(S)/UniConversion.$(OBJSUFF) \
|
||||
$(S)/WindowAccessor.$(OBJSUFF) \
|
||||
$(S)/PosRegExp.$(OBJSUFF) \
|
||||
PlatWX.$(OBJSUFF) \
|
||||
ScintillaWX.$(OBJSUFF) \
|
||||
stc.$(OBJSUFF)
|
||||
|
||||
LIBTARGET = $(WXDIR)/contrib/lib/libstc.a
|
||||
|
||||
include $(WXDIR)/src/makelib.g95
|
||||
@@ -1,105 +0,0 @@
|
||||
# File: makefile.vc For stectrl
|
||||
# Author: Robin Dunn
|
||||
# Created: 1-Feb-2000
|
||||
# Updated:
|
||||
|
||||
|
||||
|
||||
# Set WXDIR for your system
|
||||
WXDIR = $(WXWIN)
|
||||
SCINTILLA=.\scintilla
|
||||
S=$(SCINTILLA)\src
|
||||
EXTRAINC=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)\contrib\include
|
||||
NOPCH=1
|
||||
|
||||
!include $(WXDIR)\src\makevc.env
|
||||
|
||||
OBJECTS = \
|
||||
$(D)\AutoComplete.obj \
|
||||
$(D)\CallTip.obj \
|
||||
$(D)\CellBuffer.obj \
|
||||
$(D)\ContractionState.obj\
|
||||
$(D)\Document.obj \
|
||||
$(D)\DocumentAccessor.obj\
|
||||
$(D)\Editor.obj \
|
||||
$(D)\Indicator.obj \
|
||||
$(D)\KeyMap.obj \
|
||||
$(D)\KeyWords.obj \
|
||||
$(D)\LexCPP.obj \
|
||||
$(D)\LexHTML.obj \
|
||||
$(D)\LexLua.obj \
|
||||
$(D)\LexOthers.obj \
|
||||
$(D)\LexPerl.obj \
|
||||
$(D)\LexPython.obj \
|
||||
$(D)\LexSQL.obj \
|
||||
$(D)\LexVB.obj \
|
||||
$(D)\LineMarker.obj \
|
||||
$(D)\PosRegExp.obj \
|
||||
$(D)\PropSet.obj \
|
||||
$(D)\ScintillaBase.obj \
|
||||
$(D)\Style.obj \
|
||||
$(D)\UniConversion.obj \
|
||||
$(D)\ViewStyle.obj \
|
||||
$(D)\WindowAccessor.obj \
|
||||
\
|
||||
$(D)\PlatWX.obj \
|
||||
$(D)\ScintillaWX.obj \
|
||||
$(D)\stc.obj \
|
||||
|
||||
|
||||
|
||||
|
||||
LIBTARGET = $(WXDIR)\contrib\lib\stc$(LIBEXT).lib
|
||||
|
||||
all: $(D) $(LIBTARGET)
|
||||
|
||||
$(D) :
|
||||
mkdir $(D)
|
||||
|
||||
wx:
|
||||
cd $(WXDIR)\src\msw
|
||||
nmake -f makefile.vc FINAL=$(FINAL)
|
||||
cd $(THISDIR)
|
||||
|
||||
wxclean:
|
||||
cd $(WXDIR)\src\msw
|
||||
nmake -f makefile.vc clean
|
||||
cd $(THISDIR)
|
||||
|
||||
|
||||
|
||||
|
||||
$(LIBTARGET): $(OBJECTS)
|
||||
-erase $(LIBTARGET)
|
||||
$(implib) @<<
|
||||
-out:$(LIBTARGET)
|
||||
-machine:$(CPU)
|
||||
$(OBJECTS)
|
||||
<<
|
||||
|
||||
|
||||
|
||||
{$(S)}.cxx{$(D)}.obj:
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS) /c /Fo$@ /Tp $<
|
||||
<<
|
||||
|
||||
{}.cpp{$(D)}.obj:
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS) /c /Fo$@ /Tp $<
|
||||
<<
|
||||
|
||||
|
||||
show:
|
||||
@echo $(CPPFLAGS)
|
||||
|
||||
|
||||
clean:
|
||||
-erase $(D)\*.obj
|
||||
-erase *.sbr
|
||||
-erase *.exe
|
||||
-erase *.res
|
||||
-erase *.map
|
||||
-erase *.pdb
|
||||
-erase $(LIBTARGET)
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
This directory contains copies of the scintilla/src and
|
||||
scintilla/include directories from the Scintilla/SCiTE source
|
||||
distribution. All other code needed to implement Scintilla on top of
|
||||
wxWindows is located in the directory above this one.
|
||||
|
||||
The current version of the Scintilla code is 1.32
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
// SciTE - Scintilla based Text Editor
|
||||
// Accessor.h - rapid easy access to contents of a Scintilla
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
enum { wsSpace = 1, wsTab = 2, wsSpaceTab = 4, wsInconsistent=8};
|
||||
|
||||
class Accessor;
|
||||
|
||||
typedef bool (*PFNIsCommentLeader)(Accessor &styler, int pos, int len);
|
||||
|
||||
// Interface to data in a Scintilla
|
||||
class Accessor {
|
||||
protected:
|
||||
enum {extremePosition=0x7FFFFFFF};
|
||||
// bufferSize is a trade off between time taken to copy the characters and retrieval 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];
|
||||
int startPos;
|
||||
int endPos;
|
||||
int codePage;
|
||||
|
||||
virtual bool InternalIsLeadByte(char ch)=0;
|
||||
virtual void Fill(int position)=0;
|
||||
public:
|
||||
Accessor() : startPos(extremePosition), endPos(0), codePage(0) {}
|
||||
virtual ~Accessor() {}
|
||||
char operator[](int position) {
|
||||
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
|
||||
if (position < startPos || position >= endPos) {
|
||||
Fill(position);
|
||||
if (position < startPos || position >= endPos) {
|
||||
// Position is outside range of document
|
||||
return chDefault;
|
||||
}
|
||||
}
|
||||
return buf[position - startPos];
|
||||
}
|
||||
bool IsLeadByte(char ch) {
|
||||
return codePage && InternalIsLeadByte(ch);
|
||||
}
|
||||
void SetCodePage(int codePage_) { codePage = codePage_; }
|
||||
|
||||
virtual char StyleAt(int position)=0;
|
||||
virtual int GetLine(int position)=0;
|
||||
virtual int LineStart(int line)=0;
|
||||
virtual int LevelAt(int line)=0;
|
||||
virtual int Length()=0;
|
||||
virtual void Flush()=0;
|
||||
virtual int GetLineState(int line)=0;
|
||||
virtual int SetLineState(int line, int state)=0;
|
||||
virtual int GetPropertyInt(const char *key, int defaultValue=0)=0;
|
||||
|
||||
// Style setting
|
||||
virtual void StartAt(unsigned int start, char chMask=31)=0;
|
||||
virtual void SetFlags(char chFlags_, char chWhile_)=0;
|
||||
virtual unsigned int GetStartSegment()=0;
|
||||
virtual void StartSegment(unsigned int pos)=0;
|
||||
virtual void ColourTo(unsigned int pos, int chAttr)=0;
|
||||
virtual void SetLevel(int line, int level)=0;
|
||||
virtual int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0)=0;
|
||||
};
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
// SciTE - Scintilla based Text Editor
|
||||
// KeyWords.h - colourise for particular languages
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler);
|
||||
|
||||
class LexerModule {
|
||||
static LexerModule *base;
|
||||
LexerModule *next;
|
||||
int language;
|
||||
LexerFunction fn;
|
||||
public:
|
||||
LexerModule(int language_, LexerFunction fn_);
|
||||
static void Colourise(unsigned int startPos, int lengthDoc, int initStyle,
|
||||
int language, WordList *keywordlists[], Accessor &styler);
|
||||
};
|
||||
|
||||
inline bool iswordchar(char ch) {
|
||||
return isalnum(ch) || ch == '.' || ch == '_';
|
||||
}
|
||||
|
||||
inline bool iswordstart(char ch) {
|
||||
return isalnum(ch) || ch == '_';
|
||||
}
|
||||
|
||||
inline bool isoperator(char ch) {
|
||||
if (isalnum(ch))
|
||||
return false;
|
||||
// '.' left out as it is used to make up numbers
|
||||
if (ch == '%' || ch == '^' || ch == '&' || ch == '*' ||
|
||||
ch == '(' || ch == ')' || ch == '-' || ch == '+' ||
|
||||
ch == '=' || ch == '|' || ch == '{' || ch == '}' ||
|
||||
ch == '[' || ch == ']' || ch == ':' || ch == ';' ||
|
||||
ch == '<' || ch == '>' || ch == ',' || ch == '/' ||
|
||||
ch == '?' || ch == '!' || ch == '.' || ch == '~')
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,411 +0,0 @@
|
||||
// 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 <neilh@scintilla.org>
|
||||
// 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 <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#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 <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <richedit.h>
|
||||
#endif
|
||||
|
||||
#if PLAT_WX
|
||||
#include <wx/wx.h>
|
||||
#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
|
||||
|
||||
// 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 {
|
||||
protected:
|
||||
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();
|
||||
virtual ~Font();
|
||||
|
||||
virtual void Create(const char *faceName, int characterSet, int size, bool bold, bool italic);
|
||||
virtual 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:
|
||||
bool unicodeMode;
|
||||
#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();
|
||||
int DeviceHeightFont(int points);
|
||||
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);
|
||||
void FlushCachedState();
|
||||
|
||||
void SetUnicodeMode(bool unicodeMode_) {
|
||||
unicodeMode=unicodeMode_;
|
||||
}
|
||||
};
|
||||
|
||||
// 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) {}
|
||||
Window(const Window &source) : id(source.id) {}
|
||||
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);
|
||||
virtual 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
|
||||
int desiredVisibleRows;
|
||||
unsigned int maxItemCharacters;
|
||||
unsigned int aveCharWidth;
|
||||
public:
|
||||
ListBox();
|
||||
virtual ~ListBox();
|
||||
void Create(Window &parent, int ctrlID);
|
||||
virtual void SetFont(Font &font);
|
||||
void SetAverageCharWidth(int width);
|
||||
void SetVisibleRows(int rows);
|
||||
PRectangle GetDesiredRect();
|
||||
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);
|
||||
// Next three assume 16 bit shorts and 32 bit longs
|
||||
static long LongFromTwoShorts(short a,short b) {
|
||||
return (a) | ((b) << 16);
|
||||
}
|
||||
static short HighShortFromLong(long x) {
|
||||
return static_cast<short>(x >> 16);
|
||||
}
|
||||
static short LowShortFromLong(long x) {
|
||||
return static_cast<short>(x & 0xffff);
|
||||
}
|
||||
static void DebugPrintf(const char *format, ...);
|
||||
static int Clamp(int val, int minVal, int maxVal);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,138 +0,0 @@
|
||||
#ifndef POSREGEXP_H
|
||||
#define POSREGEXP_H
|
||||
|
||||
#define MatchesNum 0x10
|
||||
|
||||
enum EOps
|
||||
{
|
||||
ReBlockOps = 0x1000,
|
||||
ReMul, // *
|
||||
RePlus, // +
|
||||
ReQuest, // ?
|
||||
ReNGMul, // *?
|
||||
ReNGPlus, // +?
|
||||
ReNGQuest, // ??
|
||||
ReRangeN, // {n,}
|
||||
ReRangeNM, // {n,m}
|
||||
ReNGRangeN, // {n,}?
|
||||
ReNGRangeNM, // {n,m}?
|
||||
ReOr, // |
|
||||
ReBehind = 0x1100, // ?#n
|
||||
ReNBehind = 0x1200, // ?~n
|
||||
ReAhead = 0x1300, // ?=
|
||||
ReNAhead = 0x1400, // ?!
|
||||
|
||||
ReSymbolOps = 0x2000,
|
||||
ReEmpty,
|
||||
ReSymb, // a b \W \s ...
|
||||
ReEnum, // []
|
||||
ReNEnum, // [^]
|
||||
ReBrackets, // (...)
|
||||
ReBkTrace = 0x2100, // \yN
|
||||
ReBkBrack = 0x2200 // \N
|
||||
};
|
||||
|
||||
enum ESymbols
|
||||
{
|
||||
ReAnyChr = 0x4000, // .
|
||||
ReSoL, // ^
|
||||
ReEoL, // $
|
||||
ReDigit, // \d
|
||||
ReNDigit, // \D
|
||||
ReWordSymb, // \w
|
||||
ReNWordSymb, // \W
|
||||
ReWSpace, // \s
|
||||
ReNWSpace, // \S
|
||||
ReUCase, // \u
|
||||
ReNUCase , // \l
|
||||
ReWBound, // \b
|
||||
ReNWBound, // \B
|
||||
RePreNW, // \c
|
||||
ReStart, // \m
|
||||
ReEnd, // \M
|
||||
|
||||
ReChr = 0x0 // Char in Lower Byte
|
||||
};
|
||||
enum ETempSymb
|
||||
{
|
||||
ReTemp = 0x7000,
|
||||
ReLBrack, ReRBrack,
|
||||
ReEnumS, ReEnumE, ReNEnumS,
|
||||
ReRangeS, ReRangeE, ReNGRangeE, ReFrToEnum
|
||||
};
|
||||
|
||||
#define BackSlash '\\'
|
||||
|
||||
typedef union SCharData
|
||||
{
|
||||
int IArr[8];
|
||||
char CArr[32];
|
||||
void SetBit(unsigned char Bit);
|
||||
void ClearBit(unsigned char Bit);
|
||||
bool GetBit(unsigned char Bit);
|
||||
} *PCharData;
|
||||
|
||||
typedef struct SRegInfo
|
||||
{
|
||||
SRegInfo();
|
||||
~SRegInfo();
|
||||
|
||||
EOps Op;
|
||||
union{
|
||||
SRegInfo *Param;
|
||||
int Symb;
|
||||
PCharData ChrClass;
|
||||
}un;
|
||||
int s,e;
|
||||
SRegInfo *Parent;
|
||||
SRegInfo *Next;
|
||||
} *PRegInfo;
|
||||
|
||||
typedef struct SMatches
|
||||
{
|
||||
int s[MatchesNum];
|
||||
int e[MatchesNum];
|
||||
int CurMatch;
|
||||
} *PMatches;
|
||||
|
||||
typedef class PosRegExp
|
||||
{
|
||||
PRegInfo Info;
|
||||
PMatches BkTrace;
|
||||
bool NoCase,Extend,NoMoves;
|
||||
bool Error;
|
||||
int *Exprn;
|
||||
int posParse;
|
||||
int posEnd,posStart;
|
||||
int posBkStr;
|
||||
int FirstChar;
|
||||
|
||||
bool SetExprLow(const char *Expr);
|
||||
bool SetStructs(PRegInfo &Info,int st,int end);
|
||||
void Optimize();
|
||||
bool CheckSymb(int Symb,bool Inc);
|
||||
bool LowParse(PRegInfo Re);
|
||||
bool LowParseRe(PRegInfo &Next);
|
||||
bool LowCheckNext(PRegInfo Re);
|
||||
bool ParseRe(int posStr);
|
||||
bool QuickCheck();
|
||||
public:
|
||||
PMatches Matches;
|
||||
int Ok, CurMatch;
|
||||
|
||||
void *param;
|
||||
char (*CharAt)(int pos, void *param);
|
||||
|
||||
PosRegExp();
|
||||
~PosRegExp();
|
||||
|
||||
bool isok();
|
||||
bool SetNoMoves(bool Moves);
|
||||
bool SetBkTrace(int posStr,PMatches Trace);
|
||||
bool SetExpr(const char *Expr);
|
||||
bool Parse(int posStr, int posStop, PMatches Mtch);
|
||||
bool Parse(int posStr,int posSol, int posEol, PMatches Mtch, int Moves = -1);
|
||||
bool Evaluate(char *Expr, int posStr, PMatches Mtch, char **Res);
|
||||
} *PPosRegExp;
|
||||
|
||||
#endif /* POSREGEXP_H */
|
||||
@@ -1,244 +0,0 @@
|
||||
// SciTE - Scintilla based Text Editor
|
||||
// PropSet.h - a java style properties file module
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// 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);
|
||||
|
||||
#if PLAT_WIN
|
||||
#define strcasecmp stricmp
|
||||
#define strncasecmp strnicmp
|
||||
#endif
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#define strcasecmp stricmp
|
||||
#define strncasecmp strnicmp
|
||||
#endif
|
||||
|
||||
// Define another string class.
|
||||
// While it would be 'better' to use std::string, that doubles the executable size.
|
||||
|
||||
inline char *StringDup(const char *s, int len=-1) {
|
||||
if (!s)
|
||||
return 0;
|
||||
if (len == -1)
|
||||
len = strlen(s);
|
||||
char *sNew = new char[len + 1];
|
||||
if (sNew) {
|
||||
strncpy(sNew, s, len);
|
||||
sNew[len] = '\0';
|
||||
}
|
||||
return sNew;
|
||||
}
|
||||
|
||||
class SString {
|
||||
char *s;
|
||||
int ssize;
|
||||
public:
|
||||
typedef const char* const_iterator;
|
||||
typedef int size_type;
|
||||
static size_type npos;
|
||||
const char* begin(void) const {
|
||||
return s;
|
||||
}
|
||||
const char* end(void) const {
|
||||
return &s[ssize];
|
||||
}
|
||||
size_type size(void) const {
|
||||
if (s)
|
||||
return ssize;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
SString &assign(const char* sother, int size_ = -1) {
|
||||
char *t = s;
|
||||
s = StringDup(sother,size_);
|
||||
ssize = (s) ? strlen(s) : 0;
|
||||
delete []t;
|
||||
return *this;
|
||||
}
|
||||
SString &assign(const SString& sother, int size_ = -1) {
|
||||
return assign(sother.s,size_);
|
||||
}
|
||||
SString &assign(const_iterator ibeg, const_iterator iend) {
|
||||
return assign(ibeg,iend - ibeg);
|
||||
}
|
||||
SString() {
|
||||
s = 0;
|
||||
ssize = 0;
|
||||
}
|
||||
SString(const SString &source) {
|
||||
s = StringDup(source.s);
|
||||
ssize = (s) ? strlen(s) : 0;
|
||||
}
|
||||
SString(const char *s_) {
|
||||
s = StringDup(s_);
|
||||
ssize = (s) ? strlen(s) : 0;
|
||||
}
|
||||
SString(int i) {
|
||||
char number[100];
|
||||
sprintf(number, "%0d", i);
|
||||
s = StringDup(number);
|
||||
ssize = (s) ? strlen(s) : 0;
|
||||
}
|
||||
~SString() {
|
||||
delete []s;
|
||||
s = 0;
|
||||
ssize = 0;
|
||||
}
|
||||
SString &operator=(const SString &source) {
|
||||
if (this != &source) {
|
||||
delete []s;
|
||||
s = StringDup(source.s);
|
||||
ssize = (s) ? strlen(s) : 0;
|
||||
}
|
||||
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 SString &other) const {
|
||||
return !operator==(other);
|
||||
}
|
||||
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;
|
||||
}
|
||||
bool operator!=(const char *sother) const {
|
||||
return !operator==(sother);
|
||||
}
|
||||
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) const {
|
||||
if (s)
|
||||
return s[i];
|
||||
else
|
||||
return '\0';
|
||||
}
|
||||
SString &operator +=(const char *sother) {
|
||||
return append(sother,-1);
|
||||
}
|
||||
SString &operator +=(const SString &sother) {
|
||||
return append(sother.s,sother.ssize);
|
||||
}
|
||||
SString &operator +=(char ch) {
|
||||
return append(&ch,1);
|
||||
}
|
||||
SString &append(const char* sother, int lenOther) {
|
||||
int len = length();
|
||||
if(lenOther < 0)
|
||||
lenOther = strlen(sother);
|
||||
char *sNew = new char[len + lenOther + 1];
|
||||
if (sNew) {
|
||||
if (s)
|
||||
memcpy(sNew, s, len);
|
||||
strncpy(&sNew[len], sother, lenOther);
|
||||
sNew[len + lenOther] = '\0';
|
||||
delete []s;
|
||||
s = sNew;
|
||||
ssize = (s) ? strlen(s) : 0;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
int value() const {
|
||||
if (s)
|
||||
return atoi(s);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
void substitute(char find, char replace) {
|
||||
char *t = s;
|
||||
while (t) {
|
||||
t = strchr(t, find);
|
||||
if (t)
|
||||
*t = replace;
|
||||
}
|
||||
}
|
||||
// I don't think this really belongs here -- Neil
|
||||
void correctPath() {
|
||||
#ifdef unix
|
||||
substitute('\\', '/');
|
||||
#else
|
||||
substitute('/', '\\');
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
struct Property {
|
||||
unsigned int hash;
|
||||
char *key;
|
||||
char *val;
|
||||
Property *next;
|
||||
Property() : hash(0), key(0), val(0), next(0) {}
|
||||
};
|
||||
|
||||
class PropSet {
|
||||
private:
|
||||
enum { hashRoots=31 };
|
||||
Property *props[hashRoots];
|
||||
public:
|
||||
PropSet *superPS;
|
||||
PropSet();
|
||||
~PropSet();
|
||||
void Set(const char *key, const char *val);
|
||||
void Set(char *keyval);
|
||||
SString Get(const char *key);
|
||||
SString GetExpanded(const char *key);
|
||||
SString Expand(const char *withvars);
|
||||
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, const char *directoryForImports=0);
|
||||
void Read(const char *filename, const char *directoryForImports);
|
||||
};
|
||||
|
||||
class WordList {
|
||||
public:
|
||||
// Each word contains at least one character - a empty word acts as sentinal at the end.
|
||||
char **words;
|
||||
char **wordsNoCase;
|
||||
char *list;
|
||||
int len;
|
||||
bool onlyLineEnds; // Delimited by any white space or only line ends
|
||||
bool sorted;
|
||||
int starts[256];
|
||||
WordList(bool onlyLineEnds_ = false) :
|
||||
words(0), wordsNoCase(0), list(0), len(0), onlyLineEnds(onlyLineEnds_), sorted(false) {}
|
||||
~WordList() { Clear(); }
|
||||
operator bool() { return words ? true : false; }
|
||||
const char *operator[](int ind) { return words[ind]; }
|
||||
void Clear();
|
||||
void Set(const char *s);
|
||||
char *Allocate(int size);
|
||||
void SetFromAllocated();
|
||||
bool InList(const char *s);
|
||||
const char *GetNearestWord(const char *wordStart, int searchLen = -1, bool ignoreCase = false);
|
||||
char *GetNearestWords(const char *wordStart, int searchLen = -1, bool ignoreCase = false);
|
||||
};
|
||||
|
||||
inline bool nonFuncChar(char ch) {
|
||||
return strchr("\t\n\r !\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~", ch) != NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,204 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// SciLexer - interface to the added lexer functions in the SciLexer version of the edit control
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
// Most of this file is automatically generated from the Scintilla.iface interface definition
|
||||
// file which contains any comments about the definitions. HFacer.py does the generation.
|
||||
|
||||
#ifndef SCILEXER_H
|
||||
#define SCILEXER_H
|
||||
|
||||
// SciLexer features - not in standard Scintilla
|
||||
|
||||
//++Autogenerated -- start of section automatically generated from Scintilla.iface
|
||||
#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
|
||||
#define SCLEX_XCODE 13
|
||||
#define SCLEX_LATEX 14
|
||||
#define SCLEX_LUA 15
|
||||
#define SCLEX_DIFF 16
|
||||
#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
|
||||
#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_UUID 8
|
||||
#define SCE_C_PREPROCESSOR 9
|
||||
#define SCE_C_OPERATOR 10
|
||||
#define SCE_C_IDENTIFIER 11
|
||||
#define SCE_C_STRINGEOL 12
|
||||
#define SCE_C_VERBATIM 13
|
||||
#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
|
||||
#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
|
||||
#define SCE_H_CDATA 17
|
||||
#define SCE_H_QUESTION 18
|
||||
#define SCE_H_VALUE 19
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
#define SCE_HPHP_DEFAULT 118
|
||||
#define SCE_HPHP_HSTRING 119
|
||||
#define SCE_HPHP_SIMPLESTRING 120
|
||||
#define SCE_HPHP_WORD 121
|
||||
#define SCE_HPHP_NUMBER 122
|
||||
#define SCE_HPHP_VARIABLE 123
|
||||
#define SCE_HPHP_COMMENT 124
|
||||
#define SCE_HPHP_COMMENTLINE 125
|
||||
#define SCE_HPHP_STRINGEOL 126
|
||||
#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
|
||||
#define SCE_L_DEFAULT 0
|
||||
#define SCE_L_COMMAND 1
|
||||
#define SCE_L_TAG 2
|
||||
#define SCE_L_MATH 3
|
||||
#define SCE_L_COMMENT 4
|
||||
#define SCE_LUA_DEFAULT 0
|
||||
#define SCE_LUA_COMMENT 1
|
||||
#define SCE_LUA_COMMENTLINE 2
|
||||
#define SCE_LUA_COMMENTDOC 3
|
||||
#define SCE_LUA_NUMBER 4
|
||||
#define SCE_LUA_WORD 5
|
||||
#define SCE_LUA_STRING 6
|
||||
#define SCE_LUA_CHARACTER 7
|
||||
#define SCE_LUA_LITERALSTRING 8
|
||||
#define SCE_LUA_PREPROCESSOR 9
|
||||
#define SCE_LUA_OPERATOR 10
|
||||
#define SCE_LUA_IDENTIFIER 11
|
||||
#define SCE_LUA_STRINGEOL 12
|
||||
#define SCE_ERR_DEFAULT 0
|
||||
#define SCE_ERR_PYTHON 1
|
||||
#define SCE_ERR_GCC 2
|
||||
#define SCE_ERR_MS 3
|
||||
#define SCE_ERR_CMD 4
|
||||
#define SCE_ERR_BORLAND 5
|
||||
#define SCE_ERR_PERL 6
|
||||
//--Autogenerated -- end of section automatically generated from Scintilla.iface
|
||||
|
||||
#endif
|
||||
@@ -1,508 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// Scintilla.h - interface to the edit control
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
// Most of this file is automatically generated from the Scintilla.iface interface definition
|
||||
// file which contains any comments about the definitions. HFacer.py does the generation.
|
||||
|
||||
#ifndef SCINTILLA_H
|
||||
#define SCINTILLA_H
|
||||
|
||||
// Compile-time configuration options
|
||||
#define MACRO_SUPPORT 1 // Comment out to remove macro hooks
|
||||
|
||||
#if PLAT_WIN
|
||||
#ifdef STATIC_BUILD
|
||||
void Scintilla_RegisterClasses(HINSTANCE hInstance);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wParam, long lParam);
|
||||
|
||||
//++Autogenerated -- start of section automatically generated from Scintilla.iface
|
||||
#define INVALID_POSITION -1
|
||||
#define SCI_START 2000
|
||||
#define SCI_OPTIONAL_START 3000
|
||||
#define SCI_LEXER_START 4000
|
||||
#define SCI_ADDTEXT 2001
|
||||
#define SCI_ADDSTYLEDTEXT 2002
|
||||
#define SCI_INSERTTEXT 2003
|
||||
#define SCI_CLEARALL 2004
|
||||
#define SCI_CLEARDOCUMENTSTYLE 2005
|
||||
#define SCI_GETLENGTH 2006
|
||||
#define SCI_GETCHARAT 2007
|
||||
#define SCI_GETCURRENTPOS 2008
|
||||
#define SCI_GETANCHOR 2009
|
||||
#define SCI_GETSTYLEAT 2010
|
||||
#define SCI_REDO 2011
|
||||
#define SCI_SETUNDOCOLLECTION 2012
|
||||
#define SCI_SELECTALL 2013
|
||||
#define SCI_SETSAVEPOINT 2014
|
||||
#define SCI_GETSTYLEDTEXT 2015
|
||||
#define SCI_CANREDO 2016
|
||||
#define SCI_MARKERLINEFROMHANDLE 2017
|
||||
#define SCI_MARKERDELETEHANDLE 2018
|
||||
#define SCI_GETUNDOCOLLECTION 2019
|
||||
#define SCWS_INVISIBLE 0
|
||||
#define SCWS_VISIBLEALWAYS 1
|
||||
#define SCWS_VISIBLEAFTERINDENT 2
|
||||
#define SCI_GETVIEWWS 2020
|
||||
#define SCI_SETVIEWWS 2021
|
||||
#define SCI_POSITIONFROMPOINT 2022
|
||||
#define SCI_GOTOLINE 2024
|
||||
#define SCI_GOTOPOS 2025
|
||||
#define SCI_SETANCHOR 2026
|
||||
#define SCI_GETCURLINE 2027
|
||||
#define SCI_GETENDSTYLED 2028
|
||||
#define SCI_CONVERTEOLS 2029
|
||||
#define SC_EOL_CRLF 0
|
||||
#define SC_EOL_CR 1
|
||||
#define SC_EOL_LF 2
|
||||
#define SCI_GETEOLMODE 2030
|
||||
#define SCI_SETEOLMODE 2031
|
||||
#define SCI_STARTSTYLING 2032
|
||||
#define SCI_SETSTYLING 2033
|
||||
#define SCI_GETBUFFEREDDRAW 2034
|
||||
#define SCI_SETBUFFEREDDRAW 2035
|
||||
#define SCI_SETTABWIDTH 2036
|
||||
#define SCI_GETTABWIDTH 2121
|
||||
#define SC_CP_UTF8 65001
|
||||
#define SCI_SETCODEPAGE 2037
|
||||
#define SCI_SETUSEPALETTE 2039
|
||||
#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 SC_MARKNUM_FOLDER 30
|
||||
#define SC_MARKNUM_FOLDEROPEN 31
|
||||
#define SCI_MARKERDEFINE 2040
|
||||
#define SCI_MARKERSETFORE 2041
|
||||
#define SCI_MARKERSETBACK 2042
|
||||
#define SCI_MARKERADD 2043
|
||||
#define SCI_MARKERDELETE 2044
|
||||
#define SCI_MARKERDELETEALL 2045
|
||||
#define SCI_MARKERGET 2046
|
||||
#define SCI_MARKERNEXT 2047
|
||||
#define SCI_MARKERPREVIOUS 2048
|
||||
#define SC_MARGIN_SYMBOL 0
|
||||
#define SC_MARGIN_NUMBER 1
|
||||
#define SCI_SETMARGINTYPEN 2240
|
||||
#define SCI_GETMARGINTYPEN 2241
|
||||
#define SCI_SETMARGINWIDTHN 2242
|
||||
#define SCI_GETMARGINWIDTHN 2243
|
||||
#define SCI_SETMARGINMASKN 2244
|
||||
#define SCI_GETMARGINMASKN 2245
|
||||
#define SCI_SETMARGINSENSITIVEN 2246
|
||||
#define SCI_GETMARGINSENSITIVEN 2247
|
||||
#define STYLE_DEFAULT 32
|
||||
#define STYLE_LINENUMBER 33
|
||||
#define STYLE_BRACELIGHT 34
|
||||
#define STYLE_BRACEBAD 35
|
||||
#define STYLE_CONTROLCHAR 36
|
||||
#define STYLE_INDENTGUIDE 37
|
||||
#define STYLE_MAX 127
|
||||
#define SC_CHARSET_ANSI 0
|
||||
#define SC_CHARSET_DEFAULT 1
|
||||
#define SC_CHARSET_BALTIC 186
|
||||
#define SC_CHARSET_CHINESEBIG5 136
|
||||
#define SC_CHARSET_EASTEUROPE 238
|
||||
#define SC_CHARSET_GB2312 134
|
||||
#define SC_CHARSET_GREEK 161
|
||||
#define SC_CHARSET_HANGUL 129
|
||||
#define SC_CHARSET_MAC 77
|
||||
#define SC_CHARSET_OEM 255
|
||||
#define SC_CHARSET_RUSSIAN 204
|
||||
#define SC_CHARSET_SHIFTJIS 128
|
||||
#define SC_CHARSET_SYMBOL 2
|
||||
#define SC_CHARSET_TURKISH 162
|
||||
#define SC_CHARSET_JOHAB 130
|
||||
#define SC_CHARSET_HEBREW 177
|
||||
#define SC_CHARSET_ARABIC 178
|
||||
#define SC_CHARSET_VIETNAMESE 163
|
||||
#define SC_CHARSET_THAI 222
|
||||
#define SCI_STYLECLEARALL 2050
|
||||
#define SCI_STYLESETFORE 2051
|
||||
#define SCI_STYLESETBACK 2052
|
||||
#define SCI_STYLESETBOLD 2053
|
||||
#define SCI_STYLESETITALIC 2054
|
||||
#define SCI_STYLESETSIZE 2055
|
||||
#define SCI_STYLESETFONT 2056
|
||||
#define SCI_STYLESETEOLFILLED 2057
|
||||
#define SCI_STYLERESETDEFAULT 2058
|
||||
#define SCI_STYLESETUNDERLINE 2059
|
||||
#define SCI_STYLESETCHARACTERSET 2066
|
||||
#define SCI_SETSELFORE 2067
|
||||
#define SCI_SETSELBACK 2068
|
||||
#define SCI_SETCARETFORE 2069
|
||||
#define SCI_ASSIGNCMDKEY 2070
|
||||
#define SCI_CLEARCMDKEY 2071
|
||||
#define SCI_CLEARALLCMDKEYS 2072
|
||||
#define SCI_SETSTYLINGEX 2073
|
||||
#define SCI_STYLESETVISIBLE 2074
|
||||
#define SCI_GETCARETPERIOD 2075
|
||||
#define SCI_SETCARETPERIOD 2076
|
||||
#define SCI_SETWORDCHARS 2077
|
||||
#define SCI_BEGINUNDOACTION 2078
|
||||
#define SCI_ENDUNDOACTION 2079
|
||||
#define INDIC_MAX 7
|
||||
#define INDIC_PLAIN 0
|
||||
#define INDIC_SQUIGGLE 1
|
||||
#define INDIC_TT 2
|
||||
#define INDIC_DIAGONAL 3
|
||||
#define INDIC_STRIKE 4
|
||||
#define INDIC0_MASK 32
|
||||
#define INDIC1_MASK 64
|
||||
#define INDIC2_MASK 128
|
||||
#define INDICS_MASK INDIC0_MASK | INDIC1_MASK | INDIC2_MASK
|
||||
#define SCI_INDICSETSTYLE 2080
|
||||
#define SCI_INDICGETSTYLE 2081
|
||||
#define SCI_INDICSETFORE 2082
|
||||
#define SCI_INDICGETFORE 2083
|
||||
#define SCI_SETSTYLEBITS 2090
|
||||
#define SCI_GETSTYLEBITS 2091
|
||||
#define SCI_SETLINESTATE 2092
|
||||
#define SCI_GETLINESTATE 2093
|
||||
#define SCI_GETMAXLINESTATE 2094
|
||||
#define SCI_AUTOCSHOW 2100
|
||||
#define SCI_AUTOCCANCEL 2101
|
||||
#define SCI_AUTOCACTIVE 2102
|
||||
#define SCI_AUTOCPOSSTART 2103
|
||||
#define SCI_AUTOCCOMPLETE 2104
|
||||
#define SCI_AUTOCSTOPS 2105
|
||||
#define SCI_AUTOCSETSEPARATOR 2106
|
||||
#define SCI_AUTOCGETSEPARATOR 2107
|
||||
#define SCI_AUTOCSELECT 2108
|
||||
#define SCI_AUTOCSETCANCELATSTART 2110
|
||||
#define SCI_AUTOCGETCANCELATSTART 2111
|
||||
#define SCI_AUTOCSETFILLUPS 2112
|
||||
#define SCI_AUTOCSETCHOOSESINGLE 2113
|
||||
#define SCI_AUTOCGETCHOOSESINGLE 2114
|
||||
#define SCI_AUTOCSETIGNORECASE 2115
|
||||
#define SCI_AUTOCGETIGNORECASE 2116
|
||||
#define SCI_SETINDENT 2122
|
||||
#define SCI_GETINDENT 2123
|
||||
#define SCI_SETUSETABS 2124
|
||||
#define SCI_GETUSETABS 2125
|
||||
#define SCI_SETLINEINDENTATION 2126
|
||||
#define SCI_GETLINEINDENTATION 2127
|
||||
#define SCI_GETLINEINDENTPOSITION 2128
|
||||
#define SCI_GETCOLUMN 2129
|
||||
#define SCI_SETHSCROLLBAR 2130
|
||||
#define SCI_GETHSCROLLBAR 2131
|
||||
#define SCI_SETINDENTATIONGUIDES 2132
|
||||
#define SCI_GETINDENTATIONGUIDES 2133
|
||||
#define SCI_SETHIGHLIGHTGUIDE 2134
|
||||
#define SCI_GETHIGHLIGHTGUIDE 2135
|
||||
#define SCI_GETLINEENDPOSITION 2136
|
||||
#define SCI_GETCODEPAGE 2137
|
||||
#define SCI_GETCARETFORE 2138
|
||||
#define SCI_GETUSEPALETTE 2139
|
||||
#define SCI_GETREADONLY 2140
|
||||
#define SCI_SETCURRENTPOS 2141
|
||||
#define SCI_SETSELECTIONSTART 2142
|
||||
#define SCI_GETSELECTIONSTART 2143
|
||||
#define SCI_SETSELECTIONEND 2144
|
||||
#define SCI_GETSELECTIONEND 2145
|
||||
#define SCI_SETPRINTMAGNIFICATION 2146
|
||||
#define SCI_GETPRINTMAGNIFICATION 2147
|
||||
#define SC_PRINT_NORMAL 0
|
||||
#define SC_PRINT_INVERTLIGHT 1
|
||||
#define SC_PRINT_BLACKONWHITE 2
|
||||
#define SCI_SETPRINTCOLOURMODE 2148
|
||||
#define SCI_GETPRINTCOLOURMODE 2149
|
||||
#define SCFIND_DOWN 1
|
||||
#define SCFIND_WHOLEWORD 2
|
||||
#define SCFIND_MATCHCASE 4
|
||||
#define SCFIND_WORDSTART 0x00100000
|
||||
#define SCFIND_REGEXP 0x00200000
|
||||
#define SCI_FINDTEXT 2150
|
||||
#define SCI_FORMATRANGE 2151
|
||||
#define SCI_GETFIRSTVISIBLELINE 2152
|
||||
#define SCI_GETLINE 2153
|
||||
#define SCI_GETLINECOUNT 2154
|
||||
#define SCI_SETMARGINLEFT 2155
|
||||
#define SCI_GETMARGINLEFT 2156
|
||||
#define SCI_SETMARGINRIGHT 2157
|
||||
#define SCI_GETMARGINRIGHT 2158
|
||||
#define SCI_GETMODIFY 2159
|
||||
#define SCI_SETSEL 2160
|
||||
#define SCI_GETSELTEXT 2161
|
||||
#define SCI_GETTEXTRANGE 2162
|
||||
#define SCI_HIDESELECTION 2163
|
||||
#define SCI_POINTXFROMPOSITION 2164
|
||||
#define SCI_POINTYFROMPOSITION 2165
|
||||
#define SCI_LINEFROMPOSITION 2166
|
||||
#define SCI_POSITIONFROMLINE 2167
|
||||
#define SCI_LINESCROLL 2168
|
||||
#define SCI_SCROLLCARET 2169
|
||||
#define SCI_REPLACESEL 2170
|
||||
#define SCI_SETREADONLY 2171
|
||||
#define SCI_NULL 2172
|
||||
#define SCI_CANPASTE 2173
|
||||
#define SCI_CANUNDO 2174
|
||||
#define SCI_EMPTYUNDOBUFFER 2175
|
||||
#define SCI_UNDO 2176
|
||||
#define SCI_CUT 2177
|
||||
#define SCI_COPY 2178
|
||||
#define SCI_PASTE 2179
|
||||
#define SCI_CLEAR 2180
|
||||
#define SCI_SETTEXT 2181
|
||||
#define SCI_GETTEXT 2182
|
||||
#define SCI_GETTEXTLENGTH 2183
|
||||
#define SCI_GETDIRECTFUNCTION 2184
|
||||
#define SCI_GETDIRECTPOINTER 2185
|
||||
#define SCI_SETOVERTYPE 2186
|
||||
#define SCI_GETOVERTYPE 2187
|
||||
#define SCI_CALLTIPSHOW 2200
|
||||
#define SCI_CALLTIPCANCEL 2201
|
||||
#define SCI_CALLTIPACTIVE 2202
|
||||
#define SCI_CALLTIPPOSSTART 2203
|
||||
#define SCI_CALLTIPSETHLT 2204
|
||||
#define SCI_CALLTIPSETBACK 2205
|
||||
#define SCI_VISIBLEFROMDOCLINE 2220
|
||||
#define SCI_DOCLINEFROMVISIBLE 2221
|
||||
#define SC_FOLDLEVELBASE 0x400
|
||||
#define SC_FOLDLEVELWHITEFLAG 0x1000
|
||||
#define SC_FOLDLEVELHEADERFLAG 0x2000
|
||||
#define SC_FOLDLEVELNUMBERMASK 0x0FFF
|
||||
#define SCI_SETFOLDLEVEL 2222
|
||||
#define SCI_GETFOLDLEVEL 2223
|
||||
#define SCI_GETLASTCHILD 2224
|
||||
#define SCI_GETFOLDPARENT 2225
|
||||
#define SCI_SHOWLINES 2226
|
||||
#define SCI_HIDELINES 2227
|
||||
#define SCI_GETLINEVISIBLE 2228
|
||||
#define SCI_SETFOLDEXPANDED 2229
|
||||
#define SCI_GETFOLDEXPANDED 2230
|
||||
#define SCI_TOGGLEFOLD 2231
|
||||
#define SCI_ENSUREVISIBLE 2232
|
||||
#define SCI_SETFOLDFLAGS 2233
|
||||
#define SCI_LINEDOWN 2300
|
||||
#define SCI_LINEDOWNEXTEND 2301
|
||||
#define SCI_LINEUP 2302
|
||||
#define SCI_LINEUPEXTEND 2303
|
||||
#define SCI_CHARLEFT 2304
|
||||
#define SCI_CHARLEFTEXTEND 2305
|
||||
#define SCI_CHARRIGHT 2306
|
||||
#define SCI_CHARRIGHTEXTEND 2307
|
||||
#define SCI_WORDLEFT 2308
|
||||
#define SCI_WORDLEFTEXTEND 2309
|
||||
#define SCI_WORDRIGHT 2310
|
||||
#define SCI_WORDRIGHTEXTEND 2311
|
||||
#define SCI_HOME 2312
|
||||
#define SCI_HOMEEXTEND 2313
|
||||
#define SCI_LINEEND 2314
|
||||
#define SCI_LINEENDEXTEND 2315
|
||||
#define SCI_DOCUMENTSTART 2316
|
||||
#define SCI_DOCUMENTSTARTEXTEND 2317
|
||||
#define SCI_DOCUMENTEND 2318
|
||||
#define SCI_DOCUMENTENDEXTEND 2319
|
||||
#define SCI_PAGEUP 2320
|
||||
#define SCI_PAGEUPEXTEND 2321
|
||||
#define SCI_PAGEDOWN 2322
|
||||
#define SCI_PAGEDOWNEXTEND 2323
|
||||
#define SCI_EDITTOGGLEOVERTYPE 2324
|
||||
#define SCI_CANCEL 2325
|
||||
#define SCI_DELETEBACK 2326
|
||||
#define SCI_TAB 2327
|
||||
#define SCI_BACKTAB 2328
|
||||
#define SCI_NEWLINE 2329
|
||||
#define SCI_FORMFEED 2330
|
||||
#define SCI_VCHOME 2331
|
||||
#define SCI_VCHOMEEXTEND 2332
|
||||
#define SCI_ZOOMIN 2333
|
||||
#define SCI_ZOOMOUT 2334
|
||||
#define SCI_DELWORDLEFT 2335
|
||||
#define SCI_DELWORDRIGHT 2336
|
||||
#define SCI_LINECUT 2337
|
||||
#define SCI_LINEDELETE 2338
|
||||
#define SCI_LINETRANSPOSE 2339
|
||||
#define SCI_LOWERCASE 2340
|
||||
#define SCI_UPPERCASE 2341
|
||||
#define SCI_LINESCROLLDOWN 2342
|
||||
#define SCI_LINESCROLLUP 2343
|
||||
#define SCI_LINELENGTH 2350
|
||||
#define SCI_BRACEHIGHLIGHT 2351
|
||||
#define SCI_BRACEBADLIGHT 2352
|
||||
#define SCI_BRACEMATCH 2353
|
||||
#define SCI_GETVIEWEOL 2355
|
||||
#define SCI_SETVIEWEOL 2356
|
||||
#define SCI_GETDOCPOINTER 2357
|
||||
#define SCI_SETDOCPOINTER 2358
|
||||
#define SCI_SETMODEVENTMASK 2359
|
||||
#define EDGE_NONE 0
|
||||
#define EDGE_LINE 1
|
||||
#define EDGE_BACKGROUND 2
|
||||
#define SCI_GETEDGECOLUMN 2360
|
||||
#define SCI_SETEDGECOLUMN 2361
|
||||
#define SCI_GETEDGEMODE 2362
|
||||
#define SCI_SETEDGEMODE 2363
|
||||
#define SCI_GETEDGECOLOUR 2364
|
||||
#define SCI_SETEDGECOLOUR 2365
|
||||
#define SCI_SEARCHANCHOR 2366
|
||||
#define SCI_SEARCHNEXT 2367
|
||||
#define SCI_SEARCHPREV 2368
|
||||
#define CARET_SLOP 0x01
|
||||
#define CARET_CENTER 0x02
|
||||
#define CARET_STRICT 0x04
|
||||
#define SCI_SETCARETPOLICY 2369
|
||||
#define SCI_LINESONSCREEN 2370
|
||||
#define SCI_USEPOPUP 2371
|
||||
#define SCI_SELECTIONISRECTANGLE 2372
|
||||
#define SCI_SETZOOM 2373
|
||||
#define SCI_GETZOOM 2374
|
||||
#define SCI_CREATEDOCUMENT 2375
|
||||
#define SCI_ADDREFDOCUMENT 2376
|
||||
#define SCI_RELEASEDOCUMENT 2377
|
||||
#define SCI_GETMODEVENTMASK 2378
|
||||
#define SCI_GRABFOCUS 2400
|
||||
#define SCI_STARTRECORD 3001
|
||||
#define SCI_STOPRECORD 3002
|
||||
#define SCI_SETLEXER 4001
|
||||
#define SCI_GETLEXER 4002
|
||||
#define SCI_COLOURISE 4003
|
||||
#define SCI_SETPROPERTY 4004
|
||||
#define SCI_SETKEYWORDS 4005
|
||||
#define SC_MOD_INSERTTEXT 0x1
|
||||
#define SC_MOD_DELETETEXT 0x2
|
||||
#define SC_MOD_CHANGESTYLE 0x4
|
||||
#define SC_MOD_CHANGEFOLD 0x8
|
||||
#define SC_PERFORMED_USER 0x10
|
||||
#define SC_PERFORMED_UNDO 0x20
|
||||
#define SC_PERFORMED_REDO 0x40
|
||||
#define SC_LASTSTEPINUNDOREDO 0x100
|
||||
#define SC_MOD_CHANGEMARKER 0x200
|
||||
#define SC_MOD_BEFOREINSERT 0x400
|
||||
#define SC_MOD_BEFOREDELETE 0x800
|
||||
#define SC_MODEVENTMASKALL 0xF77
|
||||
#define SCEN_CHANGE 768
|
||||
#define SCEN_SETFOCUS 512
|
||||
#define SCEN_KILLFOCUS 256
|
||||
#define SCK_DOWN 300
|
||||
#define SCK_UP 301
|
||||
#define SCK_LEFT 302
|
||||
#define SCK_RIGHT 303
|
||||
#define SCK_HOME 304
|
||||
#define SCK_END 305
|
||||
#define SCK_PRIOR 306
|
||||
#define SCK_NEXT 307
|
||||
#define SCK_DELETE 308
|
||||
#define SCK_INSERT 309
|
||||
#define SCK_ESCAPE 7
|
||||
#define SCK_BACK 8
|
||||
#define SCK_TAB 9
|
||||
#define SCK_RETURN 13
|
||||
#define SCK_ADD 310
|
||||
#define SCK_SUBTRACT 311
|
||||
#define SCK_DIVIDE 312
|
||||
#define SCMOD_SHIFT 1
|
||||
#define SCMOD_CTRL 2
|
||||
#define SCMOD_ALT 4
|
||||
#define SCN_STYLENEEDED 2000
|
||||
#define SCN_CHARADDED 2001
|
||||
#define SCN_SAVEPOINTREACHED 2002
|
||||
#define SCN_SAVEPOINTLEFT 2003
|
||||
#define SCN_MODIFYATTEMPTRO 2004
|
||||
#define SCN_KEY 2005
|
||||
#define SCN_DOUBLECLICK 2006
|
||||
#define SCN_UPDATEUI 2007
|
||||
#define SCN_CHECKBRACE 2007
|
||||
#define SCN_MODIFIED 2008
|
||||
#define SCN_MACRORECORD 2009
|
||||
#define SCN_MARGINCLICK 2010
|
||||
#define SCN_NEEDSHOWN 2011
|
||||
#define SCN_POSCHANGED 2012
|
||||
//--Autogenerated -- end of section automatically generated from Scintilla.iface
|
||||
|
||||
// Optional module for macro recording
|
||||
#ifdef MACRO_SUPPORT
|
||||
typedef void (tMacroRecorder)(unsigned int iMessage, unsigned long wParam,
|
||||
long lParam, void *userData);
|
||||
#endif
|
||||
|
||||
// These structures are defined to be exactly the same shape as the Win32
|
||||
// CHARRANGE, TEXTRANGE, FINDTEXTEX, FORMATRANGE, and NMHDR structs.
|
||||
// So older code that treats Scintilla as a RichEdit will work.
|
||||
|
||||
struct CharacterRange {
|
||||
long cpMin;
|
||||
long cpMax;
|
||||
};
|
||||
|
||||
struct TextRange {
|
||||
CharacterRange chrg;
|
||||
char *lpstrText;
|
||||
};
|
||||
|
||||
struct TextToFind {
|
||||
CharacterRange chrg;
|
||||
char *lpstrText;
|
||||
CharacterRange chrgText;
|
||||
};
|
||||
|
||||
#ifdef PLATFORM_H
|
||||
|
||||
// This structure is used in printing and requires some of the graphics types
|
||||
// from Platform.h. Not needed by most client code.
|
||||
|
||||
struct RangeToFormat {
|
||||
SurfaceID hdc;
|
||||
SurfaceID hdcTarget;
|
||||
PRectangle rc;
|
||||
PRectangle rcPage;
|
||||
CharacterRange chrg;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
struct NotifyHeader {
|
||||
// hwndFrom is really an environment specifc window handle or pointer
|
||||
// but most clients of Scintilla.h do not have this type visible.
|
||||
//WindowID hwndFrom;
|
||||
void *hwndFrom;
|
||||
unsigned int idFrom;
|
||||
unsigned int code;
|
||||
};
|
||||
|
||||
struct SCNotification {
|
||||
NotifyHeader nmhdr;
|
||||
int position; // SCN_STYLENEEDED, SCN_MODIFIED
|
||||
int ch; // SCN_CHARADDED, SCN_KEY
|
||||
int modifiers; // SCN_KEY
|
||||
int modificationType; // SCN_MODIFIED
|
||||
const char *text; // SCN_MODIFIED
|
||||
int length; // SCN_MODIFIED
|
||||
int linesAdded; // SCN_MODIFIED
|
||||
#ifdef MACRO_SUPPORT
|
||||
int message; // SCN_MACRORECORD
|
||||
int wParam; // SCN_MACRORECORD
|
||||
int lParam; // SCN_MACRORECORD
|
||||
#endif
|
||||
int line; // SCN_MODIFIED
|
||||
int foldLevelNow; // SCN_MODIFIED
|
||||
int foldLevelPrev; // SCN_MODIFIED
|
||||
int margin; // SCN_MARGINCLICK
|
||||
};
|
||||
|
||||
#define SC_MASK_FOLDERS ((1<<SC_MARKNUM_FOLDER) | (1<<SC_MARKNUM_FOLDEROPEN))
|
||||
|
||||
// Deprecation section listing all API features that are deprecated and will
|
||||
// will be removed completely in a future version.
|
||||
// To enable these features define INCLUDE_DEPRECATED_FEATURES
|
||||
|
||||
#ifdef INCLUDE_DEPRECATED_FEATURES
|
||||
|
||||
// Deprecated in 1.27
|
||||
#define SC_UNDOCOLLECT_NONE 0
|
||||
#define SC_UNDOCOLLECT_AUTOSTART 1
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,46 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// ScintillaWidget.h - definition of Scintilla widget for GTK+
|
||||
// Only needed by GTK+ code but is harmless on other platforms.
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef SCINTILLAWIDGET_H
|
||||
#define SCINTILLAWIDGET_H
|
||||
|
||||
#if PLAT_GTK
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SCINTILLA(obj) GTK_CHECK_CAST (obj, scintilla_get_type (), ScintillaObject)
|
||||
#define SCINTILLA_CLASS(klass) GTK_CHECK_CLASS_CAST (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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,183 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// WinDefs.h - the subset of definitions from Windows needed by Scintilla for GTK+
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// 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
|
||||
|
||||
//#if 0
|
||||
/* RTF control */
|
||||
#define EM_CANPASTE (1074)
|
||||
#define EM_CANUNDO (198)
|
||||
#define EM_CHARFROMPOS (215)
|
||||
#define EM_EMPTYUNDOBUFFER (205)
|
||||
#define EM_EXGETSEL (1076)
|
||||
#define EM_EXLINEFROMCHAR (1078)
|
||||
#define EM_EXSETSEL (1079)
|
||||
#define EM_FINDTEXT (1080)
|
||||
#define EM_FINDTEXTEX (1103)
|
||||
#define EM_FORMATRANGE (1081)
|
||||
#define EM_GETFIRSTVISIBLELINE (206)
|
||||
#define EM_GETLINE (196)
|
||||
#define EM_GETLINECOUNT (186)
|
||||
#define EM_GETMARGINS (212)
|
||||
#define EM_GETMODIFY (184)
|
||||
#define EM_GETRECT (178)
|
||||
#define EM_GETSEL (176)
|
||||
#define EM_GETSELTEXT (1086)
|
||||
#define EM_GETTEXTRANGE (1099)
|
||||
#define EM_HIDESELECTION (1087)
|
||||
#define EM_LINEFROMCHAR (201)
|
||||
#define EM_LINEINDEX (187)
|
||||
#define EM_LINELENGTH (193)
|
||||
#define EM_LINESCROLL (182)
|
||||
#define EM_POSFROMCHAR (214)
|
||||
#define EM_REPLACESEL (194)
|
||||
#define EM_SCROLLCARET (183)
|
||||
#define EM_SELECTIONTYPE (1090)
|
||||
#define EM_SETMARGINS (211)
|
||||
#define EM_SETREADONLY (207)
|
||||
#define EM_SETSEL (177)
|
||||
#define EM_UNDO (199)
|
||||
|
||||
#define WM_NULL (0)
|
||||
#define WM_CLEAR (771)
|
||||
#define WM_COPY (769)
|
||||
#define WM_CUT (768)
|
||||
#define WM_GETTEXT (13)
|
||||
#define WM_GETTEXTLENGTH (14)
|
||||
#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
|
||||
|
||||
//#endif
|
||||
|
||||
#if 0
|
||||
#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
|
||||
#define VK_DIVIDE GDK_KP_Divide
|
||||
#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
|
||||
//TODO:
|
||||
#define VK_DIVIDE WXK_DIVIDE
|
||||
#endif
|
||||
|
||||
#define SHIFT_PRESSED 1
|
||||
#define LEFT_CTRL_PRESSED 2
|
||||
#define LEFT_ALT_PRESSED 4
|
||||
|
||||
// Are these needed any more
|
||||
#define LPSTR char *
|
||||
#define LONG long
|
||||
#define LPDWORD (long *)
|
||||
|
||||
/* SELCHANGE structure */
|
||||
#define SEL_EMPTY (0)
|
||||
#define SEL_TEXT (1)
|
||||
#define SEL_OBJECT (2)
|
||||
#define SEL_MULTICHAR (4)
|
||||
#define SEL_MULTIOBJECT (8)
|
||||
|
||||
struct RECT {
|
||||
LONG left;
|
||||
LONG top;
|
||||
LONG right;
|
||||
LONG bottom;
|
||||
};
|
||||
|
||||
/* FINDREPLACE structure */
|
||||
|
||||
#define FR_MATCHCASE (0x4)
|
||||
#define FR_WHOLEWORD (0x2)
|
||||
#define FR_DOWN (0x1)
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
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;
|
||||
};
|
||||
#endif
|
||||
|
||||
//#define MAKELONG(a, b) ((a) | ((b) << 16))
|
||||
//#define LOWORD(x) (x & 0xffff)
|
||||
//#define HIWORD(x) (x >> 16)
|
||||
|
||||
#endif
|
||||
@@ -1,47 +0,0 @@
|
||||
// WindowAccessor.h - implementation of BufferAccess and StylingAccess on a Scintilla rapid easy access to contents of a Scintilla
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
class WindowAccessor : public Accessor {
|
||||
// Private so WindowAccessor objects can not be copied
|
||||
WindowAccessor(const WindowAccessor &source) : Accessor(), props(source.props) {}
|
||||
WindowAccessor &operator=(const WindowAccessor &) { return *this; }
|
||||
protected:
|
||||
WindowID id;
|
||||
PropSet &props;
|
||||
int lenDoc;
|
||||
|
||||
char styleBuf[bufferSize];
|
||||
int validLen;
|
||||
char chFlags;
|
||||
char chWhile;
|
||||
unsigned int startSeg;
|
||||
|
||||
bool InternalIsLeadByte(char ch);
|
||||
void Fill(int position);
|
||||
public:
|
||||
WindowAccessor(WindowID id_, PropSet &props_) :
|
||||
Accessor(), id(id_), props(props_),
|
||||
lenDoc(-1), validLen(0), chFlags(0), chWhile(0) {
|
||||
}
|
||||
~WindowAccessor();
|
||||
char StyleAt(int position);
|
||||
int GetLine(int position);
|
||||
int LineStart(int line);
|
||||
int LevelAt(int line);
|
||||
int Length();
|
||||
void Flush();
|
||||
int GetLineState(int line);
|
||||
int SetLineState(int line, int state);
|
||||
int GetPropertyInt(const char *key, int defaultValue=0) {
|
||||
return props.GetInt(key, defaultValue);
|
||||
}
|
||||
|
||||
void StartAt(unsigned int start, char chMask=31);
|
||||
void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; };
|
||||
unsigned int GetStartSegment() { return startSeg; }
|
||||
void StartSegment(unsigned int pos);
|
||||
void ColourTo(unsigned int pos, int chAttr);
|
||||
void SetLevel(int line, int level);
|
||||
int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0);
|
||||
};
|
||||
@@ -1,121 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// AutoComplete.cxx - defines the auto completion list box
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "AutoComplete.h"
|
||||
|
||||
AutoComplete::AutoComplete() :
|
||||
active(false),
|
||||
separator(' '),
|
||||
ignoreCase(false),
|
||||
chooseSingle(false),
|
||||
posStart(0),
|
||||
startLen(0),
|
||||
cancelAtStartPos(true) {
|
||||
stopChars[0] = '\0';
|
||||
fillUpChars[0] = '\0';
|
||||
}
|
||||
|
||||
AutoComplete::~AutoComplete() {
|
||||
lb.Destroy();
|
||||
}
|
||||
|
||||
bool AutoComplete::Active() {
|
||||
return active;
|
||||
}
|
||||
|
||||
void AutoComplete::Start(Window &parent, int ctrlID, int position, int startLen_) {
|
||||
if (!lb.Created()) {
|
||||
lb.Create(parent, ctrlID);
|
||||
}
|
||||
lb.Clear();
|
||||
active = true;
|
||||
startLen = startLen_;
|
||||
posStart = position;
|
||||
}
|
||||
|
||||
void AutoComplete::SetStopChars(const char *stopChars_) {
|
||||
strncpy(stopChars, stopChars_, sizeof(stopChars));
|
||||
stopChars[sizeof(stopChars) - 1] = '\0';
|
||||
}
|
||||
|
||||
bool AutoComplete::IsStopChar(char ch) {
|
||||
return ch && strchr(stopChars, ch);
|
||||
}
|
||||
|
||||
void AutoComplete::SetFillUpChars(const char *fillUpChars_) {
|
||||
strncpy(fillUpChars, fillUpChars_, sizeof(fillUpChars));
|
||||
fillUpChars[sizeof(fillUpChars) - 1] = '\0';
|
||||
}
|
||||
|
||||
bool AutoComplete::IsFillUpChar(char ch) {
|
||||
return ch && strchr(fillUpChars, ch);
|
||||
}
|
||||
|
||||
void AutoComplete::SetSeparator(char separator_) {
|
||||
separator = separator_;
|
||||
}
|
||||
|
||||
char AutoComplete::GetSeparator() {
|
||||
return separator;
|
||||
}
|
||||
|
||||
void AutoComplete::SetList(const char *list) {
|
||||
lb.Clear();
|
||||
char *words = new char[strlen(list) + 1];
|
||||
if (words) {
|
||||
strcpy(words, list);
|
||||
char *startword = words;
|
||||
int i = 0;
|
||||
for (; words && words[i]; i++) {
|
||||
if (words[i] == separator) {
|
||||
words[i] = '\0';
|
||||
lb.Append(startword);
|
||||
startword = words + i + 1;
|
||||
}
|
||||
}
|
||||
if (startword) {
|
||||
lb.Append(startword);
|
||||
}
|
||||
delete []words;
|
||||
}
|
||||
lb.Sort();
|
||||
}
|
||||
|
||||
void AutoComplete::Show() {
|
||||
lb.Show();
|
||||
lb.Select(0);
|
||||
}
|
||||
|
||||
void AutoComplete::Cancel() {
|
||||
if (lb.Created()) {
|
||||
lb.Destroy();
|
||||
active = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AutoComplete::Move(int delta) {
|
||||
int count = lb.Length();
|
||||
int current = lb.GetSelection();
|
||||
current += delta;
|
||||
if (current >= count)
|
||||
current = count - 1;
|
||||
if (current < 0)
|
||||
current = 0;
|
||||
lb.Select(current);
|
||||
}
|
||||
|
||||
void AutoComplete::Select(const char *word) {
|
||||
int pos = lb.Find(word);
|
||||
//Platform::DebugPrintf("Autocompleting at <%s> %d\n", wordCurrent, pos);
|
||||
if (pos != -1)
|
||||
lb.Select(pos);
|
||||
}
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// AutoComplete.h - defines the auto completion list box
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef AUTOCOMPLETE_H
|
||||
#define AUTOCOMPLETE_H
|
||||
|
||||
class AutoComplete {
|
||||
bool active;
|
||||
char stopChars[256];
|
||||
char fillUpChars[256];
|
||||
char separator;
|
||||
public:
|
||||
bool ignoreCase;
|
||||
bool chooseSingle;
|
||||
ListBox lb;
|
||||
int posStart;
|
||||
int startLen;
|
||||
// Should autocompletion be canceled if editor's currentPos <= startPos?
|
||||
bool cancelAtStartPos;
|
||||
|
||||
AutoComplete();
|
||||
~AutoComplete();
|
||||
|
||||
// Is the auto completion list displayed?
|
||||
bool Active();
|
||||
|
||||
// Display the auto completion list positioned to be near a character position
|
||||
void Start(Window &parent, int ctrlID, int position, int startLen_);
|
||||
|
||||
// The stop chars are characters which, when typed, cause the auto completion list to disappear
|
||||
void SetStopChars(const char *stopChars_);
|
||||
bool IsStopChar(char ch);
|
||||
|
||||
// The fillup chars are characters which, when typed, fill up the selected word
|
||||
void SetFillUpChars(const char *fillUpChars_);
|
||||
bool IsFillUpChar(char ch);
|
||||
|
||||
// The separator character is used when interpreting the list in SetList
|
||||
void SetSeparator(char separator_);
|
||||
char GetSeparator();
|
||||
|
||||
// The list string contains a sequence of words separated by the separator character
|
||||
void SetList(const char *list);
|
||||
|
||||
void Show();
|
||||
void Cancel();
|
||||
|
||||
// Move the current list element by delta, scrolling appropriately
|
||||
void Move(int delta);
|
||||
|
||||
// Select a list element that starts with word as the current element
|
||||
void Select(const char *word);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,169 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// CallTip.cxx - code for displaying call tips
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "Scintilla.h"
|
||||
#include "CallTip.h"
|
||||
|
||||
CallTip::CallTip() {
|
||||
wCallTip = 0;
|
||||
inCallTipMode = false;
|
||||
posStartCallTip = 0;
|
||||
val = 0;
|
||||
startHighlight = 0;
|
||||
endHighlight = 0;
|
||||
|
||||
colourBG.desired = Colour(0xff, 0xff, 0xff);
|
||||
colourUnSel.desired = Colour(0x80, 0x80, 0x80);
|
||||
colourSel.desired = Colour(0, 0, 0x80);
|
||||
colourShade.desired = Colour(0, 0, 0);
|
||||
colourLight.desired = Colour(0xc0, 0xc0, 0xc0);
|
||||
}
|
||||
|
||||
CallTip::~CallTip() {
|
||||
wCallTip.Destroy();
|
||||
delete []val;
|
||||
val = 0;
|
||||
}
|
||||
|
||||
void CallTip::RefreshColourPalette(Palette &pal, bool want) {
|
||||
pal.WantFind(colourBG, want);
|
||||
pal.WantFind(colourUnSel, want);
|
||||
pal.WantFind(colourSel, want);
|
||||
pal.WantFind(colourShade, want);
|
||||
pal.WantFind(colourLight, want);
|
||||
}
|
||||
|
||||
void CallTip::PaintCT(Surface *surfaceWindow) {
|
||||
if (!val)
|
||||
return;
|
||||
PRectangle rcClientPos = wCallTip.GetClientPosition();
|
||||
PRectangle rcClientSize(0, 0, rcClientPos.right - rcClientPos.left,
|
||||
rcClientPos.bottom - rcClientPos.top);
|
||||
PRectangle rcClient(1, 1, rcClientSize.right - 1, rcClientSize.bottom - 1);
|
||||
|
||||
surfaceWindow->FillRectangle(rcClient, colourBG.allocated);
|
||||
// To make a nice small call tip window, it is only sized to fit most normal characters without accents
|
||||
int lineHeight = surfaceWindow->Height(font);
|
||||
int ascent = surfaceWindow->Ascent(font) - surfaceWindow->InternalLeading(font);
|
||||
|
||||
// For each line...
|
||||
// Draw the definition in three parts: before highlight, highlighted, after highlight
|
||||
int ytext = rcClient.top + ascent + 1;
|
||||
char *chunkVal = val;
|
||||
bool moreChunks = true;
|
||||
while (moreChunks) {
|
||||
char *chunkEnd = strchr(chunkVal, '\n');
|
||||
if (chunkEnd == NULL) {
|
||||
chunkEnd = chunkVal + strlen(chunkVal);
|
||||
moreChunks = false;
|
||||
}
|
||||
int chunkOffset = chunkVal - val;
|
||||
int chunkLength = chunkEnd - chunkVal;
|
||||
int chunkEndOffset = chunkOffset + chunkLength;
|
||||
int thisStartHighlight = Platform::Maximum(startHighlight, chunkOffset);
|
||||
thisStartHighlight = Platform::Minimum(thisStartHighlight, chunkEndOffset);
|
||||
thisStartHighlight -= chunkOffset;
|
||||
int thisEndHighlight = Platform::Maximum(endHighlight, chunkOffset);
|
||||
thisEndHighlight = Platform::Minimum(thisEndHighlight, chunkEndOffset);
|
||||
thisEndHighlight -= chunkOffset;
|
||||
int x = 5;
|
||||
int xEnd = x + surfaceWindow->WidthText(font, chunkVal, thisStartHighlight);
|
||||
rcClient.left = x;
|
||||
rcClient.top = ytext - ascent - 1;
|
||||
rcClient.right = xEnd;
|
||||
surfaceWindow->DrawText(rcClient, font, ytext,
|
||||
chunkVal, thisStartHighlight,
|
||||
colourUnSel.allocated, colourBG.allocated);
|
||||
x = xEnd;
|
||||
|
||||
xEnd = x + surfaceWindow->WidthText(font, chunkVal + thisStartHighlight,
|
||||
thisEndHighlight - thisStartHighlight);
|
||||
rcClient.top = ytext;
|
||||
rcClient.left = x;
|
||||
rcClient.right = xEnd;
|
||||
surfaceWindow->DrawText(rcClient, font, ytext,
|
||||
chunkVal + thisStartHighlight, thisEndHighlight - thisStartHighlight,
|
||||
colourSel.allocated, colourBG.allocated);
|
||||
x = xEnd;
|
||||
|
||||
xEnd = x + surfaceWindow->WidthText(font, chunkVal + thisEndHighlight,
|
||||
chunkLength - thisEndHighlight);
|
||||
rcClient.left = x;
|
||||
rcClient.right = xEnd;
|
||||
surfaceWindow->DrawText(rcClient, font, ytext,
|
||||
chunkVal + thisEndHighlight, chunkLength - thisEndHighlight,
|
||||
colourUnSel.allocated, colourBG.allocated);
|
||||
chunkVal = chunkEnd + 1;
|
||||
ytext += lineHeight;
|
||||
}
|
||||
// Draw a raised border around the edges of the window
|
||||
surfaceWindow->MoveTo(0, rcClientSize.bottom - 1);
|
||||
surfaceWindow->PenColour(colourShade.allocated);
|
||||
surfaceWindow->LineTo(rcClientSize.right - 1, rcClientSize.bottom - 1);
|
||||
surfaceWindow->LineTo(rcClientSize.right - 1, 0);
|
||||
surfaceWindow->PenColour(colourLight.allocated);
|
||||
surfaceWindow->LineTo(0, 0);
|
||||
surfaceWindow->LineTo(0, rcClientSize.bottom - 1);
|
||||
}
|
||||
|
||||
PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
|
||||
const char *faceName, int size) {
|
||||
Surface surfaceMeasure;
|
||||
surfaceMeasure.Init();
|
||||
int deviceHeight = (size * surfaceMeasure.LogPixelsY()) / 72;
|
||||
font.Create(faceName, SC_CHARSET_DEFAULT, deviceHeight, false, false);
|
||||
if (val)
|
||||
delete []val;
|
||||
val = new char[strlen(defn) + 1];
|
||||
if (!val)
|
||||
return PRectangle();
|
||||
strcpy(val, defn);
|
||||
startHighlight = 0;
|
||||
endHighlight = 0;
|
||||
inCallTipMode = true;
|
||||
posStartCallTip = pos;
|
||||
// Look for multiple lines in the text
|
||||
// Only support \n here - simply means container must avoid \r!
|
||||
int width = 0;
|
||||
int numLines = 1;
|
||||
const char *newline;
|
||||
const char *look = val;
|
||||
while ((newline = strchr(look, '\n')) != NULL) {
|
||||
int thisWidth = surfaceMeasure.WidthText(font, look, newline - look);
|
||||
width = Platform::Maximum(width, thisWidth);
|
||||
look = newline + 1;
|
||||
numLines++;
|
||||
}
|
||||
int lastWidth = surfaceMeasure.WidthText(font, look, strlen(look));
|
||||
width = Platform::Maximum(width, lastWidth) + 10;
|
||||
int lineHeight = surfaceMeasure.Height(font);
|
||||
// Extra line for border and an empty line at top and bottom
|
||||
int height = lineHeight * numLines - surfaceMeasure.InternalLeading(font) + 2 + 2;
|
||||
return PRectangle(pt.x -5, pt.y + lineHeight + 1, pt.x + width - 5, pt.y + lineHeight + 1 + height);
|
||||
}
|
||||
|
||||
|
||||
void CallTip::CallTipCancel() {
|
||||
inCallTipMode = false;
|
||||
if (wCallTip.Created()) {
|
||||
wCallTip.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
void CallTip::SetHighlight(int start, int end) {
|
||||
// Avoid flashing by checking something has really changed
|
||||
if ((start != startHighlight) || (end != endHighlight)) {
|
||||
startHighlight = start;
|
||||
endHighlight = end;
|
||||
if (wCallTip.Created()) {
|
||||
wCallTip.InvalidateAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// CallTip.h - interface to the call tip control
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef CALLTIP_H
|
||||
#define CALLTIP_H
|
||||
|
||||
class CallTip {
|
||||
int startHighlight;
|
||||
int endHighlight;
|
||||
char *val;
|
||||
Font font;
|
||||
// Private so CallTip objects can not be copied
|
||||
CallTip(const CallTip &) {}
|
||||
CallTip &operator=(const CallTip &) { return *this; }
|
||||
public:
|
||||
Window wCallTip;
|
||||
Window wDraw;
|
||||
bool inCallTipMode;
|
||||
int posStartCallTip;
|
||||
ColourPair colourBG;
|
||||
ColourPair colourUnSel;
|
||||
ColourPair colourSel;
|
||||
ColourPair colourShade;
|
||||
ColourPair colourLight;
|
||||
|
||||
CallTip();
|
||||
~CallTip();
|
||||
|
||||
// Claim or accept palette entries for the colours required to paint a calltip
|
||||
void RefreshColourPalette(Palette &pal, bool want);
|
||||
|
||||
void PaintCT(Surface *surfaceWindow);
|
||||
|
||||
// Setup the calltip and return a rectangle of the area required
|
||||
PRectangle CallTipStart(int pos, Point pt, const char *defn,
|
||||
const char *faceName, int size);
|
||||
|
||||
void CallTipCancel();
|
||||
|
||||
// Set a range of characters to be displayed in a highlight style.
|
||||
// Commonly used to highlight the current parameter.
|
||||
void SetHighlight(int start, int end);
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,229 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// CellBuffer.h - manages the text of the document
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef CELLBUFFER_H
|
||||
#define CELLBUFFER_H
|
||||
|
||||
// This holds the marker identifier and the marker type to display.
|
||||
// MarkerHandleNumbers are members of lists.
|
||||
struct MarkerHandleNumber {
|
||||
int handle;
|
||||
int number;
|
||||
MarkerHandleNumber *next;
|
||||
};
|
||||
|
||||
// A marker handle set contains any number of MarkerHandleNumbers
|
||||
class MarkerHandleSet {
|
||||
MarkerHandleNumber *root;
|
||||
public:
|
||||
MarkerHandleSet();
|
||||
~MarkerHandleSet();
|
||||
int Length();
|
||||
int NumberFromHandle(int handle);
|
||||
int MarkValue(); // Bit set of marker numbers
|
||||
bool Contains(int handle);
|
||||
bool InsertHandle(int handle, int markerNum);
|
||||
void RemoveHandle(int handle);
|
||||
void RemoveNumber(int markerNum);
|
||||
void CombineWith(MarkerHandleSet *other);
|
||||
};
|
||||
|
||||
// Each line stores the starting position of the first character of the line in the cell buffer
|
||||
// and potentially a marker handle set. Often a line will not have any attached markers.
|
||||
struct LineData {
|
||||
int startPosition;
|
||||
MarkerHandleSet *handleSet;
|
||||
LineData() : startPosition(0), handleSet(0) {
|
||||
}
|
||||
};
|
||||
|
||||
// The line vector contains information about each of the lines in a cell buffer.
|
||||
class LineVector {
|
||||
public:
|
||||
enum { growSize = 4000 };
|
||||
int lines;
|
||||
LineData *linesData;
|
||||
int size;
|
||||
int *levels;
|
||||
int sizeLevels;
|
||||
|
||||
// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big.
|
||||
int handleCurrent;
|
||||
|
||||
LineVector();
|
||||
~LineVector();
|
||||
void Init();
|
||||
|
||||
void Expand(int sizeNew);
|
||||
void ExpandLevels(int sizeNew=-1);
|
||||
void ClearLevels();
|
||||
void InsertValue(int pos, int value);
|
||||
void SetValue(int pos, int value);
|
||||
void Remove(int pos);
|
||||
int LineFromPosition(int pos);
|
||||
|
||||
int AddMark(int line, int marker);
|
||||
void MergeMarkers(int pos);
|
||||
void DeleteMark(int line, int markerNum);
|
||||
void DeleteMarkFromHandle(int markerHandle);
|
||||
int LineFromHandle(int markerHandle);
|
||||
};
|
||||
|
||||
// Actions are used to store all the information required to perform one undo/redo step.
|
||||
enum actionType { insertAction, removeAction, startAction };
|
||||
|
||||
class Action {
|
||||
public:
|
||||
actionType at;
|
||||
int position;
|
||||
char *data;
|
||||
int lenData;
|
||||
bool mayCoalesce;
|
||||
|
||||
Action();
|
||||
~Action();
|
||||
void Create(actionType at_, int position_=0, char *data_=0, int lenData_=0, bool mayCoalesce_=true);
|
||||
void Destroy();
|
||||
void Grab(Action *source);
|
||||
};
|
||||
|
||||
class UndoHistory {
|
||||
Action *actions;
|
||||
int lenActions;
|
||||
int maxAction;
|
||||
int currentAction;
|
||||
int undoSequenceDepth;
|
||||
int savePoint;
|
||||
|
||||
void EnsureUndoRoom();
|
||||
|
||||
public:
|
||||
UndoHistory();
|
||||
~UndoHistory();
|
||||
|
||||
void AppendAction(actionType at, int position, char *data, int length);
|
||||
|
||||
void BeginUndoAction();
|
||||
void EndUndoAction();
|
||||
void DropUndoSequence();
|
||||
void DeleteUndoHistory();
|
||||
|
||||
// The save point is a marker in the undo stack where the container has stated that
|
||||
// the buffer was saved. Undo and redo can move over the save point.
|
||||
void SetSavePoint();
|
||||
bool IsSavePoint() const;
|
||||
|
||||
// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
|
||||
// called that many times. Similarly for redo.
|
||||
bool CanUndo() const;
|
||||
int StartUndo();
|
||||
const Action &GetUndoStep() const;
|
||||
void CompletedUndoStep();
|
||||
bool CanRedo() const;
|
||||
int StartRedo();
|
||||
const Action &GetRedoStep() const;
|
||||
void CompletedRedoStep();
|
||||
};
|
||||
|
||||
// Holder for an expandable array of characters that supports undo and line markers
|
||||
// Based on article "Data Structures in a Bit-Mapped Text Editor"
|
||||
// by Wilfred J. Hansen, Byte January 1987, page 183
|
||||
class CellBuffer {
|
||||
private:
|
||||
char *body;
|
||||
int size;
|
||||
int length;
|
||||
int part1len;
|
||||
int gaplen;
|
||||
char *part2body;
|
||||
bool readOnly;
|
||||
|
||||
bool collectingUndo;
|
||||
UndoHistory uh;
|
||||
|
||||
LineVector lv;
|
||||
|
||||
SVector lineStates;
|
||||
|
||||
void GapTo(int position);
|
||||
void RoomFor(int insertionLength);
|
||||
|
||||
inline char ByteAt(int position);
|
||||
void SetByteAt(int position, char ch);
|
||||
|
||||
public:
|
||||
|
||||
CellBuffer(int initialLength = 4000);
|
||||
~CellBuffer();
|
||||
|
||||
// Retrieving positions outside the range of the buffer works and returns 0
|
||||
char CharAt(int position);
|
||||
void GetCharRange(char *buffer, int position, int lengthRetrieve);
|
||||
char StyleAt(int position);
|
||||
|
||||
int ByteLength();
|
||||
int Length();
|
||||
int Lines();
|
||||
int LineStart(int line);
|
||||
int LineFromPosition(int pos) { return lv.LineFromPosition(pos); }
|
||||
const char *InsertString(int position, char *s, int insertLength);
|
||||
void InsertCharStyle(int position, char ch, char style);
|
||||
|
||||
// Setting styles for positions outside the range of the buffer is safe and has no effect.
|
||||
// True is returned if the style of a character changed.
|
||||
bool SetStyleAt(int position, char style, char mask='\377');
|
||||
bool SetStyleFor(int position, int length, char style, char mask);
|
||||
|
||||
const char *DeleteChars(int position, int deleteLength);
|
||||
|
||||
bool IsReadOnly();
|
||||
void SetReadOnly(bool set);
|
||||
|
||||
// The save point is a marker in the undo stack where the container has stated that
|
||||
// the buffer was saved. Undo and redo can move over the save point.
|
||||
void SetSavePoint();
|
||||
bool IsSavePoint();
|
||||
|
||||
// Line marker functions
|
||||
int AddMark(int line, int markerNum);
|
||||
void DeleteMark(int line, int markerNum);
|
||||
void DeleteMarkFromHandle(int markerHandle);
|
||||
int GetMark(int line);
|
||||
void DeleteAllMarks(int markerNum);
|
||||
int LineFromHandle(int markerHandle);
|
||||
|
||||
// Without undo
|
||||
void BasicInsertString(int position, char *s, int insertLength);
|
||||
void BasicDeleteChars(int position, int deleteLength);
|
||||
|
||||
bool SetUndoCollection(bool collectUndo);
|
||||
bool IsCollectingUndo();
|
||||
void BeginUndoAction();
|
||||
void EndUndoAction();
|
||||
void DeleteUndoHistory();
|
||||
|
||||
// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
|
||||
// called that many times. Similarly for redo.
|
||||
bool CanUndo();
|
||||
int StartUndo();
|
||||
const Action &GetUndoStep() const;
|
||||
void PerformUndoStep();
|
||||
bool CanRedo();
|
||||
int StartRedo();
|
||||
const Action &GetRedoStep() const;
|
||||
void PerformRedoStep();
|
||||
|
||||
int SetLineState(int line, int state);
|
||||
int GetLineState(int line);
|
||||
int GetMaxLineState();
|
||||
|
||||
int SetLevel(int line, int level);
|
||||
int GetLevel(int line);
|
||||
void ClearLevels();
|
||||
};
|
||||
|
||||
#define CELL_SIZE 2
|
||||
|
||||
#endif
|
||||
@@ -1,208 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// ContractionState.cxx - manages visibility of lines for folding
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "ContractionState.h"
|
||||
|
||||
OneLine::OneLine() {
|
||||
displayLine = 0;
|
||||
docLine = 0;
|
||||
visible = true;
|
||||
expanded = true;
|
||||
}
|
||||
|
||||
ContractionState::ContractionState() {
|
||||
lines = 0;
|
||||
size = 0;
|
||||
linesInDoc = 1;
|
||||
linesInDisplay = 1;
|
||||
valid = false;
|
||||
}
|
||||
|
||||
ContractionState::~ContractionState() {
|
||||
Clear();
|
||||
}
|
||||
|
||||
void ContractionState::MakeValid() const {
|
||||
if (!valid) {
|
||||
// Could be cleverer by keeping the index of the last still valid entry
|
||||
// rather than invalidating all.
|
||||
int lineDisplay = 0;
|
||||
for (int line=0; line<linesInDoc; line++) {
|
||||
lines[line].displayLine = lineDisplay;
|
||||
if (lines[line].visible) {
|
||||
lines[lineDisplay].docLine = line;
|
||||
lineDisplay++;
|
||||
}
|
||||
}
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ContractionState::Clear() {
|
||||
delete []lines;
|
||||
lines = 0;
|
||||
size = 0;
|
||||
linesInDoc = 1;
|
||||
linesInDisplay = 1;
|
||||
}
|
||||
|
||||
int ContractionState::LinesInDoc() const {
|
||||
return linesInDoc;
|
||||
}
|
||||
|
||||
int ContractionState::LinesDisplayed() const {
|
||||
return linesInDisplay;
|
||||
}
|
||||
|
||||
int ContractionState::DisplayFromDoc(int lineDoc) const {
|
||||
if (size == 0) {
|
||||
return lineDoc;
|
||||
}
|
||||
MakeValid();
|
||||
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
|
||||
return lines[lineDoc].displayLine;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ContractionState::DocFromDisplay(int lineDisplay) const {
|
||||
if (lineDisplay <= 0)
|
||||
return 0;
|
||||
if (lineDisplay >= linesInDisplay)
|
||||
return linesInDoc-1;
|
||||
if (size == 0)
|
||||
return lineDisplay;
|
||||
MakeValid();
|
||||
return lines[lineDisplay].docLine;
|
||||
}
|
||||
|
||||
void ContractionState::Grow(int sizeNew) {
|
||||
OneLine *linesNew = new OneLine[sizeNew];
|
||||
if (linesNew) {
|
||||
int i = 0;
|
||||
for (; i < size; i++) {
|
||||
linesNew[i] = lines[i];
|
||||
}
|
||||
for (; i < sizeNew; i++) {
|
||||
linesNew[i].displayLine = i;
|
||||
}
|
||||
delete []lines;
|
||||
lines = linesNew;
|
||||
size = sizeNew;
|
||||
valid = false;
|
||||
} else {
|
||||
Platform::DebugPrintf("No memory available\n");
|
||||
// TODO: Blow up
|
||||
}
|
||||
}
|
||||
|
||||
void ContractionState::InsertLines(int lineDoc, int lineCount) {
|
||||
if (size == 0) {
|
||||
linesInDoc += lineCount;
|
||||
linesInDisplay += lineCount;
|
||||
return;
|
||||
}
|
||||
//Platform::DebugPrintf("InsertLine[%d] = %d\n", lineDoc);
|
||||
if ((linesInDoc + lineCount + 2) >= size) {
|
||||
Grow(linesInDoc + lineCount + growSize);
|
||||
}
|
||||
linesInDoc += lineCount;
|
||||
linesInDisplay += lineCount;
|
||||
for (int i = linesInDoc; i >= lineDoc + lineCount; i--) {
|
||||
lines[i].visible = lines[i - lineCount].visible;
|
||||
lines[i].expanded = lines[i - lineCount].expanded;
|
||||
}
|
||||
for (int d=0;d<lineCount;d++) {
|
||||
lines[lineDoc+d].visible = true; // Should inherit visibility from context ?
|
||||
lines[lineDoc+d].expanded = true;
|
||||
}
|
||||
valid = false;
|
||||
}
|
||||
|
||||
void ContractionState::DeleteLines(int lineDoc, int lineCount) {
|
||||
if (size == 0) {
|
||||
linesInDoc -= lineCount;
|
||||
linesInDisplay -= lineCount;
|
||||
return;
|
||||
}
|
||||
int deltaDisplayed = 0;
|
||||
for (int d=0;d<lineCount;d++) {
|
||||
if (lines[lineDoc+d].visible)
|
||||
deltaDisplayed--;
|
||||
}
|
||||
for (int i = lineDoc; i < linesInDoc-lineCount; i++) {
|
||||
if (i != 0) // Line zero is always visible
|
||||
lines[i].visible = lines[i + lineCount].visible;
|
||||
lines[i].expanded = lines[i + lineCount].expanded;
|
||||
}
|
||||
linesInDoc -= lineCount;
|
||||
linesInDisplay += deltaDisplayed;
|
||||
valid = false;
|
||||
}
|
||||
|
||||
bool ContractionState::GetVisible(int lineDoc) const {
|
||||
if (size == 0)
|
||||
return true;
|
||||
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
|
||||
return lines[lineDoc].visible;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible) {
|
||||
if (lineDocStart == 0)
|
||||
lineDocStart++;
|
||||
if (lineDocStart > lineDocEnd)
|
||||
return false;
|
||||
if (size == 0) {
|
||||
Grow(linesInDoc + growSize);
|
||||
}
|
||||
// TODO: modify docLine members to mirror displayLine
|
||||
int delta = 0;
|
||||
// Change lineDocs
|
||||
if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < linesInDoc)) {
|
||||
for (int line=lineDocStart; line <= lineDocEnd; line++) {
|
||||
if (lines[line].visible != visible) {
|
||||
delta += visible ? 1 : -1;
|
||||
lines[line].visible = visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
linesInDisplay += delta;
|
||||
valid = false;
|
||||
return delta != 0;
|
||||
}
|
||||
|
||||
bool ContractionState::GetExpanded(int lineDoc) const {
|
||||
if (size == 0)
|
||||
return true;
|
||||
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
|
||||
return lines[lineDoc].expanded;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ContractionState::SetExpanded(int lineDoc, bool expanded) {
|
||||
if (size == 0) {
|
||||
Grow(linesInDoc + growSize);
|
||||
}
|
||||
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
|
||||
if (lines[lineDoc].expanded != expanded) {
|
||||
lines[lineDoc].expanded = expanded;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ContractionState::ShowAll() {
|
||||
delete []lines;
|
||||
lines = 0;
|
||||
size = 0;
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// ContractionState.h - manages visibility of lines for folding
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef CONTRACTIONSTATE_H
|
||||
#define CONTRACTIONSTATE_H
|
||||
|
||||
class OneLine {
|
||||
public:
|
||||
int displayLine; // position within set of visible lines
|
||||
int docLine; // inverse of displayLine
|
||||
bool visible;
|
||||
bool expanded;
|
||||
|
||||
OneLine();
|
||||
virtual ~OneLine() {}
|
||||
};
|
||||
|
||||
class ContractionState {
|
||||
void Grow(int sizeNew);
|
||||
enum { growSize = 4000 };
|
||||
int linesInDoc;
|
||||
int linesInDisplay;
|
||||
mutable OneLine *lines;
|
||||
int size;
|
||||
mutable bool valid;
|
||||
void MakeValid() const;
|
||||
public:
|
||||
ContractionState();
|
||||
virtual ~ContractionState();
|
||||
|
||||
void Clear();
|
||||
|
||||
int LinesInDoc() const;
|
||||
int LinesDisplayed() const;
|
||||
int DisplayFromDoc(int lineDoc) const;
|
||||
int DocFromDisplay(int lineDisplay) const;
|
||||
|
||||
void InsertLines(int lineDoc, int lineCount);
|
||||
void DeleteLines(int lineDoc, int lineCount);
|
||||
|
||||
bool GetVisible(int lineDoc) const;
|
||||
bool SetVisible(int lineDocStart, int lineDocEnd, bool visible);
|
||||
|
||||
bool GetExpanded(int lineDoc) const;
|
||||
bool SetExpanded(int lineDoc, bool expanded);
|
||||
|
||||
void ShowAll();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,960 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// Document.cxx - text document that handles notifications, DBCS, styling, words and end of line
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "Scintilla.h"
|
||||
#include "SVector.h"
|
||||
#include "CellBuffer.h"
|
||||
#include "Document.h"
|
||||
|
||||
Document::Document() {
|
||||
refCount = 0;
|
||||
#ifdef unix
|
||||
eolMode = SC_EOL_LF;
|
||||
#else
|
||||
eolMode = SC_EOL_CRLF;
|
||||
#endif
|
||||
dbcsCodePage = 0;
|
||||
stylingBits = 5;
|
||||
stylingBitsMask = 0x1F;
|
||||
stylingPos = 0;
|
||||
stylingMask = 0;
|
||||
for (int ch = 0; ch < 256; ch++) {
|
||||
wordchars[ch] = isalnum(ch) || ch == '_';
|
||||
}
|
||||
endStyled = 0;
|
||||
enteredCount = 0;
|
||||
enteredReadOnlyCount = 0;
|
||||
tabInChars = 8;
|
||||
indentInChars = 0;
|
||||
useTabs = true;
|
||||
watchers = 0;
|
||||
lenWatchers = 0;
|
||||
}
|
||||
|
||||
Document::~Document() {
|
||||
for (int i = 0; i < lenWatchers; i++) {
|
||||
watchers[i].watcher->NotifyDeleted(this, watchers[i].userData);
|
||||
}
|
||||
delete []watchers;
|
||||
watchers = 0;
|
||||
lenWatchers = 0;
|
||||
}
|
||||
|
||||
// Increase reference count and return its previous value.
|
||||
int Document::AddRef() {
|
||||
return refCount++;
|
||||
}
|
||||
|
||||
// Decrease reference count and return its previous value.
|
||||
// Delete the document if reference count reaches zero.
|
||||
int Document::Release() {
|
||||
int curRefCount = --refCount;
|
||||
if (curRefCount == 0)
|
||||
delete this;
|
||||
return curRefCount;
|
||||
}
|
||||
|
||||
void Document::SetSavePoint() {
|
||||
cb.SetSavePoint();
|
||||
NotifySavePoint(true);
|
||||
}
|
||||
|
||||
int Document::AddMark(int line, int markerNum) {
|
||||
int prev = cb.AddMark(line, markerNum);
|
||||
DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0);
|
||||
NotifyModified(mh);
|
||||
return prev;
|
||||
}
|
||||
|
||||
void Document::DeleteMark(int line, int markerNum) {
|
||||
cb.DeleteMark(line, markerNum);
|
||||
DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0);
|
||||
NotifyModified(mh);
|
||||
}
|
||||
|
||||
void Document::DeleteMarkFromHandle(int markerHandle) {
|
||||
cb.DeleteMarkFromHandle(markerHandle);
|
||||
DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0);
|
||||
NotifyModified(mh);
|
||||
}
|
||||
|
||||
void Document::DeleteAllMarks(int markerNum) {
|
||||
cb.DeleteAllMarks(markerNum);
|
||||
DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0);
|
||||
NotifyModified(mh);
|
||||
}
|
||||
|
||||
int Document::LineStart(int line) {
|
||||
return cb.LineStart(line);
|
||||
}
|
||||
|
||||
int Document::LineEnd(int line) {
|
||||
if (line == LinesTotal() - 1) {
|
||||
return LineStart(line + 1);
|
||||
} else {
|
||||
int position = LineStart(line + 1) - 1;
|
||||
// When line terminator is CR+LF, may need to go back one more
|
||||
if ((position > LineStart(line)) && (cb.CharAt(position - 1) == '\r')) {
|
||||
position--;
|
||||
}
|
||||
return position;
|
||||
}
|
||||
}
|
||||
|
||||
int Document::LineFromPosition(int pos) {
|
||||
return cb.LineFromPosition(pos);
|
||||
}
|
||||
|
||||
int Document::LineEndPosition(int position) {
|
||||
return LineEnd(LineFromPosition(position));
|
||||
}
|
||||
|
||||
int Document::VCHomePosition(int position) {
|
||||
int line = LineFromPosition(position);
|
||||
int startPosition = LineStart(line);
|
||||
int endLine = LineStart(line + 1) - 1;
|
||||
int startText = startPosition;
|
||||
while (startText < endLine && (cb.CharAt(startText) == ' ' || cb.CharAt(startText) == '\t' ) )
|
||||
startText++;
|
||||
if (position == startText)
|
||||
return startPosition;
|
||||
else
|
||||
return startText;
|
||||
}
|
||||
|
||||
int Document::SetLevel(int line, int level) {
|
||||
int prev = cb.SetLevel(line, level);
|
||||
if (prev != level) {
|
||||
DocModification mh(SC_MOD_CHANGEFOLD, LineStart(line), 0, 0, 0);
|
||||
mh.line = line;
|
||||
mh.foldLevelNow = level;
|
||||
mh.foldLevelPrev = prev;
|
||||
NotifyModified(mh);
|
||||
}
|
||||
return prev;
|
||||
}
|
||||
|
||||
static bool IsSubordinate(int levelStart, int levelTry) {
|
||||
if (levelTry & SC_FOLDLEVELWHITEFLAG)
|
||||
return true;
|
||||
else
|
||||
return (levelStart & SC_FOLDLEVELNUMBERMASK) < (levelTry & SC_FOLDLEVELNUMBERMASK);
|
||||
}
|
||||
|
||||
int Document::GetLastChild(int lineParent, int level) {
|
||||
if (level == -1)
|
||||
level = GetLevel(lineParent) & SC_FOLDLEVELNUMBERMASK;
|
||||
int maxLine = LinesTotal();
|
||||
int lineMaxSubord = lineParent;
|
||||
while (lineMaxSubord < maxLine-1) {
|
||||
EnsureStyledTo(LineStart(lineMaxSubord+2));
|
||||
if (!IsSubordinate(level, GetLevel(lineMaxSubord+1)))
|
||||
break;
|
||||
lineMaxSubord++;
|
||||
}
|
||||
if (lineMaxSubord > lineParent) {
|
||||
if (level > (GetLevel(lineMaxSubord+1) & SC_FOLDLEVELNUMBERMASK)) {
|
||||
// Have chewed up some whitespace that belongs to a parent so seek back
|
||||
if ((lineMaxSubord > lineParent) && (GetLevel(lineMaxSubord) & SC_FOLDLEVELWHITEFLAG)) {
|
||||
lineMaxSubord--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return lineMaxSubord;
|
||||
}
|
||||
|
||||
int Document::GetFoldParent(int line) {
|
||||
int level = GetLevel(line);
|
||||
int lineLook = line-1;
|
||||
while ((lineLook > 0) && (
|
||||
(!(GetLevel(lineLook) & SC_FOLDLEVELHEADERFLAG)) ||
|
||||
((GetLevel(lineLook) & SC_FOLDLEVELNUMBERMASK) >= level))
|
||||
) {
|
||||
lineLook--;
|
||||
}
|
||||
if ((GetLevel(lineLook) & SC_FOLDLEVELHEADERFLAG) &&
|
||||
((GetLevel(lineLook) & SC_FOLDLEVELNUMBERMASK) < level)) {
|
||||
return lineLook;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int Document::ClampPositionIntoDocument(int pos) {
|
||||
return Platform::Clamp(pos, 0, Length());
|
||||
}
|
||||
|
||||
bool Document::IsCrLf(int pos) {
|
||||
if (pos < 0)
|
||||
return false;
|
||||
if (pos >= (Length() - 1))
|
||||
return false;
|
||||
return (cb.CharAt(pos) == '\r') && (cb.CharAt(pos + 1) == '\n');
|
||||
}
|
||||
|
||||
#if PLAT_WIN
|
||||
bool Document::IsDBCS(int pos) {
|
||||
if (dbcsCodePage) {
|
||||
if (SC_CP_UTF8 == dbcsCodePage) {
|
||||
unsigned char ch = static_cast<unsigned char>(cb.CharAt(pos));
|
||||
return ch >= 0x80;
|
||||
} else {
|
||||
// Anchor DBCS calculations at start of line because start of line can
|
||||
// not be a DBCS trail byte.
|
||||
int startLine = pos;
|
||||
while (startLine > 0 && cb.CharAt(startLine) != '\r' && cb.CharAt(startLine) != '\n')
|
||||
startLine--;
|
||||
while (startLine <= pos) {
|
||||
if (IsDBCSLeadByteEx(dbcsCodePage, cb.CharAt(startLine))) {
|
||||
startLine++;
|
||||
if (startLine >= pos)
|
||||
return true;
|
||||
}
|
||||
startLine++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
// PLAT_GTK or PLAT_WX
|
||||
// TODO: support DBCS under GTK+ and WX
|
||||
bool Document::IsDBCS(int) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
int Document::LenChar(int pos) {
|
||||
if (IsCrLf(pos)) {
|
||||
return 2;
|
||||
} else if (SC_CP_UTF8 == dbcsCodePage) {
|
||||
unsigned char ch = static_cast<unsigned char>(cb.CharAt(pos));
|
||||
if (ch < 0x80)
|
||||
return 1;
|
||||
int len = 2;
|
||||
if (ch >= (0x80+0x40+0x20))
|
||||
len = 3;
|
||||
int lengthDoc = Length();
|
||||
if ((pos + len) > lengthDoc)
|
||||
return lengthDoc-pos;
|
||||
else
|
||||
return len;
|
||||
} else if (IsDBCS(pos)) {
|
||||
return 2;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Normalise a position so that it is not halfway through a two byte character.
|
||||
// This can occur in two situations -
|
||||
// When lines are terminated with \r\n pairs which should be treated as one character.
|
||||
// When displaying DBCS text such as Japanese.
|
||||
// If moving, move the position in the indicated direction.
|
||||
int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) {
|
||||
//Platform::DebugPrintf("NoCRLF %d %d\n", pos, moveDir);
|
||||
// If out of range, just return value - should be fixed up after
|
||||
if (pos < 0)
|
||||
return pos;
|
||||
if (pos > Length())
|
||||
return pos;
|
||||
|
||||
// Position 0 and Length() can not be between any two characters
|
||||
if (pos == 0)
|
||||
return pos;
|
||||
if (pos == Length())
|
||||
return pos;
|
||||
|
||||
// assert pos > 0 && pos < Length()
|
||||
if (checkLineEnd && IsCrLf(pos - 1)) {
|
||||
if (moveDir > 0)
|
||||
return pos + 1;
|
||||
else
|
||||
return pos - 1;
|
||||
}
|
||||
|
||||
// Not between CR and LF
|
||||
|
||||
#if PLAT_WIN
|
||||
if (dbcsCodePage) {
|
||||
if (SC_CP_UTF8 == dbcsCodePage) {
|
||||
unsigned char ch = static_cast<unsigned char>(cb.CharAt(pos));
|
||||
while ((pos > 0) && (pos < Length()) && (ch >= 0x80) && (ch < (0x80 + 0x40))) {
|
||||
// ch is a trail byte
|
||||
if (moveDir > 0)
|
||||
pos++;
|
||||
else
|
||||
pos--;
|
||||
ch = static_cast<unsigned char>(cb.CharAt(pos));
|
||||
}
|
||||
} else {
|
||||
// Anchor DBCS calculations at start of line because start of line can
|
||||
// not be a DBCS trail byte.
|
||||
int startLine = pos;
|
||||
while (startLine > 0 && cb.CharAt(startLine) != '\r' && cb.CharAt(startLine) != '\n')
|
||||
startLine--;
|
||||
bool atLeadByte = false;
|
||||
while (startLine < pos) {
|
||||
if (atLeadByte)
|
||||
atLeadByte = false;
|
||||
else if (IsDBCSLeadByteEx(dbcsCodePage, cb.CharAt(startLine)))
|
||||
atLeadByte = true;
|
||||
else
|
||||
atLeadByte = false;
|
||||
startLine++;
|
||||
//Platform::DebugPrintf("DBCS %s\n", atlead ? "D" : "-");
|
||||
}
|
||||
|
||||
if (atLeadByte) {
|
||||
// Position is between a lead byte and a trail byte
|
||||
if (moveDir > 0)
|
||||
return pos + 1;
|
||||
else
|
||||
return pos - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
void Document::ModifiedAt(int pos) {
|
||||
if (endStyled > pos)
|
||||
endStyled = pos;
|
||||
}
|
||||
|
||||
// Document only modified by gateways DeleteChars, InsertStyledString, Undo, Redo, and SetStyleAt.
|
||||
// SetStyleAt does not change the persistent state of a document
|
||||
|
||||
// Unlike Undo, Redo, and InsertStyledString, the pos argument is a cell number not a char number
|
||||
void Document::DeleteChars(int pos, int len) {
|
||||
if ((pos + len) > Length())
|
||||
return;
|
||||
if (cb.IsReadOnly() && enteredReadOnlyCount==0) {
|
||||
enteredReadOnlyCount++;
|
||||
NotifyModifyAttempt();
|
||||
enteredReadOnlyCount--;
|
||||
}
|
||||
if (enteredCount == 0) {
|
||||
enteredCount++;
|
||||
if (!cb.IsReadOnly()) {
|
||||
NotifyModified(
|
||||
DocModification(
|
||||
SC_MOD_BEFOREDELETE | SC_PERFORMED_USER,
|
||||
pos, len,
|
||||
0, 0));
|
||||
int prevLinesTotal = LinesTotal();
|
||||
bool startSavePoint = cb.IsSavePoint();
|
||||
const char *text = cb.DeleteChars(pos*2, len * 2);
|
||||
if (startSavePoint && cb.IsCollectingUndo())
|
||||
NotifySavePoint(!startSavePoint);
|
||||
ModifiedAt(pos);
|
||||
NotifyModified(
|
||||
DocModification(
|
||||
SC_MOD_DELETETEXT | SC_PERFORMED_USER,
|
||||
pos, len,
|
||||
LinesTotal() - prevLinesTotal, text));
|
||||
}
|
||||
enteredCount--;
|
||||
}
|
||||
}
|
||||
|
||||
void Document::InsertStyledString(int position, char *s, int insertLength) {
|
||||
if (cb.IsReadOnly() && enteredReadOnlyCount==0) {
|
||||
enteredReadOnlyCount++;
|
||||
NotifyModifyAttempt();
|
||||
enteredReadOnlyCount--;
|
||||
}
|
||||
if (enteredCount == 0) {
|
||||
enteredCount++;
|
||||
if (!cb.IsReadOnly()) {
|
||||
NotifyModified(
|
||||
DocModification(
|
||||
SC_MOD_BEFOREINSERT | SC_PERFORMED_USER,
|
||||
position / 2, insertLength / 2,
|
||||
0, 0));
|
||||
int prevLinesTotal = LinesTotal();
|
||||
bool startSavePoint = cb.IsSavePoint();
|
||||
const char *text = cb.InsertString(position, s, insertLength);
|
||||
if (startSavePoint && cb.IsCollectingUndo())
|
||||
NotifySavePoint(!startSavePoint);
|
||||
ModifiedAt(position / 2);
|
||||
NotifyModified(
|
||||
DocModification(
|
||||
SC_MOD_INSERTTEXT | SC_PERFORMED_USER,
|
||||
position / 2, insertLength / 2,
|
||||
LinesTotal() - prevLinesTotal, text));
|
||||
}
|
||||
enteredCount--;
|
||||
}
|
||||
}
|
||||
|
||||
int Document::Undo() {
|
||||
int newPos = 0;
|
||||
if (enteredCount == 0) {
|
||||
enteredCount++;
|
||||
bool startSavePoint = cb.IsSavePoint();
|
||||
int steps = cb.StartUndo();
|
||||
//Platform::DebugPrintf("Steps=%d\n", steps);
|
||||
for (int step=0; step<steps; step++) {
|
||||
int prevLinesTotal = LinesTotal();
|
||||
const Action &action = cb.GetUndoStep();
|
||||
if (action.at == removeAction) {
|
||||
NotifyModified(DocModification(
|
||||
SC_MOD_BEFOREINSERT | SC_PERFORMED_UNDO, action));
|
||||
} else {
|
||||
NotifyModified(DocModification(
|
||||
SC_MOD_BEFOREDELETE | SC_PERFORMED_UNDO, action));
|
||||
}
|
||||
cb.PerformUndoStep();
|
||||
int cellPosition = action.position / 2;
|
||||
ModifiedAt(cellPosition);
|
||||
newPos = cellPosition;
|
||||
|
||||
int modFlags = SC_PERFORMED_UNDO;
|
||||
// With undo, an insertion action becomes a deletion notification
|
||||
if (action.at == removeAction) {
|
||||
newPos += action.lenData;
|
||||
modFlags |= SC_MOD_INSERTTEXT;
|
||||
} else {
|
||||
modFlags |= SC_MOD_DELETETEXT;
|
||||
}
|
||||
if (step == steps-1)
|
||||
modFlags |= SC_LASTSTEPINUNDOREDO;
|
||||
NotifyModified(DocModification(modFlags, cellPosition, action.lenData,
|
||||
LinesTotal() - prevLinesTotal, action.data));
|
||||
}
|
||||
|
||||
bool endSavePoint = cb.IsSavePoint();
|
||||
if (startSavePoint != endSavePoint)
|
||||
NotifySavePoint(endSavePoint);
|
||||
enteredCount--;
|
||||
}
|
||||
return newPos;
|
||||
}
|
||||
|
||||
int Document::Redo() {
|
||||
int newPos = 0;
|
||||
if (enteredCount == 0) {
|
||||
enteredCount++;
|
||||
bool startSavePoint = cb.IsSavePoint();
|
||||
int steps = cb.StartRedo();
|
||||
for (int step=0; step<steps; step++) {
|
||||
int prevLinesTotal = LinesTotal();
|
||||
const Action &action = cb.GetRedoStep();
|
||||
if (action.at == insertAction) {
|
||||
NotifyModified(DocModification(
|
||||
SC_MOD_BEFOREINSERT | SC_PERFORMED_REDO, action));
|
||||
} else {
|
||||
NotifyModified(DocModification(
|
||||
SC_MOD_BEFOREDELETE | SC_PERFORMED_REDO, action));
|
||||
}
|
||||
cb.PerformRedoStep();
|
||||
ModifiedAt(action.position / 2);
|
||||
newPos = action.position / 2;
|
||||
|
||||
int modFlags = SC_PERFORMED_REDO;
|
||||
if (action.at == insertAction) {
|
||||
newPos += action.lenData;
|
||||
modFlags |= SC_MOD_INSERTTEXT;
|
||||
} else {
|
||||
modFlags |= SC_MOD_DELETETEXT;
|
||||
}
|
||||
if (step == steps-1)
|
||||
modFlags |= SC_LASTSTEPINUNDOREDO;
|
||||
NotifyModified(
|
||||
DocModification(modFlags, action.position / 2, action.lenData,
|
||||
LinesTotal() - prevLinesTotal, action.data));
|
||||
}
|
||||
|
||||
bool endSavePoint = cb.IsSavePoint();
|
||||
if (startSavePoint != endSavePoint)
|
||||
NotifySavePoint(endSavePoint);
|
||||
enteredCount--;
|
||||
}
|
||||
return newPos;
|
||||
}
|
||||
|
||||
void Document::InsertChar(int pos, char ch) {
|
||||
char chs[2];
|
||||
chs[0] = ch;
|
||||
chs[1] = 0;
|
||||
InsertStyledString(pos*2, chs, 2);
|
||||
}
|
||||
|
||||
// Insert a null terminated string
|
||||
void Document::InsertString(int position, const char *s) {
|
||||
InsertString(position, s, strlen(s));
|
||||
}
|
||||
|
||||
// Insert a string with a length
|
||||
void Document::InsertString(int position, const char *s, int insertLength) {
|
||||
char *sWithStyle = new char[insertLength * 2];
|
||||
if (sWithStyle) {
|
||||
for (int i = 0; i < insertLength; i++) {
|
||||
sWithStyle[i*2] = s[i];
|
||||
sWithStyle[i*2 + 1] = 0;
|
||||
}
|
||||
InsertStyledString(position*2, sWithStyle, insertLength*2);
|
||||
delete []sWithStyle;
|
||||
}
|
||||
}
|
||||
|
||||
void Document::ChangeChar(int pos, char ch) {
|
||||
DeleteChars(pos, 1);
|
||||
InsertChar(pos, ch);
|
||||
}
|
||||
|
||||
void Document::DelChar(int pos) {
|
||||
DeleteChars(pos, LenChar(pos));
|
||||
}
|
||||
|
||||
int Document::DelCharBack(int pos) {
|
||||
if (pos <= 0) {
|
||||
return pos;
|
||||
} else if (IsCrLf(pos - 2)) {
|
||||
DeleteChars(pos - 2, 2);
|
||||
return pos - 2;
|
||||
} else if (SC_CP_UTF8 == dbcsCodePage) {
|
||||
int startChar = MovePositionOutsideChar(pos-1, -1, false);
|
||||
DeleteChars(startChar, pos - startChar);
|
||||
return startChar;
|
||||
} else if (IsDBCS(pos - 1)) {
|
||||
DeleteChars(pos - 2, 2);
|
||||
return pos - 2;
|
||||
} else {
|
||||
DeleteChars(pos - 1, 1);
|
||||
return pos - 1;
|
||||
}
|
||||
}
|
||||
|
||||
static bool isindentchar(char ch) {
|
||||
return (ch == ' ') || (ch == '\t');
|
||||
}
|
||||
|
||||
static int NextTab(int pos, int tabSize) {
|
||||
return ((pos / tabSize) + 1) * tabSize;
|
||||
}
|
||||
|
||||
static void CreateIndentation(char *linebuf, int length, int indent, int tabSize, bool insertSpaces) {
|
||||
length--; // ensure space for \0
|
||||
if (!insertSpaces) {
|
||||
while ((indent >= tabSize) && (length > 0)) {
|
||||
*linebuf++ = '\t';
|
||||
indent -= tabSize;
|
||||
length--;
|
||||
}
|
||||
}
|
||||
while ((indent > 0) && (length > 0)) {
|
||||
*linebuf++ = ' ';
|
||||
indent--;
|
||||
length--;
|
||||
}
|
||||
*linebuf = '\0';
|
||||
}
|
||||
|
||||
int Document::GetLineIndentation(int line) {
|
||||
int indent = 0;
|
||||
if ((line >= 0) && (line < LinesTotal())) {
|
||||
int lineStart = LineStart(line);
|
||||
int length = Length();
|
||||
for (int i=lineStart;i<length;i++) {
|
||||
char ch = cb.CharAt(i);
|
||||
if (ch == ' ')
|
||||
indent++;
|
||||
else if (ch == '\t')
|
||||
indent = NextTab(indent, tabInChars);
|
||||
else
|
||||
return indent;
|
||||
}
|
||||
}
|
||||
return indent;
|
||||
}
|
||||
|
||||
void Document::SetLineIndentation(int line, int indent) {
|
||||
int indentOfLine = GetLineIndentation(line);
|
||||
if (indent < 0)
|
||||
indent = 0;
|
||||
if (indent != indentOfLine) {
|
||||
char linebuf[1000];
|
||||
CreateIndentation(linebuf, sizeof(linebuf), indent, tabInChars, !useTabs);
|
||||
int thisLineStart = LineStart(line);
|
||||
int indentPos = GetLineIndentPosition(line);
|
||||
DeleteChars(thisLineStart, indentPos - thisLineStart);
|
||||
InsertString(thisLineStart, linebuf);
|
||||
}
|
||||
}
|
||||
|
||||
int Document::GetLineIndentPosition(int line) {
|
||||
if (line < 0)
|
||||
return 0;
|
||||
int pos = LineStart(line);
|
||||
int length = Length();
|
||||
while ((pos < length) && isindentchar(cb.CharAt(pos))) {
|
||||
pos++;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
int Document::GetColumn(int pos) {
|
||||
int column = 0;
|
||||
int line = LineFromPosition(pos);
|
||||
if ((line >= 0) && (line < LinesTotal())) {
|
||||
for (int i=LineStart(line);i<pos;i++) {
|
||||
char ch = cb.CharAt(i);
|
||||
if (ch == '\t')
|
||||
column = NextTab(column, tabInChars);
|
||||
else if (ch == '\r')
|
||||
return column;
|
||||
else if (ch == '\n')
|
||||
return column;
|
||||
else
|
||||
column++;
|
||||
}
|
||||
}
|
||||
return column;
|
||||
}
|
||||
|
||||
void Document::Indent(bool forwards, int lineBottom, int lineTop) {
|
||||
// Dedent - suck white space off the front of the line to dedent by equivalent of a tab
|
||||
for (int line = lineBottom; line >= lineTop; line--) {
|
||||
int indentOfLine = GetLineIndentation(line);
|
||||
if (forwards)
|
||||
SetLineIndentation(line, indentOfLine + IndentSize());
|
||||
else
|
||||
SetLineIndentation(line, indentOfLine - IndentSize());
|
||||
}
|
||||
}
|
||||
|
||||
void Document::ConvertLineEnds(int eolModeSet) {
|
||||
BeginUndoAction();
|
||||
for (int pos = 0; pos < Length(); pos++) {
|
||||
if (cb.CharAt(pos) == '\r') {
|
||||
if (cb.CharAt(pos+1) == '\n') {
|
||||
if (eolModeSet != SC_EOL_CRLF) {
|
||||
DeleteChars(pos, 2);
|
||||
if (eolModeSet == SC_EOL_CR)
|
||||
InsertString(pos, "\r", 1);
|
||||
else
|
||||
InsertString(pos, "\n", 1);
|
||||
} else {
|
||||
pos++;
|
||||
}
|
||||
} else {
|
||||
if (eolModeSet != SC_EOL_CR) {
|
||||
DeleteChars(pos, 1);
|
||||
if (eolModeSet == SC_EOL_CRLF) {
|
||||
InsertString(pos, "\r\n", 2);
|
||||
pos++;
|
||||
} else {
|
||||
InsertString(pos, "\n", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (cb.CharAt(pos) == '\n') {
|
||||
if (eolModeSet != SC_EOL_LF) {
|
||||
DeleteChars(pos, 1);
|
||||
if (eolModeSet == SC_EOL_CRLF) {
|
||||
InsertString(pos, "\r\n", 2);
|
||||
pos++;
|
||||
} else {
|
||||
InsertString(pos, "\r", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EndUndoAction();
|
||||
}
|
||||
|
||||
bool Document::IsWordChar(unsigned char ch) {
|
||||
if ((SC_CP_UTF8 == dbcsCodePage) && (ch >0x80))
|
||||
return true;
|
||||
return wordchars[ch];
|
||||
}
|
||||
|
||||
int Document::ExtendWordSelect(int pos, int delta) {
|
||||
if (delta < 0) {
|
||||
while (pos > 0 && IsWordChar(cb.CharAt(pos - 1)))
|
||||
pos--;
|
||||
} else {
|
||||
while (pos < (Length()) && IsWordChar(cb.CharAt(pos)))
|
||||
pos++;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
int Document::NextWordStart(int pos, int delta) {
|
||||
if (delta < 0) {
|
||||
while (pos > 0 && (cb.CharAt(pos - 1) == ' ' || cb.CharAt(pos - 1) == '\t'))
|
||||
pos--;
|
||||
if (isspace(cb.CharAt(pos - 1))) { // Back up to previous line
|
||||
while (pos > 0 && isspace(cb.CharAt(pos - 1)))
|
||||
pos--;
|
||||
} else {
|
||||
bool startAtWordChar = IsWordChar(cb.CharAt(pos - 1));
|
||||
while (pos > 0 && !isspace(cb.CharAt(pos - 1)) && (startAtWordChar == IsWordChar(cb.CharAt(pos - 1))))
|
||||
pos--;
|
||||
}
|
||||
} else {
|
||||
bool startAtWordChar = IsWordChar(cb.CharAt(pos));
|
||||
while (pos < (Length()) && isspace(cb.CharAt(pos)))
|
||||
pos++;
|
||||
while (pos < (Length()) && !isspace(cb.CharAt(pos)) && (startAtWordChar == IsWordChar(cb.CharAt(pos))))
|
||||
pos++;
|
||||
while (pos < (Length()) && (cb.CharAt(pos) == ' ' || cb.CharAt(pos) == '\t'))
|
||||
pos++;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
bool Document::IsWordStartAt(int pos) {
|
||||
if (pos > 0) {
|
||||
return !IsWordChar(CharAt(pos - 1));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Document::IsWordEndAt(int pos) {
|
||||
if (pos < Length() - 1) {
|
||||
return !IsWordChar(CharAt(pos));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Document::IsWordAt(int start, int end) {
|
||||
return IsWordStartAt(start) && IsWordEndAt(end);
|
||||
}
|
||||
|
||||
// Find text in document, supporting both forward and backward
|
||||
// searches (just pass minPos > maxPos to do a backward search)
|
||||
// Has not been tested with backwards DBCS searches yet.
|
||||
long Document::FindText(int minPos, int maxPos, const char *s,
|
||||
bool caseSensitive, bool word, bool wordStart) {
|
||||
bool forward = minPos <= maxPos;
|
||||
int increment = forward ? 1 : -1;
|
||||
|
||||
// Range endpoints should not be inside DBCS characters, but just in case, move them.
|
||||
int startPos = MovePositionOutsideChar(minPos, increment, false);
|
||||
int endPos = MovePositionOutsideChar(maxPos, increment, false);
|
||||
|
||||
// Compute actual search ranges needed
|
||||
int lengthFind = strlen(s);
|
||||
int endSearch = endPos;
|
||||
if (startPos <= endPos) {
|
||||
endSearch = endPos - lengthFind + 1;
|
||||
}
|
||||
//Platform::DebugPrintf("Find %d %d %s %d\n", startPos, endPos, ft->lpstrText, lengthFind);
|
||||
char firstChar = s[0];
|
||||
if (!caseSensitive)
|
||||
firstChar = static_cast<char>(toupper(firstChar));
|
||||
int pos = startPos;
|
||||
while (forward ? (pos < endSearch) : (pos >= endSearch)) {
|
||||
char ch = CharAt(pos);
|
||||
if (caseSensitive) {
|
||||
if (ch == firstChar) {
|
||||
bool found = true;
|
||||
for (int posMatch = 1; posMatch < lengthFind && found; posMatch++) {
|
||||
ch = CharAt(pos + posMatch);
|
||||
if (ch != s[posMatch])
|
||||
found = false;
|
||||
}
|
||||
if (found) {
|
||||
if ((!word && !wordStart) ||
|
||||
word && IsWordAt(pos, pos + lengthFind) ||
|
||||
wordStart && IsWordStartAt(pos))
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (toupper(ch) == firstChar) {
|
||||
bool found = true;
|
||||
for (int posMatch = 1; posMatch < lengthFind && found; posMatch++) {
|
||||
ch = CharAt(pos + posMatch);
|
||||
if (toupper(ch) != toupper(s[posMatch]))
|
||||
found = false;
|
||||
}
|
||||
if (found) {
|
||||
if (!(word && wordStart) ||
|
||||
word && IsWordAt(pos, pos + lengthFind) ||
|
||||
wordStart && IsWordStartAt(pos))
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
pos += increment;
|
||||
if (dbcsCodePage) {
|
||||
// Ensure trying to match from start of character
|
||||
pos = MovePositionOutsideChar(pos, increment, false);
|
||||
}
|
||||
}
|
||||
//Platform::DebugPrintf("Not found\n");
|
||||
return - 1;
|
||||
}
|
||||
|
||||
int Document::LinesTotal() {
|
||||
return cb.Lines();
|
||||
}
|
||||
|
||||
void Document::ChangeCase(Range r, bool makeUpperCase) {
|
||||
for (int pos=r.start; pos<r.end; pos++) {
|
||||
char ch = CharAt(pos);
|
||||
if (dbcsCodePage && IsDBCS(pos)) {
|
||||
pos += LenChar(pos);
|
||||
} else {
|
||||
if (makeUpperCase) {
|
||||
if (islower(ch)) {
|
||||
ChangeChar(pos, static_cast<char>(toupper(ch)));
|
||||
}
|
||||
} else {
|
||||
if (isupper(ch)) {
|
||||
ChangeChar(pos, static_cast<char>(tolower(ch)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Document::SetWordChars(unsigned char *chars) {
|
||||
int ch;
|
||||
for (ch = 0; ch < 256; ch++) {
|
||||
wordchars[ch] = false;
|
||||
}
|
||||
if (chars) {
|
||||
while (*chars) {
|
||||
wordchars[*chars] = true;
|
||||
chars++;
|
||||
}
|
||||
} else {
|
||||
for (ch = 0; ch < 256; ch++) {
|
||||
wordchars[ch] = isalnum(ch) || ch == '_';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Document::SetStylingBits(int bits) {
|
||||
stylingBits = bits;
|
||||
stylingBitsMask = 0;
|
||||
for (int bit=0; bit<stylingBits; bit++) {
|
||||
stylingBitsMask <<= 1;
|
||||
stylingBitsMask |= 1;
|
||||
}
|
||||
}
|
||||
|
||||
void Document::StartStyling(int position, char mask) {
|
||||
stylingPos = position;
|
||||
stylingMask = mask;
|
||||
}
|
||||
|
||||
void Document::SetStyleFor(int length, char style) {
|
||||
if (enteredCount == 0) {
|
||||
enteredCount++;
|
||||
int prevEndStyled = endStyled;
|
||||
if (cb.SetStyleFor(stylingPos, length, style, stylingMask)) {
|
||||
DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER,
|
||||
prevEndStyled, length);
|
||||
NotifyModified(mh);
|
||||
}
|
||||
stylingPos += length;
|
||||
endStyled = stylingPos;
|
||||
enteredCount--;
|
||||
}
|
||||
}
|
||||
|
||||
void Document::SetStyles(int length, char *styles) {
|
||||
if (enteredCount == 0) {
|
||||
enteredCount++;
|
||||
int prevEndStyled = endStyled;
|
||||
bool didChange = false;
|
||||
for (int iPos = 0; iPos < length; iPos++, stylingPos++) {
|
||||
if (cb.SetStyleAt(stylingPos, styles[iPos], stylingMask)) {
|
||||
didChange = true;
|
||||
}
|
||||
}
|
||||
endStyled = stylingPos;
|
||||
if (didChange) {
|
||||
DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER,
|
||||
prevEndStyled, endStyled - prevEndStyled);
|
||||
NotifyModified(mh);
|
||||
}
|
||||
enteredCount--;
|
||||
}
|
||||
}
|
||||
|
||||
bool Document::EnsureStyledTo(int pos) {
|
||||
// Ask the watchers to style, and stop as soon as one responds.
|
||||
for (int i = 0; pos > GetEndStyled() && i < lenWatchers; i++)
|
||||
watchers[i].watcher->NotifyStyleNeeded(this, watchers[i].userData, pos);
|
||||
return pos <= GetEndStyled();
|
||||
}
|
||||
|
||||
bool Document::AddWatcher(DocWatcher *watcher, void *userData) {
|
||||
for (int i = 0; i < lenWatchers; i++) {
|
||||
if ((watchers[i].watcher == watcher) &&
|
||||
(watchers[i].userData == userData))
|
||||
return false;
|
||||
}
|
||||
WatcherWithUserData *pwNew = new WatcherWithUserData[lenWatchers + 1];
|
||||
if (!pwNew)
|
||||
return false;
|
||||
for (int j = 0; j < lenWatchers; j++)
|
||||
pwNew[j] = watchers[j];
|
||||
pwNew[lenWatchers].watcher = watcher;
|
||||
pwNew[lenWatchers].userData = userData;
|
||||
delete []watchers;
|
||||
watchers = pwNew;
|
||||
lenWatchers++;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Document::RemoveWatcher(DocWatcher *watcher, void *userData) {
|
||||
for (int i = 0; i < lenWatchers; i++) {
|
||||
if ((watchers[i].watcher == watcher) &&
|
||||
(watchers[i].userData == userData)) {
|
||||
if (lenWatchers == 1) {
|
||||
delete []watchers;
|
||||
watchers = 0;
|
||||
lenWatchers = 0;
|
||||
} else {
|
||||
WatcherWithUserData *pwNew = new WatcherWithUserData[lenWatchers];
|
||||
if (!pwNew)
|
||||
return false;
|
||||
for (int j = 0; j < lenWatchers - 1; j++) {
|
||||
pwNew[j] = (j < i) ? watchers[j] : watchers[j + 1];
|
||||
}
|
||||
delete []watchers;
|
||||
watchers = pwNew;
|
||||
lenWatchers--;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Document::NotifyModifyAttempt() {
|
||||
for (int i = 0; i < lenWatchers; i++) {
|
||||
watchers[i].watcher->NotifyModifyAttempt(this, watchers[i].userData);
|
||||
}
|
||||
}
|
||||
|
||||
void Document::NotifySavePoint(bool atSavePoint) {
|
||||
for (int i = 0; i < lenWatchers; i++) {
|
||||
watchers[i].watcher->NotifySavePoint(this, watchers[i].userData, atSavePoint);
|
||||
}
|
||||
}
|
||||
|
||||
void Document::NotifyModified(DocModification mh) {
|
||||
for (int i = 0; i < lenWatchers; i++) {
|
||||
watchers[i].watcher->NotifyModified(this, mh, watchers[i].userData);
|
||||
}
|
||||
}
|
||||
@@ -1,255 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// Document.h - text document that handles notifications, DBCS, styling, words and end of line
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef DOCUMENT_H
|
||||
#define DOCUMENT_H
|
||||
|
||||
// A Position is a position within a document between two characters or at the beginning or end.
|
||||
// Sometimes used as a character index where it identifies the character after the position.
|
||||
typedef int Position;
|
||||
const Position invalidPosition = -1;
|
||||
|
||||
// The range class represents a range of text in a document.
|
||||
// The two values are not sorted as one end may be more significant than the other
|
||||
// as is the case for the selection where the end position is the position of the caret.
|
||||
// If either position is invalidPosition then the range is invalid and most operations will fail.
|
||||
class Range {
|
||||
public:
|
||||
Position start;
|
||||
Position end;
|
||||
|
||||
Range(Position pos=0) :
|
||||
start(pos), end(pos) {
|
||||
};
|
||||
Range(Position start_, Position end_) :
|
||||
start(start_), end(end_) {
|
||||
};
|
||||
|
||||
bool Valid() const {
|
||||
return (start != invalidPosition) && (end != invalidPosition);
|
||||
}
|
||||
|
||||
bool Contains(Position pos) const {
|
||||
if (start < end) {
|
||||
return (pos >= start && pos <= end);
|
||||
} else {
|
||||
return (pos <= start && pos >= end);
|
||||
}
|
||||
}
|
||||
|
||||
bool Contains(Range other) const {
|
||||
return Contains(other.start) && Contains(other.end);
|
||||
}
|
||||
|
||||
bool Overlaps(Range other) const {
|
||||
return
|
||||
Contains(other.start) ||
|
||||
Contains(other.end) ||
|
||||
other.Contains(start) ||
|
||||
other.Contains(end);
|
||||
}
|
||||
};
|
||||
|
||||
class DocWatcher;
|
||||
class DocModification;
|
||||
|
||||
class Document {
|
||||
|
||||
public:
|
||||
// Used to pair watcher pointer with user data
|
||||
class WatcherWithUserData {
|
||||
public:
|
||||
DocWatcher *watcher;
|
||||
void *userData;
|
||||
WatcherWithUserData() {
|
||||
watcher = 0;
|
||||
userData = 0;
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
int refCount;
|
||||
CellBuffer cb;
|
||||
bool wordchars[256];
|
||||
int stylingPos;
|
||||
char stylingMask;
|
||||
int endStyled;
|
||||
int enteredCount;
|
||||
int enteredReadOnlyCount;
|
||||
|
||||
WatcherWithUserData *watchers;
|
||||
int lenWatchers;
|
||||
|
||||
public:
|
||||
int stylingBits;
|
||||
int stylingBitsMask;
|
||||
|
||||
int eolMode;
|
||||
// dbcsCodePage can also be SC_CP_UTF8 to enable UTF-8 mode
|
||||
int dbcsCodePage;
|
||||
int tabInChars;
|
||||
int indentInChars;
|
||||
bool useTabs;
|
||||
|
||||
Document();
|
||||
virtual ~Document();
|
||||
|
||||
int AddRef();
|
||||
int Release();
|
||||
|
||||
int LineFromPosition(int pos);
|
||||
int ClampPositionIntoDocument(int pos);
|
||||
bool IsCrLf(int pos);
|
||||
int LenChar(int pos);
|
||||
int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true);
|
||||
|
||||
// Gateways to modifying document
|
||||
void DeleteChars(int pos, int len);
|
||||
void InsertStyledString(int position, char *s, int insertLength);
|
||||
int Undo();
|
||||
int Redo();
|
||||
bool CanUndo() { return cb.CanUndo(); }
|
||||
bool CanRedo() { return cb.CanRedo(); }
|
||||
void DeleteUndoHistory() { cb.DeleteUndoHistory(); }
|
||||
bool SetUndoCollection(bool collectUndo) {
|
||||
return cb.SetUndoCollection(collectUndo);
|
||||
}
|
||||
bool IsCollectingUndo() { return cb.IsCollectingUndo(); }
|
||||
void BeginUndoAction() { cb.BeginUndoAction(); }
|
||||
void EndUndoAction() { cb.EndUndoAction(); }
|
||||
void SetSavePoint();
|
||||
bool IsSavePoint() { return cb.IsSavePoint(); }
|
||||
|
||||
int GetLineIndentation(int line);
|
||||
void SetLineIndentation(int line, int indent);
|
||||
int GetLineIndentPosition(int line);
|
||||
int GetColumn(int position);
|
||||
void Indent(bool forwards, int lineBottom, int lineTop);
|
||||
void ConvertLineEnds(int eolModeSet);
|
||||
void SetReadOnly(bool set) { cb.SetReadOnly(set); }
|
||||
bool IsReadOnly() { return cb.IsReadOnly(); }
|
||||
|
||||
void InsertChar(int pos, char ch);
|
||||
void InsertString(int position, const char *s);
|
||||
void InsertString(int position, const char *s, int insertLength);
|
||||
void ChangeChar(int pos, char ch);
|
||||
void DelChar(int pos);
|
||||
int DelCharBack(int pos);
|
||||
|
||||
char CharAt(int position) { return cb.CharAt(position); }
|
||||
void GetCharRange(char *buffer, int position, int lengthRetrieve) {
|
||||
cb.GetCharRange(buffer, position, lengthRetrieve);
|
||||
}
|
||||
char StyleAt(int position) { return cb.StyleAt(position); }
|
||||
int GetMark(int line) { return cb.GetMark(line); }
|
||||
int AddMark(int line, int markerNum);
|
||||
void DeleteMark(int line, int markerNum);
|
||||
void DeleteMarkFromHandle(int markerHandle);
|
||||
void DeleteAllMarks(int markerNum);
|
||||
int LineFromHandle(int markerHandle) { return cb.LineFromHandle(markerHandle); }
|
||||
int LineStart(int line);
|
||||
int LineEnd(int line);
|
||||
int LineEndPosition(int position);
|
||||
int VCHomePosition(int position);
|
||||
|
||||
int SetLevel(int line, int level);
|
||||
int GetLevel(int line) { return cb.GetLevel(line); }
|
||||
void ClearLevels() { cb.ClearLevels(); }
|
||||
int GetLastChild(int lineParent, int level=-1);
|
||||
int GetFoldParent(int line);
|
||||
|
||||
void Indent(bool forwards);
|
||||
int ExtendWordSelect(int pos, int delta);
|
||||
int NextWordStart(int pos, int delta);
|
||||
int Length() { return cb.Length(); }
|
||||
long FindText(int minPos, int maxPos, const char *s,
|
||||
bool caseSensitive, bool word, bool wordStart);
|
||||
long FindText(int iMessage, unsigned long wParam, long lParam);
|
||||
int LinesTotal();
|
||||
|
||||
void ChangeCase(Range r, bool makeUpperCase);
|
||||
|
||||
void SetWordChars(unsigned char *chars);
|
||||
void SetStylingBits(int bits);
|
||||
void StartStyling(int position, char mask);
|
||||
void SetStyleFor(int length, char style);
|
||||
void SetStyles(int length, char *styles);
|
||||
int GetEndStyled() { return endStyled; }
|
||||
bool EnsureStyledTo(int pos);
|
||||
|
||||
int SetLineState(int line, int state) { return cb.SetLineState(line, state); }
|
||||
int GetLineState(int line) { return cb.GetLineState(line); }
|
||||
int GetMaxLineState() { return cb.GetMaxLineState(); }
|
||||
|
||||
bool AddWatcher(DocWatcher *watcher, void *userData);
|
||||
bool RemoveWatcher(DocWatcher *watcher, void *userData);
|
||||
const WatcherWithUserData *GetWatchers() const { return watchers; }
|
||||
int GetLenWatchers() const { return lenWatchers; }
|
||||
|
||||
private:
|
||||
bool IsDBCS(int pos);
|
||||
bool IsWordChar(unsigned char ch);
|
||||
bool IsWordStartAt(int pos);
|
||||
bool IsWordEndAt(int pos);
|
||||
bool IsWordAt(int start, int end);
|
||||
void ModifiedAt(int pos);
|
||||
|
||||
void NotifyModifyAttempt();
|
||||
void NotifySavePoint(bool atSavePoint);
|
||||
void NotifyModified(DocModification mh);
|
||||
|
||||
int IndentSize() { return indentInChars ? indentInChars : tabInChars; }
|
||||
};
|
||||
|
||||
// To optimise processing of document modifications by DocWatchers, a hint is passed indicating the
|
||||
// scope of the change.
|
||||
// If the DocWatcher is a document view then this can be used to optimise screen updating.
|
||||
class DocModification {
|
||||
public:
|
||||
int modificationType;
|
||||
int position;
|
||||
int length;
|
||||
int linesAdded; // Negative if lines deleted
|
||||
const char *text; // Only valid for changes to text, not for changes to style
|
||||
int line;
|
||||
int foldLevelNow;
|
||||
int foldLevelPrev;
|
||||
|
||||
DocModification(int modificationType_, int position_=0, int length_=0,
|
||||
int linesAdded_=0, const char *text_=0) :
|
||||
modificationType(modificationType_),
|
||||
position(position_),
|
||||
length(length_),
|
||||
linesAdded(linesAdded_),
|
||||
text(text_),
|
||||
line(0),
|
||||
foldLevelNow(0),
|
||||
foldLevelPrev(0) {}
|
||||
|
||||
DocModification(int modificationType_, const Action &act, int linesAdded_=0) :
|
||||
modificationType(modificationType_),
|
||||
position(act.position / 2),
|
||||
length(act.lenData),
|
||||
linesAdded(linesAdded_),
|
||||
text(act.data),
|
||||
line(0),
|
||||
foldLevelNow(0),
|
||||
foldLevelPrev(0) {}
|
||||
};
|
||||
|
||||
// A class that wants to receive notifications from a Document must be derived from DocWatcher
|
||||
// and implement the notification methods. It can then be added to the watcher list with AddWatcher.
|
||||
class DocWatcher {
|
||||
public:
|
||||
virtual ~DocWatcher() {}
|
||||
|
||||
virtual void NotifyModifyAttempt(Document *doc, void *userData) = 0;
|
||||
virtual void NotifySavePoint(Document *doc, void *userData, bool atSavePoint) = 0;
|
||||
virtual void NotifyModified(Document *doc, DocModification mh, void *userData) = 0;
|
||||
virtual void NotifyDeleted(Document *doc, void *userData) = 0;
|
||||
virtual void NotifyStyleNeeded(Document *doc, void *userData, int endPos) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,176 +0,0 @@
|
||||
// SciTE - Scintilla based Text Editor
|
||||
// Accessor.cxx - rapid easy access to contents of a Scintilla
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "PropSet.h"
|
||||
#include "SVector.h"
|
||||
#include "Accessor.h"
|
||||
#include "DocumentAccessor.h"
|
||||
#include "CellBuffer.h"
|
||||
#include "Scintilla.h"
|
||||
#include "Document.h"
|
||||
|
||||
DocumentAccessor::~DocumentAccessor() {
|
||||
}
|
||||
|
||||
#if PLAT_WIN
|
||||
bool DocumentAccessor::InternalIsLeadByte(char ch) {
|
||||
if (SC_CP_UTF8 == codePage)
|
||||
// For lexing, all characters >= 0x80 are treated the
|
||||
// same so none is considered a lead byte.
|
||||
return false;
|
||||
else
|
||||
return IsDBCSLeadByteEx(codePage, ch);
|
||||
}
|
||||
#else
|
||||
// PLAT_GTK or PLAT_WX
|
||||
// TODO: support DBCS under GTK+ and WX
|
||||
bool DocumentAccessor::InternalIsLeadByte(char) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
void DocumentAccessor::Fill(int position) {
|
||||
if (lenDoc == -1)
|
||||
lenDoc = pdoc->Length();
|
||||
startPos = position - slopSize;
|
||||
if (startPos + bufferSize > lenDoc)
|
||||
startPos = lenDoc - bufferSize;
|
||||
if (startPos < 0)
|
||||
startPos = 0;
|
||||
endPos = startPos + bufferSize;
|
||||
if (endPos > lenDoc)
|
||||
endPos = lenDoc;
|
||||
|
||||
pdoc->GetCharRange(buf, startPos, endPos-startPos);
|
||||
buf[endPos-startPos] = '\0';
|
||||
}
|
||||
|
||||
char DocumentAccessor::StyleAt(int position) {
|
||||
return pdoc->StyleAt(position);
|
||||
}
|
||||
|
||||
int DocumentAccessor::GetLine(int position) {
|
||||
return pdoc->LineFromPosition(position);
|
||||
}
|
||||
|
||||
int DocumentAccessor::LineStart(int line) {
|
||||
return pdoc->LineStart(line);
|
||||
}
|
||||
|
||||
int DocumentAccessor::LevelAt(int line) {
|
||||
return pdoc->GetLevel(line);
|
||||
}
|
||||
|
||||
int DocumentAccessor::Length() {
|
||||
if (lenDoc == -1)
|
||||
lenDoc = pdoc->Length();
|
||||
return lenDoc;
|
||||
}
|
||||
|
||||
int DocumentAccessor::GetLineState(int line) {
|
||||
return pdoc->GetLineState(line);
|
||||
}
|
||||
|
||||
int DocumentAccessor::SetLineState(int line, int state) {
|
||||
return pdoc->SetLineState(line, state);
|
||||
}
|
||||
|
||||
void DocumentAccessor::StartAt(unsigned int start, char chMask) {
|
||||
pdoc->StartStyling(start, chMask);
|
||||
}
|
||||
|
||||
void DocumentAccessor::StartSegment(unsigned int pos) {
|
||||
startSeg = pos;
|
||||
}
|
||||
|
||||
void DocumentAccessor::ColourTo(unsigned int pos, int chAttr) {
|
||||
// Only perform styling if non empty range
|
||||
if (pos != startSeg - 1) {
|
||||
if (pos < startSeg) {
|
||||
Platform::DebugPrintf("Bad colour positions %d - %d\n", startSeg, pos);
|
||||
}
|
||||
|
||||
if (validLen + (pos - startSeg + 1) >= bufferSize)
|
||||
Flush();
|
||||
if (validLen + (pos - startSeg + 1) >= bufferSize) {
|
||||
// Too big for buffer so send directly
|
||||
pdoc->SetStyleFor(pos - startSeg + 1, static_cast<char>(chAttr));
|
||||
} else {
|
||||
if (chAttr != chWhile)
|
||||
chFlags = 0;
|
||||
chAttr |= chFlags;
|
||||
for (unsigned int i = startSeg; i <= pos; i++) {
|
||||
styleBuf[validLen++] = static_cast<char>(chAttr);
|
||||
}
|
||||
}
|
||||
}
|
||||
startSeg = pos+1;
|
||||
}
|
||||
|
||||
void DocumentAccessor::SetLevel(int line, int level) {
|
||||
pdoc->SetLevel(line, level);
|
||||
}
|
||||
|
||||
void DocumentAccessor::Flush() {
|
||||
startPos = extremePosition;
|
||||
lenDoc = -1;
|
||||
if (validLen > 0) {
|
||||
pdoc->SetStyles(validLen, styleBuf);
|
||||
validLen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int DocumentAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader) {
|
||||
int end = Length();
|
||||
int spaceFlags = 0;
|
||||
|
||||
// Determines the indentation level of the current line and also checks for consistent
|
||||
// indentation compared to the previous line.
|
||||
// Indentation is judged consistent when the indentation whitespace of each line lines
|
||||
// the same or the indentation of one line is a prefix of the other.
|
||||
|
||||
int pos = LineStart(line);
|
||||
char ch = (*this)[pos];
|
||||
int indent = 0;
|
||||
bool inPrevPrefix = line > 0;
|
||||
int posPrev = inPrevPrefix ? LineStart(line-1) : 0;
|
||||
while ((ch == ' ' || ch == '\t') && (pos < end)) {
|
||||
if (inPrevPrefix) {
|
||||
char chPrev = (*this)[posPrev++];
|
||||
if (chPrev == ' ' || chPrev == '\t') {
|
||||
if (chPrev != ch)
|
||||
spaceFlags |= wsInconsistent;
|
||||
} else {
|
||||
inPrevPrefix = false;
|
||||
}
|
||||
}
|
||||
if (ch == ' ') {
|
||||
spaceFlags |= wsSpace;
|
||||
indent++;
|
||||
} else { // Tab
|
||||
spaceFlags |= wsTab;
|
||||
if (spaceFlags & wsSpace)
|
||||
spaceFlags |= wsSpaceTab;
|
||||
indent = (indent / 8 + 1) * 8;
|
||||
}
|
||||
ch = (*this)[++pos];
|
||||
}
|
||||
|
||||
*flags = spaceFlags;
|
||||
indent += SC_FOLDLEVELBASE;
|
||||
// if completely empty line or the start of a comment...
|
||||
if (isspace(ch) || (pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos)) )
|
||||
return indent | SC_FOLDLEVELWHITEFLAG;
|
||||
else
|
||||
return indent;
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
// DocumentAccessor.h - implementation of BufferAccess and StylingAccess on a Scintilla rapid easy access to contents of a Scintilla
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
class Document;
|
||||
|
||||
class DocumentAccessor : public Accessor {
|
||||
// Private so DocumentAccessor objects can not be copied
|
||||
DocumentAccessor(const DocumentAccessor &source) : Accessor(), props(source.props) {}
|
||||
DocumentAccessor &operator=(const DocumentAccessor &) { return *this; }
|
||||
protected:
|
||||
Document *pdoc;
|
||||
PropSet &props;
|
||||
int lenDoc;
|
||||
|
||||
char styleBuf[bufferSize];
|
||||
int validLen;
|
||||
char chFlags;
|
||||
char chWhile;
|
||||
unsigned int startSeg;
|
||||
|
||||
bool InternalIsLeadByte(char ch);
|
||||
void Fill(int position);
|
||||
public:
|
||||
DocumentAccessor(Document *pdoc_, PropSet &props_) :
|
||||
Accessor(), pdoc(pdoc_), props(props_),
|
||||
lenDoc(-1), validLen(0), chFlags(0), chWhile(0) {
|
||||
}
|
||||
~DocumentAccessor();
|
||||
char StyleAt(int position);
|
||||
int GetLine(int position);
|
||||
int LineStart(int line);
|
||||
int LevelAt(int line);
|
||||
int Length();
|
||||
void Flush();
|
||||
int GetLineState(int line);
|
||||
int SetLineState(int line, int state);
|
||||
int GetPropertyInt(const char *key, int defaultValue=0) {
|
||||
return props.GetInt(key, defaultValue);
|
||||
}
|
||||
|
||||
void StartAt(unsigned int start, char chMask=31);
|
||||
void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; };
|
||||
unsigned int GetStartSegment() { return startSeg; }
|
||||
void StartSegment(unsigned int pos);
|
||||
void ColourTo(unsigned int pos, int chAttr);
|
||||
void SetLevel(int line, int level);
|
||||
int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0);
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,308 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// Editor.h - defines the main editor class
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef EDITOR_H
|
||||
#define EDITOR_H
|
||||
|
||||
class Caret {
|
||||
public:
|
||||
bool active;
|
||||
bool on;
|
||||
int period;
|
||||
|
||||
Caret();
|
||||
};
|
||||
|
||||
class Timer {
|
||||
|
||||
public:
|
||||
bool ticking;
|
||||
int ticksToWait;
|
||||
enum {tickSize = 100};
|
||||
int tickerID;
|
||||
|
||||
Timer();
|
||||
};
|
||||
|
||||
class LineLayout {
|
||||
public:
|
||||
// Drawing is only performed for maxLineLength characters on each line.
|
||||
enum {maxLineLength = 4000};
|
||||
int numCharsInLine;
|
||||
int xHighlightGuide;
|
||||
bool highlightColumn;
|
||||
int selStart;
|
||||
int selEnd;
|
||||
int edgeColumn;
|
||||
char chars[maxLineLength+1];
|
||||
char styles[maxLineLength+1];
|
||||
char indicators[maxLineLength+1];
|
||||
int positions[maxLineLength+1];
|
||||
};
|
||||
|
||||
class Editor : public DocWatcher {
|
||||
// Private so Editor objects can not be copied
|
||||
Editor(const Editor &) : DocWatcher() {}
|
||||
Editor &operator=(const Editor &) { return *this; }
|
||||
protected: // ScintillaBase subclass needs access to much of Editor
|
||||
|
||||
// On GTK+, Scintilla is a container widget holding two scroll bars and a drawing area
|
||||
// whereas on Windows there is just one window with both scroll bars turned on.
|
||||
// Therefore, on GTK+ the following are separate windows but only one window on Windows.
|
||||
Window wMain; // The Scintilla parent window
|
||||
Window wDraw; // The text drawing area
|
||||
|
||||
// Style resources may be expensive to allocate so are cached between uses.
|
||||
// When a style attribute is changed, this cache is flushed.
|
||||
bool stylesValid;
|
||||
ViewStyle vs;
|
||||
Palette palette;
|
||||
int printMagnification;
|
||||
int printColourMode;
|
||||
|
||||
bool hideSelection;
|
||||
bool inOverstrike;
|
||||
|
||||
// In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to
|
||||
// the screen. This avoids flashing but is about 30% slower.
|
||||
bool bufferedDraw;
|
||||
|
||||
int xOffset; // Horizontal scrolled amount in pixels
|
||||
int xCaretMargin; // Ensure this many pixels visible on both sides of caret
|
||||
bool horizontalScrollBarVisible;
|
||||
|
||||
Surface pixmapLine;
|
||||
Surface pixmapSelMargin;
|
||||
Surface pixmapSelPattern;
|
||||
Surface pixmapIndentGuide;
|
||||
Surface pixmapIndentGuideHighlight;
|
||||
// Intellimouse support - currently only implemented for Windows
|
||||
unsigned int ucWheelScrollLines;
|
||||
int cWheelDelta; //wheel delta from roll
|
||||
|
||||
KeyMap kmap;
|
||||
|
||||
Caret caret;
|
||||
Timer timer;
|
||||
|
||||
Point lastClick;
|
||||
unsigned int lastClickTime;
|
||||
enum { selChar, selWord, selLine } selectionType;
|
||||
Point ptMouseLast;
|
||||
bool firstExpose;
|
||||
bool inDragDrop;
|
||||
bool dropWentOutside;
|
||||
int posDrag;
|
||||
int posDrop;
|
||||
int lastXChosen;
|
||||
int lineAnchor;
|
||||
int originalAnchorPos;
|
||||
int currentPos;
|
||||
int anchor;
|
||||
int topLine;
|
||||
int posTopLine;
|
||||
|
||||
bool needUpdateUI;
|
||||
Position braces[2];
|
||||
int bracesMatchStyle;
|
||||
int highlightGuideColumn;
|
||||
|
||||
int theEdge;
|
||||
|
||||
enum { notPainting, painting, paintAbandoned } paintState;
|
||||
PRectangle rcPaint;
|
||||
bool paintingAllText;
|
||||
|
||||
int modEventMask;
|
||||
|
||||
char *dragChars;
|
||||
int lenDrag;
|
||||
bool dragIsRectangle;
|
||||
enum { selStream, selRectangle, selRectangleFixed } selType;
|
||||
int xStartSelect;
|
||||
int xEndSelect;
|
||||
bool primarySelection;
|
||||
|
||||
int caretPolicy;
|
||||
int caretSlop;
|
||||
|
||||
int searchAnchor;
|
||||
|
||||
int displayPopupMenu;
|
||||
|
||||
#ifdef MACRO_SUPPORT
|
||||
int recordingMacro;
|
||||
#endif
|
||||
|
||||
int foldFlags;
|
||||
ContractionState cs;
|
||||
|
||||
Document *pdoc;
|
||||
|
||||
Editor();
|
||||
virtual ~Editor();
|
||||
virtual void Initialise() = 0;
|
||||
virtual void Finalise();
|
||||
|
||||
void InvalidateStyleData();
|
||||
void InvalidateStyleRedraw();
|
||||
virtual void RefreshColourPalette(Palette &pal, bool want);
|
||||
void RefreshStyleData();
|
||||
void DropGraphics();
|
||||
|
||||
PRectangle GetClientRectangle();
|
||||
PRectangle GetTextRectangle();
|
||||
|
||||
int LinesOnScreen();
|
||||
int LinesToScroll();
|
||||
int MaxScrollPos();
|
||||
Point LocationFromPosition(unsigned int pos);
|
||||
int XFromPosition(unsigned int pos);
|
||||
int PositionFromLocation(Point pt);
|
||||
int PositionFromLineX(int line, int x);
|
||||
int LineFromLocation(Point pt);
|
||||
void SetTopLine(int topLineNew);
|
||||
|
||||
void RedrawRect(PRectangle rc);
|
||||
void Redraw();
|
||||
void RedrawSelMargin();
|
||||
PRectangle RectangleFromRange(int start, int end);
|
||||
void InvalidateRange(int start, int end);
|
||||
|
||||
int CurrentPosition();
|
||||
bool SelectionEmpty();
|
||||
int SelectionStart(int line=-1);
|
||||
int SelectionEnd(int line=-1);
|
||||
void SetSelection(int currentPos_, int anchor_);
|
||||
void SetSelection(int currentPos_);
|
||||
void SetEmptySelection(int currentPos_);
|
||||
int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true);
|
||||
int MovePositionTo(int newPos, bool extend = false);
|
||||
int MovePositionSoVisible(int pos, int moveDir);
|
||||
void SetLastXChosen();
|
||||
|
||||
void ScrollTo(int line);
|
||||
virtual void ScrollText(int linesToMove);
|
||||
void HorizontalScrollTo(int xPos);
|
||||
void MoveCaretInsideView();
|
||||
void EnsureCaretVisible(bool useMargin=true);
|
||||
void ShowCaretAtCurrentPosition();
|
||||
void DropCaret();
|
||||
void InvalidateCaret();
|
||||
|
||||
void PaintSelMargin(Surface *surface, PRectangle &rc);
|
||||
void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout &ll);
|
||||
void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
|
||||
PRectangle rcLine, LineLayout &ll);
|
||||
void Paint(Surface *surfaceWindow, PRectangle rcArea);
|
||||
long FormatRange(bool draw, RangeToFormat *pfr);
|
||||
|
||||
virtual void SetVerticalScrollPos() = 0;
|
||||
virtual void SetHorizontalScrollPos() = 0;
|
||||
virtual bool ModifyScrollBars(int nMax, int nPage) = 0;
|
||||
virtual void ReconfigureScrollBars();
|
||||
void SetScrollBarsTo(PRectangle rsClient);
|
||||
void SetScrollBars();
|
||||
|
||||
void AddChar(char ch);
|
||||
virtual void AddCharUTF(char *s, unsigned int len);
|
||||
void ClearSelection();
|
||||
void ClearAll();
|
||||
void ClearDocumentStyle();
|
||||
void Cut();
|
||||
void PasteRectangular(int pos, const char *ptr, int len);
|
||||
virtual void Copy() = 0;
|
||||
virtual void Paste() = 0;
|
||||
void Clear();
|
||||
void SelectAll();
|
||||
void Undo();
|
||||
void Redo();
|
||||
void DelChar();
|
||||
void DelCharBack();
|
||||
virtual void ClaimSelection() = 0;
|
||||
|
||||
virtual void NotifyChange() = 0;
|
||||
virtual void NotifyFocus(bool focus);
|
||||
virtual void NotifyParent(SCNotification scn) = 0;
|
||||
virtual void NotifyStyleToNeeded(int endStyleNeeded);
|
||||
void NotifyChar(char ch);
|
||||
void NotifyMove(int position);
|
||||
void NotifySavePoint(bool isSavePoint);
|
||||
void NotifyModifyAttempt();
|
||||
virtual void NotifyDoubleClick(Point pt, bool shift);
|
||||
void NotifyUpdateUI();
|
||||
bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt);
|
||||
void NotifyNeedShown(int pos, int len);
|
||||
|
||||
void NotifyModifyAttempt(Document *document, void *userData);
|
||||
void NotifySavePoint(Document *document, void *userData, bool atSavePoint);
|
||||
void NotifyModified(Document *document, DocModification mh, void *userData);
|
||||
void NotifyDeleted(Document *document, void *userData);
|
||||
void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
|
||||
|
||||
|
||||
#ifdef MACRO_SUPPORT
|
||||
void NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long lParam);
|
||||
#endif
|
||||
|
||||
void PageMove(int direction, bool extend=false);
|
||||
void ChangeCaseOfSelection(bool makeUpperCase);
|
||||
void LineTranspose();
|
||||
virtual void CancelModes();
|
||||
virtual int KeyCommand(unsigned int iMessage);
|
||||
virtual int KeyDefault(int /* key */, int /*modifiers*/);
|
||||
int KeyDown(int key, bool shift, bool ctrl, bool alt);
|
||||
|
||||
int GetWhitespaceVisible();
|
||||
void SetWhitespaceVisible(int view);
|
||||
|
||||
void Indent(bool forwards);
|
||||
|
||||
long FindText(unsigned int iMessage, unsigned long wParam, long lParam);
|
||||
void SearchAnchor();
|
||||
long SearchText(unsigned int iMessage, unsigned long wParam, long lParam);
|
||||
void GoToLine(int lineNo);
|
||||
|
||||
char *CopyRange(int start, int end);
|
||||
int SelectionRangeLength();
|
||||
char *CopySelectionRange();
|
||||
void CopySelectionIntoDrag();
|
||||
void SetDragPosition(int newPos);
|
||||
virtual void StartDrag();
|
||||
void DropAt(int position, const char *value, bool moving, bool rectangular);
|
||||
// PositionInSelection returns 0 if position in selection, -1 if position before selection, and 1 if after.
|
||||
// Before means either before any line of selection or before selection on its line, with a similar meaning to after
|
||||
int PositionInSelection(int pos);
|
||||
bool PointInSelection(Point pt);
|
||||
bool PointInSelMargin(Point pt);
|
||||
virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
|
||||
void ButtonMove(Point pt);
|
||||
void ButtonUp(Point pt, unsigned int curTime, bool ctrl);
|
||||
|
||||
void Tick();
|
||||
virtual void SetTicking(bool on) = 0;
|
||||
virtual void SetMouseCapture(bool on) = 0;
|
||||
virtual bool HaveMouseCapture() = 0;
|
||||
|
||||
void CheckForChangeOutsidePaint(Range r);
|
||||
int BraceMatch(int position, int maxReStyle);
|
||||
void SetBraceHighlight(Position pos0, Position pos1, int matchStyle);
|
||||
|
||||
void SetDocPointer(Document *document);
|
||||
|
||||
void Expand(int &line, bool doExpand);
|
||||
void ToggleContraction(int line);
|
||||
void EnsureLineVisible(int line);
|
||||
|
||||
virtual long DefWndProc(unsigned int iMessage, unsigned long wParam, long lParam) = 0;
|
||||
|
||||
public:
|
||||
// Public so scintilla_send_message can use it
|
||||
virtual long WndProc(unsigned int iMessage, unsigned long wParam, long lParam);
|
||||
// Public so scintilla_set_id can use it
|
||||
int ctrlID;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,61 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// Indicator.cxx - defines the style of indicators which are text decorations such as underlining
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "Scintilla.h"
|
||||
#include "Indicator.h"
|
||||
|
||||
void Indicator::Draw(Surface *surface, PRectangle &rc) {
|
||||
surface->PenColour(fore.allocated);
|
||||
int ymid = (rc.bottom + rc.top) / 2;
|
||||
if (style == INDIC_SQUIGGLE) {
|
||||
surface->MoveTo(rc.left, rc.top);
|
||||
int x = rc.left + 2;
|
||||
int y = 2;
|
||||
while (x < rc.right) {
|
||||
surface->LineTo(x, rc.top + y);
|
||||
x += 2;
|
||||
y = 2 - y;
|
||||
}
|
||||
surface->LineTo(rc.right, rc.top + y); // Finish the line
|
||||
} else if (style == INDIC_TT) {
|
||||
surface->MoveTo(rc.left, ymid);
|
||||
int x = rc.left + 5;
|
||||
while (x < rc.right) {
|
||||
surface->LineTo(x, ymid);
|
||||
surface->MoveTo(x-3, ymid);
|
||||
surface->LineTo(x-3, ymid+2);
|
||||
x++;
|
||||
surface->MoveTo(x, ymid);
|
||||
x += 5;
|
||||
}
|
||||
surface->LineTo(rc.right, ymid); // Finish the line
|
||||
if (x - 3 <= rc.right) {
|
||||
surface->MoveTo(x-3, ymid);
|
||||
surface->LineTo(x-3, ymid+2);
|
||||
}
|
||||
} else if (style == INDIC_DIAGONAL) {
|
||||
int x = rc.left;
|
||||
while (x < rc.right) {
|
||||
surface->MoveTo(x, rc.top+2);
|
||||
int endX = x+3;
|
||||
int endY = rc.top - 1;
|
||||
if (endX > rc.right) {
|
||||
endY += endX - rc.right;
|
||||
endX = rc.right;
|
||||
}
|
||||
surface->LineTo(endX, endY);
|
||||
x += 4;
|
||||
}
|
||||
} else if (style == INDIC_STRIKE) {
|
||||
surface->MoveTo(rc.left, rc.top - 4);
|
||||
surface->LineTo(rc.right, rc.top - 4);
|
||||
} else { // Either INDIC_PLAIN or unknown
|
||||
surface->MoveTo(rc.left, ymid);
|
||||
surface->LineTo(rc.right, ymid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// Indicator.h - defines the style of indicators which are text decorations such as underlining
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef INDICATOR_H
|
||||
#define INDICATOR_H
|
||||
|
||||
class Indicator {
|
||||
public:
|
||||
int style;
|
||||
ColourPair fore;
|
||||
Indicator() : style(INDIC_PLAIN), fore(Colour(0,0,0)) {
|
||||
}
|
||||
void Draw(Surface *surface, PRectangle &rc);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,121 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// KeyMap.cxx - defines a mapping between keystrokes and commands
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "Scintilla.h"
|
||||
|
||||
#include "KeyMap.h"
|
||||
|
||||
KeyMap::KeyMap() : kmap(0), len(0), alloc(0) {
|
||||
for (int i = 0; MapDefault[i].key; i++) {
|
||||
AssignCmdKey(MapDefault[i].key,
|
||||
MapDefault[i].modifiers,
|
||||
MapDefault[i].msg);
|
||||
}
|
||||
}
|
||||
|
||||
KeyMap::~KeyMap() {
|
||||
Clear();
|
||||
}
|
||||
|
||||
void KeyMap::Clear() {
|
||||
delete []kmap;
|
||||
kmap = 0;
|
||||
len = 0;
|
||||
alloc = 0;
|
||||
}
|
||||
|
||||
void KeyMap::AssignCmdKey(int key, int modifiers, unsigned int msg) {
|
||||
if ((len+1) >= alloc) {
|
||||
KeyToCommand *ktcNew = new KeyToCommand[alloc + 5];
|
||||
if (!ktcNew)
|
||||
return;
|
||||
for (int k=0;k<len;k++)
|
||||
ktcNew[k] = kmap[k];
|
||||
alloc += 5;
|
||||
delete []kmap;
|
||||
kmap = ktcNew;
|
||||
}
|
||||
for (int keyIndex = 0; keyIndex < len; keyIndex++) {
|
||||
if ((key == kmap[keyIndex].key) && (modifiers == kmap[keyIndex].modifiers)) {
|
||||
kmap[keyIndex].msg = msg;
|
||||
return;
|
||||
}
|
||||
}
|
||||
kmap[len].key = key;
|
||||
kmap[len].modifiers = modifiers;
|
||||
kmap[len].msg = msg;
|
||||
len++;
|
||||
}
|
||||
|
||||
unsigned int KeyMap::Find(int key, int modifiers) {
|
||||
for (int i=0; i < len; i++) {
|
||||
if ((key == kmap[i].key) && (modifiers == kmap[i].modifiers)) {
|
||||
return kmap[i].msg;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
KeyToCommand KeyMap::MapDefault[] = {
|
||||
{SCK_DOWN, SCI_NORM, SCI_LINEDOWN},
|
||||
{SCK_DOWN, SCI_SHIFT, SCI_LINEDOWNEXTEND},
|
||||
{SCK_DOWN, SCI_CTRL, SCI_LINESCROLLDOWN},
|
||||
{SCK_UP, SCI_NORM, SCI_LINEUP},
|
||||
{SCK_UP, SCI_SHIFT, SCI_LINEUPEXTEND},
|
||||
{SCK_UP, SCI_CTRL, SCI_LINESCROLLUP},
|
||||
{SCK_LEFT, SCI_NORM, SCI_CHARLEFT},
|
||||
{SCK_LEFT, SCI_SHIFT, SCI_CHARLEFTEXTEND},
|
||||
{SCK_LEFT, SCI_CTRL, SCI_WORDLEFT},
|
||||
{SCK_LEFT, SCI_CSHIFT, SCI_WORDLEFTEXTEND},
|
||||
{SCK_RIGHT, SCI_NORM, SCI_CHARRIGHT},
|
||||
{SCK_RIGHT, SCI_SHIFT, SCI_CHARRIGHTEXTEND},
|
||||
{SCK_RIGHT, SCI_CTRL, SCI_WORDRIGHT},
|
||||
{SCK_RIGHT, SCI_CSHIFT, SCI_WORDRIGHTEXTEND},
|
||||
{SCK_HOME, SCI_NORM, SCI_VCHOME},
|
||||
{SCK_HOME, SCI_SHIFT, SCI_VCHOMEEXTEND},
|
||||
{SCK_HOME, SCI_CTRL, SCI_DOCUMENTSTART},
|
||||
{SCK_HOME, SCI_CSHIFT, SCI_DOCUMENTSTARTEXTEND},
|
||||
{SCK_END, SCI_NORM, SCI_LINEEND},
|
||||
{SCK_END, SCI_SHIFT, SCI_LINEENDEXTEND},
|
||||
{SCK_END, SCI_CTRL, SCI_DOCUMENTEND},
|
||||
{SCK_END, SCI_CSHIFT, SCI_DOCUMENTENDEXTEND},
|
||||
{SCK_PRIOR, SCI_NORM, SCI_PAGEUP},
|
||||
{SCK_PRIOR, SCI_SHIFT, SCI_PAGEUPEXTEND},
|
||||
{SCK_NEXT, SCI_NORM, SCI_PAGEDOWN},
|
||||
{SCK_NEXT, SCI_SHIFT, SCI_PAGEDOWNEXTEND},
|
||||
{SCK_DELETE, SCI_NORM, SCI_CLEAR},
|
||||
{SCK_DELETE, SCI_SHIFT, SCI_CUT},
|
||||
{SCK_DELETE, SCI_CTRL, SCI_DELWORDRIGHT},
|
||||
{SCK_INSERT, SCI_NORM, SCI_EDITTOGGLEOVERTYPE},
|
||||
{SCK_INSERT, SCI_SHIFT, SCI_PASTE},
|
||||
{SCK_INSERT, SCI_CTRL, SCI_COPY},
|
||||
{SCK_ESCAPE, SCI_NORM, SCI_CANCEL},
|
||||
{SCK_BACK, SCI_NORM, SCI_DELETEBACK},
|
||||
{SCK_BACK, SCI_SHIFT, SCI_DELETEBACK},
|
||||
{SCK_BACK, SCI_CTRL, SCI_DELWORDLEFT},
|
||||
{SCK_BACK, SCI_ALT, SCI_UNDO},
|
||||
{'Z', SCI_CTRL, SCI_UNDO},
|
||||
{'Y', SCI_CTRL, SCI_REDO},
|
||||
{'X', SCI_CTRL, SCI_CUT},
|
||||
{'C', SCI_CTRL, SCI_COPY},
|
||||
{'V', SCI_CTRL, SCI_PASTE},
|
||||
{'A', SCI_CTRL, SCI_SELECTALL},
|
||||
{SCK_TAB, SCI_NORM, SCI_TAB},
|
||||
{SCK_TAB, SCI_SHIFT, SCI_BACKTAB},
|
||||
{SCK_RETURN, SCI_NORM, SCI_NEWLINE},
|
||||
{SCK_ADD, SCI_CTRL, SCI_ZOOMIN},
|
||||
{SCK_SUBTRACT, SCI_CTRL, SCI_ZOOMOUT},
|
||||
{SCK_DIVIDE, SCI_CTRL, SCI_SETZOOM},
|
||||
//'L', SCI_CTRL, SCI_FORMFEED,
|
||||
{'L', SCI_CTRL, SCI_LINECUT},
|
||||
{'L', SCI_CSHIFT, SCI_LINEDELETE},
|
||||
{'T', SCI_CTRL, SCI_LINETRANSPOSE},
|
||||
{'U', SCI_CTRL, SCI_LOWERCASE},
|
||||
{'U', SCI_CSHIFT, SCI_UPPERCASE},
|
||||
{0,0,0},
|
||||
};
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// KeyMap.h - defines a mapping between keystrokes and commands
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef KEYTOCOMMAND_H
|
||||
#define KEYTOCOMMAND_H
|
||||
|
||||
#define SCI_NORM 0
|
||||
#define SCI_SHIFT SCMOD_SHIFT
|
||||
#define SCI_CTRL SCMOD_CTRL
|
||||
#define SCI_ALT SCMOD_ALT
|
||||
#define SCI_CSHIFT (SCI_CTRL | SCI_SHIFT)
|
||||
#define SCI_ASHIFT (SCI_ALT | SCI_SHIFT)
|
||||
|
||||
class KeyToCommand {
|
||||
public:
|
||||
int key;
|
||||
int modifiers;
|
||||
unsigned int msg;
|
||||
};
|
||||
|
||||
class KeyMap {
|
||||
KeyToCommand *kmap;
|
||||
int len;
|
||||
int alloc;
|
||||
static KeyToCommand MapDefault[];
|
||||
public:
|
||||
KeyMap();
|
||||
~KeyMap();
|
||||
void Clear();
|
||||
void AssignCmdKey(int key, int modifiers, unsigned int msg);
|
||||
unsigned int Find(int key, int modifiers); // 0 returned on failure
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,45 +0,0 @@
|
||||
// SciTE - Scintilla based Text Editor
|
||||
// KeyWords.cxx - colourise for particular languages
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
LexerModule *LexerModule::base = 0;
|
||||
|
||||
LexerModule::LexerModule(int language_, LexerFunction fn_) :
|
||||
language(language_), fn(fn_) {
|
||||
next = base;
|
||||
base = this;
|
||||
}
|
||||
|
||||
void LexerModule::Colourise(unsigned int startPos, int lengthDoc, int initStyle,
|
||||
int language, WordList *keywordlists[], Accessor &styler) {
|
||||
LexerModule *lm = base;
|
||||
while (lm) {
|
||||
if (lm->language == language) {
|
||||
lm->fn(startPos, lengthDoc, initStyle, keywordlists, styler);
|
||||
return;
|
||||
}
|
||||
lm = lm->next;
|
||||
}
|
||||
// Unknown language
|
||||
// Null language means all style bytes are 0 so just mark the end - no need to fill in.
|
||||
if (lengthDoc > 0) {
|
||||
styler.StartAt(startPos + lengthDoc - 1);
|
||||
styler.StartSegment(startPos + lengthDoc - 1);
|
||||
styler.ColourTo(startPos + lengthDoc - 1, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,262 +0,0 @@
|
||||
// SciTE - Scintilla based Text Editor
|
||||
// LexCPP.cxx - lexer for C++, C, Java, and Javascript
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
static bool classifyWordCpp(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
|
||||
char s[100];
|
||||
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
|
||||
s[i] = styler[start + i];
|
||||
s[i + 1] = '\0';
|
||||
}
|
||||
bool wordIsUUID = false;
|
||||
char chAttr = SCE_C_IDENTIFIER;
|
||||
if (isdigit(s[0]) || (s[0] == '.'))
|
||||
chAttr = SCE_C_NUMBER;
|
||||
else {
|
||||
if (keywords.InList(s)) {
|
||||
chAttr = SCE_C_WORD;
|
||||
wordIsUUID = strcmp(s, "uuid") == 0;
|
||||
}
|
||||
}
|
||||
styler.ColourTo(end, chAttr);
|
||||
return wordIsUUID;
|
||||
}
|
||||
|
||||
static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
|
||||
Accessor &styler) {
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
|
||||
styler.StartAt(startPos);
|
||||
|
||||
bool fold = styler.GetPropertyInt("fold");
|
||||
bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor");
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
|
||||
int levelCurrent = levelPrev;
|
||||
|
||||
int state = initStyle;
|
||||
if (state == SCE_C_STRINGEOL) // Does not leak onto next line
|
||||
state = SCE_C_DEFAULT;
|
||||
char chPrev = ' ';
|
||||
char chNext = styler[startPos];
|
||||
unsigned int lengthDoc = startPos + length;
|
||||
int visibleChars = 0;
|
||||
styler.StartSegment(startPos);
|
||||
bool lastWordWasUUID = false;
|
||||
for (unsigned int i = startPos; i < lengthDoc; i++) {
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
|
||||
if ((ch == '\r' && chNext != '\n') || (ch == '\n')) {
|
||||
// Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
|
||||
// Avoid triggering two times on Dos/Win
|
||||
// End of line
|
||||
if (state == SCE_C_STRINGEOL) {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
if (fold) {
|
||||
int lev = levelPrev;
|
||||
if (visibleChars == 0)
|
||||
lev |= SC_FOLDLEVELWHITEFLAG;
|
||||
if ((levelCurrent > levelPrev) && (visibleChars > 0))
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
lineCurrent++;
|
||||
levelPrev = levelCurrent;
|
||||
}
|
||||
visibleChars = 0;
|
||||
}
|
||||
if (!isspace(ch))
|
||||
visibleChars++;
|
||||
|
||||
if (styler.IsLeadByte(ch)) {
|
||||
chNext = styler.SafeGetCharAt(i + 2);
|
||||
chPrev = ' ';
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (state == SCE_C_DEFAULT) {
|
||||
if (ch == '@' && chNext == '\"') {
|
||||
styler.ColourTo(i-1, state);
|
||||
state = SCE_C_VERBATIM;
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
} else if (iswordstart(ch) || (ch == '@')) {
|
||||
styler.ColourTo(i-1, state);
|
||||
if (lastWordWasUUID) {
|
||||
state = SCE_C_UUID;
|
||||
lastWordWasUUID = false;
|
||||
} else {
|
||||
state = SCE_C_IDENTIFIER;
|
||||
}
|
||||
} else if (ch == '/' && chNext == '*') {
|
||||
styler.ColourTo(i-1, state);
|
||||
if (styler.SafeGetCharAt(i + 2) == '*')
|
||||
state = SCE_C_COMMENTDOC;
|
||||
else
|
||||
state = SCE_C_COMMENT;
|
||||
} else if (ch == '/' && chNext == '/') {
|
||||
styler.ColourTo(i-1, state);
|
||||
state = SCE_C_COMMENTLINE;
|
||||
} else if (ch == '\"') {
|
||||
styler.ColourTo(i-1, state);
|
||||
state = SCE_C_STRING;
|
||||
} else if (ch == '\'') {
|
||||
styler.ColourTo(i-1, state);
|
||||
state = SCE_C_CHARACTER;
|
||||
} else if (ch == '#' && visibleChars == 1) {
|
||||
// Preprocessor commands are alone on their line
|
||||
styler.ColourTo(i-1, state);
|
||||
state = SCE_C_PREPROCESSOR;
|
||||
// Skip whitespace between # and preprocessor word
|
||||
do {
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
} while (isspace(ch) && (i < lengthDoc));
|
||||
} else if (isoperator(ch)) {
|
||||
styler.ColourTo(i-1, state);
|
||||
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||
if ((ch == '{') || (ch == '}')) {
|
||||
levelCurrent += (ch == '{') ? 1 : -1;
|
||||
}
|
||||
}
|
||||
} else if (state == SCE_C_IDENTIFIER) {
|
||||
if (!iswordchar(ch)) {
|
||||
lastWordWasUUID = classifyWordCpp(styler.GetStartSegment(), i - 1, keywords, styler);
|
||||
state = SCE_C_DEFAULT;
|
||||
if (ch == '/' && chNext == '*') {
|
||||
if (styler.SafeGetCharAt(i + 2) == '*')
|
||||
state = SCE_C_COMMENTDOC;
|
||||
else
|
||||
state = SCE_C_COMMENT;
|
||||
} else if (ch == '/' && chNext == '/') {
|
||||
state = SCE_C_COMMENTLINE;
|
||||
} else if (ch == '\"') {
|
||||
state = SCE_C_STRING;
|
||||
} else if (ch == '\'') {
|
||||
state = SCE_C_CHARACTER;
|
||||
} else if (isoperator(ch)) {
|
||||
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||
if ((ch == '{') || (ch == '}')) {
|
||||
levelCurrent += (ch == '{') ? 1 : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (state == SCE_C_PREPROCESSOR) {
|
||||
if (stylingWithinPreprocessor) {
|
||||
if (isspace(ch)) {
|
||||
styler.ColourTo(i-1, state);
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
} else {
|
||||
if ((ch == '\r' || ch == '\n') && !(chPrev == '\\' || chPrev == '\r')) {
|
||||
styler.ColourTo(i-1, state);
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
}
|
||||
} else if (state == SCE_C_COMMENT) {
|
||||
if (ch == '/' && chPrev == '*') {
|
||||
if (((i > styler.GetStartSegment() + 2) || (
|
||||
(initStyle == SCE_C_COMMENT) &&
|
||||
(styler.GetStartSegment() == static_cast<unsigned int>(startPos))))) {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
}
|
||||
} else if (state == SCE_C_COMMENTDOC) {
|
||||
if (ch == '/' && chPrev == '*') {
|
||||
if (((i > styler.GetStartSegment() + 2) || (
|
||||
(initStyle == SCE_C_COMMENTDOC) &&
|
||||
(styler.GetStartSegment() == static_cast<unsigned int>(startPos))))) {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
}
|
||||
} else if (state == SCE_C_COMMENTLINE) {
|
||||
if (ch == '\r' || ch == '\n') {
|
||||
styler.ColourTo(i-1, state);
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
} else if (state == SCE_C_STRING) {
|
||||
if (ch == '\\') {
|
||||
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
} else if (ch == '\"') {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_C_DEFAULT;
|
||||
} else if (chNext == '\r' || chNext == '\n') {
|
||||
styler.ColourTo(i-1, SCE_C_STRINGEOL);
|
||||
state = SCE_C_STRINGEOL;
|
||||
}
|
||||
} else if (state == SCE_C_CHARACTER) {
|
||||
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
|
||||
styler.ColourTo(i-1, SCE_C_STRINGEOL);
|
||||
state = SCE_C_STRINGEOL;
|
||||
} else if (ch == '\\') {
|
||||
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
} else if (ch == '\'') {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
} else if (state == SCE_C_VERBATIM) {
|
||||
if (ch == '\"') {
|
||||
if (chNext == '\"') {
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
} else {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
}
|
||||
} else if (state == SCE_C_UUID) {
|
||||
if (ch == '\r' || ch == '\n' || ch == ')') {
|
||||
styler.ColourTo(i-1, state);
|
||||
if (ch == ')')
|
||||
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
chPrev = ch;
|
||||
}
|
||||
styler.ColourTo(lengthDoc - 1, state);
|
||||
|
||||
// Fill in the real level of the next line, keeping the current flags as they will be filled in later
|
||||
if (fold) {
|
||||
int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
|
||||
//styler.SetLevel(lineCurrent, levelCurrent | flagsNext);
|
||||
styler.SetLevel(lineCurrent, levelPrev | flagsNext);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
LexerModule lmCPP(SCLEX_CPP, ColouriseCppDoc);
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,298 +0,0 @@
|
||||
// LexLua.cxx - lexer for Lua language
|
||||
// Written by Paul Winwood
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
static void classifyWordLua(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler)
|
||||
{
|
||||
char s[100];
|
||||
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
|
||||
|
||||
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++)
|
||||
{
|
||||
s[i] = styler[start + i];
|
||||
s[i + 1] = '\0';
|
||||
}
|
||||
|
||||
char chAttr = SCE_LUA_IDENTIFIER;
|
||||
|
||||
if (wordIsNumber)
|
||||
chAttr = SCE_LUA_NUMBER;
|
||||
else
|
||||
{
|
||||
if (keywords.InList(s))
|
||||
{
|
||||
chAttr = SCE_LUA_WORD;
|
||||
}
|
||||
}
|
||||
styler.ColourTo(end, chAttr);
|
||||
}
|
||||
|
||||
static void ColouriseLuaDoc(unsigned int startPos,
|
||||
int length,
|
||||
int initStyle,
|
||||
WordList *keywordlists[],
|
||||
Accessor &styler)
|
||||
{
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
|
||||
styler.StartAt(startPos);
|
||||
styler.GetLine(startPos);
|
||||
|
||||
int state = initStyle;
|
||||
char chPrev = ' ';
|
||||
char chNext = styler[startPos];
|
||||
unsigned int lengthDoc = startPos + length;
|
||||
bool firstChar = true;
|
||||
int literalString = 0;
|
||||
|
||||
styler.StartSegment(startPos);
|
||||
for (unsigned int i = startPos; i <= lengthDoc; i++)
|
||||
{
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
|
||||
if (styler.IsLeadByte(ch))
|
||||
{
|
||||
chNext = styler.SafeGetCharAt(i + 2);
|
||||
chPrev = ' ';
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (state == SCE_LUA_STRINGEOL)
|
||||
{
|
||||
if (ch != '\r' && ch != '\n')
|
||||
{
|
||||
styler.ColourTo(i-1, state);
|
||||
state = SCE_LUA_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
if (state == SCE_LUA_LITERALSTRING && ch == '[' && chNext == '[')
|
||||
{
|
||||
literalString++;
|
||||
}
|
||||
else
|
||||
if (state == SCE_LUA_DEFAULT)
|
||||
{
|
||||
if (ch == '-' && chNext == '-')
|
||||
{
|
||||
styler.ColourTo(i-1, state);
|
||||
state = SCE_LUA_COMMENTLINE;
|
||||
}
|
||||
else
|
||||
if (ch == '[' && chNext == '[')
|
||||
{
|
||||
state = SCE_LUA_LITERALSTRING;
|
||||
literalString = 1;
|
||||
}
|
||||
else
|
||||
if (iswordstart(ch))
|
||||
{
|
||||
styler.ColourTo(i-1, state);
|
||||
state = SCE_LUA_WORD;
|
||||
}
|
||||
else
|
||||
if (ch == '\"')
|
||||
{
|
||||
styler.ColourTo(i-1, state);
|
||||
state = SCE_LUA_STRING;
|
||||
}
|
||||
else
|
||||
if (ch == '\'')
|
||||
{
|
||||
styler.ColourTo(i-1, state);
|
||||
state = SCE_LUA_CHARACTER;
|
||||
}
|
||||
else
|
||||
if (ch == '$' && firstChar)
|
||||
{
|
||||
styler.ColourTo(i-1, state);
|
||||
state = SCE_LUA_PREPROCESSOR;
|
||||
}
|
||||
else
|
||||
if (isoperator(ch))
|
||||
{
|
||||
styler.ColourTo(i-1, state);
|
||||
styler.ColourTo(i, SCE_LUA_OPERATOR);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (state == SCE_LUA_WORD)
|
||||
{
|
||||
if (!iswordchar(ch))
|
||||
{
|
||||
classifyWordLua(styler.GetStartSegment(), i - 1, keywords, styler);
|
||||
state = SCE_LUA_DEFAULT;
|
||||
if (ch == '[' && chNext == '[')
|
||||
{
|
||||
literalString = 1;
|
||||
state = SCE_LUA_LITERALSTRING;
|
||||
}
|
||||
else
|
||||
if (ch == '-' && chNext == '-')
|
||||
{
|
||||
state = SCE_LUA_COMMENTLINE;
|
||||
}
|
||||
else
|
||||
if (ch == '\"')
|
||||
{
|
||||
state = SCE_LUA_STRING;
|
||||
}
|
||||
else
|
||||
if (ch == '\'')
|
||||
{
|
||||
state = SCE_LUA_CHARACTER;
|
||||
}
|
||||
else
|
||||
if (ch == '$' && firstChar)
|
||||
{
|
||||
state = SCE_LUA_PREPROCESSOR;
|
||||
}
|
||||
else
|
||||
if (isoperator(ch))
|
||||
{
|
||||
styler.ColourTo(i, SCE_LUA_OPERATOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (state == SCE_LUA_LITERALSTRING)
|
||||
{
|
||||
if (ch == ']' && (chPrev == ']') && (--literalString == 0))
|
||||
{
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_LUA_DEFAULT;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (state == SCE_LUA_PREPROCESSOR)
|
||||
{
|
||||
if ((ch == '\r' || ch == '\n') && (chPrev != '\\'))
|
||||
{
|
||||
styler.ColourTo(i-1, state);
|
||||
state = SCE_LUA_DEFAULT;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (state == SCE_LUA_COMMENTLINE)
|
||||
{
|
||||
if (ch == '\r' || ch == '\n')
|
||||
{
|
||||
styler.ColourTo(i-1, state);
|
||||
state = SCE_LUA_DEFAULT;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (state == SCE_LUA_STRING)
|
||||
{
|
||||
if ((ch == '\r' || ch == '\n') && (chPrev != '\\'))
|
||||
{
|
||||
styler.ColourTo(i-1, state);
|
||||
state = SCE_LUA_STRINGEOL;
|
||||
}
|
||||
else
|
||||
if (ch == '\\')
|
||||
{
|
||||
if (chNext == '\"' || chNext == '\\')
|
||||
{
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (ch == '\"')
|
||||
{
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_LUA_DEFAULT;
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (state == SCE_LUA_CHARACTER)
|
||||
{
|
||||
if ((ch == '\r' || ch == '\n') && (chPrev != '\\'))
|
||||
{
|
||||
styler.ColourTo(i-1, state);
|
||||
state = SCE_LUA_STRINGEOL;
|
||||
}
|
||||
else
|
||||
if (ch == '\\')
|
||||
{
|
||||
if (chNext == '\'' || chNext == '\\')
|
||||
{
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (ch == '\'')
|
||||
{
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_LUA_DEFAULT;
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (state == SCE_LUA_DEFAULT)
|
||||
{
|
||||
if (ch == '-' && chNext == '-')
|
||||
{
|
||||
state = SCE_LUA_COMMENTLINE;
|
||||
}
|
||||
else
|
||||
if (ch == '\"')
|
||||
{
|
||||
state = SCE_LUA_STRING;
|
||||
}
|
||||
else
|
||||
if (ch == '\'')
|
||||
{
|
||||
state = SCE_LUA_CHARACTER;
|
||||
}
|
||||
else
|
||||
if (ch == '$' && firstChar)
|
||||
{
|
||||
state = SCE_LUA_PREPROCESSOR;
|
||||
}
|
||||
else
|
||||
if (iswordstart(ch))
|
||||
{
|
||||
state = SCE_LUA_WORD;
|
||||
}
|
||||
else
|
||||
if (isoperator(ch))
|
||||
{
|
||||
styler.ColourTo(i, SCE_LUA_OPERATOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
chPrev = ch;
|
||||
firstChar = (ch == '\r' || ch == '\n');
|
||||
}
|
||||
styler.ColourTo(lengthDoc - 1, state);
|
||||
}
|
||||
|
||||
LexerModule lmLua(SCLEX_LUA, ColouriseLuaDoc);
|
||||
@@ -1,351 +0,0 @@
|
||||
// SciTE - Scintilla based Text Editor
|
||||
// LexOthers.cxx - lexers for properties files, batch files, make files and error lists
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
static void ColouriseBatchLine(char *lineBuffer, int endLine, Accessor &styler) {
|
||||
if (0 == strncmp(lineBuffer, "REM", 3)) {
|
||||
styler.ColourTo(endLine, 1);
|
||||
} else if (0 == strncmp(lineBuffer, "rem", 3)) {
|
||||
styler.ColourTo(endLine, 1);
|
||||
} else if (0 == strncmp(lineBuffer, "SET", 3)) {
|
||||
styler.ColourTo(endLine, 2);
|
||||
} else if (0 == strncmp(lineBuffer, "set", 3)) {
|
||||
styler.ColourTo(endLine, 2);
|
||||
} else if (lineBuffer[0] == ':') {
|
||||
styler.ColourTo(endLine, 3);
|
||||
} else {
|
||||
styler.ColourTo(endLine, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void ColouriseBatchDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
|
||||
char lineBuffer[1024];
|
||||
styler.StartAt(startPos);
|
||||
styler.StartSegment(startPos);
|
||||
unsigned int linePos = 0;
|
||||
for (unsigned int i = startPos; i < startPos + length; i++) {
|
||||
lineBuffer[linePos++] = styler[i];
|
||||
if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) {
|
||||
ColouriseBatchLine(lineBuffer, i, styler);
|
||||
linePos = 0;
|
||||
}
|
||||
}
|
||||
if (linePos > 0)
|
||||
ColouriseBatchLine(lineBuffer, startPos + length, styler);
|
||||
}
|
||||
|
||||
static void ColouriseDiffLine(char *lineBuffer, int endLine, Accessor &styler) {
|
||||
// It is needed to remember the current state to recognize starting
|
||||
// comment lines before the first "diff " or "--- ". If a real
|
||||
// difference starts then each line starting with ' ' is a whitespace
|
||||
// otherwise it is considered a comment (Only in..., Binary file...)
|
||||
if (0 == strncmp(lineBuffer, "diff ", 3)) {
|
||||
styler.ColourTo(endLine, 2);
|
||||
} else if (0 == strncmp(lineBuffer, "--- ", 3)) {
|
||||
styler.ColourTo(endLine, 3);
|
||||
} else if (0 == strncmp(lineBuffer, "+++ ", 3)) {
|
||||
styler.ColourTo(endLine, 3);
|
||||
} else if (lineBuffer[0] == '@') {
|
||||
styler.ColourTo(endLine, 4);
|
||||
} else if (lineBuffer[0] == '-') {
|
||||
styler.ColourTo(endLine, 5);
|
||||
} else if (lineBuffer[0] == '+') {
|
||||
styler.ColourTo(endLine, 6);
|
||||
} else if (lineBuffer[0] != ' ') {
|
||||
styler.ColourTo(endLine, 1);
|
||||
} else {
|
||||
styler.ColourTo(endLine, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void ColouriseDiffDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
|
||||
char lineBuffer[1024];
|
||||
styler.StartAt(startPos);
|
||||
styler.StartSegment(startPos);
|
||||
unsigned int linePos = 0;
|
||||
for (unsigned int i = startPos; i < startPos + length; i++) {
|
||||
lineBuffer[linePos++] = styler[i];
|
||||
if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) {
|
||||
ColouriseDiffLine(lineBuffer, i, styler);
|
||||
linePos = 0;
|
||||
}
|
||||
}
|
||||
if (linePos > 0)
|
||||
ColouriseDiffLine(lineBuffer, startPos + length, styler);
|
||||
}
|
||||
|
||||
static void ColourisePropsLine(char *lineBuffer, int lengthLine, int startLine, int endPos, Accessor &styler) {
|
||||
int i = 0;
|
||||
while (isspace(lineBuffer[i]) && (i < lengthLine)) // Skip initial spaces
|
||||
i++;
|
||||
if (lineBuffer[i] == '#' || lineBuffer[i] == '!' || lineBuffer[i] == ';') {
|
||||
styler.ColourTo(endPos, 1);
|
||||
} else if (lineBuffer[i] == '[') {
|
||||
styler.ColourTo(endPos, 2);
|
||||
} else if (lineBuffer[i] == '@') {
|
||||
styler.ColourTo(startLine+i, 4);
|
||||
if (lineBuffer[++i] == '=')
|
||||
styler.ColourTo(startLine+i, 3);
|
||||
styler.ColourTo(endPos, 0);
|
||||
} else {
|
||||
while (lineBuffer[i] != '=' && (i < lengthLine)) // Search the '=' character
|
||||
i++;
|
||||
if (lineBuffer[i] == '=') {
|
||||
styler.ColourTo(startLine+i-1, 0);
|
||||
styler.ColourTo(startLine+i, 3);
|
||||
styler.ColourTo(endPos, 0);
|
||||
} else {
|
||||
styler.ColourTo(endPos, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ColourisePropsDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
|
||||
char lineBuffer[1024];
|
||||
styler.StartAt(startPos);
|
||||
styler.StartSegment(startPos);
|
||||
unsigned int linePos = 0;
|
||||
int startLine = startPos;
|
||||
for (unsigned int i = startPos; i <= startPos + length; i++) {
|
||||
lineBuffer[linePos++] = styler[i];
|
||||
if ((styler[i] == '\r' && styler.SafeGetCharAt(i+1) != '\n') ||
|
||||
styler[i] == '\n' ||
|
||||
(linePos >= sizeof(lineBuffer) - 1)) {
|
||||
lineBuffer[linePos] = '\0';
|
||||
ColourisePropsLine(lineBuffer, linePos, startLine, i, styler);
|
||||
linePos = 0;
|
||||
startLine = i+1;
|
||||
}
|
||||
}
|
||||
if (linePos > 0)
|
||||
ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length, styler);
|
||||
}
|
||||
|
||||
static void ColouriseMakeLine(char *lineBuffer, int lengthLine, int endPos, Accessor &styler) {
|
||||
int i = 0;
|
||||
while (isspace(lineBuffer[i]) && (i < lengthLine))
|
||||
i++;
|
||||
if (lineBuffer[i] == '#' || lineBuffer[i] == '!') {
|
||||
styler.ColourTo(endPos, 1);
|
||||
} else {
|
||||
styler.ColourTo(endPos, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void ColouriseMakeDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
|
||||
char lineBuffer[1024];
|
||||
styler.StartAt(startPos);
|
||||
styler.StartSegment(startPos);
|
||||
unsigned int linePos = 0;
|
||||
for (unsigned int i = startPos; i <= startPos + length; i++) {
|
||||
lineBuffer[linePos++] = styler[i];
|
||||
if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) {
|
||||
ColouriseMakeLine(lineBuffer, linePos, i, styler);
|
||||
linePos = 0;
|
||||
}
|
||||
}
|
||||
if (linePos > 0)
|
||||
ColouriseMakeLine(lineBuffer, linePos, startPos + length, styler);
|
||||
}
|
||||
|
||||
static void ColouriseErrorListLine(char *lineBuffer, int lengthLine, int endPos, Accessor &styler) {
|
||||
if (lineBuffer[0] == '>') {
|
||||
// Command or return status
|
||||
styler.ColourTo(endPos, SCE_ERR_CMD);
|
||||
} else if (strstr(lineBuffer, "File \"") && strstr(lineBuffer, ", line ")) {
|
||||
styler.ColourTo(endPos, SCE_ERR_PYTHON);
|
||||
} else if (0 == strncmp(lineBuffer, "Error ", strlen("Error "))) {
|
||||
// Borland error message
|
||||
styler.ColourTo(endPos, SCE_ERR_BORLAND);
|
||||
} else if (0 == strncmp(lineBuffer, "Warning ", strlen("Warning "))) {
|
||||
// Borland warning message
|
||||
styler.ColourTo(endPos, SCE_ERR_BORLAND);
|
||||
} else if (strstr(lineBuffer, " at " ) &&
|
||||
strstr(lineBuffer, " at " ) < lineBuffer+lengthLine &&
|
||||
strstr(lineBuffer, " line ") &&
|
||||
strstr(lineBuffer, " line ") < lineBuffer+lengthLine) {
|
||||
// perl error message
|
||||
styler.ColourTo(endPos, SCE_ERR_PERL);
|
||||
} else {
|
||||
// Look for <filename>:<line>:message
|
||||
// Look for <filename>(line)message
|
||||
// Look for <filename>(line,pos)message
|
||||
int state = 0;
|
||||
for (int i = 0; i < lengthLine; i++) {
|
||||
if (state == 0 && lineBuffer[i] == ':' && isdigit(lineBuffer[i + 1])) {
|
||||
state = 1;
|
||||
} else if (state == 0 && lineBuffer[i] == '(') {
|
||||
state = 10;
|
||||
} else if (state == 1 && isdigit(lineBuffer[i])) {
|
||||
state = 2;
|
||||
} else if (state == 2 && lineBuffer[i] == ':') {
|
||||
state = 3;
|
||||
break;
|
||||
} else if (state == 2 && !isdigit(lineBuffer[i])) {
|
||||
state = 99;
|
||||
} else if (state == 10 && isdigit(lineBuffer[i])) {
|
||||
state = 11;
|
||||
} else if (state == 11 && lineBuffer[i] == ',') {
|
||||
state = 14;
|
||||
} else if (state == 11 && lineBuffer[i] == ')') {
|
||||
state = 12;
|
||||
} else if (state == 12 && lineBuffer[i] == ':') {
|
||||
state = 13;
|
||||
} else if (state == 14 && lineBuffer[i] == ')') {
|
||||
state = 15;
|
||||
break;
|
||||
} else if (((state == 11) || (state == 14)) && !((lineBuffer[i] == ' ') || isdigit(lineBuffer[i]))) {
|
||||
state = 99;
|
||||
}
|
||||
}
|
||||
if (state == 3) {
|
||||
styler.ColourTo(endPos, SCE_ERR_GCC);
|
||||
} else if ((state == 13) || (state == 14) || (state == 15)) {
|
||||
styler.ColourTo(endPos, SCE_ERR_MS);
|
||||
} else {
|
||||
styler.ColourTo(endPos, SCE_ERR_DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ColouriseErrorListDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
|
||||
char lineBuffer[1024];
|
||||
styler.StartAt(startPos);
|
||||
styler.StartSegment(startPos);
|
||||
unsigned int linePos = 0;
|
||||
for (unsigned int i = startPos; i <= startPos + length; i++) {
|
||||
lineBuffer[linePos++] = styler[i];
|
||||
if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) {
|
||||
ColouriseErrorListLine(lineBuffer, linePos, i, styler);
|
||||
linePos = 0;
|
||||
}
|
||||
}
|
||||
if (linePos > 0)
|
||||
ColouriseErrorListLine(lineBuffer, linePos, startPos + length, styler);
|
||||
}
|
||||
|
||||
static int isSpecial(char s) {
|
||||
|
||||
return (s == '\\') || (s == ',') || (s == ';') || (s == '\'') || (s == ' ') ||
|
||||
(s == '\"') || (s == '`') || (s == '^') || (s == '~');
|
||||
}
|
||||
|
||||
static int isTag(int start, Accessor &styler) {
|
||||
|
||||
char s[6];
|
||||
unsigned int i = 0, e=1;
|
||||
while (i < 5 && e) {
|
||||
s[i] = styler[start + i];
|
||||
i++;
|
||||
e = styler[start + i] != '{';
|
||||
}
|
||||
s[i] = '\0';
|
||||
return (strcmp(s, "begin") == 0) || (strcmp(s, "end") == 0);
|
||||
}
|
||||
|
||||
static void ColouriseLatexDoc(unsigned int startPos, int length, int initStyle,
|
||||
WordList *[], Accessor &styler) {
|
||||
|
||||
styler.StartAt(startPos);
|
||||
|
||||
int state = initStyle;
|
||||
char chNext = styler[startPos];
|
||||
styler.StartSegment(startPos);
|
||||
int lengthDoc = startPos + length;
|
||||
|
||||
for (int i = startPos; i < lengthDoc; i++) {
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
|
||||
if (styler.IsLeadByte(ch)) {
|
||||
chNext = styler.SafeGetCharAt(i + 2);
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
switch(state) {
|
||||
case SCE_L_DEFAULT :
|
||||
switch(ch) {
|
||||
case '\\' :
|
||||
styler.ColourTo(i - 1, state);
|
||||
if (isSpecial(styler[i + 1])) {
|
||||
styler.ColourTo(i + 1, SCE_L_COMMAND);
|
||||
i++;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
else {
|
||||
if (isTag(i+1, styler))
|
||||
state = SCE_L_TAG;
|
||||
else
|
||||
state = SCE_L_COMMAND;
|
||||
}
|
||||
break;
|
||||
case '$' :
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_L_MATH;
|
||||
if (chNext == '$') {
|
||||
i++;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
break;
|
||||
case '%' :
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_L_COMMENT;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SCE_L_COMMAND :
|
||||
if (chNext == '[' || chNext == '{' || chNext == '}' ||
|
||||
chNext == ' ' || chNext == '\r' || chNext == '\n') {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_L_DEFAULT;
|
||||
i++;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
break;
|
||||
case SCE_L_TAG :
|
||||
if (ch == '}') {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_L_DEFAULT;
|
||||
}
|
||||
break;
|
||||
case SCE_L_MATH :
|
||||
if (ch == '$') {
|
||||
if (chNext == '$') {
|
||||
i++;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_L_DEFAULT;
|
||||
}
|
||||
break;
|
||||
case SCE_L_COMMENT :
|
||||
if (ch == '\r' || ch == '\n') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_L_DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
styler.ColourTo(lengthDoc, state);
|
||||
}
|
||||
|
||||
LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc);
|
||||
LexerModule lmDiff(SCLEX_DIFF, ColouriseDiffDoc);
|
||||
LexerModule lmProps(SCLEX_PROPERTIES, ColourisePropsDoc);
|
||||
LexerModule lmMake(SCLEX_MAKEFILE, ColouriseMakeDoc);
|
||||
LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc);
|
||||
LexerModule lmLatex(SCLEX_LATEX, ColouriseLatexDoc);
|
||||
@@ -1,508 +0,0 @@
|
||||
// SciTE - Scintilla based Text Editor
|
||||
// LexPerl.cxx - lexer for subset of Perl
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
inline bool isPerlOperator(char ch) {
|
||||
if (isalnum(ch))
|
||||
return false;
|
||||
// '.' left out as it is used to make up numbers
|
||||
if (ch == '%' || ch == '^' || ch == '&' || ch == '*' || ch == '\\' ||
|
||||
ch == '(' || ch == ')' || ch == '-' || ch == '+' ||
|
||||
ch == '=' || ch == '|' || ch == '{' || ch == '}' ||
|
||||
ch == '[' || ch == ']' || ch == ':' || ch == ';' ||
|
||||
ch == '<' || ch == '>' || ch == ',' || ch == '/' ||
|
||||
ch == '?' || ch == '!' || ch == '.' || ch == '~')
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static int classifyWordPerl(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
|
||||
char s[100];
|
||||
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
|
||||
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
|
||||
s[i] = styler[start + i];
|
||||
s[i + 1] = '\0';
|
||||
}
|
||||
char chAttr = SCE_PL_IDENTIFIER;
|
||||
if (wordIsNumber)
|
||||
chAttr = SCE_PL_NUMBER;
|
||||
else {
|
||||
if (keywords.InList(s))
|
||||
chAttr = SCE_PL_WORD;
|
||||
}
|
||||
styler.ColourTo(end, chAttr);
|
||||
return chAttr;
|
||||
}
|
||||
|
||||
static bool isEndVar(char ch) {
|
||||
return !isalnum(ch) && ch != '#' && ch != '$' &&
|
||||
ch != '_' && ch != '\'';
|
||||
}
|
||||
|
||||
static bool isMatch(Accessor &styler, int lengthDoc, int pos, const char *val) {
|
||||
if ((pos + static_cast<int>(strlen(val))) >= lengthDoc) {
|
||||
return false;
|
||||
}
|
||||
while (*val) {
|
||||
if (*val != styler[pos++]) {
|
||||
return false;
|
||||
}
|
||||
val++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static char opposite(char ch) {
|
||||
if (ch == '(')
|
||||
return ')';
|
||||
if (ch == '[')
|
||||
return ']';
|
||||
if (ch == '{')
|
||||
return '}';
|
||||
if (ch == '<')
|
||||
return '>';
|
||||
return ch;
|
||||
}
|
||||
|
||||
static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) {
|
||||
|
||||
// Lexer for perl often has to backtrack to start of current style to determine
|
||||
// which characters are being used as quotes, how deeply nested is the
|
||||
// start position and what the termination string is for here documents
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
|
||||
char sooked[100];
|
||||
int quotes = 0;
|
||||
char quoteDown = 'd';
|
||||
char quoteUp = 'd';
|
||||
int quoteRep = 1;
|
||||
int sookedpos = 0;
|
||||
bool preferRE = true;
|
||||
sooked[sookedpos] = '\0';
|
||||
int state = initStyle;
|
||||
int lengthDoc = startPos + length;
|
||||
// If in a long distance lexical state, seek to the beginning to find quote characters
|
||||
if (state == SCE_PL_HERE || state == SCE_PL_REGEX ||
|
||||
state == SCE_PL_REGSUBST || state == SCE_PL_LONGQUOTE) {
|
||||
while ((startPos > 1) && (styler.StyleAt(startPos - 1) == state)) {
|
||||
startPos--;
|
||||
}
|
||||
state = SCE_PL_DEFAULT;
|
||||
}
|
||||
styler.StartAt(startPos);
|
||||
char chPrev = styler.SafeGetCharAt(startPos - 1);
|
||||
char chNext = styler[startPos];
|
||||
styler.StartSegment(startPos);
|
||||
for (int i = startPos; i < lengthDoc; i++) {
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
char chNext2 = styler.SafeGetCharAt(i + 2);
|
||||
|
||||
if (styler.IsLeadByte(ch)) {
|
||||
chNext = styler.SafeGetCharAt(i + 2);
|
||||
chPrev = ' ';
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (state == SCE_PL_DEFAULT) {
|
||||
if (iswordstart(ch)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
if (ch == 's' && !isalnum(chNext)) {
|
||||
state = SCE_PL_REGSUBST;
|
||||
quotes = 0;
|
||||
quoteUp = '\0';
|
||||
quoteDown = '\0';
|
||||
quoteRep = 2;
|
||||
} else if (ch == 'm' && !isalnum(chNext)) {
|
||||
state = SCE_PL_REGEX;
|
||||
quotes = 0;
|
||||
quoteUp = '\0';
|
||||
quoteDown = '\0';
|
||||
quoteRep = 1;
|
||||
} else if (ch == 't' && chNext == 'r' && !isalnum(chNext2)) {
|
||||
state = SCE_PL_REGSUBST;
|
||||
quotes = 0;
|
||||
quoteUp = '\0';
|
||||
quoteDown = '\0';
|
||||
quoteRep = 2;
|
||||
i++;
|
||||
chNext = chNext2;
|
||||
} else if (ch == 'q' && (chNext == 'q' || chNext == 'r' || chNext == 'w' || chNext == 'x') && !isalnum(chNext2)) {
|
||||
state = SCE_PL_LONGQUOTE;
|
||||
i++;
|
||||
chNext = chNext2;
|
||||
quotes = 0;
|
||||
quoteUp = '\0';
|
||||
quoteDown = '\0';
|
||||
quoteRep = 1;
|
||||
} else {
|
||||
state = SCE_PL_WORD;
|
||||
preferRE = false;
|
||||
}
|
||||
} else if (ch == '#') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_PL_COMMENTLINE;
|
||||
} else if (ch == '\"') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_PL_STRING;
|
||||
} else if (ch == '\'') {
|
||||
if (chPrev == '&') {
|
||||
// Archaic call
|
||||
styler.ColourTo(i, state);
|
||||
} else {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_PL_CHARACTER;
|
||||
}
|
||||
} else if (ch == '`') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_PL_BACKTICKS;
|
||||
} else if (ch == '$') {
|
||||
preferRE = false;
|
||||
styler.ColourTo(i - 1, state);
|
||||
if (isalnum(chNext) || chNext == '#' || chNext == '$' || chNext == '_') {
|
||||
state = SCE_PL_SCALAR;
|
||||
} else if (chNext != '{' && chNext != '[') {
|
||||
styler.ColourTo(i, SCE_PL_SCALAR);
|
||||
i++;
|
||||
ch = ' ';
|
||||
chNext = ' ';
|
||||
} else {
|
||||
styler.ColourTo(i, SCE_PL_SCALAR);
|
||||
}
|
||||
} else if (ch == '@') {
|
||||
preferRE = false;
|
||||
styler.ColourTo(i - 1, state);
|
||||
if (isalpha(chNext) || chNext == '#' || chNext == '$' || chNext == '_') {
|
||||
state = SCE_PL_ARRAY;
|
||||
} else if (chNext != '{' && chNext != '[') {
|
||||
styler.ColourTo(i, SCE_PL_ARRAY);
|
||||
i++;
|
||||
ch = ' ';
|
||||
} else {
|
||||
styler.ColourTo(i, SCE_PL_ARRAY);
|
||||
}
|
||||
} else if (ch == '%') {
|
||||
preferRE = false;
|
||||
styler.ColourTo(i - 1, state);
|
||||
if (isalpha(chNext) || chNext == '#' || chNext == '$' || chNext == '_') {
|
||||
state = SCE_PL_HASH;
|
||||
} else if (chNext != '{' && chNext != '[') {
|
||||
styler.ColourTo(i, SCE_PL_HASH);
|
||||
i++;
|
||||
ch = ' ';
|
||||
} else {
|
||||
styler.ColourTo(i, SCE_PL_HASH);
|
||||
}
|
||||
} else if (ch == '*') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_PL_SYMBOLTABLE;
|
||||
} else if (ch == '/' && preferRE) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_PL_REGEX;
|
||||
quoteUp = '/';
|
||||
quoteDown = '/';
|
||||
quotes = 1;
|
||||
quoteRep = 1;
|
||||
} else if (ch == '<' && chNext == '<') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_PL_HERE;
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = chNext2;
|
||||
quotes = 0;
|
||||
sookedpos = 0;
|
||||
sooked[sookedpos] = '\0';
|
||||
} else if (ch == '=' && (chPrev == '\r' || chPrev == '\n') && isalpha(chNext)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_PL_POD;
|
||||
quotes = 0;
|
||||
sookedpos = 0;
|
||||
sooked[sookedpos] = '\0';
|
||||
} else if (isPerlOperator(ch)) {
|
||||
if (ch == ')' || ch == ']')
|
||||
preferRE = false;
|
||||
else
|
||||
preferRE = true;
|
||||
styler.ColourTo(i - 1, state);
|
||||
styler.ColourTo(i, SCE_PL_OPERATOR);
|
||||
}
|
||||
} else if (state == SCE_PL_WORD) {
|
||||
if (!iswordchar(ch) && ch != '\'') { // Archaic Perl has quotes inside names
|
||||
if (isMatch(styler, lengthDoc, styler.GetStartSegment(), "__DATA__")) {
|
||||
styler.ColourTo(i, SCE_PL_DATASECTION);
|
||||
state = SCE_PL_DATASECTION;
|
||||
} else if (isMatch(styler, lengthDoc, styler.GetStartSegment(), "__END__")) {
|
||||
styler.ColourTo(i, SCE_PL_DATASECTION);
|
||||
state = SCE_PL_DATASECTION;
|
||||
} else {
|
||||
if (classifyWordPerl(styler.GetStartSegment(), i - 1, keywords, styler) == SCE_PL_WORD)
|
||||
preferRE = true;
|
||||
state = SCE_PL_DEFAULT;
|
||||
if (ch == '#') {
|
||||
state = SCE_PL_COMMENTLINE;
|
||||
} else if (ch == '\"') {
|
||||
state = SCE_PL_STRING;
|
||||
} else if (ch == '\'') {
|
||||
state = SCE_PL_CHARACTER;
|
||||
} else if (ch == '<' && chNext == '<') {
|
||||
state = SCE_PL_HERE;
|
||||
quotes = 0;
|
||||
sookedpos = 0;
|
||||
sooked[sookedpos] = '\0';
|
||||
} else if (isPerlOperator(ch)) {
|
||||
if (ch == ')' || ch == ']')
|
||||
preferRE = false;
|
||||
else
|
||||
preferRE = true;
|
||||
styler.ColourTo(i, SCE_PL_OPERATOR);
|
||||
state = SCE_PL_DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (state == SCE_PL_COMMENTLINE) {
|
||||
if (ch == '\r' || ch == '\n') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_PL_DEFAULT;
|
||||
}
|
||||
} else if (state == SCE_PL_HERE) {
|
||||
if ((isalnum(ch) || ch == '_') && quotes < 2) {
|
||||
sooked[sookedpos++] = ch;
|
||||
sooked[sookedpos] = '\0';
|
||||
if (quotes == 0)
|
||||
quotes = 1;
|
||||
} else {
|
||||
quotes++;
|
||||
}
|
||||
if ((quotes > 1) &&
|
||||
(chPrev == '\n' || chPrev == '\r') &&
|
||||
isMatch(styler, lengthDoc, i, sooked)) {
|
||||
i += sookedpos;
|
||||
chNext = styler.SafeGetCharAt(i);
|
||||
if (chNext == '\n' || chNext == '\r') {
|
||||
styler.ColourTo(i - 1, SCE_PL_HERE);
|
||||
state = SCE_PL_DEFAULT;
|
||||
}
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
} else if (state == SCE_PL_STRING) {
|
||||
if (ch == '\\') {
|
||||
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
} else if (ch == '\"') {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_PL_DEFAULT;
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
} else if (state == SCE_PL_CHARACTER) {
|
||||
if (ch == '\\') {
|
||||
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
} else if (ch == '\'') {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_PL_DEFAULT;
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
} else if (state == SCE_PL_BACKTICKS) {
|
||||
if (ch == '`') {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_PL_DEFAULT;
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
} else if (state == SCE_PL_POD) {
|
||||
if (ch == '=' && (chPrev == '\r' || chPrev == '\n')) {
|
||||
if (isMatch(styler, lengthDoc, i, "=cut")) {
|
||||
styler.ColourTo(i - 1 + 4, state);
|
||||
i += 4;
|
||||
state = SCE_PL_DEFAULT;
|
||||
ch = styler.SafeGetCharAt(i);
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
}
|
||||
} else if (state == SCE_PL_SCALAR) {
|
||||
if (isEndVar(ch)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_PL_DEFAULT;
|
||||
}
|
||||
} else if (state == SCE_PL_ARRAY) {
|
||||
if (isEndVar(ch)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_PL_DEFAULT;
|
||||
}
|
||||
} else if (state == SCE_PL_HASH) {
|
||||
if (isEndVar(ch)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_PL_DEFAULT;
|
||||
}
|
||||
} else if (state == SCE_PL_SYMBOLTABLE) {
|
||||
if (isEndVar(ch)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_PL_DEFAULT;
|
||||
}
|
||||
} else if (state == SCE_PL_REF) {
|
||||
if (isEndVar(ch)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_PL_DEFAULT;
|
||||
}
|
||||
} else if (state == SCE_PL_REGEX) {
|
||||
if (!quoteUp && !isspace(ch)) {
|
||||
quoteUp = ch;
|
||||
quoteDown = opposite(ch);
|
||||
quotes++;
|
||||
} else {
|
||||
if (ch == quoteDown && chPrev != '\\') {
|
||||
quotes--;
|
||||
if (quotes == 0) {
|
||||
quoteRep--;
|
||||
if (quoteUp == quoteDown) {
|
||||
quotes++;
|
||||
}
|
||||
}
|
||||
if (!isalpha(chNext)) {
|
||||
if (quoteRep <= 0) {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_PL_DEFAULT;
|
||||
ch = ' ';
|
||||
}
|
||||
}
|
||||
} else if (ch == quoteUp && chPrev != '\\') {
|
||||
quotes++;
|
||||
} else if (!isalpha(chNext)) {
|
||||
if (quoteRep <= 0) {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_PL_DEFAULT;
|
||||
ch = ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (state == SCE_PL_REGSUBST) {
|
||||
if (!quoteUp && !isspace(ch)) {
|
||||
quoteUp = ch;
|
||||
quoteDown = opposite(ch);
|
||||
quotes++;
|
||||
} else {
|
||||
if (quotes == 0 && quoteRep == 1) {
|
||||
/* We matched something like s(...) or tr{...}
|
||||
* and are looking for the next matcher characters,
|
||||
* which could be either bracketed ({...}) or non-bracketed
|
||||
* (/.../).
|
||||
*
|
||||
* Number-signs are problematic. If they occur after
|
||||
* the close of the first part, treat them like
|
||||
* a quoteUp char, even if they actually start comments.
|
||||
*
|
||||
* If we find an alnum, we end the regsubst, and punt.
|
||||
*
|
||||
* Eric Promislow ericp@activestate.com Aug 9,2000
|
||||
*/
|
||||
if (isspace(ch)) {
|
||||
// Keep going
|
||||
} else if (isalnum(ch)) {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_PL_DEFAULT;
|
||||
ch = ' ';
|
||||
} else {
|
||||
quoteUp = ch;
|
||||
quoteDown = opposite(ch);
|
||||
quotes++;
|
||||
}
|
||||
} else if (ch == quoteDown && chPrev != '\\') {
|
||||
quotes--;
|
||||
if (quotes == 0) {
|
||||
quoteRep--;
|
||||
}
|
||||
if (!isalpha(chNext)) {
|
||||
if (quoteRep <= 0) {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_PL_DEFAULT;
|
||||
ch = ' ';
|
||||
}
|
||||
}
|
||||
if (quoteUp == quoteDown) {
|
||||
quotes++;
|
||||
}
|
||||
} else if (ch == quoteUp && chPrev != '\\') {
|
||||
quotes++;
|
||||
} else if (!isalpha(chNext)) {
|
||||
if (quoteRep <= 0) {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_PL_DEFAULT;
|
||||
ch = ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (state == SCE_PL_LONGQUOTE) {
|
||||
if (!quoteDown && !isspace(ch)) {
|
||||
quoteUp = ch;
|
||||
quoteDown = opposite(quoteUp);
|
||||
quotes++;
|
||||
} else if (ch == quoteDown) {
|
||||
quotes--;
|
||||
if (quotes == 0) {
|
||||
quoteRep--;
|
||||
if (quoteRep <= 0) {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_PL_DEFAULT;
|
||||
ch = ' ';
|
||||
}
|
||||
if (quoteUp == quoteDown) {
|
||||
quotes++;
|
||||
}
|
||||
}
|
||||
} else if (ch == quoteUp) {
|
||||
quotes++;
|
||||
}
|
||||
}
|
||||
|
||||
if (state == SCE_PL_DEFAULT) { // One of the above succeeded
|
||||
if (ch == '#') {
|
||||
state = SCE_PL_COMMENTLINE;
|
||||
} else if (ch == '\"') {
|
||||
state = SCE_PL_STRING;
|
||||
} else if (ch == '\'') {
|
||||
state = SCE_PL_CHARACTER;
|
||||
} else if (iswordstart(ch)) {
|
||||
state = SCE_PL_WORD;
|
||||
preferRE = false;
|
||||
} else if (isoperator(ch)) {
|
||||
styler.ColourTo(i, SCE_PL_OPERATOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
chPrev = ch;
|
||||
}
|
||||
styler.ColourTo(lengthDoc, state);
|
||||
}
|
||||
|
||||
LexerModule lmPerl(SCLEX_PERL, ColourisePerlDoc);
|
||||
@@ -1,281 +0,0 @@
|
||||
// SciTE - Scintilla based Text Editor
|
||||
// LexPython.cxx - lexer for Python
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
static void ClassifyWordPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) {
|
||||
char s[100];
|
||||
bool wordIsNumber = isdigit(styler[start]);
|
||||
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
|
||||
s[i] = styler[start + i];
|
||||
s[i + 1] = '\0';
|
||||
}
|
||||
char chAttr = SCE_P_IDENTIFIER;
|
||||
if (0 == strcmp(prevWord, "class"))
|
||||
chAttr = SCE_P_CLASSNAME;
|
||||
else if (0 == strcmp(prevWord, "def"))
|
||||
chAttr = SCE_P_DEFNAME;
|
||||
else if (wordIsNumber)
|
||||
chAttr = SCE_P_NUMBER;
|
||||
else if (keywords.InList(s))
|
||||
chAttr = SCE_P_WORD;
|
||||
// make sure that dot-qualifiers inside the word are lexed correct
|
||||
else for (unsigned int i = 0; i < end - start + 1; i++) {
|
||||
if (styler[start + i] == '.') {
|
||||
styler.ColourTo(start + i - 1, chAttr);
|
||||
styler.ColourTo(start + i, SCE_P_OPERATOR);
|
||||
}
|
||||
}
|
||||
styler.ColourTo(end, chAttr);
|
||||
strcpy(prevWord, s);
|
||||
}
|
||||
|
||||
static bool IsPyComment(Accessor &styler, int pos, int len) {
|
||||
return len>0 && styler[pos]=='#';
|
||||
}
|
||||
|
||||
static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) {
|
||||
|
||||
int lengthDoc = startPos + length;
|
||||
|
||||
// Backtrack to previous line in case need to fix its fold status or tab whinging
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
if (startPos > 0) {
|
||||
if (lineCurrent > 0) {
|
||||
lineCurrent--;
|
||||
startPos = styler.LineStart(lineCurrent);
|
||||
if (startPos == 0)
|
||||
initStyle = SCE_P_DEFAULT;
|
||||
else
|
||||
initStyle = styler.StyleAt(startPos-1);
|
||||
}
|
||||
}
|
||||
|
||||
// Python uses a different mask because bad indentation is marked by oring with 32
|
||||
styler.StartAt(startPos, 127);
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
|
||||
bool fold = styler.GetPropertyInt("fold");
|
||||
int whingeLevel = styler.GetPropertyInt("tab.timmy.whinge.level");
|
||||
char prevWord[200];
|
||||
prevWord[0] = '\0';
|
||||
if (length == 0)
|
||||
return ;
|
||||
int spaceFlags = 0;
|
||||
|
||||
int state = initStyle & 31;
|
||||
|
||||
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
|
||||
if ((state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE))
|
||||
indentCurrent |= SC_FOLDLEVELWHITEFLAG;
|
||||
|
||||
char chPrev = ' ';
|
||||
char chPrev2 = ' ';
|
||||
char chNext = styler[startPos];
|
||||
styler.StartSegment(startPos);
|
||||
bool atStartLine = true;
|
||||
for (int i = startPos; i < lengthDoc; i++) {
|
||||
|
||||
if (atStartLine) {
|
||||
char chBad = static_cast<char>(64);
|
||||
char chGood = static_cast<char>(0);
|
||||
char chFlags = chGood;
|
||||
if (whingeLevel == 1) {
|
||||
chFlags = (spaceFlags & wsInconsistent) ? chBad : chGood;
|
||||
} else if (whingeLevel == 2) {
|
||||
chFlags = (spaceFlags & wsSpaceTab) ? chBad : chGood;
|
||||
} else if (whingeLevel == 3) {
|
||||
chFlags = (spaceFlags & wsSpace) ? chBad : chGood;
|
||||
} else if (whingeLevel == 4) {
|
||||
chFlags = (spaceFlags & wsTab) ? chBad : chGood;
|
||||
}
|
||||
styler.SetFlags(chFlags, static_cast<char>(state));
|
||||
atStartLine = false;
|
||||
}
|
||||
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
char chNext2 = styler.SafeGetCharAt(i + 2);
|
||||
|
||||
if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) {
|
||||
if ((state == SCE_P_DEFAULT) || (state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE)) {
|
||||
// Perform colourisation of white space and triple quoted strings at end of each line to allow
|
||||
// tab marking to work inside white space and triple quoted strings
|
||||
styler.ColourTo(i, state);
|
||||
}
|
||||
|
||||
int lev = indentCurrent;
|
||||
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsPyComment);
|
||||
if ((state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE))
|
||||
indentNext |= SC_FOLDLEVELWHITEFLAG;
|
||||
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
|
||||
// Only non whitespace lines can be headers
|
||||
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) {
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
} else if (indentNext & SC_FOLDLEVELWHITEFLAG) {
|
||||
// Line after is blank so check the next - maybe should continue further?
|
||||
int spaceFlags2 = 0;
|
||||
int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsPyComment);
|
||||
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) {
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
}
|
||||
}
|
||||
}
|
||||
indentCurrent = indentNext;
|
||||
if (fold) {
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
}
|
||||
lineCurrent++;
|
||||
atStartLine = true;
|
||||
}
|
||||
|
||||
if (styler.IsLeadByte(ch)) {
|
||||
chNext = styler.SafeGetCharAt(i + 2);
|
||||
chPrev = ' ';
|
||||
chPrev2 = ' ';
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (state == SCE_P_STRINGEOL) {
|
||||
if (ch != '\r' && ch != '\n') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_P_DEFAULT;
|
||||
}
|
||||
}
|
||||
if (state == SCE_P_DEFAULT) {
|
||||
if (iswordstart(ch)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_P_WORD;
|
||||
} else if (ch == '#') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE;
|
||||
} else if (ch == '\"') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
if (chNext == '\"' && chNext2 == '\"') {
|
||||
i += 2;
|
||||
state = SCE_P_TRIPLEDOUBLE;
|
||||
ch = ' ';
|
||||
chPrev = ' ';
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
} else {
|
||||
state = SCE_P_STRING;
|
||||
}
|
||||
} else if (ch == '\'') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
if (chNext == '\'' && chNext2 == '\'') {
|
||||
i += 2;
|
||||
state = SCE_P_TRIPLE;
|
||||
ch = ' ';
|
||||
chPrev = ' ';
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
} else {
|
||||
state = SCE_P_CHARACTER;
|
||||
}
|
||||
} else if (isoperator(ch)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
styler.ColourTo(i, SCE_P_OPERATOR);
|
||||
}
|
||||
} else if (state == SCE_P_WORD) {
|
||||
if (!iswordchar(ch)) {
|
||||
ClassifyWordPy(styler.GetStartSegment(), i - 1, keywords, styler, prevWord);
|
||||
state = SCE_P_DEFAULT;
|
||||
if (ch == '#') {
|
||||
state = chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE;
|
||||
} else if (ch == '\"') {
|
||||
if (chNext == '\"' && chNext2 == '\"') {
|
||||
i += 2;
|
||||
state = SCE_P_TRIPLEDOUBLE;
|
||||
ch = ' ';
|
||||
chPrev = ' ';
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
} else {
|
||||
state = SCE_P_STRING;
|
||||
}
|
||||
} else if (ch == '\'') {
|
||||
if (chNext == '\'' && chNext2 == '\'') {
|
||||
i += 2;
|
||||
state = SCE_P_TRIPLE;
|
||||
ch = ' ';
|
||||
chPrev = ' ';
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
} else {
|
||||
state = SCE_P_CHARACTER;
|
||||
}
|
||||
} else if (isoperator(ch)) {
|
||||
styler.ColourTo(i, SCE_P_OPERATOR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (state == SCE_P_COMMENTLINE || state == SCE_P_COMMENTBLOCK) {
|
||||
if (ch == '\r' || ch == '\n') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_P_DEFAULT;
|
||||
}
|
||||
} else if (state == SCE_P_STRING) {
|
||||
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_P_STRINGEOL;
|
||||
} else if (ch == '\\') {
|
||||
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
} else if (ch == '\"') {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_P_DEFAULT;
|
||||
}
|
||||
} else if (state == SCE_P_CHARACTER) {
|
||||
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_P_STRINGEOL;
|
||||
} else if (ch == '\\') {
|
||||
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
} else if (ch == '\'') {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_P_DEFAULT;
|
||||
}
|
||||
} else if (state == SCE_P_TRIPLE) {
|
||||
if (ch == '\'' && chPrev == '\'' && chPrev2 == '\'') {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_P_DEFAULT;
|
||||
}
|
||||
} else if (state == SCE_P_TRIPLEDOUBLE) {
|
||||
if (ch == '\"' && chPrev == '\"' && chPrev2 == '\"') {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_P_DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
chPrev2 = chPrev;
|
||||
chPrev = ch;
|
||||
}
|
||||
if (state == SCE_P_WORD) {
|
||||
ClassifyWordPy(styler.GetStartSegment(), lengthDoc, keywords, styler, prevWord);
|
||||
} else {
|
||||
styler.ColourTo(lengthDoc, state);
|
||||
}
|
||||
}
|
||||
|
||||
LexerModule lmPython(SCLEX_PYTHON, ColourisePyDoc);
|
||||
@@ -1,156 +0,0 @@
|
||||
// SciTE - Scintilla based Text Editor
|
||||
// LexSQL.cxx - lexer for SQL
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
static void classifyWordSQL(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
|
||||
char s[100];
|
||||
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
|
||||
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
|
||||
s[i] = static_cast<char>(toupper(styler[start + i]));
|
||||
s[i + 1] = '\0';
|
||||
}
|
||||
char chAttr = SCE_C_IDENTIFIER;
|
||||
if (wordIsNumber)
|
||||
chAttr = SCE_C_NUMBER;
|
||||
else {
|
||||
if (keywords.InList(s))
|
||||
chAttr = SCE_C_WORD;
|
||||
}
|
||||
styler.ColourTo(end, chAttr);
|
||||
}
|
||||
|
||||
static void ColouriseSQLDoc(unsigned int startPos, int length,
|
||||
int initStyle, WordList *keywordlists[], Accessor &styler) {
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
|
||||
styler.StartAt(startPos);
|
||||
|
||||
bool fold = styler.GetPropertyInt("fold");
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
int spaceFlags = 0;
|
||||
|
||||
int state = initStyle;
|
||||
char chPrev = ' ';
|
||||
char chNext = styler[startPos];
|
||||
styler.StartSegment(startPos);
|
||||
unsigned int lengthDoc = startPos + length;
|
||||
for (unsigned int i = startPos; i < lengthDoc; i++) {
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
|
||||
if ((ch == '\r' && chNext != '\n') || (ch == '\n')) {
|
||||
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags);
|
||||
int lev = indentCurrent;
|
||||
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
|
||||
// Only non whitespace lines can be headers
|
||||
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags);
|
||||
if (indentCurrent < (indentNext & ~SC_FOLDLEVELWHITEFLAG)) {
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
}
|
||||
}
|
||||
if (fold) {
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
}
|
||||
}
|
||||
|
||||
if (styler.IsLeadByte(ch)) {
|
||||
chNext = styler.SafeGetCharAt(i + 2);
|
||||
chPrev = ' ';
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (state == SCE_C_DEFAULT) {
|
||||
if (iswordstart(ch)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_WORD;
|
||||
} else if (ch == '/' && chNext == '*') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_COMMENT;
|
||||
} else if (ch == '-' && chNext == '-') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_COMMENTLINE;
|
||||
} else if (ch == '\'') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_STRING;
|
||||
} else if (isoperator(ch)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||
}
|
||||
} else if (state == SCE_C_WORD) {
|
||||
if (!iswordchar(ch)) {
|
||||
classifyWordSQL(styler.GetStartSegment(), i - 1, keywords, styler);
|
||||
state = SCE_C_DEFAULT;
|
||||
if (ch == '/' && chNext == '*') {
|
||||
state = SCE_C_COMMENT;
|
||||
} else if (ch == '-' && chNext == '-') {
|
||||
state = SCE_C_COMMENTLINE;
|
||||
} else if (ch == '\'') {
|
||||
state = SCE_C_STRING;
|
||||
} else if (isoperator(ch)) {
|
||||
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (state == SCE_C_COMMENT) {
|
||||
if (ch == '/' && chPrev == '*') {
|
||||
if (((i > (styler.GetStartSegment() + 2)) || ((initStyle == SCE_C_COMMENT) &&
|
||||
(styler.GetStartSegment() == startPos)))) {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
}
|
||||
} else if (state == SCE_C_COMMENTLINE) {
|
||||
if (ch == '\r' || ch == '\n') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
} else if (state == SCE_C_STRING) {
|
||||
if (ch == '\'') {
|
||||
if ( chNext == '\'' ) {
|
||||
i++;
|
||||
} else {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_C_DEFAULT;
|
||||
i++;
|
||||
}
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
}
|
||||
if (state == SCE_C_DEFAULT) { // One of the above succeeded
|
||||
if (ch == '/' && chNext == '*') {
|
||||
state = SCE_C_COMMENT;
|
||||
} else if (ch == '-' && chNext == '-') {
|
||||
state = SCE_C_COMMENTLINE;
|
||||
} else if (ch == '\'') {
|
||||
state = SCE_C_STRING;
|
||||
} else if (iswordstart(ch)) {
|
||||
state = SCE_C_WORD;
|
||||
} else if (isoperator(ch)) {
|
||||
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
chPrev = ch;
|
||||
}
|
||||
styler.ColourTo(lengthDoc - 1, state);
|
||||
}
|
||||
|
||||
LexerModule lmSQL(SCLEX_SQL, ColouriseSQLDoc);
|
||||
@@ -1,139 +0,0 @@
|
||||
// SciTE - Scintilla based Text Editor
|
||||
// LexVB.cxx - lexer for Visual Basic and VBScript
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
static int classifyWordVB(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
|
||||
|
||||
char s[100];
|
||||
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.') ||
|
||||
(styler[start] == '&' && tolower(styler[start+1]) == 'h');
|
||||
unsigned int i;
|
||||
for (i = 0; i < end - start + 1 && i < 30; i++) {
|
||||
s[i] = static_cast<char>(tolower(styler[start + i]));
|
||||
}
|
||||
s[i] = '\0';
|
||||
char chAttr = SCE_C_DEFAULT;
|
||||
if (wordIsNumber)
|
||||
chAttr = SCE_C_NUMBER;
|
||||
else {
|
||||
if (strcmp(s, "rem") == 0)
|
||||
chAttr = SCE_C_COMMENTLINE;
|
||||
else if (keywords.InList(s))
|
||||
chAttr = SCE_C_WORD;
|
||||
}
|
||||
styler.ColourTo(end, chAttr);
|
||||
if (chAttr == SCE_C_COMMENTLINE)
|
||||
return SCE_C_COMMENTLINE;
|
||||
else
|
||||
return SCE_C_DEFAULT;
|
||||
}
|
||||
|
||||
static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) {
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
|
||||
styler.StartAt(startPos);
|
||||
|
||||
int visibleChars = 0;
|
||||
int state = initStyle;
|
||||
char chNext = styler[startPos];
|
||||
styler.StartSegment(startPos);
|
||||
int lengthDoc = startPos + length;
|
||||
for (int i = startPos; i < lengthDoc; i++) {
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
|
||||
if (styler.IsLeadByte(ch)) {
|
||||
chNext = styler.SafeGetCharAt(i + 2);
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch == '\r' || ch == '\n') {
|
||||
// End of line
|
||||
if (state == SCE_C_COMMENTLINE || state == SCE_C_PREPROCESSOR) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
visibleChars = 0;
|
||||
}
|
||||
if (!isspace(ch))
|
||||
visibleChars++;
|
||||
|
||||
if (state == SCE_C_DEFAULT) {
|
||||
if (iswordstart(ch)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_WORD;
|
||||
} else if (ch == '\'') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_COMMENTLINE;
|
||||
} else if (ch == '\"') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_STRING;
|
||||
} else if (ch == '#' && visibleChars == 1) {
|
||||
// Preprocessor commands are alone on their line
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_PREPROCESSOR;
|
||||
} else if (ch == '&' && tolower(chNext) == 'h') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_WORD;
|
||||
} else if (isoperator(ch)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||
}
|
||||
} else if (state == SCE_C_WORD) {
|
||||
if (!iswordchar(ch)) {
|
||||
state = classifyWordVB(styler.GetStartSegment(), i - 1, keywords, styler);
|
||||
if (state == SCE_C_DEFAULT) {
|
||||
if (ch == '\'') {
|
||||
state = SCE_C_COMMENTLINE;
|
||||
} else if (ch == '\"') {
|
||||
state = SCE_C_STRING;
|
||||
} else if (isoperator(ch)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (state == SCE_C_STRING) {
|
||||
// VB doubles quotes to preserve them
|
||||
if (ch == '\"') {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_C_DEFAULT;
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
}
|
||||
if (state == SCE_C_DEFAULT) { // One of the above succeeded
|
||||
if (ch == '\'') {
|
||||
state = SCE_C_COMMENTLINE;
|
||||
} else if (ch == '\"') {
|
||||
state = SCE_C_STRING;
|
||||
} else if (iswordstart(ch)) {
|
||||
state = SCE_C_WORD;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
styler.ColourTo(lengthDoc, state);
|
||||
}
|
||||
|
||||
LexerModule lmVB(SCLEX_VB, ColouriseVBDoc);
|
||||
@@ -1,105 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// LineMarker.cxx - defines the look of a line marker in the margin
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "Scintilla.h"
|
||||
#include "LineMarker.h"
|
||||
|
||||
void LineMarker::Draw(Surface *surface, PRectangle &rc) {
|
||||
int minDim = Platform::Minimum(rc.Width(), rc.Height());
|
||||
minDim--; // Ensure does not go beyond edge
|
||||
int centreX = (rc.right + rc.left) / 2;
|
||||
int centreY = (rc.bottom + rc.top) / 2;
|
||||
int dimOn2 = minDim / 2;
|
||||
int dimOn4 = minDim / 4;
|
||||
if (rc.Width() > (rc.Height() * 2)) {
|
||||
// Wide column is line number so move to left to try to avoid overlapping number
|
||||
centreX = rc.left + dimOn2 + 1;
|
||||
}
|
||||
if (markType == SC_MARK_ROUNDRECT) {
|
||||
PRectangle rcRounded = rc;
|
||||
rcRounded.left = rc.left + 1;
|
||||
rcRounded.right = rc.right - 1;
|
||||
surface->RoundedRectangle(rcRounded, fore.allocated, back.allocated);
|
||||
} else if (markType == SC_MARK_CIRCLE) {
|
||||
PRectangle rcCircle;
|
||||
rcCircle.left = centreX - dimOn2;
|
||||
rcCircle.top = centreY - dimOn2;
|
||||
rcCircle.right = centreX + dimOn2;
|
||||
rcCircle.bottom = centreY + dimOn2;
|
||||
surface->Ellipse(rcCircle, fore.allocated, back.allocated);
|
||||
} else if (markType == SC_MARK_ARROW) {
|
||||
Point pts[] = {
|
||||
Point(centreX - dimOn4, centreY - dimOn2),
|
||||
Point(centreX - dimOn4, centreY + dimOn2),
|
||||
Point(centreX + dimOn2 - dimOn4, centreY),
|
||||
};
|
||||
surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
|
||||
fore.allocated, back.allocated);
|
||||
|
||||
} else if (markType == SC_MARK_ARROWDOWN) {
|
||||
Point pts[] = {
|
||||
Point(centreX - dimOn2, centreY - dimOn4),
|
||||
Point(centreX + dimOn2, centreY - dimOn4),
|
||||
Point(centreX, centreY + dimOn2 - dimOn4),
|
||||
};
|
||||
surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
|
||||
fore.allocated, back.allocated);
|
||||
|
||||
} else if (markType == SC_MARK_PLUS) {
|
||||
int armSize = dimOn2-2;
|
||||
Point pts[] = {
|
||||
Point(centreX - armSize, centreY - 1),
|
||||
Point(centreX - 1, centreY - 1),
|
||||
Point(centreX - 1, centreY - armSize),
|
||||
Point(centreX + 1, centreY - armSize),
|
||||
Point(centreX + 1, centreY - 1),
|
||||
Point(centreX + armSize, centreY -1),
|
||||
Point(centreX + armSize, centreY +1),
|
||||
Point(centreX + 1, centreY + 1),
|
||||
Point(centreX + 1, centreY + armSize),
|
||||
Point(centreX - 1, centreY + armSize),
|
||||
Point(centreX - 1, centreY + 1),
|
||||
Point(centreX - armSize, centreY + 1),
|
||||
};
|
||||
surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
|
||||
fore.allocated, back.allocated);
|
||||
|
||||
} else if (markType == SC_MARK_MINUS) {
|
||||
int armSize = dimOn2-2;
|
||||
Point pts[] = {
|
||||
Point(centreX - armSize, centreY - 1),
|
||||
Point(centreX + armSize, centreY -1),
|
||||
Point(centreX + armSize, centreY +1),
|
||||
Point(centreX - armSize, centreY + 1),
|
||||
};
|
||||
surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
|
||||
fore.allocated, back.allocated);
|
||||
|
||||
} else if (markType == SC_MARK_SMALLRECT) {
|
||||
PRectangle rcSmall;
|
||||
rcSmall.left = rc.left + 1;
|
||||
rcSmall.top = rc.top + 2;
|
||||
rcSmall.right = rc.right - 1;
|
||||
rcSmall.bottom = rc.bottom - 2;
|
||||
surface->RectangleDraw(rcSmall, fore.allocated, back.allocated);
|
||||
} else if (markType == SC_MARK_EMPTY) {
|
||||
// An invisible marker so don't draw anything
|
||||
} else { // SC_MARK_SHORTARROW
|
||||
Point pts[] = {
|
||||
Point(centreX, centreY + dimOn2),
|
||||
Point(centreX + dimOn2, centreY),
|
||||
Point(centreX, centreY - dimOn2),
|
||||
Point(centreX, centreY - dimOn4),
|
||||
Point(centreX - dimOn4, centreY - dimOn4),
|
||||
Point(centreX - dimOn4, centreY + dimOn4),
|
||||
Point(centreX, centreY + dimOn4),
|
||||
Point(centreX, centreY + dimOn2),
|
||||
};
|
||||
surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
|
||||
fore.allocated, back.allocated);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// LineMarker.h - defines the look of a line marker in the margin
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef LINEMARKER_H
|
||||
#define LINEMARKER_H
|
||||
|
||||
class LineMarker {
|
||||
public:
|
||||
int markType;
|
||||
ColourPair fore;
|
||||
ColourPair back;
|
||||
LineMarker() {
|
||||
markType = SC_MARK_CIRCLE;
|
||||
fore = Colour(0,0,0);
|
||||
back = Colour(0xff,0xff,0xff);
|
||||
}
|
||||
void Draw(Surface *surface, PRectangle &rc);
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,742 +0,0 @@
|
||||
// SciTE - Scintilla based Text Editor
|
||||
// PropSet.cxx - a java style properties file module
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
// Maintain a dictionary of properties
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "PropSet.h"
|
||||
|
||||
bool EqualCaseInsensitive(const char *a, const char *b) {
|
||||
#if PLAT_GTK
|
||||
return 0 == strcasecmp(a, b);
|
||||
#elif PLAT_WIN
|
||||
return 0 == stricmp(a, b);
|
||||
#elif PLAT_WX
|
||||
return 0 == wxStricmp(a, b);
|
||||
#endif
|
||||
}
|
||||
|
||||
SString::size_type SString::npos = -1;
|
||||
|
||||
inline unsigned int HashString(const char *s) {
|
||||
unsigned int ret = 0;
|
||||
while (*s) {
|
||||
ret <<= 4;
|
||||
ret ^= *s;
|
||||
s++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Get a line of input. If end of line escaped with '\\' then continue reading.
|
||||
static bool GetFullLine(const char *&fpc, int &lenData, char *s, int len) {
|
||||
bool continuation = true;
|
||||
s[0] = '\0';
|
||||
while ((len > 1) && lenData > 0) {
|
||||
char ch = *fpc;
|
||||
fpc++;
|
||||
lenData--;
|
||||
if ((ch == '\r') || (ch == '\n')) {
|
||||
if (!continuation) {
|
||||
if ((lenData > 0) && (ch == '\r') && ((*fpc) == '\n')) {
|
||||
// munch the second half of a crlf
|
||||
fpc++;
|
||||
lenData--;
|
||||
}
|
||||
*s = '\0';
|
||||
return true;
|
||||
}
|
||||
} else if ((ch == '\\') && (lenData > 0) && ((*fpc == '\r') || (*fpc == '\n'))) {
|
||||
continuation = true;
|
||||
} else {
|
||||
continuation = false;
|
||||
*s++ = ch;
|
||||
*s = '\0';
|
||||
len--;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
PropSet::PropSet() {
|
||||
superPS = 0;
|
||||
for (int root=0; root < hashRoots; root++)
|
||||
props[root] = 0;
|
||||
}
|
||||
|
||||
PropSet::~PropSet() {
|
||||
superPS = 0;
|
||||
Clear();
|
||||
}
|
||||
|
||||
void PropSet::Set(const char *key, const char *val) {
|
||||
unsigned int hash = HashString(key);
|
||||
for (Property *p=props[hash % hashRoots]; p; p=p->next) {
|
||||
if ((hash == p->hash) && (0 == strcmp(p->key, key))) {
|
||||
// Replace current value
|
||||
delete [](p->val);
|
||||
p->val = StringDup(val);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Not found
|
||||
Property *pNew = new Property;
|
||||
if (pNew) {
|
||||
pNew->hash = HashString(key);
|
||||
pNew->key = StringDup(key);
|
||||
pNew->val = StringDup(val);
|
||||
pNew->next = props[hash % hashRoots];
|
||||
props[hash % hashRoots] = pNew;
|
||||
}
|
||||
}
|
||||
|
||||
void PropSet::Set(char *keyval) {
|
||||
while (isspace(*keyval))
|
||||
keyval++;
|
||||
char *eqat = strchr(keyval, '=');
|
||||
if (eqat) {
|
||||
*eqat = '\0';
|
||||
Set(keyval, eqat + 1);
|
||||
*eqat = '=';
|
||||
}
|
||||
}
|
||||
|
||||
SString PropSet::Get(const char *key) {
|
||||
unsigned int hash = HashString(key);
|
||||
for (Property *p=props[hash % hashRoots]; p; p=p->next) {
|
||||
if ((hash == p->hash) && (0 == strcmp(p->key, key))) {
|
||||
return p->val;
|
||||
}
|
||||
}
|
||||
if (superPS) {
|
||||
// Failed here, so try in base property set
|
||||
return superPS->Get(key);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
SString PropSet::GetExpanded(const char *key) {
|
||||
SString val = Get(key);
|
||||
return Expand(val.c_str());
|
||||
}
|
||||
|
||||
SString PropSet::Expand(const char *withvars) {
|
||||
char *base = StringDup(withvars);
|
||||
char *cpvar = strstr(base, "$(");
|
||||
while (cpvar) {
|
||||
char *cpendvar = strchr(cpvar, ')');
|
||||
if (cpendvar) {
|
||||
int lenvar = cpendvar - cpvar - 2; // Subtract the $()
|
||||
char *var = StringDup(cpvar+2, lenvar);
|
||||
SString val = GetExpanded(var);
|
||||
int newlenbase = strlen(base) + val.length() - lenvar;
|
||||
char *newbase = new char[newlenbase];
|
||||
strncpy(newbase, base, cpvar - base);
|
||||
strcpy(newbase + (cpvar - base), val.c_str());
|
||||
strcpy(newbase + (cpvar - base) + val.length(), cpendvar + 1);
|
||||
delete []var;
|
||||
delete []base;
|
||||
base = newbase;
|
||||
}
|
||||
cpvar = strstr(base, "$(");
|
||||
}
|
||||
SString sret = base;
|
||||
delete []base;
|
||||
return sret;
|
||||
}
|
||||
|
||||
int PropSet::GetInt(const char *key, int defaultValue) {
|
||||
SString val = Get(key);
|
||||
if (val.length())
|
||||
return val.value();
|
||||
else
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
inline bool isprefix(const char *target, const char *prefix) {
|
||||
while (*target && *prefix) {
|
||||
if (*target != *prefix)
|
||||
return false;
|
||||
target++;
|
||||
prefix++;
|
||||
}
|
||||
if (*prefix)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
bool issuffix(const char *target, const char *suffix) {
|
||||
int lentarget = strlen(target);
|
||||
int lensuffix = strlen(suffix);
|
||||
if (lensuffix > lentarget)
|
||||
return false;
|
||||
for (int i = lensuffix - 1; i >= 0; i--) {
|
||||
if (target[i + lentarget - lensuffix] != suffix[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
SString PropSet::GetWild(const char *keybase, const char *filename) {
|
||||
for (int root=0; root < hashRoots; root++) {
|
||||
for (Property *p=props[root]; p; p=p->next) {
|
||||
if (isprefix(p->key, keybase)) {
|
||||
char *orgkeyfile = p->key + strlen(keybase);
|
||||
char *keyfile = NULL;
|
||||
|
||||
if (strstr(orgkeyfile, "$(") == orgkeyfile) {
|
||||
char *cpendvar = strchr(orgkeyfile, ')');
|
||||
if (cpendvar) {
|
||||
*cpendvar = '\0';
|
||||
SString s = Get(orgkeyfile + 2);
|
||||
*cpendvar= ')';
|
||||
keyfile = strdup(s.c_str());
|
||||
}
|
||||
}
|
||||
char *keyptr = keyfile;
|
||||
|
||||
if (keyfile == NULL)
|
||||
keyfile = orgkeyfile;
|
||||
|
||||
for (; ; ) {
|
||||
char *del = strchr(keyfile, ';');
|
||||
if (del == NULL)
|
||||
del = keyfile + strlen(keyfile);
|
||||
char delchr = *del;
|
||||
*del = '\0';
|
||||
if (*keyfile == '*') {
|
||||
if (issuffix(filename, keyfile + 1)) {
|
||||
*del = delchr;
|
||||
free(keyptr);
|
||||
return p->val;
|
||||
}
|
||||
} else if (0 == strcmp(keyfile, filename)) {
|
||||
*del = delchr;
|
||||
free(keyptr);
|
||||
return p->val;
|
||||
}
|
||||
if (delchr == '\0')
|
||||
break;
|
||||
*del = delchr;
|
||||
keyfile = del + 1;
|
||||
}
|
||||
free(keyptr);
|
||||
|
||||
if (0 == strcmp(p->key, keybase)) {
|
||||
return p->val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (superPS) {
|
||||
// Failed here, so try in base property set
|
||||
return superPS->GetWild(keybase, filename);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
SString PropSet::GetNewExpand(const char *keybase, const char *filename) {
|
||||
char *base = StringDup(GetWild(keybase, filename).c_str());
|
||||
char *cpvar = strstr(base, "$(");
|
||||
while (cpvar) {
|
||||
char *cpendvar = strchr(cpvar, ')');
|
||||
if (cpendvar) {
|
||||
int lenvar = cpendvar - cpvar - 2; // Subtract the $()
|
||||
char *var = StringDup(cpvar+2, lenvar);
|
||||
SString val = GetWild(var, filename);
|
||||
int newlenbase = strlen(base) + val.length() - lenvar;
|
||||
char *newbase = new char[newlenbase];
|
||||
strncpy(newbase, base, cpvar - base);
|
||||
strcpy(newbase + (cpvar - base), val.c_str());
|
||||
strcpy(newbase + (cpvar - base) + val.length(), cpendvar + 1);
|
||||
delete []var;
|
||||
delete []base;
|
||||
base = newbase;
|
||||
}
|
||||
cpvar = strstr(base, "$(");
|
||||
}
|
||||
SString sret = base;
|
||||
delete []base;
|
||||
return sret;
|
||||
}
|
||||
|
||||
void PropSet::Clear() {
|
||||
for (int root=0; root < hashRoots; root++) {
|
||||
Property *p=props[root];
|
||||
while (p) {
|
||||
Property *pNext=p->next;
|
||||
p->hash = 0;
|
||||
delete p->key;
|
||||
p->key = 0;
|
||||
delete p->val;
|
||||
p->val = 0;
|
||||
delete p;
|
||||
p = pNext;
|
||||
}
|
||||
props[root] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void PropSet::ReadFromMemory(const char *data, int len, const char *directoryForImports) {
|
||||
const char *pd = data;
|
||||
char linebuf[60000];
|
||||
bool ifIsTrue = true;
|
||||
while (len > 0) {
|
||||
GetFullLine(pd, len, linebuf, sizeof(linebuf));
|
||||
if (isalpha(linebuf[0])) // If clause ends with first non-indented line
|
||||
ifIsTrue = true;
|
||||
if (isprefix(linebuf, "if ")) {
|
||||
const char *expr = linebuf + strlen("if") + 1;
|
||||
ifIsTrue = GetInt(expr);
|
||||
} else if (isprefix(linebuf, "import ") && directoryForImports) {
|
||||
char importPath[1024];
|
||||
strcpy(importPath, directoryForImports);
|
||||
strcat(importPath, linebuf + strlen("import") + 1);
|
||||
strcat(importPath, ".properties");
|
||||
Read(importPath,directoryForImports);
|
||||
} else if (isalpha(linebuf[0])) {
|
||||
Set(linebuf);
|
||||
} else if (isspace(linebuf[0]) && ifIsTrue) {
|
||||
Set(linebuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PropSet::Read(const char *filename, const char *directoryForImports) {
|
||||
char propsData[60000];
|
||||
FILE *rcfile = fopen(filename, "rb");
|
||||
if (rcfile) {
|
||||
int lenFile = fread(propsData, 1, sizeof(propsData), rcfile);
|
||||
fclose(rcfile);
|
||||
ReadFromMemory(propsData, lenFile, directoryForImports);
|
||||
} else {
|
||||
//printf("Could not open <%s>\n", filename);
|
||||
}
|
||||
}
|
||||
|
||||
static bool iswordsep(char ch, bool onlyLineEnds) {
|
||||
if (!isspace(ch))
|
||||
return false;
|
||||
if (!onlyLineEnds)
|
||||
return true;
|
||||
return ch == '\r' || ch == '\n';
|
||||
}
|
||||
|
||||
// Creates an array that points into each word in the string and puts \0 terminators
|
||||
// after each word.
|
||||
static char **ArrayFromWordList(char *wordlist, int *len, bool onlyLineEnds = false) {
|
||||
#if 1
|
||||
char prev = '\n';
|
||||
int words = 0;
|
||||
for (int j = 0; wordlist[j]; j++) {
|
||||
if (!iswordsep(wordlist[j], onlyLineEnds) && iswordsep(prev, onlyLineEnds))
|
||||
words++;
|
||||
prev = wordlist[j];
|
||||
}
|
||||
char **keywords = new char * [words + 1];
|
||||
if (keywords) {
|
||||
words = 0;
|
||||
prev = '\0';
|
||||
int slen = strlen(wordlist);
|
||||
for (int k = 0; k < slen; k++) {
|
||||
if (!iswordsep(wordlist[k], onlyLineEnds)) {
|
||||
if (!prev) {
|
||||
keywords[words] = &wordlist[k];
|
||||
words++;
|
||||
}
|
||||
} else {
|
||||
wordlist[k] = '\0';
|
||||
}
|
||||
prev = wordlist[k];
|
||||
}
|
||||
keywords[words] = &wordlist[slen];
|
||||
*len = words;
|
||||
} else {
|
||||
*len = 0;
|
||||
}
|
||||
#else
|
||||
int words = 0; // length of the returned buffer of pointers
|
||||
#undef APICHUNK // how many pointers will be pre-allocated (to avoid buffer reallocation on each new pointer)
|
||||
#define APICHUNK 256
|
||||
int size = APICHUNK; // real size of the returned buffer of pointers
|
||||
char **keywords; // buffer for the pointers returned
|
||||
int slen = strlen(wordlist); //length of the buffer with api file
|
||||
keywords = (char**) malloc((size + 1) * sizeof (*keywords));
|
||||
words = 0;
|
||||
for (int k = 0;;) {
|
||||
while (iswordsep(wordlist[k], onlyLineEnds))
|
||||
wordlist[k++] = '\0';
|
||||
if (k >= slen)
|
||||
break;
|
||||
if (words >= size) {
|
||||
do
|
||||
size += APICHUNK;
|
||||
while (size <= words);
|
||||
keywords = (char**) realloc(keywords, (size + 1) * sizeof (*keywords));
|
||||
}
|
||||
keywords[words++] = wordlist + k;
|
||||
do
|
||||
if (k < slen)
|
||||
k++;
|
||||
else
|
||||
goto out;
|
||||
while (!iswordsep(wordlist[k], onlyLineEnds));
|
||||
}
|
||||
out:
|
||||
keywords[words] = wordlist + slen;
|
||||
*len = words;
|
||||
#endif
|
||||
return keywords;
|
||||
}
|
||||
|
||||
void WordList::Clear() {
|
||||
if (words) {
|
||||
delete []list;
|
||||
#if 1
|
||||
delete []words;
|
||||
#else
|
||||
free(words);
|
||||
#endif
|
||||
free(wordsNoCase);
|
||||
}
|
||||
words = 0;
|
||||
wordsNoCase = 0;
|
||||
list = 0;
|
||||
len = 0;
|
||||
sorted = false;
|
||||
}
|
||||
|
||||
void WordList::Set(const char *s) {
|
||||
list = StringDup(s);
|
||||
sorted = false;
|
||||
words = ArrayFromWordList(list, &len, onlyLineEnds);
|
||||
wordsNoCase = (char**) malloc ((len + 1) * sizeof (*wordsNoCase));
|
||||
memcpy(wordsNoCase, words, (len + 1) * sizeof (*words));
|
||||
}
|
||||
|
||||
char *WordList::Allocate(int size) {
|
||||
list = new char[size + 1];
|
||||
list[size] = '\0';
|
||||
return list;
|
||||
}
|
||||
|
||||
void WordList::SetFromAllocated() {
|
||||
sorted = false;
|
||||
words = ArrayFromWordList(list, &len, onlyLineEnds);
|
||||
wordsNoCase = (char**) malloc ((len + 1) * sizeof (*wordsNoCase));
|
||||
memcpy(wordsNoCase, words, (len + 1) * sizeof (*words));
|
||||
}
|
||||
|
||||
int cmpString(const void *a1, const void *a2) {
|
||||
// Can't work out the correct incantation to use modern casts here
|
||||
return strcmp(*(char**)(a1), *(char**)(a2));
|
||||
}
|
||||
|
||||
int cmpStringNoCase(const void *a1, const void *a2) {
|
||||
// Can't work out the correct incantation to use modern casts here
|
||||
return strcasecmp(*(char**)(a1), *(char**)(a2));
|
||||
}
|
||||
|
||||
static void SortWordList(char **words, char **wordsNoCase, unsigned int len) {
|
||||
qsort(reinterpret_cast<void*>(words), len, sizeof(*words),
|
||||
cmpString);
|
||||
qsort(reinterpret_cast<void*>(wordsNoCase), len, sizeof(*wordsNoCase),
|
||||
cmpStringNoCase);
|
||||
}
|
||||
|
||||
bool WordList::InList(const char *s) {
|
||||
if (0 == words)
|
||||
return false;
|
||||
if (!sorted) {
|
||||
sorted = true;
|
||||
SortWordList(words, wordsNoCase, len);
|
||||
for (unsigned int k = 0; k < (sizeof(starts) / sizeof(starts[0])); k++)
|
||||
starts[k] = -1;
|
||||
for (int l = len - 1; l >= 0; l--) {
|
||||
unsigned char indexChar = words[l][0];
|
||||
starts[indexChar] = l;
|
||||
}
|
||||
}
|
||||
unsigned char firstChar = s[0];
|
||||
int j = starts[firstChar];
|
||||
if (j >= 0) {
|
||||
while (words[j][0] == firstChar) {
|
||||
if (s[1] == words[j][1]) {
|
||||
const char *a = words[j] + 1;
|
||||
const char *b = s + 1;
|
||||
while (*a && *a == *b) {
|
||||
a++;
|
||||
b++;
|
||||
}
|
||||
if (!*a && !*b)
|
||||
return true;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an element (complete) of the wordlist array which has the beginning
|
||||
* the same as the passed string. The length of the word to compare is passed
|
||||
* too. Letter case can be ignored or preserved (default).
|
||||
*/
|
||||
const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1*/, bool ignoreCase /*= false*/) {
|
||||
int start = 0; // lower bound of the api array block to search
|
||||
int end = len - 1; // upper bound of the api array block to search
|
||||
int pivot; // index of api array element just being compared
|
||||
int cond; // comparison result (in the sense of strcmp() result)
|
||||
const char *word; // api array element just being compared
|
||||
|
||||
if (0 == words)
|
||||
return NULL;
|
||||
if (!sorted) {
|
||||
sorted = true;
|
||||
SortWordList(words, wordsNoCase, len);
|
||||
}
|
||||
if (ignoreCase)
|
||||
while (start <= end) { // binary searching loop
|
||||
pivot = (start + end) >> 1;
|
||||
word = wordsNoCase[pivot];
|
||||
cond = strncasecmp(wordStart, word, searchLen);
|
||||
if (!cond && nonFuncChar(word[searchLen])) // maybe there should be a "non-word character" test here?
|
||||
return word; // result must not be freed with free()
|
||||
else if (cond < 0)
|
||||
end = pivot - 1;
|
||||
else if (cond > 0)
|
||||
start = pivot + 1;
|
||||
}
|
||||
else // preserve the letter case
|
||||
while (start <= end) { // binary searching loop
|
||||
pivot = (start + end) >> 1;
|
||||
word = words[pivot];
|
||||
cond = strncmp(wordStart, word, searchLen);
|
||||
if (!cond && nonFuncChar(word[searchLen])) // maybe there should be a "non-word character" test here?
|
||||
return word; // result must not be freed with free()
|
||||
else if (cond >= 0)
|
||||
start = pivot + 1;
|
||||
else if (cond < 0)
|
||||
end = pivot - 1;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns elements (first words of them) of the wordlist array which have
|
||||
* the beginning the same as the passed string. The length of the word to
|
||||
* compare is passed too. Letter case can be ignored or preserved (default).
|
||||
* If there are more words meeting the condition they are returned all of
|
||||
* them in the ascending order separated with spaces.
|
||||
*
|
||||
* NOTE: returned buffer has to be freed with a free() call.
|
||||
*/
|
||||
char *WordList::GetNearestWords(const char *wordStart, int searchLen /*= -1*/, bool ignoreCase /*= false*/) {
|
||||
int wordlen; // length of the word part (before the '(' brace) of the api array element
|
||||
int length = 0; // length of the returned buffer of words (string)
|
||||
int newlength; // length of the new buffer before the reallocating itself
|
||||
#undef WORDCHUNK // how many characters will be pre-allocated (to avoid buffer reallocation on each new word)
|
||||
#define WORDCHUNK 100
|
||||
int size = WORDCHUNK; // real size of the returned buffer of words
|
||||
char *buffer; // buffer for the words returned
|
||||
int start = 0; // lower bound of the api array block to search
|
||||
int end = len - 1; // upper bound of the api array block to search
|
||||
int pivot; // index of api array element just being compared
|
||||
int cond; // comparison result (in the sense of strcmp() result)
|
||||
int oldpivot; // pivot storage to be able to browse the api array upwards and then downwards
|
||||
const char *word; // api array element just being compared
|
||||
const char *brace; // position of the opening brace in the api array element just being compared
|
||||
|
||||
if (0 == words)
|
||||
return NULL;
|
||||
if (!sorted) {
|
||||
sorted = true;
|
||||
SortWordList(words, wordsNoCase, len);
|
||||
}
|
||||
buffer = (char*) malloc(size);
|
||||
*buffer = '\0';
|
||||
if (ignoreCase)
|
||||
while (start <= end) { // binary searching loop
|
||||
pivot = (start + end) >> 1;
|
||||
word = wordsNoCase[pivot];
|
||||
cond = strncasecmp(wordStart, word, searchLen);
|
||||
if (!cond) {
|
||||
oldpivot = pivot;
|
||||
do { // browse sequentially the rest after the hit
|
||||
brace = strchr(word, '(');
|
||||
if (brace)
|
||||
do
|
||||
if (--brace < word)
|
||||
break;
|
||||
while (isspace(*brace));
|
||||
else {
|
||||
brace = word + strlen(word);
|
||||
do
|
||||
if (--brace < word)
|
||||
break;
|
||||
while (isspace(*brace));
|
||||
}
|
||||
wordlen = brace - word + 1;
|
||||
newlength = length + wordlen; // stretch the buffer
|
||||
if (length)
|
||||
newlength++;
|
||||
if (newlength >= size) {
|
||||
do
|
||||
size += WORDCHUNK;
|
||||
while (size <= newlength);
|
||||
buffer = (char*) realloc(buffer, size);
|
||||
}
|
||||
if (length) // append a new entry
|
||||
buffer[length++] = ' ';
|
||||
memcpy(buffer + length, word, wordlen);
|
||||
length = newlength;
|
||||
buffer[length] = '\0';
|
||||
if (++pivot > end)
|
||||
break;
|
||||
word = wordsNoCase[pivot];
|
||||
} while (!strncasecmp(wordStart, word, searchLen));
|
||||
|
||||
pivot = oldpivot;
|
||||
for (;;) { // browse sequentially the rest before the hit
|
||||
if (--pivot < start)
|
||||
break;
|
||||
word = wordsNoCase[pivot];
|
||||
if (strncasecmp(wordStart, word, searchLen))
|
||||
break;
|
||||
brace = strchr(word, '(');
|
||||
if (brace)
|
||||
do
|
||||
if (--brace < word)
|
||||
break;
|
||||
while (isspace(*brace));
|
||||
else {
|
||||
brace = word + strlen(word);
|
||||
do
|
||||
if (--brace < word)
|
||||
break;
|
||||
while (isspace(*brace));
|
||||
}
|
||||
wordlen = brace - word + 1;
|
||||
newlength = length + wordlen; // stretch the buffer
|
||||
if (length)
|
||||
newlength++;
|
||||
if (newlength >= size)
|
||||
{
|
||||
do
|
||||
size += WORDCHUNK;
|
||||
while (size <= newlength);
|
||||
buffer = (char*) realloc(buffer, size);
|
||||
}
|
||||
if (length) // append a new entry
|
||||
buffer[length++] = ' ';
|
||||
memcpy(buffer + length, word, wordlen);
|
||||
length = newlength;
|
||||
buffer[length] = '\0';
|
||||
}
|
||||
return buffer; // result has to be freed with free()
|
||||
}
|
||||
else if (cond < 0)
|
||||
end = pivot - 1;
|
||||
else if (cond > 0)
|
||||
start = pivot + 1;
|
||||
}
|
||||
else // preserve the letter case
|
||||
while (start <= end) { // binary searching loop
|
||||
pivot = (start + end) >> 1;
|
||||
word = words[pivot];
|
||||
cond = strncmp(wordStart, word, searchLen);
|
||||
if (!cond) {
|
||||
oldpivot = pivot;
|
||||
do { // browse sequentially the rest after the hit
|
||||
brace = strchr(word, '(');
|
||||
if (brace)
|
||||
do
|
||||
if (--brace < word)
|
||||
break;
|
||||
while (isspace(*brace));
|
||||
else {
|
||||
brace = word + strlen(word);
|
||||
do
|
||||
if (--brace < word)
|
||||
break;
|
||||
while (isspace(*brace));
|
||||
}
|
||||
wordlen = brace - word + 1;
|
||||
newlength = length + wordlen; // stretch the buffer
|
||||
if (length)
|
||||
newlength++;
|
||||
if (newlength >= size)
|
||||
{
|
||||
do
|
||||
size += WORDCHUNK;
|
||||
while (size <= newlength);
|
||||
buffer = (char*) realloc(buffer, size);
|
||||
}
|
||||
if (length) // append a new entry
|
||||
buffer[length++] = ' ';
|
||||
memcpy(buffer + length, word, wordlen);
|
||||
length = newlength;
|
||||
buffer[length] = '\0';
|
||||
if (++pivot > end)
|
||||
break;
|
||||
word = words[pivot];
|
||||
} while (!strncmp(wordStart, word, searchLen));
|
||||
|
||||
pivot = oldpivot;
|
||||
for (;;) { // browse sequentially the rest before the hit
|
||||
if (--pivot < start)
|
||||
break;
|
||||
word = words[pivot];
|
||||
if (strncmp(wordStart, word, searchLen))
|
||||
break;
|
||||
brace = strchr(word, '(');
|
||||
if (brace)
|
||||
do
|
||||
if (--brace < word)
|
||||
break;
|
||||
while (isspace(*brace));
|
||||
else {
|
||||
brace = word + strlen(word);
|
||||
do
|
||||
if (--brace < word)
|
||||
break;
|
||||
while (isspace(*brace));
|
||||
}
|
||||
wordlen = brace - word + 1;
|
||||
newlength = length + wordlen; // stretch the buffer
|
||||
if (length)
|
||||
newlength++;
|
||||
if (newlength >= size)
|
||||
{
|
||||
do
|
||||
size += WORDCHUNK;
|
||||
while (size <= newlength);
|
||||
buffer = (char*) realloc(buffer, size);
|
||||
}
|
||||
if (length) // append a new entry
|
||||
buffer[length++] = ' ';
|
||||
memcpy(buffer + length, word, wordlen);
|
||||
length = newlength;
|
||||
buffer[length] = '\0';
|
||||
}
|
||||
return buffer; // result has to be freed with free()
|
||||
}
|
||||
else if (cond < 0)
|
||||
end = pivot - 1;
|
||||
else if (cond > 0)
|
||||
start = pivot + 1;
|
||||
}
|
||||
free(buffer);
|
||||
return NULL;
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// SVector.h - a simple expandable vector
|
||||
// Copyright 1998-1999 by Neil Hodgson <neilh@hare.net.au>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef SVECTOR_H
|
||||
#define SVECTOR_H
|
||||
|
||||
// A simple expandable integer vector.
|
||||
// Storage not allocated for elements until an element is used.
|
||||
// This makes it very lightweight unless used so is a good match for optional features.
|
||||
|
||||
class SVector {
|
||||
int *v;
|
||||
unsigned int size; // Number of elements allocated
|
||||
unsigned int len; // Number of elements in vector
|
||||
bool allocFailure; // A memory allocation call has failed
|
||||
|
||||
// Internally allocate more elements than the user wants to avoid
|
||||
// thrashng the memory allocator
|
||||
void SizeTo(int newSize) {
|
||||
if (newSize < 4000)
|
||||
newSize += 4000;
|
||||
else
|
||||
newSize = (newSize * 3) / 2;
|
||||
int* newv = new int[newSize];
|
||||
if (!newv) {
|
||||
allocFailure = true;
|
||||
return;
|
||||
}
|
||||
size = newSize;
|
||||
unsigned int i=0;
|
||||
for (; i<len; i++) {
|
||||
newv[i] = v[i];
|
||||
}
|
||||
for (; i<size; i++) {
|
||||
newv[i] = 0;
|
||||
}
|
||||
delete []v;
|
||||
v = newv;
|
||||
}
|
||||
|
||||
public:
|
||||
SVector() {
|
||||
allocFailure = false;
|
||||
v = 0;
|
||||
len = 0;
|
||||
size = 0;
|
||||
}
|
||||
~SVector() {
|
||||
Free();
|
||||
}
|
||||
SVector(const SVector &other) {
|
||||
allocFailure = false;
|
||||
v = 0;
|
||||
len = 0;
|
||||
size = 0;
|
||||
if (other.Length() > 0) {
|
||||
SizeTo(other.Length());
|
||||
if (!allocFailure) {
|
||||
for (int i=0;i<other.Length();i++)
|
||||
v[i] = other.v[i];
|
||||
len = other.Length();
|
||||
}
|
||||
}
|
||||
}
|
||||
SVector &operator=(const SVector &other) {
|
||||
if (this != &other) {
|
||||
delete []v;
|
||||
allocFailure = false;
|
||||
v = 0;
|
||||
len = 0;
|
||||
size = 0;
|
||||
if (other.Length() > 0) {
|
||||
SizeTo(other.Length());
|
||||
if (!allocFailure) {
|
||||
for (int i=0;i<other.Length();i++)
|
||||
v[i] = other.v[i];
|
||||
}
|
||||
len = other.Length();
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
int &operator[](unsigned int i) {
|
||||
if (i >= len) {
|
||||
if (i >= size) {
|
||||
SizeTo(i);
|
||||
}
|
||||
len = i+1;
|
||||
}
|
||||
return v[i];
|
||||
}
|
||||
void Free() {
|
||||
delete []v;
|
||||
v = 0;
|
||||
size = 0;
|
||||
len = 0;
|
||||
}
|
||||
void SetLength(unsigned int newLength) {
|
||||
if (newLength > len) {
|
||||
if (newLength >= size) {
|
||||
SizeTo(newLength);
|
||||
}
|
||||
}
|
||||
len = newLength;
|
||||
}
|
||||
int Length() const {
|
||||
return len;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,499 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// ScintillaBase.cxx - an enhanced subclass of Editor with calltips, autocomplete and context menu
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "Scintilla.h"
|
||||
#include "PropSet.h"
|
||||
#ifdef SCI_LEXER
|
||||
#include "SciLexer.h"
|
||||
#include "Accessor.h"
|
||||
#include "WindowAccessor.h"
|
||||
#include "DocumentAccessor.h"
|
||||
#include "KeyWords.h"
|
||||
#endif
|
||||
#include "ContractionState.h"
|
||||
#include "SVector.h"
|
||||
#include "CellBuffer.h"
|
||||
#include "CallTip.h"
|
||||
#include "KeyMap.h"
|
||||
#include "Indicator.h"
|
||||
#include "LineMarker.h"
|
||||
#include "Style.h"
|
||||
#include "ViewStyle.h"
|
||||
#include "AutoComplete.h"
|
||||
#include "Document.h"
|
||||
#include "Editor.h"
|
||||
#include "ScintillaBase.h"
|
||||
|
||||
ScintillaBase::ScintillaBase() {
|
||||
#ifdef SCI_LEXER
|
||||
lexLanguage = SCLEX_CONTAINER;
|
||||
for (int wl=0;wl<numWordLists;wl++)
|
||||
keyWordLists[wl] = new WordList;
|
||||
#endif
|
||||
}
|
||||
|
||||
ScintillaBase::~ScintillaBase() {
|
||||
#ifdef SCI_LEXER
|
||||
for (int wl=0;wl<numWordLists;wl++)
|
||||
delete keyWordLists[wl];
|
||||
#endif
|
||||
}
|
||||
|
||||
void ScintillaBase::Finalise() {
|
||||
Editor::Finalise();
|
||||
popup.Destroy();
|
||||
}
|
||||
|
||||
void ScintillaBase::RefreshColourPalette(Palette &pal, bool want) {
|
||||
Editor::RefreshColourPalette(pal, want);
|
||||
ct.RefreshColourPalette(pal, want);
|
||||
}
|
||||
|
||||
void ScintillaBase::AddCharUTF(char *s, unsigned int len) {
|
||||
bool acActiveBeforeCharAdded = ac.Active();
|
||||
if (!acActiveBeforeCharAdded || !ac.IsFillUpChar(*s))
|
||||
Editor::AddCharUTF(s, len);
|
||||
if (acActiveBeforeCharAdded)
|
||||
AutoCompleteChanged(s[0]);
|
||||
}
|
||||
|
||||
void ScintillaBase::Command(int cmdId) {
|
||||
|
||||
switch (cmdId) {
|
||||
|
||||
case idAutoComplete: // Nothing to do
|
||||
break;
|
||||
|
||||
case idCallTip: // Nothing to do
|
||||
break;
|
||||
|
||||
case idcmdUndo:
|
||||
WndProc(SCI_UNDO, 0, 0);
|
||||
break;
|
||||
|
||||
case idcmdRedo:
|
||||
WndProc(SCI_REDO, 0, 0);
|
||||
break;
|
||||
|
||||
case idcmdCut:
|
||||
WndProc(SCI_CUT, 0, 0);
|
||||
break;
|
||||
|
||||
case idcmdCopy:
|
||||
WndProc(SCI_COPY, 0, 0);
|
||||
break;
|
||||
|
||||
case idcmdPaste:
|
||||
WndProc(SCI_PASTE, 0, 0);
|
||||
break;
|
||||
|
||||
case idcmdDelete:
|
||||
WndProc(SCI_CLEAR, 0, 0);
|
||||
break;
|
||||
|
||||
case idcmdSelectAll:
|
||||
WndProc(SCI_SELECTALL, 0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int ScintillaBase::KeyCommand(unsigned int iMessage) {
|
||||
// Most key commands cancel autocompletion mode
|
||||
if (ac.Active()) {
|
||||
switch (iMessage) {
|
||||
// Except for these
|
||||
case SCI_LINEDOWN:
|
||||
AutoCompleteMove(1);
|
||||
return 0;
|
||||
case SCI_LINEUP:
|
||||
AutoCompleteMove( -1);
|
||||
return 0;
|
||||
case SCI_PAGEDOWN:
|
||||
AutoCompleteMove(5);
|
||||
return 0;
|
||||
case SCI_PAGEUP:
|
||||
AutoCompleteMove( -5);
|
||||
return 0;
|
||||
case SCI_VCHOME:
|
||||
AutoCompleteMove( -5000);
|
||||
return 0;
|
||||
case SCI_LINEEND:
|
||||
AutoCompleteMove(5000);
|
||||
return 0;
|
||||
case SCI_DELETEBACK:
|
||||
DelCharBack();
|
||||
AutoCompleteChanged();
|
||||
EnsureCaretVisible();
|
||||
return 0;
|
||||
case SCI_TAB:
|
||||
AutoCompleteCompleted();
|
||||
return 0;
|
||||
case SCI_NEWLINE:
|
||||
AutoCompleteCompleted();
|
||||
return 0;
|
||||
|
||||
default:
|
||||
ac.Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
if (ct.inCallTipMode) {
|
||||
if (
|
||||
(iMessage != SCI_CHARLEFT) &&
|
||||
(iMessage != SCI_CHARLEFTEXTEND) &&
|
||||
(iMessage != SCI_CHARRIGHT) &&
|
||||
(iMessage != SCI_CHARLEFTEXTEND) &&
|
||||
(iMessage != SCI_EDITTOGGLEOVERTYPE) &&
|
||||
(iMessage != SCI_DELETEBACK)
|
||||
) {
|
||||
ct.CallTipCancel();
|
||||
}
|
||||
if (iMessage == SCI_DELETEBACK) {
|
||||
if (currentPos <= ct.posStartCallTip) {
|
||||
ct.CallTipCancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Editor::KeyCommand(iMessage);
|
||||
}
|
||||
|
||||
void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
|
||||
//Platform::DebugPrintf("AutoComplete %s\n", list);
|
||||
ct.CallTipCancel();
|
||||
|
||||
if (ac.chooseSingle) {
|
||||
if (list && !strchr(list, ac.GetSeparator())) {
|
||||
if (ac.ignoreCase) {
|
||||
SetEmptySelection(currentPos - lenEntered);
|
||||
pdoc->DeleteChars(currentPos, lenEntered);
|
||||
SetEmptySelection(currentPos);
|
||||
pdoc->InsertString(currentPos, list);
|
||||
SetEmptySelection(currentPos + strlen(list));
|
||||
} else {
|
||||
SetEmptySelection(currentPos);
|
||||
pdoc->InsertString(currentPos, list + lenEntered);
|
||||
SetEmptySelection(currentPos + strlen(list + lenEntered));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
ac.Start(wDraw, idAutoComplete, currentPos, lenEntered);
|
||||
|
||||
PRectangle rcClient = GetClientRectangle();
|
||||
Point pt = LocationFromPosition(currentPos-lenEntered);
|
||||
|
||||
int heightLB = 100;
|
||||
int widthLB = 100;
|
||||
if (pt.x >= rcClient.right - widthLB) {
|
||||
HorizontalScrollTo(xOffset + pt.x - rcClient.right + widthLB);
|
||||
Redraw();
|
||||
pt = LocationFromPosition(currentPos);
|
||||
}
|
||||
PRectangle rcac;
|
||||
rcac.left = pt.x - 5;
|
||||
if (pt.y >= rcClient.bottom - heightLB && // Wont fit below.
|
||||
pt.y >= (rcClient.bottom + rcClient.top) / 2) { // and there is more room above.
|
||||
rcac.top = pt.y - heightLB;
|
||||
if (rcac.top < 0) {
|
||||
heightLB += rcac.top;
|
||||
rcac.top = 0;
|
||||
}
|
||||
} else {
|
||||
rcac.top = pt.y + vs.lineHeight;
|
||||
}
|
||||
rcac.right = rcac.left + widthLB;
|
||||
rcac.bottom = Platform::Minimum(rcac.top + heightLB, rcClient.bottom);
|
||||
ac.lb.SetPositionRelative(rcac, wMain);
|
||||
ac.lb.SetFont(vs.styles[STYLE_DEFAULT].font);
|
||||
ac.lb.SetAverageCharWidth(vs.styles[STYLE_DEFAULT].aveCharWidth);
|
||||
|
||||
ac.SetList(list);
|
||||
|
||||
// Fiddle the position of the list so it is right next to the target and wide enough for all its strings
|
||||
PRectangle rcList = ac.lb.GetDesiredRect();
|
||||
int heightAlloced = rcList.bottom - rcList.top;
|
||||
widthLB = Platform::Maximum(widthLB, rcList.right - rcList.left);
|
||||
// Make an allowance for large strings in list
|
||||
rcList.left = pt.x - 5;
|
||||
rcList.right = rcList.left + widthLB;
|
||||
if (pt.y >= rcClient.bottom - heightLB && // Wont fit below.
|
||||
pt.y >= (rcClient.bottom + rcClient.top) / 2) { // and there is more room above.
|
||||
rcList.top = pt.y - heightAlloced;
|
||||
} else {
|
||||
rcList.top = pt.y + vs.lineHeight;
|
||||
}
|
||||
rcList.bottom = rcList.top + heightAlloced;
|
||||
ac.lb.SetPositionRelative(rcList, wMain);
|
||||
ac.Show();
|
||||
if (lenEntered != 0) {
|
||||
AutoCompleteMoveToCurrentWord();
|
||||
}
|
||||
}
|
||||
|
||||
void ScintillaBase::AutoCompleteCancel() {
|
||||
ac.Cancel();
|
||||
}
|
||||
|
||||
void ScintillaBase::AutoCompleteMove(int delta) {
|
||||
ac.Move(delta);
|
||||
}
|
||||
|
||||
void ScintillaBase::AutoCompleteMoveToCurrentWord() {
|
||||
char wordCurrent[1000];
|
||||
int i;
|
||||
int startWord = ac.posStart - ac.startLen;
|
||||
for (i = startWord; i < currentPos; i++)
|
||||
wordCurrent[i - startWord] = pdoc->CharAt(i);
|
||||
wordCurrent[i - startWord] = '\0';
|
||||
ac.Select(wordCurrent);
|
||||
}
|
||||
|
||||
void ScintillaBase::AutoCompleteChanged(char ch) {
|
||||
if (ac.IsFillUpChar(ch)) {
|
||||
AutoCompleteCompleted(ch);
|
||||
} else if (currentPos <= ac.posStart - ac.startLen) {
|
||||
ac.Cancel();
|
||||
} else if (ac.cancelAtStartPos && currentPos <= ac.posStart) {
|
||||
ac.Cancel();
|
||||
} else if (ac.IsStopChar(ch)) {
|
||||
ac.Cancel();
|
||||
} else {
|
||||
AutoCompleteMoveToCurrentWord();
|
||||
}
|
||||
}
|
||||
|
||||
void ScintillaBase::AutoCompleteCompleted(char fillUp/*='\0'*/) {
|
||||
int item = ac.lb.GetSelection();
|
||||
char selected[1000];
|
||||
if (item != -1) {
|
||||
ac.lb.GetValue(item, selected, sizeof(selected));
|
||||
}
|
||||
ac.Cancel();
|
||||
|
||||
if (ac.ignoreCase) {
|
||||
if (currentPos != ac.posStart) {
|
||||
pdoc->DeleteChars(ac.posStart, currentPos - ac.posStart);
|
||||
}
|
||||
SetEmptySelection(ac.posStart - ac.startLen);
|
||||
pdoc->DeleteChars(ac.posStart - ac.startLen, ac.startLen);
|
||||
if (item != -1) {
|
||||
SString piece = selected;
|
||||
if (fillUp)
|
||||
piece += fillUp;
|
||||
pdoc->InsertString(currentPos, piece.c_str());
|
||||
SetEmptySelection(currentPos + piece.length());
|
||||
}
|
||||
} else {
|
||||
if (currentPos != ac.posStart) {
|
||||
pdoc->DeleteChars(ac.posStart, currentPos - ac.posStart);
|
||||
}
|
||||
SetEmptySelection(ac.posStart);
|
||||
if (item != -1) {
|
||||
SString piece = selected + ac.startLen;
|
||||
if (fillUp)
|
||||
piece += fillUp;
|
||||
pdoc->InsertString(currentPos, piece.c_str());
|
||||
SetEmptySelection(currentPos + piece.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ScintillaBase::ContextMenu(Point pt) {
|
||||
popup.CreatePopUp();
|
||||
AddToPopUp("Undo", idcmdUndo, pdoc->CanUndo());
|
||||
AddToPopUp("Redo", idcmdRedo, pdoc->CanRedo());
|
||||
AddToPopUp("");
|
||||
AddToPopUp("Cut", idcmdCut, currentPos != anchor);
|
||||
AddToPopUp("Copy", idcmdCopy, currentPos != anchor);
|
||||
AddToPopUp("Paste", idcmdPaste, WndProc(SCI_CANPASTE, 0, 0));
|
||||
AddToPopUp("Delete", idcmdDelete, currentPos != anchor);
|
||||
AddToPopUp("");
|
||||
AddToPopUp("Select All", idcmdSelectAll);
|
||||
popup.Show(pt, wMain);
|
||||
}
|
||||
|
||||
void ScintillaBase::CancelModes() {
|
||||
AutoCompleteCancel();
|
||||
ct.CallTipCancel();
|
||||
Editor::CancelModes();
|
||||
}
|
||||
|
||||
void ScintillaBase::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) {
|
||||
CancelModes();
|
||||
Editor::ButtonDown(pt, curTime, shift, ctrl, alt);
|
||||
}
|
||||
|
||||
#ifdef SCI_LEXER
|
||||
void ScintillaBase::Colourise(int start, int end) {
|
||||
int lengthDoc = Platform::SendScintilla(wMain.GetID(), SCI_GETLENGTH, 0, 0);
|
||||
if (end == -1)
|
||||
end = lengthDoc;
|
||||
int len = end - start;
|
||||
|
||||
//WindowAccessor styler(wMain.GetID(), props);
|
||||
DocumentAccessor styler(pdoc, props);
|
||||
|
||||
int styleStart = 0;
|
||||
if (start > 0)
|
||||
styleStart = styler.StyleAt(start - 1);
|
||||
styler.SetCodePage(pdoc->dbcsCodePage);
|
||||
|
||||
LexerModule::Colourise(start, len, styleStart, lexLanguage, keyWordLists, styler);
|
||||
styler.Flush();
|
||||
}
|
||||
#endif
|
||||
|
||||
void ScintillaBase::NotifyStyleToNeeded(int endStyleNeeded) {
|
||||
#ifdef SCI_LEXER
|
||||
if (lexLanguage != SCLEX_CONTAINER) {
|
||||
int endStyled = Platform::SendScintilla(wMain.GetID(), SCI_GETENDSTYLED, 0, 0);
|
||||
int lineEndStyled = Platform::SendScintilla(wMain.GetID(), SCI_LINEFROMPOSITION, endStyled, 0);
|
||||
endStyled = Platform::SendScintilla(wMain.GetID(), SCI_POSITIONFROMLINE, lineEndStyled, 0);
|
||||
Colourise(endStyled, endStyleNeeded);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
Editor::NotifyStyleToNeeded(endStyleNeeded);
|
||||
}
|
||||
|
||||
long ScintillaBase::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) {
|
||||
switch (iMessage) {
|
||||
case SCI_AUTOCSHOW:
|
||||
AutoCompleteStart(wParam, reinterpret_cast<const char *>(lParam));
|
||||
break;
|
||||
|
||||
case SCI_AUTOCCANCEL:
|
||||
AutoCompleteCancel();
|
||||
break;
|
||||
|
||||
case SCI_AUTOCACTIVE:
|
||||
return ac.Active();
|
||||
|
||||
case SCI_AUTOCPOSSTART:
|
||||
return ac.posStart;
|
||||
|
||||
case SCI_AUTOCCOMPLETE:
|
||||
AutoCompleteCompleted();
|
||||
break;
|
||||
|
||||
case SCI_AUTOCSETSEPARATOR:
|
||||
ac.SetSeparator(static_cast<char>(wParam));
|
||||
break;
|
||||
|
||||
case SCI_AUTOCGETSEPARATOR:
|
||||
return ac.GetSeparator();
|
||||
|
||||
case SCI_AUTOCSTOPS:
|
||||
ac.SetStopChars(reinterpret_cast<char *>(lParam));
|
||||
break;
|
||||
|
||||
case SCI_AUTOCSELECT:
|
||||
ac.Select(reinterpret_cast<char *>(lParam));
|
||||
break;
|
||||
|
||||
case SCI_AUTOCSETCANCELATSTART:
|
||||
ac.cancelAtStartPos = wParam;
|
||||
break;
|
||||
|
||||
case SCI_AUTOCGETCANCELATSTART:
|
||||
return ac.cancelAtStartPos;
|
||||
|
||||
case SCI_AUTOCSETFILLUPS:
|
||||
ac.SetFillUpChars(reinterpret_cast<char *>(lParam));
|
||||
break;
|
||||
|
||||
case SCI_AUTOCSETCHOOSESINGLE:
|
||||
ac.chooseSingle = wParam;
|
||||
break;
|
||||
|
||||
case SCI_AUTOCGETCHOOSESINGLE:
|
||||
return ac.chooseSingle;
|
||||
|
||||
case SCI_AUTOCSETIGNORECASE:
|
||||
ac.ignoreCase = wParam;
|
||||
break;
|
||||
|
||||
case SCI_AUTOCGETIGNORECASE:
|
||||
return ac.ignoreCase;
|
||||
|
||||
case SCI_CALLTIPSHOW: {
|
||||
AutoCompleteCancel();
|
||||
if (!ct.wCallTip.Created()) {
|
||||
PRectangle rc = ct.CallTipStart(currentPos, LocationFromPosition(wParam),
|
||||
reinterpret_cast<char *>(lParam),
|
||||
vs.styles[STYLE_DEFAULT].fontName, vs.styles[STYLE_DEFAULT].size);
|
||||
// If the call-tip window would be out of the client
|
||||
// space, adjust so it displays above the text.
|
||||
PRectangle rcClient = GetClientRectangle();
|
||||
if (rc.bottom > rcClient.bottom) {
|
||||
int offset = vs.lineHeight + rc.Height();
|
||||
rc.top -= offset;
|
||||
rc.bottom -= offset;
|
||||
}
|
||||
// Now display the window.
|
||||
CreateCallTipWindow(rc);
|
||||
ct.wCallTip.SetPositionRelative(rc, wDraw);
|
||||
ct.wCallTip.Show();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SCI_CALLTIPCANCEL:
|
||||
ct.CallTipCancel();
|
||||
break;
|
||||
|
||||
case SCI_CALLTIPACTIVE:
|
||||
return ct.inCallTipMode;
|
||||
|
||||
case SCI_CALLTIPPOSSTART:
|
||||
return ct.posStartCallTip;
|
||||
|
||||
case SCI_CALLTIPSETHLT:
|
||||
ct.SetHighlight(wParam, lParam);
|
||||
break;
|
||||
|
||||
case SCI_CALLTIPSETBACK:
|
||||
ct.colourBG = Colour(wParam);
|
||||
InvalidateStyleRedraw();
|
||||
break;
|
||||
|
||||
#ifdef SCI_LEXER
|
||||
case SCI_SETLEXER:
|
||||
lexLanguage = wParam;
|
||||
break;
|
||||
|
||||
case SCI_GETLEXER:
|
||||
return lexLanguage;
|
||||
|
||||
case SCI_COLOURISE:
|
||||
Colourise(wParam, lParam);
|
||||
Redraw();
|
||||
break;
|
||||
|
||||
case SCI_SETPROPERTY:
|
||||
props.Set(reinterpret_cast<const char *>(wParam),
|
||||
reinterpret_cast<const char *>(lParam));
|
||||
break;
|
||||
|
||||
case SCI_SETKEYWORDS:
|
||||
if (wParam < numWordLists) {
|
||||
keyWordLists[wParam]->Clear();
|
||||
keyWordLists[wParam]->Set(reinterpret_cast<const char *>(lParam));
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
return Editor::WndProc(iMessage, wParam, lParam);
|
||||
}
|
||||
return 0l;
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// ScintillaBase.h - defines an enhanced subclass of Editor with calltips, autocomplete and context menu
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef SCINTILLABASE_H
|
||||
#define SCINTILLABASE_H
|
||||
|
||||
class ScintillaBase : public Editor {
|
||||
// Private so ScintillaBase objects can not be copied
|
||||
ScintillaBase(const ScintillaBase &) : Editor() {}
|
||||
ScintillaBase &operator=(const ScintillaBase &) { return *this; }
|
||||
protected:
|
||||
// Enumeration of commands and child windows
|
||||
enum {
|
||||
idCallTip=1,
|
||||
idAutoComplete=2,
|
||||
|
||||
idcmdUndo=10,
|
||||
idcmdRedo=11,
|
||||
idcmdCut=12,
|
||||
idcmdCopy=13,
|
||||
idcmdPaste=14,
|
||||
idcmdDelete=15,
|
||||
idcmdSelectAll=16
|
||||
};
|
||||
|
||||
Menu popup;
|
||||
AutoComplete ac;
|
||||
|
||||
CallTip ct;
|
||||
|
||||
#ifdef SCI_LEXER
|
||||
int lexLanguage;
|
||||
PropSet props;
|
||||
enum {numWordLists=5};
|
||||
WordList *keyWordLists[numWordLists];
|
||||
void Colourise(int start, int end);
|
||||
#endif
|
||||
|
||||
ScintillaBase();
|
||||
virtual ~ScintillaBase();
|
||||
virtual void Initialise() = 0;
|
||||
virtual void Finalise() = 0;
|
||||
|
||||
virtual void RefreshColourPalette(Palette &pal, bool want);
|
||||
|
||||
virtual void AddCharUTF(char *s, unsigned int len);
|
||||
void Command(int cmdId);
|
||||
virtual void CancelModes();
|
||||
virtual int KeyCommand(unsigned int iMessage);
|
||||
|
||||
void AutoCompleteStart(int lenEntered, const char *list);
|
||||
void AutoCompleteCancel();
|
||||
void AutoCompleteMove(int delta);
|
||||
void AutoCompleteChanged(char ch=0);
|
||||
void AutoCompleteCompleted(char fillUp='\0');
|
||||
void AutoCompleteMoveToCurrentWord();
|
||||
|
||||
virtual void CreateCallTipWindow(PRectangle rc) = 0;
|
||||
|
||||
virtual void AddToPopUp(const char *label, int cmd=0, bool enabled=true) = 0;
|
||||
void ContextMenu(Point pt);
|
||||
|
||||
virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
|
||||
|
||||
virtual void NotifyStyleToNeeded(int endStyleNeeded);
|
||||
public:
|
||||
// Public so scintilla_send_message can use it
|
||||
virtual long WndProc(unsigned int iMessage, unsigned long wParam, long lParam);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,125 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// Style.cxx - defines the font and colour style for a class of text
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "Scintilla.h"
|
||||
#include "Style.h"
|
||||
|
||||
Style::Style() {
|
||||
aliasOfDefaultFont = true;
|
||||
Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
|
||||
Platform::DefaultFontSize(), 0, SC_CHARSET_DEFAULT,
|
||||
false, false, false, false, true);
|
||||
}
|
||||
|
||||
Style::Style(const Style &source) {
|
||||
Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
|
||||
0, 0, 0,
|
||||
false, false, false, false, true);
|
||||
fore.desired = source.fore.desired;
|
||||
back.desired = source.back.desired;
|
||||
characterSet = source.characterSet;
|
||||
bold = source.bold;
|
||||
italic = source.italic;
|
||||
size = source.size;
|
||||
eolFilled = source.eolFilled;
|
||||
underline = source.underline;
|
||||
visible = source.visible;
|
||||
}
|
||||
|
||||
Style::~Style() {
|
||||
if (aliasOfDefaultFont)
|
||||
font.SetID(0);
|
||||
else
|
||||
font.Release();
|
||||
aliasOfDefaultFont = false;
|
||||
}
|
||||
|
||||
Style &Style::operator=(const Style &source) {
|
||||
if (this == &source)
|
||||
return *this;
|
||||
Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
|
||||
0, 0, SC_CHARSET_DEFAULT,
|
||||
false, false, false, false, true);
|
||||
fore.desired = source.fore.desired;
|
||||
back.desired = source.back.desired;
|
||||
characterSet = source.characterSet;
|
||||
bold = source.bold;
|
||||
italic = source.italic;
|
||||
size = source.size;
|
||||
eolFilled = source.eolFilled;
|
||||
underline = source.underline;
|
||||
visible = source.visible;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Style::Clear(Colour fore_, Colour back_, int size_,
|
||||
const char *fontName_, int characterSet_,
|
||||
bool bold_, bool italic_, bool eolFilled_, bool underline_, bool visible_) {
|
||||
fore.desired = fore_;
|
||||
back.desired = back_;
|
||||
characterSet = characterSet_;
|
||||
bold = bold_;
|
||||
italic = italic_;
|
||||
size = size_;
|
||||
fontName = fontName_;
|
||||
eolFilled = eolFilled_;
|
||||
underline = underline_;
|
||||
visible = visible_;
|
||||
if (aliasOfDefaultFont)
|
||||
font.SetID(0);
|
||||
else
|
||||
font.Release();
|
||||
aliasOfDefaultFont = false;
|
||||
}
|
||||
|
||||
bool Style::EquivalentFontTo(const Style *other) const {
|
||||
if (bold != other->bold ||
|
||||
italic != other->italic ||
|
||||
size != other->size ||
|
||||
characterSet != other->characterSet)
|
||||
return false;
|
||||
if (fontName == other->fontName)
|
||||
return true;
|
||||
if (!fontName)
|
||||
return false;
|
||||
if (!other->fontName)
|
||||
return false;
|
||||
return strcmp(fontName, other->fontName) == 0;
|
||||
}
|
||||
|
||||
void Style::Realise(Surface &surface, int zoomLevel, Style *defaultStyle) {
|
||||
int sizeZoomed = size + zoomLevel;
|
||||
if (sizeZoomed <= 2) // Hangs if sizeZoomed <= 1
|
||||
sizeZoomed = 2;
|
||||
|
||||
if (aliasOfDefaultFont)
|
||||
font.SetID(0);
|
||||
else
|
||||
font.Release();
|
||||
int deviceHeight = surface.DeviceHeightFont(sizeZoomed);
|
||||
aliasOfDefaultFont = defaultStyle &&
|
||||
(EquivalentFontTo(defaultStyle) || !fontName);
|
||||
if (aliasOfDefaultFont) {
|
||||
font.SetID(defaultStyle->font.GetID());
|
||||
} else if (fontName) {
|
||||
font.Create(fontName, characterSet, deviceHeight, bold, italic);
|
||||
} else {
|
||||
font.SetID(0);
|
||||
}
|
||||
|
||||
ascent = surface.Ascent(font);
|
||||
descent = surface.Descent(font);
|
||||
// Probably more typographically correct to include leading
|
||||
// but that means more complex drawing as leading must be erased
|
||||
//lineHeight = surface.ExternalLeading() + surface.Height();
|
||||
externalLeading = surface.ExternalLeading(font);
|
||||
lineHeight = surface.Height(font);
|
||||
aveCharWidth = surface.AverageCharWidth(font);
|
||||
spaceWidth = surface.WidthChar(font, ' ');
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// Style.h - defines the font and colour style for a class of text
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef STYLE_H
|
||||
#define STYLE_H
|
||||
|
||||
class Style {
|
||||
public:
|
||||
ColourPair fore;
|
||||
ColourPair back;
|
||||
bool aliasOfDefaultFont;
|
||||
bool bold;
|
||||
bool italic;
|
||||
int size;
|
||||
const char *fontName;
|
||||
int characterSet;
|
||||
bool eolFilled;
|
||||
bool underline;
|
||||
bool visible;
|
||||
|
||||
Font font;
|
||||
unsigned int lineHeight;
|
||||
unsigned int ascent;
|
||||
unsigned int descent;
|
||||
unsigned int externalLeading;
|
||||
unsigned int aveCharWidth;
|
||||
unsigned int spaceWidth;
|
||||
|
||||
Style();
|
||||
Style(const Style &source);
|
||||
~Style();
|
||||
Style &operator=(const Style &source);
|
||||
void Clear(Colour fore_, Colour back_,
|
||||
int size_,
|
||||
const char *fontName_, int characterSet_,
|
||||
bool bold_, bool italic_, bool eolFilled_, bool underline_, bool visible_);
|
||||
bool EquivalentFontTo(const Style *other) const;
|
||||
void Realise(Surface &surface, int zoomLevel, Style *defaultStyle=0);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,77 +0,0 @@
|
||||
// UniConversion.h - functions to handle UFT-8 and UCS-2 strings
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "UniConversion.h"
|
||||
|
||||
unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen) {
|
||||
unsigned int len = 0;
|
||||
for (unsigned int i = 0; i < tlen && uptr[i]; i++) {
|
||||
unsigned int uch = uptr[i];
|
||||
if (uch < 0x80)
|
||||
len++;
|
||||
else if (uch < 0x800)
|
||||
len+=2;
|
||||
else
|
||||
len +=3;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
void UTF8FromUCS2(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len) {
|
||||
int k = 0;
|
||||
for (unsigned int i = 0; i < tlen && uptr[i]; i++) {
|
||||
unsigned int uch = uptr[i];
|
||||
if (uch < 0x80) {
|
||||
putf[k++] = static_cast<char>(uch);
|
||||
} else if (uch < 0x800) {
|
||||
putf[k++] = static_cast<char>(0xC0 | (uch >> 6));
|
||||
putf[k++] = static_cast<char>(0x80 | (uch & 0x3f));
|
||||
} else {
|
||||
putf[k++] = static_cast<char>(0xE0 | (uch >> 12));
|
||||
putf[k++] = static_cast<char>(0x80 | ((uch >> 6) & 0x3f));
|
||||
putf[k++] = static_cast<char>(0x80 | (uch & 0x3f));
|
||||
}
|
||||
}
|
||||
putf[len] = '\0';
|
||||
}
|
||||
|
||||
unsigned int UCS2Length(const char *s, unsigned int len) {
|
||||
unsigned int ulen = 0;
|
||||
for (unsigned int i=0;i<len;i++) {
|
||||
unsigned char ch = static_cast<unsigned char>(s[i]);
|
||||
if ((ch < 0x80) || (ch > (0x80 + 0x40)))
|
||||
ulen++;
|
||||
}
|
||||
return ulen;
|
||||
}
|
||||
|
||||
unsigned int UCS2FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen) {
|
||||
#ifdef USE_API
|
||||
return ::MultiByteToWideChar(CP_UTF8, 0, s, len, tbuf, tlen);
|
||||
#else
|
||||
unsigned int ui=0;
|
||||
const unsigned char *us = reinterpret_cast<const unsigned char *>(s);
|
||||
unsigned int i=0;
|
||||
while ((i<len) && (ui<tlen)) {
|
||||
unsigned char ch = us[i++];
|
||||
if (ch < 0x80) {
|
||||
tbuf[ui] = ch;
|
||||
} else if (ch < 0x80 + 0x40 + 0x20) {
|
||||
tbuf[ui] = static_cast<wchar_t>((ch & 0x1F) << 6);
|
||||
ch = us[i++];
|
||||
tbuf[ui] = static_cast<wchar_t>(tbuf[ui] + (ch & 0x7F));
|
||||
} else {
|
||||
tbuf[ui] = static_cast<wchar_t>((ch & 0xF) << 12);
|
||||
ch = us[i++];
|
||||
tbuf[ui] = static_cast<wchar_t>(tbuf[ui] + ((ch & 0x7F) << 6));
|
||||
ch = us[i++];
|
||||
tbuf[ui] = static_cast<wchar_t>(tbuf[ui] + (ch & 0x7F));
|
||||
}
|
||||
ui++;
|
||||
}
|
||||
return ui;
|
||||
#endif
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
// UniConversion.h - functions to handle UFT-8 and UCS-2 strings
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen);
|
||||
void UTF8FromUCS2(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len);
|
||||
unsigned int UCS2Length(const char *s, unsigned int len);
|
||||
unsigned int UCS2FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen);
|
||||
|
||||
@@ -1,238 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// ViewStyle.cxx - store information on how the document is to be viewed
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "Scintilla.h"
|
||||
#include "Indicator.h"
|
||||
#include "LineMarker.h"
|
||||
#include "Style.h"
|
||||
#include "ViewStyle.h"
|
||||
|
||||
MarginStyle::MarginStyle() :
|
||||
symbol(false), width(16), mask(0xffffffff), sensitive(false) {
|
||||
}
|
||||
|
||||
// A list of the fontnames - avoids wasting space in each style
|
||||
FontNames::FontNames() {
|
||||
max = 0;
|
||||
}
|
||||
|
||||
FontNames::~FontNames() {
|
||||
Clear();
|
||||
}
|
||||
|
||||
void FontNames::Clear() {
|
||||
for (int i=0;i<max;i++) {
|
||||
delete []names[i];
|
||||
}
|
||||
max = 0;
|
||||
}
|
||||
|
||||
const char *FontNames::Save(const char *name) {
|
||||
if (!name)
|
||||
return 0;
|
||||
for (int i=0;i<max;i++) {
|
||||
if (strcmp(names[i], name) == 0) {
|
||||
return names[i];
|
||||
}
|
||||
}
|
||||
names[max] = new char[strlen(name) + 1];
|
||||
strcpy(names[max], name);
|
||||
max++;
|
||||
return names[max-1];
|
||||
}
|
||||
|
||||
ViewStyle::ViewStyle() {
|
||||
Init();
|
||||
}
|
||||
|
||||
ViewStyle::ViewStyle(const ViewStyle &source) {
|
||||
Init();
|
||||
for (unsigned int sty=0;sty<(sizeof(styles)/sizeof(styles[0]));sty++) {
|
||||
styles[sty] = source.styles[sty];
|
||||
// Can't just copy fontname as its lifetime is relative to its owning ViewStyle
|
||||
styles[sty].fontName = fontNames.Save(source.styles[sty].fontName);
|
||||
}
|
||||
for (int mrk=0;mrk<=MARKER_MAX;mrk++) {
|
||||
markers[mrk] = source.markers[mrk];
|
||||
}
|
||||
for (int ind=0;ind<=INDIC_MAX;ind++) {
|
||||
indicators[ind] = source.indicators[ind];
|
||||
}
|
||||
|
||||
selforeset = source.selforeset;
|
||||
selforeground.desired = source.selforeground.desired;
|
||||
selbackset = source.selbackset;
|
||||
selbackground.desired = source.selbackground.desired;
|
||||
selbackground2.desired = source.selbackground2.desired;
|
||||
selbar.desired = source.selbar.desired;
|
||||
selbarlight.desired = source.selbarlight.desired;
|
||||
caretcolour.desired = source.caretcolour.desired;
|
||||
edgecolour.desired = source.edgecolour.desired;
|
||||
edgeState = source.edgeState;
|
||||
leftMarginWidth = source.leftMarginWidth;
|
||||
rightMarginWidth = source.rightMarginWidth;
|
||||
for (int i=0;i < margins; i++) {
|
||||
ms[i] = source.ms[i];
|
||||
}
|
||||
symbolMargin = source.symbolMargin;
|
||||
maskInLine = source.maskInLine;
|
||||
fixedColumnWidth = source.fixedColumnWidth;
|
||||
zoomLevel = source.zoomLevel;
|
||||
viewWhitespace = source.viewWhitespace;
|
||||
viewIndentationGuides = source.viewIndentationGuides;
|
||||
viewEOL = source.viewEOL;
|
||||
showMarkedLines = source.showMarkedLines;
|
||||
}
|
||||
|
||||
ViewStyle::~ViewStyle() {
|
||||
}
|
||||
|
||||
void ViewStyle::Init() {
|
||||
fontNames.Clear();
|
||||
ResetDefaultStyle();
|
||||
|
||||
indicators[0].style = INDIC_SQUIGGLE;
|
||||
indicators[0].fore = Colour(0, 0x7f, 0);
|
||||
indicators[1].style = INDIC_TT;
|
||||
indicators[1].fore = Colour(0, 0, 0xff);
|
||||
indicators[2].style = INDIC_PLAIN;
|
||||
indicators[2].fore = Colour(0xff, 0, 0);
|
||||
|
||||
lineHeight = 1;
|
||||
maxAscent = 1;
|
||||
maxDescent = 1;
|
||||
aveCharWidth = 8;
|
||||
spaceWidth = 8;
|
||||
|
||||
selforeset = false;
|
||||
selforeground.desired = Colour(0xff, 0, 0);
|
||||
selbackset = true;
|
||||
selbackground.desired = Colour(0xc0, 0xc0, 0xc0);
|
||||
selbackground2.desired = Colour(0xb0, 0xb0, 0xb0);
|
||||
selbar.desired = Platform::Chrome();
|
||||
selbarlight.desired = Platform::ChromeHighlight();
|
||||
styles[STYLE_LINENUMBER].fore.desired = Colour(0, 0, 0);
|
||||
styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
|
||||
//caretcolour.desired = Colour(0xff, 0, 0);
|
||||
caretcolour.desired = Colour(0, 0, 0);
|
||||
edgecolour.desired = Colour(0xc0, 0xc0, 0xc0);
|
||||
edgeState = EDGE_NONE;
|
||||
|
||||
leftMarginWidth = 1;
|
||||
rightMarginWidth = 1;
|
||||
ms[0].symbol = false;
|
||||
ms[0].width = 0;
|
||||
ms[0].mask = 0;
|
||||
ms[1].symbol = true;
|
||||
ms[1].width = 16;
|
||||
ms[1].mask = ~SC_MASK_FOLDERS;
|
||||
ms[2].symbol = true;
|
||||
ms[2].width = 14; // Nice width for arrows
|
||||
ms[2].mask = SC_MASK_FOLDERS;
|
||||
ms[2].width = 0; // Nice width for arrows
|
||||
ms[2].mask = 0;
|
||||
fixedColumnWidth = leftMarginWidth;
|
||||
symbolMargin = false;
|
||||
maskInLine = 0xffffffff;
|
||||
for (int margin=0; margin < margins; margin++) {
|
||||
fixedColumnWidth += ms[margin].width;
|
||||
symbolMargin = symbolMargin || ms[margin].symbol;
|
||||
if (ms[margin].width > 0)
|
||||
maskInLine &= ~ms[margin].mask;
|
||||
}
|
||||
zoomLevel = 0;
|
||||
viewWhitespace = wsInvisible;
|
||||
viewIndentationGuides = false;
|
||||
viewEOL = false;
|
||||
showMarkedLines = true;
|
||||
}
|
||||
|
||||
void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {
|
||||
unsigned int i;
|
||||
for (i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
|
||||
pal.WantFind(styles[i].fore, want);
|
||||
pal.WantFind(styles[i].back, want);
|
||||
}
|
||||
for (i=0;i<(sizeof(indicators)/sizeof(indicators[0]));i++) {
|
||||
pal.WantFind(indicators[i].fore, want);
|
||||
}
|
||||
for (i=0;i<(sizeof(markers)/sizeof(markers[0]));i++) {
|
||||
pal.WantFind(markers[i].fore, want);
|
||||
pal.WantFind(markers[i].back, want);
|
||||
}
|
||||
pal.WantFind(selforeground, want);
|
||||
pal.WantFind(selbackground, want);
|
||||
pal.WantFind(selbackground2, want);
|
||||
pal.WantFind(selbar, want);
|
||||
pal.WantFind(selbarlight, want);
|
||||
pal.WantFind(caretcolour, want);
|
||||
pal.WantFind(edgecolour, want);
|
||||
}
|
||||
|
||||
void ViewStyle::Refresh(Surface &surface) {
|
||||
selbar.desired = Platform::Chrome();
|
||||
selbarlight.desired = Platform::ChromeHighlight();
|
||||
styles[STYLE_DEFAULT].Realise(surface, zoomLevel);
|
||||
maxAscent = styles[STYLE_DEFAULT].ascent;
|
||||
maxDescent = styles[STYLE_DEFAULT].descent;
|
||||
for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
|
||||
if (i != STYLE_DEFAULT) {
|
||||
styles[i].Realise(surface, zoomLevel, &styles[STYLE_DEFAULT]);
|
||||
if (maxAscent < styles[i].ascent)
|
||||
maxAscent = styles[i].ascent;
|
||||
if (maxDescent < styles[i].descent)
|
||||
maxDescent = styles[i].descent;
|
||||
}
|
||||
}
|
||||
|
||||
lineHeight = maxAscent + maxDescent;
|
||||
aveCharWidth = styles[STYLE_DEFAULT].aveCharWidth;
|
||||
spaceWidth = styles[STYLE_DEFAULT].spaceWidth;
|
||||
|
||||
fixedColumnWidth = leftMarginWidth;
|
||||
symbolMargin = false;
|
||||
maskInLine = 0xffffffff;
|
||||
for (int margin=0; margin < margins; margin++) {
|
||||
fixedColumnWidth += ms[margin].width;
|
||||
symbolMargin = symbolMargin || ms[margin].symbol;
|
||||
if (ms[margin].width > 0)
|
||||
maskInLine &= ~ms[margin].mask;
|
||||
}
|
||||
}
|
||||
|
||||
void ViewStyle::ResetDefaultStyle() {
|
||||
styles[STYLE_DEFAULT].Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
|
||||
Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
|
||||
SC_CHARSET_DEFAULT,
|
||||
false, false, false, false, true);
|
||||
}
|
||||
|
||||
void ViewStyle::ClearStyles() {
|
||||
// Reset all styles to be like the default style
|
||||
for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
|
||||
if (i != STYLE_DEFAULT) {
|
||||
styles[i].Clear(
|
||||
styles[STYLE_DEFAULT].fore.desired,
|
||||
styles[STYLE_DEFAULT].back.desired,
|
||||
styles[STYLE_DEFAULT].size,
|
||||
styles[STYLE_DEFAULT].fontName,
|
||||
styles[STYLE_DEFAULT].characterSet,
|
||||
styles[STYLE_DEFAULT].bold,
|
||||
styles[STYLE_DEFAULT].italic,
|
||||
styles[STYLE_DEFAULT].eolFilled,
|
||||
styles[STYLE_DEFAULT].underline,
|
||||
styles[STYLE_DEFAULT].visible);
|
||||
}
|
||||
}
|
||||
styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
|
||||
}
|
||||
|
||||
void ViewStyle::SetStyleFontName(int styleIndex, const char *name) {
|
||||
styles[styleIndex].fontName = fontNames.Save(name);
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// ViewStyle.h - store information on how the document is to be viewed
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef VIEWSTYLE_H
|
||||
#define VIEWSTYLE_H
|
||||
|
||||
class MarginStyle {
|
||||
public:
|
||||
bool symbol;
|
||||
int width;
|
||||
int mask;
|
||||
bool sensitive;
|
||||
MarginStyle();
|
||||
};
|
||||
|
||||
class FontNames {
|
||||
private:
|
||||
char *names[STYLE_MAX + 1];
|
||||
int max;
|
||||
public:
|
||||
FontNames();
|
||||
~FontNames();
|
||||
void Clear();
|
||||
const char *Save(const char *name);
|
||||
};
|
||||
|
||||
enum WhiteSpaceVisibility {wsInvisible=0, wsVisibleAlways=1, wsVisibleAfterIndent=2};
|
||||
class ViewStyle {
|
||||
public:
|
||||
FontNames fontNames;
|
||||
Style styles[STYLE_MAX + 1];
|
||||
LineMarker markers[MARKER_MAX + 1];
|
||||
Indicator indicators[INDIC_MAX + 1];
|
||||
int lineHeight;
|
||||
unsigned int maxAscent;
|
||||
unsigned int maxDescent;
|
||||
unsigned int aveCharWidth;
|
||||
unsigned int spaceWidth;
|
||||
bool selforeset;
|
||||
ColourPair selforeground;
|
||||
bool selbackset;
|
||||
ColourPair selbackground;
|
||||
ColourPair selbackground2;
|
||||
ColourPair selbar;
|
||||
ColourPair selbarlight;
|
||||
// Margins are ordered: Line Numbers, Selection Margin, Spacing Margin
|
||||
int leftMarginWidth; // Spacing margin on left of text
|
||||
int rightMarginWidth; // Spacing margin on left of text
|
||||
enum { margins=3 };
|
||||
bool symbolMargin;
|
||||
int maskInLine; // Mask for markers to be put into text because there is nowhere for them to go in margin
|
||||
MarginStyle ms[margins];
|
||||
int fixedColumnWidth;
|
||||
int zoomLevel;
|
||||
WhiteSpaceVisibility viewWhitespace;
|
||||
bool viewIndentationGuides;
|
||||
bool viewEOL;
|
||||
bool showMarkedLines;
|
||||
ColourPair caretcolour;
|
||||
ColourPair edgecolour;
|
||||
int edgeState;
|
||||
|
||||
ViewStyle();
|
||||
ViewStyle(const ViewStyle &source);
|
||||
~ViewStyle();
|
||||
void Init();
|
||||
void RefreshColourPalette(Palette &pal, bool want);
|
||||
void Refresh(Surface &surface);
|
||||
void ResetDefaultStyle();
|
||||
void ClearStyles();
|
||||
void SetStyleFontName(int styleIndex, const char *name);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,175 +0,0 @@
|
||||
// SciTE - Scintilla based Text Editor
|
||||
// Accessor.cxx - rapid easy access to contents of a Scintilla
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "WindowAccessor.h"
|
||||
#include "Scintilla.h"
|
||||
|
||||
WindowAccessor::~WindowAccessor() {
|
||||
}
|
||||
|
||||
#if PLAT_WIN
|
||||
bool WindowAccessor::InternalIsLeadByte(char ch) {
|
||||
if (SC_CP_UTF8 == codePage)
|
||||
// For lexing, all characters >= 0x80 are treated the
|
||||
// same so none is considered a lead byte.
|
||||
return false;
|
||||
else
|
||||
return IsDBCSLeadByteEx(codePage, ch);
|
||||
}
|
||||
#else
|
||||
// PLAT_GTK or PLAT_WX
|
||||
// TODO: support DBCS under GTK+ and WX
|
||||
bool WindowAccessor::InternalIsLeadByte(char) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
void WindowAccessor::Fill(int position) {
|
||||
if (lenDoc == -1)
|
||||
lenDoc = Platform::SendScintilla(id, SCI_GETTEXTLENGTH, 0, 0);
|
||||
startPos = position - slopSize;
|
||||
if (startPos + bufferSize > lenDoc)
|
||||
startPos = lenDoc - bufferSize;
|
||||
if (startPos < 0)
|
||||
startPos = 0;
|
||||
endPos = startPos + bufferSize;
|
||||
if (endPos > lenDoc)
|
||||
endPos = lenDoc;
|
||||
|
||||
TextRange tr = {{startPos, endPos}, buf};
|
||||
Platform::SendScintilla(id, SCI_GETTEXTRANGE, 0, reinterpret_cast<long>(&tr));
|
||||
}
|
||||
|
||||
char WindowAccessor::StyleAt(int position) {
|
||||
return static_cast<char>(Platform::SendScintilla(
|
||||
id, SCI_GETSTYLEAT, position, 0));
|
||||
}
|
||||
|
||||
int WindowAccessor::GetLine(int position) {
|
||||
return Platform::SendScintilla(id, SCI_LINEFROMPOSITION, position, 0);
|
||||
}
|
||||
|
||||
int WindowAccessor::LineStart(int line) {
|
||||
return Platform::SendScintilla(id, SCI_POSITIONFROMLINE, line, 0);
|
||||
}
|
||||
|
||||
int WindowAccessor::LevelAt(int line) {
|
||||
return Platform::SendScintilla(id, SCI_GETFOLDLEVEL, line, 0);
|
||||
}
|
||||
|
||||
int WindowAccessor::Length() {
|
||||
if (lenDoc == -1)
|
||||
lenDoc = Platform::SendScintilla(id, SCI_GETTEXTLENGTH, 0, 0);
|
||||
return lenDoc;
|
||||
}
|
||||
|
||||
int WindowAccessor::GetLineState(int line) {
|
||||
return Platform::SendScintilla(id, SCI_GETLINESTATE, line);
|
||||
}
|
||||
|
||||
int WindowAccessor::SetLineState(int line, int state) {
|
||||
return Platform::SendScintilla(id, SCI_SETLINESTATE, line, state);
|
||||
}
|
||||
|
||||
void WindowAccessor::StartAt(unsigned int start, char chMask) {
|
||||
Platform::SendScintilla(id, SCI_STARTSTYLING, start, chMask);
|
||||
}
|
||||
|
||||
void WindowAccessor::StartSegment(unsigned int pos) {
|
||||
startSeg = pos;
|
||||
}
|
||||
|
||||
void WindowAccessor::ColourTo(unsigned int pos, int chAttr) {
|
||||
// Only perform styling if non empty range
|
||||
if (pos != startSeg - 1) {
|
||||
if (pos < startSeg) {
|
||||
Platform::DebugPrintf("Bad colour positions %d - %d\n", startSeg, pos);
|
||||
}
|
||||
|
||||
if (validLen + (pos - startSeg + 1) >= bufferSize)
|
||||
Flush();
|
||||
if (validLen + (pos - startSeg + 1) >= bufferSize) {
|
||||
// Too big for buffer so send directly
|
||||
Platform::SendScintilla(id, SCI_SETSTYLING, pos - startSeg + 1, chAttr);
|
||||
} else {
|
||||
if (chAttr != chWhile)
|
||||
chFlags = 0;
|
||||
chAttr |= chFlags;
|
||||
for (unsigned int i = startSeg; i <= pos; i++) {
|
||||
styleBuf[validLen++] = static_cast<char>(chAttr);
|
||||
}
|
||||
}
|
||||
}
|
||||
startSeg = pos+1;
|
||||
}
|
||||
|
||||
void WindowAccessor::SetLevel(int line, int level) {
|
||||
Platform::SendScintilla(id, SCI_SETFOLDLEVEL, line, level);
|
||||
}
|
||||
|
||||
void WindowAccessor::Flush() {
|
||||
startPos = extremePosition;
|
||||
lenDoc = -1;
|
||||
if (validLen > 0) {
|
||||
Platform::SendScintilla(id, SCI_SETSTYLINGEX, validLen,
|
||||
reinterpret_cast<long>(styleBuf));
|
||||
validLen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int WindowAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader) {
|
||||
int end = Length();
|
||||
int spaceFlags = 0;
|
||||
|
||||
// Determines the indentation level of the current line and also checks for consistent
|
||||
// indentation compared to the previous line.
|
||||
// Indentation is judged consistent when the indentation whitespace of each line lines
|
||||
// the same or the indentation of one line is a prefix of the other.
|
||||
|
||||
int pos = LineStart(line);
|
||||
char ch = (*this)[pos];
|
||||
int indent = 0;
|
||||
bool inPrevPrefix = line > 0;
|
||||
int posPrev = inPrevPrefix ? LineStart(line-1) : 0;
|
||||
while ((ch == ' ' || ch == '\t') && (pos < end)) {
|
||||
if (inPrevPrefix) {
|
||||
char chPrev = (*this)[posPrev++];
|
||||
if (chPrev == ' ' || chPrev == '\t') {
|
||||
if (chPrev != ch)
|
||||
spaceFlags |= wsInconsistent;
|
||||
} else {
|
||||
inPrevPrefix = false;
|
||||
}
|
||||
}
|
||||
if (ch == ' ') {
|
||||
spaceFlags |= wsSpace;
|
||||
indent++;
|
||||
} else { // Tab
|
||||
spaceFlags |= wsTab;
|
||||
if (spaceFlags & wsSpace)
|
||||
spaceFlags |= wsSpaceTab;
|
||||
indent = (indent / 8 + 1) * 8;
|
||||
}
|
||||
ch = (*this)[++pos];
|
||||
}
|
||||
|
||||
*flags = spaceFlags;
|
||||
indent += SC_FOLDLEVELBASE;
|
||||
// if completely empty line or the start of a comment...
|
||||
if (isspace(ch) || (pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos)) )
|
||||
return indent | SC_FOLDLEVELWHITEFLAG;
|
||||
else
|
||||
return indent;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,523 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Name: stc.cpp
|
||||
// Purpose: A wxWindows implementation of Scintilla. This class is the
|
||||
// one meant to be used directly by wx applications. It does not
|
||||
// derive directly from the Scintilla classes, but instead
|
||||
// delegates most things to the real Scintilla class.
|
||||
// This allows the use of Scintilla without polluting the
|
||||
// namespace with all the classes and identifiers from Scintilla.
|
||||
//
|
||||
// Author: Robin Dunn
|
||||
//
|
||||
// Created: 13-Jan-2000
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 by Total Control Software
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include "wx/stc/stc.h"
|
||||
#include "ScintillaWX.h"
|
||||
|
||||
#include <wx/tokenzr.h>
|
||||
|
||||
// The following code forces a reference to all of the Scintilla lexers.
|
||||
// If we don't do something like this, then the linker tends to "optimize"
|
||||
// them away. (eric@sourcegear.com)
|
||||
|
||||
int wxForceScintillaLexers(void)
|
||||
{
|
||||
extern LexerModule lmCPP;
|
||||
extern LexerModule lmHTML;
|
||||
extern LexerModule lmXML;
|
||||
extern LexerModule lmProps;
|
||||
extern LexerModule lmErrorList;
|
||||
extern LexerModule lmMake;
|
||||
extern LexerModule lmBatch;
|
||||
extern LexerModule lmPerl;
|
||||
extern LexerModule lmPython;
|
||||
extern LexerModule lmSQL;
|
||||
extern LexerModule lmVB;
|
||||
|
||||
if (
|
||||
&lmCPP
|
||||
&& &lmHTML
|
||||
&& &lmXML
|
||||
&& &lmProps
|
||||
&& &lmErrorList
|
||||
&& &lmMake
|
||||
&& &lmBatch
|
||||
&& &lmPerl
|
||||
&& &lmPython
|
||||
&& &lmSQL
|
||||
&& &lmVB
|
||||
)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
const wxChar* wxSTCNameStr = "stcwindow";
|
||||
|
||||
BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
|
||||
EVT_PAINT (wxStyledTextCtrl::OnPaint)
|
||||
EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin)
|
||||
EVT_SIZE (wxStyledTextCtrl::OnSize)
|
||||
EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown)
|
||||
EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
|
||||
EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
|
||||
EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp)
|
||||
EVT_CHAR (wxStyledTextCtrl::OnChar)
|
||||
EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
|
||||
EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
|
||||
EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus)
|
||||
EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged)
|
||||
EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground)
|
||||
EVT_MENU_RANGE (-1, -1, wxStyledTextCtrl::OnMenu)
|
||||
EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Constructor and Destructor
|
||||
|
||||
wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name) :
|
||||
wxControl(parent, id, pos, size,
|
||||
style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN,
|
||||
wxDefaultValidator, name)
|
||||
{
|
||||
m_swx = new ScintillaWX(this);
|
||||
m_stopWatch.Start();
|
||||
}
|
||||
|
||||
|
||||
wxStyledTextCtrl::~wxStyledTextCtrl() {
|
||||
delete m_swx;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) {
|
||||
|
||||
return m_swx->WndProc(msg, wp, lp);
|
||||
}
|
||||
|
||||
|
||||
#ifdef MAKELONG
|
||||
#undef MAKELONG
|
||||
#endif
|
||||
|
||||
#define MAKELONG(a, b) ((a) | ((b) << 16))
|
||||
|
||||
|
||||
static long wxColourAsLong(const wxColour& co) {
|
||||
return (((long)co.Blue() << 16) |
|
||||
((long)co.Green() << 8) |
|
||||
((long)co.Red()));
|
||||
}
|
||||
|
||||
static wxColour wxColourFromLong(long c) {
|
||||
wxColour clr;
|
||||
clr.Set(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff);
|
||||
return clr;
|
||||
}
|
||||
|
||||
|
||||
static wxColour wxColourFromSpec(const wxString& spec) {
|
||||
// spec should be #RRGGBB
|
||||
char* junk;
|
||||
int red = strtol(spec.Mid(1,2), &junk, 16);
|
||||
int green = strtol(spec.Mid(3,2), &junk, 16);
|
||||
int blue = strtol(spec.Mid(5,2), &junk, 16);
|
||||
return wxColour(red, green, blue);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// BEGIN generated section. The following code is automatically generated
|
||||
// by gen_iface.py from the contents of Scintilla.iface. Do not edit
|
||||
// this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
|
||||
|
||||
%(METHOD_IMPS)s
|
||||
|
||||
// END of generated section
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
// Returns the line number of the line with the caret.
|
||||
int wxStyledTextCtrl::GetCurrentLine() {
|
||||
int line = LineFromPosition(GetCurrentPos());
|
||||
return line;
|
||||
}
|
||||
|
||||
|
||||
// Extract style settings from a spec-string which is composed of one or
|
||||
// more of the following comma separated elements:
|
||||
//
|
||||
// bold turns on bold
|
||||
// italic turns on italics
|
||||
// fore:#RRGGBB sets the foreground colour
|
||||
// back:#RRGGBB sets the background colour
|
||||
// face:[facename] sets the font face name to use
|
||||
// size:[num] sets the font size in points
|
||||
// eol turns on eol filling
|
||||
// underline turns on underlining
|
||||
//
|
||||
void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
|
||||
|
||||
wxStringTokenizer tkz(spec, ",");
|
||||
while (tkz.HasMoreTokens()) {
|
||||
wxString token = tkz.GetNextToken();
|
||||
|
||||
wxString option = token.BeforeFirst(':');
|
||||
wxString val = token.AfterFirst(':');
|
||||
|
||||
if (option == "bold")
|
||||
StyleSetBold(styleNum, true);
|
||||
|
||||
else if (option == "italic")
|
||||
StyleSetItalic(styleNum, true);
|
||||
|
||||
else if (option == "underline")
|
||||
StyleSetUnderline(styleNum, true);
|
||||
|
||||
else if (option == "eol")
|
||||
StyleSetEOLFilled(styleNum, true);
|
||||
|
||||
else if (option == "size") {
|
||||
long points;
|
||||
if (val.ToLong(&points))
|
||||
StyleSetSize(styleNum, points);
|
||||
}
|
||||
|
||||
else if (option == "face")
|
||||
StyleSetFaceName(styleNum, val);
|
||||
|
||||
else if (option == "fore")
|
||||
StyleSetForeground(styleNum, wxColourFromSpec(val));
|
||||
|
||||
else if (option == "back")
|
||||
StyleSetBackground(styleNum, wxColourFromSpec(val));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set style size, face, bold, italic, and underline attributes from
|
||||
// a wxFont's attributes.
|
||||
void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
|
||||
int size = font.GetPointSize();
|
||||
wxString faceName = font.GetFaceName();
|
||||
bool bold = font.GetWeight() == wxBOLD;
|
||||
bool italic = font.GetStyle() != wxNORMAL;
|
||||
bool under = font.GetUnderlined();
|
||||
|
||||
// TODO: add encoding/charset mapping
|
||||
StyleSetFontAttr(styleNum, size, faceName, bold, italic, under);
|
||||
}
|
||||
|
||||
// Set all font style attributes at once.
|
||||
void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
|
||||
const wxString& faceName,
|
||||
bool bold, bool italic,
|
||||
bool underline) {
|
||||
StyleSetSize(styleNum, size);
|
||||
StyleSetFaceName(styleNum, faceName);
|
||||
StyleSetBold(styleNum, bold);
|
||||
StyleSetItalic(styleNum, italic);
|
||||
StyleSetUnderline(styleNum, underline);
|
||||
|
||||
// TODO: add encoding/charset mapping
|
||||
}
|
||||
|
||||
|
||||
// Perform one of the operations defined by the wxSTC_CMD_* constants.
|
||||
void wxStyledTextCtrl::CmdKeyExecute(int cmd) {
|
||||
SendMsg(cmd);
|
||||
}
|
||||
|
||||
|
||||
// Set the left and right margin in the edit area, measured in pixels.
|
||||
void wxStyledTextCtrl::SetMargins(int left, int right) {
|
||||
SetMarginLeft(left);
|
||||
SetMarginRight(right);
|
||||
}
|
||||
|
||||
|
||||
// Retrieve the start and end positions of the current selection.
|
||||
void wxStyledTextCtrl::GetSelection(int* startPos, int* endPos) {
|
||||
if (startPos != NULL)
|
||||
*startPos = SendMsg(SCI_GETSELECTIONSTART);
|
||||
if (endPos != NULL)
|
||||
*endPos = SendMsg(SCI_GETSELECTIONEND);
|
||||
}
|
||||
|
||||
|
||||
// Retrieve the point in the window where a position is displayed.
|
||||
wxPoint wxStyledTextCtrl::PointFromPosition(int pos) {
|
||||
int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos);
|
||||
int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos);
|
||||
return wxPoint(x, y);
|
||||
}
|
||||
|
||||
// Scroll enough to make the given line visible
|
||||
void wxStyledTextCtrl::ScrollToLine(int line) {
|
||||
m_swx->DoScrollToLine(line);
|
||||
}
|
||||
|
||||
|
||||
// Scroll enough to make the given column visible
|
||||
void wxStyledTextCtrl::ScrollToColumn(int column) {
|
||||
m_swx->DoScrollToColumn(column);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Event handlers
|
||||
|
||||
void wxStyledTextCtrl::OnPaint(wxPaintEvent& evt) {
|
||||
wxPaintDC dc(this);
|
||||
wxRegion region = GetUpdateRegion();
|
||||
|
||||
m_swx->DoPaint(&dc, region.GetBox());
|
||||
}
|
||||
|
||||
void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) {
|
||||
if (evt.GetOrientation() == wxHORIZONTAL)
|
||||
m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
|
||||
else
|
||||
m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
|
||||
}
|
||||
|
||||
void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) {
|
||||
wxSize sz = GetClientSize();
|
||||
m_swx->DoSize(sz.x, sz.y);
|
||||
}
|
||||
|
||||
void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
|
||||
wxPoint pt = evt.GetPosition();
|
||||
m_swx->DoButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
|
||||
evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
|
||||
}
|
||||
|
||||
void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) {
|
||||
wxPoint pt = evt.GetPosition();
|
||||
m_swx->DoButtonMove(Point(pt.x, pt.y));
|
||||
}
|
||||
|
||||
void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
|
||||
wxPoint pt = evt.GetPosition();
|
||||
m_swx->DoButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
|
||||
evt.ControlDown());
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
|
||||
wxPoint pt = evt.GetPosition();
|
||||
m_swx->DoContextMenu(Point(pt.x, pt.y));
|
||||
}
|
||||
|
||||
void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
|
||||
long key = evt.KeyCode();
|
||||
if ((key > WXK_ESCAPE) &&
|
||||
(key != WXK_DELETE) && (key < 255) &&
|
||||
!evt.ControlDown() && !evt.AltDown()) {
|
||||
|
||||
m_swx->DoAddChar(key);
|
||||
}
|
||||
else {
|
||||
evt.Skip();
|
||||
}
|
||||
}
|
||||
|
||||
void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
|
||||
long key = evt.KeyCode();
|
||||
key = toupper(key);
|
||||
int processed = m_swx->DoKeyDown(key, evt.ShiftDown(),
|
||||
evt.ControlDown(), evt.AltDown());
|
||||
if (! processed)
|
||||
evt.Skip();
|
||||
}
|
||||
|
||||
void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
|
||||
m_swx->DoLoseFocus();
|
||||
}
|
||||
|
||||
void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
|
||||
m_swx->DoGainFocus();
|
||||
}
|
||||
|
||||
void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& evt) {
|
||||
m_swx->DoSysColourChange();
|
||||
}
|
||||
|
||||
void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& evt) {
|
||||
// do nothing to help avoid flashing
|
||||
}
|
||||
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
|
||||
m_swx->DoCommand(evt.GetId());
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) {
|
||||
m_swx->DoOnListBox();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Turn notifications from Scintilla into events
|
||||
|
||||
|
||||
void wxStyledTextCtrl::NotifyChange() {
|
||||
wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId());
|
||||
GetEventHandler()->ProcessEvent(evt);
|
||||
}
|
||||
|
||||
void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
|
||||
SCNotification& scn = *_scn;
|
||||
int eventType = 0;
|
||||
switch (scn.nmhdr.code) {
|
||||
case SCN_STYLENEEDED:
|
||||
eventType = wxEVT_STC_STYLENEEDED;
|
||||
break;
|
||||
case SCN_CHARADDED:
|
||||
eventType = wxEVT_STC_CHARADDED;
|
||||
break;
|
||||
case SCN_UPDATEUI:
|
||||
eventType = wxEVT_STC_UPDATEUI;
|
||||
break;
|
||||
case SCN_SAVEPOINTREACHED:
|
||||
eventType = wxEVT_STC_SAVEPOINTREACHED;
|
||||
break;
|
||||
case SCN_SAVEPOINTLEFT:
|
||||
eventType = wxEVT_STC_SAVEPOINTLEFT;
|
||||
break;
|
||||
case SCN_MODIFYATTEMPTRO:
|
||||
eventType = wxEVT_STC_ROMODIFYATTEMPT;
|
||||
break;
|
||||
case SCN_DOUBLECLICK:
|
||||
eventType = wxEVT_STC_DOUBLECLICK;
|
||||
break;
|
||||
case SCN_MODIFIED:
|
||||
eventType = wxEVT_STC_MODIFIED;
|
||||
break;
|
||||
case SCN_KEY:
|
||||
eventType = wxEVT_STC_KEY;
|
||||
break;
|
||||
case SCN_MACRORECORD:
|
||||
eventType = wxEVT_STC_MACRORECORD;
|
||||
break;
|
||||
case SCN_MARGINCLICK:
|
||||
eventType = wxEVT_STC_MARGINCLICK;
|
||||
break;
|
||||
case SCN_NEEDSHOWN:
|
||||
eventType = wxEVT_STC_NEEDSHOWN;
|
||||
break;
|
||||
case SCN_POSCHANGED:
|
||||
eventType = wxEVT_STC_POSCHANGED;
|
||||
break;
|
||||
}
|
||||
if (eventType) {
|
||||
wxStyledTextEvent evt(eventType, GetId());
|
||||
evt.SetPosition(scn.position);
|
||||
evt.SetKey(scn.ch);
|
||||
evt.SetModifiers(scn.modifiers);
|
||||
if (eventType == wxEVT_STC_MODIFIED) {
|
||||
evt.SetModificationType(scn.modificationType);
|
||||
if (scn.text)
|
||||
evt.SetText(wxString(scn.text, scn.length));
|
||||
evt.SetLength(scn.length);
|
||||
evt.SetLinesAdded(scn.linesAdded);
|
||||
evt.SetLine(scn.line);
|
||||
evt.SetFoldLevelNow(scn.foldLevelNow);
|
||||
evt.SetFoldLevelPrev(scn.foldLevelPrev);
|
||||
}
|
||||
if (eventType == wxEVT_STC_MARGINCLICK)
|
||||
evt.SetMargin(scn.margin);
|
||||
if (eventType == wxEVT_STC_MACRORECORD) {
|
||||
evt.SetMessage(scn.message);
|
||||
evt.SetWParam(scn.wParam);
|
||||
evt.SetLParam(scn.lParam);
|
||||
}
|
||||
|
||||
GetEventHandler()->ProcessEvent(evt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id)
|
||||
: wxCommandEvent(commandType, id)
|
||||
{
|
||||
m_position = 0;
|
||||
m_key = 0;
|
||||
m_modifiers = 0;
|
||||
m_modificationType = 0;
|
||||
m_length = 0;
|
||||
m_linesAdded = 0;
|
||||
m_line = 0;
|
||||
m_foldLevelNow = 0;
|
||||
m_foldLevelPrev = 0;
|
||||
m_margin = 0;
|
||||
m_message = 0;
|
||||
m_wParam = 0;
|
||||
m_lParam = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; }
|
||||
bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; }
|
||||
bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; }
|
||||
|
||||
void wxStyledTextEvent::CopyObject(wxObject& obj) const {
|
||||
wxCommandEvent::CopyObject(obj);
|
||||
|
||||
wxStyledTextEvent* o = (wxStyledTextEvent*)&obj;
|
||||
o->m_position = m_position;
|
||||
o->m_key = m_key;
|
||||
o->m_modifiers = m_modifiers;
|
||||
o->m_modificationType = m_modificationType;
|
||||
o->m_text = m_text;
|
||||
o->m_length = m_length;
|
||||
o->m_linesAdded = m_linesAdded;
|
||||
o->m_line = m_line;
|
||||
o->m_foldLevelNow = m_foldLevelNow;
|
||||
o->m_foldLevelPrev = m_foldLevelPrev;
|
||||
|
||||
o->m_margin = m_margin;
|
||||
|
||||
o->m_message = m_message;
|
||||
o->m_wParam = m_wParam;
|
||||
o->m_lParam = m_lParam;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@@ -1,297 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Name: stc.h
|
||||
// Purpose: A wxWindows implementation of Scintilla. This class is the
|
||||
// one meant to be used directly by wx applications. It does not
|
||||
// derive directly from the Scintilla classes, and in fact there
|
||||
// is no mention of Scintilla classes at all in this header.
|
||||
// This class delegates all method calls and events to the
|
||||
// Scintilla objects and so forth. This allows the use of
|
||||
// Scintilla without polluting the namespace with all the
|
||||
// classes and itentifiers from Scintilla.
|
||||
//
|
||||
// Author: Robin Dunn
|
||||
//
|
||||
// Created: 13-Jan-2000
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 by Total Control Software
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __stc_h__
|
||||
#define __stc_h__
|
||||
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// BEGIN generated section. The following code is automatically generated
|
||||
// by gen_iface.py. Do not edit this file. Edit stc.h.in instead
|
||||
// and regenerate
|
||||
|
||||
%(VALUES)s
|
||||
|
||||
// END of generated section
|
||||
//----------------------------------------------------------------------
|
||||
// Others
|
||||
|
||||
#define wxSTC_MASK_FOLDERS ((1 << wxSTC_MARKNUM_FOLDER) | (1 << wxSTC_MARKNUM_FOLDEROPEN))
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class ScintillaWX; // forward declare
|
||||
class WordList;
|
||||
struct SCNotification;
|
||||
|
||||
|
||||
extern const wxChar* wxSTCNameStr;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class wxStyledTextCtrl : public wxControl {
|
||||
public:
|
||||
|
||||
#ifdef SWIG
|
||||
wxStyledTextCtrl(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0,
|
||||
const char* name = "styledtext");
|
||||
#else
|
||||
wxStyledTextCtrl(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0,
|
||||
const wxString& name = wxSTCNameStr);
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef SWIG
|
||||
~wxStyledTextCtrl();
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// BEGIN generated section. The following code is automatically generated
|
||||
// by gen_iface.py. Do not edit this file. Edit stc.h.in instead
|
||||
// and regenerate
|
||||
|
||||
%(METHOD_DEFS)s
|
||||
|
||||
// END of generated section
|
||||
//----------------------------------------------------------------------
|
||||
// Others...
|
||||
|
||||
|
||||
// Returns the line number of the line with the caret.
|
||||
int GetCurrentLine();
|
||||
|
||||
// Extract style settings from a spec-string which is composed of one or
|
||||
// more of the following comma separated elements:
|
||||
//
|
||||
// bold turns on bold
|
||||
// italic turns on italics
|
||||
// fore:#RRGGBB sets the foreground colour
|
||||
// back:#RRGGBB sets the background colour
|
||||
// face:[facename] sets the font face name to use
|
||||
// size:[num] sets the font size in points
|
||||
// eol turns on eol filling
|
||||
// underline turns on underlining
|
||||
//
|
||||
void StyleSetSpec(int styleNum, const wxString& spec);
|
||||
|
||||
|
||||
|
||||
// Set style size, face, bold, italic, and underline attributes from
|
||||
// a wxFont's attributes.
|
||||
void StyleSetFont(int styleNum, wxFont& font);
|
||||
|
||||
|
||||
|
||||
// Set all font style attributes at once.
|
||||
void StyleSetFontAttr(int styleNum, int size,
|
||||
const wxString& faceName,
|
||||
bool bold, bool italic,
|
||||
bool underline);
|
||||
|
||||
|
||||
|
||||
// Perform one of the operations defined by the wxSTC_CMD_* constants.
|
||||
void CmdKeyExecute(int cmd);
|
||||
|
||||
|
||||
|
||||
// Set the left and right margin in the edit area, measured in pixels.
|
||||
void SetMargins(int left, int right);
|
||||
|
||||
|
||||
// Retrieve the start and end positions of the current selection.
|
||||
#ifdef SWIG
|
||||
void GetSelection(int* OUTPUT, int* OUTPUT);
|
||||
#else
|
||||
void GetSelection(int* startPos, int* endPos);
|
||||
#endif
|
||||
|
||||
// Retrieve the point in the window where a position is displayed.
|
||||
wxPoint PointFromPosition(int pos);
|
||||
|
||||
|
||||
// Scroll enough to make the given line visible
|
||||
void ScrollToLine(int line);
|
||||
|
||||
|
||||
// Scroll enough to make the given column visible
|
||||
void ScrollToColumn(int column);
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef SWIG
|
||||
private:
|
||||
// Event handlers
|
||||
void OnPaint(wxPaintEvent& evt);
|
||||
void OnScrollWin(wxScrollWinEvent& evt);
|
||||
void OnSize(wxSizeEvent& evt);
|
||||
void OnMouseLeftDown(wxMouseEvent& evt);
|
||||
void OnMouseMove(wxMouseEvent& evt);
|
||||
void OnMouseLeftUp(wxMouseEvent& evt);
|
||||
void OnMouseRightUp(wxMouseEvent& evt);
|
||||
void OnChar(wxKeyEvent& evt);
|
||||
void OnKeyDown(wxKeyEvent& evt);
|
||||
void OnLoseFocus(wxFocusEvent& evt);
|
||||
void OnGainFocus(wxFocusEvent& evt);
|
||||
void OnSysColourChanged(wxSysColourChangedEvent& evt);
|
||||
void OnEraseBackground(wxEraseEvent& evt);
|
||||
void OnMenu(wxCommandEvent& evt);
|
||||
void OnListBox(wxCommandEvent& evt);
|
||||
|
||||
|
||||
// Turn notifications from Scintilla into events
|
||||
void NotifyChange();
|
||||
void NotifyParent(SCNotification* scn);
|
||||
|
||||
long SendMsg(int msg, long wp=0, long lp=0);
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_CLASS(wxStyledTextCtrl)
|
||||
|
||||
ScintillaWX* m_swx;
|
||||
wxStopWatch m_stopWatch;
|
||||
|
||||
|
||||
friend class ScintillaWX;
|
||||
friend class Platform;
|
||||
#endif
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class wxStyledTextEvent : public wxCommandEvent {
|
||||
public:
|
||||
wxStyledTextEvent(wxEventType commandType=0, int id=0);
|
||||
~wxStyledTextEvent() {}
|
||||
|
||||
void SetPosition(int pos) { m_position = pos; }
|
||||
void SetKey(int k) { m_key = k; }
|
||||
void SetModifiers(int m) { m_modifiers = m; }
|
||||
void SetModificationType(int t) { m_modificationType = t; }
|
||||
void SetText(const char* t) { m_text = t; }
|
||||
void SetLength(int len) { m_length = len; }
|
||||
void SetLinesAdded(int num) { m_linesAdded = num; }
|
||||
void SetLine(int val) { m_line = val; }
|
||||
void SetFoldLevelNow(int val) { m_foldLevelNow = val; }
|
||||
void SetFoldLevelPrev(int val) { m_foldLevelPrev = val; }
|
||||
void SetMargin(int val) { m_margin = val; }
|
||||
void SetMessage(int val) { m_message = val; }
|
||||
void SetWParam(int val) { m_wParam = val; }
|
||||
void SetLParam(int val) { m_lParam = val; }
|
||||
|
||||
int GetPosition() const { return m_position; }
|
||||
int GetKey() const { return m_key; }
|
||||
int GetModifiers() const { return m_modifiers; }
|
||||
int GetModificationType() const { return m_modificationType; }
|
||||
wxString GetText() const { return m_text; }
|
||||
int GetLength() const { return m_length; }
|
||||
int GetLinesAdded() const { return m_linesAdded; }
|
||||
int GetLine() const { return m_line; }
|
||||
int GetFoldLevelNow() const { return m_foldLevelNow; }
|
||||
int GetFoldLevelPrev() const { return m_foldLevelPrev; }
|
||||
int GetMargin() const { return m_margin; }
|
||||
int GetMessage() const { return m_message; }
|
||||
int GetWParam() const { return m_wParam; }
|
||||
int GetLParam() const { return m_lParam; }
|
||||
|
||||
bool GetShift() const;
|
||||
bool GetControl() const;
|
||||
bool GetAlt() const;
|
||||
|
||||
void CopyObject(wxObject& obj) const;
|
||||
|
||||
#ifndef SWIG
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxStyledTextEvent)
|
||||
|
||||
int m_position;
|
||||
int m_key;
|
||||
int m_modifiers;
|
||||
|
||||
int m_modificationType; // wxEVT_STC_MODIFIED
|
||||
wxString m_text;
|
||||
int m_length;
|
||||
int m_linesAdded;
|
||||
int m_line;
|
||||
int m_foldLevelNow;
|
||||
int m_foldLevelPrev;
|
||||
|
||||
int m_margin; // wxEVT_STC_MARGINCLICK
|
||||
|
||||
int m_message; // wxEVT_STC_MACRORECORD
|
||||
int m_wParam;
|
||||
int m_lParam;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
// Event types
|
||||
enum {
|
||||
wxEVT_STC_CHANGE = 1650,
|
||||
wxEVT_STC_STYLENEEDED,
|
||||
wxEVT_STC_CHARADDED,
|
||||
wxEVT_STC_UPDATEUI,
|
||||
wxEVT_STC_SAVEPOINTREACHED,
|
||||
wxEVT_STC_SAVEPOINTLEFT,
|
||||
wxEVT_STC_ROMODIFYATTEMPT,
|
||||
wxEVT_STC_DOUBLECLICK,
|
||||
wxEVT_STC_MODIFIED,
|
||||
wxEVT_STC_KEY,
|
||||
wxEVT_STC_MACRORECORD,
|
||||
wxEVT_STC_MARGINCLICK,
|
||||
wxEVT_STC_NEEDSHOWN,
|
||||
wxEVT_STC_POSCHANGED
|
||||
};
|
||||
|
||||
|
||||
#ifndef SWIG
|
||||
typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&);
|
||||
|
||||
#define EVT_STC_CHANGE(id, fn) { wxEVT_STC_CHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_STYLENEEDED(id, fn) { wxEVT_STC_STYLENEEDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_CHARADDED(id, fn) { wxEVT_STC_CHARADDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_UPDATEUI(id, fn) { wxEVT_STC_UPDATEUI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_SAVEPOINTREACHED(id, fn) { wxEVT_STC_SAVEPOINTREACHED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_SAVEPOINTLEFT(id, fn) { wxEVT_STC_SAVEPOINTLEFT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_ROMODIFYATTEMPT(id, fn) { wxEVT_STC_ROMODIFYATTEMPT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_DOUBLECLICK(id, fn) { wxEVT_STC_DOUBLECLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_MODIFIED(id, fn) { wxEVT_STC_MODIFIED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_KEY(id, fn) { wxEVT_STC_KEY, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_MACRORECORD(id, fn) { wxEVT_STC_MACRORECORD, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_MARGINCLICK(id, fn) { wxEVT_STC_MARGINCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_NEEDSHOWN(id, fn) { wxEVT_STC_NEEDSHOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_POSCHANGED(id, fn) { wxEVT_STC_POSCHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------
|
||||
#endif
|
||||
|
||||
|
||||
1396
include/wx/stc/stc.h
1396
include/wx/stc/stc.h
File diff suppressed because it is too large
Load Diff
@@ -1,56 +0,0 @@
|
||||
###############################################################################
|
||||
# Purpose: Makefile.in for STC contrib for Unix with autoconf
|
||||
# Created: 14.03.00
|
||||
# Author: VZ
|
||||
# Version: $Id$
|
||||
###############################################################################
|
||||
|
||||
top_srcdir = @top_srcdir@/..
|
||||
top_builddir = ../../..
|
||||
|
||||
scintilla_dir = $(top_srcdir)/contrib/src/stc/scintilla
|
||||
libsrc_dir = contrib/src/stc@PATH_IFS@$(scintilla_dir)/src
|
||||
|
||||
TARGET_LIBNAME=libstc
|
||||
|
||||
LIBVERSION_CURRENT=1
|
||||
LIBVERSION_REVISION=0
|
||||
LIBVERSION_AGE=0
|
||||
|
||||
HEADER_PATH=$(top_srcdir)/contrib/include/wx
|
||||
HEADER_SUBDIR=stc
|
||||
|
||||
HEADERS=stc.h
|
||||
|
||||
OBJECTS=PlatWX.o ScintillaWX.o stc.o \
|
||||
DocumentAccessor.o \
|
||||
LexCPP.o \
|
||||
LexHTML.o \
|
||||
LexLua.o \
|
||||
LexOthers.o \
|
||||
LexPerl.o \
|
||||
LexPython.o \
|
||||
LexSQL.o \
|
||||
LexVB.o \
|
||||
UniConversion.o \
|
||||
WindowAccessor.o \
|
||||
AutoComplete.o \
|
||||
CallTip.o \
|
||||
CellBuffer.o \
|
||||
ContractionState.o \
|
||||
Document.o \
|
||||
Editor.o \
|
||||
Indicator.o \
|
||||
KeyMap.o \
|
||||
KeyWords.o \
|
||||
LineMarker.o \
|
||||
PropSet.o \
|
||||
ScintillaBase.o \
|
||||
Style.o \
|
||||
ViewStyle.o \
|
||||
PosRegExp.o \
|
||||
|
||||
|
||||
APPEXTRADEFS=-D__WX__ -DSCI_LEXER -I$(scintilla_dir)/src -I$(scintilla_dir)/include -I$(top_srcdir)/contrib/include
|
||||
|
||||
include $(top_builddir)/src/makelib.env
|
||||
@@ -1,712 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// PlatWX.cxx - implementation of platform facilities on wxWindows
|
||||
// Copyright 1998-1999 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Robin Dunn <robin@aldunn.com>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include "Platform.h"
|
||||
#include "wx/stc/stc.h"
|
||||
|
||||
|
||||
#ifdef __WXGTK__
|
||||
#include <gtk/gtk.h>
|
||||
#endif
|
||||
|
||||
Point Point::FromLong(long lpoint) {
|
||||
return Point(lpoint & 0xFFFF, lpoint >> 16);
|
||||
}
|
||||
|
||||
wxRect wxRectFromPRectangle(PRectangle prc) {
|
||||
wxRect rc(prc.left, prc.top,
|
||||
prc.right-prc.left, prc.bottom-prc.top);
|
||||
return rc;
|
||||
}
|
||||
|
||||
PRectangle PRectangleFromwxRect(wxRect rc) {
|
||||
return PRectangle(rc.GetLeft(), rc.GetTop(), rc.GetRight(), rc.GetBottom());
|
||||
}
|
||||
|
||||
Colour::Colour(long lcol) {
|
||||
co.Set(lcol & 0xff, (lcol >> 8) & 0xff, (lcol >> 16) & 0xff);
|
||||
}
|
||||
|
||||
Colour::Colour(unsigned int red, unsigned int green, unsigned int blue) {
|
||||
co.Set(red, green, blue);
|
||||
}
|
||||
|
||||
bool Colour::operator==(const Colour &other) const {
|
||||
return co == other.co;
|
||||
}
|
||||
|
||||
long Colour::AsLong() const {
|
||||
return (((long)co.Blue() << 16) |
|
||||
((long)co.Green() << 8) |
|
||||
((long)co.Red()));
|
||||
}
|
||||
|
||||
unsigned int Colour::GetRed() {
|
||||
return co.Red();
|
||||
}
|
||||
|
||||
unsigned int Colour::GetGreen() {
|
||||
return co.Green();
|
||||
}
|
||||
|
||||
unsigned int Colour::GetBlue() {
|
||||
return co.Blue();
|
||||
}
|
||||
|
||||
Palette::Palette() {
|
||||
used = 0;
|
||||
allowRealization = false;
|
||||
}
|
||||
|
||||
Palette::~Palette() {
|
||||
Release();
|
||||
}
|
||||
|
||||
void Palette::Release() {
|
||||
used = 0;
|
||||
}
|
||||
|
||||
// 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 Palette::WantFind(ColourPair &cp, bool want) {
|
||||
if (want) {
|
||||
for (int i=0; i < used; i++) {
|
||||
if (entries[i].desired == cp.desired)
|
||||
return;
|
||||
}
|
||||
|
||||
if (used < numEntries) {
|
||||
entries[used].desired = cp.desired;
|
||||
entries[used].allocated = cp.desired;
|
||||
used++;
|
||||
}
|
||||
} else {
|
||||
for (int i=0; i < used; i++) {
|
||||
if (entries[i].desired == cp.desired) {
|
||||
cp.allocated = entries[i].allocated;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cp.allocated = cp.desired;
|
||||
}
|
||||
}
|
||||
|
||||
void Palette::Allocate(Window &) {
|
||||
if (allowRealization) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Font::Font() {
|
||||
id = 0;
|
||||
ascent = 0;
|
||||
}
|
||||
|
||||
Font::~Font() {
|
||||
}
|
||||
|
||||
void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic) {
|
||||
Release();
|
||||
id = new wxFont(size,
|
||||
wxDEFAULT,
|
||||
italic ? wxITALIC : wxNORMAL,
|
||||
bold ? wxBOLD : wxNORMAL,
|
||||
false,
|
||||
faceName,
|
||||
wxFONTENCODING_DEFAULT);
|
||||
}
|
||||
|
||||
|
||||
void Font::Release() {
|
||||
if (id)
|
||||
delete id;
|
||||
id = 0;
|
||||
}
|
||||
|
||||
|
||||
Surface::Surface() :
|
||||
hdc(0), hdcOwned(0), bitmap(0),
|
||||
x(0), y(0) {
|
||||
}
|
||||
|
||||
Surface::~Surface() {
|
||||
Release();
|
||||
}
|
||||
|
||||
void Surface::Release() {
|
||||
if (bitmap) {
|
||||
((wxMemoryDC*)hdc)->SelectObject(wxNullBitmap);
|
||||
delete bitmap;
|
||||
bitmap = 0;
|
||||
}
|
||||
if (hdcOwned) {
|
||||
delete hdc;
|
||||
hdc = 0;
|
||||
hdcOwned = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Surface::Initialised() {
|
||||
return hdc != 0;
|
||||
}
|
||||
|
||||
void Surface::Init() {
|
||||
Release();
|
||||
hdc = new wxMemoryDC();
|
||||
hdcOwned = true;
|
||||
// **** ::SetTextAlign(hdc, TA_BASELINE);
|
||||
}
|
||||
|
||||
void Surface::Init(SurfaceID hdc_) {
|
||||
Release();
|
||||
hdc = hdc_;
|
||||
// **** ::SetTextAlign(hdc, TA_BASELINE);
|
||||
}
|
||||
|
||||
void Surface::InitPixMap(int width, int height, Surface *surface_) {
|
||||
Release();
|
||||
hdc = new wxMemoryDC(surface_->hdc);
|
||||
hdcOwned = true;
|
||||
bitmap = new wxBitmap(width, height);
|
||||
((wxMemoryDC*)hdc)->SelectObject(*bitmap);
|
||||
// **** ::SetTextAlign(hdc, TA_BASELINE);
|
||||
}
|
||||
|
||||
void Surface::PenColour(Colour fore) {
|
||||
hdc->SetPen(wxPen(fore.co, 1, wxSOLID));
|
||||
}
|
||||
|
||||
void Surface::BrushColor(Colour back) {
|
||||
hdc->SetBrush(wxBrush(back.co, wxSOLID));
|
||||
}
|
||||
|
||||
void Surface::SetFont(Font &font_) {
|
||||
if (font_.GetID()) {
|
||||
hdc->SetFont(*font_.GetID());
|
||||
}
|
||||
}
|
||||
|
||||
int Surface::LogPixelsY() {
|
||||
return hdc->GetPPI().y;
|
||||
}
|
||||
|
||||
|
||||
int Surface::DeviceHeightFont(int points) {
|
||||
return points * LogPixelsY() / 72;
|
||||
}
|
||||
|
||||
|
||||
void Surface::MoveTo(int x_, int y_) {
|
||||
x = x_;
|
||||
y = y_;
|
||||
}
|
||||
|
||||
void Surface::LineTo(int x_, int y_) {
|
||||
hdc->DrawLine(x,y, x_,y_);
|
||||
x = x_;
|
||||
y = y_;
|
||||
}
|
||||
|
||||
void Surface::Polygon(Point *pts, int npts, Colour fore,
|
||||
Colour back) {
|
||||
PenColour(fore);
|
||||
BrushColor(back);
|
||||
hdc->DrawPolygon(npts, (wxPoint*)pts);
|
||||
}
|
||||
|
||||
void Surface::RectangleDraw(PRectangle rc, Colour fore, Colour back) {
|
||||
PenColour(fore);
|
||||
BrushColor(back);
|
||||
hdc->DrawRectangle(wxRectFromPRectangle(rc));
|
||||
}
|
||||
|
||||
void Surface::FillRectangle(PRectangle rc, Colour back) {
|
||||
BrushColor(back);
|
||||
hdc->SetPen(*wxTRANSPARENT_PEN);
|
||||
hdc->DrawRectangle(wxRectFromPRectangle(rc));
|
||||
}
|
||||
|
||||
void Surface::FillRectangle(PRectangle rc, Surface &surfacePattern) {
|
||||
wxBrush br;
|
||||
if (surfacePattern.bitmap)
|
||||
br = wxBrush(*surfacePattern.bitmap);
|
||||
else // Something is wrong so display in red
|
||||
br = wxBrush(*wxRED, wxSOLID);
|
||||
hdc->SetPen(*wxTRANSPARENT_PEN);
|
||||
hdc->SetBrush(br);
|
||||
hdc->DrawRectangle(wxRectFromPRectangle(rc));
|
||||
}
|
||||
|
||||
void Surface::RoundedRectangle(PRectangle rc, Colour fore, Colour back) {
|
||||
PenColour(fore);
|
||||
BrushColor(back);
|
||||
hdc->DrawRoundedRectangle(wxRectFromPRectangle(rc), 4);
|
||||
}
|
||||
|
||||
void Surface::Ellipse(PRectangle rc, Colour fore, Colour back) {
|
||||
PenColour(fore);
|
||||
BrushColor(back);
|
||||
hdc->DrawEllipse(wxRectFromPRectangle(rc));
|
||||
}
|
||||
|
||||
void Surface::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
|
||||
wxRect r = wxRectFromPRectangle(rc);
|
||||
hdc->Blit(r.x, r.y, r.width, r.height,
|
||||
surfaceSource.hdc, from.x, from.y, wxCOPY);
|
||||
}
|
||||
|
||||
void Surface::DrawText(PRectangle rc, Font &font, int ybase,
|
||||
const char *s, int len, Colour fore, Colour back) {
|
||||
SetFont(font);
|
||||
hdc->SetTextForeground(fore.co);
|
||||
hdc->SetTextBackground(back.co);
|
||||
FillRectangle(rc, back);
|
||||
|
||||
// ybase is where the baseline should be, but wxWin uses the upper left
|
||||
// corner, so I need to calculate the real position for the text...
|
||||
hdc->DrawText(wxString(s, len), rc.left, ybase - font.ascent);
|
||||
}
|
||||
|
||||
void Surface::DrawTextClipped(PRectangle rc, Font &font, int ybase, const char *s, int len, Colour fore, Colour back) {
|
||||
SetFont(font);
|
||||
hdc->SetTextForeground(fore.co);
|
||||
hdc->SetTextBackground(back.co);
|
||||
FillRectangle(rc, back);
|
||||
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
|
||||
|
||||
// see comments above
|
||||
hdc->DrawText(wxString(s, len), rc.left, ybase - font.ascent);
|
||||
hdc->DestroyClippingRegion();
|
||||
}
|
||||
|
||||
int Surface::WidthText(Font &font, const char *s, int len) {
|
||||
SetFont(font);
|
||||
int w;
|
||||
int h;
|
||||
hdc->GetTextExtent(wxString(s, len), &w, &h);
|
||||
return w;
|
||||
}
|
||||
|
||||
void Surface::MeasureWidths(Font &font, const char *s, int len, int *positions) {
|
||||
SetFont(font);
|
||||
int totalWidth = 0;
|
||||
for (int i=0; i<len; i++) {
|
||||
int w;
|
||||
int h;
|
||||
hdc->GetTextExtent(s[i], &w, &h);
|
||||
totalWidth += w;
|
||||
positions[i] = totalWidth;
|
||||
}
|
||||
}
|
||||
|
||||
int Surface::WidthChar(Font &font, char ch) {
|
||||
SetFont(font);
|
||||
int w;
|
||||
int h;
|
||||
hdc->GetTextExtent(ch, &w, &h);
|
||||
return w;
|
||||
}
|
||||
|
||||
#define EXTENT_TEST " `~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
int Surface::Ascent(Font &font) {
|
||||
SetFont(font);
|
||||
int w, h, d, e;
|
||||
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
|
||||
font.ascent = h - d;
|
||||
return font.ascent;
|
||||
}
|
||||
|
||||
int Surface::Descent(Font &font) {
|
||||
SetFont(font);
|
||||
int w, h, d, e;
|
||||
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
|
||||
return d;
|
||||
}
|
||||
|
||||
int Surface::InternalLeading(Font &font) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Surface::ExternalLeading(Font &font) {
|
||||
SetFont(font);
|
||||
int w, h, d, e;
|
||||
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
|
||||
return e;
|
||||
}
|
||||
|
||||
int Surface::Height(Font &font) {
|
||||
SetFont(font);
|
||||
return hdc->GetCharHeight();
|
||||
}
|
||||
|
||||
int Surface::AverageCharWidth(Font &font) {
|
||||
SetFont(font);
|
||||
return hdc->GetCharWidth();
|
||||
}
|
||||
|
||||
int Surface::SetPalette(Palette *pal, bool inBackGround) {
|
||||
return 0; // **** figure out what to do with palettes...
|
||||
}
|
||||
|
||||
void Surface::SetClip(PRectangle rc) {
|
||||
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
|
||||
}
|
||||
|
||||
void Surface::FlushCachedState() {
|
||||
}
|
||||
|
||||
Window::~Window() {
|
||||
}
|
||||
|
||||
void Window::Destroy() {
|
||||
if (id)
|
||||
id->Destroy();
|
||||
id = 0;
|
||||
}
|
||||
|
||||
bool Window::HasFocus() {
|
||||
return wxWindow::FindFocus() == id;
|
||||
}
|
||||
|
||||
PRectangle Window::GetPosition() {
|
||||
wxRect rc(id->GetPosition(), id->GetSize());
|
||||
return PRectangleFromwxRect(rc);
|
||||
}
|
||||
|
||||
void Window::SetPosition(PRectangle rc) {
|
||||
wxRect r = wxRectFromPRectangle(rc);
|
||||
id->SetSize(r);
|
||||
}
|
||||
|
||||
void Window::SetPositionRelative(PRectangle rc, Window) {
|
||||
SetPosition(rc); // ????
|
||||
}
|
||||
|
||||
PRectangle Window::GetClientPosition() {
|
||||
wxSize sz = id->GetClientSize();
|
||||
return PRectangle(0, 0, sz.x, sz.y);
|
||||
}
|
||||
|
||||
void Window::Show(bool show) {
|
||||
id->Show(show);
|
||||
}
|
||||
|
||||
void Window::InvalidateAll() {
|
||||
id->Refresh(false);
|
||||
}
|
||||
|
||||
void Window::InvalidateRectangle(PRectangle rc) {
|
||||
wxRect r = wxRectFromPRectangle(rc);
|
||||
id->Refresh(false, &r);
|
||||
}
|
||||
|
||||
void Window::SetFont(Font &font) {
|
||||
id->SetFont(*font.GetID());
|
||||
}
|
||||
|
||||
void Window::SetCursor(Cursor curs) {
|
||||
int cursorId;
|
||||
|
||||
switch (curs) {
|
||||
case cursorText:
|
||||
cursorId = wxCURSOR_IBEAM;
|
||||
break;
|
||||
case cursorArrow:
|
||||
cursorId = wxCURSOR_ARROW;
|
||||
break;
|
||||
case cursorUp:
|
||||
cursorId = wxCURSOR_ARROW; // ** no up arrow... wxCURSOR_UPARROW;
|
||||
break;
|
||||
case cursorWait:
|
||||
cursorId = wxCURSOR_WAIT;
|
||||
break;
|
||||
case cursorHoriz:
|
||||
cursorId = wxCURSOR_SIZEWE;
|
||||
break;
|
||||
case cursorVert:
|
||||
cursorId = wxCURSOR_SIZENS;
|
||||
break;
|
||||
case cursorReverseArrow:
|
||||
cursorId = wxCURSOR_POINT_RIGHT;
|
||||
break;
|
||||
default:
|
||||
cursorId = wxCURSOR_ARROW;
|
||||
break;
|
||||
}
|
||||
|
||||
id->SetCursor(wxCursor(cursorId));
|
||||
}
|
||||
|
||||
|
||||
void Window::SetTitle(const char *s) {
|
||||
id->SetTitle(s);
|
||||
}
|
||||
|
||||
|
||||
class wxSTCListBox : public wxListBox {
|
||||
public:
|
||||
wxSTCListBox(wxWindow* parent, wxWindowID id)
|
||||
: wxListBox(parent, id, wxDefaultPosition, wxDefaultSize,
|
||||
0, NULL, wxLB_SINGLE | wxLB_SORT | wxSIMPLE_BORDER)
|
||||
{}
|
||||
|
||||
void OnFocus(wxFocusEvent& event) {
|
||||
GetParent()->SetFocus();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
#ifdef __WXGTK__
|
||||
void DoSetFirstItem(int n);
|
||||
#endif
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(wxSTCListBox, wxListBox)
|
||||
EVT_SET_FOCUS(wxSTCListBox::OnFocus)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __WXGTK__
|
||||
// This can be removed after 2.2.2 I think
|
||||
void wxSTCListBox::DoSetFirstItem( int n )
|
||||
{
|
||||
wxCHECK_RET( m_list, wxT("invalid listbox") );
|
||||
|
||||
if (gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_GRAB (m_list))
|
||||
return;
|
||||
|
||||
// terribly efficient
|
||||
const gchar *vadjustment_key = "gtk-vadjustment";
|
||||
guint vadjustment_key_id = g_quark_from_static_string (vadjustment_key);
|
||||
|
||||
GtkAdjustment *adjustment =
|
||||
(GtkAdjustment*) gtk_object_get_data_by_id (GTK_OBJECT (m_list), vadjustment_key_id);
|
||||
wxCHECK_RET( adjustment, wxT("invalid listbox code") );
|
||||
|
||||
GList *target = g_list_nth( m_list->children, n );
|
||||
wxCHECK_RET( target, wxT("invalid listbox index") );
|
||||
|
||||
GtkWidget *item = GTK_WIDGET(target->data);
|
||||
wxCHECK_RET( item, wxT("invalid listbox code") );
|
||||
|
||||
// find the last item before this one which is already realized
|
||||
size_t nItemsBefore;
|
||||
for ( nItemsBefore = 0; item && (item->allocation.y == -1); nItemsBefore++ )
|
||||
{
|
||||
target = target->prev;
|
||||
if ( !target )
|
||||
{
|
||||
// nothing we can do if there are no allocated items yet
|
||||
return;
|
||||
}
|
||||
|
||||
item = GTK_WIDGET(target->data);
|
||||
}
|
||||
|
||||
gtk_adjustment_set_value(adjustment,
|
||||
item->allocation.y +
|
||||
nItemsBefore*item->allocation.height);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
ListBox::ListBox() {
|
||||
}
|
||||
|
||||
ListBox::~ListBox() {
|
||||
}
|
||||
|
||||
void ListBox::Create(Window &parent, int ctrlID) {
|
||||
id = new wxSTCListBox(parent.id, ctrlID);
|
||||
// id = new wxListBox(parent.id, ctrlID, wxDefaultPosition, wxDefaultSize,
|
||||
// 0, NULL, wxLB_SINGLE | wxLB_SORT | wxSIMPLE_BORDER);
|
||||
}
|
||||
|
||||
PRectangle ListBox::GetDesiredRect() {
|
||||
wxSize sz = ((wxListBox*)id)->GetBestSize();
|
||||
PRectangle rc;
|
||||
rc.top = 0;
|
||||
rc.left = 0;
|
||||
if (sz.x > 150) // TODO: A better way to determine these max sizes
|
||||
sz.x = 150;
|
||||
if (sz.y > 100)
|
||||
sz.y = 100;
|
||||
rc.right = sz.x;
|
||||
rc.bottom = sz.y;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
void ListBox::SetAverageCharWidth(int width) {
|
||||
aveCharWidth = width;
|
||||
}
|
||||
|
||||
void ListBox::SetFont(Font &font) {
|
||||
Window::SetFont(font);
|
||||
}
|
||||
|
||||
void ListBox::Clear() {
|
||||
((wxListBox*)id)->Clear();
|
||||
}
|
||||
|
||||
void ListBox::Append(char *s) {
|
||||
((wxListBox*)id)->Append(s);
|
||||
}
|
||||
|
||||
int ListBox::Length() {
|
||||
return ((wxListBox*)id)->Number();
|
||||
}
|
||||
|
||||
void ListBox::Select(int n) {
|
||||
((wxListBox*)id)->SetSelection(n);
|
||||
#ifdef __WXGTK__
|
||||
if (n > 4)
|
||||
n = n - 4;
|
||||
else
|
||||
n = 1;
|
||||
((wxListBox*)id)->SetFirstItem(n);
|
||||
#endif
|
||||
}
|
||||
|
||||
int ListBox::GetSelection() {
|
||||
return ((wxListBox*)id)->GetSelection();
|
||||
}
|
||||
|
||||
int ListBox::Find(const char *prefix) {
|
||||
if (prefix) {
|
||||
for (int x=0; x < ((wxListBox*)id)->Number(); x++) {
|
||||
wxString text = ((wxListBox*)id)->GetString(x);
|
||||
if (text.StartsWith(prefix))
|
||||
return x;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ListBox::GetValue(int n, char *value, int len) {
|
||||
wxString text = ((wxListBox*)id)->GetString(n);
|
||||
strncpy(value, text.c_str(), len);
|
||||
value[len-1] = '\0';
|
||||
}
|
||||
|
||||
void ListBox::Sort() {
|
||||
// wxWindows keeps sorted so no need to sort
|
||||
}
|
||||
|
||||
|
||||
Menu::Menu() : id(0) {
|
||||
}
|
||||
|
||||
void Menu::CreatePopUp() {
|
||||
Destroy();
|
||||
id = new wxMenu();
|
||||
}
|
||||
|
||||
void Menu::Destroy() {
|
||||
if (id)
|
||||
delete id;
|
||||
id = 0;
|
||||
}
|
||||
|
||||
void Menu::Show(Point pt, Window &w) {
|
||||
w.GetID()->PopupMenu(id, pt.x - 4, pt.y);
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
||||
Colour Platform::Chrome() {
|
||||
wxColour c;
|
||||
c = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
|
||||
return Colour(c.Red(), c.Green(), c.Blue());
|
||||
}
|
||||
|
||||
Colour Platform::ChromeHighlight() {
|
||||
wxColour c;
|
||||
c = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DHIGHLIGHT);
|
||||
return Colour(c.Red(), c.Green(), c.Blue());
|
||||
}
|
||||
|
||||
const char *Platform::DefaultFont() {
|
||||
return wxNORMAL_FONT->GetFaceName();
|
||||
}
|
||||
|
||||
int Platform::DefaultFontSize() {
|
||||
return 8;
|
||||
}
|
||||
|
||||
unsigned int Platform::DoubleClickTime() {
|
||||
return 500; // **** ::GetDoubleClickTime();
|
||||
}
|
||||
|
||||
void Platform::DebugDisplay(const char *s) {
|
||||
wxLogDebug(s);
|
||||
}
|
||||
|
||||
bool Platform::IsKeyDown(int key) {
|
||||
return false; // I don't think we'll need this.
|
||||
}
|
||||
|
||||
long Platform::SendScintilla(WindowID w,
|
||||
unsigned int msg,
|
||||
unsigned long wParam,
|
||||
long lParam) {
|
||||
|
||||
wxStyledTextCtrl* stc = (wxStyledTextCtrl*)w;
|
||||
return stc->SendMsg(msg, wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
// These are utility functions not really tied to a platform
|
||||
|
||||
int Platform::Minimum(int a, int b) {
|
||||
if (a < b)
|
||||
return a;
|
||||
else
|
||||
return b;
|
||||
}
|
||||
|
||||
int Platform::Maximum(int a, int b) {
|
||||
if (a > b)
|
||||
return a;
|
||||
else
|
||||
return b;
|
||||
}
|
||||
|
||||
#define TRACE
|
||||
|
||||
void Platform::DebugPrintf(const char *format, ...) {
|
||||
#ifdef TRACE
|
||||
char buffer[2000];
|
||||
va_list pArguments;
|
||||
va_start(pArguments, format);
|
||||
vsprintf(buffer,format,pArguments);
|
||||
va_end(pArguments);
|
||||
Platform::DebugDisplay(buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
int Platform::Clamp(int val, int minVal, int maxVal) {
|
||||
if (val > maxVal)
|
||||
val = maxVal;
|
||||
if (val < minVal)
|
||||
val = minVal;
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
This contrib is the wxStyledTextCtrl, which is a wrapper around the
|
||||
Scintilla edit control. (See www.scintilla.org)
|
||||
|
||||
There is still VERY MUCH to be done, most notable of which is a more
|
||||
advanced sample that exercises more of the code. (I havn't tested
|
||||
AutoComplete or CallTips, or most of the event types at all yet.) And
|
||||
also documentation, adding wrappers for some new scintilla
|
||||
functionality, building and testing on wxGTK, etc. Be patient, it all
|
||||
will get there soon.
|
||||
|
||||
|
||||
|
||||
Let me describe a bit about the architecture I am implementing...
|
||||
Obviously there is the Platform layer which implements the varioius
|
||||
platform classes by using wxWindows classes and filling in where
|
||||
needed. Then there is a ScintillaWX class that is derived from
|
||||
ScintillaBase and implements the necessary virtual methods that
|
||||
Scintilla needs to fully funciton. This class however is not meant to
|
||||
ever be used directly by wx programmers. I call it one end of the
|
||||
bridge between the wx and Scintilla worlds. The other end of the
|
||||
bridge is a class called wxStyledTextCtrl that looks, feels and acts
|
||||
like other classes in wxWindows. Here is a diagram:
|
||||
|
||||
|
||||
+------------------+ +-------------------+
|
||||
| wxStyledTextCtrl |--bridge--| ScintillaWX |
|
||||
+------------------+ +-------------------+
|
||||
| ScintillaBase |
|
||||
+-------------------+
|
||||
| Editor |
|
||||
+-------------------+
|
||||
| PlatWX |
|
||||
+-------------------+
|
||||
|
||||
|
||||
wxStyledTextCtrl derives from wxControl so it has a window that can be
|
||||
drawn upon. When a wxStyledTextCtrl is constructed it constructs a
|
||||
ScintillaWX for itself and passes itself to the scintilla object to be
|
||||
set as the wMain and wDraw attributes. All method calls on the STC
|
||||
are sent over the bridge in the form of calls to ScintiallWX::WndProc.
|
||||
All notifications are sent back over the bridge and turned into
|
||||
wxEvents.
|
||||
|
||||
|
||||
Robin
|
||||
|
||||
|
||||
@@ -1,515 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Name: ScintillaWX.cxx
|
||||
// Purpose: A wxWindows implementation of Scintilla. A class derived
|
||||
// from ScintillaBase that uses the "wx platform" defined in
|
||||
// PlatformWX.cxx This class is one end of a bridge between
|
||||
// the wx world and the Scintilla world. It needs a peer
|
||||
// object of type wxStyledTextCtrl to function.
|
||||
//
|
||||
// Author: Robin Dunn
|
||||
//
|
||||
// Created: 13-Jan-2000
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 by Total Control Software
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include "ScintillaWX.h"
|
||||
#include "wx/stc/stc.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
const int H_SCROLL_MAX = 2000;
|
||||
const int H_SCROLL_STEP = 20;
|
||||
const int H_SCROLL_PAGE = 200;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper classes
|
||||
|
||||
class wxSTCTimer : public wxTimer {
|
||||
public:
|
||||
wxSTCTimer(ScintillaWX* swx) {
|
||||
this->swx = swx;
|
||||
}
|
||||
|
||||
void Notify() {
|
||||
swx->DoTick();
|
||||
}
|
||||
|
||||
private:
|
||||
ScintillaWX* swx;
|
||||
};
|
||||
|
||||
|
||||
|
||||
bool wxSTCDropTarget::OnDropText(wxCoord x, wxCoord y, const wxString& data) {
|
||||
return swx->DoDropText(x, y, data);
|
||||
}
|
||||
|
||||
wxDragResult wxSTCDropTarget::OnEnter(wxCoord x, wxCoord y, wxDragResult def) {
|
||||
return swx->DoDragEnter(x, y, def);
|
||||
}
|
||||
|
||||
wxDragResult wxSTCDropTarget::OnDragOver(wxCoord x, wxCoord y, wxDragResult def) {
|
||||
return swx->DoDragOver(x, y, def);
|
||||
}
|
||||
|
||||
void wxSTCDropTarget::OnLeave() {
|
||||
swx->DoDragLeave();
|
||||
}
|
||||
|
||||
|
||||
class wxSTCCallTip : public wxWindow {
|
||||
public:
|
||||
wxSTCCallTip(wxWindow* parent, int ID, CallTip* ct)
|
||||
: wxWindow(parent, ID)
|
||||
{
|
||||
m_ct = ct;
|
||||
}
|
||||
|
||||
void OnPaint(wxPaintEvent& evt) {
|
||||
wxPaintDC dc(this);
|
||||
Surface surfaceWindow;
|
||||
surfaceWindow.Init(&dc);
|
||||
m_ct->PaintCT(&surfaceWindow);
|
||||
surfaceWindow.Release();
|
||||
}
|
||||
|
||||
CallTip* m_ct;
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(wxSTCCallTip, wxWindow)
|
||||
EVT_PAINT(wxSTCCallTip::OnPaint)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Constructor/Destructor
|
||||
|
||||
|
||||
ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) {
|
||||
capturedMouse = false;
|
||||
wMain = win;
|
||||
wDraw = win;
|
||||
stc = win;
|
||||
Initialise();
|
||||
}
|
||||
|
||||
|
||||
ScintillaWX::~ScintillaWX() {
|
||||
SetTicking(false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// base class virtuals
|
||||
|
||||
|
||||
void ScintillaWX::Initialise() {
|
||||
//ScintillaBase::Initialise();
|
||||
dropTarget = new wxSTCDropTarget;
|
||||
dropTarget->SetScintilla(this);
|
||||
stc->SetDropTarget(dropTarget);
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::Finalise() {
|
||||
ScintillaBase::Finalise();
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::StartDrag() {
|
||||
wxDropSource source(wMain.GetID());
|
||||
wxTextDataObject data(dragChars);
|
||||
wxDragResult result;
|
||||
|
||||
source.SetData(data);
|
||||
result = source.DoDragDrop(TRUE);
|
||||
if (result == wxDragMove && dropWentOutside)
|
||||
ClearSelection();
|
||||
inDragDrop = FALSE;
|
||||
SetDragPosition(invalidPosition);
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::SetTicking(bool on) {
|
||||
wxSTCTimer* steTimer;
|
||||
if (timer.ticking != on) {
|
||||
timer.ticking = on;
|
||||
if (timer.ticking) {
|
||||
steTimer = new wxSTCTimer(this);
|
||||
steTimer->Start(timer.tickSize);
|
||||
timer.tickerID = (int)steTimer;
|
||||
} else {
|
||||
steTimer = (wxSTCTimer*)timer.tickerID;
|
||||
steTimer->Stop();
|
||||
delete steTimer;
|
||||
timer.tickerID = 0;
|
||||
}
|
||||
}
|
||||
timer.ticksToWait = caret.period;
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::SetMouseCapture(bool on) {
|
||||
if (on && !capturedMouse)
|
||||
wMain.GetID()->CaptureMouse();
|
||||
else if (!on && capturedMouse)
|
||||
wMain.GetID()->ReleaseMouse();
|
||||
capturedMouse = on;
|
||||
}
|
||||
|
||||
|
||||
bool ScintillaWX::HaveMouseCapture() {
|
||||
return capturedMouse;
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::ScrollText(int linesToMove) {
|
||||
int dy = vs.lineHeight * (linesToMove);
|
||||
// TODO: calculate the rectangle to refreshed...
|
||||
wMain.GetID()->ScrollWindow(0, dy);
|
||||
}
|
||||
|
||||
void ScintillaWX::SetVerticalScrollPos() {
|
||||
wMain.GetID()->SetScrollPos(wxVERTICAL, topLine);
|
||||
}
|
||||
|
||||
void ScintillaWX::SetHorizontalScrollPos() {
|
||||
wMain.GetID()->SetScrollPos(wxHORIZONTAL, xOffset);
|
||||
}
|
||||
|
||||
|
||||
bool ScintillaWX::ModifyScrollBars(int nMax, int nPage) {
|
||||
bool modified = false;
|
||||
int sbMax = wMain.GetID()->GetScrollRange(wxVERTICAL);
|
||||
int sbThumb = wMain.GetID()->GetScrollThumb(wxVERTICAL);
|
||||
int sbPos = wMain.GetID()->GetScrollPos(wxVERTICAL);
|
||||
|
||||
|
||||
if (sbMax != nMax || sbThumb != nPage) {
|
||||
wMain.GetID()->SetScrollbar(wxVERTICAL, sbPos, nPage, nMax);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
sbMax = wMain.GetID()->GetScrollRange(wxHORIZONTAL);
|
||||
sbThumb = wMain.GetID()->GetScrollThumb(wxHORIZONTAL);
|
||||
if ((sbMax != H_SCROLL_MAX) || (sbThumb != H_SCROLL_STEP)) {
|
||||
wMain.GetID()->SetScrollbar(wxHORIZONTAL, 0, H_SCROLL_STEP, H_SCROLL_MAX);
|
||||
modified = true;
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::NotifyChange() {
|
||||
stc->NotifyChange();
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::NotifyParent(SCNotification scn) {
|
||||
stc->NotifyParent(&scn);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ScintillaWX::Copy() {
|
||||
if (currentPos != anchor) {
|
||||
char* text = CopySelectionRange();
|
||||
wxTheClipboard->Open();
|
||||
wxTheClipboard->SetData(new wxTextDataObject(text));
|
||||
wxTheClipboard->Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::Paste() {
|
||||
pdoc->BeginUndoAction();
|
||||
ClearSelection();
|
||||
|
||||
wxTextDataObject data;
|
||||
bool canPaste;
|
||||
|
||||
wxTheClipboard->Open();
|
||||
canPaste = wxTheClipboard->GetData(data);
|
||||
wxTheClipboard->Close();
|
||||
if (canPaste) {
|
||||
wxString str = data.GetText();
|
||||
int len = str.Length();
|
||||
pdoc->InsertString(currentPos, str.c_str(), len);
|
||||
SetEmptySelection(currentPos + len);
|
||||
}
|
||||
|
||||
pdoc->EndUndoAction();
|
||||
NotifyChange();
|
||||
Redraw();
|
||||
}
|
||||
|
||||
|
||||
bool ScintillaWX::CanPaste() {
|
||||
wxTextDataObject data;
|
||||
bool canPaste;
|
||||
|
||||
wxTheClipboard->Open();
|
||||
canPaste = wxTheClipboard->GetData(data);
|
||||
wxTheClipboard->Close();
|
||||
|
||||
return canPaste;
|
||||
}
|
||||
|
||||
void ScintillaWX::CreateCallTipWindow(PRectangle) {
|
||||
ct.wCallTip = new wxSTCCallTip(wDraw.GetID(), -1, &ct);
|
||||
ct.wDraw = ct.wCallTip;
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) {
|
||||
if (!label[0])
|
||||
popup.GetID()->AppendSeparator();
|
||||
else
|
||||
popup.GetID()->Append(cmd, label);
|
||||
|
||||
if (!enabled)
|
||||
popup.GetID()->Enable(cmd, enabled);
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::ClaimSelection() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
long ScintillaWX::DefWndProc(unsigned int /*iMessage*/, unsigned long /*wParam*/, long /*lParam*/) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
long ScintillaWX::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) {
|
||||
// switch (iMessage) {
|
||||
// case EM_CANPASTE:
|
||||
// return CanPaste();
|
||||
// default:
|
||||
return ScintillaBase::WndProc(iMessage, wParam, lParam);
|
||||
// }
|
||||
// return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Event delegates
|
||||
|
||||
void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) {
|
||||
|
||||
paintState = painting;
|
||||
Surface surfaceWindow;
|
||||
surfaceWindow.Init(dc);
|
||||
PRectangle rcPaint = PRectangleFromwxRect(rect);
|
||||
dc->BeginDrawing();
|
||||
Paint(&surfaceWindow, rcPaint);
|
||||
dc->EndDrawing();
|
||||
surfaceWindow.Release();
|
||||
if (paintState == paintAbandoned) {
|
||||
// Painting area was insufficient to cover new styling or brace highlight positions
|
||||
FullPaint();
|
||||
}
|
||||
paintState = notPainting;
|
||||
#ifdef __WXGTK__
|
||||
// On wxGTK the editor window paints can overwrite the listbox...
|
||||
if (ac.Active())
|
||||
((wxWindow*)ac.lb.GetID())->Refresh(TRUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::DoHScroll(int type, int pos) {
|
||||
int xPos = xOffset;
|
||||
switch (type) {
|
||||
case wxEVT_SCROLLWIN_LINEUP:
|
||||
xPos -= H_SCROLL_STEP;
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_LINEDOWN:
|
||||
xPos += H_SCROLL_STEP;
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_PAGEUP:
|
||||
xPos -= H_SCROLL_PAGE;
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_PAGEDOWN:
|
||||
xPos += H_SCROLL_PAGE;
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_TOP:
|
||||
xPos = 0;
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_BOTTOM:
|
||||
xPos = H_SCROLL_MAX;
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_THUMBTRACK:
|
||||
xPos = pos;
|
||||
break;
|
||||
}
|
||||
HorizontalScrollTo(xPos);
|
||||
}
|
||||
|
||||
void ScintillaWX::DoVScroll(int type, int pos) {
|
||||
int topLineNew = topLine;
|
||||
switch (type) {
|
||||
case wxEVT_SCROLLWIN_LINEUP:
|
||||
topLineNew -= 1;
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_LINEDOWN:
|
||||
topLineNew += 1;
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_PAGEUP:
|
||||
topLineNew -= LinesToScroll();
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_PAGEDOWN:
|
||||
topLineNew += LinesToScroll();
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_TOP:
|
||||
topLineNew = 0;
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_BOTTOM:
|
||||
topLineNew = MaxScrollPos();
|
||||
break;
|
||||
case wxEVT_SCROLLWIN_THUMBTRACK:
|
||||
topLineNew = pos;
|
||||
break;
|
||||
}
|
||||
ScrollTo(topLineNew);
|
||||
}
|
||||
|
||||
void ScintillaWX::DoSize(int width, int height) {
|
||||
PRectangle rcClient(0,0,width,height);
|
||||
SetScrollBarsTo(rcClient);
|
||||
DropGraphics();
|
||||
}
|
||||
|
||||
void ScintillaWX::DoLoseFocus(){
|
||||
DropCaret();
|
||||
}
|
||||
|
||||
void ScintillaWX::DoGainFocus(){
|
||||
ShowCaretAtCurrentPosition();
|
||||
}
|
||||
|
||||
void ScintillaWX::DoSysColourChange() {
|
||||
InvalidateStyleData();
|
||||
}
|
||||
|
||||
void ScintillaWX::DoButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) {
|
||||
ButtonDown(pt, curTime, shift, ctrl, alt);
|
||||
}
|
||||
|
||||
void ScintillaWX::DoButtonUp(Point pt, unsigned int curTime, bool ctrl) {
|
||||
ButtonUp(pt, curTime, ctrl);
|
||||
}
|
||||
|
||||
void ScintillaWX::DoButtonMove(Point pt) {
|
||||
ButtonMove(pt);
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::DoAddChar(char ch) {
|
||||
//bool acActiveBeforeCharAdded = ac.Active();
|
||||
AddChar(ch);
|
||||
//if (acActiveBeforeCharAdded)
|
||||
// AutoCompleteChanged(ch);
|
||||
}
|
||||
|
||||
int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt) {
|
||||
switch (key) {
|
||||
case WXK_DOWN: key = SCK_DOWN; break;
|
||||
case WXK_UP: key = SCK_UP; break;
|
||||
case WXK_LEFT: key = SCK_LEFT; break;
|
||||
case WXK_RIGHT: key = SCK_RIGHT; break;
|
||||
case WXK_HOME: key = SCK_HOME; break;
|
||||
case WXK_END: key = SCK_END; break;
|
||||
case WXK_PRIOR: key = SCK_PRIOR; break;
|
||||
case WXK_NEXT: key = SCK_NEXT; break;
|
||||
case WXK_DELETE: key = SCK_DELETE; break;
|
||||
case WXK_INSERT: key = SCK_INSERT; break;
|
||||
case WXK_ESCAPE: key = SCK_ESCAPE; break;
|
||||
case WXK_BACK: key = SCK_BACK; break;
|
||||
case WXK_TAB: key = SCK_TAB; break;
|
||||
case WXK_RETURN: key = SCK_RETURN; break;
|
||||
case WXK_ADD: key = SCK_ADD; break;
|
||||
case WXK_SUBTRACT: key = SCK_SUBTRACT; break;
|
||||
case WXK_DIVIDE: key = SCK_DIVIDE; break;
|
||||
case WXK_CONTROL: key = 0; break;
|
||||
case WXK_ALT: key = 0; break;
|
||||
case WXK_SHIFT: key = 0; break;
|
||||
}
|
||||
|
||||
return KeyDown(key, shift, ctrl, alt);
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::DoCommand(int ID) {
|
||||
Command(ID);
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::DoContextMenu(Point pt) {
|
||||
ContextMenu(pt);
|
||||
}
|
||||
|
||||
void ScintillaWX::DoOnListBox() {
|
||||
AutoCompleteCompleted();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
bool ScintillaWX::DoDropText(long x, long y, const wxString& data) {
|
||||
SetDragPosition(invalidPosition);
|
||||
int movePos = PositionFromLocation(Point(x,y));
|
||||
DropAt(movePos, data, dragResult == wxDragMove, FALSE); // TODO: rectangular?
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
wxDragResult ScintillaWX::DoDragEnter(wxCoord x, wxCoord y, wxDragResult def) {
|
||||
return def;
|
||||
}
|
||||
|
||||
|
||||
wxDragResult ScintillaWX::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
|
||||
SetDragPosition(PositionFromLocation(Point(x, y)));
|
||||
dragResult = def;
|
||||
return def;
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::DoDragLeave() {
|
||||
SetDragPosition(invalidPosition);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Redraw all of text area. This paint will not be abandoned.
|
||||
void ScintillaWX::FullPaint() {
|
||||
paintState = painting;
|
||||
// rcPaint = GetTextRectangle();
|
||||
// wxClientDC dc(wMain.GetID());
|
||||
// Surface surfaceWindow;
|
||||
// surfaceWindow.Init(&dc);
|
||||
// Paint(&surfaceWindow, rcPaint);
|
||||
// surfaceWindow.Release();
|
||||
wMain.GetID()->Refresh(FALSE);
|
||||
paintState = notPainting;
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::DoScrollToLine(int line) {
|
||||
ScrollTo(line);
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::DoScrollToColumn(int column) {
|
||||
HorizontalScrollTo(column * vs.spaceWidth);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------
|
||||
@@ -1,152 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Name: ScintillaWX.h
|
||||
// Purpose: A wxWindows implementation of Scintilla. A class derived
|
||||
// from ScintillaBase that uses the "wx platform" defined in
|
||||
// PlatWX.cpp. This class is one end of a bridge between
|
||||
// the wx world and the Scintilla world. It needs a peer
|
||||
// object of type wxStyledTextCtrl to function.
|
||||
//
|
||||
// Author: Robin Dunn
|
||||
//
|
||||
// Created: 13-Jan-2000
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 by Total Control Software
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __ScintillaWX_h__
|
||||
#define __ScintillaWX_h__
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "Scintilla.h"
|
||||
#ifdef SCI_LEXER
|
||||
#include "SciLexer.h"
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "KeyWords.h"
|
||||
#endif
|
||||
#include "ContractionState.h"
|
||||
#include "SVector.h"
|
||||
#include "CellBuffer.h"
|
||||
#include "CallTip.h"
|
||||
#include "KeyMap.h"
|
||||
#include "Indicator.h"
|
||||
#include "LineMarker.h"
|
||||
#include "Style.h"
|
||||
#include "ViewStyle.h"
|
||||
#include "AutoComplete.h"
|
||||
#include "Document.h"
|
||||
#include "Editor.h"
|
||||
#include "ScintillaBase.h"
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/dataobj.h>
|
||||
#include <wx/clipbrd.h>
|
||||
#include <wx/dnd.h>
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class wxStyledTextCtrl; // forward
|
||||
class ScintillaWX;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper classes
|
||||
|
||||
class wxSTCDropTarget : public wxTextDropTarget {
|
||||
public:
|
||||
void SetScintilla(ScintillaWX* swx) {
|
||||
this->swx = swx;
|
||||
}
|
||||
|
||||
bool OnDropText(wxCoord x, wxCoord y, const wxString& data);
|
||||
wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def);
|
||||
wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
|
||||
void OnLeave();
|
||||
|
||||
private:
|
||||
ScintillaWX* swx;
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class ScintillaWX : public ScintillaBase {
|
||||
public:
|
||||
|
||||
ScintillaWX(wxStyledTextCtrl* win);
|
||||
~ScintillaWX();
|
||||
|
||||
// base class virtuals
|
||||
virtual void Initialise();
|
||||
virtual void Finalise();
|
||||
virtual void StartDrag();
|
||||
virtual void SetTicking(bool on);
|
||||
virtual void SetMouseCapture(bool on);
|
||||
virtual bool HaveMouseCapture();
|
||||
virtual void ScrollText(int linesToMove);
|
||||
virtual void SetVerticalScrollPos();
|
||||
virtual void SetHorizontalScrollPos();
|
||||
virtual bool ModifyScrollBars(int nMax, int nPage);
|
||||
virtual void Copy();
|
||||
virtual void Paste();
|
||||
virtual void CreateCallTipWindow(PRectangle rc);
|
||||
virtual void AddToPopUp(const char *label, int cmd = 0, bool enabled = true);
|
||||
virtual void ClaimSelection();
|
||||
|
||||
virtual long DefWndProc(unsigned int iMessage,
|
||||
unsigned long wParam,
|
||||
long lParam);
|
||||
virtual long WndProc(unsigned int iMessage,
|
||||
unsigned long wParam,
|
||||
long lParam);
|
||||
|
||||
virtual void NotifyChange();
|
||||
virtual void NotifyParent(SCNotification scn);
|
||||
|
||||
|
||||
// Event delegates
|
||||
void DoPaint(wxDC* dc, wxRect rect);
|
||||
void DoHScroll(int type, int pos);
|
||||
void DoVScroll(int type, int pos);
|
||||
void DoSize(int width, int height);
|
||||
void DoLoseFocus();
|
||||
void DoGainFocus();
|
||||
void DoSysColourChange();
|
||||
void DoButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
|
||||
void DoButtonUp(Point pt, unsigned int curTime, bool ctrl);
|
||||
void DoButtonMove(Point pt);
|
||||
void DoAddChar(char ch);
|
||||
int DoKeyDown(int key, bool shift, bool ctrl, bool alt);
|
||||
void DoTick() { Tick(); }
|
||||
|
||||
bool DoDropText(long x, long y, const wxString& data);
|
||||
wxDragResult DoDragEnter(wxCoord x, wxCoord y, wxDragResult def);
|
||||
wxDragResult DoDragOver(wxCoord x, wxCoord y, wxDragResult def);
|
||||
void DoDragLeave();
|
||||
|
||||
void DoCommand(int ID);
|
||||
void DoContextMenu(Point pt);
|
||||
void DoOnListBox();
|
||||
|
||||
|
||||
// helpers
|
||||
void FullPaint();
|
||||
bool CanPaste();
|
||||
bool GetHideSelection() { return hideSelection; }
|
||||
void DoScrollToLine(int line);
|
||||
void DoScrollToColumn(int column);
|
||||
|
||||
private:
|
||||
bool capturedMouse;
|
||||
wxStyledTextCtrl* stc;
|
||||
|
||||
wxSTCDropTarget* dropTarget;
|
||||
wxDragResult dragResult;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -1,250 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="StcVC" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 5.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=StcVC - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "StcVC.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "StcVC.mak" CFG="StcVC - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "StcVC - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "StcVC - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
|
||||
!IF "$(CFG)" == "StcVC - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
RSC=rc.exe
|
||||
# ADD BASE RSC /l 0x809
|
||||
# ADD RSC /l 0x809
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../../include" /I "../../include" /I "scintilla/include" /I "scintilla/src" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D "__WX__" /D "SCI_LEXER" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"..\..\lib\stc.lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "StcVC - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
RSC=rc.exe
|
||||
# ADD BASE RSC /l 0x809
|
||||
# ADD RSC /l 0x809
|
||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "../../../include" /I "../../include" /I "scintilla/include" /I "scintilla/src" /D "_DEBUG" /D DEBUG=1 /D "__WXDEBUG__" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D "__WX__" /D "SCI_LEXER" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"..\..\lib\stcd.lib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "StcVC - Win32 Release"
|
||||
# Name "StcVC - Win32 Debug"
|
||||
# Begin Group "Stc"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PlatWX.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScintillaWX.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScintillaWX.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\stc.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Scintilla"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\Accessor.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\AutoComplete.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\AutoComplete.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\CallTip.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\CallTip.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\CellBuffer.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\CellBuffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\ContractionState.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\ContractionState.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\Document.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\Document.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\Editor.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\Editor.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\Indicator.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\Indicator.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\KeyMap.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\KeyMap.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\KeyWords.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexCPP.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexHTML.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexOthers.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexPerl.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexPython.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexSQL.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexVB.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LineMarker.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LineMarker.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\PropSet.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\ScintillaBase.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\ScintillaBase.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\Style.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\Style.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\SVector.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\ViewStyle.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\ViewStyle.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -1,29 +0,0 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "StcVC"=.\StcVC.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -1,684 +0,0 @@
|
||||
#!/bin/env python
|
||||
#----------------------------------------------------------------------------
|
||||
# Name: gen_iface.py
|
||||
# Purpose: Generate stc.h and stc.cpp from the info in Scintilla.iface
|
||||
#
|
||||
# Author: Robin Dunn
|
||||
#
|
||||
# Created: 5-Sept-2000
|
||||
# RCS-ID: $Id$
|
||||
# Copyright: (c) 2000 by Total Control Software
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
import sys, string, re
|
||||
from fileinput import FileInput
|
||||
|
||||
|
||||
IFACE = './scintilla/include/Scintilla.iface'
|
||||
H_TEMPLATE = './stc.h.in'
|
||||
CPP_TEMPLATE = './stc.cpp.in'
|
||||
H_DEST = '../../include/wx/stc/stc.h' # './stc_test.h' #
|
||||
CPP_DEST = './stc.cpp' #'./stc_test.cpp'
|
||||
|
||||
|
||||
# Value prefixes to convert
|
||||
valPrefixes = [('SCI_', ''),
|
||||
('SC_', ''),
|
||||
('SCN_', None), # just toss these...
|
||||
('SCEN_', None),
|
||||
('SCE_', ''),
|
||||
('SCLEX_', 'LEX_'),
|
||||
('SCK_', 'KEY_'),
|
||||
('SCFIND_', 'FIND_'),
|
||||
('SCWS_', 'WS_'),
|
||||
]
|
||||
|
||||
# Message funcion values that should have a CMD_ constant as well
|
||||
cmdValues = [ (2300, 2350), 2011, 2013, (2176, 2180) ]
|
||||
|
||||
|
||||
# Map some generic typenames to wx types, using return value syntax
|
||||
retTypeMap = {
|
||||
'position': 'int',
|
||||
'string': 'wxString',
|
||||
'colour': 'wxColour',
|
||||
}
|
||||
|
||||
# Map some generic typenames to wx types, using parameter syntax
|
||||
paramTypeMap = {
|
||||
'position': 'int',
|
||||
'string': 'const wxString&',
|
||||
'colour': 'const wxColour&',
|
||||
'keymod': 'int',
|
||||
}
|
||||
|
||||
# Map of method info that needs tweaked. Either the name needs changed, or
|
||||
# the method definition/implementation. Tuple items are:
|
||||
#
|
||||
# 1. New method name. None to skip the method, 0 to leave the
|
||||
# default name.
|
||||
# 2. Method definition for the .h file, 0 to leave alone
|
||||
# 3. Method implementation for the .cpp file, 0 to leave alone.
|
||||
# 4. tuple of Doc string lines, or 0 to leave alone.
|
||||
#
|
||||
methodOverrideMap = {
|
||||
'AddText' : (0,
|
||||
'void %s(const wxString& text);',
|
||||
|
||||
'''void %s(const wxString& text) {
|
||||
SendMsg(%s, text.Len(), (long)text.c_str());''',
|
||||
0),
|
||||
|
||||
'AddStyledText' : (0,
|
||||
'void %s(const wxString& text);',
|
||||
|
||||
'''void %s(const wxString& text) {
|
||||
SendMsg(%s, text.Len(), (long)text.c_str());''',
|
||||
0),
|
||||
|
||||
'GetViewWS' : ( 'GetViewWhiteSpace', 0, 0, 0),
|
||||
'SetViewWS' : ( 'SetViewWhiteSpace', 0, 0, 0),
|
||||
|
||||
'GetStyledText' : (0,
|
||||
'wxString %s(int startPos, int endPos);',
|
||||
|
||||
'''wxString %s(int startPos, int endPos) {
|
||||
wxString text;
|
||||
int len = endPos - startPos;
|
||||
TextRange tr;
|
||||
tr.lpstrText = text.GetWriteBuf(len*2+1);
|
||||
tr.chrg.cpMin = startPos;
|
||||
tr.chrg.cpMax = endPos;
|
||||
SendMsg(%s, 0, (long)&tr);
|
||||
text.UngetWriteBuf(len*2);
|
||||
return text;''',
|
||||
|
||||
('Retrieve a buffer of cells.',)),
|
||||
|
||||
|
||||
'PositionFromPoint' : (0,
|
||||
'int %s(wxPoint pt);',
|
||||
|
||||
'''int %s(wxPoint pt) {
|
||||
return SendMsg(%s, pt.x, pt.y);''',
|
||||
|
||||
0),
|
||||
|
||||
'GetCurLine' : (0,
|
||||
'wxString %s(int* OUTPUT=NULL);',
|
||||
|
||||
'''wxString %s(int* linePos) {
|
||||
wxString text;
|
||||
int len = LineLength(GetCurrentLine());
|
||||
char* buf = text.GetWriteBuf(len+1);
|
||||
|
||||
int pos = SendMsg(%s, len, (long)buf);
|
||||
text.UngetWriteBuf();
|
||||
if (linePos) *linePos = pos;
|
||||
|
||||
return text;''',
|
||||
|
||||
0),
|
||||
|
||||
'SetUsePalette' : (None, 0,0,0),
|
||||
|
||||
'MarkerSetFore' : ('MarkerSetForeground', 0, 0, 0),
|
||||
'MarkerSetBack' : ('MarkerSetBackground', 0, 0, 0),
|
||||
|
||||
'MarkerDefine' : (0,
|
||||
'''void %s(int markerNumber, int markerSymbol,
|
||||
const wxColour& foreground = wxNullColour,
|
||||
const wxColour& background = wxNullColour);''',
|
||||
|
||||
'''void %s(int markerNumber, int markerSymbol,
|
||||
const wxColour& foreground,
|
||||
const wxColour& background) {
|
||||
|
||||
SendMsg(%s, markerNumber, markerSymbol);
|
||||
if (foreground.Ok())
|
||||
MarkerSetForeground(markerNumber, foreground);
|
||||
if (background.Ok())
|
||||
MarkerSetBackground(markerNumber, background);''',
|
||||
|
||||
('Set the symbol used for a particular marker number,',
|
||||
'and optionally the for and background colours.')),
|
||||
|
||||
'SetMarginTypeN' : ('SetMarginType', 0, 0, 0),
|
||||
'GetMarginTypeN' : ('GetMarginType', 0, 0, 0),
|
||||
'SetMarginWidthN' : ('SetMarginWidth', 0, 0, 0),
|
||||
'GetMarginWidthN' : ('GetMarginWidth', 0, 0, 0),
|
||||
'SetMarginMaskN' : ('SetMarginMask', 0, 0, 0),
|
||||
'GetMarginMaskN' : ('GetMarginMask', 0, 0, 0),
|
||||
'SetMarginSensitiveN' : ('SetMarginSensitive', 0, 0, 0),
|
||||
'GetMarginSensitiveN' : ('GetMarginSensitive', 0, 0, 0),
|
||||
|
||||
'StyleSetFore' : ('StyleSetForeground', 0, 0, 0),
|
||||
'StyleSetBack' : ('StyleSetBackground', 0, 0, 0),
|
||||
'SetSelFore' : ('SetSelForeground', 0, 0, 0),
|
||||
'SetSelBack' : ('SetSelBackground', 0, 0, 0),
|
||||
'SetCaretFore' : ('SetCaretForeground', 0, 0, 0),
|
||||
'StyleSetFont' : ('StyleSetFaceName', 0, 0, 0),
|
||||
|
||||
# need to fix this to map between wx and scintilla encoding flags, leave it out for now...
|
||||
'StyleSetCharacterSet' : (None, 0, 0, 0),
|
||||
|
||||
'AssignCmdKey' : ('CmdKeyAssign',
|
||||
'void %s(int key, int modifiers, int cmd);',
|
||||
|
||||
'''void %s(int key, int modifiers, int cmd) {
|
||||
SendMsg(%s, MAKELONG(key, modifiers), cmd);''',
|
||||
|
||||
0),
|
||||
|
||||
'ClearCmdKey' : ('CmdKeyClear',
|
||||
'void %s(int key, int modifiers);',
|
||||
|
||||
'''void %s(int key, int modifiers) {
|
||||
SendMsg(%s, MAKELONG(key, modifiers));''',
|
||||
|
||||
0),
|
||||
|
||||
'ClearAllCmdKeys' : ('CmdKeyClearAll', 0, 0, 0),
|
||||
|
||||
|
||||
'SetStylingEx' : ('SetStyleBytes',
|
||||
'void %s(int length, char* styleBytes);',
|
||||
|
||||
'''void %s(int length, char* styleBytes) {
|
||||
SendMsg(%s, length, (long)styleBytes);''',
|
||||
|
||||
0),
|
||||
|
||||
|
||||
'IndicSetStyle' : ('IndicatorSetStyle', 0, 0, 0),
|
||||
'IndicGetStyle' : ('IndicatorGetStyle', 0, 0, 0),
|
||||
'IndicSetFore' : ('IndicatorSetForeground', 0, 0, 0),
|
||||
'IndicGetFore' : ('IndicatorGetForeground', 0, 0, 0),
|
||||
|
||||
'AutoCShow' : ('AutoCompShow', 0, 0, 0),
|
||||
'AutoCCancel' : ('AutoCompCancel', 0, 0, 0),
|
||||
'AutoCActive' : ('AutoCompActive', 0, 0, 0),
|
||||
'AutoCPosStart' : ('AutoCompPosStart', 0, 0, 0),
|
||||
'AutoCComplete' : ('AutoCompComplete', 0, 0, 0),
|
||||
'AutoCStops' : ('AutoCompStops', 0, 0, 0),
|
||||
'AutoCSetSeparator' : ('AutoCompSetSeparator', 0, 0, 0),
|
||||
'AutoCGetSeparator' : ('AutoCompGetSeparator', 0, 0, 0),
|
||||
'AutoCSelect' : ('AutoCompSelect', 0, 0, 0),
|
||||
'AutoCSetCancelAtStart' : ('AutoCompSetCancelAtStart', 0, 0, 0),
|
||||
'AutoCGetCancelAtStart' : ('AutoCompGetCancelAtStart', 0, 0, 0),
|
||||
'AutoCSetFillUps' : ('AutoCompSetFillUps', 0, 0, 0),
|
||||
'AutoCSetChooseSingle' : ('AutoCompSetChooseSingle', 0, 0, 0),
|
||||
'AutoCGetChooseSingle' : ('AutoCompGetChooseSingle', 0, 0, 0),
|
||||
'AutoCSetIgnoreCase' : ('AutoCompSetIgnoreCase', 0, 0, 0),
|
||||
'AutoCGetIgnoreCase' : ('AutoCompGetIgnoreCase', 0, 0, 0),
|
||||
|
||||
'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0, 0),
|
||||
'GetHScrollBar' : ('GetUseHorizontalScrollBar', 0, 0, 0),
|
||||
|
||||
'GetCaretFore' : ('GetCaretForeground', 0, 0, 0),
|
||||
|
||||
'GetUsePalette' : (None, 0, 0, 0),
|
||||
|
||||
'FindText' : (0,
|
||||
'''int %s(int minPos, int maxPos,
|
||||
const wxString& text,
|
||||
bool caseSensitive, bool wholeWord);''',
|
||||
'''int %s(int minPos, int maxPos,
|
||||
const wxString& text,
|
||||
bool caseSensitive, bool wholeWord) {
|
||||
TextToFind ft;
|
||||
int flags = 0;
|
||||
|
||||
flags |= caseSensitive ? SCFIND_MATCHCASE : 0;
|
||||
flags |= wholeWord ? SCFIND_WHOLEWORD : 0;
|
||||
ft.chrg.cpMin = minPos;
|
||||
ft.chrg.cpMax = maxPos;
|
||||
ft.lpstrText = (char*)text.c_str();
|
||||
|
||||
return SendMsg(%s, flags, (long)&ft);''',
|
||||
0),
|
||||
|
||||
'FormatRange' : (0,
|
||||
'''int %s(bool doDraw,
|
||||
int startPos,
|
||||
int endPos,
|
||||
wxDC* draw,
|
||||
wxDC* target, // Why does it use two? Can they be the same?
|
||||
wxRect renderRect,
|
||||
wxRect pageRect);''',
|
||||
''' int %s(bool doDraw,
|
||||
int startPos,
|
||||
int endPos,
|
||||
wxDC* draw,
|
||||
wxDC* target, // Why does it use two? Can they be the same?
|
||||
wxRect renderRect,
|
||||
wxRect pageRect) {
|
||||
RangeToFormat fr;
|
||||
|
||||
fr.hdc = draw;
|
||||
fr.hdcTarget = target;
|
||||
fr.rc.top = renderRect.GetTop();
|
||||
fr.rc.left = renderRect.GetLeft();
|
||||
fr.rc.right = renderRect.GetRight();
|
||||
fr.rc.bottom = renderRect.GetBottom();
|
||||
fr.rcPage.top = pageRect.GetTop();
|
||||
fr.rcPage.left = pageRect.GetLeft();
|
||||
fr.rcPage.right = pageRect.GetRight();
|
||||
fr.rcPage.bottom = pageRect.GetBottom();
|
||||
fr.chrg.cpMin = startPos;
|
||||
fr.chrg.cpMax = endPos;
|
||||
|
||||
return SendMsg(%s, doDraw, (long)&fr);''',
|
||||
0),
|
||||
|
||||
|
||||
'GetLine' : (0,
|
||||
'wxString %s(int line);',
|
||||
|
||||
'''wxString %s(int line) {
|
||||
wxString text;
|
||||
int len = LineLength(line);
|
||||
char* buf = text.GetWriteBuf(len+1);
|
||||
|
||||
int pos = SendMsg(%s, line, (long)buf);
|
||||
text.UngetWriteBuf();
|
||||
|
||||
return text;''',
|
||||
|
||||
('Retrieve the contents of a line.',)),
|
||||
|
||||
'SetSel' : ('SetSelection', 0, 0, 0),
|
||||
'GetSelText' : ('GetSelectedText',
|
||||
'wxString %s();',
|
||||
|
||||
'''wxString %s() {
|
||||
wxString text;
|
||||
int start;
|
||||
int end;
|
||||
|
||||
GetSelection(&start, &end);
|
||||
int len = end - start;
|
||||
char* buff = text.GetWriteBuf(len+1);
|
||||
|
||||
SendMsg(%s, 0, (long)buff);
|
||||
text.UngetWriteBuf();
|
||||
return text;''',
|
||||
|
||||
('Retrieve the selected text.',)),
|
||||
|
||||
'GetTextRange' : (0,
|
||||
'wxString %s(int startPos, int endPos);',
|
||||
|
||||
'''wxString %s(int startPos, int endPos) {
|
||||
wxString text;
|
||||
int len = endPos - startPos;
|
||||
char* buff = text.GetWriteBuf(len+1);
|
||||
TextRange tr;
|
||||
tr.lpstrText = buff;
|
||||
tr.chrg.cpMin = startPos;
|
||||
tr.chrg.cpMax = endPos;
|
||||
|
||||
SendMsg(%s, 0, (long)&tr);
|
||||
text.UngetWriteBuf();
|
||||
return text;''',
|
||||
|
||||
('Retrieve a range of text.',)),
|
||||
|
||||
'PointXFromPosition' : (None, 0, 0, 0),
|
||||
'PointYFromPosition' : (None, 0, 0, 0),
|
||||
|
||||
'ScrollCaret' : ('EnsureCaretVisible', 0, 0, 0),
|
||||
'ReplaceSel' : ('ReplaceSelection', 0, 0, 0),
|
||||
'Null' : (None, 0, 0, 0),
|
||||
|
||||
'GetText' : (0,
|
||||
'wxString %s();',
|
||||
|
||||
'''wxString %s() {
|
||||
wxString text;
|
||||
int len = GetTextLength();
|
||||
char* buff = text.GetWriteBuf(len+1);
|
||||
|
||||
SendMsg(%s, len, (long)buff);
|
||||
buff[len] = 0;
|
||||
text.UngetWriteBuf();
|
||||
return text;''',
|
||||
|
||||
('Retrieve all the text in the document.', )),
|
||||
|
||||
'GetDirectFunction' : (None, 0, 0, 0),
|
||||
'GetDirectPointer' : (None, 0, 0, 0),
|
||||
|
||||
'CallTipPosStart' : ('CallTipPosAtStart', 0, 0, 0),
|
||||
'CallTipSetHlt' : ('CallTipSetHighlight', 0, 0, 0),
|
||||
'CallTipSetBack' : ('CallTipSetBackground', 0, 0, 0),
|
||||
|
||||
|
||||
# Remove all methods that are key commands since they can be
|
||||
# executed with CmdKeyExecute
|
||||
'LineDown' : (None, 0, 0, 0),
|
||||
'LineDownExtend' : (None, 0, 0, 0),
|
||||
'LineUp' : (None, 0, 0, 0),
|
||||
'LineUpExtend' : (None, 0, 0, 0),
|
||||
'CharLeft' : (None, 0, 0, 0),
|
||||
'CharLeftExtend' : (None, 0, 0, 0),
|
||||
'CharRight' : (None, 0, 0, 0),
|
||||
'CharRightExtend' : (None, 0, 0, 0),
|
||||
'WordLeft' : (None, 0, 0, 0),
|
||||
'WordLeftExtend' : (None, 0, 0, 0),
|
||||
'WordRight' : (None, 0, 0, 0),
|
||||
'WordRightExtend' : (None, 0, 0, 0),
|
||||
'Home' : (None, 0, 0, 0),
|
||||
'HomeExtend' : (None, 0, 0, 0),
|
||||
'LineEnd' : (None, 0, 0, 0),
|
||||
'LineEndExtend' : (None, 0, 0, 0),
|
||||
'DocumentStart' : (None, 0, 0, 0),
|
||||
'DocumentStartExtend' : (None, 0, 0, 0),
|
||||
'DocumentEnd' : (None, 0, 0, 0),
|
||||
'DocumentEndExtend' : (None, 0, 0, 0),
|
||||
'PageUp' : (None, 0, 0, 0),
|
||||
'PageUpExtend' : (None, 0, 0, 0),
|
||||
'PageDown' : (None, 0, 0, 0),
|
||||
'PageDownExtend' : (None, 0, 0, 0),
|
||||
'EditToggleOvertype' : (None, 0, 0, 0),
|
||||
'Cancel' : (None, 0, 0, 0),
|
||||
'DeleteBack' : (None, 0, 0, 0),
|
||||
'Tab' : (None, 0, 0, 0),
|
||||
'BackTab' : (None, 0, 0, 0),
|
||||
'NewLine' : (None, 0, 0, 0),
|
||||
'FormFeed' : (None, 0, 0, 0),
|
||||
'VCHome' : (None, 0, 0, 0),
|
||||
'VCHomeExtend' : (None, 0, 0, 0),
|
||||
'ZoomIn' : (None, 0, 0, 0),
|
||||
'ZoomOut' : (None, 0, 0, 0),
|
||||
'DelWordLeft' : (None, 0, 0, 0),
|
||||
'DelWordRight' : (None, 0, 0, 0),
|
||||
'LineCut' : (None, 0, 0, 0),
|
||||
'LineDelete' : (None, 0, 0, 0),
|
||||
'LineTranspose' : (None, 0, 0, 0),
|
||||
'LowerCase' : (None, 0, 0, 0),
|
||||
'UpperCase' : (None, 0, 0, 0),
|
||||
'LineScrollDown' : (None, 0, 0, 0),
|
||||
'LineScrollUp' : (None, 0, 0, 0),
|
||||
|
||||
|
||||
'GetDocPointer' : (0,
|
||||
'void* %s();',
|
||||
'''void* %s() {
|
||||
return (void*)SendMsg(%s);''',
|
||||
0),
|
||||
|
||||
'SetDocPointer' : (0,
|
||||
'void %s(void* docPointer);',
|
||||
'''void %s(void* docPointer) {
|
||||
SendMsg(%s, (long)docPointer);''',
|
||||
0),
|
||||
|
||||
'CreateDocument' : (0,
|
||||
'void* %s();',
|
||||
'''void* %s() {
|
||||
return (void*)SendMsg(%s);''',
|
||||
0),
|
||||
|
||||
'AddRefDocument' : (0,
|
||||
'void %s(void* docPointer);',
|
||||
'''void %s(void* docPointer) {
|
||||
SendMsg(%s, (long)docPointer);''',
|
||||
0),
|
||||
|
||||
'ReleaseDocument' : (0,
|
||||
'void %s(void* docPointer);',
|
||||
'''void %s(void* docPointer) {
|
||||
SendMsg(%s, (long)docPointer);''',
|
||||
0),
|
||||
|
||||
'GrabFocus' : (None, 0, 0, 0),
|
||||
|
||||
'' : ('', 0, 0, 0),
|
||||
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
def processIface(iface, h_tmplt, cpp_tmplt, h_dest, cpp_dest):
|
||||
curDocStrings = []
|
||||
values = []
|
||||
methods = []
|
||||
|
||||
# parse iface file
|
||||
fi = FileInput(iface)
|
||||
for line in fi:
|
||||
line = line[:-1]
|
||||
if line[:2] == '##' or line == '':
|
||||
#curDocStrings = []
|
||||
continue
|
||||
|
||||
op = line[:4]
|
||||
if line[:2] == '# ': # a doc string
|
||||
curDocStrings.append(line[2:])
|
||||
|
||||
elif op == 'val ':
|
||||
parseVal(line[4:], values, curDocStrings)
|
||||
curDocStrings = []
|
||||
|
||||
elif op == 'fun ' or op == 'set ' or op == 'get ':
|
||||
parseFun(line[4:], methods, curDocStrings, values)
|
||||
curDocStrings = []
|
||||
|
||||
elif op == 'cat ':
|
||||
if string.strip(line[4:]) == 'Deprecated':
|
||||
break # skip the rest of the file
|
||||
|
||||
elif op == 'evt ':
|
||||
pass
|
||||
|
||||
else:
|
||||
print '***** Unknown line type: ', line
|
||||
|
||||
|
||||
# process templates
|
||||
data = {}
|
||||
data['VALUES'] = processVals(values)
|
||||
defs, imps = processMethods(methods)
|
||||
data['METHOD_DEFS'] = defs
|
||||
data['METHOD_IMPS'] = imps
|
||||
|
||||
# get template text
|
||||
h_text = open(h_tmplt).read()
|
||||
cpp_text = open(cpp_tmplt).read()
|
||||
|
||||
# do the substitutions
|
||||
h_text = h_text % data
|
||||
cpp_text = cpp_text % data
|
||||
|
||||
# write out destination files
|
||||
open(h_dest, 'w').write(h_text)
|
||||
open(cpp_dest, 'w').write(cpp_text)
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
def processVals(values):
|
||||
text = []
|
||||
for name, value, docs in values:
|
||||
if docs:
|
||||
text.append('')
|
||||
for x in docs:
|
||||
text.append('// ' + x)
|
||||
text.append('#define %s %s' % (name, value))
|
||||
return string.join(text, '\n')
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
def processMethods(methods):
|
||||
defs = []
|
||||
imps = []
|
||||
|
||||
for retType, name, number, param1, param2, docs in methods:
|
||||
retType = retTypeMap.get(retType, retType)
|
||||
params = makeParamString(param1, param2)
|
||||
|
||||
name, theDef, theImp, docs = checkMethodOverride(name, number, docs)
|
||||
|
||||
if name is None:
|
||||
continue
|
||||
|
||||
# Build the method definition for the .h file
|
||||
if docs:
|
||||
defs.append('')
|
||||
for x in docs:
|
||||
defs.append(' // ' + x)
|
||||
if not theDef:
|
||||
theDef = ' %s %s(%s);' % (retType, name, params)
|
||||
defs.append(theDef)
|
||||
|
||||
# Build the method implementation string
|
||||
if docs:
|
||||
imps.append('')
|
||||
for x in docs:
|
||||
imps.append('// ' + x)
|
||||
if not theImp:
|
||||
theImp = '%s wxStyledTextCtrl::%s(%s) {\n ' % (retType, name, params)
|
||||
|
||||
if retType == 'wxColour':
|
||||
theImp = theImp + 'long c = '
|
||||
elif retType != 'void':
|
||||
theImp = theImp + 'return '
|
||||
theImp = theImp + 'SendMsg(%s, %s, %s)' % (number,
|
||||
makeArgString(param1),
|
||||
makeArgString(param2))
|
||||
if retType == 'bool':
|
||||
theImp = theImp + ' != 0'
|
||||
if retType == 'wxColour':
|
||||
theImp = theImp + ';\n return wxColourFromLong(c)'
|
||||
|
||||
theImp = theImp + ';\n}'
|
||||
imps.append(theImp)
|
||||
|
||||
|
||||
return string.join(defs, '\n'), string.join(imps, '\n')
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
def checkMethodOverride(name, number, docs):
|
||||
theDef = theImp = None
|
||||
if methodOverrideMap.has_key(name):
|
||||
item = methodOverrideMap[name]
|
||||
|
||||
if item[0] != 0:
|
||||
name = item[0]
|
||||
if item[1] != 0:
|
||||
theDef = ' ' + (item[1] % name)
|
||||
if item[2] != 0:
|
||||
theImp = item[2] % ('wxStyledTextCtrl::'+name, number) + '\n}'
|
||||
if item[3] != 0:
|
||||
docs = item[3]
|
||||
|
||||
return name, theDef, theImp, docs
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
def makeArgString(param):
|
||||
if not param:
|
||||
return '0'
|
||||
|
||||
typ, name = param
|
||||
|
||||
if typ == 'string':
|
||||
return '(long)%s.c_str()' % name
|
||||
if typ == 'colour':
|
||||
return 'wxColourAsLong(%s)' % name
|
||||
|
||||
return name
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
def makeParamString(param1, param2):
|
||||
def doOne(param):
|
||||
if param:
|
||||
aType = paramTypeMap.get(param[0], param[0])
|
||||
return aType + ' ' + param[1]
|
||||
else:
|
||||
return ''
|
||||
|
||||
st = doOne(param1)
|
||||
if st and param2:
|
||||
st = st + ', '
|
||||
st = st + doOne(param2)
|
||||
return st
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
def parseVal(line, values, docs):
|
||||
name, val = string.split(line, '=')
|
||||
|
||||
# remove prefixes such as SCI, etc.
|
||||
for old, new in valPrefixes:
|
||||
lo = len(old)
|
||||
if name[:lo] == old:
|
||||
if new is None:
|
||||
return
|
||||
name = new + name[lo:]
|
||||
|
||||
# add it to the list
|
||||
values.append( ('wxSTC_' + name, val, docs) )
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
funregex = re.compile(r'\s*([a-zA-Z0-9_]+)' # <ws>return type
|
||||
'\s+([a-zA-Z0-9_]+)=' # <ws>name=
|
||||
'([0-9]+)' # number
|
||||
'\(([ a-zA-Z0-9_]*),' # (param,
|
||||
'([ a-zA-Z0-9_]*)\)') # param)
|
||||
|
||||
def parseFun(line, methods, docs, values):
|
||||
def parseParam(param):
|
||||
param = string.strip(param)
|
||||
if param == '':
|
||||
param = None
|
||||
else:
|
||||
param = tuple(string.split(param))
|
||||
return param
|
||||
|
||||
mo = funregex.match(line)
|
||||
if mo is None:
|
||||
print "***** Line doesn't match! : " + line
|
||||
|
||||
retType, name, number, param1, param2 = mo.groups()
|
||||
|
||||
param1 = parseParam(param1)
|
||||
param2 = parseParam(param2)
|
||||
|
||||
# Special case. For the key command functionss we want a value defined too
|
||||
num = string.atoi(number)
|
||||
for v in cmdValues:
|
||||
if (type(v) == type(()) and v[0] <= num < v[1]) or v == num:
|
||||
parseVal('CMD_%s=%s' % (string.upper(name), number), values, ())
|
||||
|
||||
#if retType == 'void' and not param1 and not param2:
|
||||
|
||||
methods.append( (retType, name, number, param1, param2, tuple(docs)) )
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
def main(args):
|
||||
# TODO: parse command line args to replace default input/output files???
|
||||
|
||||
# Now just do it
|
||||
processIface(IFACE, H_TEMPLATE, CPP_TEMPLATE, H_DEST, CPP_DEST)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv)
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
#
|
||||
# File: makefile.b32
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright:
|
||||
#
|
||||
# Makefile : Builds wxMMedia library for 32-bit BC++
|
||||
|
||||
# N.B. use:
|
||||
# make -f makefile.b32 stc.cfg
|
||||
# make -f makefile.b32
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
SCINTILLA=.\scintilla
|
||||
S=$(SCINTILLA)\src
|
||||
|
||||
STCEXTRACPPFLAGS=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S)
|
||||
|
||||
LIBTARGET=$(WXDIR)\contrib\lib\stc.lib
|
||||
|
||||
OBJECTS = \
|
||||
Accessor.obj \
|
||||
AutoComplete.obj \
|
||||
CallTip.obj \
|
||||
CellBuffer.obj \
|
||||
ContractionState.obj \
|
||||
Document.obj \
|
||||
DocumentAccessor.obj \
|
||||
Editor.obj \
|
||||
Indicator.obj \
|
||||
KeyMap.obj \
|
||||
KeyWords.obj \
|
||||
LexCPP.obj \
|
||||
LexHTML.obj \
|
||||
LexLua.obj \
|
||||
LexOthers.obj \
|
||||
LexPerl.obj \
|
||||
LexPython.obj \
|
||||
LexSQL.obj \
|
||||
LexVB.obj \
|
||||
LineMarker.obj \
|
||||
PropSet.obj \
|
||||
PosRegExp.obj \
|
||||
ScintillaBase.obj \
|
||||
Style.obj \
|
||||
UniConversion.obj \
|
||||
ViewStyle.obj \
|
||||
WindowAccessor.obj \
|
||||
\
|
||||
PlatWX.obj \
|
||||
ScintillaWX.obj \
|
||||
stc.obj \
|
||||
|
||||
|
||||
!include $(WXDIR)\src\makelib.b32
|
||||
|
||||
CFG = stc.cfg
|
||||
CPPFLAGS=$(DLL_FLAGS) $(EXTRACPPFLAGS) @$(CFG)
|
||||
|
||||
{$(S)}.cxx.obj:
|
||||
bcc32 $(CPPFLAGS) -P -c {$< }
|
||||
|
||||
$(CFG): makefile.b32
|
||||
copy &&!
|
||||
-H=$(WXDIR)\src\msw\wx32.csm
|
||||
-3
|
||||
-d
|
||||
-a1 # byte alignment
|
||||
-R-
|
||||
-X
|
||||
-w-par
|
||||
-w-aus
|
||||
-w-hid # virtual function A hides virtual function B
|
||||
-WE
|
||||
-tWM
|
||||
|
||||
-I$(WXINC);$(BCCDIR)\include;$(WXDIR)/src/generic;$(WXDIR)/src/png;$(WXDIR)/src/jpeg;$(WXDIR)/src/zlib;$(WXDIR)/src/xpm;$(WXDIR)/src/tiff
|
||||
-I$(WXDIR)\include\wx\msw\gnuwin32
|
||||
|
||||
-L$(BCCDIR)\lib
|
||||
-D__WXWIN__
|
||||
-D__WXMSW__
|
||||
-D__WINDOWS__
|
||||
-DWIN32
|
||||
$(OPT)
|
||||
$(DEBUG_FLAGS)
|
||||
$(WIN95FLAG)
|
||||
$(STCEXTRACPPFLAGS)
|
||||
! $(CFG)
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
# File: makefile.g95 For stectrl
|
||||
# Author: Robin Dunn
|
||||
# Created: 1-Feb-2000
|
||||
# Updated:
|
||||
|
||||
WXDIR = ../../..
|
||||
|
||||
SCINTILLA=$(WXDIR)/contrib/src/stc/scintilla
|
||||
S=$(SCINTILLA)/src
|
||||
EXTRAINC=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)/contrib/include
|
||||
|
||||
OBJECTS = \
|
||||
$(S)/Accessor.$(OBJSUFF) \
|
||||
$(S)/AutoComplete.$(OBJSUFF) \
|
||||
$(S)/CallTip.$(OBJSUFF) \
|
||||
$(S)/CellBuffer.$(OBJSUFF) \
|
||||
$(S)/ContractionState.$(OBJSUFF)\
|
||||
$(S)/Document.$(OBJSUFF) \
|
||||
$(S)/Editor.$(OBJSUFF) \
|
||||
$(S)/Indicator.$(OBJSUFF) \
|
||||
$(S)/KeyMap.$(OBJSUFF) \
|
||||
$(S)/KeyWords.$(OBJSUFF) \
|
||||
$(S)/LineMarker.$(OBJSUFF) \
|
||||
$(S)/PropSet.$(OBJSUFF) \
|
||||
$(S)/ScintillaBase.$(OBJSUFF) \
|
||||
$(S)/Style.$(OBJSUFF) \
|
||||
$(S)/ViewStyle.$(OBJSUFF) \
|
||||
$(S)/LexCPP.$(OBJSUFF) \
|
||||
$(S)/LexHTML.$(OBJSUFF) \
|
||||
$(S)/LexLua.$(OBJSUFF) \
|
||||
$(S)/LexOthers.$(OBJSUFF) \
|
||||
$(S)/LexPerl.$(OBJSUFF) \
|
||||
$(S)/LexPython.$(OBJSUFF) \
|
||||
$(S)/LexSQL.$(OBJSUFF) \
|
||||
$(S)/LexVB.$(OBJSUFF) \
|
||||
$(S)/DocumentAccessor.$(OBJSUFF)\
|
||||
$(S)/UniConversion.$(OBJSUFF) \
|
||||
$(S)/WindowAccessor.$(OBJSUFF) \
|
||||
$(S)/PosRegExp.$(OBJSUFF) \
|
||||
PlatWX.$(OBJSUFF) \
|
||||
ScintillaWX.$(OBJSUFF) \
|
||||
stc.$(OBJSUFF)
|
||||
|
||||
LIBTARGET = $(WXDIR)/contrib/lib/libstc.a
|
||||
|
||||
include $(WXDIR)/src/makelib.g95
|
||||
@@ -1,105 +0,0 @@
|
||||
# File: makefile.vc For stectrl
|
||||
# Author: Robin Dunn
|
||||
# Created: 1-Feb-2000
|
||||
# Updated:
|
||||
|
||||
|
||||
|
||||
# Set WXDIR for your system
|
||||
WXDIR = $(WXWIN)
|
||||
SCINTILLA=.\scintilla
|
||||
S=$(SCINTILLA)\src
|
||||
EXTRAINC=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)\contrib\include
|
||||
NOPCH=1
|
||||
|
||||
!include $(WXDIR)\src\makevc.env
|
||||
|
||||
OBJECTS = \
|
||||
$(D)\AutoComplete.obj \
|
||||
$(D)\CallTip.obj \
|
||||
$(D)\CellBuffer.obj \
|
||||
$(D)\ContractionState.obj\
|
||||
$(D)\Document.obj \
|
||||
$(D)\DocumentAccessor.obj\
|
||||
$(D)\Editor.obj \
|
||||
$(D)\Indicator.obj \
|
||||
$(D)\KeyMap.obj \
|
||||
$(D)\KeyWords.obj \
|
||||
$(D)\LexCPP.obj \
|
||||
$(D)\LexHTML.obj \
|
||||
$(D)\LexLua.obj \
|
||||
$(D)\LexOthers.obj \
|
||||
$(D)\LexPerl.obj \
|
||||
$(D)\LexPython.obj \
|
||||
$(D)\LexSQL.obj \
|
||||
$(D)\LexVB.obj \
|
||||
$(D)\LineMarker.obj \
|
||||
$(D)\PosRegExp.obj \
|
||||
$(D)\PropSet.obj \
|
||||
$(D)\ScintillaBase.obj \
|
||||
$(D)\Style.obj \
|
||||
$(D)\UniConversion.obj \
|
||||
$(D)\ViewStyle.obj \
|
||||
$(D)\WindowAccessor.obj \
|
||||
\
|
||||
$(D)\PlatWX.obj \
|
||||
$(D)\ScintillaWX.obj \
|
||||
$(D)\stc.obj \
|
||||
|
||||
|
||||
|
||||
|
||||
LIBTARGET = $(WXDIR)\contrib\lib\stc$(LIBEXT).lib
|
||||
|
||||
all: $(D) $(LIBTARGET)
|
||||
|
||||
$(D) :
|
||||
mkdir $(D)
|
||||
|
||||
wx:
|
||||
cd $(WXDIR)\src\msw
|
||||
nmake -f makefile.vc FINAL=$(FINAL)
|
||||
cd $(THISDIR)
|
||||
|
||||
wxclean:
|
||||
cd $(WXDIR)\src\msw
|
||||
nmake -f makefile.vc clean
|
||||
cd $(THISDIR)
|
||||
|
||||
|
||||
|
||||
|
||||
$(LIBTARGET): $(OBJECTS)
|
||||
-erase $(LIBTARGET)
|
||||
$(implib) @<<
|
||||
-out:$(LIBTARGET)
|
||||
-machine:$(CPU)
|
||||
$(OBJECTS)
|
||||
<<
|
||||
|
||||
|
||||
|
||||
{$(S)}.cxx{$(D)}.obj:
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS) /c /Fo$@ /Tp $<
|
||||
<<
|
||||
|
||||
{}.cpp{$(D)}.obj:
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS) /c /Fo$@ /Tp $<
|
||||
<<
|
||||
|
||||
|
||||
show:
|
||||
@echo $(CPPFLAGS)
|
||||
|
||||
|
||||
clean:
|
||||
-erase $(D)\*.obj
|
||||
-erase *.sbr
|
||||
-erase *.exe
|
||||
-erase *.res
|
||||
-erase *.map
|
||||
-erase *.pdb
|
||||
-erase $(LIBTARGET)
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
This directory contains copies of the scintilla/src and
|
||||
scintilla/include directories from the Scintilla/SCiTE source
|
||||
distribution. All other code needed to implement Scintilla on top of
|
||||
wxWindows is located in the directory above this one.
|
||||
|
||||
The current version of the Scintilla code is 1.32
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
// SciTE - Scintilla based Text Editor
|
||||
// Accessor.h - rapid easy access to contents of a Scintilla
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
enum { wsSpace = 1, wsTab = 2, wsSpaceTab = 4, wsInconsistent=8};
|
||||
|
||||
class Accessor;
|
||||
|
||||
typedef bool (*PFNIsCommentLeader)(Accessor &styler, int pos, int len);
|
||||
|
||||
// Interface to data in a Scintilla
|
||||
class Accessor {
|
||||
protected:
|
||||
enum {extremePosition=0x7FFFFFFF};
|
||||
// bufferSize is a trade off between time taken to copy the characters and retrieval 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];
|
||||
int startPos;
|
||||
int endPos;
|
||||
int codePage;
|
||||
|
||||
virtual bool InternalIsLeadByte(char ch)=0;
|
||||
virtual void Fill(int position)=0;
|
||||
public:
|
||||
Accessor() : startPos(extremePosition), endPos(0), codePage(0) {}
|
||||
virtual ~Accessor() {}
|
||||
char operator[](int position) {
|
||||
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
|
||||
if (position < startPos || position >= endPos) {
|
||||
Fill(position);
|
||||
if (position < startPos || position >= endPos) {
|
||||
// Position is outside range of document
|
||||
return chDefault;
|
||||
}
|
||||
}
|
||||
return buf[position - startPos];
|
||||
}
|
||||
bool IsLeadByte(char ch) {
|
||||
return codePage && InternalIsLeadByte(ch);
|
||||
}
|
||||
void SetCodePage(int codePage_) { codePage = codePage_; }
|
||||
|
||||
virtual char StyleAt(int position)=0;
|
||||
virtual int GetLine(int position)=0;
|
||||
virtual int LineStart(int line)=0;
|
||||
virtual int LevelAt(int line)=0;
|
||||
virtual int Length()=0;
|
||||
virtual void Flush()=0;
|
||||
virtual int GetLineState(int line)=0;
|
||||
virtual int SetLineState(int line, int state)=0;
|
||||
virtual int GetPropertyInt(const char *key, int defaultValue=0)=0;
|
||||
|
||||
// Style setting
|
||||
virtual void StartAt(unsigned int start, char chMask=31)=0;
|
||||
virtual void SetFlags(char chFlags_, char chWhile_)=0;
|
||||
virtual unsigned int GetStartSegment()=0;
|
||||
virtual void StartSegment(unsigned int pos)=0;
|
||||
virtual void ColourTo(unsigned int pos, int chAttr)=0;
|
||||
virtual void SetLevel(int line, int level)=0;
|
||||
virtual int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0)=0;
|
||||
};
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
// SciTE - Scintilla based Text Editor
|
||||
// KeyWords.h - colourise for particular languages
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler);
|
||||
|
||||
class LexerModule {
|
||||
static LexerModule *base;
|
||||
LexerModule *next;
|
||||
int language;
|
||||
LexerFunction fn;
|
||||
public:
|
||||
LexerModule(int language_, LexerFunction fn_);
|
||||
static void Colourise(unsigned int startPos, int lengthDoc, int initStyle,
|
||||
int language, WordList *keywordlists[], Accessor &styler);
|
||||
};
|
||||
|
||||
inline bool iswordchar(char ch) {
|
||||
return isalnum(ch) || ch == '.' || ch == '_';
|
||||
}
|
||||
|
||||
inline bool iswordstart(char ch) {
|
||||
return isalnum(ch) || ch == '_';
|
||||
}
|
||||
|
||||
inline bool isoperator(char ch) {
|
||||
if (isalnum(ch))
|
||||
return false;
|
||||
// '.' left out as it is used to make up numbers
|
||||
if (ch == '%' || ch == '^' || ch == '&' || ch == '*' ||
|
||||
ch == '(' || ch == ')' || ch == '-' || ch == '+' ||
|
||||
ch == '=' || ch == '|' || ch == '{' || ch == '}' ||
|
||||
ch == '[' || ch == ']' || ch == ':' || ch == ';' ||
|
||||
ch == '<' || ch == '>' || ch == ',' || ch == '/' ||
|
||||
ch == '?' || ch == '!' || ch == '.' || ch == '~')
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,411 +0,0 @@
|
||||
// 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 <neilh@scintilla.org>
|
||||
// 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 <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#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 <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <richedit.h>
|
||||
#endif
|
||||
|
||||
#if PLAT_WX
|
||||
#include <wx/wx.h>
|
||||
#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
|
||||
|
||||
// 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 {
|
||||
protected:
|
||||
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();
|
||||
virtual ~Font();
|
||||
|
||||
virtual void Create(const char *faceName, int characterSet, int size, bool bold, bool italic);
|
||||
virtual 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:
|
||||
bool unicodeMode;
|
||||
#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();
|
||||
int DeviceHeightFont(int points);
|
||||
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);
|
||||
void FlushCachedState();
|
||||
|
||||
void SetUnicodeMode(bool unicodeMode_) {
|
||||
unicodeMode=unicodeMode_;
|
||||
}
|
||||
};
|
||||
|
||||
// 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) {}
|
||||
Window(const Window &source) : id(source.id) {}
|
||||
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);
|
||||
virtual 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
|
||||
int desiredVisibleRows;
|
||||
unsigned int maxItemCharacters;
|
||||
unsigned int aveCharWidth;
|
||||
public:
|
||||
ListBox();
|
||||
virtual ~ListBox();
|
||||
void Create(Window &parent, int ctrlID);
|
||||
virtual void SetFont(Font &font);
|
||||
void SetAverageCharWidth(int width);
|
||||
void SetVisibleRows(int rows);
|
||||
PRectangle GetDesiredRect();
|
||||
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);
|
||||
// Next three assume 16 bit shorts and 32 bit longs
|
||||
static long LongFromTwoShorts(short a,short b) {
|
||||
return (a) | ((b) << 16);
|
||||
}
|
||||
static short HighShortFromLong(long x) {
|
||||
return static_cast<short>(x >> 16);
|
||||
}
|
||||
static short LowShortFromLong(long x) {
|
||||
return static_cast<short>(x & 0xffff);
|
||||
}
|
||||
static void DebugPrintf(const char *format, ...);
|
||||
static int Clamp(int val, int minVal, int maxVal);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,138 +0,0 @@
|
||||
#ifndef POSREGEXP_H
|
||||
#define POSREGEXP_H
|
||||
|
||||
#define MatchesNum 0x10
|
||||
|
||||
enum EOps
|
||||
{
|
||||
ReBlockOps = 0x1000,
|
||||
ReMul, // *
|
||||
RePlus, // +
|
||||
ReQuest, // ?
|
||||
ReNGMul, // *?
|
||||
ReNGPlus, // +?
|
||||
ReNGQuest, // ??
|
||||
ReRangeN, // {n,}
|
||||
ReRangeNM, // {n,m}
|
||||
ReNGRangeN, // {n,}?
|
||||
ReNGRangeNM, // {n,m}?
|
||||
ReOr, // |
|
||||
ReBehind = 0x1100, // ?#n
|
||||
ReNBehind = 0x1200, // ?~n
|
||||
ReAhead = 0x1300, // ?=
|
||||
ReNAhead = 0x1400, // ?!
|
||||
|
||||
ReSymbolOps = 0x2000,
|
||||
ReEmpty,
|
||||
ReSymb, // a b \W \s ...
|
||||
ReEnum, // []
|
||||
ReNEnum, // [^]
|
||||
ReBrackets, // (...)
|
||||
ReBkTrace = 0x2100, // \yN
|
||||
ReBkBrack = 0x2200 // \N
|
||||
};
|
||||
|
||||
enum ESymbols
|
||||
{
|
||||
ReAnyChr = 0x4000, // .
|
||||
ReSoL, // ^
|
||||
ReEoL, // $
|
||||
ReDigit, // \d
|
||||
ReNDigit, // \D
|
||||
ReWordSymb, // \w
|
||||
ReNWordSymb, // \W
|
||||
ReWSpace, // \s
|
||||
ReNWSpace, // \S
|
||||
ReUCase, // \u
|
||||
ReNUCase , // \l
|
||||
ReWBound, // \b
|
||||
ReNWBound, // \B
|
||||
RePreNW, // \c
|
||||
ReStart, // \m
|
||||
ReEnd, // \M
|
||||
|
||||
ReChr = 0x0 // Char in Lower Byte
|
||||
};
|
||||
enum ETempSymb
|
||||
{
|
||||
ReTemp = 0x7000,
|
||||
ReLBrack, ReRBrack,
|
||||
ReEnumS, ReEnumE, ReNEnumS,
|
||||
ReRangeS, ReRangeE, ReNGRangeE, ReFrToEnum
|
||||
};
|
||||
|
||||
#define BackSlash '\\'
|
||||
|
||||
typedef union SCharData
|
||||
{
|
||||
int IArr[8];
|
||||
char CArr[32];
|
||||
void SetBit(unsigned char Bit);
|
||||
void ClearBit(unsigned char Bit);
|
||||
bool GetBit(unsigned char Bit);
|
||||
} *PCharData;
|
||||
|
||||
typedef struct SRegInfo
|
||||
{
|
||||
SRegInfo();
|
||||
~SRegInfo();
|
||||
|
||||
EOps Op;
|
||||
union{
|
||||
SRegInfo *Param;
|
||||
int Symb;
|
||||
PCharData ChrClass;
|
||||
}un;
|
||||
int s,e;
|
||||
SRegInfo *Parent;
|
||||
SRegInfo *Next;
|
||||
} *PRegInfo;
|
||||
|
||||
typedef struct SMatches
|
||||
{
|
||||
int s[MatchesNum];
|
||||
int e[MatchesNum];
|
||||
int CurMatch;
|
||||
} *PMatches;
|
||||
|
||||
typedef class PosRegExp
|
||||
{
|
||||
PRegInfo Info;
|
||||
PMatches BkTrace;
|
||||
bool NoCase,Extend,NoMoves;
|
||||
bool Error;
|
||||
int *Exprn;
|
||||
int posParse;
|
||||
int posEnd,posStart;
|
||||
int posBkStr;
|
||||
int FirstChar;
|
||||
|
||||
bool SetExprLow(const char *Expr);
|
||||
bool SetStructs(PRegInfo &Info,int st,int end);
|
||||
void Optimize();
|
||||
bool CheckSymb(int Symb,bool Inc);
|
||||
bool LowParse(PRegInfo Re);
|
||||
bool LowParseRe(PRegInfo &Next);
|
||||
bool LowCheckNext(PRegInfo Re);
|
||||
bool ParseRe(int posStr);
|
||||
bool QuickCheck();
|
||||
public:
|
||||
PMatches Matches;
|
||||
int Ok, CurMatch;
|
||||
|
||||
void *param;
|
||||
char (*CharAt)(int pos, void *param);
|
||||
|
||||
PosRegExp();
|
||||
~PosRegExp();
|
||||
|
||||
bool isok();
|
||||
bool SetNoMoves(bool Moves);
|
||||
bool SetBkTrace(int posStr,PMatches Trace);
|
||||
bool SetExpr(const char *Expr);
|
||||
bool Parse(int posStr, int posStop, PMatches Mtch);
|
||||
bool Parse(int posStr,int posSol, int posEol, PMatches Mtch, int Moves = -1);
|
||||
bool Evaluate(char *Expr, int posStr, PMatches Mtch, char **Res);
|
||||
} *PPosRegExp;
|
||||
|
||||
#endif /* POSREGEXP_H */
|
||||
@@ -1,244 +0,0 @@
|
||||
// SciTE - Scintilla based Text Editor
|
||||
// PropSet.h - a java style properties file module
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// 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);
|
||||
|
||||
#if PLAT_WIN
|
||||
#define strcasecmp stricmp
|
||||
#define strncasecmp strnicmp
|
||||
#endif
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#define strcasecmp stricmp
|
||||
#define strncasecmp strnicmp
|
||||
#endif
|
||||
|
||||
// Define another string class.
|
||||
// While it would be 'better' to use std::string, that doubles the executable size.
|
||||
|
||||
inline char *StringDup(const char *s, int len=-1) {
|
||||
if (!s)
|
||||
return 0;
|
||||
if (len == -1)
|
||||
len = strlen(s);
|
||||
char *sNew = new char[len + 1];
|
||||
if (sNew) {
|
||||
strncpy(sNew, s, len);
|
||||
sNew[len] = '\0';
|
||||
}
|
||||
return sNew;
|
||||
}
|
||||
|
||||
class SString {
|
||||
char *s;
|
||||
int ssize;
|
||||
public:
|
||||
typedef const char* const_iterator;
|
||||
typedef int size_type;
|
||||
static size_type npos;
|
||||
const char* begin(void) const {
|
||||
return s;
|
||||
}
|
||||
const char* end(void) const {
|
||||
return &s[ssize];
|
||||
}
|
||||
size_type size(void) const {
|
||||
if (s)
|
||||
return ssize;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
SString &assign(const char* sother, int size_ = -1) {
|
||||
char *t = s;
|
||||
s = StringDup(sother,size_);
|
||||
ssize = (s) ? strlen(s) : 0;
|
||||
delete []t;
|
||||
return *this;
|
||||
}
|
||||
SString &assign(const SString& sother, int size_ = -1) {
|
||||
return assign(sother.s,size_);
|
||||
}
|
||||
SString &assign(const_iterator ibeg, const_iterator iend) {
|
||||
return assign(ibeg,iend - ibeg);
|
||||
}
|
||||
SString() {
|
||||
s = 0;
|
||||
ssize = 0;
|
||||
}
|
||||
SString(const SString &source) {
|
||||
s = StringDup(source.s);
|
||||
ssize = (s) ? strlen(s) : 0;
|
||||
}
|
||||
SString(const char *s_) {
|
||||
s = StringDup(s_);
|
||||
ssize = (s) ? strlen(s) : 0;
|
||||
}
|
||||
SString(int i) {
|
||||
char number[100];
|
||||
sprintf(number, "%0d", i);
|
||||
s = StringDup(number);
|
||||
ssize = (s) ? strlen(s) : 0;
|
||||
}
|
||||
~SString() {
|
||||
delete []s;
|
||||
s = 0;
|
||||
ssize = 0;
|
||||
}
|
||||
SString &operator=(const SString &source) {
|
||||
if (this != &source) {
|
||||
delete []s;
|
||||
s = StringDup(source.s);
|
||||
ssize = (s) ? strlen(s) : 0;
|
||||
}
|
||||
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 SString &other) const {
|
||||
return !operator==(other);
|
||||
}
|
||||
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;
|
||||
}
|
||||
bool operator!=(const char *sother) const {
|
||||
return !operator==(sother);
|
||||
}
|
||||
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) const {
|
||||
if (s)
|
||||
return s[i];
|
||||
else
|
||||
return '\0';
|
||||
}
|
||||
SString &operator +=(const char *sother) {
|
||||
return append(sother,-1);
|
||||
}
|
||||
SString &operator +=(const SString &sother) {
|
||||
return append(sother.s,sother.ssize);
|
||||
}
|
||||
SString &operator +=(char ch) {
|
||||
return append(&ch,1);
|
||||
}
|
||||
SString &append(const char* sother, int lenOther) {
|
||||
int len = length();
|
||||
if(lenOther < 0)
|
||||
lenOther = strlen(sother);
|
||||
char *sNew = new char[len + lenOther + 1];
|
||||
if (sNew) {
|
||||
if (s)
|
||||
memcpy(sNew, s, len);
|
||||
strncpy(&sNew[len], sother, lenOther);
|
||||
sNew[len + lenOther] = '\0';
|
||||
delete []s;
|
||||
s = sNew;
|
||||
ssize = (s) ? strlen(s) : 0;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
int value() const {
|
||||
if (s)
|
||||
return atoi(s);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
void substitute(char find, char replace) {
|
||||
char *t = s;
|
||||
while (t) {
|
||||
t = strchr(t, find);
|
||||
if (t)
|
||||
*t = replace;
|
||||
}
|
||||
}
|
||||
// I don't think this really belongs here -- Neil
|
||||
void correctPath() {
|
||||
#ifdef unix
|
||||
substitute('\\', '/');
|
||||
#else
|
||||
substitute('/', '\\');
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
struct Property {
|
||||
unsigned int hash;
|
||||
char *key;
|
||||
char *val;
|
||||
Property *next;
|
||||
Property() : hash(0), key(0), val(0), next(0) {}
|
||||
};
|
||||
|
||||
class PropSet {
|
||||
private:
|
||||
enum { hashRoots=31 };
|
||||
Property *props[hashRoots];
|
||||
public:
|
||||
PropSet *superPS;
|
||||
PropSet();
|
||||
~PropSet();
|
||||
void Set(const char *key, const char *val);
|
||||
void Set(char *keyval);
|
||||
SString Get(const char *key);
|
||||
SString GetExpanded(const char *key);
|
||||
SString Expand(const char *withvars);
|
||||
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, const char *directoryForImports=0);
|
||||
void Read(const char *filename, const char *directoryForImports);
|
||||
};
|
||||
|
||||
class WordList {
|
||||
public:
|
||||
// Each word contains at least one character - a empty word acts as sentinal at the end.
|
||||
char **words;
|
||||
char **wordsNoCase;
|
||||
char *list;
|
||||
int len;
|
||||
bool onlyLineEnds; // Delimited by any white space or only line ends
|
||||
bool sorted;
|
||||
int starts[256];
|
||||
WordList(bool onlyLineEnds_ = false) :
|
||||
words(0), wordsNoCase(0), list(0), len(0), onlyLineEnds(onlyLineEnds_), sorted(false) {}
|
||||
~WordList() { Clear(); }
|
||||
operator bool() { return words ? true : false; }
|
||||
const char *operator[](int ind) { return words[ind]; }
|
||||
void Clear();
|
||||
void Set(const char *s);
|
||||
char *Allocate(int size);
|
||||
void SetFromAllocated();
|
||||
bool InList(const char *s);
|
||||
const char *GetNearestWord(const char *wordStart, int searchLen = -1, bool ignoreCase = false);
|
||||
char *GetNearestWords(const char *wordStart, int searchLen = -1, bool ignoreCase = false);
|
||||
};
|
||||
|
||||
inline bool nonFuncChar(char ch) {
|
||||
return strchr("\t\n\r !\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~", ch) != NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,204 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// SciLexer - interface to the added lexer functions in the SciLexer version of the edit control
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
// Most of this file is automatically generated from the Scintilla.iface interface definition
|
||||
// file which contains any comments about the definitions. HFacer.py does the generation.
|
||||
|
||||
#ifndef SCILEXER_H
|
||||
#define SCILEXER_H
|
||||
|
||||
// SciLexer features - not in standard Scintilla
|
||||
|
||||
//++Autogenerated -- start of section automatically generated from Scintilla.iface
|
||||
#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
|
||||
#define SCLEX_XCODE 13
|
||||
#define SCLEX_LATEX 14
|
||||
#define SCLEX_LUA 15
|
||||
#define SCLEX_DIFF 16
|
||||
#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
|
||||
#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_UUID 8
|
||||
#define SCE_C_PREPROCESSOR 9
|
||||
#define SCE_C_OPERATOR 10
|
||||
#define SCE_C_IDENTIFIER 11
|
||||
#define SCE_C_STRINGEOL 12
|
||||
#define SCE_C_VERBATIM 13
|
||||
#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
|
||||
#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
|
||||
#define SCE_H_CDATA 17
|
||||
#define SCE_H_QUESTION 18
|
||||
#define SCE_H_VALUE 19
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
#define SCE_HPHP_DEFAULT 118
|
||||
#define SCE_HPHP_HSTRING 119
|
||||
#define SCE_HPHP_SIMPLESTRING 120
|
||||
#define SCE_HPHP_WORD 121
|
||||
#define SCE_HPHP_NUMBER 122
|
||||
#define SCE_HPHP_VARIABLE 123
|
||||
#define SCE_HPHP_COMMENT 124
|
||||
#define SCE_HPHP_COMMENTLINE 125
|
||||
#define SCE_HPHP_STRINGEOL 126
|
||||
#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
|
||||
#define SCE_L_DEFAULT 0
|
||||
#define SCE_L_COMMAND 1
|
||||
#define SCE_L_TAG 2
|
||||
#define SCE_L_MATH 3
|
||||
#define SCE_L_COMMENT 4
|
||||
#define SCE_LUA_DEFAULT 0
|
||||
#define SCE_LUA_COMMENT 1
|
||||
#define SCE_LUA_COMMENTLINE 2
|
||||
#define SCE_LUA_COMMENTDOC 3
|
||||
#define SCE_LUA_NUMBER 4
|
||||
#define SCE_LUA_WORD 5
|
||||
#define SCE_LUA_STRING 6
|
||||
#define SCE_LUA_CHARACTER 7
|
||||
#define SCE_LUA_LITERALSTRING 8
|
||||
#define SCE_LUA_PREPROCESSOR 9
|
||||
#define SCE_LUA_OPERATOR 10
|
||||
#define SCE_LUA_IDENTIFIER 11
|
||||
#define SCE_LUA_STRINGEOL 12
|
||||
#define SCE_ERR_DEFAULT 0
|
||||
#define SCE_ERR_PYTHON 1
|
||||
#define SCE_ERR_GCC 2
|
||||
#define SCE_ERR_MS 3
|
||||
#define SCE_ERR_CMD 4
|
||||
#define SCE_ERR_BORLAND 5
|
||||
#define SCE_ERR_PERL 6
|
||||
//--Autogenerated -- end of section automatically generated from Scintilla.iface
|
||||
|
||||
#endif
|
||||
@@ -1,508 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// Scintilla.h - interface to the edit control
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
// Most of this file is automatically generated from the Scintilla.iface interface definition
|
||||
// file which contains any comments about the definitions. HFacer.py does the generation.
|
||||
|
||||
#ifndef SCINTILLA_H
|
||||
#define SCINTILLA_H
|
||||
|
||||
// Compile-time configuration options
|
||||
#define MACRO_SUPPORT 1 // Comment out to remove macro hooks
|
||||
|
||||
#if PLAT_WIN
|
||||
#ifdef STATIC_BUILD
|
||||
void Scintilla_RegisterClasses(HINSTANCE hInstance);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wParam, long lParam);
|
||||
|
||||
//++Autogenerated -- start of section automatically generated from Scintilla.iface
|
||||
#define INVALID_POSITION -1
|
||||
#define SCI_START 2000
|
||||
#define SCI_OPTIONAL_START 3000
|
||||
#define SCI_LEXER_START 4000
|
||||
#define SCI_ADDTEXT 2001
|
||||
#define SCI_ADDSTYLEDTEXT 2002
|
||||
#define SCI_INSERTTEXT 2003
|
||||
#define SCI_CLEARALL 2004
|
||||
#define SCI_CLEARDOCUMENTSTYLE 2005
|
||||
#define SCI_GETLENGTH 2006
|
||||
#define SCI_GETCHARAT 2007
|
||||
#define SCI_GETCURRENTPOS 2008
|
||||
#define SCI_GETANCHOR 2009
|
||||
#define SCI_GETSTYLEAT 2010
|
||||
#define SCI_REDO 2011
|
||||
#define SCI_SETUNDOCOLLECTION 2012
|
||||
#define SCI_SELECTALL 2013
|
||||
#define SCI_SETSAVEPOINT 2014
|
||||
#define SCI_GETSTYLEDTEXT 2015
|
||||
#define SCI_CANREDO 2016
|
||||
#define SCI_MARKERLINEFROMHANDLE 2017
|
||||
#define SCI_MARKERDELETEHANDLE 2018
|
||||
#define SCI_GETUNDOCOLLECTION 2019
|
||||
#define SCWS_INVISIBLE 0
|
||||
#define SCWS_VISIBLEALWAYS 1
|
||||
#define SCWS_VISIBLEAFTERINDENT 2
|
||||
#define SCI_GETVIEWWS 2020
|
||||
#define SCI_SETVIEWWS 2021
|
||||
#define SCI_POSITIONFROMPOINT 2022
|
||||
#define SCI_GOTOLINE 2024
|
||||
#define SCI_GOTOPOS 2025
|
||||
#define SCI_SETANCHOR 2026
|
||||
#define SCI_GETCURLINE 2027
|
||||
#define SCI_GETENDSTYLED 2028
|
||||
#define SCI_CONVERTEOLS 2029
|
||||
#define SC_EOL_CRLF 0
|
||||
#define SC_EOL_CR 1
|
||||
#define SC_EOL_LF 2
|
||||
#define SCI_GETEOLMODE 2030
|
||||
#define SCI_SETEOLMODE 2031
|
||||
#define SCI_STARTSTYLING 2032
|
||||
#define SCI_SETSTYLING 2033
|
||||
#define SCI_GETBUFFEREDDRAW 2034
|
||||
#define SCI_SETBUFFEREDDRAW 2035
|
||||
#define SCI_SETTABWIDTH 2036
|
||||
#define SCI_GETTABWIDTH 2121
|
||||
#define SC_CP_UTF8 65001
|
||||
#define SCI_SETCODEPAGE 2037
|
||||
#define SCI_SETUSEPALETTE 2039
|
||||
#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 SC_MARKNUM_FOLDER 30
|
||||
#define SC_MARKNUM_FOLDEROPEN 31
|
||||
#define SCI_MARKERDEFINE 2040
|
||||
#define SCI_MARKERSETFORE 2041
|
||||
#define SCI_MARKERSETBACK 2042
|
||||
#define SCI_MARKERADD 2043
|
||||
#define SCI_MARKERDELETE 2044
|
||||
#define SCI_MARKERDELETEALL 2045
|
||||
#define SCI_MARKERGET 2046
|
||||
#define SCI_MARKERNEXT 2047
|
||||
#define SCI_MARKERPREVIOUS 2048
|
||||
#define SC_MARGIN_SYMBOL 0
|
||||
#define SC_MARGIN_NUMBER 1
|
||||
#define SCI_SETMARGINTYPEN 2240
|
||||
#define SCI_GETMARGINTYPEN 2241
|
||||
#define SCI_SETMARGINWIDTHN 2242
|
||||
#define SCI_GETMARGINWIDTHN 2243
|
||||
#define SCI_SETMARGINMASKN 2244
|
||||
#define SCI_GETMARGINMASKN 2245
|
||||
#define SCI_SETMARGINSENSITIVEN 2246
|
||||
#define SCI_GETMARGINSENSITIVEN 2247
|
||||
#define STYLE_DEFAULT 32
|
||||
#define STYLE_LINENUMBER 33
|
||||
#define STYLE_BRACELIGHT 34
|
||||
#define STYLE_BRACEBAD 35
|
||||
#define STYLE_CONTROLCHAR 36
|
||||
#define STYLE_INDENTGUIDE 37
|
||||
#define STYLE_MAX 127
|
||||
#define SC_CHARSET_ANSI 0
|
||||
#define SC_CHARSET_DEFAULT 1
|
||||
#define SC_CHARSET_BALTIC 186
|
||||
#define SC_CHARSET_CHINESEBIG5 136
|
||||
#define SC_CHARSET_EASTEUROPE 238
|
||||
#define SC_CHARSET_GB2312 134
|
||||
#define SC_CHARSET_GREEK 161
|
||||
#define SC_CHARSET_HANGUL 129
|
||||
#define SC_CHARSET_MAC 77
|
||||
#define SC_CHARSET_OEM 255
|
||||
#define SC_CHARSET_RUSSIAN 204
|
||||
#define SC_CHARSET_SHIFTJIS 128
|
||||
#define SC_CHARSET_SYMBOL 2
|
||||
#define SC_CHARSET_TURKISH 162
|
||||
#define SC_CHARSET_JOHAB 130
|
||||
#define SC_CHARSET_HEBREW 177
|
||||
#define SC_CHARSET_ARABIC 178
|
||||
#define SC_CHARSET_VIETNAMESE 163
|
||||
#define SC_CHARSET_THAI 222
|
||||
#define SCI_STYLECLEARALL 2050
|
||||
#define SCI_STYLESETFORE 2051
|
||||
#define SCI_STYLESETBACK 2052
|
||||
#define SCI_STYLESETBOLD 2053
|
||||
#define SCI_STYLESETITALIC 2054
|
||||
#define SCI_STYLESETSIZE 2055
|
||||
#define SCI_STYLESETFONT 2056
|
||||
#define SCI_STYLESETEOLFILLED 2057
|
||||
#define SCI_STYLERESETDEFAULT 2058
|
||||
#define SCI_STYLESETUNDERLINE 2059
|
||||
#define SCI_STYLESETCHARACTERSET 2066
|
||||
#define SCI_SETSELFORE 2067
|
||||
#define SCI_SETSELBACK 2068
|
||||
#define SCI_SETCARETFORE 2069
|
||||
#define SCI_ASSIGNCMDKEY 2070
|
||||
#define SCI_CLEARCMDKEY 2071
|
||||
#define SCI_CLEARALLCMDKEYS 2072
|
||||
#define SCI_SETSTYLINGEX 2073
|
||||
#define SCI_STYLESETVISIBLE 2074
|
||||
#define SCI_GETCARETPERIOD 2075
|
||||
#define SCI_SETCARETPERIOD 2076
|
||||
#define SCI_SETWORDCHARS 2077
|
||||
#define SCI_BEGINUNDOACTION 2078
|
||||
#define SCI_ENDUNDOACTION 2079
|
||||
#define INDIC_MAX 7
|
||||
#define INDIC_PLAIN 0
|
||||
#define INDIC_SQUIGGLE 1
|
||||
#define INDIC_TT 2
|
||||
#define INDIC_DIAGONAL 3
|
||||
#define INDIC_STRIKE 4
|
||||
#define INDIC0_MASK 32
|
||||
#define INDIC1_MASK 64
|
||||
#define INDIC2_MASK 128
|
||||
#define INDICS_MASK INDIC0_MASK | INDIC1_MASK | INDIC2_MASK
|
||||
#define SCI_INDICSETSTYLE 2080
|
||||
#define SCI_INDICGETSTYLE 2081
|
||||
#define SCI_INDICSETFORE 2082
|
||||
#define SCI_INDICGETFORE 2083
|
||||
#define SCI_SETSTYLEBITS 2090
|
||||
#define SCI_GETSTYLEBITS 2091
|
||||
#define SCI_SETLINESTATE 2092
|
||||
#define SCI_GETLINESTATE 2093
|
||||
#define SCI_GETMAXLINESTATE 2094
|
||||
#define SCI_AUTOCSHOW 2100
|
||||
#define SCI_AUTOCCANCEL 2101
|
||||
#define SCI_AUTOCACTIVE 2102
|
||||
#define SCI_AUTOCPOSSTART 2103
|
||||
#define SCI_AUTOCCOMPLETE 2104
|
||||
#define SCI_AUTOCSTOPS 2105
|
||||
#define SCI_AUTOCSETSEPARATOR 2106
|
||||
#define SCI_AUTOCGETSEPARATOR 2107
|
||||
#define SCI_AUTOCSELECT 2108
|
||||
#define SCI_AUTOCSETCANCELATSTART 2110
|
||||
#define SCI_AUTOCGETCANCELATSTART 2111
|
||||
#define SCI_AUTOCSETFILLUPS 2112
|
||||
#define SCI_AUTOCSETCHOOSESINGLE 2113
|
||||
#define SCI_AUTOCGETCHOOSESINGLE 2114
|
||||
#define SCI_AUTOCSETIGNORECASE 2115
|
||||
#define SCI_AUTOCGETIGNORECASE 2116
|
||||
#define SCI_SETINDENT 2122
|
||||
#define SCI_GETINDENT 2123
|
||||
#define SCI_SETUSETABS 2124
|
||||
#define SCI_GETUSETABS 2125
|
||||
#define SCI_SETLINEINDENTATION 2126
|
||||
#define SCI_GETLINEINDENTATION 2127
|
||||
#define SCI_GETLINEINDENTPOSITION 2128
|
||||
#define SCI_GETCOLUMN 2129
|
||||
#define SCI_SETHSCROLLBAR 2130
|
||||
#define SCI_GETHSCROLLBAR 2131
|
||||
#define SCI_SETINDENTATIONGUIDES 2132
|
||||
#define SCI_GETINDENTATIONGUIDES 2133
|
||||
#define SCI_SETHIGHLIGHTGUIDE 2134
|
||||
#define SCI_GETHIGHLIGHTGUIDE 2135
|
||||
#define SCI_GETLINEENDPOSITION 2136
|
||||
#define SCI_GETCODEPAGE 2137
|
||||
#define SCI_GETCARETFORE 2138
|
||||
#define SCI_GETUSEPALETTE 2139
|
||||
#define SCI_GETREADONLY 2140
|
||||
#define SCI_SETCURRENTPOS 2141
|
||||
#define SCI_SETSELECTIONSTART 2142
|
||||
#define SCI_GETSELECTIONSTART 2143
|
||||
#define SCI_SETSELECTIONEND 2144
|
||||
#define SCI_GETSELECTIONEND 2145
|
||||
#define SCI_SETPRINTMAGNIFICATION 2146
|
||||
#define SCI_GETPRINTMAGNIFICATION 2147
|
||||
#define SC_PRINT_NORMAL 0
|
||||
#define SC_PRINT_INVERTLIGHT 1
|
||||
#define SC_PRINT_BLACKONWHITE 2
|
||||
#define SCI_SETPRINTCOLOURMODE 2148
|
||||
#define SCI_GETPRINTCOLOURMODE 2149
|
||||
#define SCFIND_DOWN 1
|
||||
#define SCFIND_WHOLEWORD 2
|
||||
#define SCFIND_MATCHCASE 4
|
||||
#define SCFIND_WORDSTART 0x00100000
|
||||
#define SCFIND_REGEXP 0x00200000
|
||||
#define SCI_FINDTEXT 2150
|
||||
#define SCI_FORMATRANGE 2151
|
||||
#define SCI_GETFIRSTVISIBLELINE 2152
|
||||
#define SCI_GETLINE 2153
|
||||
#define SCI_GETLINECOUNT 2154
|
||||
#define SCI_SETMARGINLEFT 2155
|
||||
#define SCI_GETMARGINLEFT 2156
|
||||
#define SCI_SETMARGINRIGHT 2157
|
||||
#define SCI_GETMARGINRIGHT 2158
|
||||
#define SCI_GETMODIFY 2159
|
||||
#define SCI_SETSEL 2160
|
||||
#define SCI_GETSELTEXT 2161
|
||||
#define SCI_GETTEXTRANGE 2162
|
||||
#define SCI_HIDESELECTION 2163
|
||||
#define SCI_POINTXFROMPOSITION 2164
|
||||
#define SCI_POINTYFROMPOSITION 2165
|
||||
#define SCI_LINEFROMPOSITION 2166
|
||||
#define SCI_POSITIONFROMLINE 2167
|
||||
#define SCI_LINESCROLL 2168
|
||||
#define SCI_SCROLLCARET 2169
|
||||
#define SCI_REPLACESEL 2170
|
||||
#define SCI_SETREADONLY 2171
|
||||
#define SCI_NULL 2172
|
||||
#define SCI_CANPASTE 2173
|
||||
#define SCI_CANUNDO 2174
|
||||
#define SCI_EMPTYUNDOBUFFER 2175
|
||||
#define SCI_UNDO 2176
|
||||
#define SCI_CUT 2177
|
||||
#define SCI_COPY 2178
|
||||
#define SCI_PASTE 2179
|
||||
#define SCI_CLEAR 2180
|
||||
#define SCI_SETTEXT 2181
|
||||
#define SCI_GETTEXT 2182
|
||||
#define SCI_GETTEXTLENGTH 2183
|
||||
#define SCI_GETDIRECTFUNCTION 2184
|
||||
#define SCI_GETDIRECTPOINTER 2185
|
||||
#define SCI_SETOVERTYPE 2186
|
||||
#define SCI_GETOVERTYPE 2187
|
||||
#define SCI_CALLTIPSHOW 2200
|
||||
#define SCI_CALLTIPCANCEL 2201
|
||||
#define SCI_CALLTIPACTIVE 2202
|
||||
#define SCI_CALLTIPPOSSTART 2203
|
||||
#define SCI_CALLTIPSETHLT 2204
|
||||
#define SCI_CALLTIPSETBACK 2205
|
||||
#define SCI_VISIBLEFROMDOCLINE 2220
|
||||
#define SCI_DOCLINEFROMVISIBLE 2221
|
||||
#define SC_FOLDLEVELBASE 0x400
|
||||
#define SC_FOLDLEVELWHITEFLAG 0x1000
|
||||
#define SC_FOLDLEVELHEADERFLAG 0x2000
|
||||
#define SC_FOLDLEVELNUMBERMASK 0x0FFF
|
||||
#define SCI_SETFOLDLEVEL 2222
|
||||
#define SCI_GETFOLDLEVEL 2223
|
||||
#define SCI_GETLASTCHILD 2224
|
||||
#define SCI_GETFOLDPARENT 2225
|
||||
#define SCI_SHOWLINES 2226
|
||||
#define SCI_HIDELINES 2227
|
||||
#define SCI_GETLINEVISIBLE 2228
|
||||
#define SCI_SETFOLDEXPANDED 2229
|
||||
#define SCI_GETFOLDEXPANDED 2230
|
||||
#define SCI_TOGGLEFOLD 2231
|
||||
#define SCI_ENSUREVISIBLE 2232
|
||||
#define SCI_SETFOLDFLAGS 2233
|
||||
#define SCI_LINEDOWN 2300
|
||||
#define SCI_LINEDOWNEXTEND 2301
|
||||
#define SCI_LINEUP 2302
|
||||
#define SCI_LINEUPEXTEND 2303
|
||||
#define SCI_CHARLEFT 2304
|
||||
#define SCI_CHARLEFTEXTEND 2305
|
||||
#define SCI_CHARRIGHT 2306
|
||||
#define SCI_CHARRIGHTEXTEND 2307
|
||||
#define SCI_WORDLEFT 2308
|
||||
#define SCI_WORDLEFTEXTEND 2309
|
||||
#define SCI_WORDRIGHT 2310
|
||||
#define SCI_WORDRIGHTEXTEND 2311
|
||||
#define SCI_HOME 2312
|
||||
#define SCI_HOMEEXTEND 2313
|
||||
#define SCI_LINEEND 2314
|
||||
#define SCI_LINEENDEXTEND 2315
|
||||
#define SCI_DOCUMENTSTART 2316
|
||||
#define SCI_DOCUMENTSTARTEXTEND 2317
|
||||
#define SCI_DOCUMENTEND 2318
|
||||
#define SCI_DOCUMENTENDEXTEND 2319
|
||||
#define SCI_PAGEUP 2320
|
||||
#define SCI_PAGEUPEXTEND 2321
|
||||
#define SCI_PAGEDOWN 2322
|
||||
#define SCI_PAGEDOWNEXTEND 2323
|
||||
#define SCI_EDITTOGGLEOVERTYPE 2324
|
||||
#define SCI_CANCEL 2325
|
||||
#define SCI_DELETEBACK 2326
|
||||
#define SCI_TAB 2327
|
||||
#define SCI_BACKTAB 2328
|
||||
#define SCI_NEWLINE 2329
|
||||
#define SCI_FORMFEED 2330
|
||||
#define SCI_VCHOME 2331
|
||||
#define SCI_VCHOMEEXTEND 2332
|
||||
#define SCI_ZOOMIN 2333
|
||||
#define SCI_ZOOMOUT 2334
|
||||
#define SCI_DELWORDLEFT 2335
|
||||
#define SCI_DELWORDRIGHT 2336
|
||||
#define SCI_LINECUT 2337
|
||||
#define SCI_LINEDELETE 2338
|
||||
#define SCI_LINETRANSPOSE 2339
|
||||
#define SCI_LOWERCASE 2340
|
||||
#define SCI_UPPERCASE 2341
|
||||
#define SCI_LINESCROLLDOWN 2342
|
||||
#define SCI_LINESCROLLUP 2343
|
||||
#define SCI_LINELENGTH 2350
|
||||
#define SCI_BRACEHIGHLIGHT 2351
|
||||
#define SCI_BRACEBADLIGHT 2352
|
||||
#define SCI_BRACEMATCH 2353
|
||||
#define SCI_GETVIEWEOL 2355
|
||||
#define SCI_SETVIEWEOL 2356
|
||||
#define SCI_GETDOCPOINTER 2357
|
||||
#define SCI_SETDOCPOINTER 2358
|
||||
#define SCI_SETMODEVENTMASK 2359
|
||||
#define EDGE_NONE 0
|
||||
#define EDGE_LINE 1
|
||||
#define EDGE_BACKGROUND 2
|
||||
#define SCI_GETEDGECOLUMN 2360
|
||||
#define SCI_SETEDGECOLUMN 2361
|
||||
#define SCI_GETEDGEMODE 2362
|
||||
#define SCI_SETEDGEMODE 2363
|
||||
#define SCI_GETEDGECOLOUR 2364
|
||||
#define SCI_SETEDGECOLOUR 2365
|
||||
#define SCI_SEARCHANCHOR 2366
|
||||
#define SCI_SEARCHNEXT 2367
|
||||
#define SCI_SEARCHPREV 2368
|
||||
#define CARET_SLOP 0x01
|
||||
#define CARET_CENTER 0x02
|
||||
#define CARET_STRICT 0x04
|
||||
#define SCI_SETCARETPOLICY 2369
|
||||
#define SCI_LINESONSCREEN 2370
|
||||
#define SCI_USEPOPUP 2371
|
||||
#define SCI_SELECTIONISRECTANGLE 2372
|
||||
#define SCI_SETZOOM 2373
|
||||
#define SCI_GETZOOM 2374
|
||||
#define SCI_CREATEDOCUMENT 2375
|
||||
#define SCI_ADDREFDOCUMENT 2376
|
||||
#define SCI_RELEASEDOCUMENT 2377
|
||||
#define SCI_GETMODEVENTMASK 2378
|
||||
#define SCI_GRABFOCUS 2400
|
||||
#define SCI_STARTRECORD 3001
|
||||
#define SCI_STOPRECORD 3002
|
||||
#define SCI_SETLEXER 4001
|
||||
#define SCI_GETLEXER 4002
|
||||
#define SCI_COLOURISE 4003
|
||||
#define SCI_SETPROPERTY 4004
|
||||
#define SCI_SETKEYWORDS 4005
|
||||
#define SC_MOD_INSERTTEXT 0x1
|
||||
#define SC_MOD_DELETETEXT 0x2
|
||||
#define SC_MOD_CHANGESTYLE 0x4
|
||||
#define SC_MOD_CHANGEFOLD 0x8
|
||||
#define SC_PERFORMED_USER 0x10
|
||||
#define SC_PERFORMED_UNDO 0x20
|
||||
#define SC_PERFORMED_REDO 0x40
|
||||
#define SC_LASTSTEPINUNDOREDO 0x100
|
||||
#define SC_MOD_CHANGEMARKER 0x200
|
||||
#define SC_MOD_BEFOREINSERT 0x400
|
||||
#define SC_MOD_BEFOREDELETE 0x800
|
||||
#define SC_MODEVENTMASKALL 0xF77
|
||||
#define SCEN_CHANGE 768
|
||||
#define SCEN_SETFOCUS 512
|
||||
#define SCEN_KILLFOCUS 256
|
||||
#define SCK_DOWN 300
|
||||
#define SCK_UP 301
|
||||
#define SCK_LEFT 302
|
||||
#define SCK_RIGHT 303
|
||||
#define SCK_HOME 304
|
||||
#define SCK_END 305
|
||||
#define SCK_PRIOR 306
|
||||
#define SCK_NEXT 307
|
||||
#define SCK_DELETE 308
|
||||
#define SCK_INSERT 309
|
||||
#define SCK_ESCAPE 7
|
||||
#define SCK_BACK 8
|
||||
#define SCK_TAB 9
|
||||
#define SCK_RETURN 13
|
||||
#define SCK_ADD 310
|
||||
#define SCK_SUBTRACT 311
|
||||
#define SCK_DIVIDE 312
|
||||
#define SCMOD_SHIFT 1
|
||||
#define SCMOD_CTRL 2
|
||||
#define SCMOD_ALT 4
|
||||
#define SCN_STYLENEEDED 2000
|
||||
#define SCN_CHARADDED 2001
|
||||
#define SCN_SAVEPOINTREACHED 2002
|
||||
#define SCN_SAVEPOINTLEFT 2003
|
||||
#define SCN_MODIFYATTEMPTRO 2004
|
||||
#define SCN_KEY 2005
|
||||
#define SCN_DOUBLECLICK 2006
|
||||
#define SCN_UPDATEUI 2007
|
||||
#define SCN_CHECKBRACE 2007
|
||||
#define SCN_MODIFIED 2008
|
||||
#define SCN_MACRORECORD 2009
|
||||
#define SCN_MARGINCLICK 2010
|
||||
#define SCN_NEEDSHOWN 2011
|
||||
#define SCN_POSCHANGED 2012
|
||||
//--Autogenerated -- end of section automatically generated from Scintilla.iface
|
||||
|
||||
// Optional module for macro recording
|
||||
#ifdef MACRO_SUPPORT
|
||||
typedef void (tMacroRecorder)(unsigned int iMessage, unsigned long wParam,
|
||||
long lParam, void *userData);
|
||||
#endif
|
||||
|
||||
// These structures are defined to be exactly the same shape as the Win32
|
||||
// CHARRANGE, TEXTRANGE, FINDTEXTEX, FORMATRANGE, and NMHDR structs.
|
||||
// So older code that treats Scintilla as a RichEdit will work.
|
||||
|
||||
struct CharacterRange {
|
||||
long cpMin;
|
||||
long cpMax;
|
||||
};
|
||||
|
||||
struct TextRange {
|
||||
CharacterRange chrg;
|
||||
char *lpstrText;
|
||||
};
|
||||
|
||||
struct TextToFind {
|
||||
CharacterRange chrg;
|
||||
char *lpstrText;
|
||||
CharacterRange chrgText;
|
||||
};
|
||||
|
||||
#ifdef PLATFORM_H
|
||||
|
||||
// This structure is used in printing and requires some of the graphics types
|
||||
// from Platform.h. Not needed by most client code.
|
||||
|
||||
struct RangeToFormat {
|
||||
SurfaceID hdc;
|
||||
SurfaceID hdcTarget;
|
||||
PRectangle rc;
|
||||
PRectangle rcPage;
|
||||
CharacterRange chrg;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
struct NotifyHeader {
|
||||
// hwndFrom is really an environment specifc window handle or pointer
|
||||
// but most clients of Scintilla.h do not have this type visible.
|
||||
//WindowID hwndFrom;
|
||||
void *hwndFrom;
|
||||
unsigned int idFrom;
|
||||
unsigned int code;
|
||||
};
|
||||
|
||||
struct SCNotification {
|
||||
NotifyHeader nmhdr;
|
||||
int position; // SCN_STYLENEEDED, SCN_MODIFIED
|
||||
int ch; // SCN_CHARADDED, SCN_KEY
|
||||
int modifiers; // SCN_KEY
|
||||
int modificationType; // SCN_MODIFIED
|
||||
const char *text; // SCN_MODIFIED
|
||||
int length; // SCN_MODIFIED
|
||||
int linesAdded; // SCN_MODIFIED
|
||||
#ifdef MACRO_SUPPORT
|
||||
int message; // SCN_MACRORECORD
|
||||
int wParam; // SCN_MACRORECORD
|
||||
int lParam; // SCN_MACRORECORD
|
||||
#endif
|
||||
int line; // SCN_MODIFIED
|
||||
int foldLevelNow; // SCN_MODIFIED
|
||||
int foldLevelPrev; // SCN_MODIFIED
|
||||
int margin; // SCN_MARGINCLICK
|
||||
};
|
||||
|
||||
#define SC_MASK_FOLDERS ((1<<SC_MARKNUM_FOLDER) | (1<<SC_MARKNUM_FOLDEROPEN))
|
||||
|
||||
// Deprecation section listing all API features that are deprecated and will
|
||||
// will be removed completely in a future version.
|
||||
// To enable these features define INCLUDE_DEPRECATED_FEATURES
|
||||
|
||||
#ifdef INCLUDE_DEPRECATED_FEATURES
|
||||
|
||||
// Deprecated in 1.27
|
||||
#define SC_UNDOCOLLECT_NONE 0
|
||||
#define SC_UNDOCOLLECT_AUTOSTART 1
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,46 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// ScintillaWidget.h - definition of Scintilla widget for GTK+
|
||||
// Only needed by GTK+ code but is harmless on other platforms.
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef SCINTILLAWIDGET_H
|
||||
#define SCINTILLAWIDGET_H
|
||||
|
||||
#if PLAT_GTK
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SCINTILLA(obj) GTK_CHECK_CAST (obj, scintilla_get_type (), ScintillaObject)
|
||||
#define SCINTILLA_CLASS(klass) GTK_CHECK_CLASS_CAST (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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,183 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// WinDefs.h - the subset of definitions from Windows needed by Scintilla for GTK+
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// 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
|
||||
|
||||
//#if 0
|
||||
/* RTF control */
|
||||
#define EM_CANPASTE (1074)
|
||||
#define EM_CANUNDO (198)
|
||||
#define EM_CHARFROMPOS (215)
|
||||
#define EM_EMPTYUNDOBUFFER (205)
|
||||
#define EM_EXGETSEL (1076)
|
||||
#define EM_EXLINEFROMCHAR (1078)
|
||||
#define EM_EXSETSEL (1079)
|
||||
#define EM_FINDTEXT (1080)
|
||||
#define EM_FINDTEXTEX (1103)
|
||||
#define EM_FORMATRANGE (1081)
|
||||
#define EM_GETFIRSTVISIBLELINE (206)
|
||||
#define EM_GETLINE (196)
|
||||
#define EM_GETLINECOUNT (186)
|
||||
#define EM_GETMARGINS (212)
|
||||
#define EM_GETMODIFY (184)
|
||||
#define EM_GETRECT (178)
|
||||
#define EM_GETSEL (176)
|
||||
#define EM_GETSELTEXT (1086)
|
||||
#define EM_GETTEXTRANGE (1099)
|
||||
#define EM_HIDESELECTION (1087)
|
||||
#define EM_LINEFROMCHAR (201)
|
||||
#define EM_LINEINDEX (187)
|
||||
#define EM_LINELENGTH (193)
|
||||
#define EM_LINESCROLL (182)
|
||||
#define EM_POSFROMCHAR (214)
|
||||
#define EM_REPLACESEL (194)
|
||||
#define EM_SCROLLCARET (183)
|
||||
#define EM_SELECTIONTYPE (1090)
|
||||
#define EM_SETMARGINS (211)
|
||||
#define EM_SETREADONLY (207)
|
||||
#define EM_SETSEL (177)
|
||||
#define EM_UNDO (199)
|
||||
|
||||
#define WM_NULL (0)
|
||||
#define WM_CLEAR (771)
|
||||
#define WM_COPY (769)
|
||||
#define WM_CUT (768)
|
||||
#define WM_GETTEXT (13)
|
||||
#define WM_GETTEXTLENGTH (14)
|
||||
#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
|
||||
|
||||
//#endif
|
||||
|
||||
#if 0
|
||||
#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
|
||||
#define VK_DIVIDE GDK_KP_Divide
|
||||
#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
|
||||
//TODO:
|
||||
#define VK_DIVIDE WXK_DIVIDE
|
||||
#endif
|
||||
|
||||
#define SHIFT_PRESSED 1
|
||||
#define LEFT_CTRL_PRESSED 2
|
||||
#define LEFT_ALT_PRESSED 4
|
||||
|
||||
// Are these needed any more
|
||||
#define LPSTR char *
|
||||
#define LONG long
|
||||
#define LPDWORD (long *)
|
||||
|
||||
/* SELCHANGE structure */
|
||||
#define SEL_EMPTY (0)
|
||||
#define SEL_TEXT (1)
|
||||
#define SEL_OBJECT (2)
|
||||
#define SEL_MULTICHAR (4)
|
||||
#define SEL_MULTIOBJECT (8)
|
||||
|
||||
struct RECT {
|
||||
LONG left;
|
||||
LONG top;
|
||||
LONG right;
|
||||
LONG bottom;
|
||||
};
|
||||
|
||||
/* FINDREPLACE structure */
|
||||
|
||||
#define FR_MATCHCASE (0x4)
|
||||
#define FR_WHOLEWORD (0x2)
|
||||
#define FR_DOWN (0x1)
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
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;
|
||||
};
|
||||
#endif
|
||||
|
||||
//#define MAKELONG(a, b) ((a) | ((b) << 16))
|
||||
//#define LOWORD(x) (x & 0xffff)
|
||||
//#define HIWORD(x) (x >> 16)
|
||||
|
||||
#endif
|
||||
@@ -1,47 +0,0 @@
|
||||
// WindowAccessor.h - implementation of BufferAccess and StylingAccess on a Scintilla rapid easy access to contents of a Scintilla
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
class WindowAccessor : public Accessor {
|
||||
// Private so WindowAccessor objects can not be copied
|
||||
WindowAccessor(const WindowAccessor &source) : Accessor(), props(source.props) {}
|
||||
WindowAccessor &operator=(const WindowAccessor &) { return *this; }
|
||||
protected:
|
||||
WindowID id;
|
||||
PropSet &props;
|
||||
int lenDoc;
|
||||
|
||||
char styleBuf[bufferSize];
|
||||
int validLen;
|
||||
char chFlags;
|
||||
char chWhile;
|
||||
unsigned int startSeg;
|
||||
|
||||
bool InternalIsLeadByte(char ch);
|
||||
void Fill(int position);
|
||||
public:
|
||||
WindowAccessor(WindowID id_, PropSet &props_) :
|
||||
Accessor(), id(id_), props(props_),
|
||||
lenDoc(-1), validLen(0), chFlags(0), chWhile(0) {
|
||||
}
|
||||
~WindowAccessor();
|
||||
char StyleAt(int position);
|
||||
int GetLine(int position);
|
||||
int LineStart(int line);
|
||||
int LevelAt(int line);
|
||||
int Length();
|
||||
void Flush();
|
||||
int GetLineState(int line);
|
||||
int SetLineState(int line, int state);
|
||||
int GetPropertyInt(const char *key, int defaultValue=0) {
|
||||
return props.GetInt(key, defaultValue);
|
||||
}
|
||||
|
||||
void StartAt(unsigned int start, char chMask=31);
|
||||
void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; };
|
||||
unsigned int GetStartSegment() { return startSeg; }
|
||||
void StartSegment(unsigned int pos);
|
||||
void ColourTo(unsigned int pos, int chAttr);
|
||||
void SetLevel(int line, int level);
|
||||
int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0);
|
||||
};
|
||||
@@ -1,121 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// AutoComplete.cxx - defines the auto completion list box
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "AutoComplete.h"
|
||||
|
||||
AutoComplete::AutoComplete() :
|
||||
active(false),
|
||||
separator(' '),
|
||||
ignoreCase(false),
|
||||
chooseSingle(false),
|
||||
posStart(0),
|
||||
startLen(0),
|
||||
cancelAtStartPos(true) {
|
||||
stopChars[0] = '\0';
|
||||
fillUpChars[0] = '\0';
|
||||
}
|
||||
|
||||
AutoComplete::~AutoComplete() {
|
||||
lb.Destroy();
|
||||
}
|
||||
|
||||
bool AutoComplete::Active() {
|
||||
return active;
|
||||
}
|
||||
|
||||
void AutoComplete::Start(Window &parent, int ctrlID, int position, int startLen_) {
|
||||
if (!lb.Created()) {
|
||||
lb.Create(parent, ctrlID);
|
||||
}
|
||||
lb.Clear();
|
||||
active = true;
|
||||
startLen = startLen_;
|
||||
posStart = position;
|
||||
}
|
||||
|
||||
void AutoComplete::SetStopChars(const char *stopChars_) {
|
||||
strncpy(stopChars, stopChars_, sizeof(stopChars));
|
||||
stopChars[sizeof(stopChars) - 1] = '\0';
|
||||
}
|
||||
|
||||
bool AutoComplete::IsStopChar(char ch) {
|
||||
return ch && strchr(stopChars, ch);
|
||||
}
|
||||
|
||||
void AutoComplete::SetFillUpChars(const char *fillUpChars_) {
|
||||
strncpy(fillUpChars, fillUpChars_, sizeof(fillUpChars));
|
||||
fillUpChars[sizeof(fillUpChars) - 1] = '\0';
|
||||
}
|
||||
|
||||
bool AutoComplete::IsFillUpChar(char ch) {
|
||||
return ch && strchr(fillUpChars, ch);
|
||||
}
|
||||
|
||||
void AutoComplete::SetSeparator(char separator_) {
|
||||
separator = separator_;
|
||||
}
|
||||
|
||||
char AutoComplete::GetSeparator() {
|
||||
return separator;
|
||||
}
|
||||
|
||||
void AutoComplete::SetList(const char *list) {
|
||||
lb.Clear();
|
||||
char *words = new char[strlen(list) + 1];
|
||||
if (words) {
|
||||
strcpy(words, list);
|
||||
char *startword = words;
|
||||
int i = 0;
|
||||
for (; words && words[i]; i++) {
|
||||
if (words[i] == separator) {
|
||||
words[i] = '\0';
|
||||
lb.Append(startword);
|
||||
startword = words + i + 1;
|
||||
}
|
||||
}
|
||||
if (startword) {
|
||||
lb.Append(startword);
|
||||
}
|
||||
delete []words;
|
||||
}
|
||||
lb.Sort();
|
||||
}
|
||||
|
||||
void AutoComplete::Show() {
|
||||
lb.Show();
|
||||
lb.Select(0);
|
||||
}
|
||||
|
||||
void AutoComplete::Cancel() {
|
||||
if (lb.Created()) {
|
||||
lb.Destroy();
|
||||
active = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AutoComplete::Move(int delta) {
|
||||
int count = lb.Length();
|
||||
int current = lb.GetSelection();
|
||||
current += delta;
|
||||
if (current >= count)
|
||||
current = count - 1;
|
||||
if (current < 0)
|
||||
current = 0;
|
||||
lb.Select(current);
|
||||
}
|
||||
|
||||
void AutoComplete::Select(const char *word) {
|
||||
int pos = lb.Find(word);
|
||||
//Platform::DebugPrintf("Autocompleting at <%s> %d\n", wordCurrent, pos);
|
||||
if (pos != -1)
|
||||
lb.Select(pos);
|
||||
}
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// AutoComplete.h - defines the auto completion list box
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef AUTOCOMPLETE_H
|
||||
#define AUTOCOMPLETE_H
|
||||
|
||||
class AutoComplete {
|
||||
bool active;
|
||||
char stopChars[256];
|
||||
char fillUpChars[256];
|
||||
char separator;
|
||||
public:
|
||||
bool ignoreCase;
|
||||
bool chooseSingle;
|
||||
ListBox lb;
|
||||
int posStart;
|
||||
int startLen;
|
||||
// Should autocompletion be canceled if editor's currentPos <= startPos?
|
||||
bool cancelAtStartPos;
|
||||
|
||||
AutoComplete();
|
||||
~AutoComplete();
|
||||
|
||||
// Is the auto completion list displayed?
|
||||
bool Active();
|
||||
|
||||
// Display the auto completion list positioned to be near a character position
|
||||
void Start(Window &parent, int ctrlID, int position, int startLen_);
|
||||
|
||||
// The stop chars are characters which, when typed, cause the auto completion list to disappear
|
||||
void SetStopChars(const char *stopChars_);
|
||||
bool IsStopChar(char ch);
|
||||
|
||||
// The fillup chars are characters which, when typed, fill up the selected word
|
||||
void SetFillUpChars(const char *fillUpChars_);
|
||||
bool IsFillUpChar(char ch);
|
||||
|
||||
// The separator character is used when interpreting the list in SetList
|
||||
void SetSeparator(char separator_);
|
||||
char GetSeparator();
|
||||
|
||||
// The list string contains a sequence of words separated by the separator character
|
||||
void SetList(const char *list);
|
||||
|
||||
void Show();
|
||||
void Cancel();
|
||||
|
||||
// Move the current list element by delta, scrolling appropriately
|
||||
void Move(int delta);
|
||||
|
||||
// Select a list element that starts with word as the current element
|
||||
void Select(const char *word);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,169 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// CallTip.cxx - code for displaying call tips
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "Scintilla.h"
|
||||
#include "CallTip.h"
|
||||
|
||||
CallTip::CallTip() {
|
||||
wCallTip = 0;
|
||||
inCallTipMode = false;
|
||||
posStartCallTip = 0;
|
||||
val = 0;
|
||||
startHighlight = 0;
|
||||
endHighlight = 0;
|
||||
|
||||
colourBG.desired = Colour(0xff, 0xff, 0xff);
|
||||
colourUnSel.desired = Colour(0x80, 0x80, 0x80);
|
||||
colourSel.desired = Colour(0, 0, 0x80);
|
||||
colourShade.desired = Colour(0, 0, 0);
|
||||
colourLight.desired = Colour(0xc0, 0xc0, 0xc0);
|
||||
}
|
||||
|
||||
CallTip::~CallTip() {
|
||||
wCallTip.Destroy();
|
||||
delete []val;
|
||||
val = 0;
|
||||
}
|
||||
|
||||
void CallTip::RefreshColourPalette(Palette &pal, bool want) {
|
||||
pal.WantFind(colourBG, want);
|
||||
pal.WantFind(colourUnSel, want);
|
||||
pal.WantFind(colourSel, want);
|
||||
pal.WantFind(colourShade, want);
|
||||
pal.WantFind(colourLight, want);
|
||||
}
|
||||
|
||||
void CallTip::PaintCT(Surface *surfaceWindow) {
|
||||
if (!val)
|
||||
return;
|
||||
PRectangle rcClientPos = wCallTip.GetClientPosition();
|
||||
PRectangle rcClientSize(0, 0, rcClientPos.right - rcClientPos.left,
|
||||
rcClientPos.bottom - rcClientPos.top);
|
||||
PRectangle rcClient(1, 1, rcClientSize.right - 1, rcClientSize.bottom - 1);
|
||||
|
||||
surfaceWindow->FillRectangle(rcClient, colourBG.allocated);
|
||||
// To make a nice small call tip window, it is only sized to fit most normal characters without accents
|
||||
int lineHeight = surfaceWindow->Height(font);
|
||||
int ascent = surfaceWindow->Ascent(font) - surfaceWindow->InternalLeading(font);
|
||||
|
||||
// For each line...
|
||||
// Draw the definition in three parts: before highlight, highlighted, after highlight
|
||||
int ytext = rcClient.top + ascent + 1;
|
||||
char *chunkVal = val;
|
||||
bool moreChunks = true;
|
||||
while (moreChunks) {
|
||||
char *chunkEnd = strchr(chunkVal, '\n');
|
||||
if (chunkEnd == NULL) {
|
||||
chunkEnd = chunkVal + strlen(chunkVal);
|
||||
moreChunks = false;
|
||||
}
|
||||
int chunkOffset = chunkVal - val;
|
||||
int chunkLength = chunkEnd - chunkVal;
|
||||
int chunkEndOffset = chunkOffset + chunkLength;
|
||||
int thisStartHighlight = Platform::Maximum(startHighlight, chunkOffset);
|
||||
thisStartHighlight = Platform::Minimum(thisStartHighlight, chunkEndOffset);
|
||||
thisStartHighlight -= chunkOffset;
|
||||
int thisEndHighlight = Platform::Maximum(endHighlight, chunkOffset);
|
||||
thisEndHighlight = Platform::Minimum(thisEndHighlight, chunkEndOffset);
|
||||
thisEndHighlight -= chunkOffset;
|
||||
int x = 5;
|
||||
int xEnd = x + surfaceWindow->WidthText(font, chunkVal, thisStartHighlight);
|
||||
rcClient.left = x;
|
||||
rcClient.top = ytext - ascent - 1;
|
||||
rcClient.right = xEnd;
|
||||
surfaceWindow->DrawText(rcClient, font, ytext,
|
||||
chunkVal, thisStartHighlight,
|
||||
colourUnSel.allocated, colourBG.allocated);
|
||||
x = xEnd;
|
||||
|
||||
xEnd = x + surfaceWindow->WidthText(font, chunkVal + thisStartHighlight,
|
||||
thisEndHighlight - thisStartHighlight);
|
||||
rcClient.top = ytext;
|
||||
rcClient.left = x;
|
||||
rcClient.right = xEnd;
|
||||
surfaceWindow->DrawText(rcClient, font, ytext,
|
||||
chunkVal + thisStartHighlight, thisEndHighlight - thisStartHighlight,
|
||||
colourSel.allocated, colourBG.allocated);
|
||||
x = xEnd;
|
||||
|
||||
xEnd = x + surfaceWindow->WidthText(font, chunkVal + thisEndHighlight,
|
||||
chunkLength - thisEndHighlight);
|
||||
rcClient.left = x;
|
||||
rcClient.right = xEnd;
|
||||
surfaceWindow->DrawText(rcClient, font, ytext,
|
||||
chunkVal + thisEndHighlight, chunkLength - thisEndHighlight,
|
||||
colourUnSel.allocated, colourBG.allocated);
|
||||
chunkVal = chunkEnd + 1;
|
||||
ytext += lineHeight;
|
||||
}
|
||||
// Draw a raised border around the edges of the window
|
||||
surfaceWindow->MoveTo(0, rcClientSize.bottom - 1);
|
||||
surfaceWindow->PenColour(colourShade.allocated);
|
||||
surfaceWindow->LineTo(rcClientSize.right - 1, rcClientSize.bottom - 1);
|
||||
surfaceWindow->LineTo(rcClientSize.right - 1, 0);
|
||||
surfaceWindow->PenColour(colourLight.allocated);
|
||||
surfaceWindow->LineTo(0, 0);
|
||||
surfaceWindow->LineTo(0, rcClientSize.bottom - 1);
|
||||
}
|
||||
|
||||
PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
|
||||
const char *faceName, int size) {
|
||||
Surface surfaceMeasure;
|
||||
surfaceMeasure.Init();
|
||||
int deviceHeight = (size * surfaceMeasure.LogPixelsY()) / 72;
|
||||
font.Create(faceName, SC_CHARSET_DEFAULT, deviceHeight, false, false);
|
||||
if (val)
|
||||
delete []val;
|
||||
val = new char[strlen(defn) + 1];
|
||||
if (!val)
|
||||
return PRectangle();
|
||||
strcpy(val, defn);
|
||||
startHighlight = 0;
|
||||
endHighlight = 0;
|
||||
inCallTipMode = true;
|
||||
posStartCallTip = pos;
|
||||
// Look for multiple lines in the text
|
||||
// Only support \n here - simply means container must avoid \r!
|
||||
int width = 0;
|
||||
int numLines = 1;
|
||||
const char *newline;
|
||||
const char *look = val;
|
||||
while ((newline = strchr(look, '\n')) != NULL) {
|
||||
int thisWidth = surfaceMeasure.WidthText(font, look, newline - look);
|
||||
width = Platform::Maximum(width, thisWidth);
|
||||
look = newline + 1;
|
||||
numLines++;
|
||||
}
|
||||
int lastWidth = surfaceMeasure.WidthText(font, look, strlen(look));
|
||||
width = Platform::Maximum(width, lastWidth) + 10;
|
||||
int lineHeight = surfaceMeasure.Height(font);
|
||||
// Extra line for border and an empty line at top and bottom
|
||||
int height = lineHeight * numLines - surfaceMeasure.InternalLeading(font) + 2 + 2;
|
||||
return PRectangle(pt.x -5, pt.y + lineHeight + 1, pt.x + width - 5, pt.y + lineHeight + 1 + height);
|
||||
}
|
||||
|
||||
|
||||
void CallTip::CallTipCancel() {
|
||||
inCallTipMode = false;
|
||||
if (wCallTip.Created()) {
|
||||
wCallTip.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
void CallTip::SetHighlight(int start, int end) {
|
||||
// Avoid flashing by checking something has really changed
|
||||
if ((start != startHighlight) || (end != endHighlight)) {
|
||||
startHighlight = start;
|
||||
endHighlight = end;
|
||||
if (wCallTip.Created()) {
|
||||
wCallTip.InvalidateAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// CallTip.h - interface to the call tip control
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef CALLTIP_H
|
||||
#define CALLTIP_H
|
||||
|
||||
class CallTip {
|
||||
int startHighlight;
|
||||
int endHighlight;
|
||||
char *val;
|
||||
Font font;
|
||||
// Private so CallTip objects can not be copied
|
||||
CallTip(const CallTip &) {}
|
||||
CallTip &operator=(const CallTip &) { return *this; }
|
||||
public:
|
||||
Window wCallTip;
|
||||
Window wDraw;
|
||||
bool inCallTipMode;
|
||||
int posStartCallTip;
|
||||
ColourPair colourBG;
|
||||
ColourPair colourUnSel;
|
||||
ColourPair colourSel;
|
||||
ColourPair colourShade;
|
||||
ColourPair colourLight;
|
||||
|
||||
CallTip();
|
||||
~CallTip();
|
||||
|
||||
// Claim or accept palette entries for the colours required to paint a calltip
|
||||
void RefreshColourPalette(Palette &pal, bool want);
|
||||
|
||||
void PaintCT(Surface *surfaceWindow);
|
||||
|
||||
// Setup the calltip and return a rectangle of the area required
|
||||
PRectangle CallTipStart(int pos, Point pt, const char *defn,
|
||||
const char *faceName, int size);
|
||||
|
||||
void CallTipCancel();
|
||||
|
||||
// Set a range of characters to be displayed in a highlight style.
|
||||
// Commonly used to highlight the current parameter.
|
||||
void SetHighlight(int start, int end);
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,229 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// CellBuffer.h - manages the text of the document
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef CELLBUFFER_H
|
||||
#define CELLBUFFER_H
|
||||
|
||||
// This holds the marker identifier and the marker type to display.
|
||||
// MarkerHandleNumbers are members of lists.
|
||||
struct MarkerHandleNumber {
|
||||
int handle;
|
||||
int number;
|
||||
MarkerHandleNumber *next;
|
||||
};
|
||||
|
||||
// A marker handle set contains any number of MarkerHandleNumbers
|
||||
class MarkerHandleSet {
|
||||
MarkerHandleNumber *root;
|
||||
public:
|
||||
MarkerHandleSet();
|
||||
~MarkerHandleSet();
|
||||
int Length();
|
||||
int NumberFromHandle(int handle);
|
||||
int MarkValue(); // Bit set of marker numbers
|
||||
bool Contains(int handle);
|
||||
bool InsertHandle(int handle, int markerNum);
|
||||
void RemoveHandle(int handle);
|
||||
void RemoveNumber(int markerNum);
|
||||
void CombineWith(MarkerHandleSet *other);
|
||||
};
|
||||
|
||||
// Each line stores the starting position of the first character of the line in the cell buffer
|
||||
// and potentially a marker handle set. Often a line will not have any attached markers.
|
||||
struct LineData {
|
||||
int startPosition;
|
||||
MarkerHandleSet *handleSet;
|
||||
LineData() : startPosition(0), handleSet(0) {
|
||||
}
|
||||
};
|
||||
|
||||
// The line vector contains information about each of the lines in a cell buffer.
|
||||
class LineVector {
|
||||
public:
|
||||
enum { growSize = 4000 };
|
||||
int lines;
|
||||
LineData *linesData;
|
||||
int size;
|
||||
int *levels;
|
||||
int sizeLevels;
|
||||
|
||||
// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big.
|
||||
int handleCurrent;
|
||||
|
||||
LineVector();
|
||||
~LineVector();
|
||||
void Init();
|
||||
|
||||
void Expand(int sizeNew);
|
||||
void ExpandLevels(int sizeNew=-1);
|
||||
void ClearLevels();
|
||||
void InsertValue(int pos, int value);
|
||||
void SetValue(int pos, int value);
|
||||
void Remove(int pos);
|
||||
int LineFromPosition(int pos);
|
||||
|
||||
int AddMark(int line, int marker);
|
||||
void MergeMarkers(int pos);
|
||||
void DeleteMark(int line, int markerNum);
|
||||
void DeleteMarkFromHandle(int markerHandle);
|
||||
int LineFromHandle(int markerHandle);
|
||||
};
|
||||
|
||||
// Actions are used to store all the information required to perform one undo/redo step.
|
||||
enum actionType { insertAction, removeAction, startAction };
|
||||
|
||||
class Action {
|
||||
public:
|
||||
actionType at;
|
||||
int position;
|
||||
char *data;
|
||||
int lenData;
|
||||
bool mayCoalesce;
|
||||
|
||||
Action();
|
||||
~Action();
|
||||
void Create(actionType at_, int position_=0, char *data_=0, int lenData_=0, bool mayCoalesce_=true);
|
||||
void Destroy();
|
||||
void Grab(Action *source);
|
||||
};
|
||||
|
||||
class UndoHistory {
|
||||
Action *actions;
|
||||
int lenActions;
|
||||
int maxAction;
|
||||
int currentAction;
|
||||
int undoSequenceDepth;
|
||||
int savePoint;
|
||||
|
||||
void EnsureUndoRoom();
|
||||
|
||||
public:
|
||||
UndoHistory();
|
||||
~UndoHistory();
|
||||
|
||||
void AppendAction(actionType at, int position, char *data, int length);
|
||||
|
||||
void BeginUndoAction();
|
||||
void EndUndoAction();
|
||||
void DropUndoSequence();
|
||||
void DeleteUndoHistory();
|
||||
|
||||
// The save point is a marker in the undo stack where the container has stated that
|
||||
// the buffer was saved. Undo and redo can move over the save point.
|
||||
void SetSavePoint();
|
||||
bool IsSavePoint() const;
|
||||
|
||||
// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
|
||||
// called that many times. Similarly for redo.
|
||||
bool CanUndo() const;
|
||||
int StartUndo();
|
||||
const Action &GetUndoStep() const;
|
||||
void CompletedUndoStep();
|
||||
bool CanRedo() const;
|
||||
int StartRedo();
|
||||
const Action &GetRedoStep() const;
|
||||
void CompletedRedoStep();
|
||||
};
|
||||
|
||||
// Holder for an expandable array of characters that supports undo and line markers
|
||||
// Based on article "Data Structures in a Bit-Mapped Text Editor"
|
||||
// by Wilfred J. Hansen, Byte January 1987, page 183
|
||||
class CellBuffer {
|
||||
private:
|
||||
char *body;
|
||||
int size;
|
||||
int length;
|
||||
int part1len;
|
||||
int gaplen;
|
||||
char *part2body;
|
||||
bool readOnly;
|
||||
|
||||
bool collectingUndo;
|
||||
UndoHistory uh;
|
||||
|
||||
LineVector lv;
|
||||
|
||||
SVector lineStates;
|
||||
|
||||
void GapTo(int position);
|
||||
void RoomFor(int insertionLength);
|
||||
|
||||
inline char ByteAt(int position);
|
||||
void SetByteAt(int position, char ch);
|
||||
|
||||
public:
|
||||
|
||||
CellBuffer(int initialLength = 4000);
|
||||
~CellBuffer();
|
||||
|
||||
// Retrieving positions outside the range of the buffer works and returns 0
|
||||
char CharAt(int position);
|
||||
void GetCharRange(char *buffer, int position, int lengthRetrieve);
|
||||
char StyleAt(int position);
|
||||
|
||||
int ByteLength();
|
||||
int Length();
|
||||
int Lines();
|
||||
int LineStart(int line);
|
||||
int LineFromPosition(int pos) { return lv.LineFromPosition(pos); }
|
||||
const char *InsertString(int position, char *s, int insertLength);
|
||||
void InsertCharStyle(int position, char ch, char style);
|
||||
|
||||
// Setting styles for positions outside the range of the buffer is safe and has no effect.
|
||||
// True is returned if the style of a character changed.
|
||||
bool SetStyleAt(int position, char style, char mask='\377');
|
||||
bool SetStyleFor(int position, int length, char style, char mask);
|
||||
|
||||
const char *DeleteChars(int position, int deleteLength);
|
||||
|
||||
bool IsReadOnly();
|
||||
void SetReadOnly(bool set);
|
||||
|
||||
// The save point is a marker in the undo stack where the container has stated that
|
||||
// the buffer was saved. Undo and redo can move over the save point.
|
||||
void SetSavePoint();
|
||||
bool IsSavePoint();
|
||||
|
||||
// Line marker functions
|
||||
int AddMark(int line, int markerNum);
|
||||
void DeleteMark(int line, int markerNum);
|
||||
void DeleteMarkFromHandle(int markerHandle);
|
||||
int GetMark(int line);
|
||||
void DeleteAllMarks(int markerNum);
|
||||
int LineFromHandle(int markerHandle);
|
||||
|
||||
// Without undo
|
||||
void BasicInsertString(int position, char *s, int insertLength);
|
||||
void BasicDeleteChars(int position, int deleteLength);
|
||||
|
||||
bool SetUndoCollection(bool collectUndo);
|
||||
bool IsCollectingUndo();
|
||||
void BeginUndoAction();
|
||||
void EndUndoAction();
|
||||
void DeleteUndoHistory();
|
||||
|
||||
// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
|
||||
// called that many times. Similarly for redo.
|
||||
bool CanUndo();
|
||||
int StartUndo();
|
||||
const Action &GetUndoStep() const;
|
||||
void PerformUndoStep();
|
||||
bool CanRedo();
|
||||
int StartRedo();
|
||||
const Action &GetRedoStep() const;
|
||||
void PerformRedoStep();
|
||||
|
||||
int SetLineState(int line, int state);
|
||||
int GetLineState(int line);
|
||||
int GetMaxLineState();
|
||||
|
||||
int SetLevel(int line, int level);
|
||||
int GetLevel(int line);
|
||||
void ClearLevels();
|
||||
};
|
||||
|
||||
#define CELL_SIZE 2
|
||||
|
||||
#endif
|
||||
@@ -1,208 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// ContractionState.cxx - manages visibility of lines for folding
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "ContractionState.h"
|
||||
|
||||
OneLine::OneLine() {
|
||||
displayLine = 0;
|
||||
docLine = 0;
|
||||
visible = true;
|
||||
expanded = true;
|
||||
}
|
||||
|
||||
ContractionState::ContractionState() {
|
||||
lines = 0;
|
||||
size = 0;
|
||||
linesInDoc = 1;
|
||||
linesInDisplay = 1;
|
||||
valid = false;
|
||||
}
|
||||
|
||||
ContractionState::~ContractionState() {
|
||||
Clear();
|
||||
}
|
||||
|
||||
void ContractionState::MakeValid() const {
|
||||
if (!valid) {
|
||||
// Could be cleverer by keeping the index of the last still valid entry
|
||||
// rather than invalidating all.
|
||||
int lineDisplay = 0;
|
||||
for (int line=0; line<linesInDoc; line++) {
|
||||
lines[line].displayLine = lineDisplay;
|
||||
if (lines[line].visible) {
|
||||
lines[lineDisplay].docLine = line;
|
||||
lineDisplay++;
|
||||
}
|
||||
}
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ContractionState::Clear() {
|
||||
delete []lines;
|
||||
lines = 0;
|
||||
size = 0;
|
||||
linesInDoc = 1;
|
||||
linesInDisplay = 1;
|
||||
}
|
||||
|
||||
int ContractionState::LinesInDoc() const {
|
||||
return linesInDoc;
|
||||
}
|
||||
|
||||
int ContractionState::LinesDisplayed() const {
|
||||
return linesInDisplay;
|
||||
}
|
||||
|
||||
int ContractionState::DisplayFromDoc(int lineDoc) const {
|
||||
if (size == 0) {
|
||||
return lineDoc;
|
||||
}
|
||||
MakeValid();
|
||||
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
|
||||
return lines[lineDoc].displayLine;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ContractionState::DocFromDisplay(int lineDisplay) const {
|
||||
if (lineDisplay <= 0)
|
||||
return 0;
|
||||
if (lineDisplay >= linesInDisplay)
|
||||
return linesInDoc-1;
|
||||
if (size == 0)
|
||||
return lineDisplay;
|
||||
MakeValid();
|
||||
return lines[lineDisplay].docLine;
|
||||
}
|
||||
|
||||
void ContractionState::Grow(int sizeNew) {
|
||||
OneLine *linesNew = new OneLine[sizeNew];
|
||||
if (linesNew) {
|
||||
int i = 0;
|
||||
for (; i < size; i++) {
|
||||
linesNew[i] = lines[i];
|
||||
}
|
||||
for (; i < sizeNew; i++) {
|
||||
linesNew[i].displayLine = i;
|
||||
}
|
||||
delete []lines;
|
||||
lines = linesNew;
|
||||
size = sizeNew;
|
||||
valid = false;
|
||||
} else {
|
||||
Platform::DebugPrintf("No memory available\n");
|
||||
// TODO: Blow up
|
||||
}
|
||||
}
|
||||
|
||||
void ContractionState::InsertLines(int lineDoc, int lineCount) {
|
||||
if (size == 0) {
|
||||
linesInDoc += lineCount;
|
||||
linesInDisplay += lineCount;
|
||||
return;
|
||||
}
|
||||
//Platform::DebugPrintf("InsertLine[%d] = %d\n", lineDoc);
|
||||
if ((linesInDoc + lineCount + 2) >= size) {
|
||||
Grow(linesInDoc + lineCount + growSize);
|
||||
}
|
||||
linesInDoc += lineCount;
|
||||
linesInDisplay += lineCount;
|
||||
for (int i = linesInDoc; i >= lineDoc + lineCount; i--) {
|
||||
lines[i].visible = lines[i - lineCount].visible;
|
||||
lines[i].expanded = lines[i - lineCount].expanded;
|
||||
}
|
||||
for (int d=0;d<lineCount;d++) {
|
||||
lines[lineDoc+d].visible = true; // Should inherit visibility from context ?
|
||||
lines[lineDoc+d].expanded = true;
|
||||
}
|
||||
valid = false;
|
||||
}
|
||||
|
||||
void ContractionState::DeleteLines(int lineDoc, int lineCount) {
|
||||
if (size == 0) {
|
||||
linesInDoc -= lineCount;
|
||||
linesInDisplay -= lineCount;
|
||||
return;
|
||||
}
|
||||
int deltaDisplayed = 0;
|
||||
for (int d=0;d<lineCount;d++) {
|
||||
if (lines[lineDoc+d].visible)
|
||||
deltaDisplayed--;
|
||||
}
|
||||
for (int i = lineDoc; i < linesInDoc-lineCount; i++) {
|
||||
if (i != 0) // Line zero is always visible
|
||||
lines[i].visible = lines[i + lineCount].visible;
|
||||
lines[i].expanded = lines[i + lineCount].expanded;
|
||||
}
|
||||
linesInDoc -= lineCount;
|
||||
linesInDisplay += deltaDisplayed;
|
||||
valid = false;
|
||||
}
|
||||
|
||||
bool ContractionState::GetVisible(int lineDoc) const {
|
||||
if (size == 0)
|
||||
return true;
|
||||
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
|
||||
return lines[lineDoc].visible;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible) {
|
||||
if (lineDocStart == 0)
|
||||
lineDocStart++;
|
||||
if (lineDocStart > lineDocEnd)
|
||||
return false;
|
||||
if (size == 0) {
|
||||
Grow(linesInDoc + growSize);
|
||||
}
|
||||
// TODO: modify docLine members to mirror displayLine
|
||||
int delta = 0;
|
||||
// Change lineDocs
|
||||
if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < linesInDoc)) {
|
||||
for (int line=lineDocStart; line <= lineDocEnd; line++) {
|
||||
if (lines[line].visible != visible) {
|
||||
delta += visible ? 1 : -1;
|
||||
lines[line].visible = visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
linesInDisplay += delta;
|
||||
valid = false;
|
||||
return delta != 0;
|
||||
}
|
||||
|
||||
bool ContractionState::GetExpanded(int lineDoc) const {
|
||||
if (size == 0)
|
||||
return true;
|
||||
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
|
||||
return lines[lineDoc].expanded;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ContractionState::SetExpanded(int lineDoc, bool expanded) {
|
||||
if (size == 0) {
|
||||
Grow(linesInDoc + growSize);
|
||||
}
|
||||
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
|
||||
if (lines[lineDoc].expanded != expanded) {
|
||||
lines[lineDoc].expanded = expanded;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ContractionState::ShowAll() {
|
||||
delete []lines;
|
||||
lines = 0;
|
||||
size = 0;
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
// Scintilla source code edit control
|
||||
// ContractionState.h - manages visibility of lines for folding
|
||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef CONTRACTIONSTATE_H
|
||||
#define CONTRACTIONSTATE_H
|
||||
|
||||
class OneLine {
|
||||
public:
|
||||
int displayLine; // position within set of visible lines
|
||||
int docLine; // inverse of displayLine
|
||||
bool visible;
|
||||
bool expanded;
|
||||
|
||||
OneLine();
|
||||
virtual ~OneLine() {}
|
||||
};
|
||||
|
||||
class ContractionState {
|
||||
void Grow(int sizeNew);
|
||||
enum { growSize = 4000 };
|
||||
int linesInDoc;
|
||||
int linesInDisplay;
|
||||
mutable OneLine *lines;
|
||||
int size;
|
||||
mutable bool valid;
|
||||
void MakeValid() const;
|
||||
public:
|
||||
ContractionState();
|
||||
virtual ~ContractionState();
|
||||
|
||||
void Clear();
|
||||
|
||||
int LinesInDoc() const;
|
||||
int LinesDisplayed() const;
|
||||
int DisplayFromDoc(int lineDoc) const;
|
||||
int DocFromDisplay(int lineDisplay) const;
|
||||
|
||||
void InsertLines(int lineDoc, int lineCount);
|
||||
void DeleteLines(int lineDoc, int lineCount);
|
||||
|
||||
bool GetVisible(int lineDoc) const;
|
||||
bool SetVisible(int lineDocStart, int lineDocEnd, bool visible);
|
||||
|
||||
bool GetExpanded(int lineDoc) const;
|
||||
bool SetExpanded(int lineDoc, bool expanded);
|
||||
|
||||
void ShowAll();
|
||||
};
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user