aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/Platform.h53
-rw-r--r--include/Scintilla.h1
-rw-r--r--include/Scintilla.iface1
-rw-r--r--src/Editor.cxx13
-rw-r--r--src/LineMarker.cxx24
5 files changed, 45 insertions, 47 deletions
diff --git a/include/Platform.h b/include/Platform.h
index 1e6acbaac..7e521d63b 100644
--- a/include/Platform.h
+++ b/include/Platform.h
@@ -110,13 +110,13 @@ public:
/**
* In some circumstances, including Win32 in paletted mode and GTK+, each colour
- * must be allocated before use. The desired colours are held in the ColourDesired class,
+ * must be allocated before use. The desired colours are held in the ColourDesired class,
* and after allocation the allocation entry is stored in the ColourAllocated class. In other
- * circumstances, such as Win32 in true colour mode, the allocation process just copies
+ * circumstances, such as Win32 in true colour mode, the allocation process just copies
* the RGB values from the desired to the allocated class.
* As each desired colour requires allocation before it can be used, the ColourPair class
* holds both a ColourDesired and a ColourAllocated
- * The Palette class is responsible for managing the palette of colours which contains a
+ * The Palette class is responsible for managing the palette of colours which contains a
* list of ColourPair objects and performs the allocation.
*/
@@ -129,31 +129,56 @@ public:
ColourDesired(long lcol=0) {
co = lcol;
}
-
+
ColourDesired(unsigned int red, unsigned int green, unsigned int blue) {
- co = red | (green << 8) | (blue << 16);
+ Set(red, green, blue);
}
-
+
bool operator==(const ColourDesired &other) const {
return co == other.co;
}
-
+
void Set(long lcol) {
co = lcol;
}
-
+
+ void Set(unsigned int red, unsigned int green, unsigned int blue) {
+ co = red | (green << 8) | (blue << 16);
+ }
+
+ static inline unsigned int ValueOfHex(const char ch) {
+ if (ch >= '0' && ch <= '9')
+ return ch - '0';
+ else if (ch >= 'A' && ch <= 'F')
+ return ch - 'A' + 10;
+ else if (ch >= 'a' && ch <= 'f')
+ return ch - 'a' + 10;
+ else
+ return 0;
+ }
+
+ void Set(const char *val) {
+ if (*val == '#') {
+ val++;
+ }
+ unsigned int r = ValueOfHex(val[0]) * 16 + ValueOfHex(val[1]);
+ unsigned int g = ValueOfHex(val[2]) * 16 + ValueOfHex(val[3]);
+ unsigned int b = ValueOfHex(val[4]) * 16 + ValueOfHex(val[5]);
+ Set(r, g, b);
+ }
+
long AsLong() const {
return co;
}
-
+
unsigned int GetRed() {
return co & 0xff;
}
-
+
unsigned int GetGreen() {
return (co >> 8) & 0xff;
}
-
+
unsigned int GetBlue() {
return (co >> 16) & 0xff;
}
@@ -164,17 +189,17 @@ public:
*/
class ColourAllocated {
long coAllocated;
-
+
public:
ColourAllocated(long lcol=0) {
coAllocated = lcol;
}
-
+
void Set(long lcol) {
coAllocated = lcol;
}
-
+
long AsLong() const {
return coAllocated;
}
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 7e070a068..a3de07809 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -111,6 +111,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SC_MARK_BACKGROUND 22
#define SC_MARK_DOTDOTDOT 23
#define SC_MARK_ARROWS 24
+#define SC_MARK_PIXMAP 25
#define SC_MARK_CHARACTER 10000
#define SC_MARKNUM_FOLDEREND 25
#define SC_MARKNUM_FOLDEROPENMID 26
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index bff157435..fba4c85a0 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -260,6 +260,7 @@ val SC_MARK_CIRCLEMINUSCONNECTED=21
val SC_MARK_BACKGROUND=22
val SC_MARK_DOTDOTDOT=23
val SC_MARK_ARROWS=24
+val SC_MARK_PIXMAP=25
val SC_MARK_CHARACTER=10000
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 425847852..790840f51 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -5142,19 +5142,6 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_MARKERDEFINE:
if (wParam <= MARKER_MAX)
vs.markers[wParam].markType = lParam;
- {
- static char *stop_xpm = "\
- static char *stop_xpm[] = {\
-\"4 4 3 1\",\
-\" c None\",\
-\". c #0000FF\",\
-\"+ c #FFFF00\",\
-\" .. \",\
-\".++.\",\
-\".++.\",\
-\" .. \"};";
- vs.markers[wParam].SetXPM(stop_xpm);
- };
InvalidateStyleData();
RedrawSelMargin();
break;
diff --git a/src/LineMarker.cxx b/src/LineMarker.cxx
index 16be7436a..03a9c1dd8 100644
--- a/src/LineMarker.cxx
+++ b/src/LineMarker.cxx
@@ -22,24 +22,6 @@ static const char *NextField(const char *s) {
return s;
}
-static int IntFromHexDigit(const char ch) {
- if (ch >= '0' && ch <= '9')
- return ch - '0';
- else if (ch >= 'A' && ch <= 'F')
- return ch - 'A' + 10;
- else if (ch >= 'a' && ch <= 'f')
- return ch - 'a' + 10;
- else
- return 0;
-}
-
-static ColourDesired ColourFromString(const char *val) {
- int r = IntFromHexDigit(val[1]) * 16 + IntFromHexDigit(val[2]);
- int g = IntFromHexDigit(val[3]) * 16 + IntFromHexDigit(val[4]);
- int b = IntFromHexDigit(val[5]) * 16 + IntFromHexDigit(val[6]);
- return ColourDesired(r, g, b);
-}
-
void XPM::Init(const char * const *linesForm) {
height = 1;
width = 1;
@@ -66,7 +48,7 @@ void XPM::Init(const char * const *linesForm) {
codes[c] = colourDef[0];
colourDef += 4;
if (*colourDef == '#') {
- colours[c].desired = ColourFromString(colourDef);
+ colours[c].desired.Set(colourDef);
} else {
colours[c].desired = ColourDesired(0xff, 0xff, 0xff);
codeTransparent = codes[c];
@@ -171,11 +153,13 @@ void LineMarker::RefreshColourPalette(Palette &pal, bool want) {
void LineMarker::SetXPM(const char *textForm) {
delete pxpm;
pxpm = new XPM(textForm);
+ markType = SC_MARK_PIXMAP;
}
void LineMarker::SetXPM(const char * const *linesForm) {
delete pxpm;
pxpm = new XPM(linesForm);
+ markType = SC_MARK_PIXMAP;
}
static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore, ColourAllocated back) {
@@ -209,7 +193,7 @@ static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, C
}
void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter) {
- if (pxpm) {
+ if ((markType == SC_MARK_PIXMAP) && (pxpm)) {
pxpm->Draw(surface, rcWhole);
return;
}