#include <axwin3/richtext.h>
#include "include/internal.h"
#include <richtext_messages.h>
+#include <string.h>
+#include <wm_messages.h>
+//#include <alloca.h>
// === TYPES ===
typedef struct sRichText_Window
// === CODE ===
int AxWin3_RichText_MessageHandler(tHWND Window, int MessageID, int Size, void *Data)
{
+ tRichText_Window *info = AxWin3_int_GetDataPtr(Window);
+ struct sWndMsg_KeyAction *keyaction = Data;
+ switch(MessageID)
+ {
+ case WNDMSG_KEYFIRE:
+ if(Size < sizeof(*keyaction)) return -1;
+ info->KeyCallback(Window, 2, keyaction->KeySym, keyaction->UCS32);
+ return 1;
+ case WNDMSG_KEYDOWN:
+ if(Size < sizeof(*keyaction)) return -1;
+ info->KeyCallback(Window, 1, keyaction->KeySym, keyaction->UCS32);
+ return 1;
+ case WNDMSG_KEYUP:
+ if(Size < sizeof(*keyaction)) return -1;
+ info->KeyCallback(Window, 0, keyaction->KeySym, 0);
+ return 1;
+ }
return 0;
}
static void _SendAttrib(tHWND Window, int Attr, uint32_t Value)
{
- struct sRichTextMsg_SetAttr msg;
+ struct sRichTextIPC_SetAttr msg;
msg.Attr = Attr;
msg.Value = Value;
- AxWin3_SendMessage(Window, Window, MSG_RICHTEXT_SETATTR, sizeof(msg), &msg);
+ AxWin3_SendIPC(Window, IPC_RICHTEXT_SETATTR, sizeof(msg), &msg);
}
tHWND AxWin3_RichText_CreateWindow(tHWND Parent, int Flags)
return ;
_SendAttrib(Window, _ATTR_CURSORPOS, ((Row & 0xFFFFF) << 12) | (Column & 0xFFF));
}
+
+void AxWin3_RichText_SendLine(tHWND Window, int Line, const char *Text)
+{
+ // TODO: Local sanity check on `Line`?
+ struct sRichTextIPC_WriteLine *msg;
+ size_t len = sizeof(*msg) + strlen(Text) + 1;
+ char buffer[len];
+ msg = (void*)buffer;
+ msg->Line = Line;
+ strcpy(msg->LineData, Text);
+ AxWin3_SendIPC(Window, IPC_RICHTEXT_WRITELINE, len, msg);
+}
+