mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 06:05:58 -06:00
upp.src: Various CHARSET_UNICODE->CHARSET_UTF8 changes, FT_fontsys fix, SDL2GL fix
This commit is contained in:
parent
d2207cd21f
commit
22cf499432
14 changed files with 44 additions and 53 deletions
|
|
@ -146,7 +146,6 @@ CONSOLE_APP_MAIN
|
|||
LOG("Quick allocator test Passed");
|
||||
HeapTest(8192, 100 * 1000000, false);
|
||||
LOG("Allocator test Passed");
|
||||
MemoryFreeThread();
|
||||
}
|
||||
LOG("Used: " << MemoryUsedKb() << " KB");
|
||||
LOG("============== OK " << tm);
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ CONSOLE_APP_MAIN
|
|||
dword emoticon = 0x1f60d; // Smiling Face With Heart-shaped Eyes
|
||||
|
||||
String text = "Český 아침글";
|
||||
Vector<dword> h = ToUtf32(text);
|
||||
h.Add('\n');
|
||||
h.Add(emoticon);
|
||||
h.Add(31);
|
||||
WString h = ToUtf32(text);
|
||||
h.Cat('\n');
|
||||
h.Cat(emoticon);
|
||||
h.Cat(31);
|
||||
DUMP(h);
|
||||
|
||||
dword ref[] = { 268, 101, 115, 107, 253, 32, 50500, 52840, 44544, 10, 128525, 31 };
|
||||
|
|
|
|||
|
|
@ -15,25 +15,23 @@ CONSOLE_APP_MAIN
|
|||
DeleteFolderDeep(outdir);
|
||||
RealizeDirectory(outdir);
|
||||
|
||||
for(FindFile ff(GetDataFile("*.qtf")); ff; ff.Next()) {
|
||||
String qtf = LoadFile(ff.GetPath());
|
||||
LOG(ff.GetName() << ' ' << qtf.GetCount());
|
||||
|
||||
ASSERT(qtf.GetLength() > 10000);
|
||||
RichText txt = ParseQTF(qtf);
|
||||
String qtf2 = AsQTF(txt);
|
||||
ASSERT(qtf2 == qtf);
|
||||
SaveFile(AppendFileName(outdir, ff.GetName()), qtf2);
|
||||
|
||||
String pdfname = ForceExt(ff.GetName(), ".pdf");
|
||||
String pdf = Pdf(txt);
|
||||
SaveFile(AppendFileName(outdir, pdfname), pdf);
|
||||
|
||||
String h = LoadDataFile(pdfname);
|
||||
ASSERT(h.GetCount() == pdf.GetCount());
|
||||
int q = h.ReverseFind("trailer");
|
||||
ASSERT(pdf.Mid(0, q) == h.Mid(0, q));
|
||||
}
|
||||
String qtf = LoadDataFile("test.qtf");
|
||||
|
||||
DDUMP(qtf.GetCount());
|
||||
|
||||
ASSERT(qtf.GetLength() > 10000);
|
||||
RichText txt = ParseQTF(qtf);
|
||||
String qtf2 = AsQTF(txt);
|
||||
ASSERT(qtf2 == qtf);
|
||||
|
||||
String pdf = Pdf(txt);
|
||||
String pdfpath = AppendFileName(outdir, "test.pdf");
|
||||
SaveFile(pdfpath, pdf);
|
||||
|
||||
String h = LoadDataFile("test.pdf");
|
||||
ASSERT(h.GetCount() == pdf.GetCount());
|
||||
int q = h.ReverseFind("trailer");
|
||||
ASSERT(pdf.Mid(0, q) == h.Mid(0, q));
|
||||
|
||||
DeleteFolderDeep(outdir);
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ CONSOLE_APP_MAIN
|
|||
|
||||
DLOG("===== Decompose");
|
||||
for(int i = 0; i < 0x110000; i++) {
|
||||
Vector<dword> dc = UnicodeDecompose(i, true);
|
||||
WString dc = UnicodeDecompose(i, true);
|
||||
if(dc.GetCount()) {
|
||||
VppLog() << Format64Hex(i) << "->";
|
||||
for(int c : dc)
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ bool Ctrl::DispatchKey(dword keycode, int count)
|
|||
return true;
|
||||
dword k = keycode;
|
||||
word l = LOWORD(keycode);
|
||||
if(!(k & K_DELTA) && l >= 32 && l != 127 && GetDefaultCharset() != CHARSET_UNICODE)
|
||||
if(!(k & K_DELTA) && l >= 32 && l != 127 && GetDefaultCharset() != CHARSET_UTF8)
|
||||
k = MAKELONG((word)FromUnicode(l, CHARSET_DEFAULT), HIWORD(keycode));
|
||||
if(!focusCtrl)
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -441,7 +441,7 @@ bool DocEdit::Key(dword key, int cnt)
|
|||
if(key >= ' ' && key < K_CHAR_LIM || key == '\n' || key == '\t' || key == K_SHIFT_SPACE) {
|
||||
if(key == K_TAB && !processtab)
|
||||
return false;
|
||||
if(key >= 128 && key < K_CHAR_LIM && (charset != CHARSET_UNICODE && charset != CHARSET_UTF8_BOM)
|
||||
if(key >= 128 && key < K_CHAR_LIM && (charset != CHARSET_UTF8 && charset != CHARSET_UTF8_BOM)
|
||||
&& FromUnicode((wchar)key, charset) == DEFAULTCHAR)
|
||||
return true;
|
||||
RemoveSelection();
|
||||
|
|
|
|||
|
|
@ -624,7 +624,7 @@ int EditField::Insert(int pos, const WString& itext)
|
|||
chr = (*filter)(chr);
|
||||
if(chr) {
|
||||
chr = convert->Filter(chr);
|
||||
if(chr && (charset == CHARSET_UNICODE || FromUnicode(chr, charset, 0)))
|
||||
if(chr && (charset == CHARSET_UTF8 || FromUnicode(chr, charset, 0)))
|
||||
ins.Cat(chr, count);
|
||||
}
|
||||
}
|
||||
|
|
@ -1015,7 +1015,7 @@ void EditField::Reset()
|
|||
autosize = false;
|
||||
keep_selection = false;
|
||||
errorbg = nobg = false;
|
||||
charset = CHARSET_UNICODE;
|
||||
charset = CHARSET_UTF8;
|
||||
alignright = false;
|
||||
SetStyle(StyleDefault());
|
||||
SetFrame(edge);
|
||||
|
|
|
|||
|
|
@ -1022,7 +1022,7 @@ bool LineEdit::InsertChar(dword key, int count, bool canow) {
|
|||
key = (*filter)(key);
|
||||
if(!IsReadOnly() && (key >= 32 && key < K_CHAR_LIM || key == '\t' || key == '\n' ||
|
||||
key == K_ENTER && processenter || key == K_SHIFT_SPACE)) {
|
||||
if(key >= 128 && key < K_CHAR_LIM && (charset != CHARSET_UNICODE && charset != CHARSET_UTF8_BOM)
|
||||
if(key >= 128 && key < K_CHAR_LIM && (charset != CHARSET_UTF8 && charset != CHARSET_UTF8_BOM)
|
||||
&& FromUnicode((wchar)key, charset) == DEFAULTCHAR)
|
||||
return true;
|
||||
if(!RemoveSelection() && overwrite && key != '\n' && key != K_ENTER && canow) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ TextCtrl::TextCtrl()
|
|||
incundoserial = false;
|
||||
undo_op = false;
|
||||
WhenBar = THISBACK(StdBar);
|
||||
charset = CHARSET_UNICODE;
|
||||
charset = CHARSET_UTF8;
|
||||
color[INK_NORMAL] = SColorText;
|
||||
color[INK_DISABLED] = SColorDisabled;
|
||||
color[INK_SELECTED] = SColorHighlightText;
|
||||
|
|
|
|||
|
|
@ -249,6 +249,8 @@ Vector<FaceInfo> GetAllFacesSys()
|
|||
|
||||
String GetFontDataSys(Font font, const char *table, int offset, int size)
|
||||
{ // read truetype or opentype table
|
||||
if(!table)
|
||||
return LoadFile(font.Fi().path);
|
||||
FileIn in(font.Fi().path);
|
||||
int q = in.Get32be();
|
||||
if(q == 0x74746366) { // font collection
|
||||
|
|
|
|||
|
|
@ -492,7 +492,7 @@ bool OCI8Connection::BulkExecute(const char *stmt, const Vector< Vector<Value> >
|
|||
sql_type = SQLT_STR;
|
||||
if(session->utf8_session) {
|
||||
WString wstr(v);
|
||||
len = 1 + lenAsUtf8(wstr, wstr.GetLength());
|
||||
len = 1 + Utf8Len(wstr, wstr.GetLength());
|
||||
}
|
||||
else
|
||||
len = 1 + String(v).GetLength();
|
||||
|
|
@ -910,7 +910,7 @@ void OCI8Connection::GetColumn(int i, WString& ws) const {
|
|||
s = (char *) c.Data();
|
||||
}
|
||||
if(session->utf8_session)
|
||||
ws = FromUtf8(s);
|
||||
ws = ToUtf32(s);
|
||||
else
|
||||
ws = s.ToWString();
|
||||
}
|
||||
|
|
@ -1610,13 +1610,9 @@ dword OracleClob::Read(int64 at, void *ptr, dword size) {
|
|||
return full_bytes;
|
||||
WString unibuf;
|
||||
if(utf8)
|
||||
unibuf = FromUtf8(charbuf, nchars);
|
||||
else {
|
||||
WStringBuffer tmp;
|
||||
tmp.SetLength(nchars);
|
||||
ToUnicode(tmp, charbuf, nchars, CHARSET_DEFAULT);
|
||||
unibuf = tmp;
|
||||
}
|
||||
unibuf = ToUtf32(charbuf, nchars);
|
||||
else
|
||||
unibuf = ToUnicode(charbuf, nchars, CHARSET_DEFAULT);
|
||||
int ulen = unibuf.GetLength();
|
||||
int uoff = (int)(at & 1);
|
||||
int upart = min((int)size, 2 * ulen - uoff);
|
||||
|
|
@ -1663,12 +1659,8 @@ void OracleClob::Write(int64 at, const void *ptr, dword size) {
|
|||
String chrbuf;
|
||||
if(utf8)
|
||||
chrbuf = ToUtf8((const wchar *)ptr, nchars);
|
||||
else {
|
||||
StringBuffer tmp;
|
||||
tmp.SetLength(nchars);
|
||||
FromUnicode(tmp, (const wchar *)ptr, nchars, CHARSET_DEFAULT);
|
||||
chrbuf = tmp;
|
||||
}
|
||||
else
|
||||
chrbuf = FromUnicode((const wchar *)ptr, nchars, CHARSET_DEFAULT);
|
||||
ub4 n = chrbuf.GetLength();
|
||||
sword res = session->oci8.OCILobWrite(session->svchp, session->errhp, locp,
|
||||
&n, (dword)(at >> 1) + 1, (dvoid *)chrbuf.Begin(), chrbuf.GetLength(),
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ void AppendClipboardText(const String& s)
|
|||
|
||||
void AppendClipboardUnicodeText(const WString& s)
|
||||
{
|
||||
AppendClipboard("wtext", (byte *)~s, 2 * s.GetLength());
|
||||
AppendClipboard("wtext", (byte *)~s, sizeof(wchar) * s.GetLength());
|
||||
}
|
||||
|
||||
const char *ClipFmtsText()
|
||||
|
|
@ -66,7 +66,7 @@ String GetString(PasteClip& clip)
|
|||
GuiLock __;
|
||||
if(clip.Accept("wtext")) {
|
||||
String s = ~clip;
|
||||
return WString((const wchar *)~s, wstrlen((const wchar *)~s)).ToString();
|
||||
return WString((const wchar *)~s, strlen__((const wchar *)~s)).ToString();
|
||||
}
|
||||
if(clip.IsAvailable("text"))
|
||||
return ~clip;
|
||||
|
|
@ -78,7 +78,7 @@ WString GetWString(PasteClip& clip)
|
|||
GuiLock __;
|
||||
if(clip.Accept("wtext")) {
|
||||
String s = ~clip;
|
||||
return WString((const wchar *)~s, wstrlen((const wchar *)~s));
|
||||
return WString((const wchar *)~s, strlen__((const wchar *)~s));
|
||||
}
|
||||
if(clip.IsAvailable("text"))
|
||||
return (~clip).ToWString();
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ void SDL2GUI::HandleSDLEvent(SDL_Event* event)
|
|||
// break;
|
||||
case SDL_TEXTINPUT: {
|
||||
//send respective keyup things as char events as well
|
||||
WString text = FromUtf8(event->text.text);
|
||||
WString text = event->text.text;
|
||||
for(int i = 0; i < text.GetCount(); i++) {
|
||||
int c = text[i];
|
||||
if(c != 127)
|
||||
|
|
|
|||
|
|
@ -72,9 +72,9 @@ FtFontStyle GetFontStyle(Font font)
|
|||
return fd.At(0).style[0];
|
||||
}
|
||||
|
||||
String GetFontDataSys(Font font)
|
||||
{
|
||||
return LoadFile(font.Fi().path);
|
||||
String GetFontDataSys(Font font, const char *table, int offset, int size)
|
||||
{ // TODO: Finish this!
|
||||
return Null;
|
||||
}
|
||||
|
||||
static FT_Library sFTlib;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue