-rw-r--r-- | noncore/apps/opie-reader/Bkmks.cpp | 18 | ||||
-rw-r--r-- | noncore/apps/opie-reader/Bkmks.h | 7 | ||||
-rw-r--r-- | noncore/apps/opie-reader/StyleConsts.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/opie-reader/StyleConsts.h | 8 | ||||
-rw-r--r-- | noncore/apps/opie-write/qrichtext.cpp | 5 | ||||
-rw-r--r-- | noncore/apps/tinykate/libkate/document/katehighlight.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/tinykate/libkate/document/katehighlight.h | 2 |
7 files changed, 38 insertions, 16 deletions
diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp index 440d8be..28f6318 100644 --- a/noncore/apps/opie-reader/Bkmks.cpp +++ b/noncore/apps/opie-reader/Bkmks.cpp | |||
@@ -1,70 +1,86 @@ | |||
1 | #include <qmessagebox.h> | 1 | #include <qmessagebox.h> |
2 | 2 | ||
3 | #include "Bkmks.h" | 3 | #include "Bkmks.h" |
4 | 4 | ||
5 | #include "StyleConsts.h" | 5 | #include "StyleConsts.h" |
6 | #include "Markups.h" | 6 | #include "Markups.h" |
7 | #include "my_list.h" | 7 | #include "my_list.h" |
8 | #include "version.h" | 8 | #include "version.h" |
9 | #include "names.h" | 9 | #include "names.h" |
10 | 10 | ||
11 | const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE); | 11 | const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE); |
12 | 12 | ||
13 | Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p) | 13 | Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p) : |
14 | m_name(0), | ||
15 | m_namelen(0), | ||
16 | m_anno(0), | ||
17 | m_annolen(0), | ||
18 | m_position(0) | ||
14 | { | 19 | { |
15 | init(_nm, _nmlen, _anno, _annolen, _p); | 20 | init(_nm, _nmlen, _anno, _annolen, _p); |
16 | } | 21 | } |
17 | 22 | ||
18 | Bkmk::Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short annolen, unsigned int _p) : m_position(_p) | 23 | Bkmk::Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short annolen, unsigned int _p) : m_position(_p) |
19 | { | 24 | { |
20 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, annolen, _p); | 25 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, annolen, _p); |
21 | } | 26 | } |
22 | 27 | ||
28 | Bkmk::Bkmk(const Bkmk& rhs) : | ||
29 | m_name(0), | ||
30 | m_namelen(0), | ||
31 | m_anno(0), | ||
32 | m_annolen(0), | ||
33 | m_position(0) | ||
34 | { | ||
35 | init(rhs.name(), sizeof(tchar)*(ustrlen(rhs.name())+1), rhs.anno(), | ||
36 | sizeof(tchar)*(ustrlen(rhs.anno())+1), rhs.value()); | ||
37 | } | ||
38 | |||
23 | Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p) | 39 | Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p) |
24 | { | 40 | { |
25 | if (_anno == NULL) | 41 | if (_anno == NULL) |
26 | { | 42 | { |
27 | tchar t = 0; | 43 | tchar t = 0; |
28 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p); | 44 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p); |
29 | } | 45 | } |
30 | else | 46 | else |
31 | { | 47 | { |
32 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p); | 48 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p); |
33 | } | 49 | } |
34 | } | 50 | } |
35 | 51 | ||
36 | Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2) : m_position(_p) | 52 | Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2) : m_position(_p) |
37 | { | 53 | { |
38 | if (_anno == NULL) | 54 | if (_anno == NULL) |
39 | { | 55 | { |
40 | tchar t = 0; | 56 | tchar t = 0; |
41 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p); | 57 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p); |
42 | } | 58 | } |
43 | else | 59 | else |
44 | { | 60 | { |
45 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p); | 61 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p); |
46 | } | 62 | } |
47 | m_position2 = _p2; | 63 | m_position2 = _p2; |
48 | m_red = m_green = m_blue = 127; | 64 | m_red = m_green = m_blue = 127; |
49 | } | 65 | } |
50 | 66 | ||
51 | void Bkmk::init(const void* _nm, unsigned short _nmlen, const void* _anno, unsigned short _annolen, unsigned int _p) | 67 | void Bkmk::init(const void* _nm, unsigned short _nmlen, const void* _anno, unsigned short _annolen, unsigned int _p) |
52 | { | 68 | { |
53 | m_namelen = _nmlen; | 69 | m_namelen = _nmlen; |
54 | if (m_namelen > 0) | 70 | if (m_namelen > 0) |
55 | { | 71 | { |
56 | m_name = new unsigned char[m_namelen]; | 72 | m_name = new unsigned char[m_namelen]; |
57 | memcpy(m_name, _nm, m_namelen); | 73 | memcpy(m_name, _nm, m_namelen); |
58 | } | 74 | } |
59 | else | 75 | else |
60 | { | 76 | { |
61 | m_name = NULL; | 77 | m_name = NULL; |
62 | } | 78 | } |
63 | 79 | ||
64 | m_annolen = _annolen; | 80 | m_annolen = _annolen; |
65 | if (m_annolen > 0) | 81 | if (m_annolen > 0) |
66 | { | 82 | { |
67 | m_anno = new unsigned char[m_annolen]; | 83 | m_anno = new unsigned char[m_annolen]; |
68 | memcpy(m_anno, _anno, m_annolen); | 84 | memcpy(m_anno, _anno, m_annolen); |
69 | } | 85 | } |
70 | else | 86 | else |
diff --git a/noncore/apps/opie-reader/Bkmks.h b/noncore/apps/opie-reader/Bkmks.h index c2275e2..985e158 100644 --- a/noncore/apps/opie-reader/Bkmks.h +++ b/noncore/apps/opie-reader/Bkmks.h | |||
@@ -1,79 +1,76 @@ | |||
1 | #ifndef __Bkmks_h | 1 | #ifndef __Bkmks_h |
2 | #define __Bkmks_h | 2 | #define __Bkmks_h |
3 | 3 | ||
4 | #include "config.h" | 4 | #include "config.h" |
5 | #include "Filedata.h" | 5 | #include "Filedata.h" |
6 | #include <stdio.h> | 6 | #include <stdio.h> |
7 | 7 | ||
8 | template<class T> | 8 | template<class T> |
9 | class CList; | 9 | class CList; |
10 | 10 | ||
11 | class Bkmk | 11 | class Bkmk |
12 | { | 12 | { |
13 | friend class BkmkFile; | 13 | friend class BkmkFile; |
14 | unsigned char* m_name; | 14 | unsigned char* m_name; |
15 | unsigned short m_namelen; | 15 | unsigned short m_namelen; |
16 | unsigned char* m_anno; | 16 | unsigned char* m_anno; |
17 | unsigned short m_annolen; | 17 | unsigned short m_annolen; |
18 | unsigned int m_position; | 18 | unsigned int m_position; |
19 | unsigned int m_position2; | 19 | unsigned int m_position2; |
20 | unsigned char m_red,m_green,m_blue, m_level; | 20 | unsigned char m_red,m_green,m_blue, m_level; |
21 | void init(const void*, unsigned short, const void*, unsigned short, unsigned int); | 21 | void init(const void*, unsigned short, const void*, unsigned short, unsigned int); |
22 | public: | 22 | public: |
23 | Bkmk() : m_name(NULL), m_namelen(0), m_anno(NULL), m_annolen(0), m_position(0) {}; | 23 | Bkmk() : m_name(0), m_namelen(0), m_anno(0), m_annolen(0), m_position(0) {}; |
24 | Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); | 24 | Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); |
25 | Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); | 25 | Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); |
26 | Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p); | 26 | Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p); |
27 | Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2); | 27 | Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2); |
28 | Bkmk(const Bkmk& rhs) : m_name(NULL), m_anno(NULL) | 28 | Bkmk(const Bkmk& rhs); |
29 | { | ||
30 | *this = rhs; | ||
31 | } | ||
32 | ~Bkmk(); | 29 | ~Bkmk(); |
33 | unsigned int value() const { return m_position; } | 30 | unsigned int value() const { return m_position; } |
34 | void value(unsigned int _v) { m_position = _v; } | 31 | void value(unsigned int _v) { m_position = _v; } |
35 | unsigned int value2() const { return m_position2; } | 32 | unsigned int value2() const { return m_position2; } |
36 | void value2(unsigned int _v) { m_position2 = _v; } | 33 | void value2(unsigned int _v) { m_position2 = _v; } |
37 | unsigned char red() { return m_red; } | 34 | unsigned char red() { return m_red; } |
38 | unsigned char green() { return m_green; } | 35 | unsigned char green() { return m_green; } |
39 | unsigned char blue() { return m_blue; } | 36 | unsigned char blue() { return m_blue; } |
40 | void red(unsigned char _v) { m_red = _v; } | 37 | void red(unsigned char _v) { m_red = _v; } |
41 | void green(unsigned char _v) { m_green = _v; } | 38 | void green(unsigned char _v) { m_green = _v; } |
42 | void blue(unsigned char _v) { m_blue = _v; } | 39 | void blue(unsigned char _v) { m_blue = _v; } |
43 | unsigned char level() { return m_level; } | 40 | unsigned char level() { return m_level; } |
44 | void level(unsigned char _v) { m_level = _v; } | 41 | void level(unsigned char _v) { m_level = _v; } |
45 | tchar *name() const { return (tchar*)m_name; } | 42 | tchar *name() const { return (tchar*)m_name; } |
46 | tchar *anno() const { return (tchar*)m_anno; } | 43 | tchar *anno() const { return (tchar*)m_anno; } |
47 | bool operator<(const Bkmk& rhs) { return (m_position < rhs.m_position); } | 44 | bool operator<(const Bkmk& rhs) { return (m_position < rhs.m_position); } |
48 | Bkmk& operator=(const Bkmk& rhs); | 45 | Bkmk& operator=(const Bkmk& rhs); |
49 | bool operator==(const Bkmk& rhs); | 46 | bool operator==(const Bkmk& rhs); |
50 | void setAnno(tchar* t); | 47 | void setAnno(tchar* t); |
51 | void setAnno(unsigned char* t, unsigned short len); | 48 | void setAnno(unsigned char* t, unsigned short len); |
52 | unsigned char* filedata() | 49 | unsigned char* filedata() |
53 | { | 50 | { |
54 | CFiledata fd(anno()); | 51 | CFiledata fd(anno()); |
55 | return m_anno+fd.length(); | 52 | return m_anno+fd.length(); |
56 | } | 53 | } |
57 | unsigned short filedatalen() | 54 | unsigned short filedatalen() |
58 | { | 55 | { |
59 | CFiledata fd(anno()); | 56 | CFiledata fd(anno()); |
60 | return m_annolen - fd.length(); | 57 | return m_annolen - fd.length(); |
61 | } | 58 | } |
62 | }; | 59 | }; |
63 | 60 | ||
64 | class BkmkFile | 61 | class BkmkFile |
65 | { | 62 | { |
66 | FILE* f; | 63 | FILE* f; |
67 | bool wt; | 64 | bool wt; |
68 | bool isUpgraded, m_extras; | 65 | bool isUpgraded, m_extras; |
69 | static const unsigned long magic; | 66 | static const unsigned long magic; |
70 | private: | 67 | private: |
71 | static Bkmk* read07(BkmkFile*, FILE*); | 68 | static Bkmk* read07(BkmkFile*, FILE*); |
72 | static Bkmk* read06(BkmkFile*, FILE*); | 69 | static Bkmk* read06(BkmkFile*, FILE*); |
73 | static Bkmk* read05(BkmkFile*, FILE*); | 70 | static Bkmk* read05(BkmkFile*, FILE*); |
74 | static Bkmk* read03(BkmkFile*, FILE*); | 71 | static Bkmk* read03(BkmkFile*, FILE*); |
75 | CList<Bkmk>* readall00(Bkmk*(*fn)(BkmkFile*, FILE*)); | 72 | CList<Bkmk>* readall00(Bkmk*(*fn)(BkmkFile*, FILE*)); |
76 | void write(const Bkmk& b); | 73 | void write(const Bkmk& b); |
77 | public: | 74 | public: |
78 | bool upgraded() { return isUpgraded; } | 75 | bool upgraded() { return isUpgraded; } |
79 | BkmkFile(const char *fnm, bool w, bool _x); | 76 | BkmkFile(const char *fnm, bool w, bool _x); |
diff --git a/noncore/apps/opie-reader/StyleConsts.cpp b/noncore/apps/opie-reader/StyleConsts.cpp index 77c9d3b..c19fa3d 100644 --- a/noncore/apps/opie-reader/StyleConsts.cpp +++ b/noncore/apps/opie-reader/StyleConsts.cpp | |||
@@ -1,54 +1,61 @@ | |||
1 | 1 | ||
2 | #include <qimage.h> | 2 | #include <qimage.h> |
3 | #include "StyleConsts.h" | 3 | #include "StyleConsts.h" |
4 | 4 | ||
5 | GraphicLink::~GraphicLink() { delete graphic; } | 5 | GraphicLink::~GraphicLink() { delete graphic; } |
6 | 6 | ||
7 | pmstore::pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) : | ||
8 | count(1), | ||
9 | m_isScaleable(_canScale) | ||
10 | { | ||
11 | graphic = new GraphicLink(p, isLnk, tgt); | ||
12 | } | ||
13 | |||
7 | pmstore::~pmstore() | 14 | pmstore::~pmstore() |
8 | { | 15 | { |
9 | //// qDebug("Deleting image"); | 16 | //// qDebug("Deleting image"); |
10 | delete graphic; | 17 | delete graphic; |
11 | } | 18 | } |
12 | 19 | ||
13 | CStyle::~CStyle() | 20 | CStyle::~CStyle() |
14 | { | 21 | { |
15 | if (graphic != NULL) | 22 | if (graphic != NULL) |
16 | { | 23 | { |
17 | if (--(graphic->count) == 0) | 24 | if (--(graphic->count) == 0) |
18 | { | 25 | { |
19 | delete graphic; | 26 | delete graphic; |
20 | } | 27 | } |
21 | } | 28 | } |
22 | } | 29 | } |
23 | 30 | ||
24 | CStyle::CStyle(const CStyle& rhs) : graphic(NULL) | 31 | CStyle::CStyle(const CStyle& rhs) : graphic(NULL) |
25 | { | 32 | { |
26 | *this = rhs; | 33 | *this = rhs; |
27 | } | 34 | } |
28 | 35 | ||
29 | CStyle& CStyle::operator=(const CStyle& rhs) | 36 | CStyle& CStyle::operator=(const CStyle& rhs) |
30 | { | 37 | { |
31 | if (rhs.graphic != NULL) | 38 | if (rhs.graphic != NULL) |
32 | { | 39 | { |
33 | (rhs.graphic->count)++; | 40 | (rhs.graphic->count)++; |
34 | if (graphic != NULL) | 41 | if (graphic != NULL) |
35 | { | 42 | { |
36 | if (--(graphic->count) == 0) | 43 | if (--(graphic->count) == 0) |
37 | { | 44 | { |
38 | delete graphic; | 45 | delete graphic; |
39 | } | 46 | } |
40 | } | 47 | } |
41 | graphic = rhs.graphic; | 48 | graphic = rhs.graphic; |
42 | } | 49 | } |
43 | else | 50 | else |
44 | { | 51 | { |
45 | if (graphic != NULL) | 52 | if (graphic != NULL) |
46 | { | 53 | { |
47 | if (--(graphic->count) == 0) | 54 | if (--(graphic->count) == 0) |
48 | { | 55 | { |
49 | delete graphic; | 56 | delete graphic; |
50 | } | 57 | } |
51 | graphic = NULL; | 58 | graphic = NULL; |
52 | } | 59 | } |
53 | } | 60 | } |
54 | sty = rhs.sty; | 61 | sty = rhs.sty; |
diff --git a/noncore/apps/opie-reader/StyleConsts.h b/noncore/apps/opie-reader/StyleConsts.h index 4b7ff4b..5fd9669 100644 --- a/noncore/apps/opie-reader/StyleConsts.h +++ b/noncore/apps/opie-reader/StyleConsts.h | |||
@@ -1,80 +1,78 @@ | |||
1 | #ifndef __STYLECONSTS_H | 1 | #ifndef __STYLECONSTS_H |
2 | #define __STYLECONSTS_H | 2 | #define __STYLECONSTS_H |
3 | 3 | ||
4 | typedef unsigned short StyleType; | 4 | typedef unsigned short StyleType; |
5 | 5 | ||
6 | #ifdef _WINDOWS | 6 | #ifdef _WINDOWS |
7 | #include <string.h> | 7 | #include <string.h> |
8 | #endif | 8 | #endif |
9 | #include <string.h> | 9 | #include <string.h> |
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <qglobal.h> | 11 | #include <qglobal.h> |
12 | class QImage; | 12 | class QImage; |
13 | 13 | ||
14 | struct GraphicLink | 14 | struct GraphicLink |
15 | { | 15 | { |
16 | QImage* graphic; | 16 | QImage* graphic; |
17 | bool isLink; | 17 | bool isLink; |
18 | unsigned long link; | 18 | unsigned long link; |
19 | GraphicLink(QImage* p, bool isLnk, unsigned long tgt) : | 19 | GraphicLink(QImage* p, bool isLnk, unsigned long tgt) : |
20 | graphic(p), isLink(isLnk), link(tgt) {} | 20 | graphic(p), isLink(isLnk), link(tgt) {} |
21 | ~GraphicLink(); | 21 | ~GraphicLink(); |
22 | }; | 22 | }; |
23 | 23 | ||
24 | struct pmstore | 24 | class pmstore |
25 | { | 25 | { |
26 | public: | ||
26 | unsigned int count; | 27 | unsigned int count; |
27 | bool m_isScaleable; | 28 | bool m_isScaleable; |
28 | GraphicLink* graphic; | 29 | GraphicLink* graphic; |
29 | pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) : count(1), m_isScaleable(_canScale) | 30 | pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt); |
30 | { | ||
31 | graphic = new GraphicLink(p, isLnk, tgt); | ||
32 | } | ||
33 | ~pmstore(); | 31 | ~pmstore(); |
34 | }; | 32 | }; |
35 | 33 | ||
36 | enum EalignmentType | 34 | enum EalignmentType |
37 | { | 35 | { |
38 | m_AlignLeft, | 36 | m_AlignLeft, |
39 | m_AlignRight, | 37 | m_AlignRight, |
40 | m_AlignCentre, | 38 | m_AlignCentre, |
41 | m_AlignJustify, | 39 | m_AlignJustify, |
42 | m_AlignNone | 40 | m_AlignNone |
43 | }; | 41 | }; |
44 | 42 | ||
45 | class CBasicStyle | 43 | class CBasicStyle |
46 | { | 44 | { |
47 | friend class CStyle; | 45 | friend class CStyle; |
48 | bool m_bold, | 46 | bool m_bold, |
49 | m_italic; | 47 | m_italic; |
50 | unsigned long m_table; | 48 | unsigned long m_table; |
51 | int m_fontsize; | 49 | int m_fontsize; |
52 | EalignmentType m_align; | 50 | EalignmentType m_align; |
53 | unsigned char red, green, blue; | 51 | unsigned char red, green, blue; |
54 | unsigned char bred, bgreen, bblue; | 52 | unsigned char bred, bgreen, bblue; |
55 | unsigned char pred, pgreen, pblue; | 53 | unsigned char pred, pgreen, pblue; |
56 | unsigned long data; | 54 | unsigned long data; |
57 | unsigned long offset; | 55 | unsigned long offset; |
58 | bool isLink; | 56 | bool isLink; |
59 | // bool isVisited; | 57 | // bool isVisited; |
60 | bool m_underline; | 58 | bool m_underline; |
61 | bool m_strikethru; | 59 | bool m_strikethru; |
62 | bool m_monospaced; | 60 | bool m_monospaced; |
63 | unsigned char m_leftmargin, m_rightmargin; | 61 | unsigned char m_leftmargin, m_rightmargin; |
64 | signed char m_extraspace; | 62 | signed char m_extraspace; |
65 | signed char m_voffset; | 63 | signed char m_voffset; |
66 | CBasicStyle() | 64 | CBasicStyle() |
67 | { | 65 | { |
68 | unset(); | 66 | unset(); |
69 | m_table = 0xffffffff; | 67 | m_table = 0xffffffff; |
70 | } | 68 | } |
71 | bool operator!=(const CBasicStyle& rhs) | 69 | bool operator!=(const CBasicStyle& rhs) |
72 | { | 70 | { |
73 | return (memcmp(this, &rhs, sizeof(CBasicStyle)) != 0); | 71 | return (memcmp(this, &rhs, sizeof(CBasicStyle)) != 0); |
74 | } | 72 | } |
75 | void unset() | 73 | void unset() |
76 | { | 74 | { |
77 | m_bold = false; | 75 | m_bold = false; |
78 | m_italic = false; | 76 | m_italic = false; |
79 | m_fontsize = 0; | 77 | m_fontsize = 0; |
80 | m_align = m_AlignLeft; | 78 | m_align = m_AlignLeft; |
diff --git a/noncore/apps/opie-write/qrichtext.cpp b/noncore/apps/opie-write/qrichtext.cpp index c27eb1e..f040f1e 100644 --- a/noncore/apps/opie-write/qrichtext.cpp +++ b/noncore/apps/opie-write/qrichtext.cpp | |||
@@ -6015,197 +6015,196 @@ QTextFormat QTextFormat::makeTextFormat( const QStyleSheetItem *style, const QMa | |||
6015 | format.setPointSize( int( scaleFontsFactor * style.mid( 10, style.length() - 12 ).toInt() ) ); | 6015 | format.setPointSize( int( scaleFontsFactor * style.mid( 10, style.length() - 12 ).toInt() ) ); |
6016 | } if ( style.startsWith("font-style:" ) ) { | 6016 | } if ( style.startsWith("font-style:" ) ) { |
6017 | QString s = style.mid( 11 ).stripWhiteSpace(); | 6017 | QString s = style.mid( 11 ).stripWhiteSpace(); |
6018 | if ( s == "normal" ) | 6018 | if ( s == "normal" ) |
6019 | format.fn.setItalic( FALSE ); | 6019 | format.fn.setItalic( FALSE ); |
6020 | else if ( s == "italic" || s == "oblique" ) | 6020 | else if ( s == "italic" || s == "oblique" ) |
6021 | format.fn.setItalic( TRUE ); | 6021 | format.fn.setItalic( TRUE ); |
6022 | } else if ( style.startsWith("font-weight:" ) ) { | 6022 | } else if ( style.startsWith("font-weight:" ) ) { |
6023 | QString s = style.mid( 12 ); | 6023 | QString s = style.mid( 12 ); |
6024 | bool ok = TRUE; | 6024 | bool ok = TRUE; |
6025 | int n = s.toInt( &ok ); | 6025 | int n = s.toInt( &ok ); |
6026 | if ( ok ) | 6026 | if ( ok ) |
6027 | format.fn.setWeight( n/8 ); | 6027 | format.fn.setWeight( n/8 ); |
6028 | } else if ( style.startsWith("font-family:" ) ) { | 6028 | } else if ( style.startsWith("font-family:" ) ) { |
6029 | format.fn.setFamily( QTextDocument::section(style.mid(12),",",0,0).stripWhiteSpace() ); | 6029 | format.fn.setFamily( QTextDocument::section(style.mid(12),",",0,0).stripWhiteSpace() ); |
6030 | } else if ( style.startsWith("text-decoration:" ) ) { | 6030 | } else if ( style.startsWith("text-decoration:" ) ) { |
6031 | QString s = style.mid( 16 ).stripWhiteSpace(); | 6031 | QString s = style.mid( 16 ).stripWhiteSpace(); |
6032 | format.fn.setUnderline( s == "underline" ); | 6032 | format.fn.setUnderline( s == "underline" ); |
6033 | } else if ( style.startsWith("vertical-align:" ) ) { | 6033 | } else if ( style.startsWith("vertical-align:" ) ) { |
6034 | QString s = style.mid( 15 ).stripWhiteSpace(); | 6034 | QString s = style.mid( 15 ).stripWhiteSpace(); |
6035 | if ( s == "sub" ) | 6035 | if ( s == "sub" ) |
6036 | format.setVAlign( QTextFormat::AlignSubScript ); | 6036 | format.setVAlign( QTextFormat::AlignSubScript ); |
6037 | else if ( s == "super" ) | 6037 | else if ( s == "super" ) |
6038 | format.setVAlign( QTextFormat::AlignSuperScript ); | 6038 | format.setVAlign( QTextFormat::AlignSuperScript ); |
6039 | else | 6039 | else |
6040 | format.setVAlign( QTextFormat::AlignNormal ); | 6040 | format.setVAlign( QTextFormat::AlignNormal ); |
6041 | } else if ( style.startsWith("color:" ) ) { | 6041 | } else if ( style.startsWith("color:" ) ) { |
6042 | format.col.setNamedColor( style.mid(6) ); | 6042 | format.col.setNamedColor( style.mid(6) ); |
6043 | format.linkColor = FALSE; | 6043 | format.linkColor = FALSE; |
6044 | } | 6044 | } |
6045 | } | 6045 | } |
6046 | } | 6046 | } |
6047 | 6047 | ||
6048 | format.update(); | 6048 | format.update(); |
6049 | return format; | 6049 | return format; |
6050 | } | 6050 | } |
6051 | 6051 | ||
6052 | struct QPixmapInt | 6052 | struct QPixmapInt |
6053 | { | 6053 | { |
6054 | QPixmapInt() : ref( 0 ) {} | 6054 | QPixmapInt() : ref( 0 ) {} |
6055 | QPixmap pm; | 6055 | QPixmap pm; |
6056 | int ref; | 6056 | int ref; |
6057 | }; | 6057 | }; |
6058 | 6058 | ||
6059 | static QMap<QString, QPixmapInt> *pixmap_map = 0; | 6059 | static QMap<QString, QPixmapInt> *pixmap_map = 0; |
6060 | 6060 | ||
6061 | QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context, | 6061 | QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context, |
6062 | QMimeSourceFactory &factory ) | 6062 | QMimeSourceFactory &factory ) |
6063 | : QTextCustomItem( p ) | 6063 | : QTextCustomItem( p ), reg( 0 ) |
6064 | { | 6064 | { |
6065 | width = height = 0; | 6065 | width = height = 0; |
6066 | if ( attr.contains("width") ) | 6066 | if ( attr.contains("width") ) |
6067 | width = attr["width"].toInt(); | 6067 | width = attr["width"].toInt(); |
6068 | if ( attr.contains("height") ) | 6068 | if ( attr.contains("height") ) |
6069 | height = attr["height"].toInt(); | 6069 | height = attr["height"].toInt(); |
6070 | 6070 | ||
6071 | reg = 0; | ||
6072 | QString imageName = attr["src"]; | 6071 | QString imageName = attr["src"]; |
6073 | 6072 | ||
6074 | if (!imageName) | 6073 | if (!imageName) |
6075 | imageName = attr["source"]; | 6074 | imageName = attr["source"]; |
6076 | 6075 | ||
6077 | if ( !imageName.isEmpty() ) { | 6076 | if ( !imageName.isEmpty() ) { |
6078 | imgId = QString( "%1,%2,%3,%4" ).arg( imageName ).arg( width ).arg( height ).arg( (ulong)&factory ); | 6077 | imgId = QString( "%1,%2,%3,%4" ).arg( imageName ).arg( width ).arg( height ).arg( (ulong)&factory ); |
6079 | if ( !pixmap_map ) | 6078 | if ( !pixmap_map ) |
6080 | pixmap_map = new QMap<QString, QPixmapInt>; | 6079 | pixmap_map = new QMap<QString, QPixmapInt>; |
6081 | if ( pixmap_map->contains( imgId ) ) { | 6080 | if ( pixmap_map->contains( imgId ) ) { |
6082 | QPixmapInt& pmi = pixmap_map->operator[](imgId); | 6081 | QPixmapInt& pmi = pixmap_map->operator[](imgId); |
6083 | pm = pmi.pm; | 6082 | pm = pmi.pm; |
6084 | pmi.ref++; | 6083 | pmi.ref++; |
6085 | width = pm.width(); | 6084 | width = pm.width(); |
6086 | height = pm.height(); | 6085 | height = pm.height(); |
6087 | } else { | 6086 | } else { |
6088 | QImage img; | 6087 | QImage img; |
6089 | const QMimeSource* m = | 6088 | const QMimeSource* m = |
6090 | factory.data( imageName, context ); | 6089 | factory.data( imageName, context ); |
6091 | if ( !m ) { | 6090 | if ( !m ) { |
6092 | owarn << "QTextImage: no mimesource for " << imageName.latin1() << "" << oendl; | 6091 | owarn << "QTextImage: no mimesource for " << imageName.latin1() << "" << oendl; |
6093 | } | 6092 | } |
6094 | else { | 6093 | else { |
6095 | if ( !QImageDrag::decode( m, img ) ) { | 6094 | if ( !QImageDrag::decode( m, img ) ) { |
6096 | owarn << "QTextImage: cannot decode " << imageName.latin1() << "" << oendl; | 6095 | owarn << "QTextImage: cannot decode " << imageName.latin1() << "" << oendl; |
6097 | } | 6096 | } |
6098 | } | 6097 | } |
6099 | 6098 | ||
6100 | if ( !img.isNull() ) { | 6099 | if ( !img.isNull() ) { |
6101 | if ( width == 0 ) { | 6100 | if ( width == 0 ) { |
6102 | width = img.width(); | 6101 | width = img.width(); |
6103 | if ( height != 0 ) { | 6102 | if ( height != 0 ) { |
6104 | width = img.width() * height / img.height(); | 6103 | width = img.width() * height / img.height(); |
6105 | } | 6104 | } |
6106 | } | 6105 | } |
6107 | if ( height == 0 ) { | 6106 | if ( height == 0 ) { |
6108 | height = img.height(); | 6107 | height = img.height(); |
6109 | if ( width != img.width() ) { | 6108 | if ( width != img.width() ) { |
6110 | height = img.height() * width / img.width(); | 6109 | height = img.height() * width / img.width(); |
6111 | } | 6110 | } |
6112 | } | 6111 | } |
6113 | if ( img.width() != width || img.height() != height ){ | 6112 | if ( img.width() != width || img.height() != height ){ |
6114 | #ifndef QT_NO_IMAGE_SMOOTHSCALE | 6113 | #ifndef QT_NO_IMAGE_SMOOTHSCALE |
6115 | img = img.smoothScale(width, height); | 6114 | img = img.smoothScale(width, height); |
6116 | #endif | 6115 | #endif |
6117 | width = img.width(); | 6116 | width = img.width(); |
6118 | height = img.height(); | 6117 | height = img.height(); |
6119 | } | 6118 | } |
6120 | pm.convertFromImage( img ); | 6119 | pm.convertFromImage( img ); |
6121 | } | 6120 | } |
6122 | if ( !pm.isNull() ) { | 6121 | if ( !pm.isNull() ) { |
6123 | QPixmapInt& pmi = pixmap_map->operator[](imgId); | 6122 | QPixmapInt& pmi = pixmap_map->operator[](imgId); |
6124 | pmi.pm = pm; | 6123 | pmi.pm = pm; |
6125 | pmi.ref++; | 6124 | pmi.ref++; |
6126 | } | 6125 | } |
6127 | } | 6126 | } |
6128 | if ( pm.mask() ) { | 6127 | if ( pm.mask() ) { |
6129 | QRegion mask( *pm.mask() ); | 6128 | QRegion mask( *pm.mask() ); |
6130 | QRegion all( 0, 0, pm.width(), pm.height() ); | 6129 | QRegion all( 0, 0, pm.width(), pm.height() ); |
6131 | reg = new QRegion( all.subtract( mask ) ); | 6130 | reg = new QRegion( all.subtract( mask ) ); |
6132 | } | 6131 | } |
6133 | } | 6132 | } |
6134 | 6133 | ||
6135 | if ( pm.isNull() && (width*height)==0 ) | 6134 | if ( pm.isNull() && (width*height)==0 ) |
6136 | width = height = 50; | 6135 | width = height = 50; |
6137 | 6136 | ||
6138 | place = PlaceInline; | 6137 | place = PlaceInline; |
6139 | if ( attr["align"] == "left" ) | 6138 | if ( attr["align"] == "left" ) |
6140 | place = PlaceLeft; | 6139 | place = PlaceLeft; |
6141 | else if ( attr["align"] == "right" ) | 6140 | else if ( attr["align"] == "right" ) |
6142 | place = PlaceRight; | 6141 | place = PlaceRight; |
6143 | 6142 | ||
6144 | tmpwidth = width; | 6143 | tmpwidth = width; |
6145 | tmpheight = height; | 6144 | tmpheight = height; |
6146 | 6145 | ||
6147 | attributes = attr; | 6146 | attributes = attr; |
6148 | } | 6147 | } |
6149 | 6148 | ||
6150 | QTextImage::~QTextImage() | 6149 | QTextImage::~QTextImage() |
6151 | { | 6150 | { |
6151 | delete reg; | ||
6152 | if ( pixmap_map && pixmap_map->contains( imgId ) ) { | 6152 | if ( pixmap_map && pixmap_map->contains( imgId ) ) { |
6153 | QPixmapInt& pmi = pixmap_map->operator[](imgId); | 6153 | QPixmapInt& pmi = pixmap_map->operator[](imgId); |
6154 | pmi.ref--; | 6154 | pmi.ref--; |
6155 | if ( !pmi.ref ) { | 6155 | if ( !pmi.ref ) { |
6156 | pixmap_map->remove( imgId ); | 6156 | pixmap_map->remove( imgId ); |
6157 | if ( pixmap_map->isEmpty() ) { | 6157 | if ( pixmap_map->isEmpty() ) { |
6158 | delete pixmap_map; | 6158 | delete pixmap_map; |
6159 | pixmap_map = 0; | 6159 | pixmap_map = 0; |
6160 | } | 6160 | } |
6161 | } | 6161 | } |
6162 | } | 6162 | } |
6163 | delete reg; | ||
6164 | } | 6163 | } |
6165 | 6164 | ||
6166 | QString QTextImage::richText() const | 6165 | QString QTextImage::richText() const |
6167 | { | 6166 | { |
6168 | QString s; | 6167 | QString s; |
6169 | s += "<img "; | 6168 | s += "<img "; |
6170 | QMap<QString, QString>::ConstIterator it = attributes.begin(); | 6169 | QMap<QString, QString>::ConstIterator it = attributes.begin(); |
6171 | for ( ; it != attributes.end(); ++it ) | 6170 | for ( ; it != attributes.end(); ++it ) |
6172 | s += it.key() + "=" + *it + " "; | 6171 | s += it.key() + "=" + *it + " "; |
6173 | s += ">"; | 6172 | s += ">"; |
6174 | return s; | 6173 | return s; |
6175 | } | 6174 | } |
6176 | 6175 | ||
6177 | void QTextImage::adjustToPainter( QPainter* p ) | 6176 | void QTextImage::adjustToPainter( QPainter* p ) |
6178 | { | 6177 | { |
6179 | width = scale( tmpwidth, p ); | 6178 | width = scale( tmpwidth, p ); |
6180 | height = scale( tmpheight, p ); | 6179 | height = scale( tmpheight, p ); |
6181 | } | 6180 | } |
6182 | 6181 | ||
6183 | #if !defined(Q_WS_X11) | 6182 | #if !defined(Q_WS_X11) |
6184 | #include <qbitmap.h> | 6183 | #include <qbitmap.h> |
6185 | #include "qcleanuphandler.h" | 6184 | #include "qcleanuphandler.h" |
6186 | static QPixmap *qrt_selection = 0; | 6185 | static QPixmap *qrt_selection = 0; |
6187 | static QSingleCleanupHandler<QPixmap> qrt_cleanup_pixmap; | 6186 | static QSingleCleanupHandler<QPixmap> qrt_cleanup_pixmap; |
6188 | static void qrt_createSelectionPixmap( const QColorGroup &cg ) | 6187 | static void qrt_createSelectionPixmap( const QColorGroup &cg ) |
6189 | { | 6188 | { |
6190 | qrt_selection = new QPixmap( 2, 2 ); | 6189 | qrt_selection = new QPixmap( 2, 2 ); |
6191 | qrt_cleanup_pixmap.set( &qrt_selection ); | 6190 | qrt_cleanup_pixmap.set( &qrt_selection ); |
6192 | qrt_selection->fill( Qt::color0 ); | 6191 | qrt_selection->fill( Qt::color0 ); |
6193 | QBitmap m( 2, 2 ); | 6192 | QBitmap m( 2, 2 ); |
6194 | m.fill( Qt::color1 ); | 6193 | m.fill( Qt::color1 ); |
6195 | QPainter p( &m ); | 6194 | QPainter p( &m ); |
6196 | p.setPen( Qt::color0 ); | 6195 | p.setPen( Qt::color0 ); |
6197 | for ( int j = 0; j < 2; ++j ) { | 6196 | for ( int j = 0; j < 2; ++j ) { |
6198 | p.drawPoint( j % 2, j ); | 6197 | p.drawPoint( j % 2, j ); |
6199 | } | 6198 | } |
6200 | p.end(); | 6199 | p.end(); |
6201 | qrt_selection->setMask( m ); | 6200 | qrt_selection->setMask( m ); |
6202 | qrt_selection->fill( cg.highlight() ); | 6201 | qrt_selection->fill( cg.highlight() ); |
6203 | } | 6202 | } |
6204 | #endif | 6203 | #endif |
6205 | 6204 | ||
6206 | void QTextImage::draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected ) | 6205 | void QTextImage::draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected ) |
6207 | { | 6206 | { |
6208 | if ( placement() != PlaceInline ) { | 6207 | if ( placement() != PlaceInline ) { |
6209 | x = xpos; | 6208 | x = xpos; |
6210 | y = ypos; | 6209 | y = ypos; |
6211 | } | 6210 | } |
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.cpp b/noncore/apps/tinykate/libkate/document/katehighlight.cpp index 539d356..89024f7 100644 --- a/noncore/apps/tinykate/libkate/document/katehighlight.cpp +++ b/noncore/apps/tinykate/libkate/document/katehighlight.cpp | |||
@@ -344,103 +344,108 @@ const QChar *HlCHex::checkHgl(const QChar *str, int len, bool) { | |||
344 | #if 0 | 344 | #if 0 |
345 | int i; | 345 | int i; |
346 | for (i=0;(*s)!='\0';s++,i++); | 346 | for (i=0;(*s)!='\0';s++,i++); |
347 | QString line(str,i); | 347 | QString line(str,i); |
348 | QRegExp3 rx("0[xX][a-fA-F\\d]+[UuLl]?"); // this matches but is also matching parenthesis | 348 | QRegExp3 rx("0[xX][a-fA-F\\d]+[UuLl]?"); // this matches but is also matching parenthesis |
349 | int pos=rx.search(line,0); | 349 | int pos=rx.search(line,0); |
350 | if(pos > -1) return str+rx.matchedLength(); | 350 | if(pos > -1) return str+rx.matchedLength(); |
351 | else | 351 | else |
352 | return 0L; | 352 | return 0L; |
353 | 353 | ||
354 | #else | 354 | #else |
355 | if (str[0] == '0' && ((str[1]&0xdf) == 'X' )) { | 355 | if (str[0] == '0' && ((str[1]&0xdf) == 'X' )) { |
356 | str += 2; | 356 | str += 2; |
357 | s = str; | 357 | s = str; |
358 | while (s->isDigit() || ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') /*|| (*s >= 'a' && *s <= 'f')*/) s++; | 358 | while (s->isDigit() || ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') /*|| (*s >= 'a' && *s <= 'f')*/) s++; |
359 | if (s > str) { | 359 | if (s > str) { |
360 | if ((*s&0xdf) == 'L' || (*s&0xdf) == 'U' ) s++; | 360 | if ((*s&0xdf) == 'L' || (*s&0xdf) == 'U' ) s++; |
361 | return s; | 361 | return s; |
362 | } | 362 | } |
363 | } | 363 | } |
364 | return 0L; | 364 | return 0L; |
365 | #endif | 365 | #endif |
366 | } | 366 | } |
367 | 367 | ||
368 | HlCFloat::HlCFloat(int attribute, int context) | 368 | HlCFloat::HlCFloat(int attribute, int context) |
369 | : HlFloat(attribute,context) { | 369 | : HlFloat(attribute,context) { |
370 | } | 370 | } |
371 | 371 | ||
372 | const QChar *HlCFloat::checkHgl(const QChar *s, int len, bool lineStart) { | 372 | const QChar *HlCFloat::checkHgl(const QChar *s, int len, bool lineStart) { |
373 | 373 | ||
374 | s = HlFloat::checkHgl(s, len, lineStart); | 374 | s = HlFloat::checkHgl(s, len, lineStart); |
375 | if (s && ((*s&0xdf) == 'F' )) s++; | 375 | if (s && ((*s&0xdf) == 'F' )) s++; |
376 | return s; | 376 | return s; |
377 | } | 377 | } |
378 | 378 | ||
379 | HlAnyChar::HlAnyChar(int attribute, int context, const QChar* charList, uint len) | 379 | HlAnyChar::HlAnyChar(int attribute, int context, const QChar* charList, uint len) |
380 | : HlItem(attribute, context) { | 380 | : HlItem(attribute, context) { |
381 | _charList=charList; | 381 | _charList=charList; |
382 | _charListLen=len; | 382 | _charListLen=len; |
383 | } | 383 | } |
384 | 384 | ||
385 | const QChar *HlAnyChar::checkHgl(const QChar *s, int len, bool) | 385 | const QChar *HlAnyChar::checkHgl(const QChar *s, int len, bool) |
386 | { | 386 | { |
387 | if (ustrchr(_charList, _charListLen, *s)) return s +1; | 387 | if (ustrchr(_charList, _charListLen, *s)) return s +1; |
388 | return 0L; | 388 | return 0L; |
389 | } | 389 | } |
390 | 390 | ||
391 | HlRegExpr::HlRegExpr(int attribute, int context,QString regexp) | 391 | HlRegExpr::HlRegExpr(int attribute, int context,QString regexp) |
392 | : HlItem(attribute, context) { | 392 | : HlItem(attribute, context), Expr(0) { |
393 | 393 | ||
394 | handlesLinestart=regexp.startsWith("^"); | 394 | handlesLinestart=regexp.startsWith("^"); |
395 | if(!handlesLinestart) regexp.prepend("^"); | 395 | if(!handlesLinestart) regexp.prepend("^"); |
396 | Expr=new QRegExp3(regexp); | 396 | Expr=new QRegExp3(regexp); |
397 | } | 397 | } |
398 | 398 | ||
399 | HlRegExpr::~HlRegExpr() | ||
400 | { | ||
401 | delete Expr; | ||
402 | } | ||
403 | |||
399 | const QChar *HlRegExpr::checkHgl(const QChar *s, int len, bool lineStart) | 404 | const QChar *HlRegExpr::checkHgl(const QChar *s, int len, bool lineStart) |
400 | { | 405 | { |
401 | if ((!lineStart) && handlesLinestart) return 0; | 406 | if ((!lineStart) && handlesLinestart) return 0; |
402 | 407 | ||
403 | QString line(s,len); | 408 | QString line(s,len); |
404 | int pos = Expr->search( line, 0 ); | 409 | int pos = Expr->search( line, 0 ); |
405 | if (pos==-1) return 0L; | 410 | if (pos==-1) return 0L; |
406 | else | 411 | else |
407 | return (s+Expr->matchedLength()); | 412 | return (s+Expr->matchedLength()); |
408 | }; | 413 | }; |
409 | 414 | ||
410 | 415 | ||
411 | HlLineContinue::HlLineContinue(int attribute, int context) | 416 | HlLineContinue::HlLineContinue(int attribute, int context) |
412 | : HlItem(attribute,context) { | 417 | : HlItem(attribute,context) { |
413 | } | 418 | } |
414 | 419 | ||
415 | const QChar *HlLineContinue::checkHgl(const QChar *s, int len, bool) { | 420 | const QChar *HlLineContinue::checkHgl(const QChar *s, int len, bool) { |
416 | 421 | ||
417 | if ((s[0].latin1() == '\\') && (len == 1)) | 422 | if ((s[0].latin1() == '\\') && (len == 1)) |
418 | { | 423 | { |
419 | return s + 1; | 424 | return s + 1; |
420 | } | 425 | } |
421 | return 0L; | 426 | return 0L; |
422 | } | 427 | } |
423 | 428 | ||
424 | 429 | ||
425 | HlCStringChar::HlCStringChar(int attribute, int context) | 430 | HlCStringChar::HlCStringChar(int attribute, int context) |
426 | : HlItem(attribute,context) { | 431 | : HlItem(attribute,context) { |
427 | } | 432 | } |
428 | 433 | ||
429 | //checks for hex and oct (for example \x1b or \033) | 434 | //checks for hex and oct (for example \x1b or \033) |
430 | const QChar *checkCharHexOct(const QChar *str) { | 435 | const QChar *checkCharHexOct(const QChar *str) { |
431 | const QChar *s; | 436 | const QChar *s; |
432 | s=str; | 437 | s=str; |
433 | int n; | 438 | int n; |
434 | if (*s == 'x') { | 439 | if (*s == 'x') { |
435 | n = 0; | 440 | n = 0; |
436 | do { | 441 | do { |
437 | s++; | 442 | s++; |
438 | n *= 16; | 443 | n *= 16; |
439 | if (s->isDigit()) n += *s - '0'; | 444 | if (s->isDigit()) n += *s - '0'; |
440 | else if ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') n += (*s&0xdf) - 'A' + 10; | 445 | else if ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') n += (*s&0xdf) - 'A' + 10; |
441 | // else if (*s >= 'a' && *s <= 'f') n += *s - 'a' + 10; | 446 | // else if (*s >= 'a' && *s <= 'f') n += *s - 'a' + 10; |
442 | else break; | 447 | else break; |
443 | if (n >= 256) return 0L; | 448 | if (n >= 256) return 0L; |
444 | } while (true); | 449 | } while (true); |
445 | if (s - str == 1) return 0L; | 450 | if (s - str == 1) return 0L; |
446 | } else { | 451 | } else { |
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.h b/noncore/apps/tinykate/libkate/document/katehighlight.h index fddf585..f0be27b 100644 --- a/noncore/apps/tinykate/libkate/document/katehighlight.h +++ b/noncore/apps/tinykate/libkate/document/katehighlight.h | |||
@@ -139,97 +139,97 @@ class HlCInt : public HlInt { | |||
139 | class HlCOct : public HlItem { | 139 | class HlCOct : public HlItem { |
140 | public: | 140 | public: |
141 | HlCOct(int attribute, int context); | 141 | HlCOct(int attribute, int context); |
142 | virtual const QChar *checkHgl(const QChar *, int len, bool); | 142 | virtual const QChar *checkHgl(const QChar *, int len, bool); |
143 | }; | 143 | }; |
144 | 144 | ||
145 | class HlCHex : public HlItem { | 145 | class HlCHex : public HlItem { |
146 | public: | 146 | public: |
147 | HlCHex(int attribute, int context); | 147 | HlCHex(int attribute, int context); |
148 | virtual const QChar *checkHgl(const QChar *, int len, bool); | 148 | virtual const QChar *checkHgl(const QChar *, int len, bool); |
149 | }; | 149 | }; |
150 | 150 | ||
151 | class HlCFloat : public HlFloat { | 151 | class HlCFloat : public HlFloat { |
152 | public: | 152 | public: |
153 | HlCFloat(int attribute, int context); | 153 | HlCFloat(int attribute, int context); |
154 | virtual const QChar *checkHgl(const QChar *, int len, bool); | 154 | virtual const QChar *checkHgl(const QChar *, int len, bool); |
155 | }; | 155 | }; |
156 | 156 | ||
157 | class HlLineContinue : public HlItem { | 157 | class HlLineContinue : public HlItem { |
158 | public: | 158 | public: |
159 | HlLineContinue(int attribute, int context); | 159 | HlLineContinue(int attribute, int context); |
160 | virtual bool endEnable(QChar c) {return c == '\0';} | 160 | virtual bool endEnable(QChar c) {return c == '\0';} |
161 | virtual const QChar *checkHgl(const QChar *, int len, bool); | 161 | virtual const QChar *checkHgl(const QChar *, int len, bool); |
162 | }; | 162 | }; |
163 | 163 | ||
164 | class HlCStringChar : public HlItem { | 164 | class HlCStringChar : public HlItem { |
165 | public: | 165 | public: |
166 | HlCStringChar(int attribute, int context); | 166 | HlCStringChar(int attribute, int context); |
167 | virtual const QChar *checkHgl(const QChar *, int len, bool); | 167 | virtual const QChar *checkHgl(const QChar *, int len, bool); |
168 | }; | 168 | }; |
169 | 169 | ||
170 | class HlCChar : public HlItem { | 170 | class HlCChar : public HlItem { |
171 | public: | 171 | public: |
172 | HlCChar(int attribute, int context); | 172 | HlCChar(int attribute, int context); |
173 | virtual const QChar *checkHgl(const QChar *, int len, bool); | 173 | virtual const QChar *checkHgl(const QChar *, int len, bool); |
174 | }; | 174 | }; |
175 | 175 | ||
176 | class HlAnyChar : public HlItem { | 176 | class HlAnyChar : public HlItem { |
177 | public: | 177 | public: |
178 | HlAnyChar(int attribute, int context, const QChar* charList, uint len); | 178 | HlAnyChar(int attribute, int context, const QChar* charList, uint len); |
179 | virtual const QChar *checkHgl(const QChar *, int len, bool); | 179 | virtual const QChar *checkHgl(const QChar *, int len, bool); |
180 | const QChar* _charList; | 180 | const QChar* _charList; |
181 | uint _charListLen; | 181 | uint _charListLen; |
182 | }; | 182 | }; |
183 | 183 | ||
184 | class HlRegExpr : public HlItem { | 184 | class HlRegExpr : public HlItem { |
185 | public: | 185 | public: |
186 | HlRegExpr(int attribute, int context,QString expr); | 186 | HlRegExpr(int attribute, int context,QString expr); |
187 | ~HlRegExpr(){delete Expr;}; | 187 | ~HlRegExpr(); |
188 | virtual const QChar *checkHgl(const QChar *, int len, bool); | 188 | virtual const QChar *checkHgl(const QChar *, int len, bool); |
189 | QRegExp3 *Expr; | 189 | QRegExp3 *Expr; |
190 | bool handlesLinestart; | 190 | bool handlesLinestart; |
191 | }; | 191 | }; |
192 | 192 | ||
193 | //-------- | 193 | //-------- |
194 | 194 | ||
195 | 195 | ||
196 | //Item Style: color, selected color, bold, italic | 196 | //Item Style: color, selected color, bold, italic |
197 | class ItemStyle { | 197 | class ItemStyle { |
198 | public: | 198 | public: |
199 | ItemStyle(); | 199 | ItemStyle(); |
200 | // ItemStyle(const ItemStyle &); | 200 | // ItemStyle(const ItemStyle &); |
201 | ItemStyle(const QColor &, const QColor &, bool bold, bool italic); | 201 | ItemStyle(const QColor &, const QColor &, bool bold, bool italic); |
202 | ItemStyle(ItemStyle *its){col=its->col;selCol=its->selCol; bold=its->bold; italic=its->italic;} | 202 | ItemStyle(ItemStyle *its){col=its->col;selCol=its->selCol; bold=its->bold; italic=its->italic;} |
203 | // void setData(const ItemStyle &); | 203 | // void setData(const ItemStyle &); |
204 | QColor col; | 204 | QColor col; |
205 | QColor selCol; | 205 | QColor selCol; |
206 | int bold; //boolean value | 206 | int bold; //boolean value |
207 | int italic; //boolean value | 207 | int italic; //boolean value |
208 | }; | 208 | }; |
209 | 209 | ||
210 | typedef QList<ItemStyle> ItemStyleList; | 210 | typedef QList<ItemStyle> ItemStyleList; |
211 | 211 | ||
212 | //Item Properties: name, Item Style, Item Font | 212 | //Item Properties: name, Item Style, Item Font |
213 | class ItemData : public ItemStyle { | 213 | class ItemData : public ItemStyle { |
214 | public: | 214 | public: |
215 | ItemData(const QString name, int defStyleNum); | 215 | ItemData(const QString name, int defStyleNum); |
216 | ItemData(const QString name, int defStyleNum, | 216 | ItemData(const QString name, int defStyleNum, |
217 | const QColor&, const QColor&, bool bold, bool italic); | 217 | const QColor&, const QColor&, bool bold, bool italic); |
218 | ItemData(ItemData | 218 | ItemData(ItemData |
219 | *itd):ItemStyle((ItemStyle*)itd),name(itd->name),defStyleNum(itd->defStyleNum),defStyle(itd->defStyle){;} | 219 | *itd):ItemStyle((ItemStyle*)itd),name(itd->name),defStyleNum(itd->defStyleNum),defStyle(itd->defStyle){;} |
220 | const QString name; | 220 | const QString name; |
221 | int defStyleNum; | 221 | int defStyleNum; |
222 | int defStyle; //boolean value | 222 | int defStyle; //boolean value |
223 | }; | 223 | }; |
224 | 224 | ||
225 | typedef QList<ItemData> ItemDataList; | 225 | typedef QList<ItemData> ItemDataList; |
226 | 226 | ||
227 | class HlData { | 227 | class HlData { |
228 | public: | 228 | public: |
229 | HlData(const QString &wildcards, const QString &mimetypes,const QString &identifier); | 229 | HlData(const QString &wildcards, const QString &mimetypes,const QString &identifier); |
230 | ItemDataList itemDataList; | 230 | ItemDataList itemDataList; |
231 | QString wildcards; | 231 | QString wildcards; |
232 | QString mimetypes; | 232 | QString mimetypes; |
233 | QString identifier; | 233 | QString identifier; |
234 | }; | 234 | }; |
235 | 235 | ||