aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <unknown>2003-01-03 02:45:30 +0000
committernyamatongwe <unknown>2003-01-03 02:45:30 +0000
commit5374c3fabbc53e567c55cb9546e705b49791a1c7 (patch)
treed3c8c057328f8cbba002e33559f9f608a3bb9fdc
parent4ccb201634926f148ead6154e25b6ebeceb442ab (diff)
downloadscintilla-mirror-5374c3fabbc53e567c55cb9546e705b49791a1c7.tar.gz
Enable text form XPM for autocompletion lists.
Enable line form XPM for markers.
-rw-r--r--gtk/PlatGTK.cxx44
-rw-r--r--include/Platform.h2
-rw-r--r--src/LineMarker.cxx15
-rw-r--r--src/ScintillaBase.cxx2
4 files changed, 55 insertions, 8 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx
index 1bfd0c22f..abd1ebb5a 100644
--- a/gtk/PlatGTK.cxx
+++ b/gtk/PlatGTK.cxx
@@ -1141,7 +1141,7 @@ void Window::SetTitle(const char *s) {
}
struct ListImage {
- const char **xpm_data;
+ const char *xpm_data;
GdkPixmap *pixmap;
GdkBitmap *bitmap;
};
@@ -1289,9 +1289,47 @@ void ListBox::Clear() {
}
static void init_pixmap(ListImage *li, GtkWidget *window) {
+ const char *textForm = li->xpm_data;
+ const char * const * xpm_lineform = reinterpret_cast<const char * const *>(textForm);
+ const char *xpm_lineformpointers[1000];
+ // The XPM data can be either in atext form as will be read from a file
+ // or in a line form (array of char *) as will be used for images defined in code.
+ // Test for text form and convert to line form
+ if ((0 == memcmp(textForm, "/* X", 4)) && (0 == memcmp(textForm, "/* XPM */", 9))) {
+ // Test done is two parts to avoid possibility of overstepping the memory
+ // if memcmp implemented strangely. Must be 4 bytes at least at destination.
+ int countQuotes = 0;
+ int lines=1;
+ for (int j=0; textForm[j] && (countQuotes < 2*lines); j++) {
+ if (textForm[j] == '\"') {
+ if (countQuotes == 0) {
+ const char *info = textForm + j + 1;
+ // Skip width
+ while (*info != ' ')
+ info++;
+ while (*info == ' ')
+ info++;
+ // Add height
+ lines += atoi(info);
+ while (*info != ' ')
+ info++;
+ while (*info == ' ')
+ info++;
+ // Add colours
+ lines += atoi(info);
+ }
+ if ((countQuotes & 1) == 0) {
+ xpm_lineformpointers[countQuotes / 2] = textForm + j + 1;
+ }
+ countQuotes++;
+ }
+ }
+ xpm_lineform = xpm_lineformpointers;
+ }
+
li->pixmap = gdk_pixmap_colormap_create_from_xpm_d(NULL
, gtk_widget_get_colormap(window), &(li->bitmap), NULL
- , (gchar **) li->xpm_data);
+ , (gchar **) xpm_lineform);
if (NULL == li->pixmap) {
if (li->bitmap)
gdk_bitmap_unref(li->bitmap);
@@ -1376,7 +1414,7 @@ void ListBox::Sort() {
#pragma warning(disable: 4127)
#endif
-void ListBox::SetTypeXpm(int type, const char **xpm_data) {
+void ListBox::SetTypeXpm(int type, const char *xpm_data) {
ListImage *list_image;
g_return_if_fail(xpm_data);
diff --git a/include/Platform.h b/include/Platform.h
index 53b1dfecc..d65710e3e 100644
--- a/include/Platform.h
+++ b/include/Platform.h
@@ -401,7 +401,7 @@ public:
int Find(const char *prefix);
void GetValue(int n, char *value, int len);
void Sort();
- void SetTypeXpm(int type, const char **xpm_data);
+ void SetTypeXpm(int type, const char *xpm_data);
void SetDoubleClickAction(CallBackAction action, void *data) {
doubleClickAction = action;
doubleClickActionData = data;
diff --git a/src/LineMarker.cxx b/src/LineMarker.cxx
index 99e54072f..faf265475 100644
--- a/src/LineMarker.cxx
+++ b/src/LineMarker.cxx
@@ -5,6 +5,7 @@
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
+#include <string.h>
#include <stdlib.h>
#include "Platform.h"
@@ -151,9 +152,17 @@ void LineMarker::RefreshColourPalette(Palette &pal, bool want) {
}
void LineMarker::SetXPM(const char *textForm) {
- delete pxpm;
- pxpm = new XPM(textForm);
- markType = SC_MARK_PIXMAP;
+ // Test done is two parts to avoid possibility of overstepping the memory
+ // if memcmp implemented strangely. Must be 4 bytes at least at destination.
+ if ((0 == memcmp(textForm, "/* X", 4)) && (0 == memcmp(textForm, "/* XPM */", 9))) {
+ // It is in text form
+ delete pxpm;
+ pxpm = new XPM(textForm);
+ markType = SC_MARK_PIXMAP;
+ } else {
+ // It is really in line form
+ SetXPM(reinterpret_cast<const char * const *>(textForm));
+ }
}
void LineMarker::SetXPM(const char * const *linesForm) {
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index 1c44b0bd6..620513b4f 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -510,7 +510,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
return ac.dropRestOfWord;
case SCI_REGISTERIMAGE:
- ac.lb.SetTypeXpm(wParam, reinterpret_cast<const char **>(lParam));
+ ac.lb.SetTypeXpm(wParam, reinterpret_cast<const char *>(lParam));
break;
case SCI_CALLTIPSHOW: {