ide: rudimentary css highlighting support, PGSQL: support for hex blobs

git-svn-id: svn://ultimatepp.org/upp/trunk@5078 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2012-06-26 19:13:33 +00:00
parent 6372241578
commit 0a14488501
7 changed files with 48 additions and 10 deletions

View file

@ -180,6 +180,7 @@ public:
enum {
HIGHLIGHT_NONE = -1, HIGHLIGHT_CPP = 0, HIGHLIGHT_USC, HIGHLIGHT_JAVA, HIGHLIGHT_T,
HIGHLIGHT_CALC, HIGHLIGHT_LAY, HIGHLIGHT_SCH, HIGHLIGHT_SQL, HIGHLIGHT_JAVASCRIPT,
HIGHLIGHT_CSS,
HIGHLIGHT_COUNT
};

View file

@ -328,6 +328,26 @@ void CodeEditor::InitKeywords()
"debugger", "super", "true", "false", "undefined",
NULL
};
static const char *css[] = {
"azimuth", "background-attachment", "background-color", "background-image", "background-position",
"background-repeat", "background", "border-collapse", "border-color", "border-spacing", "border-style",
"border-top", "border-right", "border-bottom", "border-left", "border-top-color", "border-right-color",
"border-bottom-color", "border-left-color", "border-top-style", "border-right-style", "border-bottom-style",
"border-left-style", "border-top-width", "border-right-width", "border-bottom-width", "border-left-width",
"border-width", "border", "bottom", "caption-side", "clear", "clip", "color", "content", "counter-increment",
"counter-reset", "cue-after", "cue-before", "cue", "cursor", "direction", "display", "elevation", "empty-cells",
"float", "font-family", "font-size", "font-style", "font-variant", "font-weight", "font", "height", "left",
"letter-spacing", "line-height", "list-style-image", "list-style-position", "list-style-type", "list-style",
"margin-right", "margin-left", "margin-top", "margin-bottom", "margin", "max-height", "max-width", "min-height",
"min-width", "orphans", "outline-color", "outline-style", "outline-width", "outline", "overflow", "padding-top",
"padding-right", "padding-bottom", "padding-left", "padding", "page-break-after", "page-break-before",
"page-break-inside", "pause-after", "pause-before", "pause", "pitch-range", "pitch", "play-during", "position",
"quotes", "richness", "right", "speak-header", "speak-numeral", "speak-punctuation", "speak", "speech-rate",
"stress", "table-layout", "text-align", "text-decoration", "text-indent", "text-transform", "top",
"unicode-bidi", "vertical-align", "visibility", "voice-family", "volume", "white-space", "widows", "width",
"word-spacing", "z-index",
NULL
};
static const char *upp_macros[] = {
"CLASSNAME", "THISBACK", "THISBACK1", "THISBACK2", "THISBACK3", "THISBACK4",
"PTEBACK", "PTEBACK1", "PTEBACK2", "PTEBACK3", "PTEBACK4",
@ -431,10 +451,10 @@ void CodeEditor::InitKeywords()
NULL
};
static const char **kw[HIGHLIGHT_COUNT] = {
cpp, usc, java, tfile, usc, lay, sch, sql, javascript
cpp, usc, java, tfile, usc, lay, sch, sql, javascript, css,
};
static const char **nm[HIGHLIGHT_COUNT] = {
upp, usclib, javan, tlng, usclib, javan, javan, javan, javascriptn
upp, usclib, javan, tlng, usclib, javan, javan, javan, javascriptn, javan,
};
const char **q = NULL;
for(int i = 0; i < HIGHLIGHT_COUNT; i++) {
@ -503,7 +523,7 @@ void CodeEditor::HighlightLine(int line, Vector<LineEdit::Highlight>& hl, int po
p++;
hls.Put(hl_style[INK_NORMAL]);
}
if(*p == '#' && highlight != HIGHLIGHT_JAVASCRIPT) {
if(*p == '#' && highlight != HIGHLIGHT_JAVASCRIPT && highlight != HIGHLIGHT_CSS) {
static const char *pd[] = {
"define", "error", "if", "elif", "else", "endif",
"ifdef", "ifndef", "include", "line", "undef", "pragma",

View file

@ -219,8 +219,11 @@ void WakeUpGuiThread()
::PostThreadMessage(sMainThreadId, WM_NULL, 0, 0);
}
void AvoidPaintingCheck__();
static void Win32PanicMessageBox(const char *title, const char *text)
{
AvoidPaintingCheck__();
#ifdef PLATFORM_WINCE
static wchar wtext[256], wtitle[256];
ToUnicode(wtext, text, strlen(text), CHARSET_DEFAULT);

View file

@ -371,7 +371,12 @@ bool PostgreSQLSession::Open(const char *connect)
DoKeepAlive();
LLOG( String("Postgresql client encoding: ") + pg_encoding_to_char( PQclientEncoding(conn) ) );
Sql sql(*this);
if(sql.Execute("select setting from pg_settings where name = 'bytea_output'") && sql[0] == "hex")
hex_blobs = true;
return true;
}
@ -627,10 +632,14 @@ void PostgreSQLConnection::GetColumn(int i, Ref f) const
break;
default: {
if(oid[i] == PGSQL_BYTEAOID) {
size_t len;
unsigned char *q = PQunescapeBytea((const unsigned char *)s, &len);
f.SetValue(String(q, len));
PQfreemem(q);
if(session.hex_blobs)
f.SetValue(ScanHexString(s, strlen(s)));
else {
size_t len;
unsigned char *q = PQunescapeBytea((const unsigned char *)s, &len);
f.SetValue(String(q, len));
PQfreemem(q);
}
}
else
f.SetValue(FromCharset(String(s)));

View file

@ -54,6 +54,7 @@ private:
String conns;
bool keepalive;
bool hex_blobs;
void ExecTrans(const char * statement);
Vector<String> EnumData(char type, const char *schema = NULL);
@ -88,7 +89,7 @@ public:
virtual void Rollback();
virtual int GetTransactionLevel() const;
PostgreSQLSession() { conn = NULL; Dialect(PGSQL); level = 0; keepalive = false; }
PostgreSQLSession() { conn = NULL; Dialect(PGSQL); level = 0; keepalive = hex_blobs = false; }
~PostgreSQLSession() { Close(); }
PGconn * GetPGConn() { return conn; }
};

View file

@ -26,6 +26,9 @@ void Ide::SetupEditor(int f, String hl, String fn)
if(hl == "js")
editor.Highlight(CodeEditor::HIGHLIGHT_JAVASCRIPT);
else
if(hl == "css")
editor.Highlight(CodeEditor::HIGHLIGHT_CSS);
else
if(hl == "t" || hl == "jt")
editor.Highlight(CodeEditor::HIGHLIGHT_T);
else
@ -123,6 +126,7 @@ void Ide::FileProperties()
d.highlight.Add("cpp", "C++");
d.highlight.Add("java", "Java");
d.highlight.Add("js", "JavaScript");
d.highlight.Add("css", "CSS");
d.highlight.Add("sql", "SQL");
d.highlight.Add("usc", "Esc");
d.highlight.Add("sch", "DB schema");

View file

@ -17,6 +17,6 @@
#include "usvn/init"
#include "TextDiffCtrl/init"
#include "TabBar/init"
#include "ide\SrcUpdater/init"
#include "ide\Img/init"
#include "ide\SrcUpdater/init"
#endif