mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2025-12-30 22:20:50 +00:00
seems to work
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@243 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
CC = cl
|
||||
LD = link
|
||||
|
||||
OBJS = src\core.obj src\draw.obj src\default.obj src\lowlevel.obj src\error.obj src\font.obj src\boldfont.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\submenu.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\widget\entry.obj src\external\ds.obj src\external\image.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\backend\gdi.obj
|
||||
OOOBJS = oosrc\base.obj oosrc\widget\button.obj oosrc\widget\frame.obj oosrc\widget\image.obj oosrc\widget\menu.obj oosrc\widget\opengl.obj oosrc\widget\scrollbar.obj oosrc\widget\submenu.obj oosrc\widget\window.obj oosrc\widget\checkbox.obj oosrc\widget\text.obj oosrc\widget\label.obj oosrc\widget\entry.obj
|
||||
OBJS = src\core.obj src\draw.obj src\default.obj src\lowlevel.obj src\error.obj src\unicode.obj src\font.obj src\boldfont.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\entry.obj src\widget\submenu.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\external\ds.obj src\external\image.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\backend\gdi.obj
|
||||
OOOBJS = oosrc\base.obj oosrc\widget\button.obj oosrc\widget\frame.obj oosrc\widget\image.obj oosrc\widget\menu.obj oosrc\widget\opengl.obj oosrc\widget\scrollbar.obj oosrc\widget\submenu.obj oosrc\widget\window.obj oosrc\widget\checkbox.obj oosrc\widget\label.obj oosrc\widget\entry.obj
|
||||
CFLAGS = /nologo /DSTBI_NO_SIMD /D_MILSKO /DUSE_GDI /DUSE_STB_IMAGE /Iinclude
|
||||
CXXFLAGS = /nologo /Iinclude
|
||||
LDFLAGS = /nologo /DLL /LIBPATH:src /LIBPATH:oosrc
|
||||
|
||||
@@ -203,6 +203,18 @@
|
||||
<dt>
|
||||
<a href="#Mw_TypeDefs_h">Mw/TypeDefs.h</a>
|
||||
</dt>
|
||||
<dt>
|
||||
<a href="#Mw_Unicode_h">Mw/Unicode.h</a>
|
||||
</dt>
|
||||
<dd>
|
||||
<a href="#Mw_Unicode_h__MwUTF8ToUTF32">MwUTF8ToUTF32</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="#Mw_Unicode_h__MwUTF8Length">MwUTF8Length</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="#Mw_Unicode_h__MwUTF8Copy">MwUTF8Copy</a>
|
||||
</dd>
|
||||
<dt>
|
||||
<a href="#Mw_Widget_Button_h">Mw/Widget/Button.h</a>
|
||||
</dt>
|
||||
@@ -1655,6 +1667,63 @@
|
||||
</dt>
|
||||
</dl>
|
||||
<hr>
|
||||
<h2 align="center" id="Mw_Unicode_h">Mw/Unicode.h</h2>
|
||||
<dl>
|
||||
<dt>
|
||||
Handles UTF8 stuff.
|
||||
</dt>
|
||||
</dl>
|
||||
<hr>
|
||||
<pre id="Mw_Unicode_h__MwUTF8ToUTF32">MWDECL <B><FONT COLOR="#228B22">int</FONT></B> <B><FONT COLOR="#0000FF">MwUTF8ToUTF32</FONT></B> (
|
||||
<B><FONT COLOR="#228B22">const</FONT></B> <B><FONT COLOR="#228B22">char</FONT></B>* input,
|
||||
<B><FONT COLOR="#228B22">int</FONT></B>* output
|
||||
);</pre>
|
||||
<dl>
|
||||
<dd>
|
||||
output Output.
|
||||
</dd>
|
||||
<dt>
|
||||
Returns
|
||||
</dt>
|
||||
<dd>
|
||||
Bytes this multibyte takes.
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<pre id="Mw_Unicode_h__MwUTF8Length">MWDECL <B><FONT COLOR="#228B22">int</FONT></B> <B><FONT COLOR="#0000FF">MwUTF8Length</FONT></B> (
|
||||
<B><FONT COLOR="#228B22">const</FONT></B> <B><FONT COLOR="#228B22">char</FONT></B>* input
|
||||
);</pre>
|
||||
<dl>
|
||||
<dd>
|
||||
input Input.
|
||||
</dd>
|
||||
<dt>
|
||||
Returns
|
||||
</dt>
|
||||
<dd>
|
||||
Length.
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<pre id="Mw_Unicode_h__MwUTF8Copy">MWDECL <B><FONT COLOR="#228B22">int</FONT></B> <B><FONT COLOR="#0000FF">MwUTF8Copy</FONT></B> (
|
||||
<B><FONT COLOR="#228B22">const</FONT></B> <B><FONT COLOR="#228B22">char</FONT></B>* src,
|
||||
<B><FONT COLOR="#228B22">int</FONT></B> srcskip,
|
||||
<B><FONT COLOR="#228B22">char</FONT></B>* dst,
|
||||
<B><FONT COLOR="#228B22">int</FONT></B> dstskip,
|
||||
<B><FONT COLOR="#228B22">int</FONT></B> len
|
||||
);</pre>
|
||||
<dl>
|
||||
<dd>
|
||||
len Length.
|
||||
</dd>
|
||||
<dt>
|
||||
Returns
|
||||
</dt>
|
||||
<dd>
|
||||
Copied length in bytes.
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<h2 align="center" id="Mw_Widget_Button_h">Mw/Widget/Button.h</h2>
|
||||
<dl>
|
||||
<dt>
|
||||
|
||||
@@ -360,7 +360,7 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert,
|
||||
}
|
||||
|
||||
void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color) {
|
||||
int i, x, y, sx, sy;
|
||||
int i = 0, x, y, sx, sy;
|
||||
MwRect r;
|
||||
|
||||
sx = point->x;
|
||||
@@ -374,7 +374,7 @@ void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int
|
||||
|
||||
while(text[i] != 0) {
|
||||
int out;
|
||||
i += MwUTF8ToUTF32(text, &out);
|
||||
i += MwUTF8ToUTF32(text + i, &out);
|
||||
|
||||
if(out >= 0x80) out = 0;
|
||||
|
||||
|
||||
@@ -75,14 +75,17 @@ int MwUTF8Length(const char* input) {
|
||||
return len;
|
||||
}
|
||||
|
||||
int MwUTF8Copy(const char* src, int srcskip, char* dst, int dstskip, int len){
|
||||
int MwUTF8Copy(const char* src, int srcskip, char* dst, int dstskip, int len) {
|
||||
int i;
|
||||
int out;
|
||||
int total = 0;
|
||||
for(i = 0; i < srcskip; i++) src += MwUTF8ToUTF32(src, &out);
|
||||
for(i = 0; i < dstskip; i++) dst += MwUTF8ToUTF32(dst, &out);
|
||||
for(i = 0; i < len; i++){
|
||||
int len = MwUTF8ToUTF32(src, &out);
|
||||
for(i = 0; i < len; i++) {
|
||||
int len;
|
||||
if(src[0] == 0) break;
|
||||
|
||||
len = MwUTF8ToUTF32(src, &out);
|
||||
|
||||
memcpy(dst, src, len);
|
||||
|
||||
@@ -90,7 +93,7 @@ int MwUTF8Copy(const char* src, int srcskip, char* dst, int dstskip, int len){
|
||||
dst += len;
|
||||
total += len;
|
||||
}
|
||||
dst[total] = 0;
|
||||
dst[0] = 0;
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ static int create(MwWidget handle) {
|
||||
|
||||
MwSetDefault(handle);
|
||||
|
||||
MwSetText(handle, MwNtext, "こんにちは、世界 Hello, World");
|
||||
MwLLSetCursor(handle->lowlevel, &MwCursorText, &MwCursorTextMask);
|
||||
|
||||
return 0;
|
||||
@@ -53,14 +52,12 @@ static void draw(MwWidget handle) {
|
||||
|
||||
len = (r.width - p.x * 2) / w;
|
||||
|
||||
show = malloc(len + 1);
|
||||
memset(show, 0, len + 1);
|
||||
show = malloc(len * 4 + 1);
|
||||
memset(show, 0, len * 4 + 1);
|
||||
|
||||
start = (t->cursor - 1) / len;
|
||||
start *= len;
|
||||
for(i = start; i < (int)strlen(str) && i < start + len; i++) {
|
||||
show[i - start] = str[i];
|
||||
}
|
||||
MwUTF8Copy(str, start, show, 0, len);
|
||||
|
||||
MwDrawText(handle, &p, show, 0, MwALIGNMENT_BEGINNING, text);
|
||||
|
||||
@@ -88,18 +85,13 @@ static void key(MwWidget handle, int code) {
|
||||
if(str == NULL) str = "";
|
||||
|
||||
if(code == MwLLKeyBackSpace) {
|
||||
int i, incr = 0;
|
||||
if(t->cursor == 0) return;
|
||||
out = malloc(strlen(str) + 1);
|
||||
|
||||
t->cursor--;
|
||||
|
||||
for(i = 0; str[i] != 0; i++) {
|
||||
if(i != t->cursor) {
|
||||
out[incr++] = str[i];
|
||||
}
|
||||
}
|
||||
out[incr++] = 0;
|
||||
MwUTF8Copy(str, 0, out, 0, t->cursor);
|
||||
MwUTF8Copy(str, t->cursor + 1, out, t->cursor, MwUTF8Length(str) - (t->cursor + 1));
|
||||
|
||||
MwSetText(handle, MwNtext, out);
|
||||
|
||||
@@ -108,11 +100,11 @@ static void key(MwWidget handle, int code) {
|
||||
if(t->cursor == 0) return;
|
||||
t->cursor--;
|
||||
} else if(code == MwLLKeyRight) {
|
||||
if(t->cursor == (int)strlen(str)) return;
|
||||
if(t->cursor == MwUTF8Length(str)) return;
|
||||
t->cursor++;
|
||||
} else {
|
||||
int incr = 0;
|
||||
out = malloc(strlen(str) + 1 + 1);
|
||||
out = malloc(strlen(str) + 1 + 1);
|
||||
incr += MwUTF8Copy(str, 0, out, 0, t->cursor);
|
||||
out[incr++] = code;
|
||||
MwUTF8Copy(str, t->cursor, out, t->cursor + 1, MwUTF8Length(str) - t->cursor);
|
||||
|
||||
Reference in New Issue
Block a user