#include <common.h>
#include "./common.h"
#include "./colours.h"
-#include <utf8.h>
+#include <unicode.h>
#include <string.h>
// TODO: Include a proper keysym header
info = Element->Data = malloc(sizeof(*info));
info->DrawOfs = 0;
info->CursorXOfs = 0;
+ info->CursorByteOfs = 0;
+ info->Length = 0;
// No need to explicitly update parent min dims, as the AddElement routine does that
}
{
len = ReadUTF8Rev(Element->Text, info->CursorByteOfs, &cp);
info->CursorByteOfs -= len;
+ WM_Render_GetTextDims(
+ gpTextInput_Font,
+ Element->Text+info->CursorByteOfs,
+ len, &w, 0
+ );
+ info->CursorXOfs -= w;
}
break;
case KEYSYM_RIGHTARROW:
if( info->CursorByteOfs < info->Length )
{
len = ReadUTF8(Element->Text + info->CursorByteOfs, &cp);
+ WM_Render_GetTextDims(
+ gpTextInput_Font,
+ Element->Text+info->CursorByteOfs,
+ len, &w, 0
+ );
info->CursorByteOfs += len;
+ info->CursorXOfs += w;
}
break;
}
}
// TODO: Have a Widget_ function to do this instead
- WM_Invalidate(Element->Window);
+ WM_Invalidate(Element->Window, 1);
return 0;
}
-DEFWIDGETTYPE(ELETYPE_TEXTINPUT,
+DEFWIDGETTYPE(ELETYPE_TEXTINPUT, "TextInput",
WIDGETTYPE_FLAG_NOCHILDREN,
.Render = Widget_TextInput_Render,
.Init = Widget_TextInput_Init,