mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2025-12-31 06:30:52 +00:00
Compare commits
5 Commits
549d235893
...
72820e87f1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72820e87f1 | ||
|
|
d3147ac087 | ||
|
|
4bdda59693 | ||
|
|
823c865791 | ||
|
|
3f9125d1ae |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,6 +5,7 @@ examples/*/*.exe
|
|||||||
!examples/*/
|
!examples/*/
|
||||||
!examples/*.*
|
!examples/*.*
|
||||||
!examples/*/*.*
|
!examples/*/*.*
|
||||||
|
*.exe
|
||||||
*.o
|
*.o
|
||||||
*.so
|
*.so
|
||||||
*.dll
|
*.dll
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ void handler(MwWidget handle, void* user_data, void* call_data) {
|
|||||||
(void)handle;
|
(void)handle;
|
||||||
(void)user_data;
|
(void)user_data;
|
||||||
(void)call_data;
|
(void)call_data;
|
||||||
|
|
||||||
|
/* nishi: please rewrite this part */
|
||||||
|
/*
|
||||||
char* clipboard;
|
char* clipboard;
|
||||||
|
|
||||||
clipboard = MwLLGetClipboard(handle->lowlevel);
|
clipboard = MwLLGetClipboard(handle->lowlevel);
|
||||||
@@ -37,6 +40,7 @@ void handler(MwWidget handle, void* user_data, void* call_data) {
|
|||||||
MwVaApply(text, MwNtext, clipboard);
|
MwVaApply(text, MwNtext, clipboard);
|
||||||
MwForceRender(text);
|
MwForceRender(text);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
resize(window, NULL, NULL);
|
resize(window, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ struct _MwLLHandler {
|
|||||||
void (*key_released)(MwLL handle, void* data);
|
void (*key_released)(MwLL handle, void* data);
|
||||||
void (*focus_in)(MwLL handle, void* data);
|
void (*focus_in)(MwLL handle, void* data);
|
||||||
void (*focus_out)(MwLL handle, void* data);
|
void (*focus_out)(MwLL handle, void* data);
|
||||||
|
void (*clipboard)(MwLL handle, void* data);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -203,7 +204,7 @@ MWDECL void (*MwLLFocus)(MwLL handle);
|
|||||||
MWDECL void (*MwLLGrabPointer)(MwLL handle, int toggle);
|
MWDECL void (*MwLLGrabPointer)(MwLL handle, int toggle);
|
||||||
|
|
||||||
MWDECL void (*MwLLSetClipboard)(MwLL handle, const char* text);
|
MWDECL void (*MwLLSetClipboard)(MwLL handle, const char* text);
|
||||||
MWDECL char* (*MwLLGetClipboard)(MwLL handle);
|
MWDECL void (*MwLLGetClipboard)(MwLL handle);
|
||||||
|
|
||||||
MWDECL void (*MwLLGetCursorCoord)(MwLL handle, MwPoint* point);
|
MWDECL void (*MwLLGetCursorCoord)(MwLL handle, MwPoint* point);
|
||||||
MWDECL void (*MwLLGetScreenSize)(MwLL handle, MwRect* rect);
|
MWDECL void (*MwLLGetScreenSize)(MwLL handle, MwRect* rect);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ struct _MwLLGDI {
|
|||||||
|
|
||||||
int grabbed;
|
int grabbed;
|
||||||
int force_render;
|
int force_render;
|
||||||
|
int get_clipboard;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MwLLGDIColor {
|
struct _MwLLGDIColor {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ struct _MwLLX11 {
|
|||||||
GC gc;
|
GC gc;
|
||||||
Colormap colormap;
|
Colormap colormap;
|
||||||
Atom wm_delete;
|
Atom wm_delete;
|
||||||
|
Atom wm_protocols;
|
||||||
XIM xim;
|
XIM xim;
|
||||||
XIC xic;
|
XIC xic;
|
||||||
|
|
||||||
|
|||||||
@@ -71,5 +71,6 @@
|
|||||||
#define MwNdirectoryChosenHandler "CdirectoryChosen" /* char* */
|
#define MwNdirectoryChosenHandler "CdirectoryChosen" /* char* */
|
||||||
#define MwNcolorChosenHandler "CcolorChosen" /* MwRGB* */
|
#define MwNcolorChosenHandler "CcolorChosen" /* MwRGB* */
|
||||||
#define MwNdrawHandler "Cdraw" /* NULL */
|
#define MwNdrawHandler "Cdraw" /* NULL */
|
||||||
|
#define MwNclipboardHandler "Cclipboard" /* char* */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ typedef void (*MwHandlerChildrenProp)(MwWidget handle, MwWidget child, const cha
|
|||||||
typedef void (*MwHandlerKey)(MwWidget handle, int key);
|
typedef void (*MwHandlerKey)(MwWidget handle, int key);
|
||||||
typedef void (*MwHandlerMouse)(MwWidget handle, void* ptr);
|
typedef void (*MwHandlerMouse)(MwWidget handle, void* ptr);
|
||||||
typedef void (*MwHandlerExecute)(MwWidget handle, const char* name, void* out, va_list args);
|
typedef void (*MwHandlerExecute)(MwWidget handle, const char* name, void* out, va_list args);
|
||||||
|
typedef void (*MwHandlerClipboardReceived)(MwWidget handle, const char* data);
|
||||||
|
|
||||||
typedef void (*MwUserHandler)(MwWidget handle, void* user_data, void* call_data);
|
typedef void (*MwUserHandler)(MwWidget handle, void* user_data, void* call_data);
|
||||||
typedef void (*MwErrorHandler)(int code, const char* message, void* user_data);
|
typedef void (*MwErrorHandler)(int code, const char* message, void* user_data);
|
||||||
@@ -196,26 +197,26 @@ struct _MwListBoxPacket {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct _MwClass {
|
struct _MwClass {
|
||||||
MwHandlerWithStatus create;
|
MwHandlerWithStatus create;
|
||||||
MwHandler destroy;
|
MwHandler destroy;
|
||||||
MwHandler draw;
|
MwHandler draw;
|
||||||
MwHandler click;
|
MwHandler click;
|
||||||
MwHandler parent_resize;
|
MwHandler parent_resize;
|
||||||
MwHandlerProp prop_change;
|
MwHandlerProp prop_change;
|
||||||
MwHandler mouse_move;
|
MwHandler mouse_move;
|
||||||
MwHandlerMouse mouse_up;
|
MwHandlerMouse mouse_up;
|
||||||
MwHandlerMouse mouse_down;
|
MwHandlerMouse mouse_down;
|
||||||
MwHandlerKey key;
|
MwHandlerKey key;
|
||||||
MwHandlerExecute execute;
|
MwHandlerExecute execute;
|
||||||
MwHandler tick;
|
MwHandler tick;
|
||||||
MwHandler resize;
|
MwHandler resize;
|
||||||
MwHandler children_update;
|
MwHandler children_update;
|
||||||
MwHandlerChildrenProp children_prop_change;
|
MwHandlerChildrenProp children_prop_change;
|
||||||
void* reserved1;
|
MwHandlerClipboardReceived clipboard;
|
||||||
void* reserved2;
|
void* reserved1;
|
||||||
void* reserved3;
|
void* reserved2;
|
||||||
void* reserved4;
|
void* reserved3;
|
||||||
void* reserved5;
|
void* reserved4;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -122,6 +122,7 @@
|
|||||||
<handler name="directoryChosen" />
|
<handler name="directoryChosen" />
|
||||||
<handler name="colorChosen" />
|
<handler name="colorChosen" />
|
||||||
<handler name="draw" />
|
<handler name="draw" />
|
||||||
|
<handler name="clipboard" />
|
||||||
</properties>
|
</properties>
|
||||||
<enumerations>
|
<enumerations>
|
||||||
<enumeration name="MwDIRECTION">
|
<enumeration name="MwDIRECTION">
|
||||||
|
|||||||
@@ -237,12 +237,13 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
|||||||
r->common.copy_buffer = 1;
|
r->common.copy_buffer = 1;
|
||||||
r->common.type = MwLLBackendGDI;
|
r->common.type = MwLLBackendGDI;
|
||||||
|
|
||||||
r->gdi.force_render = 0;
|
r->gdi.get_clipboard = 1;
|
||||||
r->gdi.grabbed = 0;
|
r->gdi.force_render = 0;
|
||||||
r->gdi.hWnd = CreateWindow("milsko", "Milsko", parent == NULL ? (WS_OVERLAPPEDWINDOW) : (WS_CHILD | WS_VISIBLE), x == MwDEFAULT ? CW_USEDEFAULT : x, y == MwDEFAULT ? CW_USEDEFAULT : y, width, height, parent == NULL ? NULL : parent->gdi.hWnd, 0, wc.hInstance, NULL);
|
r->gdi.grabbed = 0;
|
||||||
r->gdi.hInstance = wc.hInstance;
|
r->gdi.hWnd = CreateWindow("milsko", "Milsko", parent == NULL ? (WS_OVERLAPPEDWINDOW) : (WS_CHILD | WS_VISIBLE), x == MwDEFAULT ? CW_USEDEFAULT : x, y == MwDEFAULT ? CW_USEDEFAULT : y, width, height, parent == NULL ? NULL : parent->gdi.hWnd, 0, wc.hInstance, NULL);
|
||||||
r->gdi.cursor = NULL;
|
r->gdi.hInstance = wc.hInstance;
|
||||||
r->gdi.icon = NULL;
|
r->gdi.cursor = NULL;
|
||||||
|
r->gdi.icon = NULL;
|
||||||
|
|
||||||
u->ll = r;
|
u->ll = r;
|
||||||
u->min_set = 0;
|
u->min_set = 0;
|
||||||
@@ -383,6 +384,7 @@ static int MwLLPendingImpl(MwLL handle) {
|
|||||||
|
|
||||||
(void)handle;
|
(void)handle;
|
||||||
|
|
||||||
|
if(handle->gdi.get_clipboard) return 1;
|
||||||
return PeekMessage(&msg, handle->gdi.hWnd, 0, 0, PM_NOREMOVE) ? 1 : 0;
|
return PeekMessage(&msg, handle->gdi.hWnd, 0, 0, PM_NOREMOVE) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,6 +393,24 @@ static void MwLLNextEventImpl(MwLL handle) {
|
|||||||
|
|
||||||
(void)handle;
|
(void)handle;
|
||||||
|
|
||||||
|
if(handle->gdi.get_clipboard) {
|
||||||
|
HGLOBAL hg;
|
||||||
|
if(OpenClipboard(handle->gdi.hWnd) != 0 && (hg = GetClipboardData(CF_TEXT)) != NULL) {
|
||||||
|
char* txt = malloc(GlobalSize(hg));
|
||||||
|
char* clp = GlobalLock(hg);
|
||||||
|
|
||||||
|
strcpy(txt, clp);
|
||||||
|
|
||||||
|
GlobalUnlock(hg);
|
||||||
|
CloseClipboard();
|
||||||
|
|
||||||
|
MwLLDispatch(handle, clipboard, txt);
|
||||||
|
|
||||||
|
free(txt);
|
||||||
|
}
|
||||||
|
|
||||||
|
handle->gdi.get_clipboard = 0;
|
||||||
|
}
|
||||||
while(PeekMessage(&msg, handle->gdi.hWnd, 0, 0, PM_NOREMOVE)) {
|
while(PeekMessage(&msg, handle->gdi.hWnd, 0, 0, PM_NOREMOVE)) {
|
||||||
GetMessage(&msg, handle->gdi.hWnd, 0, 0);
|
GetMessage(&msg, handle->gdi.hWnd, 0, 0);
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
@@ -697,21 +717,8 @@ static void MwLLSetClipboardImpl(MwLL handle, const char* text) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* MwLLGetClipboardImpl(MwLL handle) {
|
static void MwLLGetClipboardImpl(MwLL handle) {
|
||||||
HGLOBAL hg;
|
handle->gdi.get_clipboard = 1; /* nishi: we do this to make clipboard api work similar to other backends */
|
||||||
char* r = NULL;
|
|
||||||
if(OpenClipboard(handle->gdi.hWnd) != 0 && (hg = GetClipboardData(CF_TEXT)) != NULL) {
|
|
||||||
char* lock;
|
|
||||||
|
|
||||||
r = malloc(GlobalSize(hg));
|
|
||||||
|
|
||||||
lock = GlobalLock(hg);
|
|
||||||
strcpy(r, lock);
|
|
||||||
GlobalUnlock(hg);
|
|
||||||
|
|
||||||
CloseClipboard();
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLMakeToolWindowImpl(MwLL handle) {
|
static void MwLLMakeToolWindowImpl(MwLL handle) {
|
||||||
|
|||||||
@@ -209,8 +209,9 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
|||||||
r->x11.grabbed = 0;
|
r->x11.grabbed = 0;
|
||||||
r->x11.force_render = 0;
|
r->x11.force_render = 0;
|
||||||
|
|
||||||
r->x11.colormap = DefaultColormap(r->x11.display, XDefaultScreen(r->x11.display));
|
r->x11.colormap = DefaultColormap(r->x11.display, XDefaultScreen(r->x11.display));
|
||||||
r->x11.wm_delete = XInternAtom(r->x11.display, "WM_DELETE_WINDOW", False);
|
r->x11.wm_delete = XInternAtom(r->x11.display, "WM_DELETE_WINDOW", False);
|
||||||
|
r->x11.wm_protocols = XInternAtom(r->x11.display, "WM_PROTOCOLS", False);
|
||||||
XSetWMProtocols(r->x11.display, r->x11.window, &r->x11.wm_delete, 1);
|
XSetWMProtocols(r->x11.display, r->x11.window, &r->x11.wm_delete, 1);
|
||||||
|
|
||||||
r->x11.gc = XCreateGC(r->x11.display, r->x11.window, 0, NULL);
|
r->x11.gc = XCreateGC(r->x11.display, r->x11.window, 0, NULL);
|
||||||
@@ -471,7 +472,7 @@ static void MwLLNextEventImpl(MwLL handle) {
|
|||||||
handle->x11.width = ev.xconfigure.width;
|
handle->x11.width = ev.xconfigure.width;
|
||||||
handle->x11.height = ev.xconfigure.height;
|
handle->x11.height = ev.xconfigure.height;
|
||||||
} else if(ev.type == ClientMessage) {
|
} else if(ev.type == ClientMessage) {
|
||||||
if(ev.xclient.data.l[0] == (long)handle->x11.wm_delete) {
|
if(ev.xclient.message_type == handle->x11.wm_protocols && ev.xclient.data.l[0] == (long)handle->x11.wm_delete) {
|
||||||
MwLLDispatch(handle, close, NULL);
|
MwLLDispatch(handle, close, NULL);
|
||||||
}
|
}
|
||||||
} else if(ev.type == FocusIn) {
|
} else if(ev.type == FocusIn) {
|
||||||
@@ -956,45 +957,10 @@ static void MwLLSetClipboardImpl(MwLL handle, const char* text) {
|
|||||||
(void)text;
|
(void)text;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* MwLLGetClipboardImpl(MwLL handle) {
|
static void MwLLGetClipboardImpl(MwLL handle) {
|
||||||
Atom clip, target, prop;
|
/* TODO */
|
||||||
XEvent ev;
|
|
||||||
XEvent* queue = NULL;
|
|
||||||
char* r = NULL;
|
|
||||||
|
|
||||||
clip = XInternAtom(handle->x11.display, "CLIPBOARD", 0);
|
(void)handle;
|
||||||
target = XA_STRING;
|
|
||||||
prop = XInternAtom(handle->x11.display, "XSEL_DATA", 0);
|
|
||||||
|
|
||||||
XConvertSelection(handle->x11.display, clip, target, prop, handle->x11.window, CurrentTime);
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
XNextEvent(handle->x11.display, &ev);
|
|
||||||
if(ev.type == SelectionNotify) {
|
|
||||||
if(ev.xselection.selection == clip && ev.xselection.property != 0) {
|
|
||||||
Atom t;
|
|
||||||
unsigned long size, N;
|
|
||||||
char* data;
|
|
||||||
int format;
|
|
||||||
|
|
||||||
XGetWindowProperty(ev.xselection.display, ev.xselection.requestor, ev.xselection.property, 0, (~0L), 0, AnyPropertyType, &t, &format, &size, &N, (unsigned char**)&data);
|
|
||||||
if(t == target) {
|
|
||||||
r = MwStringDuplicate(data);
|
|
||||||
XFree(data);
|
|
||||||
}
|
|
||||||
XDeleteProperty(ev.xselection.display, ev.xselection.requestor, ev.xselection.property);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while(arrlen(queue) > 0) {
|
|
||||||
XPutBackEvent(handle->x11.display, &queue[0]);
|
|
||||||
arrdel(queue, 0);
|
|
||||||
}
|
|
||||||
arrfree(queue);
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLMakeToolWindowImpl(MwLL handle) {
|
static void MwLLMakeToolWindowImpl(MwLL handle) {
|
||||||
|
|||||||
11
src/core.c
11
src/core.c
@@ -107,6 +107,13 @@ static void llfocusouthandler(MwLL handle, void* data) {
|
|||||||
MwDispatchUserHandler(h, MwNfocusOutHandler, data);
|
MwDispatchUserHandler(h, MwNfocusOutHandler, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void llclipboardhandler(MwLL handle, void* data) {
|
||||||
|
MwWidget h = (MwWidget)handle->common.user;
|
||||||
|
|
||||||
|
MwDispatch3(h, clipboard, data);
|
||||||
|
MwDispatchUserHandler(h, MwNclipboardHandler, data);
|
||||||
|
}
|
||||||
|
|
||||||
MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height) {
|
MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height) {
|
||||||
MwWidget h = malloc(sizeof(*h));
|
MwWidget h = malloc(sizeof(*h));
|
||||||
|
|
||||||
@@ -148,6 +155,7 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent,
|
|||||||
h->lowlevel->common.handler->key_released = llkeyrelhandler;
|
h->lowlevel->common.handler->key_released = llkeyrelhandler;
|
||||||
h->lowlevel->common.handler->focus_in = llfocusinhandler;
|
h->lowlevel->common.handler->focus_in = llfocusinhandler;
|
||||||
h->lowlevel->common.handler->focus_out = llfocusouthandler;
|
h->lowlevel->common.handler->focus_out = llfocusouthandler;
|
||||||
|
h->lowlevel->common.handler->clipboard = llclipboardhandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(parent != NULL) arrput(parent->children, h);
|
if(parent != NULL) arrput(parent->children, h);
|
||||||
@@ -387,6 +395,9 @@ void MwSetInteger(MwWidget handle, const char* key, int n) {
|
|||||||
MwDispatch3(handle, prop_change, key);
|
MwDispatch3(handle, prop_change, key);
|
||||||
if(handle->parent != NULL) MwDispatch4(handle->parent, children_prop_change, handle, key);
|
if(handle->parent != NULL) MwDispatch4(handle->parent, children_prop_change, handle, key);
|
||||||
}
|
}
|
||||||
|
if(strcmp(key, MwNforceInverted) == 0) {
|
||||||
|
MwForceRender(handle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwSetText(MwWidget handle, const char* key, const char* value) {
|
void MwSetText(MwWidget handle, const char* key, const char* value) {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ void (*MwLLFocus)(MwLL handle);
|
|||||||
void (*MwLLGrabPointer)(MwLL handle, int toggle);
|
void (*MwLLGrabPointer)(MwLL handle, int toggle);
|
||||||
|
|
||||||
void (*MwLLSetClipboard)(MwLL handle, const char* text);
|
void (*MwLLSetClipboard)(MwLL handle, const char* text);
|
||||||
char* (*MwLLGetClipboard)(MwLL handle);
|
void (*MwLLGetClipboard)(MwLL handle);
|
||||||
|
|
||||||
void (*MwLLGetCursorCoord)(MwLL handle, MwPoint* point);
|
void (*MwLLGetCursorCoord)(MwLL handle, MwPoint* point);
|
||||||
void (*MwLLGetScreenSize)(MwLL handle, MwRect* rect);
|
void (*MwLLGetScreenSize)(MwLL handle, MwRect* rect);
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ MwClassRec MwBoxClassRec = {
|
|||||||
resize, /* resize */
|
resize, /* resize */
|
||||||
children_update, /* children_update */
|
children_update, /* children_update */
|
||||||
children_prop_change, /* children_prop_change */
|
children_prop_change, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ MwClassRec MwButtonClassRec = {
|
|||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ MwClassRec MwCheckBoxClassRec = {
|
|||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ MwClassRec MwComboBoxClassRec = {
|
|||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -109,20 +109,7 @@ static void key(MwWidget handle, int code) {
|
|||||||
} else if(code == MwLLKeyEnter) {
|
} else if(code == MwLLKeyEnter) {
|
||||||
MwDispatchUserHandler(handle, MwNactivateHandler, NULL);
|
MwDispatchUserHandler(handle, MwNactivateHandler, NULL);
|
||||||
} else if(code == (MwLLControlMask | 'v')) {
|
} else if(code == (MwLLControlMask | 'v')) {
|
||||||
char* c = MwLLGetClipboard(handle->lowlevel);
|
MwLLGetClipboard(handle->lowlevel);
|
||||||
if(c != NULL) {
|
|
||||||
char* out = malloc(strlen(str) + strlen(c) + 1);
|
|
||||||
|
|
||||||
MwUTF8Copy(str, 0, out, 0, t->cursor);
|
|
||||||
MwUTF8Copy(c, 0, out, t->cursor, MwUTF8Length(c));
|
|
||||||
MwUTF8Copy(str, t->cursor, out, t->cursor + MwUTF8Length(c), MwUTF8Length(str) - t->cursor);
|
|
||||||
|
|
||||||
t->cursor += MwUTF8Length(c);
|
|
||||||
|
|
||||||
MwSetText(handle, MwNtext, out);
|
|
||||||
free(out);
|
|
||||||
free(c);
|
|
||||||
}
|
|
||||||
} else if(!(code & MwLLKeyMask)) {
|
} else if(!(code & MwLLKeyMask)) {
|
||||||
int incr = 0;
|
int incr = 0;
|
||||||
out = malloc(strlen(str) + 5 + 1);
|
out = malloc(strlen(str) + 5 + 1);
|
||||||
@@ -157,6 +144,23 @@ static void prop_change(MwWidget handle, const char* prop) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void clipboard(MwWidget handle, const char* data) {
|
||||||
|
MwEntry t = handle->internal;
|
||||||
|
const char* str = MwGetText(handle, MwNtext);
|
||||||
|
char* out = malloc(strlen(str) + strlen(data) + 1);
|
||||||
|
|
||||||
|
if(str == NULL) str = "";
|
||||||
|
|
||||||
|
MwUTF8Copy(str, 0, out, 0, t->cursor);
|
||||||
|
MwUTF8Copy(data, 0, out, t->cursor, MwUTF8Length(data));
|
||||||
|
MwUTF8Copy(str, t->cursor, out, t->cursor + MwUTF8Length(data), MwUTF8Length(str) - t->cursor);
|
||||||
|
|
||||||
|
t->cursor += MwUTF8Length(data);
|
||||||
|
|
||||||
|
MwSetText(handle, MwNtext, out);
|
||||||
|
free(out);
|
||||||
|
}
|
||||||
|
|
||||||
MwClassRec MwEntryClassRec = {
|
MwClassRec MwEntryClassRec = {
|
||||||
create, /* create */
|
create, /* create */
|
||||||
destroy, /* destroy */
|
destroy, /* destroy */
|
||||||
@@ -173,7 +177,7 @@ MwClassRec MwEntryClassRec = {
|
|||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
clipboard, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ MwClassRec MwFrameClassRec = {
|
|||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ MwClassRec MwImageClassRec = {
|
|||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -375,7 +375,7 @@ MwClassRec MwLabelClassRec = {
|
|||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -608,7 +608,7 @@ MwClassRec MwListBoxClassRec = {
|
|||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ MwClassRec MwMenuClassRec = {
|
|||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ MwClassRec MwNumberEntryClassRec = {
|
|||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ MwClassRec MwOpenGLClassRec = {
|
|||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ MwClassRec MwProgressBarClassRec = {
|
|||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ MwClassRec MwRadioBoxClassRec = {
|
|||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ MwClassRec MwScrollBarClassRec = {
|
|||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ MwClassRec MwSeparatorClassRec = {
|
|||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ MwClassRec MwSubMenuClassRec = {
|
|||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -496,7 +496,7 @@ MwClassRec MwTreeViewClassRec = {
|
|||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ MwClassRec MwViewportClassRec = {
|
|||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -524,7 +524,7 @@ MwClassRec MwVulkanClassRec = {
|
|||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ MwClassRec MwWindowClassRec = {
|
|||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
Reference in New Issue
Block a user