clipboard refactoring
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good

This commit is contained in:
IoI_xD 2026-04-15 10:58:46 -07:00
commit b641a03bae
12 changed files with 116 additions and 73 deletions

View file

@ -1,6 +1,6 @@
#include <Mw/Milsko.h>
MwWidget window, instructions, text;
MwWidget window, instructions, text1, text2, cur_text;
static void resize(MwWidget handle, void* user_data, void* call_data) {
unsigned int w, h;
@ -17,9 +17,14 @@ static void resize(MwWidget handle, void* user_data, void* call_data) {
MwNheight, h - 125 - 50 * 3,
NULL);
MwVaApply(text,
MwNy, 200,
MwNwidth, w - 50 * 2,
MwVaApply(text1,
MwNy, 150,
MwNwidth, w - 25 * 2,
MwNheight, h - 125 - 50 * 3,
NULL);
MwVaApply(text2,
MwNy, 250,
MwNwidth, w - 25 * 2,
MwNheight, h - 125 - 50 * 3,
NULL);
}
@ -30,14 +35,17 @@ static void clipboard(MwWidget handle, void* user_data, void* call_data) {
(void)user_data;
if(clipboard != NULL) {
MwVaApply(text, MwNtext, clipboard, NULL);
MwForceRender(text);
MwVaApply(cur_text, MwNtext, clipboard, NULL);
MwForceRender(cur_text);
}
MwForceRender(window);
}
static void tick(MwWidget handle, void* user_data, void* call_data) {
MwGetClipboard(handle);
cur_text = text1;
MwGetClipboard(handle, MwClipboardMain);
cur_text = text2;
MwGetClipboard(handle, MwClipboardPrimary);
MwForceRender(window);
}
int main() {
@ -49,14 +57,19 @@ int main() {
instructions = MwVaCreateWidget(MwLabelClass, "button", window, 50, 50, 300, 125,
MwNtext, "clipboard contents will show up below.",
NULL);
text = MwVaCreateWidget(MwLabelClass, "label", window, 50, 200, 300, 125,
text1 = MwVaCreateWidget(MwLabelClass, "label", window, 25, 150, 300, 75,
MwNtext, "",
NULL);
text2 = MwVaCreateWidget(MwLabelClass, "label2", window, 25, 250, 300, 75,
MwNtext, "",
NULL);
cur_text = text1;
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
MwAddUserHandler(window, MwNclipboardHandler, clipboard, NULL);
MwAddUserHandler(instructions, MwNclipboardHandler, clipboard, NULL);
MwAddUserHandler(text, MwNclipboardHandler, clipboard, NULL);
MwAddUserHandler(cur_text, MwNclipboardHandler, clipboard, NULL);
MwAddUserHandler(window, MwNtickHandler, tick, NULL);
resize(window, NULL, NULL);