shithub: microui

Download patch

ref: 14d8cf017ece030b0ebe569239cc1fe93cabda7f
parent: e7530c204ba05aaf5443803a4d235ddb2785680e
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Thu Jan 2 16:09:06 EST 2020

handle ctrl+u

--- a/demo/plan9.c
+++ b/demo/plan9.c
@@ -109,6 +109,7 @@
 			case Kshift: nkey = MU_KEY_SHIFT; break;
 			case Kbs: nkey = MU_KEY_BACKSPACE; break;
 			case '\n': nkey = MU_KEY_RETURN; break;
+			case 0x15: nkey = MU_KEY_CTRL_U; break;
 			default:
 				if (key < 0xf000 || key > 0xffff) {
 					memset(text, 0, sizeof(text));
--- a/src/microui.c
+++ b/src/microui.c
@@ -782,6 +782,10 @@
       buf[len] = '\0';
       res |= MU_RES_CHANGE;
     }
+    if (ctx->key_pressed & MU_KEY_CTRL_U && len > 0) {
+      buf[0] = '\0';
+      res |= MU_RES_CHANGE;
+    }
     /* handle return */
     if (ctx->key_pressed & MU_KEY_RETURN) {
       mu_set_focus(ctx, 0);
--- a/src/microui.h
+++ b/src/microui.h
@@ -100,7 +100,8 @@
   MU_KEY_CTRL         = (1 << 1),
   MU_KEY_ALT          = (1 << 2),
   MU_KEY_BACKSPACE    = (1 << 3),
-  MU_KEY_RETURN       = (1 << 4)
+  MU_KEY_RETURN       = (1 << 4),
+  MU_KEY_CTRL_U       = (1 << 5),
 };