Update Scintilla to 3.5.0 pre-release
This commit is contained in:
parent
593b9dd2c9
commit
d77fe4c6b7
@ -97,6 +97,10 @@ src/Document.cxx \
|
||||
src/Document.h \
|
||||
src/Editor.cxx \
|
||||
src/Editor.h \
|
||||
src/EditModel.cxx \
|
||||
src/EditModel.h \
|
||||
src/EditView.cxx \
|
||||
src/EditView.h \
|
||||
src/ExternalLexer.cxx \
|
||||
src/ExternalLexer.h \
|
||||
src/FontQuality.h \
|
||||
@ -106,6 +110,8 @@ src/KeyMap.cxx \
|
||||
src/KeyMap.h \
|
||||
src/LineMarker.cxx \
|
||||
src/LineMarker.h \
|
||||
src/MarginView.cxx \
|
||||
src/MarginView.h \
|
||||
src/Partitioning.h \
|
||||
src/PerLine.cxx \
|
||||
src/PerLine.h \
|
||||
|
@ -527,6 +527,7 @@ void SurfaceImpl::Release() {
|
||||
}
|
||||
|
||||
bool SurfaceImpl::Initialised() {
|
||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 8, 0)
|
||||
if (inited && context) {
|
||||
if (cairo_status(context) == CAIRO_STATUS_SUCCESS) {
|
||||
// Even when status is success, the target surface may have been
|
||||
@ -543,6 +544,7 @@ bool SurfaceImpl::Initialised() {
|
||||
}
|
||||
return cairo_status(context) == CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
return inited;
|
||||
}
|
||||
|
||||
@ -1086,6 +1088,10 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION
|
||||
}
|
||||
clusterStart = clusterEnd;
|
||||
}
|
||||
while (i < lenPositions) {
|
||||
// If something failed, fill in rest of the positions
|
||||
positions[i++] = clusterStart;
|
||||
}
|
||||
PLATFORM_ASSERT(i == lenPositions);
|
||||
}
|
||||
}
|
||||
@ -1799,6 +1805,7 @@ void ListBoxX::Select(int n) {
|
||||
}
|
||||
|
||||
int ListBoxX::GetSelection() {
|
||||
int index = -1;
|
||||
GtkTreeIter iter;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeSelection *selection;
|
||||
@ -1808,9 +1815,10 @@ int ListBoxX::GetSelection() {
|
||||
int *indices = gtk_tree_path_get_indices(path);
|
||||
// Don't free indices.
|
||||
if (indices)
|
||||
return indices[0];
|
||||
index = indices[0];
|
||||
gtk_tree_path_free(path);
|
||||
}
|
||||
return -1;
|
||||
return index;
|
||||
}
|
||||
|
||||
int ListBoxX::Find(const char *prefix) {
|
||||
|
@ -57,9 +57,13 @@
|
||||
#include "UniConversion.h"
|
||||
#include "Selection.h"
|
||||
#include "PositionCache.h"
|
||||
#include "EditModel.h"
|
||||
#include "MarginView.h"
|
||||
#include "EditView.h"
|
||||
#include "Editor.h"
|
||||
#include "AutoComplete.h"
|
||||
#include "ScintillaBase.h"
|
||||
#include "UnicodeFromUTF8.h"
|
||||
|
||||
#ifdef SCI_LEXER
|
||||
#include "ExternalLexer.h"
|
||||
@ -186,13 +190,23 @@ public: // Public for scintilla_send_message
|
||||
virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
|
||||
private:
|
||||
virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
|
||||
virtual void SetTicking(bool on);
|
||||
struct TimeThunk {
|
||||
TickReason reason;
|
||||
ScintillaGTK *scintilla;
|
||||
guint timer;
|
||||
TimeThunk() : reason(tickCaret), scintilla(NULL), timer(0) {}
|
||||
};
|
||||
TimeThunk timers[tickDwell+1];
|
||||
virtual bool FineTickerAvailable();
|
||||
virtual bool FineTickerRunning(TickReason reason);
|
||||
virtual void FineTickerStart(TickReason reason, int millis, int tolerance);
|
||||
virtual void FineTickerCancel(TickReason reason);
|
||||
virtual bool SetIdle(bool on);
|
||||
virtual void SetMouseCapture(bool on);
|
||||
virtual bool HaveMouseCapture();
|
||||
virtual bool PaintContains(PRectangle rc);
|
||||
void FullPaint();
|
||||
virtual PRectangle GetClientRectangle();
|
||||
virtual PRectangle GetClientRectangle() const;
|
||||
virtual void ScrollText(int linesToMove);
|
||||
virtual void SetVerticalScrollPos();
|
||||
virtual void SetHorizontalScrollPos();
|
||||
@ -280,6 +294,9 @@ private:
|
||||
static void Commit(GtkIMContext *context, char *str, ScintillaGTK *sciThis);
|
||||
void PreeditChangedThis();
|
||||
static void PreeditChanged(GtkIMContext *context, ScintillaGTK *sciThis);
|
||||
|
||||
bool KoreanIME();
|
||||
|
||||
static void StyleSetText(GtkWidget *widget, GtkStyle *previous, void*);
|
||||
static void RealizeText(GtkWidget *widget, void*);
|
||||
static void Destroy(GObject *object);
|
||||
@ -300,7 +317,7 @@ private:
|
||||
gint x, gint y, GtkSelectionData *selection_data, guint info, guint time);
|
||||
static void DragDataGet(GtkWidget *widget, GdkDragContext *context,
|
||||
GtkSelectionData *selection_data, guint info, guint time);
|
||||
static gboolean TimeOut(ScintillaGTK *sciThis);
|
||||
static gboolean TimeOut(TimeThunk *tt);
|
||||
static gboolean IdleCallback(ScintillaGTK *sciThis);
|
||||
static gboolean StyleIdle(ScintillaGTK *sciThis);
|
||||
virtual void QueueIdleWork(WorkNeeded::workItems items, int upTo);
|
||||
@ -624,22 +641,37 @@ void ScintillaGTK::MainForAll(GtkContainer *container, gboolean include_internal
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class PreEditString {
|
||||
public:
|
||||
gchar *str;
|
||||
gint cursor_pos;
|
||||
PangoAttrList *attrs;
|
||||
|
||||
PreEditString(GtkIMContext *im_context) {
|
||||
gtk_im_context_get_preedit_string(im_context, &str, &attrs, &cursor_pos);
|
||||
}
|
||||
~PreEditString() {
|
||||
g_free(str);
|
||||
pango_attr_list_unref(attrs);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
gint ScintillaGTK::FocusInThis(GtkWidget *widget) {
|
||||
try {
|
||||
SetFocusState(true);
|
||||
if (im_context != NULL) {
|
||||
gchar *str = NULL;
|
||||
gint cursor_pos;
|
||||
|
||||
gtk_im_context_get_preedit_string(im_context, &str, NULL, &cursor_pos);
|
||||
PreEditString pes(im_context);
|
||||
if (PWidget(wPreedit) != NULL) {
|
||||
if (strlen(str) > 0) {
|
||||
if (strlen(pes.str) > 0) {
|
||||
gtk_widget_show(PWidget(wPreedit));
|
||||
} else {
|
||||
gtk_widget_hide(PWidget(wPreedit));
|
||||
}
|
||||
}
|
||||
g_free(str);
|
||||
gtk_im_context_focus_in(im_context);
|
||||
}
|
||||
|
||||
@ -829,11 +861,16 @@ void ScintillaGTK::Initialise() {
|
||||
caret.period = 0;
|
||||
}
|
||||
|
||||
SetTicking(true);
|
||||
for (TickReason tr = tickCaret; tr <= tickDwell; tr = static_cast<TickReason>(tr + 1)) {
|
||||
timers[tr].reason = tr;
|
||||
timers[tr].scintilla = this;
|
||||
}
|
||||
}
|
||||
|
||||
void ScintillaGTK::Finalise() {
|
||||
SetTicking(false);
|
||||
for (TickReason tr = tickCaret; tr <= tickDwell; tr = static_cast<TickReason>(tr + 1)) {
|
||||
FineTickerCancel(tr);
|
||||
}
|
||||
ScintillaBase::Finalise();
|
||||
}
|
||||
|
||||
@ -1024,17 +1061,27 @@ sptr_t ScintillaGTK::DefWndProc(unsigned int, uptr_t, sptr_t) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ScintillaGTK::SetTicking(bool on) {
|
||||
if (timer.ticking != on) {
|
||||
timer.ticking = on;
|
||||
if (timer.ticking) {
|
||||
timer.tickerID = reinterpret_cast<TickerID>(g_timeout_add(timer.tickSize,
|
||||
reinterpret_cast<GSourceFunc>(TimeOut), this));
|
||||
} else {
|
||||
g_source_remove(GPOINTER_TO_UINT(timer.tickerID));
|
||||
}
|
||||
/**
|
||||
* Report that this Editor subclass has a working implementation of FineTickerStart.
|
||||
*/
|
||||
bool ScintillaGTK::FineTickerAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ScintillaGTK::FineTickerRunning(TickReason reason) {
|
||||
return timers[reason].timer != 0;
|
||||
}
|
||||
|
||||
void ScintillaGTK::FineTickerStart(TickReason reason, int millis, int /* tolerance */) {
|
||||
FineTickerCancel(reason);
|
||||
timers[reason].timer = g_timeout_add(millis, reinterpret_cast<GSourceFunc>(TimeOut), &timers[reason]);
|
||||
}
|
||||
|
||||
void ScintillaGTK::FineTickerCancel(TickReason reason) {
|
||||
if (timers[reason].timer) {
|
||||
g_source_remove(timers[reason].timer);
|
||||
timers[reason].timer = 0;
|
||||
}
|
||||
timer.ticksToWait = caret.period;
|
||||
}
|
||||
|
||||
bool ScintillaGTK::SetIdle(bool on) {
|
||||
@ -1121,8 +1168,9 @@ void ScintillaGTK::FullPaint() {
|
||||
wText.InvalidateAll();
|
||||
}
|
||||
|
||||
PRectangle ScintillaGTK::GetClientRectangle() {
|
||||
PRectangle rc = wMain.GetClientPosition();
|
||||
PRectangle ScintillaGTK::GetClientRectangle() const {
|
||||
Window &win = const_cast<Window &>(wMain);
|
||||
PRectangle rc = win.GetClientPosition();
|
||||
if (verticalScrollBarVisible)
|
||||
rc.right -= verticalScrollBarWidth;
|
||||
if (horizontalScrollBarVisible && !Wrapping())
|
||||
@ -2220,19 +2268,13 @@ gboolean ScintillaGTK::KeyRelease(GtkWidget *widget, GdkEventKey *event) {
|
||||
|
||||
gboolean ScintillaGTK::DrawPreeditThis(GtkWidget *widget, cairo_t *cr) {
|
||||
try {
|
||||
gchar *str;
|
||||
gint cursor_pos;
|
||||
PangoAttrList *attrs;
|
||||
|
||||
gtk_im_context_get_preedit_string(im_context, &str, &attrs, &cursor_pos);
|
||||
PangoLayout *layout = gtk_widget_create_pango_layout(PWidget(wText), str);
|
||||
pango_layout_set_attributes(layout, attrs);
|
||||
PreEditString pes(im_context);
|
||||
PangoLayout *layout = gtk_widget_create_pango_layout(PWidget(wText), pes.str);
|
||||
pango_layout_set_attributes(layout, pes.attrs);
|
||||
|
||||
cairo_move_to(cr, 0, 0);
|
||||
pango_cairo_show_layout(cr, layout);
|
||||
|
||||
g_free(str);
|
||||
pango_attr_list_unref(attrs);
|
||||
g_object_unref(layout);
|
||||
} catch (...) {
|
||||
errorStatus = SC_STATUS_FAILURE;
|
||||
@ -2248,20 +2290,14 @@ gboolean ScintillaGTK::DrawPreedit(GtkWidget *widget, cairo_t *cr, ScintillaGTK
|
||||
|
||||
gboolean ScintillaGTK::ExposePreeditThis(GtkWidget *widget, GdkEventExpose *ose) {
|
||||
try {
|
||||
gchar *str;
|
||||
gint cursor_pos;
|
||||
PangoAttrList *attrs;
|
||||
|
||||
gtk_im_context_get_preedit_string(im_context, &str, &attrs, &cursor_pos);
|
||||
PangoLayout *layout = gtk_widget_create_pango_layout(PWidget(wText), str);
|
||||
pango_layout_set_attributes(layout, attrs);
|
||||
PreEditString pes(im_context);
|
||||
PangoLayout *layout = gtk_widget_create_pango_layout(PWidget(wText), pes.str);
|
||||
pango_layout_set_attributes(layout, pes.attrs);
|
||||
|
||||
cairo_t *context = gdk_cairo_create(reinterpret_cast<GdkDrawable *>(WindowFromWidget(widget)));
|
||||
cairo_move_to(context, 0, 0);
|
||||
pango_cairo_show_layout(context, layout);
|
||||
cairo_destroy(context);
|
||||
g_free(str);
|
||||
pango_attr_list_unref(attrs);
|
||||
g_object_unref(layout);
|
||||
} catch (...) {
|
||||
errorStatus = SC_STATUS_FAILURE;
|
||||
@ -2275,9 +2311,43 @@ gboolean ScintillaGTK::ExposePreedit(GtkWidget *widget, GdkEventExpose *ose, Sci
|
||||
|
||||
#endif
|
||||
|
||||
bool ScintillaGTK::KoreanIME() {
|
||||
// Warn : for KoreanIME use only.
|
||||
if (pdoc->TentativeActive()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool koreanIME = false;
|
||||
PreEditString utfval(im_context);
|
||||
|
||||
// Only need to check if the first preedit char is Korean.
|
||||
// The rest will be handled in TentativeActive()
|
||||
// which can handle backspace and CJK commons and so forth.
|
||||
|
||||
if (strlen(utfval.str) == 3) { // One hangul char has 3byte.
|
||||
int unicode = UnicodeFromUTF8(reinterpret_cast<unsigned char *>(utfval.str));
|
||||
// Korean character ranges which are used for the first preedit chars.
|
||||
// http://www.programminginkorean.com/programming/hangul-in-unicode/
|
||||
bool HangulJamo = (0x1100 <= unicode && unicode <= 0x11FF);
|
||||
bool HangulCompatibleJamo = (0x3130 <= unicode && unicode <= 0x318F);
|
||||
bool HangulJamoExtendedA = (0xA960 <= unicode && unicode <= 0xA97F);
|
||||
bool HangulJamoExtendedB = (0xD7B0 <= unicode && unicode <= 0xD7FF);
|
||||
bool HangulSyllable = (0xAC00 <= unicode && unicode <= 0xD7A3);
|
||||
koreanIME = (HangulJamo | HangulCompatibleJamo | HangulSyllable
|
||||
| HangulJamoExtendedA | HangulJamoExtendedB);
|
||||
}
|
||||
return koreanIME;
|
||||
}
|
||||
|
||||
void ScintillaGTK::CommitThis(char *utfVal) {
|
||||
try {
|
||||
//~ fprintf(stderr, "Commit '%s'\n", utfVal);
|
||||
if (pdoc->TentativeActive()) {
|
||||
pdoc->TentativeUndo();
|
||||
}
|
||||
|
||||
view.imeCaretBlockOverride = false;
|
||||
|
||||
if (IsUnicodeMode()) {
|
||||
AddCharUTF(utfVal, strlen(utfVal));
|
||||
} else {
|
||||
@ -2285,7 +2355,7 @@ void ScintillaGTK::CommitThis(char *utfVal) {
|
||||
if (*source) {
|
||||
Converter conv(source, "UTF-8", true);
|
||||
if (conv) {
|
||||
char localeVal[4] = "\0\0\0";
|
||||
char localeVal[maxLenInputIME * 2];
|
||||
char *pin = utfVal;
|
||||
size_t inLeft = strlen(utfVal);
|
||||
char *pout = localeVal;
|
||||
@ -2293,15 +2363,14 @@ void ScintillaGTK::CommitThis(char *utfVal) {
|
||||
size_t conversions = conv.Convert(&pin, &inLeft, &pout, &outLeft);
|
||||
if (conversions != ((size_t)(-1))) {
|
||||
*pout = '\0';
|
||||
for (int i = 0; localeVal[i]; i++) {
|
||||
AddChar(localeVal[i]);
|
||||
}
|
||||
AddCharUTF(localeVal, strlen(localeVal));
|
||||
} else {
|
||||
fprintf(stderr, "Conversion failed '%s'\n", utfVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ShowCaretAtCurrentPosition();
|
||||
} catch (...) {
|
||||
errorStatus = SC_STATUS_FAILURE;
|
||||
}
|
||||
@ -2313,36 +2382,99 @@ void ScintillaGTK::Commit(GtkIMContext *, char *str, ScintillaGTK *sciThis) {
|
||||
|
||||
void ScintillaGTK::PreeditChangedThis() {
|
||||
try {
|
||||
gchar *str;
|
||||
PangoAttrList *attrs;
|
||||
gint cursor_pos;
|
||||
gtk_im_context_get_preedit_string(im_context, &str, &attrs, &cursor_pos);
|
||||
if (strlen(str) > 0) {
|
||||
PangoLayout *layout = gtk_widget_create_pango_layout(PWidget(wText), str);
|
||||
pango_layout_set_attributes(layout, attrs);
|
||||
if (KoreanIME()) {
|
||||
// Copy & paste by johnsonj.
|
||||
// Great thanks to
|
||||
// jiniya from http://www.jiniya.net/tt/494 for DBCS input with AddCharUTF().
|
||||
// BLUEnLIVE from http://zockr.tistory.com/1118 for UNDO and inOverstrike.
|
||||
view.imeCaretBlockOverride = false; // If backspace.
|
||||
|
||||
gint w, h;
|
||||
pango_layout_get_pixel_size(layout, &w, &h);
|
||||
g_object_unref(layout);
|
||||
if (pdoc->TentativeActive()) {
|
||||
pdoc->TentativeUndo();
|
||||
} else {
|
||||
// No tentative undo means start of this composition so
|
||||
// fill in any virtual spaces.
|
||||
bool tmpOverstrike = inOverstrike;
|
||||
inOverstrike = false; // Not allowed to be deleted twice.
|
||||
AddCharUTF("", 0);
|
||||
inOverstrike = tmpOverstrike;
|
||||
}
|
||||
|
||||
gint x, y;
|
||||
gdk_window_get_origin(PWindow(wText), &x, &y);
|
||||
PreEditString utfval(im_context);
|
||||
|
||||
Point pt = PointMainCaret();
|
||||
if (pt.x < 0)
|
||||
pt.x = 0;
|
||||
if (pt.y < 0)
|
||||
pt.y = 0;
|
||||
if (strlen(utfval.str) > maxLenInputIME * 3) {
|
||||
return; // Do not allow over 200 chars.
|
||||
}
|
||||
|
||||
gtk_window_move(GTK_WINDOW(PWidget(wPreedit)), x + pt.x, y + pt.y);
|
||||
gtk_window_resize(GTK_WINDOW(PWidget(wPreedit)), w, h);
|
||||
gtk_widget_show(PWidget(wPreedit));
|
||||
gtk_widget_queue_draw_area(PWidget(wPreeditDraw), 0, 0, w, h);
|
||||
} else {
|
||||
gtk_widget_hide(PWidget(wPreedit));
|
||||
char localeVal[maxLenInputIME * 2];
|
||||
char *hanval = (char *)"";
|
||||
|
||||
if (IsUnicodeMode()) {
|
||||
hanval = utfval.str;
|
||||
} else {
|
||||
const char *source = CharacterSetID();
|
||||
if (*source) {
|
||||
Converter conv(source, "UTF-8", true);
|
||||
if (conv) {
|
||||
char *pin = utfval.str;
|
||||
size_t inLeft = strlen(utfval.str);
|
||||
char *pout = localeVal;
|
||||
size_t outLeft = sizeof(localeVal);
|
||||
size_t conversions = conv.Convert(&pin, &inLeft, &pout, &outLeft);
|
||||
if (conversions != ((size_t)(-1))) {
|
||||
*pout = '\0';
|
||||
hanval = localeVal;
|
||||
} else {
|
||||
fprintf(stderr, "Conversion failed '%s'\n", utfval.str);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!pdoc->TentativeActive()) {
|
||||
pdoc->TentativeStart();
|
||||
}
|
||||
|
||||
bool tmpRecordingMacro = recordingMacro;
|
||||
recordingMacro = false;
|
||||
int hanlen = strlen(hanval);
|
||||
AddCharUTF(hanval, hanlen);
|
||||
recordingMacro = tmpRecordingMacro;
|
||||
|
||||
// For block caret which means KoreanIME is in composition.
|
||||
view.imeCaretBlockOverride = true;
|
||||
for (size_t r = 0; r < sel.Count(); r++) {
|
||||
int positionInsert = sel.Range(r).Start().Position();
|
||||
sel.Range(r).caret.SetPosition(positionInsert - hanlen);
|
||||
sel.Range(r).anchor.SetPosition(positionInsert - hanlen);
|
||||
}
|
||||
} else { // Original code follows for other IMEs.
|
||||
PreEditString pes(im_context);
|
||||
if (strlen(pes.str) > 0) {
|
||||
PangoLayout *layout = gtk_widget_create_pango_layout(PWidget(wText), pes.str);
|
||||
pango_layout_set_attributes(layout, pes.attrs);
|
||||
|
||||
gint w, h;
|
||||
pango_layout_get_pixel_size(layout, &w, &h);
|
||||
g_object_unref(layout);
|
||||
|
||||
gint x, y;
|
||||
gdk_window_get_origin(PWindow(wText), &x, &y);
|
||||
|
||||
Point pt = PointMainCaret();
|
||||
if (pt.x < 0)
|
||||
pt.x = 0;
|
||||
if (pt.y < 0)
|
||||
pt.y = 0;
|
||||
|
||||
gtk_window_move(GTK_WINDOW(PWidget(wPreedit)), x + pt.x, y + pt.y);
|
||||
gtk_window_resize(GTK_WINDOW(PWidget(wPreedit)), w, h);
|
||||
gtk_widget_show(PWidget(wPreedit));
|
||||
gtk_widget_queue_draw_area(PWidget(wPreeditDraw), 0, 0, w, h);
|
||||
} else {
|
||||
gtk_widget_hide(PWidget(wPreedit));
|
||||
}
|
||||
}
|
||||
g_free(str);
|
||||
pango_attr_list_unref(attrs);
|
||||
} catch (...) {
|
||||
errorStatus = SC_STATUS_FAILURE;
|
||||
}
|
||||
@ -2711,8 +2843,8 @@ void ScintillaGTK::DragDataGet(GtkWidget *widget, GdkDragContext *context,
|
||||
}
|
||||
}
|
||||
|
||||
int ScintillaGTK::TimeOut(ScintillaGTK *sciThis) {
|
||||
sciThis->Tick();
|
||||
int ScintillaGTK::TimeOut(TimeThunk *tt) {
|
||||
tt->scintilla->TickFor(tt->reason);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -127,6 +127,7 @@
|
||||
#define SCLEX_DMAP 112
|
||||
#define SCLEX_AS 113
|
||||
#define SCLEX_DMIS 114
|
||||
#define SCLEX_REGISTRY 115
|
||||
#define SCLEX_AUTOMATIC 1000
|
||||
#define SCE_P_DEFAULT 0
|
||||
#define SCE_P_COMMENTLINE 1
|
||||
@ -906,6 +907,7 @@
|
||||
#define SCE_KIX_KEYWORD 7
|
||||
#define SCE_KIX_FUNCTIONS 8
|
||||
#define SCE_KIX_OPERATOR 9
|
||||
#define SCE_KIX_COMMENTSTREAM 10
|
||||
#define SCE_KIX_IDENTIFIER 31
|
||||
#define SCE_GC_DEFAULT 0
|
||||
#define SCE_GC_COMMENTLINE 1
|
||||
@ -1692,6 +1694,9 @@
|
||||
#define SCE_RUST_LIFETIME 18
|
||||
#define SCE_RUST_MACRO 19
|
||||
#define SCE_RUST_LEXERROR 20
|
||||
#define SCE_RUST_BYTESTRING 21
|
||||
#define SCE_RUST_BYTESTRINGR 22
|
||||
#define SCE_RUST_BYTECHARACTER 23
|
||||
#define SCE_DMAP_DEFAULT 0
|
||||
#define SCE_DMAP_COMMENT 1
|
||||
#define SCE_DMAP_NUMBER 2
|
||||
@ -1713,6 +1718,19 @@
|
||||
#define SCE_DMIS_UNSUPPORTED_MAJOR 7
|
||||
#define SCE_DMIS_UNSUPPORTED_MINOR 8
|
||||
#define SCE_DMIS_LABEL 9
|
||||
#define SCE_REG_DEFAULT 0
|
||||
#define SCE_REG_COMMENT 1
|
||||
#define SCE_REG_VALUENAME 2
|
||||
#define SCE_REG_STRING 3
|
||||
#define SCE_REG_HEXDIGIT 4
|
||||
#define SCE_REG_VALUETYPE 5
|
||||
#define SCE_REG_ADDEDKEY 6
|
||||
#define SCE_REG_DELETEDKEY 7
|
||||
#define SCE_REG_ESCAPED 8
|
||||
#define SCE_REG_KEYPATH_GUID 9
|
||||
#define SCE_REG_STRING_GUID 10
|
||||
#define SCE_REG_PARAMETER 11
|
||||
#define SCE_REG_OPERATOR 12
|
||||
/* --Autogenerated -- end of section automatically generated from Scintilla.iface */
|
||||
|
||||
#endif
|
||||
|
@ -18,9 +18,9 @@ extern "C" {
|
||||
#if defined(_WIN32)
|
||||
/* Return false on failure: */
|
||||
int Scintilla_RegisterClasses(void *hInstance);
|
||||
int Scintilla_ReleaseResources();
|
||||
int Scintilla_ReleaseResources(void);
|
||||
#endif
|
||||
int Scintilla_LinkLexers();
|
||||
int Scintilla_LinkLexers(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
@ -92,6 +92,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SCI_SETBUFFEREDDRAW 2035
|
||||
#define SCI_SETTABWIDTH 2036
|
||||
#define SCI_GETTABWIDTH 2121
|
||||
#define SCI_CLEARTABSTOPS 2675
|
||||
#define SCI_ADDTABSTOP 2676
|
||||
#define SCI_GETNEXTTABSTOP 2677
|
||||
#define SC_CP_UTF8 65001
|
||||
#define SCI_SETCODEPAGE 2037
|
||||
#define MARKER_MAX 31
|
||||
@ -517,6 +520,11 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SCI_APPENDTEXT 2282
|
||||
#define SCI_GETTWOPHASEDRAW 2283
|
||||
#define SCI_SETTWOPHASEDRAW 2284
|
||||
#define SC_PHASES_ONE 0
|
||||
#define SC_PHASES_TWO 1
|
||||
#define SC_PHASES_MULTIPLE 2
|
||||
#define SCI_GETPHASESDRAW 2673
|
||||
#define SCI_SETPHASESDRAW 2674
|
||||
#define SC_EFF_QUALITY_MASK 0xF
|
||||
#define SC_EFF_QUALITY_DEFAULT 0
|
||||
#define SC_EFF_QUALITY_NON_ANTIALIASED 1
|
||||
@ -952,7 +960,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SC_MOD_CONTAINER 0x40000
|
||||
#define SC_MOD_LEXERSTATE 0x80000
|
||||
#define SC_MOD_INSERTCHECK 0x100000
|
||||
#define SC_MODEVENTMASKALL 0x1FFFFF
|
||||
#define SC_MOD_CHANGETABSTOPS 0x200000
|
||||
#define SC_MODEVENTMASKALL 0x3FFFFF
|
||||
#define SC_UPDATE_CONTENT 0x1
|
||||
#define SC_UPDATE_SELECTION 0x2
|
||||
#define SC_UPDATE_V_SCROLL 0x4
|
||||
|
@ -226,6 +226,15 @@ set void SetTabWidth=2036(int tabWidth,)
|
||||
# Retrieve the visible size of a tab.
|
||||
get int GetTabWidth=2121(,)
|
||||
|
||||
# Clear explicit tabstops on a line.
|
||||
fun void ClearTabStops=2675(int line,)
|
||||
|
||||
# Add an explicit tab stop for a line.
|
||||
fun void AddTabStop=2676(int line, int x)
|
||||
|
||||
# Find the next explicit tab stop position on a line after a position.
|
||||
fun int GetNextTabStop=2677(int line, int x)
|
||||
|
||||
# The SC_CP_UTF8 value can be used to enter Unicode mode.
|
||||
# This is the same value as CP_UTF8 in Windows
|
||||
val SC_CP_UTF8=65001
|
||||
@ -1291,13 +1300,27 @@ get bool GetVScrollBar=2281(,)
|
||||
# Append a string to the end of the document without changing the selection.
|
||||
fun void AppendText=2282(int length, string text)
|
||||
|
||||
# Is drawing done in two phases with backgrounds drawn before faoregrounds?
|
||||
# Is drawing done in two phases with backgrounds drawn before foregrounds?
|
||||
get bool GetTwoPhaseDraw=2283(,)
|
||||
|
||||
# In twoPhaseDraw mode, drawing is performed in two phases, first the background
|
||||
# and then the foreground. This avoids chopping off characters that overlap the next run.
|
||||
set void SetTwoPhaseDraw=2284(bool twoPhase,)
|
||||
|
||||
enu FontQuality=SC_PHASES_
|
||||
val SC_PHASES_ONE=0
|
||||
val SC_PHASES_TWO=1
|
||||
val SC_PHASES_MULTIPLE=2
|
||||
|
||||
# How many phases is drawing done in?
|
||||
get int GetPhasesDraw=2673(,)
|
||||
|
||||
# In one phase draw, text is drawn in a series of rectangular blocks with no overlap.
|
||||
# In two phase draw, text is drawn in a series of lines allowing runs to overlap horizontally.
|
||||
# In multiple phase draw, each element is drawn over the whole drawing area, allowing text
|
||||
# to overlap from one line to the next.
|
||||
set void SetPhasesDraw=2674(int phases,)
|
||||
|
||||
# Control font anti-aliasing.
|
||||
|
||||
enu FontQuality=SC_EFF_
|
||||
@ -2509,7 +2532,8 @@ val SC_MOD_CHANGEANNOTATION=0x20000
|
||||
val SC_MOD_CONTAINER=0x40000
|
||||
val SC_MOD_LEXERSTATE=0x80000
|
||||
val SC_MOD_INSERTCHECK=0x100000
|
||||
val SC_MODEVENTMASKALL=0x1FFFFF
|
||||
val SC_MOD_CHANGETABSTOPS=0x200000
|
||||
val SC_MODEVENTMASKALL=0x3FFFFF
|
||||
|
||||
enu Update=SC_UPDATE_
|
||||
val SC_UPDATE_CONTENT=0x1
|
||||
@ -2675,6 +2699,7 @@ val SCLEX_RUST=111
|
||||
val SCLEX_DMAP=112
|
||||
val SCLEX_AS=113
|
||||
val SCLEX_DMIS=114
|
||||
val SCLEX_REGISTRY=115
|
||||
|
||||
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
|
||||
# value assigned in sequence from SCLEX_AUTOMATIC+1.
|
||||
@ -3567,6 +3592,7 @@ val SCE_KIX_MACRO=6
|
||||
val SCE_KIX_KEYWORD=7
|
||||
val SCE_KIX_FUNCTIONS=8
|
||||
val SCE_KIX_OPERATOR=9
|
||||
val SCE_KIX_COMMENTSTREAM=10
|
||||
val SCE_KIX_IDENTIFIER=31
|
||||
# Lexical states for SCLEX_GUI4CLI
|
||||
lex Gui4Cli=SCLEX_GUI4CLI SCE_GC_
|
||||
@ -4443,6 +4469,9 @@ val SCE_RUST_IDENTIFIER=17
|
||||
val SCE_RUST_LIFETIME=18
|
||||
val SCE_RUST_MACRO=19
|
||||
val SCE_RUST_LEXERROR=20
|
||||
val SCE_RUST_BYTESTRING=21
|
||||
val SCE_RUST_BYTESTRINGR=22
|
||||
val SCE_RUST_BYTECHARACTER=23
|
||||
# Lexical states for SCLEX_DMAP
|
||||
lex DMAP=SCLEX_DMAP SCE_DMAP_
|
||||
val SCE_DMAP_DEFAULT=0
|
||||
@ -4468,6 +4497,21 @@ val SCE_DMIS_MINORWORD=6
|
||||
val SCE_DMIS_UNSUPPORTED_MAJOR=7
|
||||
val SCE_DMIS_UNSUPPORTED_MINOR=8
|
||||
val SCE_DMIS_LABEL=9
|
||||
# Lexical states for SCLEX_REGISTRY
|
||||
lex REG=SCLEX_REGISTRY SCE_REG_
|
||||
val SCE_REG_DEFAULT=0
|
||||
val SCE_REG_COMMENT=1
|
||||
val SCE_REG_VALUENAME=2
|
||||
val SCE_REG_STRING=3
|
||||
val SCE_REG_HEXDIGIT=4
|
||||
val SCE_REG_VALUETYPE=5
|
||||
val SCE_REG_ADDEDKEY=6
|
||||
val SCE_REG_DELETEDKEY=7
|
||||
val SCE_REG_ESCAPED=8
|
||||
val SCE_REG_KEYPATH_GUID=9
|
||||
val SCE_REG_STRING_GUID=10
|
||||
val SCE_REG_PARAMETER=11
|
||||
val SCE_REG_OPERATOR=12
|
||||
|
||||
# Events
|
||||
|
||||
|
@ -822,19 +822,27 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
// handle start of Mako comment line
|
||||
if (isMako && ch == '#' && chNext == '#') {
|
||||
makoComment = 1;
|
||||
state = SCE_HP_COMMENTLINE;
|
||||
}
|
||||
|
||||
// handle end of Mako comment line
|
||||
else if (isMako && makoComment && (ch == '\r' || ch == '\n')) {
|
||||
makoComment = 0;
|
||||
styler.ColourTo(i, SCE_HP_COMMENTLINE);
|
||||
state = SCE_HP_DEFAULT;
|
||||
styler.ColourTo(i, StateToPrint);
|
||||
if (scriptLanguage == eScriptPython) {
|
||||
state = SCE_HP_DEFAULT;
|
||||
} else {
|
||||
state = SCE_H_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
// Allow falling through to mako handling code if newline is going to end a block
|
||||
if (((ch == '\r' && chNext != '\n') || (ch == '\n')) &&
|
||||
(!isMako || (0 != strcmp(makoBlockType, "%")))) {
|
||||
}
|
||||
// Ignore everything in mako comment until the line ends
|
||||
else if (isMako && makoComment) {
|
||||
}
|
||||
|
||||
// generic end of script processing
|
||||
else if ((inScriptType == eNonHtmlScript) && (ch == '<') && (chNext == '/')) {
|
||||
|
@ -12,6 +12,9 @@
|
||||
** - added ... displayed as a comment
|
||||
** - removed unused IsAWord functions
|
||||
** - added some comments
|
||||
**
|
||||
** Changes by John Donoghue 2014/08/01
|
||||
** - fix allowed transpose ' after {} operator
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
@ -218,7 +221,7 @@ static void ColouriseMatlabOctaveDoc(
|
||||
} else if (isalpha(sc.ch)) {
|
||||
sc.SetState(SCE_MATLAB_KEYWORD);
|
||||
} else if (isoperator(static_cast<char>(sc.ch)) || sc.ch == '@' || sc.ch == '\\') {
|
||||
if (sc.ch == ')' || sc.ch == ']') {
|
||||
if (sc.ch == ')' || sc.ch == ']' || sc.ch == '}') {
|
||||
transpose = true;
|
||||
} else {
|
||||
transpose = false;
|
||||
|
@ -882,6 +882,31 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
|
||||
preferRE = false;
|
||||
} else if (isSafeWordcharOrHigh(chNext)) {
|
||||
state = SCE_RB_SYMBOL;
|
||||
} else if ((chNext == '@' || chNext == '$') &&
|
||||
isSafeWordcharOrHigh(chNext2)) {
|
||||
// instance and global variable followed by an identifier
|
||||
advance_char(i, ch, chNext, chNext2);
|
||||
state = SCE_RB_SYMBOL;
|
||||
} else if (((chNext == '@' && chNext2 == '@') ||
|
||||
(chNext == '$' && chNext2 == '-')) &&
|
||||
isSafeWordcharOrHigh(styler.SafeGetCharAt(i+3))) {
|
||||
// class variables and special global variable "$-IDENTCHAR"
|
||||
state = SCE_RB_SYMBOL;
|
||||
// $-IDENTCHAR doesn't continue past the IDENTCHAR
|
||||
if (chNext == '$') {
|
||||
styler.ColourTo(i+3, SCE_RB_SYMBOL);
|
||||
state = SCE_RB_DEFAULT;
|
||||
}
|
||||
i += 3;
|
||||
ch = styler.SafeGetCharAt(i);
|
||||
chNext = styler.SafeGetCharAt(i+1);
|
||||
} else if (chNext == '$' && strchr("_~*$?!@/\\;,.=:<>\"&`'+", chNext2)) {
|
||||
// single-character special global variables
|
||||
i += 2;
|
||||
ch = chNext2;
|
||||
chNext = styler.SafeGetCharAt(i+1);
|
||||
styler.ColourTo(i, SCE_RB_SYMBOL);
|
||||
state = SCE_RB_DEFAULT;
|
||||
} else if (strchr("[*!~+-*/%=<>&^|", chNext)) {
|
||||
// Do the operator analysis in-line, looking ahead
|
||||
// Based on the table in pickaxe 2nd ed., page 339
|
||||
@ -1260,7 +1285,16 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
|
||||
} else if (state == SCE_RB_CLASS_VAR
|
||||
|| state == SCE_RB_INSTANCE_VAR
|
||||
|| state == SCE_RB_SYMBOL) {
|
||||
if (!isSafeWordcharOrHigh(ch)) {
|
||||
if (state == SCE_RB_SYMBOL &&
|
||||
// FIDs suffices '?' and '!'
|
||||
(((ch == '!' || ch == '?') && chNext != '=') ||
|
||||
// identifier suffix '='
|
||||
(ch == '=' && (chNext != '~' && chNext != '>' &&
|
||||
(chNext != '=' || chNext2 == '>'))))) {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_RB_DEFAULT;
|
||||
preferRE = false;
|
||||
} else if (!isSafeWordcharOrHigh(ch)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
redo_char(i, ch, chNext, chNext2, state); // pass by ref
|
||||
preferRE = false;
|
||||
|
@ -230,7 +230,9 @@ static void ScanIdentifier(Accessor& styler, int& pos, WordList *keywords) {
|
||||
}
|
||||
}
|
||||
|
||||
static void ScanDigits(Accessor& styler, int& pos, int base) {
|
||||
/* Scans a sequence of digits, returning true if it found any. */
|
||||
static bool ScanDigits(Accessor& styler, int& pos, int base) {
|
||||
int old_pos = pos;
|
||||
for (;;) {
|
||||
int c = styler.SafeGetCharAt(pos, '\0');
|
||||
if (IsADigit(c, base) || c == '_')
|
||||
@ -238,13 +240,17 @@ static void ScanDigits(Accessor& styler, int& pos, int base) {
|
||||
else
|
||||
break;
|
||||
}
|
||||
return old_pos != pos;
|
||||
}
|
||||
|
||||
/* Scans an integer and floating point literals. */
|
||||
static void ScanNumber(Accessor& styler, int& pos) {
|
||||
int base = 10;
|
||||
int c = styler.SafeGetCharAt(pos, '\0');
|
||||
int n = styler.SafeGetCharAt(pos + 1, '\0');
|
||||
bool error = false;
|
||||
/* Scan the prefix, thus determining the base.
|
||||
* 10 is default if there's no prefix. */
|
||||
if (c == '0' && n == 'x') {
|
||||
pos += 2;
|
||||
base = 16;
|
||||
@ -255,8 +261,11 @@ static void ScanNumber(Accessor& styler, int& pos) {
|
||||
pos += 2;
|
||||
base = 8;
|
||||
}
|
||||
int old_pos = pos;
|
||||
ScanDigits(styler, pos, base);
|
||||
|
||||
/* Scan initial digits. The literal is malformed if there are none. */
|
||||
error |= !ScanDigits(styler, pos, base);
|
||||
/* See if there's an integer suffix. We mimic the Rust's lexer
|
||||
* and munch it even if there was an error above. */
|
||||
c = styler.SafeGetCharAt(pos, '\0');
|
||||
if (c == 'u' || c == 'i') {
|
||||
pos++;
|
||||
@ -271,14 +280,22 @@ static void ScanNumber(Accessor& styler, int& pos) {
|
||||
} else if (c == '6' && n == '4') {
|
||||
pos += 2;
|
||||
}
|
||||
} else {
|
||||
/* See if it's a floating point literal. These literals have to be base 10.
|
||||
*/
|
||||
} else if (!error) {
|
||||
/* If there's a period, it's a floating point literal unless it's
|
||||
* followed by an identifier (meaning this is a method call, e.g.
|
||||
* `1.foo()`) or another period, in which case it's a range (e.g. 1..2)
|
||||
*/
|
||||
n = styler.SafeGetCharAt(pos + 1, '\0');
|
||||
if (c == '.' && !(IsIdentifierStart(n) || n == '.')) {
|
||||
error |= base != 10;
|
||||
pos++;
|
||||
/* It's ok to have no digits after the period. */
|
||||
ScanDigits(styler, pos, 10);
|
||||
}
|
||||
|
||||
/* Look for the exponentiation. */
|
||||
c = styler.SafeGetCharAt(pos, '\0');
|
||||
if (c == 'e' || c == 'E') {
|
||||
error |= base != 10;
|
||||
@ -286,13 +303,11 @@ static void ScanNumber(Accessor& styler, int& pos) {
|
||||
c = styler.SafeGetCharAt(pos, '\0');
|
||||
if (c == '-' || c == '+')
|
||||
pos++;
|
||||
int old_pos = pos;
|
||||
ScanDigits(styler, pos, 10);
|
||||
if (old_pos == pos) {
|
||||
error = true;
|
||||
}
|
||||
/* It is invalid to have no digits in the exponent. */
|
||||
error |= !ScanDigits(styler, pos, 10);
|
||||
}
|
||||
|
||||
/* Scan the floating point suffix. */
|
||||
c = styler.SafeGetCharAt(pos, '\0');
|
||||
if (c == 'f') {
|
||||
error |= base != 10;
|
||||
@ -308,9 +323,7 @@ static void ScanNumber(Accessor& styler, int& pos) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (old_pos == pos) {
|
||||
error = true;
|
||||
}
|
||||
|
||||
if (error)
|
||||
styler.ColourTo(pos - 1, SCE_RUST_LEXERROR);
|
||||
else
|
||||
@ -351,7 +364,7 @@ static bool IsValidCharacterEscape(int c) {
|
||||
}
|
||||
|
||||
static bool IsValidStringEscape(int c) {
|
||||
return IsValidCharacterEscape(c) || c == '\n';
|
||||
return IsValidCharacterEscape(c) || c == '\n' || c == '\r';
|
||||
}
|
||||
|
||||
static bool ScanNumericEscape(Accessor &styler, int& pos, int num_digits, bool stop_asap) {
|
||||
@ -373,12 +386,12 @@ static bool ScanNumericEscape(Accessor &styler, int& pos, int num_digits, bool s
|
||||
|
||||
/* This is overly permissive for character literals in order to accept UTF-8 encoded
|
||||
* character literals. */
|
||||
static void ScanCharacterLiteralOrLifetime(Accessor &styler, int& pos) {
|
||||
static void ScanCharacterLiteralOrLifetime(Accessor &styler, int& pos, bool ascii_only) {
|
||||
pos++;
|
||||
int c = styler.SafeGetCharAt(pos, '\0');
|
||||
int n = styler.SafeGetCharAt(pos + 1, '\0');
|
||||
bool done = false;
|
||||
bool valid_lifetime = IsIdentifierStart(c);
|
||||
bool valid_lifetime = !ascii_only && IsIdentifierStart(c);
|
||||
bool valid_char = true;
|
||||
bool first = true;
|
||||
while (!done) {
|
||||
@ -390,10 +403,10 @@ static void ScanCharacterLiteralOrLifetime(Accessor &styler, int& pos) {
|
||||
} else if (n == 'x') {
|
||||
pos += 2;
|
||||
valid_char = ScanNumericEscape(styler, pos, 2, false);
|
||||
} else if (n == 'u') {
|
||||
} else if (n == 'u' && !ascii_only) {
|
||||
pos += 2;
|
||||
valid_char = ScanNumericEscape(styler, pos, 4, false);
|
||||
} else if (n == 'U') {
|
||||
} else if (n == 'U' && !ascii_only) {
|
||||
pos += 2;
|
||||
valid_char = ScanNumericEscape(styler, pos, 8, false);
|
||||
} else {
|
||||
@ -412,7 +425,10 @@ static void ScanCharacterLiteralOrLifetime(Accessor &styler, int& pos) {
|
||||
done = true;
|
||||
break;
|
||||
default:
|
||||
if (!IsIdentifierContinue(c) && !first) {
|
||||
if (ascii_only && !IsASCII((char)c)) {
|
||||
done = true;
|
||||
valid_char = false;
|
||||
} else if (!IsIdentifierContinue(c) && !first) {
|
||||
done = true;
|
||||
} else {
|
||||
pos++;
|
||||
@ -433,7 +449,7 @@ static void ScanCharacterLiteralOrLifetime(Accessor &styler, int& pos) {
|
||||
styler.ColourTo(pos - 1, SCE_RUST_LIFETIME);
|
||||
} else if (valid_char) {
|
||||
pos++;
|
||||
styler.ColourTo(pos - 1, SCE_RUST_CHARACTER);
|
||||
styler.ColourTo(pos - 1, ascii_only ? SCE_RUST_BYTECHARACTER : SCE_RUST_CHARACTER);
|
||||
} else {
|
||||
styler.ColourTo(pos - 1, SCE_RUST_LEXERROR);
|
||||
}
|
||||
@ -542,7 +558,7 @@ static void ScanComments(Accessor &styler, int& pos, int max) {
|
||||
ResumeBlockComment(styler, pos, max, UnknownComment, 1);
|
||||
}
|
||||
|
||||
static void ResumeString(Accessor &styler, int& pos, int max) {
|
||||
static void ResumeString(Accessor &styler, int& pos, int max, bool ascii_only) {
|
||||
int c = styler.SafeGetCharAt(pos, '\0');
|
||||
bool error = false;
|
||||
while (c != '"' && !error) {
|
||||
@ -559,10 +575,10 @@ static void ResumeString(Accessor &styler, int& pos, int max) {
|
||||
} else if (n == 'x') {
|
||||
pos += 2;
|
||||
error = !ScanNumericEscape(styler, pos, 2, true);
|
||||
} else if (n == 'u') {
|
||||
} else if (n == 'u' && !ascii_only) {
|
||||
pos += 2;
|
||||
error = !ScanNumericEscape(styler, pos, 4, true);
|
||||
} else if (n == 'U') {
|
||||
} else if (n == 'U' && !ascii_only) {
|
||||
pos += 2;
|
||||
error = !ScanNumericEscape(styler, pos, 8, true);
|
||||
} else {
|
||||
@ -570,16 +586,19 @@ static void ResumeString(Accessor &styler, int& pos, int max) {
|
||||
error = true;
|
||||
}
|
||||
} else {
|
||||
pos++;
|
||||
if (ascii_only && !IsASCII((char)c))
|
||||
error = true;
|
||||
else
|
||||
pos++;
|
||||
}
|
||||
c = styler.SafeGetCharAt(pos, '\0');
|
||||
}
|
||||
if (!error)
|
||||
pos++;
|
||||
styler.ColourTo(pos - 1, SCE_RUST_STRING);
|
||||
styler.ColourTo(pos - 1, ascii_only ? SCE_RUST_BYTESTRING : SCE_RUST_STRING);
|
||||
}
|
||||
|
||||
static void ResumeRawString(Accessor &styler, int& pos, int max, int num_hashes) {
|
||||
static void ResumeRawString(Accessor &styler, int& pos, int max, int num_hashes, bool ascii_only) {
|
||||
for (;;) {
|
||||
if (pos == styler.LineEnd(styler.GetLine(pos)))
|
||||
styler.SetLineState(styler.GetLine(pos), num_hashes);
|
||||
@ -594,19 +613,20 @@ static void ResumeRawString(Accessor &styler, int& pos, int max, int num_hashes)
|
||||
}
|
||||
if (trailing_num_hashes == num_hashes) {
|
||||
styler.SetLineState(styler.GetLine(pos), 0);
|
||||
styler.ColourTo(pos - 1, SCE_RUST_STRINGR);
|
||||
break;
|
||||
}
|
||||
} else if (pos >= max) {
|
||||
styler.ColourTo(pos - 1, SCE_RUST_STRINGR);
|
||||
break;
|
||||
} else {
|
||||
} else {
|
||||
if (ascii_only && !IsASCII((char)c))
|
||||
break;
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
styler.ColourTo(pos - 1, ascii_only ? SCE_RUST_BYTESTRINGR : SCE_RUST_STRINGR);
|
||||
}
|
||||
|
||||
static void ScanRawString(Accessor &styler, int& pos, int max) {
|
||||
static void ScanRawString(Accessor &styler, int& pos, int max, bool ascii_only) {
|
||||
pos++;
|
||||
int num_hashes = 0;
|
||||
while (styler.SafeGetCharAt(pos, '\0') == '#') {
|
||||
@ -617,7 +637,7 @@ static void ScanRawString(Accessor &styler, int& pos, int max) {
|
||||
styler.ColourTo(pos - 1, SCE_RUST_LEXERROR);
|
||||
} else {
|
||||
pos++;
|
||||
ResumeRawString(styler, pos, max, num_hashes);
|
||||
ResumeRawString(styler, pos, max, num_hashes, ascii_only);
|
||||
}
|
||||
}
|
||||
|
||||
@ -635,9 +655,13 @@ void SCI_METHOD LexerRust::Lex(unsigned int startPos, int length, int initStyle,
|
||||
} else if (initStyle == SCE_RUST_COMMENTLINE || initStyle == SCE_RUST_COMMENTLINEDOC) {
|
||||
ResumeLineComment(styler, pos, max, initStyle == SCE_RUST_COMMENTLINEDOC ? DocComment : NotDocComment);
|
||||
} else if (initStyle == SCE_RUST_STRING) {
|
||||
ResumeString(styler, pos, max);
|
||||
ResumeString(styler, pos, max, false);
|
||||
} else if (initStyle == SCE_RUST_BYTESTRING) {
|
||||
ResumeString(styler, pos, max, true);
|
||||
} else if (initStyle == SCE_RUST_STRINGR) {
|
||||
ResumeRawString(styler, pos, max, styler.GetLineState(styler.GetLine(pos) - 1));
|
||||
ResumeRawString(styler, pos, max, styler.GetLineState(styler.GetLine(pos) - 1), false);
|
||||
} else if (initStyle == SCE_RUST_BYTESTRINGR) {
|
||||
ResumeRawString(styler, pos, max, styler.GetLineState(styler.GetLine(pos) - 1), true);
|
||||
}
|
||||
|
||||
while (pos < max) {
|
||||
@ -645,7 +669,7 @@ void SCI_METHOD LexerRust::Lex(unsigned int startPos, int length, int initStyle,
|
||||
int n = styler.SafeGetCharAt(pos + 1, '\0');
|
||||
int n2 = styler.SafeGetCharAt(pos + 2, '\0');
|
||||
|
||||
if (pos == 0 && c == '#' && n == '!') {
|
||||
if (pos == 0 && c == '#' && n == '!' && n2 != '[') {
|
||||
pos += 2;
|
||||
ResumeLineComment(styler, pos, max, NotDocComment);
|
||||
} else if (IsWhitespace(c)) {
|
||||
@ -653,7 +677,16 @@ void SCI_METHOD LexerRust::Lex(unsigned int startPos, int length, int initStyle,
|
||||
} else if (c == '/' && (n == '/' || n == '*')) {
|
||||
ScanComments(styler, pos, max);
|
||||
} else if (c == 'r' && (n == '#' || n == '"')) {
|
||||
ScanRawString(styler, pos, max);
|
||||
ScanRawString(styler, pos, max, false);
|
||||
} else if (c == 'b' && n == 'r' && (n2 == '#' || n2 == '"')) {
|
||||
pos++;
|
||||
ScanRawString(styler, pos, max, true);
|
||||
} else if (c == 'b' && n == '"') {
|
||||
pos += 2;
|
||||
ResumeString(styler, pos, max, true);
|
||||
} else if (c == 'b' && n == '\'') {
|
||||
pos++;
|
||||
ScanCharacterLiteralOrLifetime(styler, pos, true);
|
||||
} else if (IsIdentifierStart(c)) {
|
||||
ScanIdentifier(styler, pos, keywords);
|
||||
} else if (IsADigit(c)) {
|
||||
@ -668,10 +701,10 @@ void SCI_METHOD LexerRust::Lex(unsigned int startPos, int length, int initStyle,
|
||||
pos++;
|
||||
styler.ColourTo(pos - 1, SCE_RUST_OPERATOR);
|
||||
} else if (c == '\'') {
|
||||
ScanCharacterLiteralOrLifetime(styler, pos);
|
||||
ScanCharacterLiteralOrLifetime(styler, pos, false);
|
||||
} else if (c == '"') {
|
||||
pos++;
|
||||
ResumeString(styler, pos, max);
|
||||
ResumeString(styler, pos, max, false);
|
||||
} else {
|
||||
pos++;
|
||||
styler.ColourTo(pos - 1, SCE_RUST_LEXERROR);
|
||||
|
@ -67,7 +67,12 @@ inline int Maximum(int a, int b) {
|
||||
|
||||
// Shut up annoying Visual C++ warnings:
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4244 4309)
|
||||
#pragma warning(disable: 4244 4309 4456 4457)
|
||||
#endif
|
||||
|
||||
// Turn off shadow warnings for lexers as may be maintained by others
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic ignored "-Wshadow"
|
||||
#endif
|
||||
|
||||
#ifdef SCI_NAMESPACE
|
||||
|
@ -130,10 +130,13 @@ SRCOBJS=\
|
||||
Decoration.o \
|
||||
Document.o \
|
||||
Editor.o \
|
||||
EditModel.o \
|
||||
EditView.o \
|
||||
ExternalLexer.o \
|
||||
Indicator.o \
|
||||
KeyMap.o \
|
||||
LineMarker.o \
|
||||
MarginView.o \
|
||||
PerLine.o \
|
||||
PositionCache.o \
|
||||
RESearch.o \
|
||||
|
@ -31,7 +31,7 @@ diff --git b/scintilla/src/Catalogue.cxx a/scintilla/src/Catalogue.cxx
|
||||
index 41d5d54..70ce3bc 100644
|
||||
--- scintilla/src/Catalogue.cxx
|
||||
+++ scintilla/src/Catalogue.cxx
|
||||
@@ -76,115 +76,48 @@ int Scintilla_LinkLexers() {
|
||||
@@ -76,116 +76,48 @@ int Scintilla_LinkLexers() {
|
||||
|
||||
//++Autogenerated -- run scripts/LexGen.py to regenerate
|
||||
//**\(\tLINK_LEXER(\*);\n\)
|
||||
@ -123,6 +123,7 @@ index 41d5d54..70ce3bc 100644
|
||||
LINK_LEXER(lmPython);
|
||||
LINK_LEXER(lmR);
|
||||
- LINK_LEXER(lmREBOL);
|
||||
- LINK_LEXER(lmRegistry);
|
||||
LINK_LEXER(lmRuby);
|
||||
LINK_LEXER(lmRust);
|
||||
- LINK_LEXER(lmScriptol);
|
||||
|
@ -144,6 +144,7 @@ UndoHistory::UndoHistory() {
|
||||
currentAction = 0;
|
||||
undoSequenceDepth = 0;
|
||||
savePoint = 0;
|
||||
tentativePoint = -1;
|
||||
|
||||
actions[currentAction].Create(startAction);
|
||||
}
|
||||
@ -194,7 +195,7 @@ const char *UndoHistory::AppendAction(actionType at, int position, const char *d
|
||||
// Visual Studio 2013 Code Analysis wrongly believes actions can be NULL at its next reference
|
||||
__analysis_assume(actions);
|
||||
#endif
|
||||
if (currentAction == savePoint) {
|
||||
if ((currentAction == savePoint) || (currentAction == tentativePoint)) {
|
||||
currentAction++;
|
||||
} else if (!actions[currentAction].mayCoalesce) {
|
||||
// Not allowed to coalesce if this set
|
||||
@ -282,6 +283,7 @@ void UndoHistory::DeleteUndoHistory() {
|
||||
currentAction = 0;
|
||||
actions[currentAction].Create(startAction);
|
||||
savePoint = 0;
|
||||
tentativePoint = -1;
|
||||
}
|
||||
|
||||
void UndoHistory::SetSavePoint() {
|
||||
@ -292,6 +294,26 @@ bool UndoHistory::IsSavePoint() const {
|
||||
return savePoint == currentAction;
|
||||
}
|
||||
|
||||
void UndoHistory::TentativeStart() {
|
||||
tentativePoint = currentAction;
|
||||
}
|
||||
|
||||
void UndoHistory::TentativeCommit() {
|
||||
tentativePoint = -1;
|
||||
// Truncate undo history
|
||||
maxAction = currentAction;
|
||||
}
|
||||
|
||||
int UndoHistory::TentativeSteps() {
|
||||
// Drop any trailing startAction
|
||||
if (actions[currentAction].at == startAction && currentAction > 0)
|
||||
currentAction--;
|
||||
if (tentativePoint >= 0)
|
||||
return currentAction - tentativePoint;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool UndoHistory::CanUndo() const {
|
||||
return (currentAction > 0) && (maxAction > 0);
|
||||
}
|
||||
@ -505,6 +527,22 @@ bool CellBuffer::IsSavePoint() const {
|
||||
return uh.IsSavePoint();
|
||||
}
|
||||
|
||||
void CellBuffer::TentativeStart() {
|
||||
uh.TentativeStart();
|
||||
}
|
||||
|
||||
void CellBuffer::TentativeCommit() {
|
||||
uh.TentativeCommit();
|
||||
}
|
||||
|
||||
int CellBuffer::TentativeSteps() {
|
||||
return uh.TentativeSteps();
|
||||
}
|
||||
|
||||
bool CellBuffer::TentativeActive() const {
|
||||
return uh.TentativeActive();
|
||||
}
|
||||
|
||||
// Without undo
|
||||
|
||||
void CellBuffer::InsertLine(int line, int position, bool lineStart) {
|
||||
|
@ -95,6 +95,7 @@ class UndoHistory {
|
||||
int currentAction;
|
||||
int undoSequenceDepth;
|
||||
int savePoint;
|
||||
int tentativePoint;
|
||||
|
||||
void EnsureUndoRoom();
|
||||
|
||||
@ -117,6 +118,12 @@ public:
|
||||
void SetSavePoint();
|
||||
bool IsSavePoint() const;
|
||||
|
||||
// Tentative actions are used for input composition so that it can be undone cleanly
|
||||
void TentativeStart();
|
||||
void TentativeCommit();
|
||||
bool TentativeActive() const { return tentativePoint >= 0; }
|
||||
int TentativeSteps();
|
||||
|
||||
/// 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;
|
||||
@ -193,6 +200,11 @@ public:
|
||||
void SetSavePoint();
|
||||
bool IsSavePoint() const;
|
||||
|
||||
void TentativeStart();
|
||||
void TentativeCommit();
|
||||
bool TentativeActive() const;
|
||||
int TentativeSteps();
|
||||
|
||||
bool SetUndoCollection(bool collectUndo);
|
||||
bool IsCollectingUndo() const;
|
||||
void BeginUndoAction();
|
||||
|
@ -150,8 +150,8 @@ bool ContractionState::GetVisible(int lineDoc) const {
|
||||
}
|
||||
}
|
||||
|
||||
bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible_) {
|
||||
if (OneToOne() && visible_) {
|
||||
bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool isVisible) {
|
||||
if (OneToOne() && isVisible) {
|
||||
return false;
|
||||
} else {
|
||||
EnsureData();
|
||||
@ -159,9 +159,9 @@ bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible
|
||||
Check();
|
||||
if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < LinesInDoc())) {
|
||||
for (int line = lineDocStart; line <= lineDocEnd; line++) {
|
||||
if (GetVisible(line) != visible_) {
|
||||
int difference = visible_ ? heights->ValueAt(line) : -heights->ValueAt(line);
|
||||
visible->SetValueAt(line, visible_ ? 1 : 0);
|
||||
if (GetVisible(line) != isVisible) {
|
||||
int difference = isVisible ? heights->ValueAt(line) : -heights->ValueAt(line);
|
||||
visible->SetValueAt(line, isVisible ? 1 : 0);
|
||||
displayLines->InsertText(line, difference);
|
||||
delta += difference;
|
||||
}
|
||||
@ -191,13 +191,13 @@ bool ContractionState::GetExpanded(int lineDoc) const {
|
||||
}
|
||||
}
|
||||
|
||||
bool ContractionState::SetExpanded(int lineDoc, bool expanded_) {
|
||||
if (OneToOne() && expanded_) {
|
||||
bool ContractionState::SetExpanded(int lineDoc, bool isExpanded) {
|
||||
if (OneToOne() && isExpanded) {
|
||||
return false;
|
||||
} else {
|
||||
EnsureData();
|
||||
if (expanded_ != (expanded->ValueAt(lineDoc) == 1)) {
|
||||
expanded->SetValueAt(lineDoc, expanded_ ? 1 : 0);
|
||||
if (isExpanded != (expanded->ValueAt(lineDoc) == 1)) {
|
||||
expanded->SetValueAt(lineDoc, isExpanded ? 1 : 0);
|
||||
Check();
|
||||
return true;
|
||||
} else {
|
||||
|
@ -48,11 +48,11 @@ public:
|
||||
void DeleteLines(int lineDoc, int lineCount);
|
||||
|
||||
bool GetVisible(int lineDoc) const;
|
||||
bool SetVisible(int lineDocStart, int lineDocEnd, bool visible);
|
||||
bool SetVisible(int lineDocStart, int lineDocEnd, bool isVisible);
|
||||
bool HiddenLines() const;
|
||||
|
||||
bool GetExpanded(int lineDoc) const;
|
||||
bool SetExpanded(int lineDoc, bool expanded);
|
||||
bool SetExpanded(int lineDoc, bool isExpanded);
|
||||
int ContractedNext(int lineDocStart) const;
|
||||
|
||||
int GetHeight(int lineDoc) const;
|
||||
|
@ -209,6 +209,65 @@ void Document::SetSavePoint() {
|
||||
NotifySavePoint(true);
|
||||
}
|
||||
|
||||
void Document::TentativeUndo() {
|
||||
CheckReadOnly();
|
||||
if (enteredModification == 0) {
|
||||
enteredModification++;
|
||||
if (!cb.IsReadOnly()) {
|
||||
bool startSavePoint = cb.IsSavePoint();
|
||||
bool multiLine = false;
|
||||
int steps = cb.TentativeSteps();
|
||||
//Platform::DebugPrintf("Steps=%d\n", steps);
|
||||
for (int step = 0; step < steps; step++) {
|
||||
const int prevLinesTotal = LinesTotal();
|
||||
const Action &action = cb.GetUndoStep();
|
||||
if (action.at == removeAction) {
|
||||
NotifyModified(DocModification(
|
||||
SC_MOD_BEFOREINSERT | SC_PERFORMED_UNDO, action));
|
||||
} else if (action.at == containerAction) {
|
||||
DocModification dm(SC_MOD_CONTAINER | SC_PERFORMED_UNDO);
|
||||
dm.token = action.position;
|
||||
NotifyModified(dm);
|
||||
} else {
|
||||
NotifyModified(DocModification(
|
||||
SC_MOD_BEFOREDELETE | SC_PERFORMED_UNDO, action));
|
||||
}
|
||||
cb.PerformUndoStep();
|
||||
if (action.at != containerAction) {
|
||||
ModifiedAt(action.position);
|
||||
}
|
||||
|
||||
int modFlags = SC_PERFORMED_UNDO;
|
||||
// With undo, an insertion action becomes a deletion notification
|
||||
if (action.at == removeAction) {
|
||||
modFlags |= SC_MOD_INSERTTEXT;
|
||||
} else if (action.at == insertAction) {
|
||||
modFlags |= SC_MOD_DELETETEXT;
|
||||
}
|
||||
if (steps > 1)
|
||||
modFlags |= SC_MULTISTEPUNDOREDO;
|
||||
const int linesAdded = LinesTotal() - prevLinesTotal;
|
||||
if (linesAdded != 0)
|
||||
multiLine = true;
|
||||
if (step == steps - 1) {
|
||||
modFlags |= SC_LASTSTEPINUNDOREDO;
|
||||
if (multiLine)
|
||||
modFlags |= SC_MULTILINEUNDOREDO;
|
||||
}
|
||||
NotifyModified(DocModification(modFlags, action.position, action.lenData,
|
||||
linesAdded, action.data));
|
||||
}
|
||||
|
||||
bool endSavePoint = cb.IsSavePoint();
|
||||
if (startSavePoint != endSavePoint)
|
||||
NotifySavePoint(endSavePoint);
|
||||
|
||||
cb.TentativeCommit();
|
||||
}
|
||||
enteredModification--;
|
||||
}
|
||||
}
|
||||
|
||||
int Document::GetMark(int line) {
|
||||
return static_cast<LineMarkers *>(perLineData[ldMarkers])->MarkValue(line);
|
||||
}
|
||||
|
@ -303,6 +303,12 @@ public:
|
||||
void AddUndoAction(int token, bool mayCoalesce) { cb.AddUndoAction(token, mayCoalesce); }
|
||||
void SetSavePoint();
|
||||
bool IsSavePoint() const { return cb.IsSavePoint(); }
|
||||
|
||||
void TentativeStart() { cb.TentativeStart(); }
|
||||
void TentativeCommit() { cb.TentativeCommit(); }
|
||||
void TentativeUndo();
|
||||
bool TentativeActive() const { return cb.TentativeActive(); }
|
||||
|
||||
const char * SCI_METHOD BufferPointer() { return cb.BufferPointer(); }
|
||||
const char *RangePointer(int position, int rangeLength) { return cb.RangePointer(position, rangeLength); }
|
||||
int GapPosition() const { return cb.GapPosition(); }
|
||||
@ -368,7 +374,7 @@ public:
|
||||
|
||||
void SetDefaultCharClasses(bool includeWordClass);
|
||||
void SetCharClasses(const unsigned char *chars, CharClassify::cc newCharClass);
|
||||
int GetCharsOfClass(CharClassify::cc charClass, unsigned char *buffer);
|
||||
int GetCharsOfClass(CharClassify::cc characterClass, unsigned char *buffer);
|
||||
void SCI_METHOD StartStyling(int position, char mask);
|
||||
bool SCI_METHOD SetStyleFor(int length, char style);
|
||||
bool SCI_METHOD SetStyles(int length, const char *styles);
|
||||
|
74
scintilla/src/EditModel.cxx
Normal file
74
scintilla/src/EditModel.cxx
Normal file
@ -0,0 +1,74 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file EditModel.cxx
|
||||
** Defines the editor state that must be visible to EditorView.
|
||||
**/
|
||||
// Copyright 1998-2014 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 <math.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "ILexer.h"
|
||||
#include "Scintilla.h"
|
||||
|
||||
#include "StringCopy.h"
|
||||
#include "SplitVector.h"
|
||||
#include "Partitioning.h"
|
||||
#include "RunStyles.h"
|
||||
#include "ContractionState.h"
|
||||
#include "CellBuffer.h"
|
||||
#include "KeyMap.h"
|
||||
#include "Indicator.h"
|
||||
#include "XPM.h"
|
||||
#include "LineMarker.h"
|
||||
#include "Style.h"
|
||||
#include "ViewStyle.h"
|
||||
#include "CharClassify.h"
|
||||
#include "Decoration.h"
|
||||
#include "CaseFolder.h"
|
||||
#include "Document.h"
|
||||
#include "UniConversion.h"
|
||||
#include "Selection.h"
|
||||
#include "PositionCache.h"
|
||||
#include "EditModel.h"
|
||||
|
||||
#ifdef SCI_NAMESPACE
|
||||
using namespace Scintilla;
|
||||
#endif
|
||||
|
||||
Caret::Caret() :
|
||||
active(false), on(false), period(500) {}
|
||||
|
||||
EditModel::EditModel() {
|
||||
inOverstrike = false;
|
||||
xOffset = 0;
|
||||
trackLineWidth = false;
|
||||
posDrag = SelectionPosition(invalidPosition);
|
||||
braces[0] = invalidPosition;
|
||||
braces[1] = invalidPosition;
|
||||
bracesMatchStyle = STYLE_BRACEBAD;
|
||||
highlightGuideColumn = 0;
|
||||
primarySelection = true;
|
||||
foldFlags = 0;
|
||||
hotspot = Range(invalidPosition);
|
||||
wrapWidth = LineLayout::wrapWidthInfinite;
|
||||
pdoc = new Document();
|
||||
pdoc->AddRef();
|
||||
}
|
||||
|
||||
EditModel::~EditModel() {
|
||||
pdoc->Release();
|
||||
pdoc = 0;
|
||||
}
|
67
scintilla/src/EditModel.h
Normal file
67
scintilla/src/EditModel.h
Normal file
@ -0,0 +1,67 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file EditModel.h
|
||||
** Defines the editor state that must be visible to EditorView.
|
||||
**/
|
||||
// Copyright 1998-2014 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef EDITMODEL_H
|
||||
#define EDITMODEL_H
|
||||
|
||||
#ifdef SCI_NAMESPACE
|
||||
namespace Scintilla {
|
||||
#endif
|
||||
|
||||
/**
|
||||
*/
|
||||
class Caret {
|
||||
public:
|
||||
bool active;
|
||||
bool on;
|
||||
int period;
|
||||
|
||||
Caret();
|
||||
};
|
||||
|
||||
class EditModel {
|
||||
// Private so EditModel objects can not be copied
|
||||
EditModel(const EditModel &);
|
||||
EditModel &operator=(const EditModel &);
|
||||
|
||||
public:
|
||||
bool inOverstrike;
|
||||
int xOffset; ///< Horizontal scrolled amount in pixels
|
||||
bool trackLineWidth;
|
||||
|
||||
SpecialRepresentations reprs;
|
||||
Caret caret;
|
||||
SelectionPosition posDrag;
|
||||
Position braces[2];
|
||||
int bracesMatchStyle;
|
||||
int highlightGuideColumn;
|
||||
Selection sel;
|
||||
bool primarySelection;
|
||||
|
||||
int foldFlags;
|
||||
ContractionState cs;
|
||||
// Hotspot support
|
||||
Range hotspot;
|
||||
|
||||
// Wrapping support
|
||||
int wrapWidth;
|
||||
|
||||
Document *pdoc;
|
||||
|
||||
EditModel();
|
||||
virtual ~EditModel();
|
||||
virtual int TopLineOfMain() const = 0;
|
||||
virtual Point GetVisibleOriginInMain() const = 0;
|
||||
virtual int LinesOnScreen() const = 0;
|
||||
virtual Range GetHotSpotRange() const = 0;
|
||||
};
|
||||
|
||||
#ifdef SCI_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
2072
scintilla/src/EditView.cxx
Normal file
2072
scintilla/src/EditView.cxx
Normal file
File diff suppressed because it is too large
Load Diff
163
scintilla/src/EditView.h
Normal file
163
scintilla/src/EditView.h
Normal file
@ -0,0 +1,163 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file EditView.h
|
||||
** Defines the appearance of the main text area of the editor window.
|
||||
**/
|
||||
// Copyright 1998-2014 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef EDITVIEW_H
|
||||
#define EDITVIEW_H
|
||||
|
||||
#ifdef SCI_NAMESPACE
|
||||
namespace Scintilla {
|
||||
#endif
|
||||
|
||||
struct PrintParameters {
|
||||
int magnification;
|
||||
int colourMode;
|
||||
WrapMode wrapState;
|
||||
PrintParameters();
|
||||
};
|
||||
|
||||
/**
|
||||
* The view may be drawn in separate phases.
|
||||
*/
|
||||
enum DrawPhase {
|
||||
drawBack = 0x1,
|
||||
drawIndicatorsBack = 0x2,
|
||||
drawText = 0x4,
|
||||
drawIndentationGuides = 0x8,
|
||||
drawIndicatorsFore = 0x10,
|
||||
drawSelectionTranslucent = 0x20,
|
||||
drawLineTranslucent = 0x40,
|
||||
drawFoldLines = 0x80,
|
||||
drawCarets = 0x100,
|
||||
drawAll = 0x1FF,
|
||||
};
|
||||
|
||||
bool ValidStyledText(const ViewStyle &vs, size_t styleOffset, const StyledText &st);
|
||||
int WidestLineWidth(Surface *surface, const ViewStyle &vs, int styleOffset, const StyledText &st);
|
||||
void DrawTextNoClipPhase(Surface *surface, PRectangle rc, const Style &style, XYPOSITION ybase,
|
||||
const char *s, int len, DrawPhase phase);
|
||||
void DrawStyledText(Surface *surface, const ViewStyle &vs, int styleOffset, PRectangle rcText,
|
||||
const StyledText &st, size_t start, size_t length, DrawPhase phase);
|
||||
|
||||
/**
|
||||
* EditView draws the main text area.
|
||||
*/
|
||||
class EditView {
|
||||
public:
|
||||
PrintParameters printParameters;
|
||||
PerLine *ldTabstops;
|
||||
|
||||
bool hideSelection;
|
||||
bool drawOverstrikeCaret;
|
||||
|
||||
/** 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;
|
||||
/** In phasesTwo mode, drawing is performed in two phases, first the background
|
||||
* and then the foreground. This avoids chopping off characters that overlap the next run.
|
||||
* In multiPhaseDraw mode, drawing is performed in multiple phases with each phase drawing
|
||||
* one feature over the whole drawing area, instead of within one line. This allows text to
|
||||
* overlap from one line to the next. */
|
||||
enum PhasesDraw { phasesOne, phasesTwo, phasesMultiple };
|
||||
PhasesDraw phasesDraw;
|
||||
|
||||
int lineWidthMaxSeen;
|
||||
|
||||
bool additionalCaretsBlink;
|
||||
bool additionalCaretsVisible;
|
||||
|
||||
bool imeCaretBlockOverride;
|
||||
|
||||
Surface *pixmapLine;
|
||||
Surface *pixmapIndentGuide;
|
||||
Surface *pixmapIndentGuideHighlight;
|
||||
|
||||
LineLayoutCache llc;
|
||||
PositionCache posCache;
|
||||
|
||||
EditView();
|
||||
virtual ~EditView();
|
||||
|
||||
bool SetTwoPhaseDraw(bool twoPhaseDraw);
|
||||
bool SetPhasesDraw(int phases);
|
||||
bool LinesOverlap() const;
|
||||
|
||||
void ClearAllTabstops();
|
||||
int NextTabstopPos(int line, int x, int tabWidth) const;
|
||||
bool ClearTabstops(int line);
|
||||
bool AddTabstop(int line, int x);
|
||||
int GetNextTabstop(int line, int x) const;
|
||||
void LinesAddedOrRemoved(int lineOfPos, int linesAdded);
|
||||
|
||||
void DropGraphics(bool freeObjects);
|
||||
void AllocateGraphics(const ViewStyle &vsDraw);
|
||||
void RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewStyle &vsDraw);
|
||||
|
||||
LineLayout *RetrieveLineLayout(int lineNumber, const EditModel &model);
|
||||
void LayoutLine(const EditModel &model, int line, Surface *surface, const ViewStyle &vstyle,
|
||||
LineLayout *ll, int width = LineLayout::wrapWidthInfinite);
|
||||
|
||||
Point LocationFromPosition(Surface *surface, const EditModel &model, SelectionPosition pos, int topLine, const ViewStyle &vs);
|
||||
SelectionPosition SPositionFromLocation(Surface *surface, const EditModel &model, Point pt, bool canReturnInvalid,
|
||||
bool charPosition, bool virtualSpace, const ViewStyle &vs);
|
||||
SelectionPosition SPositionFromLineX(Surface *surface, const EditModel &model, int lineDoc, int x, const ViewStyle &vs);
|
||||
int DisplayFromPosition(Surface *surface, const EditModel &model, int pos, const ViewStyle &vs);
|
||||
int StartEndDisplayLine(Surface *surface, const EditModel &model, int pos, bool start, const ViewStyle &vs);
|
||||
|
||||
void DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight);
|
||||
void DrawEOL(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, PRectangle rcLine,
|
||||
int line, int lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart,
|
||||
ColourOptional background);
|
||||
void DrawAnnotation(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
|
||||
int line, int xStart, PRectangle rcLine, int subLine, DrawPhase phase);
|
||||
void DrawCarets(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, int line,
|
||||
int xStart, PRectangle rcLine, int subLine) const;
|
||||
void DrawBackground(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, PRectangle rcLine,
|
||||
Range lineRange, int posLineStart, int xStart,
|
||||
int subLine, ColourOptional background) const;
|
||||
void DrawForeground(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, int lineVisible,
|
||||
PRectangle rcLine, Range lineRange, int posLineStart, int xStart,
|
||||
int subLine, ColourOptional background);
|
||||
void DrawIndentGuidesOverEmpty(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
|
||||
int line, int lineVisible, PRectangle rcLine, int xStart, int subLine);
|
||||
void DrawLine(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, int line,
|
||||
int lineVisible, int xStart, PRectangle rcLine, int subLine, DrawPhase phase);
|
||||
void PaintText(Surface *surfaceWindow, const EditModel &model, PRectangle rcArea, PRectangle rcClient,
|
||||
const ViewStyle &vsDraw);
|
||||
long FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface, Surface *surfaceMeasure,
|
||||
const EditModel &model, const ViewStyle &vs);
|
||||
};
|
||||
|
||||
/**
|
||||
* Convenience class to ensure LineLayout objects are always disposed.
|
||||
*/
|
||||
class AutoLineLayout {
|
||||
LineLayoutCache &llc;
|
||||
LineLayout *ll;
|
||||
AutoLineLayout &operator=(const AutoLineLayout &);
|
||||
public:
|
||||
AutoLineLayout(LineLayoutCache &llc_, LineLayout *ll_) : llc(llc_), ll(ll_) {}
|
||||
~AutoLineLayout() {
|
||||
llc.Dispose(ll);
|
||||
ll = 0;
|
||||
}
|
||||
LineLayout *operator->() const {
|
||||
return ll;
|
||||
}
|
||||
operator LineLayout *() const {
|
||||
return ll;
|
||||
}
|
||||
void Set(LineLayout *ll_) {
|
||||
llc.Dispose(ll);
|
||||
ll = ll_;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef SCI_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -12,17 +12,6 @@
|
||||
namespace Scintilla {
|
||||
#endif
|
||||
|
||||
/**
|
||||
*/
|
||||
class Caret {
|
||||
public:
|
||||
bool active;
|
||||
bool on;
|
||||
int period;
|
||||
|
||||
Caret();
|
||||
};
|
||||
|
||||
/**
|
||||
*/
|
||||
class Timer {
|
||||
@ -160,16 +149,9 @@ struct WrapPending {
|
||||
}
|
||||
};
|
||||
|
||||
struct PrintParameters {
|
||||
int magnification;
|
||||
int colourMode;
|
||||
WrapMode wrapState;
|
||||
PrintParameters();
|
||||
};
|
||||
|
||||
/**
|
||||
*/
|
||||
class Editor : public DocWatcher {
|
||||
class Editor : public EditModel, public DocWatcher {
|
||||
// Private so Editor objects can not be copied
|
||||
Editor(const Editor &);
|
||||
Editor &operator=(const Editor &);
|
||||
@ -189,32 +171,17 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
Point sizeRGBAImage;
|
||||
float scaleRGBAImage;
|
||||
|
||||
PrintParameters printParameters;
|
||||
MarginView marginView;
|
||||
EditView view;
|
||||
|
||||
int cursorMode;
|
||||
|
||||
// Highlight current folding block
|
||||
HighlightDelimiter highlightDelimiter;
|
||||
|
||||
bool hasFocus;
|
||||
bool hideSelection;
|
||||
bool inOverstrike;
|
||||
bool drawOverstrikeCaret;
|
||||
bool mouseDownCaptures;
|
||||
|
||||
/** 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;
|
||||
/** In twoPhaseDraw mode, drawing is performed in two phases, first the background
|
||||
* and then the foreground. This avoids chopping off characters that overlap the next run. */
|
||||
bool twoPhaseDraw;
|
||||
|
||||
int xOffset; ///< Horizontal scrolled amount in pixels
|
||||
int xCaretMargin; ///< Ensure this many pixels visible on both sides of caret
|
||||
bool horizontalScrollBarVisible;
|
||||
int scrollWidth;
|
||||
bool trackLineWidth;
|
||||
int lineWidthMaxSeen;
|
||||
bool verticalScrollBarVisible;
|
||||
bool endAtLastLine;
|
||||
int caretSticky;
|
||||
@ -223,25 +190,11 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
bool multipleSelection;
|
||||
bool additionalSelectionTyping;
|
||||
int multiPasteMode;
|
||||
bool additionalCaretsBlink;
|
||||
bool additionalCaretsVisible;
|
||||
|
||||
int virtualSpaceOptions;
|
||||
|
||||
Surface *pixmapLine;
|
||||
Surface *pixmapSelMargin;
|
||||
Surface *pixmapSelPattern;
|
||||
Surface *pixmapSelPatternOffset1;
|
||||
Surface *pixmapIndentGuide;
|
||||
Surface *pixmapIndentGuideHighlight;
|
||||
|
||||
LineLayoutCache llc;
|
||||
PositionCache posCache;
|
||||
SpecialRepresentations reprs;
|
||||
|
||||
KeyMap kmap;
|
||||
|
||||
Caret caret;
|
||||
Timer timer;
|
||||
Timer autoScrollTimer;
|
||||
enum { autoScrollDelay = 200 };
|
||||
@ -257,7 +210,6 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
Point ptMouseLast;
|
||||
enum { ddNone, ddInitial, ddDragging } inDragDrop;
|
||||
bool dropWentOutside;
|
||||
SelectionPosition posDrag;
|
||||
SelectionPosition posDrop;
|
||||
int hotSpotClickPos;
|
||||
int lastXChosen;
|
||||
@ -274,9 +226,6 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
int lengthForEncode;
|
||||
|
||||
int needUpdateUI;
|
||||
Position braces[2];
|
||||
int bracesMatchStyle;
|
||||
int highlightGuideColumn;
|
||||
|
||||
enum { notPainting, painting, paintAbandoned } paintState;
|
||||
bool paintAbandonedByStyling;
|
||||
@ -288,8 +237,6 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
int modEventMask;
|
||||
|
||||
SelectionText drag;
|
||||
Selection sel;
|
||||
bool primarySelection;
|
||||
|
||||
int caretXPolicy;
|
||||
int caretXSlop; ///< Ensure this many pixels visible on both sides of caret
|
||||
@ -304,21 +251,13 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
|
||||
bool recordingMacro;
|
||||
|
||||
int foldFlags;
|
||||
int foldAutomatic;
|
||||
ContractionState cs;
|
||||
|
||||
// Hotspot support
|
||||
Range hotspot;
|
||||
|
||||
// Wrapping support
|
||||
int wrapWidth;
|
||||
WrapPending wrapPending;
|
||||
|
||||
bool convertPastes;
|
||||
|
||||
Document *pdoc;
|
||||
|
||||
Editor();
|
||||
virtual ~Editor();
|
||||
virtual void Initialise() = 0;
|
||||
@ -333,23 +272,23 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
|
||||
// The top left visible point in main window coordinates. Will be 0,0 except for
|
||||
// scroll views where it will be equivalent to the current scroll position.
|
||||
virtual Point GetVisibleOriginInMain();
|
||||
Point DocumentPointFromView(Point ptView); // Convert a point from view space to document
|
||||
virtual Point GetVisibleOriginInMain() const;
|
||||
Point DocumentPointFromView(Point ptView) const; // Convert a point from view space to document
|
||||
int TopLineOfMain() const; // Return the line at Main's y coordinate 0
|
||||
virtual PRectangle GetClientRectangle();
|
||||
virtual PRectangle GetClientRectangle() const;
|
||||
virtual PRectangle GetClientDrawingRectangle();
|
||||
PRectangle GetTextRectangle();
|
||||
PRectangle GetTextRectangle() const;
|
||||
|
||||
int LinesOnScreen();
|
||||
int LinesToScroll();
|
||||
int MaxScrollPos();
|
||||
virtual int LinesOnScreen() const;
|
||||
int LinesToScroll() const;
|
||||
int MaxScrollPos() const;
|
||||
SelectionPosition ClampPositionIntoDocument(SelectionPosition sp) const;
|
||||
Point LocationFromPosition(SelectionPosition pos);
|
||||
Point LocationFromPosition(int pos);
|
||||
int XFromPosition(int pos);
|
||||
int XFromPosition(SelectionPosition sp);
|
||||
SelectionPosition SPositionFromLocation(Point pt, bool canReturnInvalid=false, bool charPosition=false, bool virtualSpace=true);
|
||||
int PositionFromLocation(Point pt, bool canReturnInvalid=false, bool charPosition=false);
|
||||
int PositionFromLocation(Point pt, bool canReturnInvalid = false, bool charPosition = false);
|
||||
SelectionPosition SPositionFromLineX(int lineDoc, int x);
|
||||
int PositionFromLineX(int line, int x);
|
||||
int LineFromLocation(Point pt) const;
|
||||
@ -360,7 +299,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
virtual void DiscardOverdraw();
|
||||
virtual void Redraw();
|
||||
void RedrawSelMargin(int line=-1, bool allAfter=false);
|
||||
PRectangle RectangleFromRange(Range r);
|
||||
PRectangle RectangleFromRange(Range r, int overlap);
|
||||
void InvalidateRange(int start, int end);
|
||||
|
||||
bool UserVirtualSpace() const {
|
||||
@ -383,8 +322,8 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
bool SelectionContainsProtected();
|
||||
int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true) const;
|
||||
SelectionPosition MovePositionOutsideChar(SelectionPosition pos, int moveDir, bool checkLineEnd=true) const;
|
||||
int MovePositionTo(SelectionPosition newPos, Selection::selTypes sel=Selection::noSel, bool ensureVisible=true);
|
||||
int MovePositionTo(int newPos, Selection::selTypes sel=Selection::noSel, bool ensureVisible=true);
|
||||
int MovePositionTo(SelectionPosition newPos, Selection::selTypes selt=Selection::noSel, bool ensureVisible=true);
|
||||
int MovePositionTo(int newPos, Selection::selTypes selt=Selection::noSel, bool ensureVisible=true);
|
||||
SelectionPosition MovePositionSoVisible(SelectionPosition pos, int moveDir);
|
||||
SelectionPosition MovePositionSoVisible(int pos, int moveDir);
|
||||
Point PointMainCaret();
|
||||
@ -431,30 +370,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
void LinesJoin();
|
||||
void LinesSplit(int pixelWidth);
|
||||
|
||||
int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault) const;
|
||||
void PaintSelMargin(Surface *surface, PRectangle &rc);
|
||||
LineLayout *RetrieveLineLayout(int lineNumber);
|
||||
void LayoutLine(int line, Surface *surface, const ViewStyle &vstyle, LineLayout *ll,
|
||||
int width=LineLayout::wrapWidthInfinite);
|
||||
ColourDesired SelectionBackground(const ViewStyle &vsDraw, bool main) const;
|
||||
ColourDesired TextBackground(const ViewStyle &vsDraw, ColourOptional background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) const;
|
||||
void DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight);
|
||||
static void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourDesired wrapColour);
|
||||
void DrawEOL(Surface *surface, const ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll,
|
||||
int line, int lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart,
|
||||
ColourOptional background);
|
||||
static void DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, const ViewStyle &vsDraw,
|
||||
int xStart, PRectangle rcLine, LineLayout *ll, int subLine);
|
||||
void DrawIndicators(Surface *surface, const ViewStyle &vsDraw, int line, int xStart,
|
||||
PRectangle rcLine, LineLayout *ll, int subLine, int lineEnd, bool under);
|
||||
void DrawAnnotation(Surface *surface, const ViewStyle &vsDraw, int line, int xStart,
|
||||
PRectangle rcLine, LineLayout *ll, int subLine);
|
||||
void DrawLine(Surface *surface, const ViewStyle &vsDraw, int line, int lineVisible, int xStart,
|
||||
PRectangle rcLine, LineLayout *ll, int subLine);
|
||||
void DrawBlockCaret(Surface *surface, const ViewStyle &vsDraw, LineLayout *ll, int subLine,
|
||||
int xStart, int offset, int posCaret, PRectangle rcCaret, ColourDesired caretColour) const;
|
||||
void DrawCarets(Surface *surface, const ViewStyle &vsDraw, int line, int xStart,
|
||||
PRectangle rcLine, LineLayout *ll, int subLine);
|
||||
void RefreshPixMaps(Surface *surfaceWindow);
|
||||
void Paint(Surface *surfaceWindow, PRectangle rcArea);
|
||||
long FormatRange(bool draw, Sci_RangeToFormat *pfr);
|
||||
@ -470,7 +386,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
void FilterSelections();
|
||||
int InsertSpace(int position, unsigned int spaces);
|
||||
void AddChar(char ch);
|
||||
virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
|
||||
virtual void AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS=false);
|
||||
void InsertPaste(const char *text, int len);
|
||||
enum PasteShape { pasteStream=0, pasteRectangular = 1, pasteLine = 2 };
|
||||
void InsertPasteShape(const char *text, int len, PasteShape shape);
|
||||
@ -530,7 +446,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
void NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
|
||||
|
||||
void ContainerNeedsUpdate(int flags);
|
||||
void PageMove(int direction, Selection::selTypes sel=Selection::noSel, bool stuttered = false);
|
||||
void PageMove(int direction, Selection::selTypes selt=Selection::noSel, bool stuttered = false);
|
||||
enum { cmSame, cmUpper, cmLower };
|
||||
virtual std::string CaseMapString(const std::string &s, int caseMapping);
|
||||
void ChangeCaseOfSelection(int caseMapping);
|
||||
@ -538,8 +454,8 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
void Duplicate(bool forLine);
|
||||
virtual void CancelModes();
|
||||
void NewLine();
|
||||
void CursorUpOrDown(int direction, Selection::selTypes sel=Selection::noSel);
|
||||
void ParaUpOrDown(int direction, Selection::selTypes sel=Selection::noSel);
|
||||
void CursorUpOrDown(int direction, Selection::selTypes selt=Selection::noSel);
|
||||
void ParaUpOrDown(int direction, Selection::selTypes selt=Selection::noSel);
|
||||
int StartEndDisplayLine(int pos, bool start);
|
||||
virtual int KeyCommand(unsigned int iMessage);
|
||||
virtual int KeyDefault(int /* key */, int /*modifiers*/);
|
||||
@ -569,7 +485,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
/** PositionInSelection returns true if position in selection. */
|
||||
bool PositionInSelection(int pos);
|
||||
bool PointInSelection(Point pt);
|
||||
bool PointInSelMargin(Point pt);
|
||||
bool PointInSelMargin(Point pt) const;
|
||||
Window::Cursor GetMarginCursor(Point pt) const;
|
||||
void TrimAndSetSelection(int currentPos_, int anchor_);
|
||||
void LineSelection(int lineCurrentPos_, int lineAnchorPos_, bool wholeLine);
|
||||
@ -584,7 +500,13 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
|
||||
void Tick();
|
||||
bool Idle();
|
||||
virtual void SetTicking(bool on) = 0;
|
||||
virtual void SetTicking(bool on);
|
||||
enum TickReason { tickCaret, tickScroll, tickWiden, tickDwell, tickPlatform };
|
||||
virtual void TickFor(TickReason reason);
|
||||
virtual bool FineTickerAvailable();
|
||||
virtual bool FineTickerRunning(TickReason reason);
|
||||
virtual void FineTickerStart(TickReason reason, int millis, int tolerance);
|
||||
virtual void FineTickerCancel(TickReason reason);
|
||||
virtual bool SetIdle(bool) { return false; }
|
||||
virtual void SetMouseCapture(bool on) = 0;
|
||||
virtual bool HaveMouseCapture() = 0;
|
||||
|
@ -72,23 +72,23 @@ static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, C
|
||||
}
|
||||
|
||||
void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter, typeOfFold tFold, int marginStyle) const {
|
||||
ColourDesired head = back;
|
||||
ColourDesired body = back;
|
||||
ColourDesired tail = back;
|
||||
ColourDesired colourHead = back;
|
||||
ColourDesired colourBody = back;
|
||||
ColourDesired colourTail = back;
|
||||
|
||||
switch (tFold) {
|
||||
case LineMarker::head :
|
||||
case LineMarker::headWithTail :
|
||||
head = backSelected;
|
||||
tail = backSelected;
|
||||
colourHead = backSelected;
|
||||
colourTail = backSelected;
|
||||
break;
|
||||
case LineMarker::body :
|
||||
head = backSelected;
|
||||
body = backSelected;
|
||||
colourHead = backSelected;
|
||||
colourBody = backSelected;
|
||||
break;
|
||||
case LineMarker::tail :
|
||||
body = backSelected;
|
||||
tail = backSelected;
|
||||
colourBody = backSelected;
|
||||
colourTail = backSelected;
|
||||
break;
|
||||
default :
|
||||
// LineMarker::undefined
|
||||
@ -192,69 +192,69 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
|
||||
// An invisible marker so don't draw anything
|
||||
|
||||
} else if (markType == SC_MARK_VLINE) {
|
||||
surface->PenColour(body);
|
||||
surface->PenColour(colourBody);
|
||||
surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
|
||||
surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
|
||||
|
||||
} else if (markType == SC_MARK_LCORNER) {
|
||||
surface->PenColour(tail);
|
||||
surface->PenColour(colourTail);
|
||||
surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
|
||||
surface->LineTo(centreX, centreY);
|
||||
surface->LineTo(static_cast<int>(rc.right) - 1, centreY);
|
||||
|
||||
} else if (markType == SC_MARK_TCORNER) {
|
||||
surface->PenColour(tail);
|
||||
surface->PenColour(colourTail);
|
||||
surface->MoveTo(centreX, centreY);
|
||||
surface->LineTo(static_cast<int>(rc.right) - 1, centreY);
|
||||
|
||||
surface->PenColour(body);
|
||||
surface->PenColour(colourBody);
|
||||
surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
|
||||
surface->LineTo(centreX, centreY + 1);
|
||||
|
||||
surface->PenColour(head);
|
||||
surface->PenColour(colourHead);
|
||||
surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
|
||||
|
||||
} else if (markType == SC_MARK_LCORNERCURVE) {
|
||||
surface->PenColour(tail);
|
||||
surface->PenColour(colourTail);
|
||||
surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
|
||||
surface->LineTo(centreX, centreY-3);
|
||||
surface->LineTo(centreX+3, centreY);
|
||||
surface->LineTo(static_cast<int>(rc.right) - 1, centreY);
|
||||
|
||||
} else if (markType == SC_MARK_TCORNERCURVE) {
|
||||
surface->PenColour(tail);
|
||||
surface->PenColour(colourTail);
|
||||
surface->MoveTo(centreX, centreY-3);
|
||||
surface->LineTo(centreX+3, centreY);
|
||||
surface->LineTo(static_cast<int>(rc.right) - 1, centreY);
|
||||
|
||||
surface->PenColour(body);
|
||||
surface->PenColour(colourBody);
|
||||
surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
|
||||
surface->LineTo(centreX, centreY-2);
|
||||
|
||||
surface->PenColour(head);
|
||||
surface->PenColour(colourHead);
|
||||
surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
|
||||
|
||||
} else if (markType == SC_MARK_BOXPLUS) {
|
||||
DrawBox(surface, centreX, centreY, blobSize, fore, head);
|
||||
DrawPlus(surface, centreX, centreY, blobSize, tail);
|
||||
DrawBox(surface, centreX, centreY, blobSize, fore, colourHead);
|
||||
DrawPlus(surface, centreX, centreY, blobSize, colourTail);
|
||||
|
||||
} else if (markType == SC_MARK_BOXPLUSCONNECTED) {
|
||||
if (tFold == LineMarker::headWithTail)
|
||||
surface->PenColour(tail);
|
||||
surface->PenColour(colourTail);
|
||||
else
|
||||
surface->PenColour(body);
|
||||
surface->PenColour(colourBody);
|
||||
surface->MoveTo(centreX, centreY + blobSize);
|
||||
surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
|
||||
|
||||
surface->PenColour(body);
|
||||
surface->PenColour(colourBody);
|
||||
surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
|
||||
surface->LineTo(centreX, centreY - blobSize);
|
||||
|
||||
DrawBox(surface, centreX, centreY, blobSize, fore, head);
|
||||
DrawPlus(surface, centreX, centreY, blobSize, tail);
|
||||
DrawBox(surface, centreX, centreY, blobSize, fore, colourHead);
|
||||
DrawPlus(surface, centreX, centreY, blobSize, colourTail);
|
||||
|
||||
if (tFold == LineMarker::body) {
|
||||
surface->PenColour(tail);
|
||||
surface->PenColour(colourTail);
|
||||
surface->MoveTo(centreX + 1, centreY + blobSize);
|
||||
surface->LineTo(centreX + blobSize + 1, centreY + blobSize);
|
||||
|
||||
@ -265,27 +265,27 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
|
||||
surface->LineTo(centreX + blobSize + 1, centreY - blobSize);
|
||||
}
|
||||
} else if (markType == SC_MARK_BOXMINUS) {
|
||||
DrawBox(surface, centreX, centreY, blobSize, fore, head);
|
||||
DrawMinus(surface, centreX, centreY, blobSize, tail);
|
||||
DrawBox(surface, centreX, centreY, blobSize, fore, colourHead);
|
||||
DrawMinus(surface, centreX, centreY, blobSize, colourTail);
|
||||
|
||||
surface->PenColour(head);
|
||||
surface->PenColour(colourHead);
|
||||
surface->MoveTo(centreX, centreY + blobSize);
|
||||
surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
|
||||
|
||||
} else if (markType == SC_MARK_BOXMINUSCONNECTED) {
|
||||
DrawBox(surface, centreX, centreY, blobSize, fore, head);
|
||||
DrawMinus(surface, centreX, centreY, blobSize, tail);
|
||||
DrawBox(surface, centreX, centreY, blobSize, fore, colourHead);
|
||||
DrawMinus(surface, centreX, centreY, blobSize, colourTail);
|
||||
|
||||
surface->PenColour(head);
|
||||
surface->PenColour(colourHead);
|
||||
surface->MoveTo(centreX, centreY + blobSize);
|
||||
surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
|
||||
|
||||
surface->PenColour(body);
|
||||
surface->PenColour(colourBody);
|
||||
surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
|
||||
surface->LineTo(centreX, centreY - blobSize);
|
||||
|
||||
if (tFold == LineMarker::body) {
|
||||
surface->PenColour(tail);
|
||||
surface->PenColour(colourTail);
|
||||
surface->MoveTo(centreX + 1, centreY + blobSize);
|
||||
surface->LineTo(centreX + blobSize + 1, centreY + blobSize);
|
||||
|
||||
@ -296,43 +296,43 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
|
||||
surface->LineTo(centreX + blobSize + 1, centreY - blobSize);
|
||||
}
|
||||
} else if (markType == SC_MARK_CIRCLEPLUS) {
|
||||
DrawCircle(surface, centreX, centreY, blobSize, fore, head);
|
||||
DrawPlus(surface, centreX, centreY, blobSize, tail);
|
||||
DrawCircle(surface, centreX, centreY, blobSize, fore, colourHead);
|
||||
DrawPlus(surface, centreX, centreY, blobSize, colourTail);
|
||||
|
||||
} else if (markType == SC_MARK_CIRCLEPLUSCONNECTED) {
|
||||
if (tFold == LineMarker::headWithTail)
|
||||
surface->PenColour(tail);
|
||||
surface->PenColour(colourTail);
|
||||
else
|
||||
surface->PenColour(body);
|
||||
surface->PenColour(colourBody);
|
||||
surface->MoveTo(centreX, centreY + blobSize);
|
||||
surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
|
||||
|
||||
surface->PenColour(body);
|
||||
surface->PenColour(colourBody);
|
||||
surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
|
||||
surface->LineTo(centreX, centreY - blobSize);
|
||||
|
||||
DrawCircle(surface, centreX, centreY, blobSize, fore, head);
|
||||
DrawPlus(surface, centreX, centreY, blobSize, tail);
|
||||
DrawCircle(surface, centreX, centreY, blobSize, fore, colourHead);
|
||||
DrawPlus(surface, centreX, centreY, blobSize, colourTail);
|
||||
|
||||
} else if (markType == SC_MARK_CIRCLEMINUS) {
|
||||
surface->PenColour(head);
|
||||
surface->PenColour(colourHead);
|
||||
surface->MoveTo(centreX, centreY + blobSize);
|
||||
surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
|
||||
|
||||
DrawCircle(surface, centreX, centreY, blobSize, fore, head);
|
||||
DrawMinus(surface, centreX, centreY, blobSize, tail);
|
||||
DrawCircle(surface, centreX, centreY, blobSize, fore, colourHead);
|
||||
DrawMinus(surface, centreX, centreY, blobSize, colourTail);
|
||||
|
||||
} else if (markType == SC_MARK_CIRCLEMINUSCONNECTED) {
|
||||
surface->PenColour(head);
|
||||
surface->PenColour(colourHead);
|
||||
surface->MoveTo(centreX, centreY + blobSize);
|
||||
surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
|
||||
|
||||
surface->PenColour(body);
|
||||
surface->PenColour(colourBody);
|
||||
surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
|
||||
surface->LineTo(centreX, centreY - blobSize);
|
||||
|
||||
DrawCircle(surface, centreX, centreY, blobSize, fore, head);
|
||||
DrawMinus(surface, centreX, centreY, blobSize, tail);
|
||||
DrawCircle(surface, centreX, centreY, blobSize, fore, colourHead);
|
||||
DrawMinus(surface, centreX, centreY, blobSize, colourTail);
|
||||
|
||||
} else if (markType >= SC_MARK_CHARACTER) {
|
||||
char character[1];
|
||||
|
455
scintilla/src/MarginView.cxx
Normal file
455
scintilla/src/MarginView.cxx
Normal file
@ -0,0 +1,455 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file MarginView.cxx
|
||||
** Defines the appearance of the editor margin.
|
||||
**/
|
||||
// Copyright 1998-2014 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 <math.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "ILexer.h"
|
||||
#include "Scintilla.h"
|
||||
|
||||
#include "StringCopy.h"
|
||||
#include "SplitVector.h"
|
||||
#include "Partitioning.h"
|
||||
#include "RunStyles.h"
|
||||
#include "ContractionState.h"
|
||||
#include "CellBuffer.h"
|
||||
#include "KeyMap.h"
|
||||
#include "Indicator.h"
|
||||
#include "XPM.h"
|
||||
#include "LineMarker.h"
|
||||
#include "Style.h"
|
||||
#include "ViewStyle.h"
|
||||
#include "CharClassify.h"
|
||||
#include "Decoration.h"
|
||||
#include "CaseFolder.h"
|
||||
#include "Document.h"
|
||||
#include "UniConversion.h"
|
||||
#include "Selection.h"
|
||||
#include "PositionCache.h"
|
||||
#include "EditModel.h"
|
||||
#include "MarginView.h"
|
||||
#include "EditView.h"
|
||||
|
||||
#ifdef SCI_NAMESPACE
|
||||
using namespace Scintilla;
|
||||
#endif
|
||||
|
||||
#ifdef SCI_NAMESPACE
|
||||
namespace Scintilla {
|
||||
#endif
|
||||
|
||||
void DrawWrapMarker(Surface *surface, PRectangle rcPlace,
|
||||
bool isEndMarker, ColourDesired wrapColour) {
|
||||
surface->PenColour(wrapColour);
|
||||
|
||||
enum { xa = 1 }; // gap before start
|
||||
int w = static_cast<int>(rcPlace.right - rcPlace.left) - xa - 1;
|
||||
|
||||
bool xStraight = isEndMarker; // x-mirrored symbol for start marker
|
||||
|
||||
int x0 = static_cast<int>(xStraight ? rcPlace.left : rcPlace.right - 1);
|
||||
int y0 = static_cast<int>(rcPlace.top);
|
||||
|
||||
int dy = static_cast<int>(rcPlace.bottom - rcPlace.top) / 5;
|
||||
int y = static_cast<int>(rcPlace.bottom - rcPlace.top) / 2 + dy;
|
||||
|
||||
struct Relative {
|
||||
Surface *surface;
|
||||
int xBase;
|
||||
int xDir;
|
||||
int yBase;
|
||||
int yDir;
|
||||
void MoveTo(int xRelative, int yRelative) {
|
||||
surface->MoveTo(xBase + xDir * xRelative, yBase + yDir * yRelative);
|
||||
}
|
||||
void LineTo(int xRelative, int yRelative) {
|
||||
surface->LineTo(xBase + xDir * xRelative, yBase + yDir * yRelative);
|
||||
}
|
||||
};
|
||||
Relative rel = { surface, x0, xStraight ? 1 : -1, y0, 1 };
|
||||
|
||||
// arrow head
|
||||
rel.MoveTo(xa, y);
|
||||
rel.LineTo(xa + 2 * w / 3, y - dy);
|
||||
rel.MoveTo(xa, y);
|
||||
rel.LineTo(xa + 2 * w / 3, y + dy);
|
||||
|
||||
// arrow body
|
||||
rel.MoveTo(xa, y);
|
||||
rel.LineTo(xa + w, y);
|
||||
rel.LineTo(xa + w, y - 2 * dy);
|
||||
rel.LineTo(xa - 1, // on windows lineto is exclusive endpoint, perhaps GTK not...
|
||||
y - 2 * dy);
|
||||
}
|
||||
|
||||
MarginView::MarginView() {
|
||||
pixmapSelMargin = 0;
|
||||
pixmapSelPattern = 0;
|
||||
pixmapSelPatternOffset1 = 0;
|
||||
}
|
||||
|
||||
void MarginView::DropGraphics(bool freeObjects) {
|
||||
if (freeObjects) {
|
||||
delete pixmapSelMargin;
|
||||
pixmapSelMargin = 0;
|
||||
delete pixmapSelPattern;
|
||||
pixmapSelPattern = 0;
|
||||
delete pixmapSelPatternOffset1;
|
||||
pixmapSelPatternOffset1 = 0;
|
||||
} else {
|
||||
if (pixmapSelMargin)
|
||||
pixmapSelMargin->Release();
|
||||
if (pixmapSelPattern)
|
||||
pixmapSelPattern->Release();
|
||||
if (pixmapSelPatternOffset1)
|
||||
pixmapSelPatternOffset1->Release();
|
||||
}
|
||||
}
|
||||
|
||||
void MarginView::AllocateGraphics(const ViewStyle &vsDraw) {
|
||||
if (!pixmapSelMargin)
|
||||
pixmapSelMargin = Surface::Allocate(vsDraw.technology);
|
||||
if (!pixmapSelPattern)
|
||||
pixmapSelPattern = Surface::Allocate(vsDraw.technology);
|
||||
if (!pixmapSelPatternOffset1)
|
||||
pixmapSelPatternOffset1 = Surface::Allocate(vsDraw.technology);
|
||||
}
|
||||
|
||||
void MarginView::RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewStyle &vsDraw) {
|
||||
if (!pixmapSelPattern->Initialised()) {
|
||||
const int patternSize = 8;
|
||||
pixmapSelPattern->InitPixMap(patternSize, patternSize, surfaceWindow, wid);
|
||||
pixmapSelPatternOffset1->InitPixMap(patternSize, patternSize, surfaceWindow, wid);
|
||||
// This complex procedure is to reproduce the checkerboard dithered pattern used by windows
|
||||
// for scroll bars and Visual Studio for its selection margin. The colour of this pattern is half
|
||||
// way between the chrome colour and the chrome highlight colour making a nice transition
|
||||
// between the window chrome and the content area. And it works in low colour depths.
|
||||
PRectangle rcPattern = PRectangle::FromInts(0, 0, patternSize, patternSize);
|
||||
|
||||
// Initialize default colours based on the chrome colour scheme. Typically the highlight is white.
|
||||
ColourDesired colourFMFill = vsDraw.selbar;
|
||||
ColourDesired colourFMStripes = vsDraw.selbarlight;
|
||||
|
||||
if (!(vsDraw.selbarlight == ColourDesired(0xff, 0xff, 0xff))) {
|
||||
// User has chosen an unusual chrome colour scheme so just use the highlight edge colour.
|
||||
// (Typically, the highlight colour is white.)
|
||||
colourFMFill = vsDraw.selbarlight;
|
||||
}
|
||||
|
||||
if (vsDraw.foldmarginColour.isSet) {
|
||||
// override default fold margin colour
|
||||
colourFMFill = vsDraw.foldmarginColour;
|
||||
}
|
||||
if (vsDraw.foldmarginHighlightColour.isSet) {
|
||||
// override default fold margin highlight colour
|
||||
colourFMStripes = vsDraw.foldmarginHighlightColour;
|
||||
}
|
||||
|
||||
pixmapSelPattern->FillRectangle(rcPattern, colourFMFill);
|
||||
pixmapSelPatternOffset1->FillRectangle(rcPattern, colourFMStripes);
|
||||
for (int y = 0; y < patternSize; y++) {
|
||||
for (int x = y % 2; x < patternSize; x += 2) {
|
||||
PRectangle rcPixel = PRectangle::FromInts(x, y, x + 1, y + 1);
|
||||
pixmapSelPattern->FillRectangle(rcPixel, colourFMStripes);
|
||||
pixmapSelPatternOffset1->FillRectangle(rcPixel, colourFMFill);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault, const ViewStyle &vs) {
|
||||
if (vs.markers[markerCheck].markType == SC_MARK_EMPTY)
|
||||
return markerDefault;
|
||||
return markerCheck;
|
||||
}
|
||||
|
||||
void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRectangle rcMargin,
|
||||
const EditModel &model, const ViewStyle &vs) {
|
||||
|
||||
PRectangle rcSelMargin = rcMargin;
|
||||
rcSelMargin.right = rcMargin.left;
|
||||
if (rcSelMargin.bottom < rc.bottom)
|
||||
rcSelMargin.bottom = rc.bottom;
|
||||
|
||||
Point ptOrigin = model.GetVisibleOriginInMain();
|
||||
FontAlias fontLineNumber = vs.styles[STYLE_LINENUMBER].font;
|
||||
for (int margin = 0; margin <= SC_MAX_MARGIN; margin++) {
|
||||
if (vs.ms[margin].width > 0) {
|
||||
|
||||
rcSelMargin.left = rcSelMargin.right;
|
||||
rcSelMargin.right = rcSelMargin.left + vs.ms[margin].width;
|
||||
|
||||
if (vs.ms[margin].style != SC_MARGIN_NUMBER) {
|
||||
if (vs.ms[margin].mask & SC_MASK_FOLDERS) {
|
||||
// Required because of special way brush is created for selection margin
|
||||
// Ensure patterns line up when scrolling with separate margin view
|
||||
// by choosing correctly aligned variant.
|
||||
bool invertPhase = static_cast<int>(ptOrigin.y) & 1;
|
||||
surface->FillRectangle(rcSelMargin,
|
||||
invertPhase ? *pixmapSelPattern : *pixmapSelPatternOffset1);
|
||||
} else {
|
||||
ColourDesired colour;
|
||||
switch (vs.ms[margin].style) {
|
||||
case SC_MARGIN_BACK:
|
||||
colour = vs.styles[STYLE_DEFAULT].back;
|
||||
break;
|
||||
case SC_MARGIN_FORE:
|
||||
colour = vs.styles[STYLE_DEFAULT].fore;
|
||||
break;
|
||||
default:
|
||||
colour = vs.styles[STYLE_LINENUMBER].back;
|
||||
break;
|
||||
}
|
||||
surface->FillRectangle(rcSelMargin, colour);
|
||||
}
|
||||
} else {
|
||||
surface->FillRectangle(rcSelMargin, vs.styles[STYLE_LINENUMBER].back);
|
||||
}
|
||||
|
||||
const int lineStartPaint = static_cast<int>(rcMargin.top + ptOrigin.y) / vs.lineHeight;
|
||||
int visibleLine = model.TopLineOfMain() + lineStartPaint;
|
||||
int yposScreen = lineStartPaint * vs.lineHeight - static_cast<int>(ptOrigin.y);
|
||||
// Work out whether the top line is whitespace located after a
|
||||
// lessening of fold level which implies a 'fold tail' but which should not
|
||||
// be displayed until the last of a sequence of whitespace.
|
||||
bool needWhiteClosure = false;
|
||||
if (vs.ms[margin].mask & SC_MASK_FOLDERS) {
|
||||
int level = model.pdoc->GetLevel(model.cs.DocFromDisplay(visibleLine));
|
||||
if (level & SC_FOLDLEVELWHITEFLAG) {
|
||||
int lineBack = model.cs.DocFromDisplay(visibleLine);
|
||||
int levelPrev = level;
|
||||
while ((lineBack > 0) && (levelPrev & SC_FOLDLEVELWHITEFLAG)) {
|
||||
lineBack--;
|
||||
levelPrev = model.pdoc->GetLevel(lineBack);
|
||||
}
|
||||
if (!(levelPrev & SC_FOLDLEVELHEADERFLAG)) {
|
||||
if ((level & SC_FOLDLEVELNUMBERMASK) < (levelPrev & SC_FOLDLEVELNUMBERMASK))
|
||||
needWhiteClosure = true;
|
||||
}
|
||||
}
|
||||
if (highlightDelimiter.isEnabled) {
|
||||
int lastLine = model.cs.DocFromDisplay(topLine + model.LinesOnScreen()) + 1;
|
||||
model.pdoc->GetHighlightDelimiters(highlightDelimiter, model.pdoc->LineFromPosition(model.sel.MainCaret()), lastLine);
|
||||
}
|
||||
}
|
||||
|
||||
// Old code does not know about new markers needed to distinguish all cases
|
||||
const int folderOpenMid = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEROPENMID,
|
||||
SC_MARKNUM_FOLDEROPEN, vs);
|
||||
const int folderEnd = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEREND,
|
||||
SC_MARKNUM_FOLDER, vs);
|
||||
|
||||
while ((visibleLine < model.cs.LinesDisplayed()) && yposScreen < rc.bottom) {
|
||||
|
||||
PLATFORM_ASSERT(visibleLine < model.cs.LinesDisplayed());
|
||||
const int lineDoc = model.cs.DocFromDisplay(visibleLine);
|
||||
PLATFORM_ASSERT(model.cs.GetVisible(lineDoc));
|
||||
const bool firstSubLine = visibleLine == model.cs.DisplayFromDoc(lineDoc);
|
||||
const bool lastSubLine = visibleLine == model.cs.DisplayLastFromDoc(lineDoc);
|
||||
|
||||
int marks = model.pdoc->GetMark(lineDoc);
|
||||
if (!firstSubLine)
|
||||
marks = 0;
|
||||
|
||||
bool headWithTail = false;
|
||||
|
||||
if (vs.ms[margin].mask & SC_MASK_FOLDERS) {
|
||||
// Decide which fold indicator should be displayed
|
||||
const int level = model.pdoc->GetLevel(lineDoc);
|
||||
const int levelNext = model.pdoc->GetLevel(lineDoc + 1);
|
||||
const int levelNum = level & SC_FOLDLEVELNUMBERMASK;
|
||||
const int levelNextNum = levelNext & SC_FOLDLEVELNUMBERMASK;
|
||||
if (level & SC_FOLDLEVELHEADERFLAG) {
|
||||
if (firstSubLine) {
|
||||
if (levelNum < levelNextNum) {
|
||||
if (model.cs.GetExpanded(lineDoc)) {
|
||||
if (levelNum == SC_FOLDLEVELBASE)
|
||||
marks |= 1 << SC_MARKNUM_FOLDEROPEN;
|
||||
else
|
||||
marks |= 1 << folderOpenMid;
|
||||
} else {
|
||||
if (levelNum == SC_FOLDLEVELBASE)
|
||||
marks |= 1 << SC_MARKNUM_FOLDER;
|
||||
else
|
||||
marks |= 1 << folderEnd;
|
||||
}
|
||||
} else if (levelNum > SC_FOLDLEVELBASE) {
|
||||
marks |= 1 << SC_MARKNUM_FOLDERSUB;
|
||||
}
|
||||
} else {
|
||||
if (levelNum < levelNextNum) {
|
||||
if (model.cs.GetExpanded(lineDoc)) {
|
||||
marks |= 1 << SC_MARKNUM_FOLDERSUB;
|
||||
} else if (levelNum > SC_FOLDLEVELBASE) {
|
||||
marks |= 1 << SC_MARKNUM_FOLDERSUB;
|
||||
}
|
||||
} else if (levelNum > SC_FOLDLEVELBASE) {
|
||||
marks |= 1 << SC_MARKNUM_FOLDERSUB;
|
||||
}
|
||||
}
|
||||
needWhiteClosure = false;
|
||||
const int firstFollowupLine = model.cs.DocFromDisplay(model.cs.DisplayFromDoc(lineDoc + 1));
|
||||
const int firstFollowupLineLevel = model.pdoc->GetLevel(firstFollowupLine);
|
||||
const int secondFollowupLineLevelNum = model.pdoc->GetLevel(firstFollowupLine + 1) & SC_FOLDLEVELNUMBERMASK;
|
||||
if (!model.cs.GetExpanded(lineDoc)) {
|
||||
if ((firstFollowupLineLevel & SC_FOLDLEVELWHITEFLAG) &&
|
||||
(levelNum > secondFollowupLineLevelNum))
|
||||
needWhiteClosure = true;
|
||||
|
||||
if (highlightDelimiter.IsFoldBlockHighlighted(firstFollowupLine))
|
||||
headWithTail = true;
|
||||
}
|
||||
} else if (level & SC_FOLDLEVELWHITEFLAG) {
|
||||
if (needWhiteClosure) {
|
||||
if (levelNext & SC_FOLDLEVELWHITEFLAG) {
|
||||
marks |= 1 << SC_MARKNUM_FOLDERSUB;
|
||||
} else if (levelNextNum > SC_FOLDLEVELBASE) {
|
||||
marks |= 1 << SC_MARKNUM_FOLDERMIDTAIL;
|
||||
needWhiteClosure = false;
|
||||
} else {
|
||||
marks |= 1 << SC_MARKNUM_FOLDERTAIL;
|
||||
needWhiteClosure = false;
|
||||
}
|
||||
} else if (levelNum > SC_FOLDLEVELBASE) {
|
||||
if (levelNextNum < levelNum) {
|
||||
if (levelNextNum > SC_FOLDLEVELBASE) {
|
||||
marks |= 1 << SC_MARKNUM_FOLDERMIDTAIL;
|
||||
} else {
|
||||
marks |= 1 << SC_MARKNUM_FOLDERTAIL;
|
||||
}
|
||||
} else {
|
||||
marks |= 1 << SC_MARKNUM_FOLDERSUB;
|
||||
}
|
||||
}
|
||||
} else if (levelNum > SC_FOLDLEVELBASE) {
|
||||
if (levelNextNum < levelNum) {
|
||||
needWhiteClosure = false;
|
||||
if (levelNext & SC_FOLDLEVELWHITEFLAG) {
|
||||
marks |= 1 << SC_MARKNUM_FOLDERSUB;
|
||||
needWhiteClosure = true;
|
||||
} else if (lastSubLine) {
|
||||
if (levelNextNum > SC_FOLDLEVELBASE) {
|
||||
marks |= 1 << SC_MARKNUM_FOLDERMIDTAIL;
|
||||
} else {
|
||||
marks |= 1 << SC_MARKNUM_FOLDERTAIL;
|
||||
}
|
||||
} else {
|
||||
marks |= 1 << SC_MARKNUM_FOLDERSUB;
|
||||
}
|
||||
} else {
|
||||
marks |= 1 << SC_MARKNUM_FOLDERSUB;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
marks &= vs.ms[margin].mask;
|
||||
|
||||
PRectangle rcMarker = rcSelMargin;
|
||||
rcMarker.top = static_cast<XYPOSITION>(yposScreen);
|
||||
rcMarker.bottom = static_cast<XYPOSITION>(yposScreen + vs.lineHeight);
|
||||
if (vs.ms[margin].style == SC_MARGIN_NUMBER) {
|
||||
if (firstSubLine) {
|
||||
char number[100] = "";
|
||||
if (lineDoc >= 0)
|
||||
sprintf(number, "%d", lineDoc + 1);
|
||||
if (model.foldFlags & (SC_FOLDFLAG_LEVELNUMBERS | SC_FOLDFLAG_LINESTATE)) {
|
||||
if (model.foldFlags & SC_FOLDFLAG_LEVELNUMBERS) {
|
||||
int lev = model.pdoc->GetLevel(lineDoc);
|
||||
sprintf(number, "%c%c %03X %03X",
|
||||
(lev & SC_FOLDLEVELHEADERFLAG) ? 'H' : '_',
|
||||
(lev & SC_FOLDLEVELWHITEFLAG) ? 'W' : '_',
|
||||
lev & SC_FOLDLEVELNUMBERMASK,
|
||||
lev >> 16
|
||||
);
|
||||
} else {
|
||||
int state = model.pdoc->GetLineState(lineDoc);
|
||||
sprintf(number, "%0X", state);
|
||||
}
|
||||
}
|
||||
PRectangle rcNumber = rcMarker;
|
||||
// Right justify
|
||||
XYPOSITION width = surface->WidthText(fontLineNumber, number, static_cast<int>(strlen(number)));
|
||||
XYPOSITION xpos = rcNumber.right - width - vs.marginNumberPadding;
|
||||
rcNumber.left = xpos;
|
||||
DrawTextNoClipPhase(surface, rcNumber, vs.styles[STYLE_LINENUMBER],
|
||||
rcNumber.top + vs.maxAscent, number, static_cast<int>(strlen(number)), drawAll);
|
||||
} else if (vs.wrapVisualFlags & SC_WRAPVISUALFLAG_MARGIN) {
|
||||
PRectangle rcWrapMarker = rcMarker;
|
||||
rcWrapMarker.right -= 3;
|
||||
rcWrapMarker.left = rcWrapMarker.right - vs.styles[STYLE_LINENUMBER].aveCharWidth;
|
||||
DrawWrapMarker(surface, rcWrapMarker, false, vs.styles[STYLE_LINENUMBER].fore);
|
||||
}
|
||||
} else if (vs.ms[margin].style == SC_MARGIN_TEXT || vs.ms[margin].style == SC_MARGIN_RTEXT) {
|
||||
if (firstSubLine) {
|
||||
const StyledText stMargin = model.pdoc->MarginStyledText(lineDoc);
|
||||
if (stMargin.text && ValidStyledText(vs, vs.marginStyleOffset, stMargin)) {
|
||||
surface->FillRectangle(rcMarker,
|
||||
vs.styles[stMargin.StyleAt(0) + vs.marginStyleOffset].back);
|
||||
if (vs.ms[margin].style == SC_MARGIN_RTEXT) {
|
||||
int width = WidestLineWidth(surface, vs, vs.marginStyleOffset, stMargin);
|
||||
rcMarker.left = rcMarker.right - width - 3;
|
||||
}
|
||||
DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker,
|
||||
stMargin, 0, stMargin.length, drawAll);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (marks) {
|
||||
for (int markBit = 0; (markBit < 32) && marks; markBit++) {
|
||||
if (marks & 1) {
|
||||
LineMarker::typeOfFold tFold = LineMarker::undefined;
|
||||
if ((vs.ms[margin].mask & SC_MASK_FOLDERS) && highlightDelimiter.IsFoldBlockHighlighted(lineDoc)) {
|
||||
if (highlightDelimiter.IsBodyOfFoldBlock(lineDoc)) {
|
||||
tFold = LineMarker::body;
|
||||
} else if (highlightDelimiter.IsHeadOfFoldBlock(lineDoc)) {
|
||||
if (firstSubLine) {
|
||||
tFold = headWithTail ? LineMarker::headWithTail : LineMarker::head;
|
||||
} else {
|
||||
if (model.cs.GetExpanded(lineDoc) || headWithTail) {
|
||||
tFold = LineMarker::body;
|
||||
} else {
|
||||
tFold = LineMarker::undefined;
|
||||
}
|
||||
}
|
||||
} else if (highlightDelimiter.IsTailOfFoldBlock(lineDoc)) {
|
||||
tFold = LineMarker::tail;
|
||||
}
|
||||
}
|
||||
vs.markers[markBit].Draw(surface, rcMarker, fontLineNumber, tFold, vs.ms[margin].style);
|
||||
}
|
||||
marks >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
visibleLine++;
|
||||
yposScreen += vs.lineHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PRectangle rcBlankMargin = rcMargin;
|
||||
rcBlankMargin.left = rcSelMargin.right;
|
||||
surface->FillRectangle(rcBlankMargin, vs.styles[STYLE_DEFAULT].back);
|
||||
}
|
||||
|
||||
#ifdef SCI_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
41
scintilla/src/MarginView.h
Normal file
41
scintilla/src/MarginView.h
Normal file
@ -0,0 +1,41 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file MarginView.h
|
||||
** Defines the appearance of the editor margin.
|
||||
**/
|
||||
// Copyright 1998-2014 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef MARGINVIEW_H
|
||||
#define MARGINVIEW_H
|
||||
|
||||
#ifdef SCI_NAMESPACE
|
||||
namespace Scintilla {
|
||||
#endif
|
||||
|
||||
void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourDesired wrapColour);
|
||||
|
||||
/**
|
||||
* MarginView draws the margins.
|
||||
*/
|
||||
class MarginView {
|
||||
public:
|
||||
Surface *pixmapSelMargin;
|
||||
Surface *pixmapSelPattern;
|
||||
Surface *pixmapSelPatternOffset1;
|
||||
// Highlight current folding block
|
||||
HighlightDelimiter highlightDelimiter;
|
||||
|
||||
MarginView();
|
||||
|
||||
void DropGraphics(bool freeObjects);
|
||||
void AllocateGraphics(const ViewStyle &vsDraw);
|
||||
void RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewStyle &vsDraw);
|
||||
void PaintMargin(Surface *surface, int topLine, PRectangle rc, PRectangle rcMargin,
|
||||
const EditModel &model, const ViewStyle &vs);
|
||||
};
|
||||
|
||||
#ifdef SCI_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include "Platform.h"
|
||||
@ -484,3 +485,72 @@ int LineAnnotation::Lines(int line) const {
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
LineTabstops::~LineTabstops() {
|
||||
Init();
|
||||
}
|
||||
|
||||
void LineTabstops::Init() {
|
||||
for (int line = 0; line < tabstops.Length(); line++) {
|
||||
delete tabstops[line];
|
||||
}
|
||||
tabstops.DeleteAll();
|
||||
}
|
||||
|
||||
void LineTabstops::InsertLine(int line) {
|
||||
if (tabstops.Length()) {
|
||||
tabstops.EnsureLength(line);
|
||||
tabstops.Insert(line, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void LineTabstops::RemoveLine(int line) {
|
||||
if (tabstops.Length() > line) {
|
||||
delete tabstops[line];
|
||||
tabstops.Delete(line);
|
||||
}
|
||||
}
|
||||
|
||||
bool LineTabstops::ClearTabstops(int line) {
|
||||
if (line < tabstops.Length()) {
|
||||
TabstopList *tl = tabstops[line];
|
||||
if (tl) {
|
||||
tl->clear();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LineTabstops::AddTabstop(int line, int x) {
|
||||
tabstops.EnsureLength(line + 1);
|
||||
if (!tabstops[line]) {
|
||||
tabstops[line] = new TabstopList();
|
||||
}
|
||||
|
||||
TabstopList *tl = tabstops[line];
|
||||
if (tl) {
|
||||
// tabstop positions are kept in order - insert in the right place
|
||||
std::vector<int>::iterator it = std::lower_bound(tl->begin(), tl->end(), x);
|
||||
// don't insert duplicates
|
||||
if (it == tl->end() || *it != x) {
|
||||
tl->insert(it, x);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int LineTabstops::GetNextTabstop(int line, int x) const {
|
||||
if (line < tabstops.Length()) {
|
||||
TabstopList *tl = tabstops[line];
|
||||
if (tl) {
|
||||
for (size_t i = 0; i < tl->size(); i++) {
|
||||
if ((*tl)[i] > x) {
|
||||
return (*tl)[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -112,6 +112,23 @@ public:
|
||||
int Lines(int line) const;
|
||||
};
|
||||
|
||||
typedef std::vector<int> TabstopList;
|
||||
|
||||
class LineTabstops : public PerLine {
|
||||
SplitVector<TabstopList *> tabstops;
|
||||
public:
|
||||
LineTabstops() {
|
||||
}
|
||||
virtual ~LineTabstops();
|
||||
virtual void Init();
|
||||
virtual void InsertLine(int line);
|
||||
virtual void RemoveLine(int line);
|
||||
|
||||
bool ClearTabstops(int line);
|
||||
bool AddTabstop(int line, int x);
|
||||
int GetNextTabstop(int line, int x) const;
|
||||
};
|
||||
|
||||
#ifdef SCI_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
@ -438,13 +438,12 @@ void BreakFinder::Insert(int val) {
|
||||
}
|
||||
}
|
||||
|
||||
BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, int lineStart_, int lineEnd_, int posLineStart_,
|
||||
BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lineRange_, int posLineStart_,
|
||||
int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_) :
|
||||
ll(ll_),
|
||||
lineStart(lineStart_),
|
||||
lineEnd(lineEnd_),
|
||||
lineRange(lineRange_),
|
||||
posLineStart(posLineStart_),
|
||||
nextBreak(lineStart_),
|
||||
nextBreak(lineRange_.start),
|
||||
saeCurrentPos(0),
|
||||
saeNext(0),
|
||||
subBreak(-1),
|
||||
@ -455,15 +454,15 @@ BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, int lineS
|
||||
// Search for first visible break
|
||||
// First find the first visible character
|
||||
if (xStart > 0.0f)
|
||||
nextBreak = ll->FindBefore(static_cast<XYPOSITION>(xStart), lineStart, lineEnd);
|
||||
nextBreak = ll->FindBefore(static_cast<XYPOSITION>(xStart), lineRange.start, lineRange.end);
|
||||
// Now back to a style break
|
||||
while ((nextBreak > lineStart) && (ll->styles[nextBreak] == ll->styles[nextBreak - 1])) {
|
||||
while ((nextBreak > lineRange.start) && (ll->styles[nextBreak] == ll->styles[nextBreak - 1])) {
|
||||
nextBreak--;
|
||||
}
|
||||
|
||||
if (breakForSelection) {
|
||||
SelectionPosition posStart(posLineStart);
|
||||
SelectionPosition posEnd(posLineStart + lineEnd);
|
||||
SelectionPosition posEnd(posLineStart + lineRange.end);
|
||||
SelectionSegment segmentLine(posStart, posEnd);
|
||||
for (size_t r=0; r<psel->Count(); r++) {
|
||||
SelectionSegment portion = psel->Range(r).Intersect(segmentLine);
|
||||
@ -477,7 +476,7 @@ BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, int lineS
|
||||
}
|
||||
|
||||
Insert(ll->edgeColumn);
|
||||
Insert(lineEnd);
|
||||
Insert(lineRange.end);
|
||||
saeNext = (!selAndEdge.empty()) ? selAndEdge[0] : -1;
|
||||
}
|
||||
|
||||
@ -487,19 +486,19 @@ BreakFinder::~BreakFinder() {
|
||||
TextSegment BreakFinder::Next() {
|
||||
if (subBreak == -1) {
|
||||
int prev = nextBreak;
|
||||
while (nextBreak < lineEnd) {
|
||||
while (nextBreak < lineRange.end) {
|
||||
int charWidth = 1;
|
||||
if (encodingFamily == efUnicode)
|
||||
charWidth = UTF8DrawBytes(reinterpret_cast<unsigned char *>(ll->chars) + nextBreak, lineEnd - nextBreak);
|
||||
charWidth = UTF8DrawBytes(reinterpret_cast<unsigned char *>(ll->chars) + nextBreak, lineRange.end - nextBreak);
|
||||
else if (encodingFamily == efDBCS)
|
||||
charWidth = pdoc->IsDBCSLeadByte(ll->chars[nextBreak]) ? 2 : 1;
|
||||
const Representation *repr = preprs->RepresentationFromCharacter(ll->chars + nextBreak, charWidth);
|
||||
if (((nextBreak > 0) && (ll->styles[nextBreak] != ll->styles[nextBreak - 1])) ||
|
||||
repr ||
|
||||
(nextBreak == saeNext)) {
|
||||
while ((nextBreak >= saeNext) && (saeNext < lineEnd)) {
|
||||
while ((nextBreak >= saeNext) && (saeNext < lineRange.end)) {
|
||||
saeCurrentPos++;
|
||||
saeNext = (saeCurrentPos < selAndEdge.size()) ? selAndEdge[saeCurrentPos] : lineEnd;
|
||||
saeNext = (saeCurrentPos < selAndEdge.size()) ? selAndEdge[saeCurrentPos] : lineRange.end;
|
||||
}
|
||||
if ((nextBreak > prev) || repr) {
|
||||
// Have a segment to report
|
||||
@ -540,7 +539,7 @@ TextSegment BreakFinder::Next() {
|
||||
}
|
||||
|
||||
bool BreakFinder::More() const {
|
||||
return (subBreak >= 0) || (nextBreak < lineEnd);
|
||||
return (subBreak >= 0) || (nextBreak < lineRange.end);
|
||||
}
|
||||
|
||||
PositionCacheEntry::PositionCacheEntry() :
|
||||
|
@ -104,7 +104,7 @@ class PositionCacheEntry {
|
||||
public:
|
||||
PositionCacheEntry();
|
||||
~PositionCacheEntry();
|
||||
void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_, unsigned int clock);
|
||||
void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_, unsigned int clock_);
|
||||
void Clear();
|
||||
bool Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_) const;
|
||||
static unsigned int Hash(unsigned int styleNumber_, const char *s, unsigned int len);
|
||||
@ -148,8 +148,7 @@ struct TextSegment {
|
||||
// Class to break a line of text into shorter runs at sensible places.
|
||||
class BreakFinder {
|
||||
const LineLayout *ll;
|
||||
int lineStart;
|
||||
int lineEnd;
|
||||
Range lineRange;
|
||||
int posLineStart;
|
||||
int nextBreak;
|
||||
std::vector<int> selAndEdge;
|
||||
@ -168,7 +167,7 @@ public:
|
||||
enum { lengthStartSubdivision = 300 };
|
||||
// Try to make each subdivided run lengthEachSubdivision or shorter.
|
||||
enum { lengthEachSubdivision = 100 };
|
||||
BreakFinder(const LineLayout *ll_, const Selection *psel, int lineStart_, int lineEnd_, int posLineStart_,
|
||||
BreakFinder(const LineLayout *ll_, const Selection *psel, Range rangeLine_, int posLineStart_,
|
||||
int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_);
|
||||
~BreakFinder();
|
||||
TextSegment Next();
|
||||
|
@ -203,6 +203,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
#include "CharClassify.h"
|
||||
#include "RESearch.h"
|
||||
@ -251,22 +252,18 @@ const char bitarr[] = { 1, 2, 4, 8, 16, 32, 64, '\200' };
|
||||
RESearch::RESearch(CharClassify *charClassTable) {
|
||||
failure = 0;
|
||||
charClass = charClassTable;
|
||||
Init();
|
||||
sta = NOP; /* status of lastpat */
|
||||
bol = 0;
|
||||
std::fill(bittab, bittab + BITBLK, 0);
|
||||
std::fill(tagstk, tagstk + MAXTAG, 0);
|
||||
std::fill(nfa, nfa + MAXNFA, 0);
|
||||
Clear();
|
||||
}
|
||||
|
||||
RESearch::~RESearch() {
|
||||
Clear();
|
||||
}
|
||||
|
||||
void RESearch::Init() {
|
||||
sta = NOP; /* status of lastpat */
|
||||
bol = 0;
|
||||
for (int i = 0; i < MAXTAG; i++)
|
||||
pat[i].clear();
|
||||
for (int j = 0; j < BITBLK; j++)
|
||||
bittab[j] = 0;
|
||||
}
|
||||
|
||||
void RESearch::Clear() {
|
||||
for (int i = 0; i < MAXTAG; i++) {
|
||||
pat[i].clear();
|
||||
|
@ -46,7 +46,6 @@ public:
|
||||
std::string pat[MAXTAG];
|
||||
|
||||
private:
|
||||
void Init();
|
||||
void Clear();
|
||||
void ChSet(unsigned char c);
|
||||
void ChSetWithCase(unsigned char c, bool caseSensitive);
|
||||
|
@ -50,6 +50,9 @@
|
||||
#include "Document.h"
|
||||
#include "Selection.h"
|
||||
#include "PositionCache.h"
|
||||
#include "EditModel.h"
|
||||
#include "MarginView.h"
|
||||
#include "EditView.h"
|
||||
#include "Editor.h"
|
||||
#include "AutoComplete.h"
|
||||
#include "ScintillaBase.h"
|
||||
@ -73,7 +76,7 @@ void ScintillaBase::Finalise() {
|
||||
popup.Destroy();
|
||||
}
|
||||
|
||||
void ScintillaBase::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
|
||||
void ScintillaBase::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) {
|
||||
bool isFillUp = ac.Active() && ac.IsFillUpChar(*s);
|
||||
if (!isFillUp) {
|
||||
Editor::AddCharUTF(s, len, treatAsDBCS);
|
||||
|
@ -38,6 +38,8 @@ protected:
|
||||
idcmdSelectAll=16
|
||||
};
|
||||
|
||||
enum { maxLenInputIME = 200 };
|
||||
|
||||
bool displayPopupMenu;
|
||||
Menu popup;
|
||||
AutoComplete ac;
|
||||
@ -60,7 +62,7 @@ protected:
|
||||
virtual void Initialise() = 0;
|
||||
virtual void Finalise();
|
||||
|
||||
virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
|
||||
virtual void AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS=false);
|
||||
void Command(int cmdId);
|
||||
virtual void CancelModes();
|
||||
virtual int KeyCommand(unsigned int iMessage);
|
||||
|
@ -81,6 +81,11 @@ int SelectionRange::Length() const {
|
||||
}
|
||||
}
|
||||
|
||||
void SelectionRange::MoveForInsertDelete(bool insertion, int startChange, int length) {
|
||||
caret.MoveForInsertDelete(insertion, startChange, length);
|
||||
anchor.MoveForInsertDelete(insertion, startChange, length);
|
||||
}
|
||||
|
||||
bool SelectionRange::Contains(int pos) const {
|
||||
if (anchor > caret)
|
||||
return (pos >= caret.Position()) && (pos <= anchor.Position());
|
||||
@ -283,9 +288,11 @@ int Selection::Length() const {
|
||||
|
||||
void Selection::MovePositions(bool insertion, int startChange, int length) {
|
||||
for (size_t i=0; i<ranges.size(); i++) {
|
||||
ranges[i].caret.MoveForInsertDelete(insertion, startChange, length);
|
||||
ranges[i].anchor.MoveForInsertDelete(insertion, startChange, length);
|
||||
ranges[i].MoveForInsertDelete(insertion, startChange, length);
|
||||
}
|
||||
if (selType == selRectangle) {
|
||||
rangeRectangular.MoveForInsertDelete(insertion, startChange, length);
|
||||
}
|
||||
}
|
||||
|
||||
void Selection::TrimSelection(SelectionRange range) {
|
||||
|
@ -115,6 +115,7 @@ struct SelectionRange {
|
||||
anchor.SetVirtualSpace(0);
|
||||
caret.SetVirtualSpace(0);
|
||||
}
|
||||
void MoveForInsertDelete(bool insertion, int startChange, int length);
|
||||
bool Contains(int pos) const;
|
||||
bool Contains(SelectionPosition sp) const;
|
||||
bool ContainsCharacter(int posCharacter) const;
|
||||
|
@ -204,6 +204,7 @@ void ViewStyle::Init(size_t stylesSize_) {
|
||||
|
||||
technology = SC_TECHNOLOGY_DEFAULT;
|
||||
lineHeight = 1;
|
||||
lineOverlap = 0;
|
||||
maxAscent = 1;
|
||||
maxDescent = 1;
|
||||
aveCharWidth = 8;
|
||||
@ -329,6 +330,11 @@ void ViewStyle::Refresh(Surface &surface, int tabInChars) {
|
||||
maxAscent += extraAscent;
|
||||
maxDescent += extraDescent;
|
||||
lineHeight = maxAscent + maxDescent;
|
||||
lineOverlap = lineHeight / 10;
|
||||
if (lineOverlap < 2)
|
||||
lineOverlap = 2;
|
||||
if (lineOverlap > lineHeight)
|
||||
lineOverlap = lineHeight;
|
||||
|
||||
someStylesProtected = false;
|
||||
someStylesForceCase = false;
|
||||
@ -470,6 +476,14 @@ ColourOptional ViewStyle::Background(int marksOfLine, bool caretActive, bool lin
|
||||
return background;
|
||||
}
|
||||
|
||||
bool ViewStyle::SelectionBackgroundDrawn() const {
|
||||
return selColours.back.isSet &&
|
||||
((selAlpha == SC_ALPHA_NOALPHA) || (selAdditionalAlpha == SC_ALPHA_NOALPHA));
|
||||
}
|
||||
|
||||
bool ViewStyle::WhitespaceBackgroundDrawn() const {
|
||||
return (viewWhitespace != wsInvisible) && (whitespaceColours.back.isSet);
|
||||
}
|
||||
|
||||
ColourDesired ViewStyle::WrapColour() const {
|
||||
if (whitespaceColours.fore.isSet)
|
||||
|
@ -85,6 +85,7 @@ public:
|
||||
Indicator indicators[INDIC_MAX + 1];
|
||||
int technology;
|
||||
int lineHeight;
|
||||
int lineOverlap;
|
||||
unsigned int maxAscent;
|
||||
unsigned int maxDescent;
|
||||
XYPOSITION aveCharWidth;
|
||||
@ -170,7 +171,10 @@ public:
|
||||
bool ValidStyle(size_t styleIndex) const;
|
||||
void CalcLargestMarkerHeight();
|
||||
ColourOptional Background(int marksOfLine, bool caretActive, bool lineContainsCaret) const;
|
||||
bool SelectionBackgroundDrawn() const;
|
||||
bool WhitespaceBackgroundDrawn() const;
|
||||
ColourDesired WrapColour() const;
|
||||
|
||||
bool SetWrapState(int wrapState_);
|
||||
bool SetWrapVisualFlags(int wrapVisualFlags_);
|
||||
bool SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation_);
|
||||
|
@ -1 +1 @@
|
||||
344
|
||||
350
|
||||
|
Loading…
x
Reference in New Issue
Block a user