Usermode/axwin3 - RichText cursor (hacked)
[tpg/acess2.git] / Usermode / Applications / axwin3_src / libaxwin3.so_src / r_richtext.c
index 74b437b..9fed544 100644 (file)
@@ -9,6 +9,9 @@
 #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
@@ -21,15 +24,25 @@ 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;
+       _SysDebug("MessageID = %i", MessageID);
+       switch(MessageID)
+       {
+       case WNDMSG_KEYFIRE:
+               if(Size < sizeof(*keyaction))   return -1;
+               info->KeyCallback(Window, 2, keyaction->KeySym, keyaction->UCS32);
+               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)
@@ -89,3 +102,16 @@ void AxWin3_RichText_SetCursorPos(tHWND Window, int Row, int Column)
                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);
+}
+

UCC git Repository :: git.ucc.asn.au